正在显示
1 个修改的文件
包含
22 行增加
和
19 行删除
| @@ -53,32 +53,35 @@ class KeywordLogic extends BaseLogic | @@ -53,32 +53,35 @@ 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); | ||
| 59 | - if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 60 | - //TODO::不能修改路由 | ||
| 61 | - $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 62 | - $route = RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD,$this->param['id'], $this->user['project_id']); | ||
| 63 | - }else{ | ||
| 64 | - $this->param = $this->addHandleParam($this->param); | ||
| 65 | - $id = $this->model->insertGetId($this->param); | ||
| 66 | - //路由映射 | ||
| 67 | - $route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); | ||
| 68 | - $this->model->edit(['route'=>$route],['id'=>$id]); | 56 | + $this->param = $this->handleSaveParam($this->param); |
| 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已存在'); | ||
| 69 | } | 61 | } |
| 70 | -// //清除缓存 | ||
| 71 | - Common::del_user_cache('product_keyword',$this->user['project_id']); | ||
| 72 | - DB::commit(); | ||
| 73 | - }catch (\Exception $e){ | ||
| 74 | - DB::rollBack(); | ||
| 75 | - $this->fail('保存失败'); | 62 | + //TODO::不能修改路由 |
| 63 | + $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 64 | + $route = RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD,$this->param['id'], $this->user['project_id']); | ||
| 65 | + }else{ | ||
| 66 | + $info = $this->model->read(['title'=>$this->param['title']]); | ||
| 67 | + if($info !== false){ | ||
| 68 | + $this->fail('当前title已存在'); | ||
| 69 | + } | ||
| 70 | + $this->param = $this->addHandleParam($this->param); | ||
| 71 | + $id = $this->model->insertGetId($this->param); | ||
| 72 | + //路由映射 | ||
| 73 | + $route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); | ||
| 74 | + $this->model->edit(['route'=>$route],['id'=>$id]); | ||
| 76 | } | 75 | } |
| 76 | +// //清除缓存 | ||
| 77 | + Common::del_user_cache('product_keyword',$this->user['project_id']); | ||
| 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 |
-
请 注册 或 登录 后发表评论