|
...
|
...
|
@@ -67,25 +67,23 @@ class ServerConfigLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/8/2 17:55
|
|
|
|
*/
|
|
|
|
public function save($param)
|
|
|
|
public function serviceConfigSave()
|
|
|
|
{
|
|
|
|
$project_logic = new ProjectLogic();
|
|
|
|
$project = $project_logic->getCacheInfo($param['project_id']);
|
|
|
|
if(!$project){
|
|
|
|
$project = new Project();
|
|
|
|
$project_list = $project->read(['id'=>$this->param['project_id']]);
|
|
|
|
if($project_list === false){
|
|
|
|
$this->fail('项目不存在或者已经删除');
|
|
|
|
}
|
|
|
|
DB::beginTransaction();
|
|
|
|
try {
|
|
|
|
//保存配置
|
|
|
|
$res = parent::save($param);
|
|
|
|
//关联到项目
|
|
|
|
$data['id'] = $param['project_id'];
|
|
|
|
if ($param['type'] == ServerConfig::TYPE_SERVER) {
|
|
|
|
$res = $this->model->add($this->param);
|
|
|
|
if ($this->param['type'] == ServerConfig::TYPE_SERVER) {
|
|
|
|
$data['serve_id'] = $res['id'];
|
|
|
|
}else{
|
|
|
|
$data['mysql_id'] = $res['id'];
|
|
|
|
}
|
|
|
|
$project_logic->save($data);
|
|
|
|
$project->edit($data,['id'=>$this->param['project_id']]);
|
|
|
|
//初始化数据库
|
|
|
|
// if ($param['type'] == ServerConfig::TYPE_MYSQL) {
|
|
|
|
// //切换数据库配置
|
|
...
|
...
|
@@ -98,7 +96,6 @@ class ServerConfigLogic extends BaseLogic |
|
|
|
DB::commit();
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
DB::rollBack();
|
|
|
|
errorLog('项目运维服务配置保存失败', $param, $e);
|
|
|
|
$this->fail('保存失败');
|
|
|
|
}
|
|
|
|
return $this->success();
|
...
|
...
|
|