作者 lyh

gx

... ... @@ -30,14 +30,30 @@ class KeywordPrefixLogic extends BaseLogic
* @time :2023/9/6 14:42
*/
public function prefixSave(){
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->model->add($this->param);
if(isset($this->param['id']) && !empty($this->param['id'])){
$condition = [
'keyword'=>$this->param['keyword'],
'id'=>['!=',$this->param['id']]
];
$prefixInfo = $this->model->read($condition);
if($prefixInfo !== false){
$this->fail('当前关键字已存在');
}
}catch (\Exception $e){
$this->fail('error');
$data = [
'keyword'=>$this->param['keyword']
];
$this->model->edit($data,['id'=>$this->param['id']]);
}else{
$data = [
'project_id'=>$this->param['project_id'] ?? 0,
'keyword'=>$this->param['keyword'],
'type'=>$this->param['type']
];
$prefixInfo = $this->model->read($data);
if($prefixInfo !== false){
$this->fail('当前关键字已存在');
}
$this->model->add($data);
}
return $this->success();
}
... ...