接口修改4

This commit is contained in:
彭桃 2023-01-31 17:09:14 +08:00
parent 62a174c0d9
commit b3cdc4f743
2 changed files with 12 additions and 3 deletions

View File

@ -322,7 +322,12 @@ class Common extends BaseController
if ($id==0 && $type==''){ if ($id==0 && $type==''){
return $this->apiError('参数不能为空,请填写参数'); return $this->apiError('参数不能为空,请填写参数');
} }
if($pid){
$where[]=['pid','=',$pid]; $where[]=['pid','=',$pid];
}else{
$where[]=['pid','<>',0];
}
$where[]=['status','=','normal']; $where[]=['status','=','normal'];
$select=Db::table('fa_category')->where($where)->select(); $select=Db::table('fa_category')->where($where)->select();
return $this->apiSuccess('ok',$select); return $this->apiSuccess('ok',$select);
@ -359,7 +364,11 @@ class Common extends BaseController
if ($id==0 && $type==''){ if ($id==0 && $type==''){
return $this->apiError('参数不能为空,请填写参数'); return $this->apiError('参数不能为空,请填写参数');
} }
if($pid){
$where[]=['pid','=',$pid]; $where[]=['pid','=',$pid];
}else{
$where[]=['pid','<>',0];
}
$where[]=['status','=','normal']; $where[]=['status','=','normal'];
$select=Db::table('fa_category')->where($where)->field('id as category_id,name as topic_name,image as pic,pid')->select()->toArray(); $select=Db::table('fa_category')->where($where)->field('id as category_id,name as topic_name,image as pic,pid')->select()->toArray();
foreach ($select as $k=>$v){ foreach ($select as $k=>$v){