This commit is contained in:
weiz 2024-05-28 10:57:29 +08:00
parent 32cb4992ee
commit aaf7a2e40f

View File

@ -154,7 +154,12 @@ class AdminController extends BaseAdminController
//获取所有人员
public function getAdminsByAll(): \think\response\Json
{
$data = Admin::field('id,name,avatar,org_id,dept_id,job_id')->select()->each(function($item){
$params = $this->request->get(['exclude_id']);
$where = [];
if(!empty($params['exclude_id'])){
$where[] = ['id','<>',$params['exclude_id']];
}
$data = Admin::field('id,name,avatar,org_id,dept_id,job_id')->where($where)->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();
@ -172,11 +177,15 @@ class AdminController extends BaseAdminController
//获取某个部门下的所有人员
public function getAdminsByDept(): \think\response\Json
{
$dept_id = $this->request->get('dept_id');
if(empty($dept_id)){
$params = $this->request->get(['dept_id','exclude_id']);
if(empty($params['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){
$where = [];
if(!empty($params['exclude_id'])){
$where[] = ['id','<>',$params['exclude_id']];
}
$data = Admin::field('id,name,avatar,org_id,dept_id,job_id')->where('dept_id',$params['dept_id'])->where($where)->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();
@ -194,11 +203,15 @@ class AdminController extends BaseAdminController
//获取某个岗位下的所有人员
public function getAdminsByJob(): \think\response\Json
{
$job_id = $this->request->get('job_id');
if(empty($job_id)){
$params = $this->request->get(['job_id','exclude_id']);
if(empty($params['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){
$where = [];
if(!empty($params['exclude_id'])){
$where[] = ['id','<>',$params['exclude_id']];
}
$data = Admin::field('id,name,avatar,org_id,dept_id,job_id')->where('job_id',$params['job_id'])->where($where)->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();