作者 lyh

gx

... ... @@ -354,7 +354,25 @@ class BlogCategoryLogic extends BaseLogic
}
$return[] = $c_id;
}
return ','.implode(',',$return).',';
return $this->getLastCategory($return);
}
/**
* @remark :获取最后一级分类id
* @name :getLastCategory
* @author :lyh
* @method :post
* @time :2023/10/20 9:02
*/
public function getLastCategory($category){
$str = '';
foreach ($category as $v){
$info = $this->model->read(['pid'=>$v]);
if($info === false){
$str .= $v.',';
}
}
return ','.$str;
}
/**
... ...
... ... @@ -336,7 +336,25 @@ class NewsCategoryLogic extends BaseLogic
}
$return[] = $c_id;
}
return ','.implode(',',$return).',';
return $this->getLastCategory($return);
}
/**
* @remark :获取最后一级分类id
* @name :getLastCategory
* @author :lyh
* @method :post
* @time :2023/10/20 9:02
*/
public function getLastCategory($category){
$str = '';
foreach ($category as $v){
$info = $this->model->read(['pid'=>$v]);
if($info === false){
$str .= $v.',';
}
}
return ','.$str;
}
/**
... ...
... ... @@ -59,8 +59,8 @@ class NewsLogic extends BaseLogic
public function newsSave()
{
//拼接参数
// DB::beginTransaction();
// try {
DB::beginTransaction();
try {
$this->param = $this->paramProcessing($this->param);
if (isset($this->param['id']) && !empty($this->param['id'])) {
//是否更新路由
... ... @@ -72,11 +72,11 @@ class NewsLogic extends BaseLogic
//更新路由
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
$this->edit(['url' => $route], ['id' => $id]);
// DB::commit();
// } catch (\Exception $e) {
// DB::rollBack();
// $this->fail('系统错误,请联系管理员');
// }
DB::commit();
} catch (\Exception $e) {
DB::rollBack();
$this->fail('系统错误,请联系管理员');
}
//通知更新
$this->updateNotify(['project_id' => $this->user['project_id'], 'type' => RouteMap::SOURCE_NEWS, 'route' => $route]);
return $this->success();
... ...
... ... @@ -319,10 +319,29 @@ class CategoryLogic extends BaseLogic
}
$return[] = $c_id;
}
//清除缓存
Common::del_user_cache('product_category',$project_id);
return ','.implode(',',$return).',';
return $this->getLastCategory($return);
}
/**
* @remark :获取最后一级分类id
* @name :getLastCategory
* @author :lyh
* @method :post
* @time :2023/10/20 9:02
*/
public function getLastCategory($category){
$str = '';
if(isset($category) && !empty($category)){
foreach ($category as $v){
$info = $this->model->read(['pid'=>$v]);
if($info === false){
$str .= $v.',';
}
}
}
return ','.$str;
}
/**
... ...