mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2026-04-27 16:29:36 +08:00
update 优化 校验角色是否有数据权限
This commit is contained in:
@@ -27,6 +27,7 @@ public class PasswordLoginBody extends LoginBody {
|
|||||||
*/
|
*/
|
||||||
@NotBlank(message = "{user.password.not.blank}")
|
@NotBlank(message = "{user.password.not.blank}")
|
||||||
@Length(min = 5, max = 30, message = "{user.password.length.valid}")
|
@Length(min = 5, max = 30, message = "{user.password.length.valid}")
|
||||||
|
// @Pattern(regexp = RegexConstants.PASSWORD, message = "{user.password.format.valid}")
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public class RegisterBody extends LoginBody {
|
|||||||
*/
|
*/
|
||||||
@NotBlank(message = "{user.password.not.blank}")
|
@NotBlank(message = "{user.password.not.blank}")
|
||||||
@Length(min = 5, max = 30, message = "{user.password.length.valid}")
|
@Length(min = 5, max = 30, message = "{user.password.length.valid}")
|
||||||
|
// @Pattern(regexp = RegexConstants.PASSWORD, message = "{user.password.format.valid}")
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ user.username.length.valid=账户长度必须在{min}到{max}个字符之间
|
|||||||
user.password.not.blank=用户密码不能为空
|
user.password.not.blank=用户密码不能为空
|
||||||
user.password.length.valid=用户密码长度必须在{min}到{max}个字符之间
|
user.password.length.valid=用户密码长度必须在{min}到{max}个字符之间
|
||||||
user.password.not.valid=* 5-50个字符
|
user.password.not.valid=* 5-50个字符
|
||||||
|
user.password.format.valid=密码必须包含大写字母、小写字母、数字和特殊字符
|
||||||
user.email.not.valid=邮箱格式错误
|
user.email.not.valid=邮箱格式错误
|
||||||
user.email.not.blank=邮箱不能为空
|
user.email.not.blank=邮箱不能为空
|
||||||
user.phonenumber.not.blank=用户手机号不能为空
|
user.phonenumber.not.blank=用户手机号不能为空
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ user.username.length.valid=Account length must be between {min} and {max} charac
|
|||||||
user.password.not.blank=Password cannot be empty
|
user.password.not.blank=Password cannot be empty
|
||||||
user.password.length.valid=Password length must be between {min} and {max} characters
|
user.password.length.valid=Password length must be between {min} and {max} characters
|
||||||
user.password.not.valid=* 5-50 characters
|
user.password.not.valid=* 5-50 characters
|
||||||
|
user.password.format.valid=Password must contain uppercase, lowercase, digit, and special character
|
||||||
user.email.not.valid=Mailbox format error
|
user.email.not.valid=Mailbox format error
|
||||||
user.email.not.blank=Mailbox cannot be blank
|
user.email.not.blank=Mailbox cannot be blank
|
||||||
user.phonenumber.not.blank=Phone number cannot be blank
|
user.phonenumber.not.blank=Phone number cannot be blank
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ user.username.length.valid=账户长度必须在{min}到{max}个字符之间
|
|||||||
user.password.not.blank=用户密码不能为空
|
user.password.not.blank=用户密码不能为空
|
||||||
user.password.length.valid=用户密码长度必须在{min}到{max}个字符之间
|
user.password.length.valid=用户密码长度必须在{min}到{max}个字符之间
|
||||||
user.password.not.valid=* 5-50个字符
|
user.password.not.valid=* 5-50个字符
|
||||||
|
user.password.format.valid=密码必须包含大写字母、小写字母、数字和特殊字符
|
||||||
user.email.not.valid=邮箱格式错误
|
user.email.not.valid=邮箱格式错误
|
||||||
user.email.not.blank=邮箱不能为空
|
user.email.not.blank=邮箱不能为空
|
||||||
user.phonenumber.not.blank=用户手机号不能为空
|
user.phonenumber.not.blank=用户手机号不能为空
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ public class SysTenantBo extends BaseEntity {
|
|||||||
* 密码(创建系统用户)
|
* 密码(创建系统用户)
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "密码不能为空", groups = { AddGroup.class })
|
@NotBlank(message = "密码不能为空", groups = { AddGroup.class })
|
||||||
|
// @Pattern(regexp = RegexConstants.PASSWORD, message = "{user.password.format.valid}", groups = { AddGroup.class })
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -118,6 +118,13 @@ public interface ISysRoleService {
|
|||||||
*/
|
*/
|
||||||
void checkRoleDataScope(Long roleId);
|
void checkRoleDataScope(Long roleId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验角色是否有数据权限
|
||||||
|
*
|
||||||
|
* @param roleIds 角色ID列表(支持传单个ID)
|
||||||
|
*/
|
||||||
|
void checkRoleDataScope(List<Long> roleIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过角色ID查询角色使用数量
|
* 通过角色ID查询角色使用数量
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -253,14 +253,23 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||||||
if (ObjectUtil.isNull(roleId)) {
|
if (ObjectUtil.isNull(roleId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (LoginHelper.isSuperAdmin()) {
|
this.checkRoleDataScope(Collections.singletonList(roleId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验角色是否有数据权限
|
||||||
|
*
|
||||||
|
* @param roleIds 角色ID列表(支持传单个ID)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void checkRoleDataScope(List<Long> roleIds) {
|
||||||
|
if (CollUtil.isEmpty(roleIds) || LoginHelper.isSuperAdmin()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<SysRoleVo> roles = this.selectRoleList(new SysRoleBo(roleId));
|
long count = baseMapper.selectRoleCount(roleIds);
|
||||||
if (CollUtil.isEmpty(roles)) {
|
if (count != roleIds.size()) {
|
||||||
throw new ServiceException("没有权限访问角色数据!");
|
throw new ServiceException("没有权限访问部分角色数据!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -417,10 +426,10 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public int deleteRoleByIds(List<Long> roleIds) {
|
public int deleteRoleByIds(List<Long> roleIds) {
|
||||||
|
checkRoleDataScope(roleIds);
|
||||||
List<SysRole> roles = baseMapper.selectByIds(roleIds);
|
List<SysRole> roles = baseMapper.selectByIds(roleIds);
|
||||||
for (SysRole role : roles) {
|
for (SysRole role : roles) {
|
||||||
checkRoleAllowed(BeanUtil.toBean(role, SysRoleBo.class));
|
checkRoleAllowed(BeanUtil.toBean(role, SysRoleBo.class));
|
||||||
checkRoleDataScope(role.getRoleId());
|
|
||||||
if (countUserRoleByRoleId(role.getRoleId()) > 0) {
|
if (countUserRoleByRoleId(role.getRoleId()) > 0) {
|
||||||
throw new ServiceException(String.format("%1$s已分配,不能删除!", role.getRoleName()));
|
throw new ServiceException(String.format("%1$s已分配,不能删除!", role.getRoleName()));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user