From 35df912be789ff96958b31c0eee5ac689b95c087 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 17 Jun 2023 21:57:52 +0800 Subject: [PATCH] =?UTF-8?q?code=20review=EF=BC=9A=E5=95=86=E5=93=81?= =?UTF-8?q?=E8=AF=84=E4=BB=B7=E5=93=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/comment/ProductCommentApi.java | 5 +-- ...O.java => ProductCommentCreateReqDTO.java} | 35 ++++++++----------- .../api/comment/ProductCommentApiImpl.java | 6 ++-- .../comment/vo/ProductCommentBaseVO.java | 10 +++--- .../comment/vo/ProductCommentCreateReqVO.java | 1 + .../comment/vo/ProductCommentPageReqVO.java | 2 +- .../comment/vo/ProductCommentRespVO.java | 2 +- .../comment/AppProductCommentController.java | 3 +- .../app/comment/vo/AppCommentPageReqVO.java | 7 ---- .../vo/AppCommentStatisticsRespVO.java | 5 --- .../vo/AppProductCommentCreateReqVO.java | 27 ++++++-------- .../comment/vo/AppProductCommentRespVO.java | 18 +++++----- .../comment/ProductCommentConvert.java | 6 ++-- .../dataobject/comment/ProductCommentDO.java | 2 +- .../mysql/comment/ProductCommentMapper.java | 1 + .../comment/ProductCommentService.java | 3 +- .../comment/ProductCommentServiceImpl.java | 4 +-- .../src/test/resources/sql/create_tables.sql | 3 +- .../app/order/AppTradeOrderController.java | 9 +++-- .../AppTradeOrderItemCommentCreateReqVO.java | 24 ++++++------- .../convert/order/TradeOrderConvert.java | 6 ++-- 21 files changed, 80 insertions(+), 99 deletions(-) rename yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/dto/{CommentCreateReqDTO.java => ProductCommentCreateReqDTO.java} (79%) diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApi.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApi.java index 2daf87d0e..28910ec65 100644 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApi.java +++ b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApi.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.module.product.api.comment; -import cn.iocoder.yudao.module.product.api.comment.dto.CommentCreateReqDTO; +import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; /** * 产品评论 API 接口 @@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.product.api.comment.dto.CommentCreateReqDTO; */ public interface ProductCommentApi { + // TODO @puhui:Long orderId 放到 createReqDTO 里噶? /** * 创建评论 * @@ -16,6 +17,6 @@ public interface ProductCommentApi { * @param orderId 订单 id * @return 返回评论创建后的 id */ - Long createComment(CommentCreateReqDTO createReqDTO, Long orderId); + Long createComment(ProductCommentCreateReqDTO createReqDTO, Long orderId); } diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/dto/CommentCreateReqDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/dto/ProductCommentCreateReqDTO.java similarity index 79% rename from yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/dto/CommentCreateReqDTO.java rename to yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/dto/ProductCommentCreateReqDTO.java index 640d04784..10ebce588 100644 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/dto/CommentCreateReqDTO.java +++ b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/dto/ProductCommentCreateReqDTO.java @@ -10,71 +10,64 @@ import java.util.List; * @author HUIHUI */ @Data -public class CommentCreateReqDTO { +public class ProductCommentCreateReqDTO { /** - * 是否匿名 + * 商品 SKU 编号 */ - private Boolean anonymous; - + private Long skuId; /** * 交易订单项编号 */ private Long orderItemId; + // TODO @huihui:spuId、spuName 去查询哇?通过 skuId /** * 商品 SPU 编号 */ private Long spuId; - /** * 商品 SPU 名称 */ private String spuName; - /** - * 商品 SKU 编号 - */ - private Long skuId; - /** * 评分星级 1-5 分 */ private Integer scores; - /** * 描述星级 1-5 分 */ private Integer descriptionScores; - /** * 服务星级 1-5 分 */ private Integer benefitScores; - /** * 评论内容 */ private String content; - /** - * 评论图片地址数组,以逗号分隔最多上传9张 + * 评论图片地址数组,以逗号分隔最多上传 9 张 */ private List picUrls; + /** + * 是否匿名 + */ + private Boolean anonymous; + /** + * 评价人 + */ + private Long userId; + // TODO @puhui999:是不是 userNickname、userAvatar 去掉?通过 userId 查询 /** * 评价人名称 */ private String userNickname; - /** * 评价人头像 */ private String userAvatar; - /** - * 评价人 - */ - private Long userId; - } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApiImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApiImpl.java index cd1145c66..3eca0d523 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApiImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApiImpl.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.module.product.api.comment; -import cn.iocoder.yudao.module.product.api.comment.dto.CommentCreateReqDTO; +import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert; import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; import cn.iocoder.yudao.module.product.service.comment.ProductCommentService; @@ -17,12 +17,14 @@ import javax.annotation.Resource; @Service @Validated public class ProductCommentApiImpl implements ProductCommentApi { + @Resource private ProductCommentService productCommentService; @Override - public Long createComment(CommentCreateReqDTO createReqDTO, Long orderId) { + public Long createComment(ProductCommentCreateReqDTO createReqDTO, Long orderId) { ProductCommentDO commentDO = ProductCommentConvert.INSTANCE.convert(createReqDTO, orderId); return productCommentService.createComment(commentDO); } + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentBaseVO.java index b934298b7..5bf728a5e 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentBaseVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentBaseVO.java @@ -30,15 +30,15 @@ public class ProductCommentBaseVO { @NotNull(message = "商品 SKU 编号不能为空") private Long skuId; - @Schema(description = "评分星级 1-5分", required = true, example = "5") + @Schema(description = "评分星级 1-5 分", required = true, example = "5") @NotNull(message = "评分星级不能为空") private Integer scores; - @Schema(description = "描述星级 1-5分", required = true, example = "5") + @Schema(description = "描述星级 1-5 分", required = true, example = "5") @NotNull(message = "描述星级不能为空") private Integer descriptionScores; - @Schema(description = "服务星级 1-5分", required = true, example = "5") + @Schema(description = "服务星级 1-5 分", required = true, example = "5") @NotNull(message = "服务星级分不能为空") private Integer benefitScores; @@ -46,8 +46,8 @@ public class ProductCommentBaseVO { @NotNull(message = "评论内容不能为空") private String content; - @Schema(description = "评论图片地址数组,以逗号分隔最多上传9张", required = true, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") - @Size(max = 9, message = "评论图片地址数组长度不能超过9张") + @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", required = true, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") + @Size(max = 9, message = "评论图片地址数组长度不能超过 9 张") private List picUrls; } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentCreateReqVO.java index 1d325e03d..bdeec76f1 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentCreateReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentCreateReqVO.java @@ -13,6 +13,7 @@ import javax.validation.constraints.NotNull; @ToString(callSuper = true) public class ProductCommentCreateReqVO extends ProductCommentBaseVO { + // TODO @puhui999:是不是也放到父类里? @Schema(description = "评价人", required = true, example = "16868") @NotNull(message = "评价人不能为空") private Long userId; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentPageReqVO.java index f7da9b5d9..e88f8c4ad 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentPageReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentPageReqVO.java @@ -31,7 +31,7 @@ public class ProductCommentPageReqVO extends PageParam { @Schema(description = "商品SPU名称", example = "感冒药") private String spuName; - @Schema(description = "评分星级 1-5分", example = "5") + @Schema(description = "评分星级 1-5 分", example = "5") @InEnum(ProductCommentScoresEnum.class) private Integer scores; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java index c9a06d476..e4d23c008 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java @@ -16,7 +16,7 @@ public class ProductCommentRespVO extends ProductCommentBaseVO { @Schema(description = "订单项编号", required = true, example = "24965") private Long id; - @Schema(description = "是否匿名:[false:不匿名 true:匿名]", required = true, example = "false") + @Schema(description = "是否匿名", required = true, example = "false") private Boolean anonymous; @Schema(description = "交易订单编号", required = true, example = "24428") diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppProductCommentController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppProductCommentController.java index 90a387c80..dad93590f 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppProductCommentController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppProductCommentController.java @@ -36,6 +36,7 @@ public class AppProductCommentController { @Resource private ProductCommentService productCommentService; + // TODO @puhui999:可以实现下 @GetMapping("/list") @Operation(summary = "获得最近的 n 条商品评价") @Parameters({ @@ -44,7 +45,6 @@ public class AppProductCommentController { }) public CommonResult> getCommentList(@RequestParam("spuId") Long spuId, @RequestParam(value = "count", defaultValue = "10") Integer count) { - List list = new ArrayList<>(); AppProductPropertyValueDetailRespVO item1 = new AppProductPropertyValueDetailRespVO(); @@ -101,6 +101,7 @@ public class AppProductCommentController { return success(productCommentService.getCommentPage(pageVO, Boolean.TRUE)); } + // TODO @puhui:get-statistics;方法改成 getCommentStatistics;getCommentPageTabsCount 也改掉哈 @GetMapping("/getCommentStatistics") @Operation(summary = "获得商品的评价统计") public CommonResult getCommentPage(@Valid @RequestParam("spuId") Long spuId) { diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentPageReqVO.java index 0e6ef98cc..a6d0827e0 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentPageReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentPageReqVO.java @@ -8,11 +8,6 @@ import lombok.ToString; import javax.validation.constraints.NotNull; -/** - * 用户 APP - 商品评价分页 Request VO - * - * @author HUIHUI - */ @Schema(description = "用户APP - 商品评价分页 Request VO") @Data @EqualsAndHashCode(callSuper = true) @@ -23,12 +18,10 @@ public class AppCommentPageReqVO extends PageParam { * 好评 */ public static final Integer GOOD_COMMENT = 1; - /** * 中评 */ public static final Integer MEDIOCRE_COMMENT = 2; - /** * 差评 */ diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentStatisticsRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentStatisticsRespVO.java index 0687e5eea..61d0ac7c4 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentStatisticsRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentStatisticsRespVO.java @@ -4,11 +4,6 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.ToString; -/** - * APP 商品评价页评论分类数统计 Response VO - * - * @author HUIHUI - */ @Schema(description = "APP - 商品评价页评论分类数统计 Response VO") @Data @ToString(callSuper = true) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentCreateReqVO.java index 53e797447..272fe64e9 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentCreateReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentCreateReqVO.java @@ -8,11 +8,6 @@ import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import java.util.List; -/** - * 用户APP - 商品评价创建 Request VO - * - * @author HUIHUI - */ @Schema(description = "用户APP - 商品评价创建 Request VO") @Data @ToString(callSuper = true) @@ -26,36 +21,36 @@ public class AppProductCommentCreateReqVO { @NotNull(message = "交易订单项编号不能为空") private Long orderItemId; - @Schema(description = "商品SPU编号", required = true, example = "91192") + @Schema(description = "商品 SPU 编号", required = true, example = "91192") @NotNull(message = "商品SPU编号不能为空") private Long spuId; - @Schema(description = "商品SPU名称", required = true, example = "清凉丝滑小短袖") + @Schema(description = "商品 SPU 名称", required = true, example = "清凉丝滑小短袖") @NotNull(message = "商品SPU名称不能为空") private String spuName; - @Schema(description = "商品SKU编号", required = true, example = "81192") + @Schema(description = "商品 SKU 编号", required = true, example = "81192") @NotNull(message = "商品SKU编号不能为空") private Long skuId; - @Schema(description = "评分星级 1-5分", required = true, example = "5") - @NotNull(message = "评分星级 1-5分不能为空") + @Schema(description = "评分星级 1-5 分", required = true, example = "5") + @NotNull(message = "评分星级 1-5 分不能为空") private Integer scores; - @Schema(description = "描述星级 1-5分", required = true, example = "5") - @NotNull(message = "描述星级 1-5分不能为空") + @Schema(description = "描述星级 1-5 分", required = true, example = "5") + @NotNull(message = "描述星级 1-5 分不能为空") private Integer descriptionScores; - @Schema(description = "服务星级 1-5分", required = true, example = "5") - @NotNull(message = "服务星级 1-5分不能为空") + @Schema(description = "服务星级 1-5 分", required = true, example = "5") + @NotNull(message = "服务星级 1-5 分不能为空") private Integer benefitScores; @Schema(description = "评论内容", required = true, example = "哇,真的很丝滑凉快诶,好评") @NotNull(message = "评论内容不能为空") private String content; - @Schema(description = "评论图片地址数组,以逗号分隔最多上传9张", required = true, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") - @Size(max = 9, message = "评论图片地址数组长度不能超过9张") + @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", required = true, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") + @Size(max = 9, message = "评论图片地址数组长度不能超过 9 张") private List picUrls; } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentRespVO.java index e78f996e1..5aa5c8530 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentRespVO.java @@ -60,7 +60,7 @@ public class AppProductCommentRespVO { @Schema(description = "追加评价内容", example = "穿了很久都很丝滑诶") private String additionalContent; - @Schema(description = "追评评价图片地址数组,以逗号分隔最多上传9张", example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") + @Schema(description = "追评评价图片地址数组,以逗号分隔最多上传 9 张", example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") private List additionalPicUrls; @Schema(description = "追加评价时间") @@ -86,24 +86,24 @@ public class AppProductCommentRespVO { @Schema(description = "商品 SKU 属性", required = true) private List skuProperties; - @Schema(description = "评分星级 1-5分", required = true, example = "5") - @NotNull(message = "评分星级 1-5分不能为空") + @Schema(description = "评分星级 1-5 分", required = true, example = "5") + @NotNull(message = "评分星级 1-5 分不能为空") private Integer scores; - @Schema(description = "描述星级 1-5分", required = true, example = "5") - @NotNull(message = "描述星级 1-5分不能为空") + @Schema(description = "描述星级 1-5 分", required = true, example = "5") + @NotNull(message = "描述星级 1-5 分不能为空") private Integer descriptionScores; - @Schema(description = "服务星级 1-5分", required = true, example = "5") - @NotNull(message = "服务星级 1-5分不能为空") + @Schema(description = "服务星级 1-5 分", required = true, example = "5") + @NotNull(message = "服务星级 1-5 分不能为空") private Integer benefitScores; @Schema(description = "评论内容", required = true, example = "哇,真的很丝滑凉快诶,好评") @NotNull(message = "评论内容不能为空") private String content; - @Schema(description = "评论图片地址数组,以逗号分隔最多上传9张", required = true, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") - @Size(max = 9, message = "评论图片地址数组长度不能超过9张") + @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", required = true, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") + @Size(max = 9, message = "评论图片地址数组长度不能超过 9 张") private List picUrls; } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java index 9ec7e5cb4..db91663b6 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.product.convert.comment; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.comment.dto.CommentCreateReqDTO; +import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentCreateReqVO; import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentRespVO; import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentStatisticsRespVO; @@ -49,7 +49,7 @@ public interface ProductCommentConvert { * * @param descriptionScores 描述星级 * @param benefitScores 服务星级 - * @return {@link Integer} + * @return 综合评分 */ @Named("convertScores") default Integer convertScores(Integer descriptionScores, Integer benefitScores) { @@ -61,7 +61,7 @@ public interface ProductCommentConvert { @Mapping(target = "orderId", source = "orderId") @Mapping(target = "scores", expression = "java(convertScores(createReqDTO.getDescriptionScores(), createReqDTO.getBenefitScores()))") - ProductCommentDO convert(CommentCreateReqDTO createReqDTO, Long orderId); + ProductCommentDO convert(ProductCommentCreateReqDTO createReqDTO, Long orderId); @Mapping(target = "userId", constant = "0L") @Mapping(target = "orderId", constant = "0L") diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java index f353d7761..366b237a2 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java @@ -97,7 +97,7 @@ public class ProductCommentDO extends BaseDO { /** * 评分星级 * - * 1-5分 + * 1-5 分 */ private Integer scores; /** diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java index f44c1e334..4d5472fe0 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java @@ -25,6 +25,7 @@ public interface ProductCommentMapper extends BaseMapperX { } // TODO 芋艿:在看看这块 + // TODO @puhui999:直接使用 scores 来算好评、中评、差评 static void appendTabQuery(LambdaQueryWrapperX queryWrapper, Integer type) { // 构建好评查询语句:好评计算 (商品评分星级+服务评分星级) >= 8 if (ObjectUtil.equal(type, AppCommentPageReqVO.GOOD_COMMENT)) { diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentService.java index c6841770a..3ce2a3821 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentService.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentService.java @@ -54,7 +54,8 @@ public interface ProductCommentService { PageResult getCommentPage(AppCommentPageReqVO pageVO, Boolean visible); /** - * 创建商品评论 后台管理员创建评论使用 + * 创建商品评论 + * 后台管理员创建评论使用 * * @param createReqVO 商品评价创建 Request VO 对象 */ diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java index 05d38899c..1d09605bc 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java @@ -86,6 +86,7 @@ public class ProductCommentServiceImpl implements ProductCommentService { @Transactional(rollbackFor = Exception.class) public void createComment(ProductCommentCreateReqVO createReqVO) { // 校验订单 + // TODO @puhui999:不校验哈;尽可能解耦 Long orderId = tradeOrderApi.validateOrder(createReqVO.getUserId(), createReqVO.getOrderItemId()); // 校验评论 validateComment(createReqVO.getSpuId(), createReqVO.getUserId(), orderId); @@ -104,8 +105,6 @@ public class ProductCommentServiceImpl implements ProductCommentService { return commentDO.getId(); } - // TODO 只有创建和更新诶 要不要删除接口 - private void validateComment(Long spuId, Long userId, Long orderId) { ProductSpuDO spu = productSpuService.getSpu(spuId); if (null == spu) { @@ -144,6 +143,7 @@ public class ProductCommentServiceImpl implements ProductCommentService { public PageResult getCommentPage(AppCommentPageReqVO pageVO, Boolean visible) { PageResult result = ProductCommentConvert.INSTANCE.convertPage02( productCommentMapper.selectPage(pageVO, visible)); + // TODO @puhui999:要不这块放到 controller 里拼接? Set skuIds = result.getList().stream().map(AppProductCommentRespVO::getSkuId).collect(Collectors.toSet()); List skuList = productSkuService.getSkuList(skuIds); Map skuDOMap = new HashMap<>(skuIds.size()); diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/create_tables.sql b/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/create_tables.sql index e9fa0f6ce..172e916f7 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/create_tables.sql +++ b/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/create_tables.sql @@ -126,6 +126,7 @@ CREATE TABLE IF NOT EXISTS `product_property_value` ( PRIMARY KEY("id") ) COMMENT '规格值'; +-- TODO @puhui999:格式不太对哈 CREATE TABLE IF NOT EXISTS `product_comment` ( `id` @@ -166,7 +167,7 @@ CREATE TABLE IF NOT EXISTS `product_comment` ( 1 ) DEFAULT NULL COMMENT '是否可见true:显示false:隐藏', - `scores` tinyint DEFAULT NULL COMMENT '评分星级1-5分', + `scores` tinyint DEFAULT NULL COMMENT '评分星级1-5 分', `description_scores` tinyint DEFAULT NULL COMMENT '描述星级1-5 星', `benefit_scores` tinyint DEFAULT NULL COMMENT '服务星级1-5 星', `content` varchar diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java index 2d7463cd4..098d776f8 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.trade.controller.app.order; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO; import cn.iocoder.yudao.module.product.api.comment.ProductCommentApi; @@ -49,13 +48,12 @@ public class AppTradeOrderController { @Resource private ProductPropertyValueApi productPropertyValueApi; + @Resource + private ProductCommentApi productCommentApi; @Resource private TradeOrderProperties tradeOrderProperties; - @Resource - private ProductCommentApi productCommentApi; - @GetMapping("/settlement") @Operation(summary = "获得订单结算信息") @PreAuthenticated @@ -141,6 +139,7 @@ public class AppTradeOrderController { @Operation(summary = "创建交易订单项的评价") public CommonResult createOrderItemComment(@RequestBody AppTradeOrderItemCommentCreateReqVO createReqVO) { // 校验订单项,订单项存在订单就存在 + // TODO @puhui999:要去查询订单是不是自己的;不然别人模拟请求哈; TradeOrderItemDO item = tradeOrderService.getOrderItem(createReqVO.getUserId(), createReqVO.getOrderItemId()); if (item == null) { throw exception(ORDER_ITEM_NOT_FOUND); @@ -149,6 +148,6 @@ public class AppTradeOrderController { return success(productCommentApi.createComment(TradeOrderConvert.INSTANCE.convert04(createReqVO), item.getOrderId())); } - // TODO 合并代码后发现只有商家回复功能 用户追评不要了吗? + // TODO 合并代码后发现只有商家回复功能 用户追评不要了吗?不要了哈; } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemCommentCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemCommentCreateReqVO.java index 9fbec0625..85910e6ef 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemCommentCreateReqVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemCommentCreateReqVO.java @@ -7,11 +7,6 @@ import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import java.util.List; -/** - * 商品评价创建 Request VO - * - * @author HUIHUI - */ @Schema(description = "用户APP - 商品评价创建 Request VO") @Data public class AppTradeOrderItemCommentCreateReqVO { @@ -24,6 +19,7 @@ public class AppTradeOrderItemCommentCreateReqVO { @NotNull(message = "交易订单项编号不能为空") private Long orderItemId; + // TODO @puhui:spuId、spuName、skuId 直接查询出来; @Schema(description = "商品SPU编号", required = true, example = "29502") @NotNull(message = "商品SPU编号不能为空") private Long spuId; @@ -36,30 +32,32 @@ public class AppTradeOrderItemCommentCreateReqVO { @NotNull(message = "商品SKU编号不能为空") private Long skuId; - @Schema(description = "评分星级 1-5分", required = true, example = "5") - @NotNull(message = "评分星级 1-5分不能为空") + @Schema(description = "评分星级 1-5 分", required = true, example = "5") + @NotNull(message = "评分星级 1-5 分不能为空") private Integer scores; - @Schema(description = "描述星级 1-5分", required = true, example = "5") - @NotNull(message = "描述星级 1-5分不能为空") + @Schema(description = "描述星级 1-5 分", required = true, example = "5") + @NotNull(message = "描述星级 1-5 分不能为空") private Integer descriptionScores; - @Schema(description = "服务星级 1-5分", required = true, example = "5") - @NotNull(message = "服务星级 1-5分不能为空") + @Schema(description = "服务星级 1-5 分", required = true, example = "5") + @NotNull(message = "服务星级 1-5 分不能为空") private Integer benefitScores; @Schema(description = "评论内容", required = true, example = "穿身上很漂亮诶(*^▽^*)") @NotNull(message = "评论内容不能为空") private String content; - @Schema(description = "评论图片地址数组,以逗号分隔最多上传9张", required = true, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xx.png]") - @Size(max = 9, message = "评论图片地址数组长度不能超过9张") + @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", required = true, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xx.png]") + @Size(max = 9, message = "评论图片地址数组长度不能超过 9 张") private List picUrls; @Schema(description = "评价人名称", required = true, example = "小姑凉") @NotNull(message = "评价人名称不能为空") private String userNickname; + // TODO @puhui:userAvatar、userAvatar、userId 直接查询出来; + @Schema(description = "评价人头像", required = true, example = "https://www.iocoder.cn/xx.png") @NotNull(message = "评价人头像不能为空") private String userAvatar; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java index 6e81746a4..edc81de7b 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java @@ -8,7 +8,7 @@ import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.product.api.comment.dto.CommentCreateReqDTO; +import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateReqDTO; @@ -227,6 +227,7 @@ public interface TradeOrderConvert { AppProductPropertyValueDetailRespVO convert02(ProductPropertyValueDetailRespDTO bean); + // TODO 芋艿:可简化 default AppTradeOrderDetailRespVO convert02(TradeOrderDO order, List orderItems, List propertyValueDetails, TradeOrderProperties tradeOrderProperties) { AppTradeOrderDetailRespVO orderVO = convert3(order, orderItems); @@ -258,7 +259,7 @@ public interface TradeOrderConvert { AppTradeOrderItemRespVO convert03(TradeOrderItemDO bean); - CommentCreateReqDTO convert04(AppTradeOrderItemCommentCreateReqVO createReqVO); + ProductCommentCreateReqDTO convert04(AppTradeOrderItemCommentCreateReqVO createReqVO); default TradePriceCalculateReqBO convert(Long userId, AppTradeOrderSettlementReqVO settlementReqVO, List cartList) { @@ -302,5 +303,4 @@ public interface TradeOrderConvert { AppTradeOrderSettlementRespVO convert0(TradePriceCalculateRespBO calculate, AddressRespDTO address); - }