Merge pull request '新增获取所有人员接口' (#10) from zhangwei into dev
Reviewed-on: #10
This commit is contained in:
commit
2d6d34fc3c
@ -19,6 +19,10 @@ use app\adminapi\lists\auth\AdminLists;
|
||||
use app\adminapi\validate\auth\AdminValidate;
|
||||
use app\adminapi\logic\auth\AdminLogic;
|
||||
use app\adminapi\validate\auth\editSelfValidate;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dept\Jobs;
|
||||
use app\common\model\dept\Orgs;
|
||||
|
||||
/**
|
||||
* 管理员控制器
|
||||
@ -130,5 +134,43 @@ class AdminController extends BaseAdminController
|
||||
$result = AdminLogic::editSelf($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
// 获取所有人员
|
||||
public function getAllAdmins(): \think\response\Json
|
||||
{
|
||||
$data = Admin::field('id,name,avatar')->select()->toArray();
|
||||
// 组织列表
|
||||
$orgLists = Orgs::column('name', 'id');
|
||||
// 部门列表
|
||||
$deptLists = Dept::column('name', 'id');
|
||||
// 岗位列表
|
||||
$jobsLists = Jobs::column('name', 'id');
|
||||
//管理员列表增加角色名称
|
||||
foreach ($data as $k => $v) {
|
||||
$orgName = '';
|
||||
foreach ($v['org_id'] as $orgId) {
|
||||
$orgName .= $orgLists[$orgId] ?? '';
|
||||
$orgName .= '/';
|
||||
}
|
||||
$deptName = '';
|
||||
foreach ($v['dept_id'] as $deptId) {
|
||||
$deptName .= $deptLists[$deptId] ?? '';
|
||||
$deptName .= '/';
|
||||
}
|
||||
$jobsName = '';
|
||||
foreach ($v['jobs_id'] as $jobsId) {
|
||||
$jobsName .= $jobsLists[$jobsId] ?? '';
|
||||
$jobsName .= '/';
|
||||
}
|
||||
$data[$k]['orgName'] = trim($orgName, '/');
|
||||
$data[$k]['dept_name'] = trim($deptName, '/');
|
||||
$data[$k]['jobs_name'] = trim($jobsName, '/');
|
||||
unset($data[$k]['role_id']);
|
||||
unset($data[$k]['org_id']);
|
||||
unset($data[$k]['dept_id']);
|
||||
unset($data[$k]['jobs_id']);
|
||||
}
|
||||
return $this->success('请求成功',$data);
|
||||
}
|
||||
|
||||
}
|
@ -28,6 +28,7 @@ class Admin extends BaseModel
|
||||
|
||||
protected $append = [
|
||||
'role_id',
|
||||
'org_id',
|
||||
'dept_id',
|
||||
'jobs_id',
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user