|
...
|
...
|
@@ -42,6 +42,53 @@ class CategoryLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name :(添加/编辑分类时获取级分类)categoryTopList
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/13 9:09
|
|
|
|
*/
|
|
|
|
public function categoryTopList(){
|
|
|
|
$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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取详情
|
|
|
|
* @name :getInfo
|
|
|
|
* @author :lyh
|
...
|
...
|
|