|
...
|
...
|
@@ -77,24 +77,21 @@ class ServerConfigLogic extends BaseLogic |
|
|
|
DB::beginTransaction();
|
|
|
|
try {
|
|
|
|
//保存配置
|
|
|
|
$this->param['created_at'] = date('Y-m-d H:i:s');
|
|
|
|
$this->param['updated_at'] = $this->param['created_at'];
|
|
|
|
$res = $this->model->insertGetId($this->param);
|
|
|
|
if ($this->param['type'] == ServerConfig::TYPE_SERVER) {
|
|
|
|
$data['serve_id'] = $res;
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
$this->param['updated_at'] = date('Y-m-d H:i:s');
|
|
|
|
$this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
}else{
|
|
|
|
$data['mysql_id'] = $res;
|
|
|
|
$this->param['created_at'] = date('Y-m-d H:i:s');
|
|
|
|
$this->param['updated_at'] = $this->param['created_at'];
|
|
|
|
$res = $this->model->insertGetId($this->param);
|
|
|
|
if ($this->param['type'] == ServerConfig::TYPE_SERVER) {
|
|
|
|
$data['serve_id'] = $res;
|
|
|
|
}else{
|
|
|
|
$data['mysql_id'] = $res;
|
|
|
|
}
|
|
|
|
$project->edit($data,['id'=>$this->param['project_id']]);
|
|
|
|
}
|
|
|
|
$project->edit($data,['id'=>$this->param['project_id']]);
|
|
|
|
//初始化数据库
|
|
|
|
// if ($param['type'] == ServerConfig::TYPE_MYSQL) {
|
|
|
|
// //切换数据库配置
|
|
|
|
// $project = ProjectServer::useProject($param['project_id']);
|
|
|
|
// //创建数据库
|
|
|
|
// ProjectServer::createDatabase($project);
|
|
|
|
// //创建表
|
|
|
|
// ProjectServer::initTable($project);
|
|
|
|
// }
|
|
|
|
DB::commit();
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
DB::rollBack();
|
|
...
|
...
|
@@ -104,6 +101,25 @@ class ServerConfigLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :初始化数据库
|
|
|
|
* @name :initializationMysql
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/8/4 15:08
|
|
|
|
*/
|
|
|
|
public function initializationMysql($param){
|
|
|
|
if ($param['type'] == ServerConfig::TYPE_MYSQL) {
|
|
|
|
//切换数据库配置
|
|
|
|
$project = ProjectServer::useProject($param['project_id']);
|
|
|
|
//创建数据库
|
|
|
|
ProjectServer::createDatabase($project);
|
|
|
|
//创建表
|
|
|
|
ProjectServer::initTable($project);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :删除记录
|
|
|
|
* @name :delServiceConfig
|
|
|
|
* @author :lyh
|
...
|
...
|
|