|
...
|
...
|
@@ -39,11 +39,11 @@ class NewsCategoryLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name :详情
|
|
|
|
* @return array
|
|
|
|
* @throws \App\Exceptions\BsideGlobalException
|
|
|
|
* @author :liyuhang
|
|
|
|
* @method
|
|
|
|
* @remark :获取详情
|
|
|
|
* @name :info_news_category
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/19 16:04
|
|
|
|
*/
|
|
|
|
public function info_news_category(){
|
|
|
|
$info = $this->model->read($this->param);
|
|
...
|
...
|
@@ -118,9 +118,6 @@ class NewsCategoryLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function verifyEditParam($id,$pid){
|
|
|
|
$info = $this->model->read(['id'=>$id]);
|
|
|
|
if($info['id'] == $pid){
|
|
|
|
$this->fail('不能成为自己的上级');
|
|
|
|
}
|
|
|
|
if($info['pid'] != $pid){
|
|
|
|
$info = $this->model->read(['pid'=>$id]);
|
|
|
|
if($info !== false){
|
|
...
|
...
|
@@ -166,7 +163,7 @@ class NewsCategoryLogic extends BaseLogic |
|
|
|
$newsModel = new NewsModel();
|
|
|
|
$rs = $newsModel->read(['category_id'=>$id],['id']);
|
|
|
|
if($rs !== false){
|
|
|
|
$this->fail('当前分类拥有商品');
|
|
|
|
$this->fail('当前分类拥有商品,不允许删除');
|
|
|
|
}
|
|
|
|
$this->delRoute($id);
|
|
|
|
$this->model->del(['id'=>$id]);
|
|
...
|
...
|
@@ -181,13 +178,44 @@ class NewsCategoryLogic extends BaseLogic |
|
|
|
* @time :2023/6/13 9:09
|
|
|
|
*/
|
|
|
|
public function categoryTopList(){
|
|
|
|
$map = [
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'pid'=>0,
|
|
|
|
'status'=>0,
|
|
|
|
];
|
|
|
|
$list = $this->model->list($map);
|
|
|
|
return $this->success($list);
|
|
|
|
$this->param['project_id'] = $this->user['project_id'];
|
|
|
|
$this->param['status'] = 0;
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
$str = [];
|
|
|
|
//排序掉当前id下所有子集
|
|
|
|
$str = $this->getAllSub($this->param['id'],$str);
|
|
|
|
$str[] = (int)$this->param['id'];
|
|
|
|
$this->param['id'] = ['not in',$str];
|
|
|
|
}
|
|
|
|
$menu = array();
|
|
|
|
$list = $this->model->list($this->param);
|
|
|
|
if(!empty($list)){
|
|
|
|
foreach ($list as $k => $v){
|
|
|
|
if($v['pid'] == 0){
|
|
|
|
$v['sub'] = _get_child($v['id'],$list);
|
|
|
|
$menu[] = $v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->success($menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取当前id下所有子集
|
|
|
|
* @name :getAllSub
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/18 15:10
|
|
|
|
*/
|
|
|
|
public function getAllSub($id,&$str = []){
|
|
|
|
$list = $this->model->list(['pid'=>$id,'status'=>0],['id','pid']);
|
|
|
|
if(!empty($list)){
|
|
|
|
foreach ($list as $v){
|
|
|
|
$str[] = $v['id'];
|
|
|
|
$this->getAllSub($v['id'],$str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $str;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
|