新增获取全部人员、获取某个部门下的人员、获取某个岗位下的人员接口
This commit is contained in:
parent
bfb2e312d6
commit
3dc5e2e47f
@ -134,4 +134,69 @@ class AdminController extends BaseAdminController
|
||||
$result = AdminLogic::editSelf($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
//获取所有人员
|
||||
public function getAdminsByAll(): \think\response\Json
|
||||
{
|
||||
$data = Admin::field('id,name,avatar,org_id,dept_id,job_id')->select()->each(function($item){
|
||||
$job = Jobs::field('name')->where('id',$item['job_id'])->findOrEmpty();
|
||||
$dept = Dept::field('name')->where('id',$item['dept_id'])->findOrEmpty();
|
||||
$org = Orgs::field('name')->where('id',$item['org_id'])->findOrEmpty();
|
||||
$item['job_name'] = $job->isEmpty() ? '' : $job['name'];
|
||||
$item['dept_name'] = $dept->isEmpty() ? '' : $dept['name'];
|
||||
$item['org_name'] = $org->isEmpty() ? '' : $org['name'];
|
||||
unset($item['org_id'],$item['dept_id'],$item['job_id']);
|
||||
return $item;
|
||||
})->toArray();
|
||||
foreach($data as $k=>$v){
|
||||
unset($data[$k]['role_id']);
|
||||
}
|
||||
return $this->success('请求成功',$data);
|
||||
}
|
||||
|
||||
//获取某个部门下的所有人员
|
||||
public function getAdminsByDept(): \think\response\Json
|
||||
{
|
||||
$dept_id = $this->request->get('dept_id');
|
||||
if(empty($dept_id)){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$data = Admin::field('id,name,avatar,org_id,dept_id,job_id')->where('dept_id',$dept_id)->select()->each(function($item){
|
||||
$job = Jobs::field('name')->where('id',$item['job_id'])->findOrEmpty();
|
||||
$dept = Dept::field('name')->where('id',$item['dept_id'])->findOrEmpty();
|
||||
$org = Orgs::field('name')->where('id',$item['org_id'])->findOrEmpty();
|
||||
$item['job_name'] = $job->isEmpty() ? '' : $job['name'];
|
||||
$item['dept_name'] = $dept->isEmpty() ? '' : $dept['name'];
|
||||
$item['org_name'] = $org->isEmpty() ? '' : $org['name'];
|
||||
unset($item['org_id'],$item['dept_id'],$item['job_id']);
|
||||
return $item;
|
||||
})->toArray();
|
||||
foreach($data as $k=>$v){
|
||||
unset($data[$k]['role_id']);
|
||||
}
|
||||
return $this->success('请求成功',$data);
|
||||
}
|
||||
|
||||
//获取某个岗位下的所有人员
|
||||
public function getAdminsByJob(): \think\response\Json
|
||||
{
|
||||
$job_id = $this->request->get('job_id');
|
||||
if(empty($job_id)){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$data = Admin::field('id,name,avatar,org_id,dept_id,job_id')->where('job_id',$job_id)->select()->each(function($item){
|
||||
$job = Jobs::field('name')->where('id',$item['job_id'])->findOrEmpty();
|
||||
$dept = Dept::field('name')->where('id',$item['dept_id'])->findOrEmpty();
|
||||
$org = Orgs::field('name')->where('id',$item['org_id'])->findOrEmpty();
|
||||
$item['job_name'] = $job->isEmpty() ? '' : $job['name'];
|
||||
$item['dept_name'] = $dept->isEmpty() ? '' : $dept['name'];
|
||||
$item['org_name'] = $org->isEmpty() ? '' : $org['name'];
|
||||
unset($item['org_id'],$item['dept_id'],$item['job_id']);
|
||||
return $item;
|
||||
})->toArray();
|
||||
foreach($data as $k=>$v){
|
||||
unset($data[$k]['role_id']);
|
||||
}
|
||||
return $this->success('请求成功',$data);
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ use app\common\logic\BaseLogic;
|
||||
use app\common\model\article\Article;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dept\Jobs;
|
||||
use app\common\model\dept\Orgs;
|
||||
use app\common\service\FileService;
|
||||
|
||||
|
||||
@ -99,7 +100,10 @@ class JobsLogic extends BaseLogic
|
||||
return [];
|
||||
}
|
||||
$dept = Dept::where('id',$jobs['dept_id'])->findOrEmpty();
|
||||
$org = Orgs::where('id',$dept['org_id'])->findOrEmpty();
|
||||
$jobs['dept_name'] = $dept->isEmpty() ? '' : $dept['name'];
|
||||
$jobs['org_id'] = $org->isEmpty() ? 0 : $org['id'];
|
||||
$jobs['org_name'] = $org->isEmpty() ? '' : $org['name'];
|
||||
$jobs['status_text'] = $jobs->status_text;
|
||||
return $jobs->toArray();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user