|
...
|
...
|
@@ -52,18 +52,18 @@ class KeywordLogic extends BaseLogic |
|
|
|
DB::beginTransaction();
|
|
|
|
try {
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
$route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $this->param['id'], $this->user['project_id']);
|
|
|
|
$id = $this->editCategoryRoute($this->param['id'],$route);
|
|
|
|
$this->model->edit($this->param,['id'=>$id]);
|
|
|
|
$info = $this->model->read(['id'=>$this->param['id']],['id','route']);
|
|
|
|
$route = $info['route'];
|
|
|
|
$this->model->edit($this->param,['id'=>$info['id']]);
|
|
|
|
}else{
|
|
|
|
$this->param['project_id'] = $this->user['project_id'];
|
|
|
|
$this->param['created_at'] = date('Y-m-d H:i:s');
|
|
|
|
$this->param['updated_at'] = $this->param['created_at'];
|
|
|
|
$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]);
|
|
|
|
}
|
|
|
|
//路由映射
|
|
|
|
$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']);
|
|
|
|
DB::commit();
|
|
...
|
...
|
@@ -77,26 +77,6 @@ class KeywordLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :编辑路由时生成路由记录
|
|
|
|
* @name :editCategoryRoute
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/9/7 10:51
|
|
|
|
*/
|
|
|
|
public function editCategoryRoute($id,$route){
|
|
|
|
//生成一条删除路由记录
|
|
|
|
$info = $this->model->read(['id'=>$id],['id','route']);
|
|
|
|
if($info['route'] != $route){
|
|
|
|
$data = [
|
|
|
|
'source'=>RouteMap::SOURCE_PRODUCT_KEYWORD,
|
|
|
|
'route'=>$info['route'],
|
|
|
|
];
|
|
|
|
$this->setRouteDeleteSave($data);
|
|
|
|
}
|
|
|
|
return $id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :批量添加数据
|
|
|
|
* @name :batchAdd
|
|
|
|
* @author :lyh
|
...
|
...
|
|