|
@@ -12,6 +12,7 @@ import com.diagbot.log.entity.BiRecord;
|
|
|
import com.diagbot.log.entity.SysLog;
|
|
|
import com.diagbot.vo.BaseBiVO;
|
|
|
import org.aspectj.lang.JoinPoint;
|
|
|
+import org.aspectj.lang.ProceedingJoinPoint;
|
|
|
import org.aspectj.lang.reflect.MethodSignature;
|
|
|
import org.springframework.validation.BindException;
|
|
|
import org.springframework.validation.FieldError;
|
|
@@ -35,7 +36,7 @@ public class AopUtil {
|
|
|
* @param joinPoint
|
|
|
* @param sysType
|
|
|
*/
|
|
|
- public static SysLog SysLoggerAspect(JoinPoint joinPoint, Integer sysType) {
|
|
|
+ public static SysLog sysLoggerAspect(JoinPoint joinPoint, Integer sysType) {
|
|
|
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
|
|
Method method = signature.getMethod();
|
|
|
|
|
@@ -76,7 +77,7 @@ public class AopUtil {
|
|
|
* @param joinPoint
|
|
|
* @param sysType
|
|
|
*/
|
|
|
- public static SysLog SysLoggerExprotAspect(JoinPoint joinPoint, Integer sysType) {
|
|
|
+ public static SysLog sysLoggerExprotAspect(JoinPoint joinPoint, Integer sysType) {
|
|
|
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
|
|
Method method = signature.getMethod();
|
|
|
|
|
@@ -115,24 +116,30 @@ public class AopUtil {
|
|
|
/**
|
|
|
* Bi日志有返回值处理(普通)
|
|
|
*
|
|
|
+ * @param biRecord
|
|
|
* @param joinPoint
|
|
|
- * @param keys
|
|
|
* @param productType
|
|
|
* @return
|
|
|
+ * @throws Throwable
|
|
|
*/
|
|
|
- public static BiRecord BiLoggerAspect(JoinPoint joinPoint, Object keys, Integer productType) {
|
|
|
- BiRecord biRecord = new BiRecord();
|
|
|
+ public static Object biLoggerAspect(BiRecord biRecord, ProceedingJoinPoint joinPoint,
|
|
|
+ Integer productType) throws Throwable {
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
+ Object object = joinPoint.proceed();
|
|
|
if (!biRecordSet(biRecord, joinPoint, productType, BiSourceEnum.BI_NORMAL.getKey())) {
|
|
|
- return null;
|
|
|
+ biRecord = null;
|
|
|
+ return object;
|
|
|
}
|
|
|
//出参设置
|
|
|
String result = "";
|
|
|
- result = FastJsonUtils.getBeanToJson(keys);
|
|
|
+ result = FastJsonUtils.getBeanToJson(object);
|
|
|
if (!StringUtil.isEmpty(result)) {
|
|
|
biRecord.setResult(result);
|
|
|
}
|
|
|
biRecord.setSuccessFlag(1);
|
|
|
- return biRecord;
|
|
|
+ long execTime = System.currentTimeMillis() - start;
|
|
|
+ biRecord.setExecTime(String.valueOf(execTime));
|
|
|
+ return object;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -143,7 +150,7 @@ public class AopUtil {
|
|
|
* @param productType
|
|
|
* @return
|
|
|
*/
|
|
|
- public static BiRecord BiLoggerAspectThrow(JoinPoint joinPoint, Throwable ex, Integer productType) {
|
|
|
+ public static BiRecord biLoggerAspectThrow(JoinPoint joinPoint, Throwable ex, Integer productType) {
|
|
|
BiRecord biRecord = new BiRecord();
|
|
|
if (!biRecordSet(biRecord, joinPoint, productType, BiSourceEnum.BI_NORMAL.getKey())) {
|
|
|
return null;
|
|
@@ -159,33 +166,39 @@ public class AopUtil {
|
|
|
/**
|
|
|
* Bi日志有返回值处理(特殊)
|
|
|
*
|
|
|
+ * @param biRecord
|
|
|
* @param joinPoint
|
|
|
- * @param keys
|
|
|
* @param productType
|
|
|
* @return
|
|
|
+ * @throws Throwable
|
|
|
*/
|
|
|
- public static BiRecord BiLoggerResultAspect(JoinPoint joinPoint, Object keys, Integer productType) {
|
|
|
- BiRecord biRecord = new BiRecord();
|
|
|
+ public static Object biLoggerResultAspect(BiRecord biRecord, ProceedingJoinPoint joinPoint,
|
|
|
+ Integer productType) throws Throwable {
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
+ Object object = joinPoint.proceed();
|
|
|
if (!biRecordSet(biRecord, joinPoint, productType, BiSourceEnum.BI_RESULT.getKey())) {
|
|
|
- return null;
|
|
|
+ biRecord = null;
|
|
|
+ return object;
|
|
|
}
|
|
|
//出参设置
|
|
|
String result = "";
|
|
|
- if (keys instanceof RespDTO) {
|
|
|
- RespDTO respDTO = (RespDTO) keys;
|
|
|
+ if (object instanceof RespDTO) {
|
|
|
+ RespDTO respDTO = (RespDTO) object;
|
|
|
RespDTO rs = new RespDTO();
|
|
|
rs.code = respDTO.code;
|
|
|
rs.msg = respDTO.msg;
|
|
|
rs.data = new Object();
|
|
|
result = FastJsonUtils.getBeanToJson(rs);
|
|
|
} else {
|
|
|
- result = FastJsonUtils.getBeanToJson(keys);
|
|
|
+ result = FastJsonUtils.getBeanToJson(object);
|
|
|
}
|
|
|
if (!StringUtil.isEmpty(result)) {
|
|
|
biRecord.setResult(result);
|
|
|
}
|
|
|
biRecord.setSuccessFlag(1);
|
|
|
- return biRecord;
|
|
|
+ long execTime = System.currentTimeMillis() - start;
|
|
|
+ biRecord.setExecTime(String.valueOf(execTime));
|
|
|
+ return object;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -196,7 +209,7 @@ public class AopUtil {
|
|
|
* @param productType
|
|
|
* @return
|
|
|
*/
|
|
|
- public static BiRecord BiLoggerResultAspectThrow(JoinPoint joinPoint, Throwable ex, Integer productType) {
|
|
|
+ public static BiRecord biLoggerResultAspectThrow(JoinPoint joinPoint, Throwable ex, Integer productType) {
|
|
|
BiRecord biRecord = new BiRecord();
|
|
|
if (!biRecordSet(biRecord, joinPoint, productType, BiSourceEnum.BI_RESULT.getKey())) {
|
|
|
return null;
|
|
@@ -312,7 +325,6 @@ public class AopUtil {
|
|
|
}
|
|
|
resp.code = CommonErrorCode.FAIL.getCode();
|
|
|
resp.msg = e.getMessage();
|
|
|
- e.printStackTrace();
|
|
|
return resp;
|
|
|
}
|
|
|
}
|