正在显示
1 个修改的文件
包含
5 行增加
和
18 行删除
| @@ -29,31 +29,18 @@ class KeywordPrefixLogic extends BaseLogic | @@ -29,31 +29,18 @@ class KeywordPrefixLogic extends BaseLogic | ||
| 29 | * @time :2023/9/6 14:42 | 29 | * @time :2023/9/6 14:42 |
| 30 | */ | 30 | */ |
| 31 | public function prefixSave(){ | 31 | public function prefixSave(){ |
| 32 | - if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 33 | - $condition = [ | ||
| 34 | - 'keyword'=>$this->param['keyword'], | ||
| 35 | - 'id'=>['!=',$this->param['id']] | ||
| 36 | - ]; | ||
| 37 | - $prefixInfo = $this->model->read($condition); | ||
| 38 | - if($prefixInfo !== false){ | ||
| 39 | - $this->fail('当前关键字已存在'); | ||
| 40 | - } | ||
| 41 | - $data = [ | ||
| 42 | - 'keyword'=>$this->param['keyword'] | ||
| 43 | - ]; | ||
| 44 | - $this->model->edit($data,['id'=>$this->param['id']]); | ||
| 45 | - }else{ | 32 | + $keyword_arr = explode(',',$this->param['keyword']); |
| 33 | + foreach ($keyword_arr as $v){ | ||
| 46 | $data = [ | 34 | $data = [ |
| 47 | 'project_id'=>$this->param['project_id'] ?? 0, | 35 | 'project_id'=>$this->param['project_id'] ?? 0, |
| 48 | - 'keyword'=>$this->param['keyword'], | 36 | + 'keyword'=>$v, |
| 49 | 'type'=>$this->param['type'] | 37 | 'type'=>$this->param['type'] |
| 50 | ]; | 38 | ]; |
| 51 | $prefixInfo = $this->model->read($data); | 39 | $prefixInfo = $this->model->read($data); |
| 52 | - if($prefixInfo !== false){ | ||
| 53 | - $this->fail('当前关键字已存在'); | ||
| 54 | - } | 40 | + if($prefixInfo == false){ |
| 55 | $this->model->add($data); | 41 | $this->model->add($data); |
| 56 | } | 42 | } |
| 43 | + } | ||
| 57 | return $this->success(); | 44 | return $this->success(); |
| 58 | } | 45 | } |
| 59 | 46 |
-
请 注册 或 登录 后发表评论