作者 lyh

gx

@@ -64,7 +64,7 @@ class ServerConfigController extends BaseController @@ -64,7 +64,7 @@ class ServerConfigController extends BaseController
64 * @date 2023/4/23 64 * @date 2023/4/23
65 */ 65 */
66 public function save(ServerConfigRequest $request, ServerConfigLogic $logic){ 66 public function save(ServerConfigRequest $request, ServerConfigLogic $logic){
67 - $data = $logic->save($this->param); 67 + $data = $logic->serviceConfigSave($this->param);
68 return $this->success($data); 68 return $this->success($data);
69 } 69 }
70 70
@@ -67,25 +67,23 @@ class ServerConfigLogic extends BaseLogic @@ -67,25 +67,23 @@ class ServerConfigLogic extends BaseLogic
67 * @method :post 67 * @method :post
68 * @time :2023/8/2 17:55 68 * @time :2023/8/2 17:55
69 */ 69 */
70 - public function save($param) 70 + public function serviceConfigSave()
71 { 71 {
72 - $project_logic = new ProjectLogic();  
73 - $project = $project_logic->getCacheInfo($param['project_id']);  
74 - if(!$project){ 72 + $project = new Project();
  73 + $project_list = $project->read(['id'=>$this->param['project_id']]);
  74 + if($project_list === false){
75 $this->fail('项目不存在或者已经删除'); 75 $this->fail('项目不存在或者已经删除');
76 } 76 }
77 DB::beginTransaction(); 77 DB::beginTransaction();
78 try { 78 try {
79 //保存配置 79 //保存配置
80 - $res = parent::save($param);  
81 - //关联到项目  
82 - $data['id'] = $param['project_id'];  
83 - if ($param['type'] == ServerConfig::TYPE_SERVER) { 80 + $res = $this->model->add($this->param);
  81 + if ($this->param['type'] == ServerConfig::TYPE_SERVER) {
84 $data['serve_id'] = $res['id']; 82 $data['serve_id'] = $res['id'];
85 }else{ 83 }else{
86 $data['mysql_id'] = $res['id']; 84 $data['mysql_id'] = $res['id'];
87 } 85 }
88 - $project_logic->save($data); 86 + $project->edit($data,['id'=>$this->param['project_id']]);
89 //初始化数据库 87 //初始化数据库
90 // if ($param['type'] == ServerConfig::TYPE_MYSQL) { 88 // if ($param['type'] == ServerConfig::TYPE_MYSQL) {
91 // //切换数据库配置 89 // //切换数据库配置
@@ -98,7 +96,6 @@ class ServerConfigLogic extends BaseLogic @@ -98,7 +96,6 @@ class ServerConfigLogic extends BaseLogic
98 DB::commit(); 96 DB::commit();
99 } catch (\Exception $e) { 97 } catch (\Exception $e) {
100 DB::rollBack(); 98 DB::rollBack();
101 - errorLog('项目运维服务配置保存失败', $param, $e);  
102 $this->fail('保存失败'); 99 $this->fail('保存失败');
103 } 100 }
104 return $this->success(); 101 return $this->success();