Commit 178e8a4b authored by yanzg's avatar yanzg

设置打包时可以通过GIT查看源码

parent 6d6a8bcf
package com.yanzuoguang.util.helper;
import com.yanzuoguang.util.vo.ResponseResult;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
/**
* 类型帮助类
*
* @author 颜佐光
*/
public class TypeHelper {
/**
*  判断是否属于子类
*
* @param from
* @param to
* @return
*/
public static boolean isSubType(Type from, Class to) {
Class returnClass = getClass(from);
boolean isResponseResult = returnClass != null && returnClass.isAssignableFrom(ResponseResult.class);
return isResponseResult;
}
/**
* 获取type的class
*
* @param type
* @return
*/
public static Class getClass(Type type) {
if (type instanceof ParameterizedType) {
Type rawType = ((ParameterizedType) type).getRawType();
return getClass(rawType);
} else if (type instanceof Class) {
return (Class) type;
}
return null;
}
}
...@@ -3,6 +3,7 @@ package com.yanzuoguang.cloud.aop; ...@@ -3,6 +3,7 @@ package com.yanzuoguang.cloud.aop;
import com.yanzuoguang.cloud.service.TokenServiceCall; import com.yanzuoguang.cloud.service.TokenServiceCall;
import com.yanzuoguang.token.TokenHelper; import com.yanzuoguang.token.TokenHelper;
import com.yanzuoguang.util.exception.ExceptionHelper; import com.yanzuoguang.util.exception.ExceptionHelper;
import com.yanzuoguang.util.helper.TypeHelper;
import com.yanzuoguang.util.log.Log; import com.yanzuoguang.util.log.Log;
import com.yanzuoguang.util.vo.ResponseResult; import com.yanzuoguang.util.vo.ResponseResult;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
...@@ -102,9 +103,7 @@ public class WebAspect extends BaseRequestAspect { ...@@ -102,9 +103,7 @@ public class WebAspect extends BaseRequestAspect {
ex = e; ex = e;
result = ExceptionHelper.getError(e); result = ExceptionHelper.getError(e);
Type returnType = getReturnType(joinPoint); Type returnType = getReturnType(joinPoint);
Class returnClass = getClass(returnType); if (TypeHelper.isSubType(returnType, ResponseResult.class)) {
boolean isResponseResult = returnClass != null && returnClass.isAssignableFrom(ResponseResult.class);
if (isResponseResult) {
return result; return result;
} else { } else {
throw e; throw e;
...@@ -118,16 +117,6 @@ public class WebAspect extends BaseRequestAspect { ...@@ -118,16 +117,6 @@ public class WebAspect extends BaseRequestAspect {
} }
} }
private Class getClass(Type type) {
if (type instanceof ParameterizedType) {
Type rawType = ((ParameterizedType) type).getRawType();
return getClass(rawType);
} else if (type instanceof Class) {
return (Class) type;
}
return null;
}
/** /**
* 是否属于网关服务,网关服务不进行监控 * 是否属于网关服务,网关服务不进行监控
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment