mirror of https://gitee.com/xiaonuobase/snowy
【更新】升级角色功能,业务管理员可以授权给个人全局角色啦
parent
b584c17d58
commit
67bf454e66
|
@ -39,7 +39,7 @@ public interface SysRoleApi {
|
|||
* @author xuyuxiang
|
||||
* @date 2022/7/22 14:49
|
||||
**/
|
||||
Page<JSONObject> roleSelector(String orgId, String category, String searchKey, List<String> dataScopeList);
|
||||
Page<JSONObject> roleSelector(String orgId, String category, String searchKey, List<String> dataScopeList, boolean excludeSuperAdmin);
|
||||
|
||||
/**
|
||||
* 代码生成菜单按钮授权
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package vip.xiaonuo.biz.modular.user.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import vip.xiaonuo.common.exception.CommonException;
|
||||
|
||||
/**
|
||||
* 角色分类枚举
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/4/21 19:56
|
||||
**/
|
||||
@Getter
|
||||
public enum BizRoleCategoryEnum {
|
||||
|
||||
/** 全局 */
|
||||
GLOBAL("GLOBAL"),
|
||||
|
||||
/** 组织 */
|
||||
ORG("ORG");
|
||||
|
||||
private final String value;
|
||||
|
||||
BizRoleCategoryEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static void validate(String value) {
|
||||
boolean flag = GLOBAL.getValue().equals(value) || ORG.getValue().equals(value);
|
||||
if(!flag) {
|
||||
throw new CommonException("不支持的角色分类:{}", value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -59,6 +59,7 @@ import vip.xiaonuo.biz.modular.org.service.BizOrgService;
|
|||
import vip.xiaonuo.biz.modular.position.entity.BizPosition;
|
||||
import vip.xiaonuo.biz.modular.position.service.BizPositionService;
|
||||
import vip.xiaonuo.biz.modular.user.entity.BizUser;
|
||||
import vip.xiaonuo.biz.modular.user.enums.BizRoleCategoryEnum;
|
||||
import vip.xiaonuo.biz.modular.user.enums.BizUserStatusEnum;
|
||||
import vip.xiaonuo.biz.modular.user.mapper.BizUserMapper;
|
||||
import vip.xiaonuo.biz.modular.user.param.*;
|
||||
|
@ -685,13 +686,19 @@ public class BizUserServiceImpl extends ServiceImpl<BizUserMapper, BizUser> impl
|
|||
if(ObjectUtil.isNotEmpty(bizUserSelectorRoleParam.getOrgId())) {
|
||||
if(loginUserDataScope.contains(bizUserSelectorRoleParam.getOrgId())) {
|
||||
return BeanUtil.toBean(sysRoleApi.roleSelector(bizUserSelectorRoleParam.getOrgId(), bizUserSelectorRoleParam.getCategory(),
|
||||
bizUserSelectorRoleParam.getSearchKey(), loginUserDataScope), Page.class);
|
||||
bizUserSelectorRoleParam.getSearchKey(), loginUserDataScope, true), Page.class);
|
||||
} else {
|
||||
return new Page<>();
|
||||
}
|
||||
} else {
|
||||
return BeanUtil.toBean(sysRoleApi.roleSelector(bizUserSelectorRoleParam.getOrgId(), bizUserSelectorRoleParam.getCategory(),
|
||||
bizUserSelectorRoleParam.getSearchKey(), loginUserDataScope), Page.class);
|
||||
if (ObjectUtil.isNotEmpty(bizUserSelectorRoleParam.getCategory()) & BizRoleCategoryEnum.GLOBAL.getValue().equals(bizUserSelectorRoleParam.getCategory())) {
|
||||
// 查询系统级别的
|
||||
return BeanUtil.toBean(sysRoleApi.roleSelector(null, bizUserSelectorRoleParam.getCategory(),
|
||||
bizUserSelectorRoleParam.getSearchKey(), null, true), Page.class);
|
||||
} else {
|
||||
return BeanUtil.toBean(sysRoleApi.roleSelector(null, bizUserSelectorRoleParam.getCategory(),
|
||||
bizUserSelectorRoleParam.getSearchKey(), loginUserDataScope, true), Page.class);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return new Page<>();
|
||||
|
|
|
@ -52,4 +52,8 @@ public class SysRoleSelectorRoleParam {
|
|||
/** 数据范围信息 */
|
||||
@ApiModelProperty(value = "数据范围信息")
|
||||
private List<String> dataScopeList;
|
||||
|
||||
/** 是否排除超管 */
|
||||
@ApiModelProperty(value = "是否排除超管")
|
||||
private boolean excludeSuperAdmin = false;
|
||||
}
|
||||
|
|
|
@ -69,20 +69,21 @@ public class SysRoleApiProvider implements SysRoleApi {
|
|||
|
||||
@SuppressWarnings("ALL")
|
||||
@Override
|
||||
public Page<JSONObject> roleSelector(String orgId, String category, String searchKey, List<String> dataScopeList) {
|
||||
public Page<JSONObject> roleSelector(String orgId, String category, String searchKey, List<String> dataScopeList, boolean excludeSuperAdmin) {
|
||||
SysRoleSelectorRoleParam sysRoleSelectorRoleParam = new SysRoleSelectorRoleParam();
|
||||
sysRoleSelectorRoleParam.setOrgId(orgId);
|
||||
sysRoleSelectorRoleParam.setCategory(category);
|
||||
sysRoleSelectorRoleParam.setSearchKey(searchKey);
|
||||
sysRoleSelectorRoleParam.setDataScopeList(dataScopeList);
|
||||
sysRoleSelectorRoleParam.setExcludeSuperAdmin(excludeSuperAdmin);
|
||||
return BeanUtil.toBean(sysRoleService.roleSelector(sysRoleSelectorRoleParam), Page.class);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void grantForGenMenuAndButton(String menuId) {
|
||||
String superAdminRoleId = sysRoleService.getOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getCode, SysBuildInEnum.BUILD_IN_ROLE_CODE.getValue())
|
||||
.eq(SysRole::getCategory, SysRoleCategoryEnum.GLOBAL.getValue())).getId();
|
||||
String superAdminRoleId = sysRoleService.getOne(new LambdaQueryWrapper<SysRole>()
|
||||
.eq(SysRole::getCode, SysBuildInEnum.BUILD_IN_ROLE_CODE.getValue())).getId();
|
||||
SysRoleGrantResourceParam sysRoleGrantResourceParam = new SysRoleGrantResourceParam();
|
||||
sysRoleGrantResourceParam.setId(superAdminRoleId);
|
||||
SysMenu sysMenu = sysMenuService.queryEntity(menuId);
|
||||
|
|
|
@ -451,6 +451,10 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||
if(ObjectUtil.isNotEmpty(sysRoleSelectorRoleParam.getDataScopeList())) {
|
||||
lambdaQueryWrapper.in(SysRole::getOrgId, sysRoleSelectorRoleParam.getDataScopeList());
|
||||
}
|
||||
// 排除超管角色
|
||||
if(sysRoleSelectorRoleParam.isExcludeSuperAdmin()) {
|
||||
lambdaQueryWrapper.ne(SysRole::getCode, SysBuildInEnum.BUILD_IN_ROLE_CODE.getValue());
|
||||
}
|
||||
lambdaQueryWrapper.orderByAsc(SysRole::getSortCode);
|
||||
return this.page(CommonPageRequest.defaultPage(), lambdaQueryWrapper);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue