|
@@ -2,6 +2,7 @@ package com.xy.annotation.aspet;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.TimeInterval;
|
|
import cn.hutool.core.date.TimeInterval;
|
|
|
|
+import com.xy.annotation.LogEnvents;
|
|
import com.xy.annotation.LogOperate;
|
|
import com.xy.annotation.LogOperate;
|
|
import com.xy.collections.list.JArrayList;
|
|
import com.xy.collections.list.JArrayList;
|
|
import com.xy.collections.list.JList;
|
|
import com.xy.collections.list.JList;
|
|
@@ -48,7 +49,7 @@ public class LogAspet {
|
|
* @throws Throwable
|
|
* @throws Throwable
|
|
*/
|
|
*/
|
|
@Around("@annotation(logOperate)")
|
|
@Around("@annotation(logOperate)")
|
|
- public Object LogOperate(ProceedingJoinPoint joinPoint, LogOperate logOperate) throws Throwable {
|
|
|
|
|
|
+ public Object logOperate(ProceedingJoinPoint joinPoint, LogOperate logOperate) throws Throwable {
|
|
TimeInterval timeInterval = DateUtil.timer();
|
|
TimeInterval timeInterval = DateUtil.timer();
|
|
LogEnum.LogType logType = logOperate.logType();
|
|
LogEnum.LogType logType = logOperate.logType();
|
|
LogEnum.OptType optType = logOperate.optType();
|
|
LogEnum.OptType optType = logOperate.optType();
|
|
@@ -85,6 +86,42 @@ public class LogAspet {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 系统事件
|
|
|
|
+ *
|
|
|
|
+ * @param joinPoint
|
|
|
|
+ * @param logEnvents
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Throwable
|
|
|
|
+ */
|
|
|
|
+ @Around("@annotation(logEnvents)")
|
|
|
|
+ public Object logEnvents(ProceedingJoinPoint joinPoint, LogEnvents logEnvents) throws Throwable {
|
|
|
|
+ //参数
|
|
|
|
+ Object[] args = joinPoint.getArgs();
|
|
|
|
+ Object result;
|
|
|
|
+ try {
|
|
|
|
+ result = joinPoint.proceed(args);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ String eventName = logEnvents.eventName();
|
|
|
|
+ String eventDescript = logEnvents.eventDescript();
|
|
|
|
+ LogEnum.EventLevel eventLevel = logEnvents.eventLevel();
|
|
|
|
+ if (!Emptys.check(eventDescript)) {
|
|
|
|
+ String api = getApi(joinPoint);
|
|
|
|
+ Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
|
|
|
|
+ ApiOperation apiOperation = method.getAnnotation(ApiOperation.class);
|
|
|
|
+ if (apiOperation != null) {
|
|
|
|
+ String value = apiOperation.value();
|
|
|
|
+ eventDescript = api + "-" + value + "------" + e.getMessage();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (Emptys.check(eventDescript)) {
|
|
|
|
+ LogUtils.envents(eventName, eventLevel, eventDescript);
|
|
|
|
+ }
|
|
|
|
+ throw e;
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
private String getApi(ProceedingJoinPoint joinPoint) {
|
|
private String getApi(ProceedingJoinPoint joinPoint) {
|
|
Class<?> classz = joinPoint.getTarget().getClass();
|
|
Class<?> classz = joinPoint.getTarget().getClass();
|
|
Api api = classz.getAnnotation(Api.class);
|
|
Api api = classz.getAnnotation(Api.class);
|