【更新】修复手机号重复校验的bug,修复 #I71SNK 非超管角色用户不可被授权系统模块菜单资源的bug

pull/110/MERGE
xuyuxiang 2023-06-14 18:34:34 +08:00
parent 2ef6b9c45d
commit 5dbb5ef23b
3 changed files with 25 additions and 25 deletions

View File

@ -186,7 +186,7 @@ public class BizUserServiceImpl extends ServiceImpl<BizUserMapper, BizUser> impl
throw new CommonException("手机号码:{}格式错误", bizUserAddParam.getPhone()); throw new CommonException("手机号码:{}格式错误", bizUserAddParam.getPhone());
} }
if (this.count(new LambdaQueryWrapper<BizUser>() if (this.count(new LambdaQueryWrapper<BizUser>()
.eq(BizUser::getPhone, bizUserAddParam.getPhone())) > 0) { .eq(BizUser::getPhone, CommonCryptogramUtil.doSm4CbcEncrypt(bizUserAddParam.getPhone()))) > 0) {
throw new CommonException("存在重复的手机号,手机号为:{}", bizUserAddParam.getPhone()); throw new CommonException("存在重复的手机号,手机号为:{}", bizUserAddParam.getPhone());
} }
} }
@ -240,7 +240,7 @@ public class BizUserServiceImpl extends ServiceImpl<BizUserMapper, BizUser> impl
throw new CommonException("手机号码:{}格式错误", bizUserEditParam.getPhone()); throw new CommonException("手机号码:{}格式错误", bizUserEditParam.getPhone());
} }
if (this.count(new LambdaQueryWrapper<BizUser>() if (this.count(new LambdaQueryWrapper<BizUser>()
.eq(BizUser::getPhone, bizUserEditParam.getPhone()) .eq(BizUser::getPhone, CommonCryptogramUtil.doSm4CbcEncrypt(bizUserEditParam.getPhone()))
.ne(BizUser::getId, bizUserEditParam.getId())) > 0) { .ne(BizUser::getId, bizUserEditParam.getId())) > 0) {
throw new CommonException("存在重复的手机号,手机号为:{}", bizUserEditParam.getPhone()); throw new CommonException("存在重复的手机号,手机号为:{}", bizUserEditParam.getPhone());
} }

View File

@ -147,7 +147,7 @@ public class ClientUserServiceImpl extends ServiceImpl<ClientUserMapper, ClientU
throw new CommonException("手机号码:{}格式错误", clientUserAddParam.getPhone()); throw new CommonException("手机号码:{}格式错误", clientUserAddParam.getPhone());
} }
if (this.count(new LambdaQueryWrapper<ClientUser>() if (this.count(new LambdaQueryWrapper<ClientUser>()
.eq(ClientUser::getPhone, clientUserAddParam.getPhone())) > 0) { .eq(ClientUser::getPhone, CommonCryptogramUtil.doSm4CbcEncrypt(clientUserAddParam.getPhone()))) > 0) {
throw new CommonException("存在重复的手机号,手机号为:{}", clientUserAddParam.getPhone()); throw new CommonException("存在重复的手机号,手机号为:{}", clientUserAddParam.getPhone());
} }
} }
@ -181,7 +181,7 @@ public class ClientUserServiceImpl extends ServiceImpl<ClientUserMapper, ClientU
throw new CommonException("手机号码:{}格式错误", clientUserEditParam.getPhone()); throw new CommonException("手机号码:{}格式错误", clientUserEditParam.getPhone());
} }
if (this.count(new LambdaQueryWrapper<ClientUser>() if (this.count(new LambdaQueryWrapper<ClientUser>()
.eq(ClientUser::getPhone, clientUserEditParam.getPhone()) .eq(ClientUser::getPhone, CommonCryptogramUtil.doSm4CbcEncrypt(clientUserEditParam.getPhone()))
.ne(ClientUser::getId, clientUserEditParam.getId())) > 0) { .ne(ClientUser::getId, clientUserEditParam.getId())) > 0) {
throw new CommonException("存在重复的手机号,手机号为:{}", clientUserEditParam.getPhone()); throw new CommonException("存在重复的手机号,手机号为:{}", clientUserEditParam.getPhone());
} }

View File

@ -264,7 +264,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
throw new CommonException("手机号码:{}格式错误", sysUserAddParam.getPhone()); throw new CommonException("手机号码:{}格式错误", sysUserAddParam.getPhone());
} }
if (this.count(new LambdaQueryWrapper<SysUser>() if (this.count(new LambdaQueryWrapper<SysUser>()
.eq(SysUser::getPhone, sysUserAddParam.getPhone())) > 0) { .eq(SysUser::getPhone, CommonCryptogramUtil.doSm4CbcEncrypt(sysUserAddParam.getPhone()))) > 0) {
throw new CommonException("存在重复的手机号,手机号为:{}", sysUserAddParam.getPhone()); throw new CommonException("存在重复的手机号,手机号为:{}", sysUserAddParam.getPhone());
} }
} }
@ -307,7 +307,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
throw new CommonException("手机号码:{}格式错误", sysUserEditParam.getPhone()); throw new CommonException("手机号码:{}格式错误", sysUserEditParam.getPhone());
} }
if (this.count(new LambdaQueryWrapper<SysUser>() if (this.count(new LambdaQueryWrapper<SysUser>()
.eq(SysUser::getPhone, sysUserEditParam.getPhone()) .eq(SysUser::getPhone, CommonCryptogramUtil.doSm4CbcEncrypt(sysUserEditParam.getPhone()))
.ne(SysUser::getId, sysUserEditParam.getId())) > 0) { .ne(SysUser::getId, sysUserEditParam.getId())) > 0) {
throw new CommonException("存在重复的手机号,手机号为:{}", sysUserEditParam.getPhone()); throw new CommonException("存在重复的手机号,手机号为:{}", sysUserEditParam.getPhone());
} }
@ -784,30 +784,30 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
@Override @Override
public void grantResource(SysUserGrantResourceParam sysUserGrantResourceParam) { public void grantResource(SysUserGrantResourceParam sysUserGrantResourceParam) {
String id = sysUserGrantResourceParam.getId();
SysUserIdParam sysUserIdParam = new SysUserIdParam();
List<String> roleIdList = this.ownRole(sysUserIdParam);
if(ObjectUtil.isEmpty(roleIdList)) {
throw new CommonException("非超管角色用户不可被授权系统模块菜单资源");
}
boolean hasSuperAdminRole = sysRoleService.listByIds(roleIdList).stream().map(SysRole::getCode).collect(Collectors.toSet())
.contains(SysBuildInEnum.BUILD_IN_ROLE_CODE.getValue());
List<String> menuIdList = sysUserGrantResourceParam.getGrantInfoList().stream() List<String> menuIdList = sysUserGrantResourceParam.getGrantInfoList().stream()
.map(SysUserGrantResourceParam.SysUserGrantResource::getMenuId).collect(Collectors.toList()); .map(SysUserGrantResourceParam.SysUserGrantResource::getMenuId).collect(Collectors.toList());
if(!hasSuperAdminRole) { if(ObjectUtil.isNotEmpty(menuIdList)) {
if(ObjectUtil.isNotEmpty(menuIdList)) { SysUserIdParam sysUserIdParam = new SysUserIdParam();
Set<String> sysModuleIdList = sysMenuService.listByIds(menuIdList).stream().map(SysMenu::getModule).collect(Collectors.toSet()); sysUserIdParam.setId(sysUserGrantResourceParam.getId());
boolean containsSystemModule = sysModuleService.listByIds(sysModuleIdList).stream().map(SysModule::getCode) List<String> roleIdList = this.ownRole(sysUserIdParam);
.collect(Collectors.toSet()).contains(SysBuildInEnum.BUILD_IN_MODULE_CODE.getValue()); Set<String> sysModuleIdList = sysMenuService.listByIds(menuIdList).stream().map(SysMenu::getModule).collect(Collectors.toSet());
if(containsSystemModule) { boolean containsSystemModule = sysModuleService.listByIds(sysModuleIdList).stream().map(SysModule::getCode)
.collect(Collectors.toSet()).contains(SysBuildInEnum.BUILD_IN_MODULE_CODE.getValue());
if(containsSystemModule) {
if(ObjectUtil.isEmpty(roleIdList)) {
throw new CommonException("非超管角色用户不可被授权系统模块菜单资源"); throw new CommonException("非超管角色用户不可被授权系统模块菜单资源");
} else {
boolean hasSuperAdminRole = sysRoleService.listByIds(roleIdList).stream().map(SysRole::getCode).collect(Collectors.toSet())
.contains(SysBuildInEnum.BUILD_IN_ROLE_CODE.getValue());
if(!hasSuperAdminRole) {
throw new CommonException("非超管角色用户不可被授权系统模块菜单资源");
}
} }
} }
List<String> extJsonList = sysUserGrantResourceParam.getGrantInfoList().stream()
.map(JSONUtil::toJsonStr).collect(Collectors.toList());
sysRelationService.saveRelationBatchWithClear(sysUserGrantResourceParam.getId(), menuIdList, SysRelationCategoryEnum.SYS_USER_HAS_RESOURCE.getValue(), extJsonList);
} }
List<String> extJsonList = sysUserGrantResourceParam.getGrantInfoList().stream()
.map(JSONUtil::toJsonStr).collect(Collectors.toList());
sysRelationService.saveRelationBatchWithClear(id, menuIdList, SysRelationCategoryEnum.SYS_USER_HAS_RESOURCE.getValue(),
extJsonList);
} }
@Override @Override
@ -858,7 +858,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
throw new CommonException("手机号码:{}格式错误", sysUserUpdateInfoParam.getPhone()); throw new CommonException("手机号码:{}格式错误", sysUserUpdateInfoParam.getPhone());
} }
if (this.count(new LambdaQueryWrapper<SysUser>().ne(SysUser::getId, sysUser.getId()) if (this.count(new LambdaQueryWrapper<SysUser>().ne(SysUser::getId, sysUser.getId())
.eq(SysUser::getPhone, sysUserUpdateInfoParam.getPhone())) > 0) { .eq(SysUser::getPhone, CommonCryptogramUtil.doSm4CbcEncrypt(sysUserUpdateInfoParam.getPhone()))) > 0) {
throw new CommonException("存在重复的手机号,手机号为:{}", sysUserUpdateInfoParam.getPhone()); throw new CommonException("存在重复的手机号,手机号为:{}", sysUserUpdateInfoParam.getPhone());
} }
} }