Commit 1dfbe4591350b25a3fe8b1a1248e1e2251bb4f10
1 parent
07884ef4
mall + order:review 售后日志
Showing
8 changed files
with
23 additions
and
11 deletions
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/spring/SpringExpressionUtils.java
| ... | ... | @@ -97,6 +97,7 @@ public class SpringExpressionUtils { |
| 97 | 97 | * @author 陈賝 |
| 98 | 98 | * @since 2023/6/18 11:20 |
| 99 | 99 | */ |
| 100 | + // TODO @chenchen: 这个方法,和 parseExpressions 比较接近,是不是可以合并下; | |
| 100 | 101 | public static Map<String, Object> parseExpression(JoinPoint joinPoint, Object info, List<String> expressionStrings) { |
| 101 | 102 | // 如果为空,则不进行解析 |
| 102 | 103 | if (CollUtil.isEmpty(expressionStrings)) { |
| ... | ... | @@ -115,7 +116,7 @@ public class SpringExpressionUtils { |
| 115 | 116 | //获取方法参数值 |
| 116 | 117 | Object[] args = joinPoint.getArgs(); |
| 117 | 118 | for (int i = 0; i < args.length; i++) { |
| 118 | - //替换spel里的变量值为实际值, 比如 #user --> user对象 | |
| 119 | + // 替换 SP EL 里的变量值为实际值, 比如 #user --> user对象 | |
| 119 | 120 | context.setVariable(parameterNames[i], args[i]); |
| 120 | 121 | } |
| 121 | 122 | context.setVariable("info", info); | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleOperateTypeEnum.java
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/TradeAfterSaleLogDO.java
| ... | ... | @@ -2,9 +2,7 @@ package cn.iocoder.yudao.module.trade.dal.dataobject.aftersale; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 4 | 4 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 5 | -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; | |
| 6 | -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; | |
| 7 | -import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleStatusEnum; | |
| 5 | +import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum; | |
| 8 | 6 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 9 | 7 | import com.baomidou.mybatisplus.annotation.TableId; |
| 10 | 8 | import com.baomidou.mybatisplus.annotation.TableName; |
| ... | ... | @@ -51,8 +49,11 @@ public class TradeAfterSaleLogDO extends BaseDO { |
| 51 | 49 | * 关联 {@link TradeAfterSaleDO#getId()} |
| 52 | 50 | */ |
| 53 | 51 | private Long afterSaleId; |
| 52 | + // todo @CHENCHEN: 改成 Integer 哈;主要未来改文案,不好洗 log 存的字段; | |
| 54 | 53 | /** |
| 55 | - * 操作类型 {@link TradeAfterSaleStatusEnum} | |
| 54 | + * 操作类型 | |
| 55 | + * | |
| 56 | + * 枚举 {@link AfterSaleOperateTypeEnum} | |
| 56 | 57 | */ |
| 57 | 58 | private String operateType; |
| 58 | 59 | /** | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/config/AfterSaleLogConfiguration.java
| ... | ... | @@ -4,6 +4,7 @@ import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.aop.AfterSaleLo |
| 4 | 4 | import org.springframework.context.annotation.Bean; |
| 5 | 5 | import org.springframework.context.annotation.Configuration; |
| 6 | 6 | |
| 7 | +// TODO @chenchen:改成 aftersale 好点哈; | |
| 7 | 8 | /** |
| 8 | 9 | * trade 模块的 afterSaleLog 组件的 Configuration |
| 9 | 10 | * | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/annotations/AfterSaleLog.java
| ... | ... | @@ -5,10 +5,13 @@ import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum; |
| 5 | 5 | import java.lang.annotation.*; |
| 6 | 6 | |
| 7 | 7 | /** |
| 8 | - * 售后日志 | |
| 8 | + * 售后日志的注解 | |
| 9 | + * | |
| 10 | + * 写在方法上时,会自动记录售后日志 | |
| 9 | 11 | * |
| 10 | 12 | * @author 陈賝 |
| 11 | 13 | * @since 2023/6/8 17:04 |
| 14 | + * @see cn.iocoder.yudao.module.trade.framework.aftersalelog.core.aop.AfterSaleLogAspect | |
| 12 | 15 | */ |
| 13 | 16 | @Target({ElementType.METHOD, ElementType.TYPE}) |
| 14 | 17 | @Retention(RetentionPolicy.RUNTIME) | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/aop/AfterSaleLogAspect.java
| ... | ... | @@ -30,9 +30,11 @@ import static java.util.Arrays.asList; |
| 30 | 30 | @Slf4j |
| 31 | 31 | @Aspect |
| 32 | 32 | public class AfterSaleLogAspect { |
| 33 | + | |
| 33 | 34 | @Resource |
| 34 | - private AfterSaleLogService saleLogService; | |
| 35 | + private AfterSaleLogService afterSaleLogService; | |
| 35 | 36 | |
| 37 | + // TODO chenchen: 这个分 3 行把; | |
| 36 | 38 | private final static String OPERATE_TYPE = "operateType", ID = "id", CONTENT = "content"; |
| 37 | 39 | |
| 38 | 40 | /** |
| ... | ... | @@ -52,9 +54,9 @@ public class AfterSaleLogAspect { |
| 52 | 54 | .setOperateType(MapUtil.getStr(formatObj, OPERATE_TYPE)) |
| 53 | 55 | .setContent(MapUtil.getStr(formatObj, CONTENT)); |
| 54 | 56 | // 异步存入数据库 |
| 55 | - saleLogService.createLog(dto); | |
| 57 | + afterSaleLogService.createLog(dto); | |
| 56 | 58 | } catch (Exception exception) { |
| 57 | - log.error("[afterSaleLog({}) 日志记录错误]", toJsonString(afterSaleLog), exception); | |
| 59 | + log.error("[doAfterReturning][afterSaleLog({}) 日志记录错误]", toJsonString(afterSaleLog), exception); | |
| 58 | 60 | } |
| 59 | 61 | } |
| 60 | 62 | |
| ... | ... | @@ -67,6 +69,7 @@ public class AfterSaleLogAspect { |
| 67 | 69 | HashMap<String, String> result = Maps.newHashMapWithExpectedSize(2); |
| 68 | 70 | Map<String, Object> spelMap = SpringExpressionUtils.parseExpression(joinPoint, info, |
| 69 | 71 | asList(afterSaleLogPoint.id(), afterSaleLogPoint.content())); |
| 72 | + // TODO @chenchen:是不是抽成 3 个方法好点;毕竟 map 太抽象了;; | |
| 70 | 73 | // 售后ID |
| 71 | 74 | String id = MapUtil.getStr(spelMap, afterSaleLogPoint.id()); |
| 72 | 75 | result.put(ID, id); | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/dto/TradeAfterSaleLogCreateReqDTO.java
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceImpl.java
| ... | ... | @@ -398,6 +398,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa |
| 398 | 398 | this.createLog(logDTO); |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | + // TODO @CHENCHEN:这个注释,写在接口就好了,补充重复写哈;@date 应该是 @since | |
| 401 | 402 | /** |
| 402 | 403 | * 日志记录 |
| 403 | 404 | * |
| ... | ... | @@ -416,8 +417,9 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa |
| 416 | 417 | .setOperateType(logDTO.getOperateType()) |
| 417 | 418 | .setContent(logDTO.getContent()); |
| 418 | 419 | tradeAfterSaleLogMapper.insert(afterSaleLog); |
| 420 | + // TODO @CHENCHEN:代码排版哈;空格要正确 | |
| 419 | 421 | }catch (Exception exception){ |
| 420 | - log.error("[request({}) 日志记录错误]", toJsonString(logDTO), exception); | |
| 422 | + log.error("[createLog][request({}) 日志记录错误]", toJsonString(logDTO), exception); | |
| 421 | 423 | } |
| 422 | 424 | } |
| 423 | 425 | } | ... | ... |