From 7a749f357b5bc1a475405f80efd5a5cf9b47eed6 Mon Sep 17 00:00:00 2001 From: weiz Date: Mon, 11 Dec 2023 09:45:19 +0800 Subject: [PATCH] update --- .../controller/auth/AdminController.php | 39 ----------- app/adminapi/lists/auth/AdminLists.php | 64 ++++--------------- app/adminapi/logic/auth/AdminLogic.php | 1 - app/common/model/auth/Admin.php | 41 +----------- app/common/model/auth/AdminDept.php | 32 ---------- app/common/model/auth/AdminJobs.php | 32 ---------- app/common/model/auth/AdminOrgs.php | 20 ------ 7 files changed, 14 insertions(+), 215 deletions(-) delete mode 100755 app/common/model/auth/AdminDept.php delete mode 100755 app/common/model/auth/AdminJobs.php delete mode 100644 app/common/model/auth/AdminOrgs.php diff --git a/app/adminapi/controller/auth/AdminController.php b/app/adminapi/controller/auth/AdminController.php index 4da186f46..dd718713f 100755 --- a/app/adminapi/controller/auth/AdminController.php +++ b/app/adminapi/controller/auth/AdminController.php @@ -134,43 +134,4 @@ 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); - } - } \ No newline at end of file diff --git a/app/adminapi/lists/auth/AdminLists.php b/app/adminapi/lists/auth/AdminLists.php index ded614fdf..b564ae93f 100755 --- a/app/adminapi/lists/auth/AdminLists.php +++ b/app/adminapi/lists/auth/AdminLists.php @@ -76,6 +76,7 @@ class AdminLists extends BaseAdminDataLists implements ListsExtendInterface, Lis { return [ '%like%' => ['name', 'account'], + '=' => ['org_id','dept_id','job_id'] ]; } @@ -103,24 +104,7 @@ class AdminLists extends BaseAdminDataLists implements ListsExtendInterface, Lis { return ['id' => 'desc']; } - - /** - * @notes 查询条件 - * @return array - * @author 段誉 - * @date 2022/11/29 11:33 - */ - public function queryWhere() - { - $where = []; - if (isset($this->params['role_id']) && $this->params['role_id'] != '') { - $adminIds = AdminRole::where('role_id', $this->params['role_id'])->column('admin_id'); - if (!empty($adminIds)) { - $where[] = ['id', 'in', $adminIds]; - } - } - return $where; - } + /** @@ -135,26 +119,27 @@ class AdminLists extends BaseAdminDataLists implements ListsExtendInterface, Lis public function lists(): array { $field = [ - 'id', 'name', 'account', 'create_time', 'disable', 'root', + 'id', 'name', 'account', 'create_time', 'disable', 'root', 'org_id', 'dept_id', 'job_id', 'login_time', 'login_ip', 'multipoint_login', 'avatar' ]; $adminLists = Admin::field($field) ->where($this->searchWhere) - ->where($this->queryWhere()) ->limit($this->limitOffset, $this->limitLength) ->order($this->sortOrder) - ->append(['role_id', 'org_id', 'dept_id', 'jobs_id', 'disable_desc']) - ->select() + ->append(['role_id','disable_desc']) + ->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']; + return $item; + }) ->toArray(); // 角色数组('角色id'=>'角色名称') $roleLists = SystemRole::column('name', 'id'); - // 组织列表 - $orgLists = Orgs::column('name', 'id'); - // 部门列表 - $deptLists = Dept::column('name', 'id'); - // 岗位列表 - $jobsLists = Jobs::column('name', 'id'); //管理员列表增加角色名称 foreach ($adminLists as $k => $v) { @@ -167,29 +152,7 @@ class AdminLists extends BaseAdminDataLists implements ListsExtendInterface, Lis $roleName .= '/'; } } - - $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 .= '/'; - } - $adminLists[$k]['role_name'] = trim($roleName, '/'); - $adminLists[$k]['orgName'] = trim($orgName, '/'); - $adminLists[$k]['dept_name'] = trim($deptName, '/'); - $adminLists[$k]['jobs_name'] = trim($jobsName, '/'); } return $adminLists; @@ -204,7 +167,6 @@ class AdminLists extends BaseAdminDataLists implements ListsExtendInterface, Lis public function count(): int { return Admin::where($this->searchWhere) - ->where($this->queryWhere()) ->count(); } diff --git a/app/adminapi/logic/auth/AdminLogic.php b/app/adminapi/logic/auth/AdminLogic.php index 0b8dd1ed2..b52918753 100755 --- a/app/adminapi/logic/auth/AdminLogic.php +++ b/app/adminapi/logic/auth/AdminLogic.php @@ -232,7 +232,6 @@ class AdminLogic extends BaseLogic 'id', 'account', 'name', 'disable', 'root', 'multipoint_login', 'avatar', ])->findOrEmpty($params['id'])->toArray(); - if ($action == 'detail') { return $admin; } diff --git a/app/common/model/auth/Admin.php b/app/common/model/auth/Admin.php index f6cd0cbea..9da83b530 100755 --- a/app/common/model/auth/Admin.php +++ b/app/common/model/auth/Admin.php @@ -28,12 +28,8 @@ class Admin extends BaseModel protected $append = [ 'role_id', - 'org_id', - 'dept_id', - 'jobs_id', ]; - - + /** * @notes 关联角色id * @param $value @@ -47,41 +43,6 @@ class Admin extends BaseModel return AdminRole::where('admin_id', $data['id'])->column('role_id'); } - public function getOrgIdAttr($value, $data) - { - return AdminOrgs::where('admin_id', $data['id'])->column('org_id'); - } - - - /** - * @notes 关联部门id - * @param $value - * @param $data - * @return array - * @author 段誉 - * @date 2022/11/25 15:00 - */ - public function getDeptIdAttr($value, $data) - { - return AdminDept::where('admin_id', $data['id'])->column('dept_id'); - } - - - /** - * @notes 关联岗位id - * @param $value - * @param $data - * @return array - * @author 段誉 - * @date 2022/11/25 15:01\ - */ - public function getJobsIdAttr($value, $data) - { - return AdminJobs::where('admin_id', $data['id'])->column('jobs_id'); - } - - - /** * @notes 获取禁用状态 * @param $value diff --git a/app/common/model/auth/AdminDept.php b/app/common/model/auth/AdminDept.php deleted file mode 100755 index e5ee32e1a..000000000 --- a/app/common/model/auth/AdminDept.php +++ /dev/null @@ -1,32 +0,0 @@ - $adminId])->delete(); - } -} \ No newline at end of file diff --git a/app/common/model/auth/AdminJobs.php b/app/common/model/auth/AdminJobs.php deleted file mode 100755 index 9568ce21c..000000000 --- a/app/common/model/auth/AdminJobs.php +++ /dev/null @@ -1,32 +0,0 @@ - $adminId])->delete(); - } -} \ No newline at end of file diff --git a/app/common/model/auth/AdminOrgs.php b/app/common/model/auth/AdminOrgs.php deleted file mode 100644 index c25ff8ac4..000000000 --- a/app/common/model/auth/AdminOrgs.php +++ /dev/null @@ -1,20 +0,0 @@ - $adminId])->delete(); - } - } \ No newline at end of file