管理员新增编辑接口增加org_id参数
This commit is contained in:
parent
642b901c77
commit
cf647f22fc
@ -24,6 +24,7 @@ use app\common\model\auth\AdminRole;
|
|||||||
use app\common\model\auth\SystemRole;
|
use app\common\model\auth\SystemRole;
|
||||||
use app\common\model\dept\Dept;
|
use app\common\model\dept\Dept;
|
||||||
use app\common\model\dept\Jobs;
|
use app\common\model\dept\Jobs;
|
||||||
|
use app\common\model\dept\Orgs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 管理员列表
|
* 管理员列表
|
||||||
@ -143,12 +144,14 @@ class AdminLists extends BaseAdminDataLists implements ListsExtendInterface, Lis
|
|||||||
->where($this->queryWhere())
|
->where($this->queryWhere())
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order($this->sortOrder)
|
->order($this->sortOrder)
|
||||||
->append(['role_id', 'dept_id', 'jobs_id', 'disable_desc'])
|
->append(['role_id', 'org_id', 'dept_id', 'jobs_id', 'disable_desc'])
|
||||||
->select()
|
->select()
|
||||||
->toArray();
|
->toArray();
|
||||||
|
|
||||||
// 角色数组('角色id'=>'角色名称')
|
// 角色数组('角色id'=>'角色名称')
|
||||||
$roleLists = SystemRole::column('name', 'id');
|
$roleLists = SystemRole::column('name', 'id');
|
||||||
|
// 组织列表
|
||||||
|
$orgLists = Orgs::column('name', 'id');
|
||||||
// 部门列表
|
// 部门列表
|
||||||
$deptLists = Dept::column('name', 'id');
|
$deptLists = Dept::column('name', 'id');
|
||||||
// 岗位列表
|
// 岗位列表
|
||||||
@ -166,6 +169,12 @@ class AdminLists extends BaseAdminDataLists implements ListsExtendInterface, Lis
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$orgName = '';
|
||||||
|
foreach ($v['org_id'] as $orgId) {
|
||||||
|
$orgName .= $orgLists[$orgId] ?? '';
|
||||||
|
$orgName .= '/';
|
||||||
|
}
|
||||||
|
|
||||||
$deptName = '';
|
$deptName = '';
|
||||||
foreach ($v['dept_id'] as $deptId) {
|
foreach ($v['dept_id'] as $deptId) {
|
||||||
$deptName .= $deptLists[$deptId] ?? '';
|
$deptName .= $deptLists[$deptId] ?? '';
|
||||||
@ -179,6 +188,7 @@ class AdminLists extends BaseAdminDataLists implements ListsExtendInterface, Lis
|
|||||||
}
|
}
|
||||||
|
|
||||||
$adminLists[$k]['role_name'] = trim($roleName, '/');
|
$adminLists[$k]['role_name'] = trim($roleName, '/');
|
||||||
|
$adminLists[$k]['$orgName'] = trim($orgName, '/');
|
||||||
$adminLists[$k]['dept_name'] = trim($deptName, '/');
|
$adminLists[$k]['dept_name'] = trim($deptName, '/');
|
||||||
$adminLists[$k]['jobs_name'] = trim($jobsName, '/');
|
$adminLists[$k]['jobs_name'] = trim($jobsName, '/');
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ use app\common\logic\BaseLogic;
|
|||||||
use app\common\model\auth\Admin;
|
use app\common\model\auth\Admin;
|
||||||
use app\common\model\auth\AdminDept;
|
use app\common\model\auth\AdminDept;
|
||||||
use app\common\model\auth\AdminJobs;
|
use app\common\model\auth\AdminJobs;
|
||||||
|
use app\common\model\auth\AdminOrgs;
|
||||||
use app\common\model\auth\AdminRole;
|
use app\common\model\auth\AdminRole;
|
||||||
use app\common\model\auth\AdminSession;
|
use app\common\model\auth\AdminSession;
|
||||||
use app\common\cache\AdminTokenCache;
|
use app\common\cache\AdminTokenCache;
|
||||||
@ -62,10 +63,12 @@ class AdminLogic extends BaseLogic
|
|||||||
|
|
||||||
// 角色
|
// 角色
|
||||||
self::insertRole($admin['id'], $params['role_id'] ?? []);
|
self::insertRole($admin['id'], $params['role_id'] ?? []);
|
||||||
|
// 组织
|
||||||
|
self::insertOrg($admin['id'], $params['org_id'] ?? 0);
|
||||||
// 部门
|
// 部门
|
||||||
self::insertDept($admin['id'], $params['dept_id'] ?? []);
|
self::insertDept($admin['id'], $params['dept_id'] ?? 0);
|
||||||
// 岗位
|
// 岗位
|
||||||
self::insertJobs($admin['id'], $params['jobs_id'] ?? []);
|
self::insertJobs($admin['id'], $params['jobs_id'] ?? 0);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
@ -125,14 +128,17 @@ class AdminLogic extends BaseLogic
|
|||||||
|
|
||||||
// 删除旧的关联信息
|
// 删除旧的关联信息
|
||||||
AdminRole::delByUserId($params['id']);
|
AdminRole::delByUserId($params['id']);
|
||||||
|
AdminOrgs::delByUserId($params['id']);
|
||||||
AdminDept::delByUserId($params['id']);
|
AdminDept::delByUserId($params['id']);
|
||||||
AdminJobs::delByUserId($params['id']);
|
AdminJobs::delByUserId($params['id']);
|
||||||
// 角色
|
// 角色
|
||||||
self::insertRole($params['id'], $params['role_id']);
|
self::insertRole($params['id'], $params['role_id']);
|
||||||
|
// 组织
|
||||||
|
self::insertOrg($params['id'], $params['org_id'] ?? 0);
|
||||||
// 部门
|
// 部门
|
||||||
self::insertDept($params['id'], $params['dept_id'] ?? []);
|
self::insertDept($params['id'], $params['dept_id'] ?? 0);
|
||||||
// 岗位
|
// 岗位
|
||||||
self::insertJobs($params['id'], $params['jobs_id'] ?? []);
|
self::insertJobs($params['id'], $params['jobs_id'] ?? 0);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
@ -170,6 +176,7 @@ class AdminLogic extends BaseLogic
|
|||||||
|
|
||||||
// 删除旧的关联信息
|
// 删除旧的关联信息
|
||||||
AdminRole::delByUserId($params['id']);
|
AdminRole::delByUserId($params['id']);
|
||||||
|
AdminOrgs::delByUserId($params['id']);
|
||||||
AdminDept::delByUserId($params['id']);
|
AdminDept::delByUserId($params['id']);
|
||||||
AdminJobs::delByUserId($params['id']);
|
AdminJobs::delByUserId($params['id']);
|
||||||
|
|
||||||
@ -287,6 +294,24 @@ class AdminLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 新增组织
|
||||||
|
* @param $adminId
|
||||||
|
* @param $orgIds
|
||||||
|
* @throws \Exception
|
||||||
|
* @author 段誉
|
||||||
|
* @date 2022/11/25 14:22
|
||||||
|
*/
|
||||||
|
public static function insertOrg($adminId, $orgIds)
|
||||||
|
{
|
||||||
|
// 岗位
|
||||||
|
if (!empty($orgsIds)) {
|
||||||
|
(new AdminOrgs())->save([
|
||||||
|
'admin_id' => $adminId,
|
||||||
|
'org_id' => $orgsIds
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 新增部门
|
* @notes 新增部门
|
||||||
@ -300,14 +325,10 @@ class AdminLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
// 部门
|
// 部门
|
||||||
if (!empty($deptIds)) {
|
if (!empty($deptIds)) {
|
||||||
$deptData = [];
|
(new AdminDept())->save([
|
||||||
foreach ($deptIds as $deptId) {
|
|
||||||
$deptData[] = [
|
|
||||||
'admin_id' => $adminId,
|
'admin_id' => $adminId,
|
||||||
'dept_id' => $deptId
|
'dept_id' => $deptIds
|
||||||
];
|
]);
|
||||||
}
|
|
||||||
(new AdminDept())->saveAll($deptData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,14 +345,10 @@ class AdminLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
// 岗位
|
// 岗位
|
||||||
if (!empty($jobsIds)) {
|
if (!empty($jobsIds)) {
|
||||||
$jobsData = [];
|
(new AdminJobs())->save([
|
||||||
foreach ($jobsIds as $jobsId) {
|
|
||||||
$jobsData[] = [
|
|
||||||
'admin_id' => $adminId,
|
'admin_id' => $adminId,
|
||||||
'jobs_id' => $jobsId
|
'jobs_id' => $jobsIds
|
||||||
];
|
]);
|
||||||
}
|
|
||||||
(new AdminJobs())->saveAll($jobsData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
app/common/model/auth/AdminOrgs.php
Normal file
20
app/common/model/auth/AdminOrgs.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?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