Commit def038f6 authored by 施翔轲's avatar 施翔轲

修改企业管理员权限字符,新增企业普通管理员

parent d0baa54b
......@@ -18,34 +18,44 @@ public interface TenantConstants {
String DISABLE = "1";
/**
* 超级管理员ID
* 大司空超级管理员ID
*/
Long SUPER_ADMIN_ID = 1L;
/**
* 超级管理员角色 roleKey
* 大司空超级管理员角色 roleKey
*/
String SUPER_ADMIN_ROLE_KEY = "superadmin";
/**
* 租户管理员角色 roleKey
* 大司空租户管理员角色
*/
String TENANT_ADMIN_ROLE_KEY = "admin";
String DSK_TENANT_ADMIN_ROLE_KEY = "accountAdmin";
/**
* 租户管理员角色名称
* 大司空租户管理员角色名称
*/
String TENANT_ADMIN_ROLE_NAME = "管理员";
String DSK_TENANT_ADMIN_ROLE_NAME = "企业账号管理员";
/**
* 大司空租户管理员角色
* 企业超级管理员角色 roleKey
*/
String DSK_TENANT_ADMIN_ROLE_KEY = "accountAdmin";
String TENANT_SUPER_ADMIN_ROLE_KEY = "tenantSuperAdmin";
/**
* 大司空租户管理员角色名称
* 企业超级管理员角色名称
*/
String DSK_TENANT_ADMIN_ROLE_NAME = "企业账号管理员";
String TENANT_SUPER_ADMIN_ROLE_NAME = "企业管理员";
/**
* 企业普通管理员角色 roleKey
*/
String TENANT_ADMIN_ROLE_KEY = "tenantAdmin";
/**
* 企业普通管理员角色名称
*/
String TENANT_ADMIN_ROLE_NAME = "管理员";
/**
* 默认租户ID
......
......@@ -169,7 +169,7 @@ public class LoginHelper {
* @return 结果
*/
public static boolean isTenantAdmin(Set<String> rolePermission) {
return rolePermission.contains(TenantConstants.TENANT_ADMIN_ROLE_KEY);
return rolePermission.contains(TenantConstants.TENANT_SUPER_ADMIN_ROLE_KEY);
}
public static boolean isTenantAdmin() {
......
......@@ -303,8 +303,8 @@ public class ISysTenantServiceImpl implements ISysTenantService {
// 创建角色
SysRole role = new SysRole();
role.setTenantId(tenantId);
role.setRoleName(TenantConstants.TENANT_ADMIN_ROLE_NAME);
role.setRoleKey(TenantConstants.TENANT_ADMIN_ROLE_KEY);
role.setRoleName(TenantConstants.TENANT_SUPER_ADMIN_ROLE_NAME);
role.setRoleKey(TenantConstants.TENANT_SUPER_ADMIN_ROLE_KEY);
role.setRoleSort(1);
role.setStatus(TenantConstants.NORMAL);
roleMapper.insert(role);
......@@ -386,7 +386,7 @@ public class ISysTenantServiceImpl implements ISysTenantService {
List<Long> roleIds = new ArrayList<>(roles.size() - 1);
List<Long> menuIds = StringUtils.splitTo(tenantPackage.getMenuIds(), Convert::toLong);
roles.forEach(item -> {
if (TenantConstants.TENANT_ADMIN_ROLE_KEY.equals(item.getRoleKey())) {
if (TenantConstants.TENANT_SUPER_ADMIN_ROLE_KEY.equals(item.getRoleKey())) {
List<SysRoleMenu> roleMenus = new ArrayList<>(menuIds.size());
menuIds.forEach(menuId -> {
SysRoleMenu roleMenu = new SysRoleMenu();
......
......@@ -199,7 +199,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
// 新增不允许使用 管理员标识符
if (ObjectUtil.isNull(role.getRoleId())
&& StringUtils.equalsAny(role.getRoleKey(),
TenantConstants.SUPER_ADMIN_ROLE_KEY, TenantConstants.TENANT_ADMIN_ROLE_KEY)) {
TenantConstants.SUPER_ADMIN_ROLE_KEY, TenantConstants.TENANT_SUPER_ADMIN_ROLE_KEY)) {
throw new ServiceException("不允许使用系统内置管理员角色标识符!");
}
// 修改不允许修改 管理员标识符
......@@ -208,7 +208,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
// 如果标识符不相等 判断为修改了管理员标识符
if (!StringUtils.equals(sysRole.getRoleKey(), role.getRoleKey())
&& StringUtils.equalsAny(sysRole.getRoleKey(),
TenantConstants.SUPER_ADMIN_ROLE_KEY, TenantConstants.TENANT_ADMIN_ROLE_KEY)) {
TenantConstants.SUPER_ADMIN_ROLE_KEY, TenantConstants.TENANT_SUPER_ADMIN_ROLE_KEY)) {
throw new ServiceException("不允许修改系统内置管理员角色标识符!");
}
}
......@@ -381,7 +381,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
public int deleteRoleByIds(Long[] roleIds) {
for (Long roleId : roleIds) {
SysRole role = selectRoleById(roleId);
if ("admin".equals(role.getRoleKey())) {
if (TenantConstants.TENANT_SUPER_ADMIN_ROLE_KEY.equals(role.getRoleKey())) {
throw new ServiceException("不允许删除企业管理员角色!");
}
checkRoleAllowed(role);
......@@ -475,7 +475,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
//查询企业管理员角色ID
List<SysRole> sysRoles = selectRoleAll();
for (SysRole role : sysRoles) {
if ("admin".equals(role.getRoleKey())) {
if (TenantConstants.TENANT_SUPER_ADMIN_ROLE_KEY.equals(role.getRoleKey())) {
adminRoleId = role.getRoleId();
break;
}
......
......@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dsk.common.constant.CacheNames;
import com.dsk.common.constant.TenantConstants;
import com.dsk.common.constant.UserConstants;
import com.dsk.common.core.domain.PageQuery;
import com.dsk.common.core.page.TableDataInfo;
......@@ -422,8 +423,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
.select(SysRole::getRoleId)
.eq(SysRole::getStatus, UserConstants.USER_NORMAL)
.eq(SysRole::getDelFlag, UserConstants.USER_NORMAL)
.eq(SysRole::getRoleKey, "admin"));
.eq(SysRole::getRoleKey, TenantConstants.TENANT_SUPER_ADMIN_ROLE_KEY));
//如果目前企业管理员角色下仅有1个账号
List<Long> userIds = userRoleMapper.selectUserIdsByRoleId(adminRole.getRoleId());
int enableAccount = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment