mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	code review:售后日志逻辑
This commit is contained in:
		| @@ -7,12 +7,13 @@ import org.springframework.expression.EvaluationContext; | |||||||
| import org.springframework.expression.spel.standard.SpelExpressionParser; | import org.springframework.expression.spel.standard.SpelExpressionParser; | ||||||
| import org.springframework.expression.spel.support.StandardEvaluationContext; | import org.springframework.expression.spel.support.StandardEvaluationContext; | ||||||
|  |  | ||||||
|  | // TODO @Chopper:和 SpringExpressionUtils 合并下 | ||||||
| /** | /** | ||||||
|  * SpelUtil |  * SpelUtil | ||||||
|  * |  * | ||||||
|  * @author Chopper |  * @author Chopper | ||||||
|  * @version v1.0 |  * @version v1.0 | ||||||
|  * 2021-01-11 10:45 |  * @since 2021-01-11 10:45 | ||||||
|  */ |  */ | ||||||
| public class SpelUtil { | public class SpelUtil { | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,11 +1,10 @@ | |||||||
| package cn.iocoder.yudao.framework.trade.config; | package cn.iocoder.yudao.framework.trade.config; | ||||||
|  |  | ||||||
| import cn.iocoder.yudao.framework.trade.core.annotations.AfterSaleLog; |  | ||||||
| import cn.iocoder.yudao.framework.trade.core.aop.AfterSaleLogAspect; | import cn.iocoder.yudao.framework.trade.core.aop.AfterSaleLogAspect; | ||||||
| import cn.iocoder.yudao.module.system.api.logger.OperateLogApi; |  | ||||||
| import org.springframework.boot.autoconfigure.AutoConfiguration; | import org.springframework.boot.autoconfigure.AutoConfiguration; | ||||||
| import org.springframework.context.annotation.Bean; | import org.springframework.context.annotation.Bean; | ||||||
|  |  | ||||||
|  | // TODO @Chopper:和 yudao-module-trade-biz 的 framework 里 | ||||||
| @AutoConfiguration | @AutoConfiguration | ||||||
| public class YudaoAfterSaleLogAutoConfiguration { | public class YudaoAfterSaleLogAutoConfiguration { | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,15 +1,12 @@ | |||||||
| package cn.iocoder.yudao.framework.trade.core.annotations; | package cn.iocoder.yudao.framework.trade.core.annotations; | ||||||
|  |  | ||||||
| import org.aspectj.lang.annotation.Aspect; |  | ||||||
| import org.springframework.stereotype.Component; |  | ||||||
|  |  | ||||||
| import java.lang.annotation.*; | import java.lang.annotation.*; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 售后日志 |  * 售后日志 | ||||||
|  * |  * | ||||||
|  * @author 陈賝 |  * @author 陈賝 | ||||||
|  * @date 2023/6/8 17:04 |  * @since 2023/6/8 17:04 | ||||||
|  */ |  */ | ||||||
| @Target({ElementType.METHOD,ElementType.TYPE}) | @Target({ElementType.METHOD,ElementType.TYPE}) | ||||||
| @Retention(RetentionPolicy.RUNTIME) | @Retention(RetentionPolicy.RUNTIME) | ||||||
| @@ -21,6 +18,7 @@ public @interface AfterSaleLog { | |||||||
|      */ |      */ | ||||||
|     String id(); |     String id(); | ||||||
|  |  | ||||||
|  |     // TODO @陈賝:是不是改成一个操作的枚举? | ||||||
|     /** |     /** | ||||||
|      * 操作类型 |      * 操作类型 | ||||||
|      */ |      */ | ||||||
|   | |||||||
| @@ -1,29 +1,27 @@ | |||||||
| package cn.iocoder.yudao.framework.trade.core.aop; | package cn.iocoder.yudao.framework.trade.core.aop; | ||||||
|  |  | ||||||
| import cn.hutool.core.text.CharSequenceUtil; | import cn.hutool.core.util.StrUtil; | ||||||
| import cn.hutool.extra.spring.SpringUtil; | import cn.hutool.extra.spring.SpringUtil; | ||||||
| import cn.iocoder.yudao.framework.common.util.spel.SpelUtil; | import cn.iocoder.yudao.framework.common.util.spel.SpelUtil; | ||||||
| import cn.iocoder.yudao.framework.trade.core.annotations.AfterSaleLog; | import cn.iocoder.yudao.framework.trade.core.annotations.AfterSaleLog; | ||||||
| import cn.iocoder.yudao.framework.trade.core.dto.TradeAfterSaleLogDTO; | import cn.iocoder.yudao.framework.trade.core.dto.TradeAfterSaleLogCreateReqDTO; | ||||||
| import cn.iocoder.yudao.framework.trade.core.enums.AfterSaleStatusEnum; | import cn.iocoder.yudao.framework.trade.core.enums.AfterSaleStatusEnum; | ||||||
| import cn.iocoder.yudao.framework.trade.core.service.AfterSaleLogService; | import cn.iocoder.yudao.framework.trade.core.service.AfterSaleLogService; | ||||||
| import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; | import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; | ||||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||||
| import org.aspectj.lang.JoinPoint; | import org.aspectj.lang.JoinPoint; | ||||||
| import org.aspectj.lang.annotation.AfterReturning; | import org.aspectj.lang.annotation.AfterReturning; | ||||||
| import org.aspectj.lang.annotation.Around; |  | ||||||
| import org.aspectj.lang.annotation.Aspect; | import org.aspectj.lang.annotation.Aspect; | ||||||
| import org.aspectj.lang.reflect.MethodSignature; | import org.aspectj.lang.reflect.MethodSignature; | ||||||
| import org.springframework.stereotype.Component; |  | ||||||
|  |  | ||||||
| import java.util.HashMap; | import java.util.HashMap; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 售后日志 |  * 记录售后日志的 AOP 切面 | ||||||
|  * |  * | ||||||
|  * @author 陈賝 |  * @author 陈賝 | ||||||
|  * @date 2023/6/13 13:54 |  * @since 2023/6/13 13:54 | ||||||
|  */ |  */ | ||||||
| @Slf4j | @Slf4j | ||||||
| @Aspect | @Aspect | ||||||
| @@ -36,16 +34,16 @@ public class AfterSaleLogAspect { | |||||||
|             Integer userType = WebFrameworkUtils.getLoginUserType(); |             Integer userType = WebFrameworkUtils.getLoginUserType(); | ||||||
|             Long id = WebFrameworkUtils.getLoginUserId(); |             Long id = WebFrameworkUtils.getLoginUserId(); | ||||||
|             Map<String, String> formatObj = spelFormat(joinPoint, info); |             Map<String, String> formatObj = spelFormat(joinPoint, info); | ||||||
|             TradeAfterSaleLogDTO dto = new TradeAfterSaleLogDTO() |             TradeAfterSaleLogCreateReqDTO dto = new TradeAfterSaleLogCreateReqDTO() | ||||||
|                     .setUserId(id) |                     .setUserId(id).setUserType(userType) | ||||||
|                     .setUserType(userType) | //            MapUtil.getLong() TODO @陈賝:试试这个方法 | ||||||
|                     .setAfterSaleId(Long.valueOf(formatObj.get("id"))) |                     .setAfterSaleId(Long.valueOf(formatObj.get("id"))) | ||||||
|                     .setContent(formatObj.get("content")) |                     .setContent(formatObj.get("content")) | ||||||
|                     .setOperateType(formatObj.get("operateType")); |                     .setOperateType(formatObj.get("operateType")); | ||||||
|             // 异步存入数据库 |             // 异步存入数据库 TODO 可以注入哈; | ||||||
|             SpringUtil.getBean(AfterSaleLogService.class).insert(dto); |             SpringUtil.getBean(AfterSaleLogService.class).insert(dto); | ||||||
|             System.out.println(dto.toString()); |  | ||||||
|         } catch (Exception exception) { |         } catch (Exception exception) { | ||||||
|  |             // TODO @陈賝:日志要记录下参数哈,不然排查问题不好搞; | ||||||
|             log.error("日志记录错误", exception); |             log.error("日志记录错误", exception); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -54,34 +52,22 @@ public class AfterSaleLogAspect { | |||||||
|      * 获取描述信息 |      * 获取描述信息 | ||||||
|      */ |      */ | ||||||
|     public static Map<String, String> spelFormat(JoinPoint joinPoint, Object info) { |     public static Map<String, String> spelFormat(JoinPoint joinPoint, Object info) { | ||||||
|  |  | ||||||
|         Map<String, String> result = new HashMap<>(2); |  | ||||||
|         MethodSignature signature = (MethodSignature) joinPoint.getSignature(); |         MethodSignature signature = (MethodSignature) joinPoint.getSignature(); | ||||||
|         AfterSaleLog afterSaleLogPoint = signature.getMethod().getAnnotation(AfterSaleLog.class); |         AfterSaleLog afterSaleLogPoint = signature.getMethod().getAnnotation(AfterSaleLog.class); | ||||||
|  |         Map<String, String> result = new HashMap<>(2); // TODO @陈賝:Maps.newExpectedXXX(3) | ||||||
|         /* |         // 售后ID | ||||||
|          * 售后ID |  | ||||||
|          */ |  | ||||||
|         String id = SpelUtil.compileParams(joinPoint, info, afterSaleLogPoint.id()); |         String id = SpelUtil.compileParams(joinPoint, info, afterSaleLogPoint.id()); | ||||||
|         result.put("id", id); |         result.put("id", id); | ||||||
|  |         // 操作类型 | ||||||
|         /* |  | ||||||
|          * 操作类型 |  | ||||||
|          */ |  | ||||||
|         String operateType = SpelUtil.compileParams(joinPoint, info, afterSaleLogPoint.operateType()); |         String operateType = SpelUtil.compileParams(joinPoint, info, afterSaleLogPoint.operateType()); | ||||||
|         result.put("operateType", operateType); |         result.put("operateType", operateType); | ||||||
|  |         // 日志内容 | ||||||
|         /* |  | ||||||
|          * 日志内容 |  | ||||||
|          */ |  | ||||||
|         String content = SpelUtil.compileParams(joinPoint, info, afterSaleLogPoint.content()); |         String content = SpelUtil.compileParams(joinPoint, info, afterSaleLogPoint.content()); | ||||||
|         if (CharSequenceUtil.isNotEmpty(afterSaleLogPoint.operateType())) { |         if (StrUtil.isNotEmpty(afterSaleLogPoint.operateType())) { | ||||||
|             content += AfterSaleStatusEnum.valueOf(SpelUtil.compileParams(joinPoint, info, afterSaleLogPoint.operateType())).description(); |             content += AfterSaleStatusEnum.valueOf(SpelUtil.compileParams(joinPoint, info, afterSaleLogPoint.operateType())).description(); | ||||||
|         } |         } | ||||||
|         result.put("content", content); |         result.put("content", content); | ||||||
|         return result; |         return result; | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -3,13 +3,14 @@ package cn.iocoder.yudao.framework.trade.core.dto; | |||||||
| import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||||
| import lombok.Data; | import lombok.Data; | ||||||
| import lombok.NoArgsConstructor; | import lombok.NoArgsConstructor; | ||||||
| import lombok.experimental.Accessors; |  | ||||||
| 
 | 
 | ||||||
|  | /** | ||||||
|  |  * 售后日志的创建 Request DTO | ||||||
|  |  */ | ||||||
| @Data | @Data | ||||||
| @NoArgsConstructor | @NoArgsConstructor | ||||||
| @AllArgsConstructor | @AllArgsConstructor | ||||||
| @Accessors(chain = true) | public class TradeAfterSaleLogCreateReqDTO { | ||||||
| public class TradeAfterSaleLogDTO { |  | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * 编号 |      * 编号 | ||||||
| @@ -1,10 +1,10 @@ | |||||||
| package cn.iocoder.yudao.framework.trade.core.enums; | package cn.iocoder.yudao.framework.trade.core.enums; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 售后状态 |  * 售后状态的枚举 | ||||||
|  * |  * | ||||||
|  * @author 陈賝 |  * @author 陈賝 | ||||||
|  * @date 2023/6/13 13:53 |  * @since 2023/6/13 13:53 | ||||||
|  */ |  */ | ||||||
| public enum AfterSaleStatusEnum { | public enum AfterSaleStatusEnum { | ||||||
|  |  | ||||||
| @@ -23,5 +23,4 @@ public enum AfterSaleStatusEnum { | |||||||
|         return description; |         return description; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1 +0,0 @@ | |||||||
| package cn.iocoder.yudao.framework.trade.core; |  | ||||||
| @@ -1,16 +1,18 @@ | |||||||
| package cn.iocoder.yudao.framework.trade.core.service; | package cn.iocoder.yudao.framework.trade.core.service; | ||||||
|  |  | ||||||
| import cn.iocoder.yudao.framework.trade.core.dto.TradeAfterSaleLogDTO; | import cn.iocoder.yudao.framework.trade.core.dto.TradeAfterSaleLogCreateReqDTO; | ||||||
| import org.springframework.scheduling.annotation.Async; |  | ||||||
|  |  | ||||||
|  | // TODO @陈賝:类注释 | ||||||
| public interface AfterSaleLogService { | public interface AfterSaleLogService { | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 日志记录 |      * 创建售后日志 | ||||||
|      * |      * | ||||||
|      * @param logDTO 日志记录 |      * @param logDTO 日志记录 | ||||||
|      * @author 陈賝 |      * @author 陈賝 | ||||||
|      * @date 2023/6/12 14:18 |      * @since 2023/6/12 14:18 | ||||||
|      */ |      */ | ||||||
|     void insert(TradeAfterSaleLogDTO logDTO); |     // TODO @陈賝:createLog 方法名 | ||||||
|  |     void insert(TradeAfterSaleLogCreateReqDTO logDTO); | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1 +0,0 @@ | |||||||
| package cn.iocoder.yudao.framework.trade; |  | ||||||
| @@ -112,7 +112,7 @@ public class TradeAfterSaleController { | |||||||
|         return success(true); |         return success(true); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     // TODO @陈賝:后续要删除下 | ||||||
|     /** |     /** | ||||||
|      * 售后日志测试 |      * 售后日志测试 | ||||||
|      * |      * | ||||||
|   | |||||||
| @@ -32,6 +32,7 @@ public class AppTradeAfterSaleCreateReqVO { | |||||||
|     @NotNull(message = "申请原因不能为空") |     @NotNull(message = "申请原因不能为空") | ||||||
|     private String applyReason; |     private String applyReason; | ||||||
|  |  | ||||||
|  |     // TODO @陈賝:这个参数不应该有呀。 | ||||||
|     /** |     /** | ||||||
|      * @see AfterSaleStatusEnum |      * @see AfterSaleStatusEnum | ||||||
|      */ |      */ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV