Search in sources :

Example 1 with UacBizException

use of com.paascloud.provider.model.exceptions.UacBizException in project paascloud-master by paascloud.

the class UserManager method activeUser.

@MqProducerStore
public void activeUser(final MqMessageData mqMessageData, final UacUser uacUser, final String activeUserKey) {
    log.info("激活用户. mqMessageData={}, user={}", mqMessageData, uacUser);
    int result = uacUserMapper.updateByPrimaryKeySelective(uacUser);
    if (result < 1) {
        throw new UacBizException(ErrorCodeEnum.UAC10011038, uacUser.getId());
    }
    // 绑定一个访客角色默认值roleId=10000
    final Long userId = uacUser.getId();
    Preconditions.checkArgument(userId != null, "用戶Id不能爲空");
    final Long roleId = 10000L;
    UacRoleUser roleUser = new UacRoleUser();
    roleUser.setUserId(userId);
    roleUser.setRoleId(roleId);
    uacRoleUserMapper.insertSelective(roleUser);
    // 绑定一个组织
    UacGroupUser groupUser = new UacGroupUser();
    groupUser.setUserId(userId);
    groupUser.setGroupId(GlobalConstant.Sys.SUPER_MANAGER_GROUP_ID);
    uacGroupUserMapper.insertSelective(groupUser);
    // 删除 activeUserToken
    redisService.deleteKey(activeUserKey);
}
Also used : UacBizException(com.paascloud.provider.model.exceptions.UacBizException) UacRoleUser(com.paascloud.provider.model.domain.UacRoleUser) UacGroupUser(com.paascloud.provider.model.domain.UacGroupUser) MqProducerStore(com.paascloud.provider.annotation.MqProducerStore)

Example 2 with UacBizException

use of com.paascloud.provider.model.exceptions.UacBizException in project paascloud-master by paascloud.

the class SmsProducer method sendSmsCodeMq.

public MqMessageData sendSmsCodeMq(SmsMessage smsMessage, AliyunSmsConstants.SmsTempletEnum templetEnum) {
    log.info("sendSmsCodeMq - 发送短信验证码. smsMessage={}", smsMessage);
    String msgBody;
    try {
        PcSendSmsRequest request = new PcSendSmsRequest();
        Map<String, String> map = Maps.newHashMap();
        // 模板参数
        String smsParamName = templetEnum.getSmsParamName();
        // 模板编码
        String templetCode = templetEnum.getTempletCode();
        // 替换模板验证码
        map.put(smsParamName, smsMessage.getSmsCode());
        String param = JSON.toJSONString(map);
        request.setPhoneNumbers(smsMessage.getMobileNo());
        request.setTemplateCode(templetCode);
        request.setTemplateParam(param);
        request.setOutId(smsMessage.getOutId());
        msgBody = JSON.toJSONString(request);
    } catch (Exception e) {
        log.error("发送短信验证码 smsMessage转换为json字符串失败", e);
        throw new UacBizException(ErrorCodeEnum.UAC10011022);
    }
    String topic = AliyunMqTopicConstants.MqTopicEnum.SEND_SMS_TOPIC.getTopic();
    String tag = AliyunMqTopicConstants.MqTagEnum.REGISTER_USER_AUTH_CODE.getTag();
    String key = RedisKeyUtil.createMqKey(topic, tag, smsMessage.getMobileNo(), msgBody);
    return new MqMessageData(msgBody, topic, tag, key);
}
Also used : PcSendSmsRequest(com.paascloud.provider.model.dto.PcSendSmsRequest) MqMessageData(com.paascloud.provider.model.domain.MqMessageData) UacBizException(com.paascloud.provider.model.exceptions.UacBizException) UacBizException(com.paascloud.provider.model.exceptions.UacBizException)

Example 3 with UacBizException

use of com.paascloud.provider.model.exceptions.UacBizException in project paascloud-master by paascloud.

the class EmailServiceImpl method decryptEmail.

private String decryptEmail(final String loginName, String email) {
    try {
        email = HttpAesUtil.decrypt(email, KEY_STR, false, IV_STR);
        log.info("发送短信 解密loginName={}", loginName);
        log.info("发送短信 解密email={}", email);
    } catch (Exception ex) {
        log.info("发送短信 解密手机号码失败 密文loginName={}, email={}", loginName, email);
        throw new UacBizException(ErrorCodeEnum.UAC10011031);
    }
    return email;
}
Also used : UacBizException(com.paascloud.provider.model.exceptions.UacBizException) UacBizException(com.paascloud.provider.model.exceptions.UacBizException)

Example 4 with UacBizException

use of com.paascloud.provider.model.exceptions.UacBizException in project paascloud-master by paascloud.

the class UacActionServiceImpl method deleteActionById.

@Override
public int deleteActionById(Long actionId) {
    // 查询该角色下是否有用户绑定, 有的话提醒不能删除
    if (null == actionId) {
        throw new IllegalArgumentException("权限ID不能为空");
    }
    UacAction uacAction = uacActionMapper.selectByPrimaryKey(actionId);
    if (uacAction == null) {
        logger.error("找不到权限信息 actionId={}", actionId);
        throw new UacBizException(ErrorCodeEnum.UAC10014001, actionId);
    }
    // 删除角色权限表数据  不查询了 直接删除了
    uacRoleActionMapper.deleteByActionId(actionId);
    return uacActionMapper.deleteByPrimaryKey(actionId);
}
Also used : UacAction(com.paascloud.provider.model.domain.UacAction) UacBizException(com.paascloud.provider.model.exceptions.UacBizException)

Example 5 with UacBizException

use of com.paascloud.provider.model.exceptions.UacBizException in project paascloud-master by paascloud.

the class UacGroupServiceImpl method saveUacGroup.

@Override
public int saveUacGroup(UacGroup group, LoginAuthDto loginAuthDto) {
    int result;
    Preconditions.checkArgument(!StringUtils.isEmpty(group.getPid()), "上级节点不能为空");
    UacGroup parenGroup = uacGroupMapper.selectByPrimaryKey(group.getPid());
    if (PublicUtil.isEmpty(parenGroup)) {
        throw new UacBizException(ErrorCodeEnum.UAC10015009, group.getPid());
    }
    setGroupAddress(group);
    group.setUpdateInfo(loginAuthDto);
    if (group.isNew()) {
        Long groupId = super.generateId();
        group.setId(groupId);
        group.setLevel(parenGroup.getLevel() + 1);
        result = this.addUacGroup(group);
    } else {
        result = this.editUacGroup(group);
    }
    return result;
}
Also used : UacGroup(com.paascloud.provider.model.domain.UacGroup) UacBizException(com.paascloud.provider.model.exceptions.UacBizException)

Aggregations

UacBizException (com.paascloud.provider.model.exceptions.UacBizException)37 Transactional (org.springframework.transaction.annotation.Transactional)8 UacGroup (com.paascloud.provider.model.domain.UacGroup)6 UacMenu (com.paascloud.provider.model.domain.UacMenu)6 LoginAuthDto (com.paascloud.base.dto.LoginAuthDto)5 UacGroupUser (com.paascloud.provider.model.domain.UacGroupUser)5 MqMessageData (com.paascloud.provider.model.domain.MqMessageData)4 UacRoleMenu (com.paascloud.provider.model.domain.UacRoleMenu)4 UacRoleUser (com.paascloud.provider.model.domain.UacRoleUser)4 MenuVo (com.paascloud.provider.model.vo.MenuVo)4 UacRoleAction (com.paascloud.provider.model.domain.UacRoleAction)3 UacUser (com.paascloud.provider.model.domain.UacUser)3 BindAuthVo (com.paascloud.provider.model.vo.BindAuthVo)2 UserBindRoleVo (com.paascloud.provider.model.vo.UserBindRoleVo)2 ApiOperation (io.swagger.annotations.ApiOperation)2 Date (java.util.Date)2 LogAnnotation (com.paascloud.core.annotation.LogAnnotation)1 MqProducerStore (com.paascloud.provider.annotation.MqProducerStore)1 UacAction (com.paascloud.provider.model.domain.UacAction)1 UacRole (com.paascloud.provider.model.domain.UacRole)1