Commit 410c54df by 吕明尚

验卷AOP增加异步

parent 82361745
......@@ -16,6 +16,7 @@ import share.common.enums.YesNoEnum;
import share.system.domain.CouponLog;
import share.system.domain.SConsumerCoupon;
import share.system.domain.SStore;
import share.system.domain.vo.MqttxVo;
import share.system.service.CouponLogService;
import share.system.service.ISConsumerCouponService;
import share.system.service.ISStoreService;
......@@ -23,6 +24,7 @@ import share.system.service.ISStoreService;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.util.*;
import java.util.concurrent.CompletableFuture;
@Aspect
......@@ -37,6 +39,7 @@ public class QPServiceImplAspect {
@Autowired
private ISStoreService sStoreService;
/**
* 切点函数,用于标识需要记录操作日志的方法。
* 切点表达式为:execution(* share.system.service.impl.QPServiceImpl.*(..)),表示匹配所有在share.system.service.impl.QPServiceImpl类中定义的方法。
......@@ -89,7 +92,15 @@ public class QPServiceImplAspect {
couponLog.setStatus(YesNoEnum.yes.getDisplay_3());
couponLog.setMessage(outParams);
couponLog.setCreateTime(new Date());
couponLogService.insertCouponLog(couponLog);
// 异步执行
CompletableFuture.supplyAsync(() -> {
int i = couponLogService.insertCouponLog(couponLog);
if (i > 0) {
return true;
} else {
return false;
}
});
// }
} catch (Exception e) {
e.printStackTrace();
......@@ -119,7 +130,15 @@ public class QPServiceImplAspect {
couponLog.setStatus(YesNoEnum.no.getDisplay_3());
couponLog.setMessage(stackTraceToString(e.getClass().getName(), e.getMessage(), e.getStackTrace()));
couponLog.setCreateTime(new Date());
couponLogService.insertCouponLog(couponLog);
// 异步执行
CompletableFuture.supplyAsync(() -> {
int i = couponLogService.insertCouponLog(couponLog);
if (i > 0) {
return true;
} else {
return false;
}
});
// }
} catch (Exception e2) {
e2.printStackTrace();
......
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