|
...
|
...
|
@@ -53,32 +53,35 @@ class KeywordLogic extends BaseLogic |
|
|
|
* @time :2023/8/23 16:50
|
|
|
|
*/
|
|
|
|
public function keywordSave(){
|
|
|
|
DB::beginTransaction();
|
|
|
|
try {
|
|
|
|
$this->param = $this->handleSaveParam($this->param);
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
//TODO::不能修改路由
|
|
|
|
$this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
$route = RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD,$this->param['id'], $this->user['project_id']);
|
|
|
|
}else{
|
|
|
|
$this->param = $this->addHandleParam($this->param);
|
|
|
|
$id = $this->model->insertGetId($this->param);
|
|
|
|
//路由映射
|
|
|
|
$route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
|
|
|
|
$this->model->edit(['route'=>$route],['id'=>$id]);
|
|
|
|
$this->param = $this->handleSaveParam($this->param);
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
$info = $this->model->read(['title'=>$this->param['title'],'id'=>['!=',$this->param['id']]]);
|
|
|
|
if($info !== false){
|
|
|
|
$this->fail('当前title已存在');
|
|
|
|
}
|
|
|
|
// //清除缓存
|
|
|
|
Common::del_user_cache('product_keyword',$this->user['project_id']);
|
|
|
|
DB::commit();
|
|
|
|
}catch (\Exception $e){
|
|
|
|
DB::rollBack();
|
|
|
|
$this->fail('保存失败');
|
|
|
|
//TODO::不能修改路由
|
|
|
|
$this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
$route = RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD,$this->param['id'], $this->user['project_id']);
|
|
|
|
}else{
|
|
|
|
$info = $this->model->read(['title'=>$this->param['title']]);
|
|
|
|
if($info !== false){
|
|
|
|
$this->fail('当前title已存在');
|
|
|
|
}
|
|
|
|
$this->param = $this->addHandleParam($this->param);
|
|
|
|
$id = $this->model->insertGetId($this->param);
|
|
|
|
//路由映射
|
|
|
|
$route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
|
|
|
|
$this->model->edit(['route'=>$route],['id'=>$id]);
|
|
|
|
}
|
|
|
|
// //清除缓存
|
|
|
|
Common::del_user_cache('product_keyword',$this->user['project_id']);
|
|
|
|
$this->addUpdateNotify(RouteMap::SOURCE_PRODUCT_KEYWORD,$route);
|
|
|
|
$this->curlDelRoute(['new_route'=>$route]);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :添加组装数据
|
|
|
|
* @name :addHandleParam
|
...
|
...
|
|