|
|
|
@ -184,17 +184,15 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean changePassWord(String account, String password) {
|
|
|
|
|
UserInfoDTO user = UserUtil.getUser();
|
|
|
|
|
|
|
|
|
|
// 账号不为空,且当前操作不是账号归属人出发 (需要管理员权限)
|
|
|
|
|
Assert.notEmpty(password, "密码不能为空");
|
|
|
|
|
|
|
|
|
|
UserInfoDTO user = UserUtil.getUser();
|
|
|
|
|
// 账号不为空,且当前操作不是账号归属人触发 (需要管理员权限)
|
|
|
|
|
if (StrUtil.isNotEmpty(account) && !StrUtil.equals(user.getAccount(), account)){
|
|
|
|
|
long count = user.getUserRoleList().stream().filter(userRoleDTO -> StrUtil.equals(userRoleDTO.getRoleId(), RoleEnum.ADMIN.getCode())).count();
|
|
|
|
|
if (count == 0){
|
|
|
|
|
log.info("账号:{}不是管理员,不能修改其他账号密码", user.getAccount());
|
|
|
|
|
throw new BusinessException("您没有权限修改用户密码!");
|
|
|
|
|
}
|
|
|
|
|
boolean isAdmin = user.getUserRoleList().stream().anyMatch(userRoleDTO -> StrUtil.equals(userRoleDTO.getRoleId(), RoleEnum.ADMIN.getCode()));
|
|
|
|
|
Assert.isTrue(isAdmin, "您没有权限修改用户密码!");
|
|
|
|
|
}
|
|
|
|
|
Assert.notEmpty(password, "密码不能为空");
|
|
|
|
|
|
|
|
|
|
String userCount = StrUtil.isEmpty(account) ? user.getAccount() : account;
|
|
|
|
|
SystemUser systemUser = super.lambdaQuery().eq(SystemUser::getAccount, userCount).one();
|
|
|
|
|