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

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

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