dataLists(new AdminLists()); } /** * @notes 添加管理员 * @return \think\response\Json * @author 段誉 * @date 2021/12/29 10:21 */ public function add() { $params = (new AdminValidate())->post()->goCheck('add'); $result = AdminLogic::add($params); if (true === $result) { return $this->success('操作成功', [], 1, 1); } return $this->fail(AdminLogic::getError()); } /** * @notes 编辑管理员 * @return \think\response\Json * @author 段誉 * @date 2021/12/29 11:03 */ public function edit() { $params = (new AdminValidate())->post()->goCheck('edit'); $result = AdminLogic::edit($params); if (true === $result) { return $this->success('操作成功', [], 1, 1); } return $this->fail(AdminLogic::getError()); } /** * @notes 删除管理员 * @return \think\response\Json * @author 段誉 * @date 2021/12/29 11:03 */ public function delete() { $params = (new AdminValidate())->post()->goCheck('delete'); $result = AdminLogic::delete($params); if (true === $result) { return $this->success('操作成功', [], 1, 1); } return $this->fail(AdminLogic::getError()); } /** * @notes 查看管理员详情 * @return \think\response\Json * @author 段誉 * @date 2021/12/29 11:07 */ public function detail() { $params = (new AdminValidate())->goCheck('detail'); $result = AdminLogic::detail($params); return $this->data($result); } /** * @notes 获取当前管理员信息 * @return \think\response\Json * @author 段誉 * @date 2021/12/31 10:53 */ public function mySelf() { $result = AdminLogic::detail(['id' => $this->adminId], 'auth'); return $this->data($result); } /** * @notes 编辑超级管理员信息 * @return \think\response\Json * @author 段誉 * @date 2022/4/8 17:54 */ public function editSelf() { $params = (new editSelfValidate())->post()->goCheck('', ['admin_id' => $this->adminId]); $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); } }