|
...
|
...
|
@@ -44,11 +44,10 @@ class NewsCategoryLogic extends BaseLogic |
|
|
|
DB::beginTransaction();
|
|
|
|
try {
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
$this->param['operator_id'] = $this->user['id'];
|
|
|
|
//查看路由是否更新
|
|
|
|
$id = $this->param['id'];
|
|
|
|
$this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $this->param['id'], $this->user['project_id']);
|
|
|
|
$this->editCategoryRoute($this->param['id'],$this->param['alias']);
|
|
|
|
$this->editHandleCategory($this->param['id'],$this->param['pid']);
|
|
|
|
$this->param['operator_id'] = $this->user['id'];
|
|
|
|
$this->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
}else{
|
|
|
|
if(!isset($this->param['alias']) || empty($this->param['alias'])){
|
|
...
|
...
|
@@ -56,18 +55,17 @@ class NewsCategoryLogic extends BaseLogic |
|
|
|
}
|
|
|
|
$this->param = $this->addParamProcessing($this->param);
|
|
|
|
$id = $this->model->addReturnId($this->param);
|
|
|
|
$route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
|
|
|
|
$this->addUpdateNotify(RouteMap::SOURCE_NEWS_CATE,$route);
|
|
|
|
$this->model->edit(['alias'=>$route],['id'=>$id]);
|
|
|
|
//当父级分类拥有产品时,处理子集
|
|
|
|
$this->addProcessingSon($id);
|
|
|
|
}
|
|
|
|
$route = RouteMap::setRoute($this->param['alias'], 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('系统错误,请联系管理员');
|
|
|
|
}
|
|
|
|
//更新通知记录表
|
|
|
|
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS_CATE, 'route'=>$route]);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -124,22 +122,19 @@ class NewsCategoryLogic extends BaseLogic |
|
|
|
//生成一条删除路由记录
|
|
|
|
$info = $this->model->read(['id'=>$id],['id','alias']);
|
|
|
|
if($info['alias'] != $route){
|
|
|
|
$data = [
|
|
|
|
'source'=>RouteMap::SOURCE_NEWS_CATE,
|
|
|
|
'route'=>$info['alias'],
|
|
|
|
];
|
|
|
|
$this->setRouteDeleteSave($data);
|
|
|
|
$this->addUpdateNotify(RouteMap::SOURCE_NEWS_CATE,$route);
|
|
|
|
$this->curlDelRoute($info['alias']);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name :修改状态
|
|
|
|
* @return array
|
|
|
|
* @throws \App\Exceptions\BsideGlobalException
|
|
|
|
* @author :liyuhang
|
|
|
|
* @method
|
|
|
|
* @remark :修改状态
|
|
|
|
* @name :status_news_category
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/11/30 15:13
|
|
|
|
*/
|
|
|
|
public function status_news_category(){
|
|
|
|
$this->param['operator_id'] = $this->user['id'];
|
|
...
|
...
|
@@ -291,13 +286,8 @@ class NewsCategoryLogic extends BaseLogic |
|
|
|
public function delRoute($id){
|
|
|
|
//删除路由映射
|
|
|
|
RouteMap::delRoute(RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
|
|
|
|
//生成一条删除路由记录
|
|
|
|
$info = $this->model->read(['id'=>$id],['id','alias']);
|
|
|
|
$data = [
|
|
|
|
'source'=>RouteMap::SOURCE_NEWS_CATE,
|
|
|
|
'route'=>$info['alias'],
|
|
|
|
];
|
|
|
|
$this->setRouteDeleteSave($data);
|
|
|
|
$this->curlDelRoute($info['alias']);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -313,22 +303,18 @@ class NewsCategoryLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function importNewsCategory($project_id,$user_id,$category){
|
|
|
|
$return = [];
|
|
|
|
|
|
|
|
$cate_arr = explode('/',$category);
|
|
|
|
|
|
|
|
$pid = 0;
|
|
|
|
foreach ($cate_arr as $v){
|
|
|
|
if($v){
|
|
|
|
$category_info = $this->model->read(['name'=>$v,'pid'=>$pid]);
|
|
|
|
if(!$category_info){
|
|
|
|
$id = $this->model->addReturnId(['name'=>$v,'pid'=>$pid,'project_id'=>$project_id,'operator_id'=>$user_id,'create_id'=>$user_id]);
|
|
|
|
|
|
|
|
$route = RouteMap::setRoute($v, RouteMap::SOURCE_NEWS_CATE, $id, $project_id);
|
|
|
|
$this->model->edit(['alias'=>$route],['id'=>$id]);
|
|
|
|
}else{
|
|
|
|
$id = $category_info['id'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$return[] = $id;
|
|
|
|
$pid = $id;
|
|
|
|
}
|
...
|
...
|
|