|
@@ -4,13 +4,12 @@ import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.iocoder.yudao.framework.common.util.spring.SpringExpressionUtils;
|
|
|
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
|
|
-import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.dto.TradeAfterSaleLogCreateReqDTO;
|
|
|
import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.annotations.AfterSaleLog;
|
|
|
+import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.dto.TradeAfterSaleLogCreateReqDTO;
|
|
|
import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.service.AfterSaleLogService;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.aspectj.lang.JoinPoint;
|
|
|
-import org.aspectj.lang.ProceedingJoinPoint;
|
|
|
import org.aspectj.lang.annotation.AfterReturning;
|
|
|
import org.aspectj.lang.annotation.Aspect;
|
|
|
import org.aspectj.lang.reflect.MethodSignature;
|
|
@@ -34,6 +33,11 @@ public class AfterSaleLogAspect {
|
|
|
@Resource
|
|
|
private AfterSaleLogService saleLogService;
|
|
|
|
|
|
+ private final static String OPERATE_TYPE = "operateType", ID = "id", CONTENT = "content";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 切面存入日志
|
|
|
+ */
|
|
|
@AfterReturning(pointcut = "@annotation(afterSaleLog)", returning = "info")
|
|
|
public void doAfterReturning(JoinPoint joinPoint, AfterSaleLog afterSaleLog, Object info) {
|
|
|
try {
|
|
@@ -42,10 +46,11 @@ public class AfterSaleLogAspect {
|
|
|
Long id = WebFrameworkUtils.getLoginUserId();
|
|
|
Map<String, String> formatObj = spelFormat(joinPoint, info);
|
|
|
TradeAfterSaleLogCreateReqDTO dto = new TradeAfterSaleLogCreateReqDTO()
|
|
|
- .setUserId(id).setUserType(userType)
|
|
|
- .setAfterSaleId(MapUtil.getLong(formatObj, "id"))
|
|
|
- .setContent(formatObj.get("content"))
|
|
|
- .setOperateType(formatObj.get("operateType"));
|
|
|
+ .setUserId(id)
|
|
|
+ .setUserType(userType)
|
|
|
+ .setAfterSaleId(MapUtil.getLong(formatObj, ID))
|
|
|
+ .setOperateType(MapUtil.getStr(formatObj, OPERATE_TYPE))
|
|
|
+ .setContent(MapUtil.getStr(formatObj, CONTENT));
|
|
|
// 异步存入数据库
|
|
|
saleLogService.createLog(dto);
|
|
|
} catch (Exception exception) {
|
|
@@ -59,21 +64,21 @@ public class AfterSaleLogAspect {
|
|
|
public static Map<String, String> spelFormat(JoinPoint joinPoint, Object info) {
|
|
|
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
|
|
AfterSaleLog afterSaleLogPoint = signature.getMethod().getAnnotation(AfterSaleLog.class);
|
|
|
- HashMap<String, String> result = Maps.newHashMapWithExpectedSize(3);
|
|
|
+ HashMap<String, String> result = Maps.newHashMapWithExpectedSize(2);
|
|
|
Map<String, Object> spelMap = SpringExpressionUtils.parseExpression(joinPoint, info,
|
|
|
- asList(afterSaleLogPoint.id(), afterSaleLogPoint.operateType().description(), afterSaleLogPoint.content()));
|
|
|
+ asList(afterSaleLogPoint.id(), afterSaleLogPoint.content()));
|
|
|
// 售后ID
|
|
|
String id = MapUtil.getStr(spelMap, afterSaleLogPoint.id());
|
|
|
- result.put("id", id);
|
|
|
+ result.put(ID, id);
|
|
|
// 操作类型
|
|
|
- String operateType = MapUtil.getStr(spelMap, afterSaleLogPoint.operateType().description());
|
|
|
- result.put("operateType", operateType);
|
|
|
+ String operateType = afterSaleLogPoint.operateType().description();
|
|
|
+ result.put(OPERATE_TYPE, operateType);
|
|
|
// 日志内容
|
|
|
String content = MapUtil.getStr(spelMap, afterSaleLogPoint.content());
|
|
|
if (ObjectUtil.isNotNull(afterSaleLogPoint.operateType())) {
|
|
|
- content += MapUtil.getStr(spelMap, afterSaleLogPoint.operateType().description());
|
|
|
+ content += operateType;
|
|
|
}
|
|
|
- result.put("content", content);
|
|
|
+ result.put(CONTENT, content);
|
|
|
return result;
|
|
|
}
|
|
|
|