Search in sources :

Example 1 with MqProducerStore

use of com.paascloud.provider.annotation.MqProducerStore 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 MqProducerStore

use of com.paascloud.provider.annotation.MqProducerStore in project paascloud-master by paascloud.

the class MqProducerStoreAspect method processMqProducerStoreJoinPoint.

/**
 * Add exe time method object.
 *
 * @param joinPoint the join point
 *
 * @return the object
 */
@Around(value = "mqProducerStoreAnnotationPointcut()")
public Object processMqProducerStoreJoinPoint(ProceedingJoinPoint joinPoint) throws Throwable {
    log.info("processMqProducerStoreJoinPoint - 线程id={}", Thread.currentThread().getId());
    Object result;
    Object[] args = joinPoint.getArgs();
    MqProducerStore annotation = getAnnotation(joinPoint);
    MqSendTypeEnum type = annotation.sendType();
    int orderType = annotation.orderType().orderType();
    DelayLevelEnum delayLevelEnum = annotation.delayLevel();
    if (args.length == 0) {
        throw new TpcBizException(ErrorCodeEnum.TPC10050005);
    }
    MqMessageData domain = null;
    for (Object object : args) {
        if (object instanceof MqMessageData) {
            domain = (MqMessageData) object;
            break;
        }
    }
    if (domain == null) {
        throw new TpcBizException(ErrorCodeEnum.TPC10050005);
    }
    domain.setOrderType(orderType);
    domain.setProducerGroup(producerGroup);
    if (type == MqSendTypeEnum.WAIT_CONFIRM) {
        if (delayLevelEnum != DelayLevelEnum.ZERO) {
            domain.setDelayLevel(delayLevelEnum.delayLevel());
        }
        mqMessageService.saveWaitConfirmMessage(domain);
    }
    result = joinPoint.proceed();
    if (type == MqSendTypeEnum.SAVE_AND_SEND) {
        mqMessageService.saveAndSendMessage(domain);
    } else if (type == MqSendTypeEnum.DIRECT_SEND) {
        mqMessageService.directSendMessage(domain);
    } else {
        final MqMessageData finalDomain = domain;
        taskExecutor.execute(() -> mqMessageService.confirmAndSendMessage(finalDomain.getMessageKey()));
    }
    return result;
}
Also used : MqProducerStore(com.paascloud.provider.annotation.MqProducerStore) MqMessageData(com.paascloud.provider.model.domain.MqMessageData) MqSendTypeEnum(com.paascloud.provider.model.enums.MqSendTypeEnum) DelayLevelEnum(com.paascloud.provider.model.enums.DelayLevelEnum) TpcBizException(com.paascloud.provider.exceptions.TpcBizException) JoinPoint(org.aspectj.lang.JoinPoint) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) Around(org.aspectj.lang.annotation.Around)

Aggregations

MqProducerStore (com.paascloud.provider.annotation.MqProducerStore)2 TpcBizException (com.paascloud.provider.exceptions.TpcBizException)1 MqMessageData (com.paascloud.provider.model.domain.MqMessageData)1 UacGroupUser (com.paascloud.provider.model.domain.UacGroupUser)1 UacRoleUser (com.paascloud.provider.model.domain.UacRoleUser)1 DelayLevelEnum (com.paascloud.provider.model.enums.DelayLevelEnum)1 MqSendTypeEnum (com.paascloud.provider.model.enums.MqSendTypeEnum)1 UacBizException (com.paascloud.provider.model.exceptions.UacBizException)1 JoinPoint (org.aspectj.lang.JoinPoint)1 ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)1 Around (org.aspectj.lang.annotation.Around)1