Merge pull request 'update' (#12) from zhangwei into dev
Reviewed-on: #12
This commit is contained in:
commit
6f074486ea
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model\auth;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
class AdminDept extends BaseModel
|
||||
{
|
||||
/**
|
||||
* @notes 删除用户关联部门
|
||||
* @param $adminId
|
||||
* @return bool
|
||||
* @author 段誉
|
||||
* @date 2022/11/25 14:14
|
||||
*/
|
||||
public static function delByUserId($adminId)
|
||||
{
|
||||
return self::where(['admin_id' => $adminId])->delete();
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model\auth;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
class AdminJobs extends BaseModel
|
||||
{
|
||||
/**
|
||||
* @notes 删除用户关联岗位
|
||||
* @param $adminId
|
||||
* @return bool
|
||||
* @author 段誉
|
||||
* @date 2022/11/25 14:14
|
||||
*/
|
||||
public static function delByUserId($adminId)
|
||||
{
|
||||
return self::where(['admin_id' => $adminId])->delete();
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\auth;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
class AdminOrgs extends BaseModel
|
||||
{
|
||||
/**
|
||||
* @notes 删除用户关联岗位
|
||||
* @param $adminId
|
||||
* @return bool
|
||||
* @author 段誉
|
||||
* @date 2022/11/25 14:14
|
||||
*/
|
||||
public static function delByUserId($adminId)
|
||||
{
|
||||
return self::where(['admin_id' => $adminId])->delete();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user