Search in sources :

Example 16 with UacUser

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);
}
Also used : UacUser(com.paascloud.provider.model.domain.UacUser) MqMessageData(com.paascloud.provider.model.domain.MqMessageData) UacBizException(com.paascloud.provider.model.exceptions.UacBizException) Date(java.util.Date)

Example 17 with UacUser

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);
    }
}
Also used : UacUser(com.paascloud.provider.model.domain.UacUser) UacGroup(com.paascloud.provider.model.domain.UacGroup) UacBizException(com.paascloud.provider.model.exceptions.UacBizException) UacGroupUser(com.paascloud.provider.model.domain.UacGroupUser)

Aggregations

UacUser (com.paascloud.provider.model.domain.UacUser)17 ApiOperation (io.swagger.annotations.ApiOperation)8 LoginAuthDto (com.paascloud.base.dto.LoginAuthDto)4 UacBizException (com.paascloud.provider.model.exceptions.UacBizException)3 UserTokenDto (com.paascloud.base.dto.UserTokenDto)2 MenuVo (com.paascloud.provider.model.vo.MenuVo)2 SecurityUser (com.paascloud.security.core.SecurityUser)2 ModelMapper (org.modelmapper.ModelMapper)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 JSONObject (com.alibaba.fastjson.JSONObject)1 HttpConfig (com.arronlong.httpclientutil.common.HttpConfig)1 HttpHeader (com.arronlong.httpclientutil.common.HttpHeader)1 PageInfo (com.github.pagehelper.PageInfo)1 LogAnnotation (com.paascloud.core.annotation.LogAnnotation)1 MqMessageData (com.paascloud.provider.model.domain.MqMessageData)1 UacGroup (com.paascloud.provider.model.domain.UacGroup)1 UacGroupUser (com.paascloud.provider.model.domain.UacGroupUser)1 UacRole (com.paascloud.provider.model.domain.UacRole)1 UacUserToken (com.paascloud.provider.model.domain.UacUserToken)1 LoginRespDto (com.paascloud.provider.model.dto.user.LoginRespDto)1