正在显示
2 个修改的文件
包含
32 行增加
和
16 行删除
| @@ -77,24 +77,21 @@ class ServerConfigLogic extends BaseLogic | @@ -77,24 +77,21 @@ class ServerConfigLogic extends BaseLogic | ||
| 77 | DB::beginTransaction(); | 77 | DB::beginTransaction(); |
| 78 | try { | 78 | try { |
| 79 | //保存配置 | 79 | //保存配置 |
| 80 | - $this->param['created_at'] = date('Y-m-d H:i:s'); | ||
| 81 | - $this->param['updated_at'] = $this->param['created_at']; | ||
| 82 | - $res = $this->model->insertGetId($this->param); | ||
| 83 | - if ($this->param['type'] == ServerConfig::TYPE_SERVER) { | ||
| 84 | - $data['serve_id'] = $res; | 80 | + if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 81 | + $this->param['updated_at'] = date('Y-m-d H:i:s'); | ||
| 82 | + $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 85 | }else{ | 83 | }else{ |
| 86 | - $data['mysql_id'] = $res; | 84 | + $this->param['created_at'] = date('Y-m-d H:i:s'); |
| 85 | + $this->param['updated_at'] = $this->param['created_at']; | ||
| 86 | + $res = $this->model->insertGetId($this->param); | ||
| 87 | + if ($this->param['type'] == ServerConfig::TYPE_SERVER) { | ||
| 88 | + $data['serve_id'] = $res; | ||
| 89 | + }else{ | ||
| 90 | + $data['mysql_id'] = $res; | ||
| 91 | + } | ||
| 92 | + $project->edit($data,['id'=>$this->param['project_id']]); | ||
| 87 | } | 93 | } |
| 88 | - $project->edit($data,['id'=>$this->param['project_id']]); | ||
| 89 | //初始化数据库 | 94 | //初始化数据库 |
| 90 | -// if ($param['type'] == ServerConfig::TYPE_MYSQL) { | ||
| 91 | -// //切换数据库配置 | ||
| 92 | -// $project = ProjectServer::useProject($param['project_id']); | ||
| 93 | -// //创建数据库 | ||
| 94 | -// ProjectServer::createDatabase($project); | ||
| 95 | -// //创建表 | ||
| 96 | -// ProjectServer::initTable($project); | ||
| 97 | -// } | ||
| 98 | DB::commit(); | 95 | DB::commit(); |
| 99 | } catch (\Exception $e) { | 96 | } catch (\Exception $e) { |
| 100 | DB::rollBack(); | 97 | DB::rollBack(); |
| @@ -104,6 +101,25 @@ class ServerConfigLogic extends BaseLogic | @@ -104,6 +101,25 @@ class ServerConfigLogic extends BaseLogic | ||
| 104 | } | 101 | } |
| 105 | 102 | ||
| 106 | /** | 103 | /** |
| 104 | + * @remark :初始化数据库 | ||
| 105 | + * @name :initializationMysql | ||
| 106 | + * @author :lyh | ||
| 107 | + * @method :post | ||
| 108 | + * @time :2023/8/4 15:08 | ||
| 109 | + */ | ||
| 110 | + public function initializationMysql($param){ | ||
| 111 | + if ($param['type'] == ServerConfig::TYPE_MYSQL) { | ||
| 112 | + //切换数据库配置 | ||
| 113 | + $project = ProjectServer::useProject($param['project_id']); | ||
| 114 | + //创建数据库 | ||
| 115 | + ProjectServer::createDatabase($project); | ||
| 116 | + //创建表 | ||
| 117 | + ProjectServer::initTable($project); | ||
| 118 | + } | ||
| 119 | + return true; | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + /** | ||
| 107 | * @remark :删除记录 | 123 | * @remark :删除记录 |
| 108 | * @name :delServiceConfig | 124 | * @name :delServiceConfig |
| 109 | * @author :lyh | 125 | * @author :lyh |
-
请 注册 或 登录 后发表评论