use of com.chao.cloud.common.entity.Response in project chao-cloud by chaojunzi.
the class FeignFallbackProxy method around.
/**
* feign异步调用拦截
*/
@Around(value = "@annotation(com.chao.cloud.common.extra.feign.annotation.FeignFallback)")
public Object around(ProceedingJoinPoint pdj) throws Exception {
Object obj = null;
String serverName = "undefined";
try {
Method method = getMethod(pdj);
Object target = pdj.getTarget();
String targetString = target.toString();
serverName = targetString.split(",")[1];
log.info("[\nFeignClient={},\nMethod={},\nParam={}]", targetString, method, pdj.getArgs());
obj = pdj.proceed();
} catch (Throwable e) {
throw new BusinessException("[Server:" + serverName + "]" + e.getMessage());
}
if (obj instanceof Response) {
Response<?> result = (Response<?>) obj;
if (!ResultCodeEnum.CODE_200.code().equals(result.getRetCode())) {
throw new BusinessException(result.getRetMsg());
}
}
return obj;
}
Aggregations