作者 lyh

gx指令

@@ -29,30 +29,17 @@ class KeywordPrefixLogic extends BaseLogic @@ -29,30 +29,17 @@ 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('当前关键字已存在'); 40 + if($prefixInfo == false){
  41 + $this->model->add($data);
54 } 42 }
55 - $this->model->add($data);  
56 } 43 }
57 return $this->success(); 44 return $this->success();
58 } 45 }