正在显示
1 个修改的文件
包含
10 行增加
和
7 行删除
| @@ -53,14 +53,20 @@ class KeywordLogic extends BaseLogic | @@ -53,14 +53,20 @@ class KeywordLogic extends BaseLogic | ||
| 53 | * @time :2023/8/23 16:50 | 53 | * @time :2023/8/23 16:50 |
| 54 | */ | 54 | */ |
| 55 | public function keywordSave(){ | 55 | public function keywordSave(){ |
| 56 | - DB::beginTransaction(); | ||
| 57 | - try { | ||
| 58 | $this->param = $this->handleSaveParam($this->param); | 56 | $this->param = $this->handleSaveParam($this->param); |
| 59 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 57 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 58 | + $info = $this->model->read(['title'=>$this->param['title'],'id'=>['!=',$this->param['id']]]); | ||
| 59 | + if($info !== false){ | ||
| 60 | + $this->fail('当前title已存在'); | ||
| 61 | + } | ||
| 60 | //TODO::不能修改路由 | 62 | //TODO::不能修改路由 |
| 61 | $this->model->edit($this->param,['id'=>$this->param['id']]); | 63 | $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 62 | $route = RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD,$this->param['id'], $this->user['project_id']); | 64 | $route = RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD,$this->param['id'], $this->user['project_id']); |
| 63 | }else{ | 65 | }else{ |
| 66 | + $info = $this->model->read(['title'=>$this->param['title']]); | ||
| 67 | + if($info !== false){ | ||
| 68 | + $this->fail('当前title已存在'); | ||
| 69 | + } | ||
| 64 | $this->param = $this->addHandleParam($this->param); | 70 | $this->param = $this->addHandleParam($this->param); |
| 65 | $id = $this->model->insertGetId($this->param); | 71 | $id = $this->model->insertGetId($this->param); |
| 66 | //路由映射 | 72 | //路由映射 |
| @@ -69,16 +75,13 @@ class KeywordLogic extends BaseLogic | @@ -69,16 +75,13 @@ class KeywordLogic extends BaseLogic | ||
| 69 | } | 75 | } |
| 70 | // //清除缓存 | 76 | // //清除缓存 |
| 71 | Common::del_user_cache('product_keyword',$this->user['project_id']); | 77 | Common::del_user_cache('product_keyword',$this->user['project_id']); |
| 72 | - DB::commit(); | ||
| 73 | - }catch (\Exception $e){ | ||
| 74 | - DB::rollBack(); | ||
| 75 | - $this->fail('保存失败'); | ||
| 76 | - } | ||
| 77 | $this->addUpdateNotify(RouteMap::SOURCE_PRODUCT_KEYWORD,$route); | 78 | $this->addUpdateNotify(RouteMap::SOURCE_PRODUCT_KEYWORD,$route); |
| 78 | $this->curlDelRoute(['new_route'=>$route]); | 79 | $this->curlDelRoute(['new_route'=>$route]); |
| 79 | return $this->success(); | 80 | return $this->success(); |
| 80 | } | 81 | } |
| 81 | 82 | ||
| 83 | + | ||
| 84 | + | ||
| 82 | /** | 85 | /** |
| 83 | * @remark :添加组装数据 | 86 | * @remark :添加组装数据 |
| 84 | * @name :addHandleParam | 87 | * @name :addHandleParam |
-
请 注册 或 登录 后发表评论