use of com.paascloud.provider.model.domain.UacUser in project paascloud-master by paascloud.
the class EmailServiceImpl method submitResetPwdEmail.
@Override
public void submitResetPwdEmail(String email) {
Preconditions.checkArgument(StringUtils.isNotEmpty(email), ErrorCodeEnum.UAC10011018.msg());
// 获取用户名
UacUser uacUser = new UacUser();
uacUser.setEmail(email);
uacUser = uacUserService.selectOne(uacUser);
if (uacUser == null) {
throw new UacBizException(ErrorCodeEnum.UAC10011004, email);
}
String resetPwdKey = PubUtils.uuid() + UniqueIdGenerator.generateId();
redisTemplate.opsForValue().set(RedisKeyUtil.getResetPwdTokenKey(resetPwdKey), uacUser, 7 * 24, TimeUnit.HOURS);
Map<String, Object> param = Maps.newHashMap();
param.put("loginName", uacUser.getLoginName());
param.put("email", email);
param.put("resetPwdUrl", resetPwdUrl + resetPwdKey);
param.put("dateTime", DateUtil.formatDateTime(new Date()));
Set<String> to = Sets.newHashSet();
to.add(email);
MqMessageData messageData = emailProducer.sendEmailMq(to, UacEmailTemplateEnum.RESET_PWD_SEND_MAIL, AliyunMqTopicConstants.MqTagEnum.FORGOT_PASSWORD_AUTH_CODE, param);
userManager.submitResetPwdEmail(messageData);
}
use of com.paascloud.provider.model.domain.UacUser in project paascloud-master by paascloud.
the class UacGroupServiceImpl method bindUacUser4Group.
/**
* Bind uac user 4 group int.
*
* @param groupBindUserReqDto the group bind user req dto
* @param authResDto the auth res dto
*/
@Override
public void bindUacUser4Group(GroupBindUserReqDto groupBindUserReqDto, LoginAuthDto authResDto) {
if (groupBindUserReqDto == null) {
logger.error("参数不能为空");
throw new IllegalArgumentException("参数不能为空");
}
Long groupId = groupBindUserReqDto.getGroupId();
Long loginUserId = authResDto.getUserId();
List<Long> userIdList = groupBindUserReqDto.getUserIdList();
if (null == groupId) {
throw new IllegalArgumentException("組織ID不能为空");
}
UacGroup group = uacGroupMapper.selectByPrimaryKey(groupId);
if (group == null) {
logger.error("找不到角色信息 groupId={}", groupId);
throw new UacBizException(ErrorCodeEnum.UAC10015001, groupId);
}
if (PublicUtil.isNotEmpty(userIdList) && userIdList.contains(loginUserId)) {
logger.error("不能操作当前登录用户 userId={}", loginUserId);
throw new UacBizException(ErrorCodeEnum.UAC10011023);
}
// 查询超级管理员用户Id集合
List<Long> superUserList = uacRoleUserMapper.listSuperUser(GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID);
List<Long> unionList = Collections3.intersection(userIdList, superUserList);
if (PublicUtil.isNotEmpty(userIdList) && PublicUtil.isNotEmpty(unionList)) {
logger.error("不能操作超级管理员用户 超级用户={}", unionList);
throw new UacBizException(ErrorCodeEnum.UAC10011023);
}
// 1. 先取消对该角色的用户绑定(不包含超级管理员用户)
List<UacGroupUser> groupUsers = uacGroupUserMapper.listByGroupId(groupId);
if (PublicUtil.isNotEmpty(groupUsers)) {
uacGroupUserMapper.deleteExcludeSuperMng(groupId, GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID);
}
if (PublicUtil.isEmpty(userIdList)) {
// 取消该角色的所有用户的绑定
logger.info("取消绑定所有非超级管理员用户成功");
return;
}
// 绑定所选用户
for (Long userId : userIdList) {
UacUser uacUser = uacUserService.queryByUserId(userId);
if (PublicUtil.isEmpty(uacUser)) {
logger.error("找不到绑定的用户 userId={}", userId);
throw new UacBizException(ErrorCodeEnum.UAC10011024, userId);
}
UacGroupUser uacGroupUser = new UacGroupUser();
uacGroupUser.setUserId(userId);
uacGroupUser.setGroupId(groupId);
uacGroupUserMapper.insertSelective(uacGroupUser);
}
}
Aggregations