正在显示
1 个修改的文件
包含
21 行增加
和
4 行删除
| @@ -49,12 +49,15 @@ class CustomModuleLogic extends BaseLogic | @@ -49,12 +49,15 @@ class CustomModuleLogic extends BaseLogic | ||
| 49 | * @time :2023/12/4 15:47 | 49 | * @time :2023/12/4 15:47 |
| 50 | */ | 50 | */ |
| 51 | public function customModuleSave(){ | 51 | public function customModuleSave(){ |
| 52 | + ProjectServer::useProject($this->param['project_id']); | ||
| 52 | $this->param = $this->handleParam($this->param); | 53 | $this->param = $this->handleParam($this->param); |
| 54 | + $this->checkIsName($this->param['name'],$this->param['id'] ?? 0); | ||
| 53 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 55 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 54 | $this->moduleEdit(); | 56 | $this->moduleEdit(); |
| 55 | }else{ | 57 | }else{ |
| 56 | $this->moduleAdd(); | 58 | $this->moduleAdd(); |
| 57 | } | 59 | } |
| 60 | + DB::disconnect('custom_mysql'); | ||
| 58 | return $this->success(); | 61 | return $this->success(); |
| 59 | } | 62 | } |
| 60 | 63 | ||
| @@ -81,12 +84,10 @@ class CustomModuleLogic extends BaseLogic | @@ -81,12 +84,10 @@ class CustomModuleLogic extends BaseLogic | ||
| 81 | * @time :2023/12/5 9:39 | 84 | * @time :2023/12/5 9:39 |
| 82 | */ | 85 | */ |
| 83 | public function moduleAdd(){ | 86 | public function moduleAdd(){ |
| 84 | - ProjectServer::useProject($this->param['project_id']); | ||
| 85 | $rs = (new CustomModule())->add($this->param); | 87 | $rs = (new CustomModule())->add($this->param); |
| 86 | if($rs === false){ | 88 | if($rs === false){ |
| 87 | $this->fail('系统错误,请联系管理员'); | 89 | $this->fail('系统错误,请联系管理员'); |
| 88 | } | 90 | } |
| 89 | - DB::disconnect('custom_mysql'); | ||
| 90 | return $this->success(); | 91 | return $this->success(); |
| 91 | } | 92 | } |
| 92 | 93 | ||
| @@ -98,16 +99,32 @@ class CustomModuleLogic extends BaseLogic | @@ -98,16 +99,32 @@ class CustomModuleLogic extends BaseLogic | ||
| 98 | * @time :2023/12/5 9:39 | 99 | * @time :2023/12/5 9:39 |
| 99 | */ | 100 | */ |
| 100 | public function moduleEdit(){ | 101 | public function moduleEdit(){ |
| 101 | - ProjectServer::useProject($this->param['project_id']); | ||
| 102 | $rs = (new CustomModule())->edit($this->param,['id'=>$this->param['id']]); | 102 | $rs = (new CustomModule())->edit($this->param,['id'=>$this->param['id']]); |
| 103 | if($rs === false){ | 103 | if($rs === false){ |
| 104 | $this->fail('系统错误,请联系管理员'); | 104 | $this->fail('系统错误,请联系管理员'); |
| 105 | } | 105 | } |
| 106 | - DB::disconnect('custom_mysql'); | ||
| 107 | return $this->success(); | 106 | return $this->success(); |
| 108 | } | 107 | } |
| 109 | 108 | ||
| 110 | /** | 109 | /** |
| 110 | + * @remark :验证名称是否存在 | ||
| 111 | + * @name :checkIsName | ||
| 112 | + * @author :lyh | ||
| 113 | + * @method :post | ||
| 114 | + * @time :2024/1/6 14:06 | ||
| 115 | + */ | ||
| 116 | + public function checkIsName($name,$id = 0){ | ||
| 117 | + $param['name'] = $name; | ||
| 118 | + if(!empty($id)){ | ||
| 119 | + $param['id'] = ['id'=>['!=',$id],]; | ||
| 120 | + } | ||
| 121 | + $info = (new CustomModule())->read($param); | ||
| 122 | + if($info !== false){ | ||
| 123 | + $this->fail('当前名称已存在'); | ||
| 124 | + } | ||
| 125 | + return $this->success(); | ||
| 126 | + } | ||
| 127 | + /** | ||
| 111 | * @remark :删除数据 | 128 | * @remark :删除数据 |
| 112 | * @name :ModuleDel | 129 | * @name :ModuleDel |
| 113 | * @author :lyh | 130 | * @author :lyh |
-
请 注册 或 登录 后发表评论