作者 lyh

gx

@@ -354,7 +354,25 @@ class BlogCategoryLogic extends BaseLogic @@ -354,7 +354,25 @@ class BlogCategoryLogic extends BaseLogic
354 } 354 }
355 $return[] = $c_id; 355 $return[] = $c_id;
356 } 356 }
357 - return ','.implode(',',$return).','; 357 + return $this->getLastCategory($return);
  358 + }
  359 +
  360 + /**
  361 + * @remark :获取最后一级分类id
  362 + * @name :getLastCategory
  363 + * @author :lyh
  364 + * @method :post
  365 + * @time :2023/10/20 9:02
  366 + */
  367 + public function getLastCategory($category){
  368 + $str = '';
  369 + foreach ($category as $v){
  370 + $info = $this->model->read(['pid'=>$v]);
  371 + if($info === false){
  372 + $str .= $v.',';
  373 + }
  374 + }
  375 + return ','.$str;
358 } 376 }
359 377
360 /** 378 /**
@@ -336,7 +336,25 @@ class NewsCategoryLogic extends BaseLogic @@ -336,7 +336,25 @@ class NewsCategoryLogic extends BaseLogic
336 } 336 }
337 $return[] = $c_id; 337 $return[] = $c_id;
338 } 338 }
339 - return ','.implode(',',$return).','; 339 + return $this->getLastCategory($return);
  340 + }
  341 +
  342 + /**
  343 + * @remark :获取最后一级分类id
  344 + * @name :getLastCategory
  345 + * @author :lyh
  346 + * @method :post
  347 + * @time :2023/10/20 9:02
  348 + */
  349 + public function getLastCategory($category){
  350 + $str = '';
  351 + foreach ($category as $v){
  352 + $info = $this->model->read(['pid'=>$v]);
  353 + if($info === false){
  354 + $str .= $v.',';
  355 + }
  356 + }
  357 + return ','.$str;
340 } 358 }
341 359
342 /** 360 /**
@@ -59,8 +59,8 @@ class NewsLogic extends BaseLogic @@ -59,8 +59,8 @@ class NewsLogic extends BaseLogic
59 public function newsSave() 59 public function newsSave()
60 { 60 {
61 //拼接参数 61 //拼接参数
62 -// DB::beginTransaction();  
63 -// try { 62 + DB::beginTransaction();
  63 + try {
64 $this->param = $this->paramProcessing($this->param); 64 $this->param = $this->paramProcessing($this->param);
65 if (isset($this->param['id']) && !empty($this->param['id'])) { 65 if (isset($this->param['id']) && !empty($this->param['id'])) {
66 //是否更新路由 66 //是否更新路由
@@ -72,11 +72,11 @@ class NewsLogic extends BaseLogic @@ -72,11 +72,11 @@ class NewsLogic extends BaseLogic
72 //更新路由 72 //更新路由
73 $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $id, $this->user['project_id']); 73 $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
74 $this->edit(['url' => $route], ['id' => $id]); 74 $this->edit(['url' => $route], ['id' => $id]);
75 -// DB::commit();  
76 -// } catch (\Exception $e) {  
77 -// DB::rollBack();  
78 -// $this->fail('系统错误,请联系管理员');  
79 -// } 75 + DB::commit();
  76 + } catch (\Exception $e) {
  77 + DB::rollBack();
  78 + $this->fail('系统错误,请联系管理员');
  79 + }
80 //通知更新 80 //通知更新
81 $this->updateNotify(['project_id' => $this->user['project_id'], 'type' => RouteMap::SOURCE_NEWS, 'route' => $route]); 81 $this->updateNotify(['project_id' => $this->user['project_id'], 'type' => RouteMap::SOURCE_NEWS, 'route' => $route]);
82 return $this->success(); 82 return $this->success();
@@ -319,10 +319,29 @@ class CategoryLogic extends BaseLogic @@ -319,10 +319,29 @@ class CategoryLogic extends BaseLogic
319 } 319 }
320 $return[] = $c_id; 320 $return[] = $c_id;
321 } 321 }
322 -  
323 //清除缓存 322 //清除缓存
324 Common::del_user_cache('product_category',$project_id); 323 Common::del_user_cache('product_category',$project_id);
325 - return ','.implode(',',$return).','; 324 + return $this->getLastCategory($return);
  325 + }
  326 +
  327 + /**
  328 + * @remark :获取最后一级分类id
  329 + * @name :getLastCategory
  330 + * @author :lyh
  331 + * @method :post
  332 + * @time :2023/10/20 9:02
  333 + */
  334 + public function getLastCategory($category){
  335 + $str = '';
  336 + if(isset($category) && !empty($category)){
  337 + foreach ($category as $v){
  338 + $info = $this->model->read(['pid'=>$v]);
  339 + if($info === false){
  340 + $str .= $v.',';
  341 + }
  342 + }
  343 + }
  344 + return ','.$str;
326 } 345 }
327 346
328 /** 347 /**