Search in sources :

Example 6 with EcBaseBusinessException

use of com.easy.cloud.core.exception.bo.EcBaseBusinessException in project dq-easy-cloud by dq-open-cloud.

the class EcLockBO method buildLockName.

/**
 * <p>
 * 构建锁的名称
 * </p>
 *
 * @param args
 * @return
 * @author daiqi
 * @创建时间 2018年4月13日 上午11:37:42
 */
private EcLockBO buildLockName(Object[] args) {
    // 注解为空先构建注解
    EcLockAnnotation distributedLock = buildEcDistributedLock().lockDTO.getLockAnnotation();
    String lockName = distributedLock.nameBody();
    if (EcStringUtils.isEmpty(lockName)) {
        if (EcArrayUtils.isEmpty(args)) {
            throw new EcBaseBusinessException(EcBaseErrorCodeEnum.OBJECT_CANT_NULL);
        }
        String param = distributedLock.param();
        int argNum = distributedLock.argNum();
        // 注解中param为empty,直接使用方法形参所在的位置的值作为lockName
        if (EcStringUtils.isEmpty(param)) {
            lockName = String.valueOf(getArgByArgNum(args, argNum));
        } else {
            Object arg = getArgByArgNum(args, argNum);
            lockName = getParamValue(arg, param);
        }
    }
    if (EcStringUtils.isEmpty(lockName)) {
        throw new EcBaseBusinessException(EcLockErrorCodeEnum.LOCK_NAME_CANT_EMPTY);
    }
    this.lockDTO.setLockName(lockName);
    return this;
}
Also used : EcLockAnnotation(com.easy.cloud.core.lock.annotation.EcLockAnnotation) EcBaseBusinessException(com.easy.cloud.core.exception.bo.EcBaseBusinessException) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint)

Example 7 with EcBaseBusinessException

use of com.easy.cloud.core.exception.bo.EcBaseBusinessException in project dq-easy-cloud by dq-open-cloud.

the class EcLockBO method buildDistributedLockResultProcessor.

/**
 * <p>
 * 构建分布式锁结果处理对象
 * </p>
 *
 * @return
 * @author daiqi
 * @创建时间 2018年4月14日 下午12:00:15
 */
private EcLockBO buildDistributedLockResultProcessor() {
    // 先构建注解
    EcLockAnnotation distributedLock = buildEcDistributedLock().lockDTO.getLockAnnotation();
    Class<? extends EcBaseLockResultProcessor> resultProcessorClass = distributedLock.resultProcessorClass();
    // 结果处理类class为空 使用默认的结果处理类进行处理
    if (EcBaseUtils.isNull(resultProcessorClass)) {
        resultProcessorClass = EcDefaultLockResultProcessor.class;
    }
    // 根据class创建结果处理对象
    resultProcessor = EcBeanFactory.newInstance(resultProcessorClass);
    if (EcBaseUtils.isNull(resultProcessor)) {
        throw new EcBaseBusinessException(EcLockErrorCodeEnum.RESULT_PROCESSOR_OBJ_CREATE_FAIL);
    }
    return this;
}
Also used : EcLockAnnotation(com.easy.cloud.core.lock.annotation.EcLockAnnotation) EcBaseBusinessException(com.easy.cloud.core.exception.bo.EcBaseBusinessException)

Example 8 with EcBaseBusinessException

use of com.easy.cloud.core.exception.bo.EcBaseBusinessException in project dq-easy-cloud by dq-open-cloud.

the class EcZfbOauthToken method doGetOauthResource.

@Override
public EcBaseOauthResourceDTO doGetOauthResource(Map<String, Object> oAuthResponseParam) throws Exception {
    AlipayUserInfoShareRequest userInfoShareRequest = new AlipayUserInfoShareRequest();
    String accessToken = EcMapUtils.getString(oAuthResponseParam, EcOauthAccessToken.ACCESS_TOKEN);
    AlipayUserInfoShareResponse shareResponse = alipayClient.execute(userInfoShareRequest, accessToken);
    EcAssert.verifyObjNull(shareResponse, "shareResponse");
    if (shareResponse != null && shareResponse.isSuccess()) {
        EcBaseOauthResourceResponse resourceResponse = EcBeanFactory.newInstance(getResourceRequestBuilder().getResourceResponseClass());
        EcBaseOauthResourceDTO resourceDTO = EcJSONUtils.parseObject(shareResponse, resourceResponse.getResourceDTOClass());
        EcLogUtils.info("授权获取到的用户信息", resourceDTO, logger);
        return resourceDTO;
    } else {
        throw new EcBaseBusinessException(shareResponse.getCode(), shareResponse.getMsg()).buildExceptionDetail(shareResponse);
    }
}
Also used : EcBaseOauthResourceResponse(com.easy.cloud.core.oauth.client.base.response.token.EcBaseOauthResourceResponse) AlipayUserInfoShareRequest(com.alipay.api.request.AlipayUserInfoShareRequest) AlipayUserInfoShareResponse(com.alipay.api.response.AlipayUserInfoShareResponse) EcBaseBusinessException(com.easy.cloud.core.exception.bo.EcBaseBusinessException) EcBaseOauthResourceDTO(com.easy.cloud.core.oauth.client.base.pojo.dto.EcBaseOauthResourceDTO)

Example 9 with EcBaseBusinessException

use of com.easy.cloud.core.exception.bo.EcBaseBusinessException in project dq-easy-cloud by dq-open-cloud.

the class EcZfbOauthToken method doGetOauthAccessToken.

@Override
public Map<String, Object> doGetOauthAccessToken() throws Exception {
    AlipaySystemOauthTokenRequest oauthTokenRequest = new AlipaySystemOauthTokenRequest();
    oauthTokenRequest.setCode(super.authCode);
    oauthTokenRequest.setGrantType(grantType);
    AlipaySystemOauthTokenResponse oauthTokenResponse = alipayClient.execute(oauthTokenRequest);
    EcAssert.verifyObjNull(oauthTokenResponse, "oauthTokenResponse");
    if (oauthTokenResponse != null && oauthTokenResponse.isSuccess()) {
        Map<String, Object> tokenRepParam = EcMapUtils.newHashMap();
        tokenRepParam.put(EcOauthAccessToken.ACCESS_TOKEN, oauthTokenResponse.getAccessToken());
        tokenRepParam.put(EcOauthAccessToken.EXPIRES_IN, oauthTokenResponse.getExpiresIn());
        tokenRepParam.put(EcOauthAccessToken.REFRESH_TOKEN, oauthTokenResponse.getRefreshToken());
        tokenRepParam.put(EcOauthAccessToken.AUTH_TOKEN_TYPE, oauthTokenResponse.getAuthTokenType());
        tokenRepParam.put(EcOauthAccessToken.OPENID, oauthTokenResponse.getUserId());
        tokenRepParam.put(EcOauthAccessToken.RE_EXPIRES_IN, oauthTokenResponse.getReExpiresIn());
        return tokenRepParam;
    } else {
        throw new EcBaseBusinessException(oauthTokenResponse.getCode(), oauthTokenResponse.getMsg()).buildExceptionDetail(oauthTokenResponse);
    }
}
Also used : AlipaySystemOauthTokenRequest(com.alipay.api.request.AlipaySystemOauthTokenRequest) AlipaySystemOauthTokenResponse(com.alipay.api.response.AlipaySystemOauthTokenResponse) EcBaseBusinessException(com.easy.cloud.core.exception.bo.EcBaseBusinessException)

Example 10 with EcBaseBusinessException

use of com.easy.cloud.core.exception.bo.EcBaseBusinessException in project dq-easy-cloud by dq-open-cloud.

the class SysRoleServiceImpl method findByUserId.

@Override
public List<SysRoleDTO> findByUserId(Long userId) {
    if (EcBaseUtils.isNull(userId)) {
        throw new EcBaseBusinessException("A_11111111", "用户编号不能为空");
    }
    SysRoleQuery query = new SysRoleQuery();
    query.setUserId(userId);
    List<SysRoleEntity> sysRoleEntities = sysRoleDAO.listByQuery(query);
    if (EcCollectionsUtils.isEmpty(sysRoleEntities)) {
        return new ArrayList<>();
    }
    return EcJSONUtils.parseArray(sysRoleEntities, SysRoleDTO.class);
}
Also used : SysRoleQuery(com.easy.cloud.core.operator.sysrole.pojo.query.SysRoleQuery) ArrayList(java.util.ArrayList) EcBaseBusinessException(com.easy.cloud.core.exception.bo.EcBaseBusinessException) SysRoleEntity(com.easy.cloud.core.operator.sysrole.pojo.entity.SysRoleEntity)

Aggregations

EcBaseBusinessException (com.easy.cloud.core.exception.bo.EcBaseBusinessException)10 EcLockAnnotation (com.easy.cloud.core.lock.annotation.EcLockAnnotation)2 AlipaySystemOauthTokenRequest (com.alipay.api.request.AlipaySystemOauthTokenRequest)1 AlipayUserInfoShareRequest (com.alipay.api.request.AlipayUserInfoShareRequest)1 AlipaySystemOauthTokenResponse (com.alipay.api.response.AlipaySystemOauthTokenResponse)1 AlipayUserInfoShareResponse (com.alipay.api.response.AlipayUserInfoShareResponse)1 EcBaseServiceResult (com.easy.cloud.core.basic.pojo.dto.EcBaseServiceResult)1 EcLogDTO (com.easy.cloud.core.common.log.pojo.dto.EcLogDTO)1 EcBaseServiceResultException (com.easy.cloud.core.exception.dto.EcBaseServiceResultException)1 EcBaseOauthResourceDTO (com.easy.cloud.core.oauth.client.base.pojo.dto.EcBaseOauthResourceDTO)1 EcBaseOauthResourceResponse (com.easy.cloud.core.oauth.client.base.response.token.EcBaseOauthResourceResponse)1 SysRoleEntity (com.easy.cloud.core.operator.sysrole.pojo.entity.SysRoleEntity)1 SysRoleQuery (com.easy.cloud.core.operator.sysrole.pojo.query.SysRoleQuery)1 EcReptileKeyValueDTO (com.easy.cloud.core.reptile.common.pojo.dto.EcReptileKeyValueDTO)1 JavassistDynamicBean (com.geccocrawler.gecco.dynamic.JavassistDynamicBean)1 HttpGetRequest (com.geccocrawler.gecco.request.HttpGetRequest)1 ArrayList (java.util.ArrayList)1 Subject (org.apache.shiro.subject.Subject)1 ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)1 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)1