作者 lyh

gx

... ... @@ -57,9 +57,9 @@ class NewsCategoryLogic extends BaseLogic
*/
public function newsCategorySave(){
//验证名称是否存在
// $this->verifyParamName($this->param['name']);
// DB::beginTransaction();
// try {
$this->verifyParamName($this->param['name']);
DB::beginTransaction();
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
//验证是否可编辑
$this->verifyEditParam($this->param['id'],$this->param['pid']);
... ... @@ -68,17 +68,18 @@ class NewsCategoryLogic extends BaseLogic
$id = $this->editCategoryRoute($this->param['id'],$this->param['alias']);
$this->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->param = $this->addParamProcessing($this->param);
$id = $this->model->addReturnId($this->param);
//当父级分类拥有产品时,处理子集
$this->addProcessingSon($id);
}
$route = RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
$this->model->edit(['alias'=>$route],['id'=>$id]);
// DB::commit();
// }catch (\Exception $e){
// DB::rollBack();
// $this->fail('error');
// }
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('error');
}
//更新通知记录表
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS_CATE, 'route'=>$route]);
return $this->success();
... ... @@ -205,6 +206,18 @@ class NewsCategoryLogic extends BaseLogic
return $this->success();
}
/**
* @name :(参数处理)paramProcessing
* @author :lyh
* @method :post
* @time :2023/6/13 11:30
*/
public function addParamProcessing($param){
$param['project_id'] = $this->user['project_id'];
$param['operator_id'] = $this->user['id'];
$param['create_id'] = $this->user['id'];
return $this->success($param);
}
/**
* @name :(添加分类时处理子集分类)addProcessingSon
... ...