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;
}
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;
}
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);
}
}
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);
}
}
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);
}
Aggregations