Commit 35df912be789ff96958b31c0eee5ac689b95c087
1 parent
08535d60
code review:商品评价哈
Showing
21 changed files
with
80 additions
and
99 deletions
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApi.java
| 1 | 1 | package cn.iocoder.yudao.module.product.api.comment; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.product.api.comment.dto.CommentCreateReqDTO; | |
| 3 | +import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; | |
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * 产品评论 API 接口 |
| ... | ... | @@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.product.api.comment.dto.CommentCreateReqDTO; |
| 9 | 9 | */ |
| 10 | 10 | public interface ProductCommentApi { |
| 11 | 11 | |
| 12 | + // TODO @puhui:Long orderId 放到 createReqDTO 里噶? | |
| 12 | 13 | /** |
| 13 | 14 | * 创建评论 |
| 14 | 15 | * |
| ... | ... | @@ -16,6 +17,6 @@ public interface ProductCommentApi { |
| 16 | 17 | * @param orderId 订单 id |
| 17 | 18 | * @return 返回评论创建后的 id |
| 18 | 19 | */ |
| 19 | - Long createComment(CommentCreateReqDTO createReqDTO, Long orderId); | |
| 20 | + Long createComment(ProductCommentCreateReqDTO createReqDTO, Long orderId); | |
| 20 | 21 | |
| 21 | 22 | } | ... | ... |
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/dto/CommentCreateReqDTO.java renamed to 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; |
| 10 | 10 | * @author HUIHUI |
| 11 | 11 | */ |
| 12 | 12 | @Data |
| 13 | -public class CommentCreateReqDTO { | |
| 13 | +public class ProductCommentCreateReqDTO { | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * 是否匿名 | |
| 16 | + * 商品 SKU 编号 | |
| 17 | 17 | */ |
| 18 | - private Boolean anonymous; | |
| 19 | - | |
| 18 | + private Long skuId; | |
| 20 | 19 | /** |
| 21 | 20 | * 交易订单项编号 |
| 22 | 21 | */ |
| 23 | 22 | private Long orderItemId; |
| 24 | 23 | |
| 24 | + // TODO @huihui:spuId、spuName 去查询哇?通过 skuId | |
| 25 | 25 | /** |
| 26 | 26 | * 商品 SPU 编号 |
| 27 | 27 | */ |
| 28 | 28 | private Long spuId; |
| 29 | - | |
| 30 | 29 | /** |
| 31 | 30 | * 商品 SPU 名称 |
| 32 | 31 | */ |
| 33 | 32 | private String spuName; |
| 34 | 33 | |
| 35 | 34 | /** |
| 36 | - * 商品 SKU 编号 | |
| 37 | - */ | |
| 38 | - private Long skuId; | |
| 39 | - | |
| 40 | - /** | |
| 41 | 35 | * 评分星级 1-5 分 |
| 42 | 36 | */ |
| 43 | 37 | private Integer scores; |
| 44 | - | |
| 45 | 38 | /** |
| 46 | 39 | * 描述星级 1-5 分 |
| 47 | 40 | */ |
| 48 | 41 | private Integer descriptionScores; |
| 49 | - | |
| 50 | 42 | /** |
| 51 | 43 | * 服务星级 1-5 分 |
| 52 | 44 | */ |
| 53 | 45 | private Integer benefitScores; |
| 54 | - | |
| 55 | 46 | /** |
| 56 | 47 | * 评论内容 |
| 57 | 48 | */ |
| 58 | 49 | private String content; |
| 59 | - | |
| 60 | 50 | /** |
| 61 | - * 评论图片地址数组,以逗号分隔最多上传9张 | |
| 51 | + * 评论图片地址数组,以逗号分隔最多上传 9 张 | |
| 62 | 52 | */ |
| 63 | 53 | private List<String> picUrls; |
| 64 | 54 | |
| 65 | 55 | /** |
| 56 | + * 是否匿名 | |
| 57 | + */ | |
| 58 | + private Boolean anonymous; | |
| 59 | + /** | |
| 60 | + * 评价人 | |
| 61 | + */ | |
| 62 | + private Long userId; | |
| 63 | + // TODO @puhui999:是不是 userNickname、userAvatar 去掉?通过 userId 查询 | |
| 64 | + /** | |
| 66 | 65 | * 评价人名称 |
| 67 | 66 | */ |
| 68 | 67 | private String userNickname; |
| 69 | - | |
| 70 | 68 | /** |
| 71 | 69 | * 评价人头像 |
| 72 | 70 | */ |
| 73 | 71 | private String userAvatar; |
| 74 | 72 | |
| 75 | - /** | |
| 76 | - * 评价人 | |
| 77 | - */ | |
| 78 | - private Long userId; | |
| 79 | - | |
| 80 | 73 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApiImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.product.api.comment; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.product.api.comment.dto.CommentCreateReqDTO; | |
| 3 | +import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; | |
| 4 | 4 | import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert; |
| 5 | 5 | import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; |
| 6 | 6 | import cn.iocoder.yudao.module.product.service.comment.ProductCommentService; |
| ... | ... | @@ -17,12 +17,14 @@ import javax.annotation.Resource; |
| 17 | 17 | @Service |
| 18 | 18 | @Validated |
| 19 | 19 | public class ProductCommentApiImpl implements ProductCommentApi { |
| 20 | + | |
| 20 | 21 | @Resource |
| 21 | 22 | private ProductCommentService productCommentService; |
| 22 | 23 | |
| 23 | 24 | @Override |
| 24 | - public Long createComment(CommentCreateReqDTO createReqDTO, Long orderId) { | |
| 25 | + public Long createComment(ProductCommentCreateReqDTO createReqDTO, Long orderId) { | |
| 25 | 26 | ProductCommentDO commentDO = ProductCommentConvert.INSTANCE.convert(createReqDTO, orderId); |
| 26 | 27 | return productCommentService.createComment(commentDO); |
| 27 | 28 | } |
| 29 | + | |
| 28 | 30 | } | ... | ... |
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 { |
| 30 | 30 | @NotNull(message = "商品 SKU 编号不能为空") |
| 31 | 31 | private Long skuId; |
| 32 | 32 | |
| 33 | - @Schema(description = "评分星级 1-5分", required = true, example = "5") | |
| 33 | + @Schema(description = "评分星级 1-5 分", required = true, example = "5") | |
| 34 | 34 | @NotNull(message = "评分星级不能为空") |
| 35 | 35 | private Integer scores; |
| 36 | 36 | |
| 37 | - @Schema(description = "描述星级 1-5分", required = true, example = "5") | |
| 37 | + @Schema(description = "描述星级 1-5 分", required = true, example = "5") | |
| 38 | 38 | @NotNull(message = "描述星级不能为空") |
| 39 | 39 | private Integer descriptionScores; |
| 40 | 40 | |
| 41 | - @Schema(description = "服务星级 1-5分", required = true, example = "5") | |
| 41 | + @Schema(description = "服务星级 1-5 分", required = true, example = "5") | |
| 42 | 42 | @NotNull(message = "服务星级分不能为空") |
| 43 | 43 | private Integer benefitScores; |
| 44 | 44 | |
| ... | ... | @@ -46,8 +46,8 @@ public class ProductCommentBaseVO { |
| 46 | 46 | @NotNull(message = "评论内容不能为空") |
| 47 | 47 | private String content; |
| 48 | 48 | |
| 49 | - @Schema(description = "评论图片地址数组,以逗号分隔最多上传9张", required = true, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") | |
| 50 | - @Size(max = 9, message = "评论图片地址数组长度不能超过9张") | |
| 49 | + @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", required = true, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") | |
| 50 | + @Size(max = 9, message = "评论图片地址数组长度不能超过 9 张") | |
| 51 | 51 | private List<String> picUrls; |
| 52 | 52 | |
| 53 | 53 | } | ... | ... |
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; |
| 13 | 13 | @ToString(callSuper = true) |
| 14 | 14 | public class ProductCommentCreateReqVO extends ProductCommentBaseVO { |
| 15 | 15 | |
| 16 | + // TODO @puhui999:是不是也放到父类里? | |
| 16 | 17 | @Schema(description = "评价人", required = true, example = "16868") |
| 17 | 18 | @NotNull(message = "评价人不能为空") |
| 18 | 19 | private Long userId; | ... | ... |
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 { |
| 31 | 31 | @Schema(description = "商品SPU名称", example = "感冒药") |
| 32 | 32 | private String spuName; |
| 33 | 33 | |
| 34 | - @Schema(description = "评分星级 1-5分", example = "5") | |
| 34 | + @Schema(description = "评分星级 1-5 分", example = "5") | |
| 35 | 35 | @InEnum(ProductCommentScoresEnum.class) |
| 36 | 36 | private Integer scores; |
| 37 | 37 | ... | ... |
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 { |
| 16 | 16 | @Schema(description = "订单项编号", required = true, example = "24965") |
| 17 | 17 | private Long id; |
| 18 | 18 | |
| 19 | - @Schema(description = "是否匿名:[false:不匿名 true:匿名]", required = true, example = "false") | |
| 19 | + @Schema(description = "是否匿名", required = true, example = "false") | |
| 20 | 20 | private Boolean anonymous; |
| 21 | 21 | |
| 22 | 22 | @Schema(description = "交易订单编号", required = true, example = "24428") | ... | ... |
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 { |
| 36 | 36 | @Resource |
| 37 | 37 | private ProductCommentService productCommentService; |
| 38 | 38 | |
| 39 | + // TODO @puhui999:可以实现下 | |
| 39 | 40 | @GetMapping("/list") |
| 40 | 41 | @Operation(summary = "获得最近的 n 条商品评价") |
| 41 | 42 | @Parameters({ |
| ... | ... | @@ -44,7 +45,6 @@ public class AppProductCommentController { |
| 44 | 45 | }) |
| 45 | 46 | public CommonResult<List<AppProductCommentRespVO>> getCommentList(@RequestParam("spuId") Long spuId, |
| 46 | 47 | @RequestParam(value = "count", defaultValue = "10") Integer count) { |
| 47 | - | |
| 48 | 48 | List<AppProductPropertyValueDetailRespVO> list = new ArrayList<>(); |
| 49 | 49 | |
| 50 | 50 | AppProductPropertyValueDetailRespVO item1 = new AppProductPropertyValueDetailRespVO(); |
| ... | ... | @@ -101,6 +101,7 @@ public class AppProductCommentController { |
| 101 | 101 | return success(productCommentService.getCommentPage(pageVO, Boolean.TRUE)); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | + // TODO @puhui:get-statistics;方法改成 getCommentStatistics;getCommentPageTabsCount 也改掉哈 | |
| 104 | 105 | @GetMapping("/getCommentStatistics") |
| 105 | 106 | @Operation(summary = "获得商品的评价统计") |
| 106 | 107 | public CommonResult<AppCommentStatisticsRespVO> getCommentPage(@Valid @RequestParam("spuId") Long spuId) { | ... | ... |
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; |
| 8 | 8 | |
| 9 | 9 | import javax.validation.constraints.NotNull; |
| 10 | 10 | |
| 11 | -/** | |
| 12 | - * 用户 APP - 商品评价分页 Request VO | |
| 13 | - * | |
| 14 | - * @author HUIHUI | |
| 15 | - */ | |
| 16 | 11 | @Schema(description = "用户APP - 商品评价分页 Request VO") |
| 17 | 12 | @Data |
| 18 | 13 | @EqualsAndHashCode(callSuper = true) |
| ... | ... | @@ -23,12 +18,10 @@ public class AppCommentPageReqVO extends PageParam { |
| 23 | 18 | * 好评 |
| 24 | 19 | */ |
| 25 | 20 | public static final Integer GOOD_COMMENT = 1; |
| 26 | - | |
| 27 | 21 | /** |
| 28 | 22 | * 中评 |
| 29 | 23 | */ |
| 30 | 24 | public static final Integer MEDIOCRE_COMMENT = 2; |
| 31 | - | |
| 32 | 25 | /** |
| 33 | 26 | * 差评 |
| 34 | 27 | */ | ... | ... |
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; |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | import lombok.ToString; |
| 6 | 6 | |
| 7 | -/** | |
| 8 | - * APP 商品评价页评论分类数统计 Response VO | |
| 9 | - * | |
| 10 | - * @author HUIHUI | |
| 11 | - */ | |
| 12 | 7 | @Schema(description = "APP - 商品评价页评论分类数统计 Response VO") |
| 13 | 8 | @Data |
| 14 | 9 | @ToString(callSuper = true) | ... | ... |
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; |
| 8 | 8 | import javax.validation.constraints.Size; |
| 9 | 9 | import java.util.List; |
| 10 | 10 | |
| 11 | -/** | |
| 12 | - * 用户APP - 商品评价创建 Request VO | |
| 13 | - * | |
| 14 | - * @author HUIHUI | |
| 15 | - */ | |
| 16 | 11 | @Schema(description = "用户APP - 商品评价创建 Request VO") |
| 17 | 12 | @Data |
| 18 | 13 | @ToString(callSuper = true) |
| ... | ... | @@ -26,36 +21,36 @@ public class AppProductCommentCreateReqVO { |
| 26 | 21 | @NotNull(message = "交易订单项编号不能为空") |
| 27 | 22 | private Long orderItemId; |
| 28 | 23 | |
| 29 | - @Schema(description = "商品SPU编号", required = true, example = "91192") | |
| 24 | + @Schema(description = "商品 SPU 编号", required = true, example = "91192") | |
| 30 | 25 | @NotNull(message = "商品SPU编号不能为空") |
| 31 | 26 | private Long spuId; |
| 32 | 27 | |
| 33 | - @Schema(description = "商品SPU名称", required = true, example = "清凉丝滑小短袖") | |
| 28 | + @Schema(description = "商品 SPU 名称", required = true, example = "清凉丝滑小短袖") | |
| 34 | 29 | @NotNull(message = "商品SPU名称不能为空") |
| 35 | 30 | private String spuName; |
| 36 | 31 | |
| 37 | - @Schema(description = "商品SKU编号", required = true, example = "81192") | |
| 32 | + @Schema(description = "商品 SKU 编号", required = true, example = "81192") | |
| 38 | 33 | @NotNull(message = "商品SKU编号不能为空") |
| 39 | 34 | private Long skuId; |
| 40 | 35 | |
| 41 | - @Schema(description = "评分星级 1-5分", required = true, example = "5") | |
| 42 | - @NotNull(message = "评分星级 1-5分不能为空") | |
| 36 | + @Schema(description = "评分星级 1-5 分", required = true, example = "5") | |
| 37 | + @NotNull(message = "评分星级 1-5 分不能为空") | |
| 43 | 38 | private Integer scores; |
| 44 | 39 | |
| 45 | - @Schema(description = "描述星级 1-5分", required = true, example = "5") | |
| 46 | - @NotNull(message = "描述星级 1-5分不能为空") | |
| 40 | + @Schema(description = "描述星级 1-5 分", required = true, example = "5") | |
| 41 | + @NotNull(message = "描述星级 1-5 分不能为空") | |
| 47 | 42 | private Integer descriptionScores; |
| 48 | 43 | |
| 49 | - @Schema(description = "服务星级 1-5分", required = true, example = "5") | |
| 50 | - @NotNull(message = "服务星级 1-5分不能为空") | |
| 44 | + @Schema(description = "服务星级 1-5 分", required = true, example = "5") | |
| 45 | + @NotNull(message = "服务星级 1-5 分不能为空") | |
| 51 | 46 | private Integer benefitScores; |
| 52 | 47 | |
| 53 | 48 | @Schema(description = "评论内容", required = true, example = "哇,真的很丝滑凉快诶,好评") |
| 54 | 49 | @NotNull(message = "评论内容不能为空") |
| 55 | 50 | private String content; |
| 56 | 51 | |
| 57 | - @Schema(description = "评论图片地址数组,以逗号分隔最多上传9张", required = true, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") | |
| 58 | - @Size(max = 9, message = "评论图片地址数组长度不能超过9张") | |
| 52 | + @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", required = true, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") | |
| 53 | + @Size(max = 9, message = "评论图片地址数组长度不能超过 9 张") | |
| 59 | 54 | private List<String> picUrls; |
| 60 | 55 | |
| 61 | 56 | } | ... | ... |
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 { |
| 60 | 60 | @Schema(description = "追加评价内容", example = "穿了很久都很丝滑诶") |
| 61 | 61 | private String additionalContent; |
| 62 | 62 | |
| 63 | - @Schema(description = "追评评价图片地址数组,以逗号分隔最多上传9张", example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") | |
| 63 | + @Schema(description = "追评评价图片地址数组,以逗号分隔最多上传 9 张", example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") | |
| 64 | 64 | private List<String> additionalPicUrls; |
| 65 | 65 | |
| 66 | 66 | @Schema(description = "追加评价时间") |
| ... | ... | @@ -86,24 +86,24 @@ public class AppProductCommentRespVO { |
| 86 | 86 | @Schema(description = "商品 SKU 属性", required = true) |
| 87 | 87 | private List<AppProductPropertyValueDetailRespVO> skuProperties; |
| 88 | 88 | |
| 89 | - @Schema(description = "评分星级 1-5分", required = true, example = "5") | |
| 90 | - @NotNull(message = "评分星级 1-5分不能为空") | |
| 89 | + @Schema(description = "评分星级 1-5 分", required = true, example = "5") | |
| 90 | + @NotNull(message = "评分星级 1-5 分不能为空") | |
| 91 | 91 | private Integer scores; |
| 92 | 92 | |
| 93 | - @Schema(description = "描述星级 1-5分", required = true, example = "5") | |
| 94 | - @NotNull(message = "描述星级 1-5分不能为空") | |
| 93 | + @Schema(description = "描述星级 1-5 分", required = true, example = "5") | |
| 94 | + @NotNull(message = "描述星级 1-5 分不能为空") | |
| 95 | 95 | private Integer descriptionScores; |
| 96 | 96 | |
| 97 | - @Schema(description = "服务星级 1-5分", required = true, example = "5") | |
| 98 | - @NotNull(message = "服务星级 1-5分不能为空") | |
| 97 | + @Schema(description = "服务星级 1-5 分", required = true, example = "5") | |
| 98 | + @NotNull(message = "服务星级 1-5 分不能为空") | |
| 99 | 99 | private Integer benefitScores; |
| 100 | 100 | |
| 101 | 101 | @Schema(description = "评论内容", required = true, example = "哇,真的很丝滑凉快诶,好评") |
| 102 | 102 | @NotNull(message = "评论内容不能为空") |
| 103 | 103 | private String content; |
| 104 | 104 | |
| 105 | - @Schema(description = "评论图片地址数组,以逗号分隔最多上传9张", required = true, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") | |
| 106 | - @Size(max = 9, message = "评论图片地址数组长度不能超过9张") | |
| 105 | + @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", required = true, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") | |
| 106 | + @Size(max = 9, message = "评论图片地址数组长度不能超过 9 张") | |
| 107 | 107 | private List<String> picUrls; |
| 108 | 108 | |
| 109 | 109 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.product.convert.comment; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.product.api.comment.dto.CommentCreateReqDTO; | |
| 4 | +import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; | |
| 5 | 5 | import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentCreateReqVO; |
| 6 | 6 | import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentRespVO; |
| 7 | 7 | import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentStatisticsRespVO; |
| ... | ... | @@ -49,7 +49,7 @@ public interface ProductCommentConvert { |
| 49 | 49 | * |
| 50 | 50 | * @param descriptionScores 描述星级 |
| 51 | 51 | * @param benefitScores 服务星级 |
| 52 | - * @return {@link Integer} | |
| 52 | + * @return 综合评分 | |
| 53 | 53 | */ |
| 54 | 54 | @Named("convertScores") |
| 55 | 55 | default Integer convertScores(Integer descriptionScores, Integer benefitScores) { |
| ... | ... | @@ -61,7 +61,7 @@ public interface ProductCommentConvert { |
| 61 | 61 | |
| 62 | 62 | @Mapping(target = "orderId", source = "orderId") |
| 63 | 63 | @Mapping(target = "scores", expression = "java(convertScores(createReqDTO.getDescriptionScores(), createReqDTO.getBenefitScores()))") |
| 64 | - ProductCommentDO convert(CommentCreateReqDTO createReqDTO, Long orderId); | |
| 64 | + ProductCommentDO convert(ProductCommentCreateReqDTO createReqDTO, Long orderId); | |
| 65 | 65 | |
| 66 | 66 | @Mapping(target = "userId", constant = "0L") |
| 67 | 67 | @Mapping(target = "orderId", constant = "0L") | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java
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<ProductCommentDO> { |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | // TODO 芋艿:在看看这块 |
| 28 | + // TODO @puhui999:直接使用 scores 来算好评、中评、差评 | |
| 28 | 29 | static void appendTabQuery(LambdaQueryWrapperX<ProductCommentDO> queryWrapper, Integer type) { |
| 29 | 30 | // 构建好评查询语句:好评计算 (商品评分星级+服务评分星级) >= 8 |
| 30 | 31 | if (ObjectUtil.equal(type, AppCommentPageReqVO.GOOD_COMMENT)) { | ... | ... |
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 { |
| 54 | 54 | PageResult<AppProductCommentRespVO> getCommentPage(AppCommentPageReqVO pageVO, Boolean visible); |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | - * 创建商品评论 后台管理员创建评论使用 | |
| 57 | + * 创建商品评论 | |
| 58 | + * 后台管理员创建评论使用 | |
| 58 | 59 | * |
| 59 | 60 | * @param createReqVO 商品评价创建 Request VO 对象 |
| 60 | 61 | */ | ... | ... |
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 { |
| 86 | 86 | @Transactional(rollbackFor = Exception.class) |
| 87 | 87 | public void createComment(ProductCommentCreateReqVO createReqVO) { |
| 88 | 88 | // 校验订单 |
| 89 | + // TODO @puhui999:不校验哈;尽可能解耦 | |
| 89 | 90 | Long orderId = tradeOrderApi.validateOrder(createReqVO.getUserId(), createReqVO.getOrderItemId()); |
| 90 | 91 | // 校验评论 |
| 91 | 92 | validateComment(createReqVO.getSpuId(), createReqVO.getUserId(), orderId); |
| ... | ... | @@ -104,8 +105,6 @@ public class ProductCommentServiceImpl implements ProductCommentService { |
| 104 | 105 | return commentDO.getId(); |
| 105 | 106 | } |
| 106 | 107 | |
| 107 | - // TODO 只有创建和更新诶 要不要删除接口 | |
| 108 | - | |
| 109 | 108 | private void validateComment(Long spuId, Long userId, Long orderId) { |
| 110 | 109 | ProductSpuDO spu = productSpuService.getSpu(spuId); |
| 111 | 110 | if (null == spu) { |
| ... | ... | @@ -144,6 +143,7 @@ public class ProductCommentServiceImpl implements ProductCommentService { |
| 144 | 143 | public PageResult<AppProductCommentRespVO> getCommentPage(AppCommentPageReqVO pageVO, Boolean visible) { |
| 145 | 144 | PageResult<AppProductCommentRespVO> result = ProductCommentConvert.INSTANCE.convertPage02( |
| 146 | 145 | productCommentMapper.selectPage(pageVO, visible)); |
| 146 | + // TODO @puhui999:要不这块放到 controller 里拼接? | |
| 147 | 147 | Set<Long> skuIds = result.getList().stream().map(AppProductCommentRespVO::getSkuId).collect(Collectors.toSet()); |
| 148 | 148 | List<ProductSkuDO> skuList = productSkuService.getSkuList(skuIds); |
| 149 | 149 | Map<Long, ProductSkuDO> skuDOMap = new HashMap<>(skuIds.size()); | ... | ... |
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` ( |
| 126 | 126 | PRIMARY KEY("id") |
| 127 | 127 | ) COMMENT '规格值'; |
| 128 | 128 | |
| 129 | +-- TODO @puhui999:格式不太对哈 | |
| 129 | 130 | CREATE TABLE IF NOT EXISTS `product_comment` |
| 130 | 131 | ( |
| 131 | 132 | `id` |
| ... | ... | @@ -166,7 +167,7 @@ CREATE TABLE IF NOT EXISTS `product_comment` |
| 166 | 167 | ( |
| 167 | 168 | 1 |
| 168 | 169 | ) DEFAULT NULL COMMENT '是否可见true:显示false:隐藏', |
| 169 | - `scores` tinyint DEFAULT NULL COMMENT '评分星级1-5分', | |
| 170 | + `scores` tinyint DEFAULT NULL COMMENT '评分星级1-5 分', | |
| 170 | 171 | `description_scores` tinyint DEFAULT NULL COMMENT '描述星级1-5 星', |
| 171 | 172 | `benefit_scores` tinyint DEFAULT NULL COMMENT '服务星级1-5 星', |
| 172 | 173 | `content` varchar | ... | ... |
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; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | -import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; | |
| 6 | 5 | import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; |
| 7 | 6 | import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO; |
| 8 | 7 | import cn.iocoder.yudao.module.product.api.comment.ProductCommentApi; |
| ... | ... | @@ -49,12 +48,11 @@ public class AppTradeOrderController { |
| 49 | 48 | |
| 50 | 49 | @Resource |
| 51 | 50 | private ProductPropertyValueApi productPropertyValueApi; |
| 52 | - | |
| 53 | 51 | @Resource |
| 54 | - private TradeOrderProperties tradeOrderProperties; | |
| 52 | + private ProductCommentApi productCommentApi; | |
| 55 | 53 | |
| 56 | 54 | @Resource |
| 57 | - private ProductCommentApi productCommentApi; | |
| 55 | + private TradeOrderProperties tradeOrderProperties; | |
| 58 | 56 | |
| 59 | 57 | @GetMapping("/settlement") |
| 60 | 58 | @Operation(summary = "获得订单结算信息") |
| ... | ... | @@ -141,6 +139,7 @@ public class AppTradeOrderController { |
| 141 | 139 | @Operation(summary = "创建交易订单项的评价") |
| 142 | 140 | public CommonResult<Long> createOrderItemComment(@RequestBody AppTradeOrderItemCommentCreateReqVO createReqVO) { |
| 143 | 141 | // 校验订单项,订单项存在订单就存在 |
| 142 | + // TODO @puhui999:要去查询订单是不是自己的;不然别人模拟请求哈; | |
| 144 | 143 | TradeOrderItemDO item = tradeOrderService.getOrderItem(createReqVO.getUserId(), createReqVO.getOrderItemId()); |
| 145 | 144 | if (item == null) { |
| 146 | 145 | throw exception(ORDER_ITEM_NOT_FOUND); |
| ... | ... | @@ -149,6 +148,6 @@ public class AppTradeOrderController { |
| 149 | 148 | return success(productCommentApi.createComment(TradeOrderConvert.INSTANCE.convert04(createReqVO), item.getOrderId())); |
| 150 | 149 | } |
| 151 | 150 | |
| 152 | - // TODO 合并代码后发现只有商家回复功能 用户追评不要了吗? | |
| 151 | + // TODO 合并代码后发现只有商家回复功能 用户追评不要了吗?不要了哈; | |
| 153 | 152 | |
| 154 | 153 | } | ... | ... |
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; |
| 7 | 7 | import javax.validation.constraints.Size; |
| 8 | 8 | import java.util.List; |
| 9 | 9 | |
| 10 | -/** | |
| 11 | - * 商品评价创建 Request VO | |
| 12 | - * | |
| 13 | - * @author HUIHUI | |
| 14 | - */ | |
| 15 | 10 | @Schema(description = "用户APP - 商品评价创建 Request VO") |
| 16 | 11 | @Data |
| 17 | 12 | public class AppTradeOrderItemCommentCreateReqVO { |
| ... | ... | @@ -24,6 +19,7 @@ public class AppTradeOrderItemCommentCreateReqVO { |
| 24 | 19 | @NotNull(message = "交易订单项编号不能为空") |
| 25 | 20 | private Long orderItemId; |
| 26 | 21 | |
| 22 | + // TODO @puhui:spuId、spuName、skuId 直接查询出来; | |
| 27 | 23 | @Schema(description = "商品SPU编号", required = true, example = "29502") |
| 28 | 24 | @NotNull(message = "商品SPU编号不能为空") |
| 29 | 25 | private Long spuId; |
| ... | ... | @@ -36,30 +32,32 @@ public class AppTradeOrderItemCommentCreateReqVO { |
| 36 | 32 | @NotNull(message = "商品SKU编号不能为空") |
| 37 | 33 | private Long skuId; |
| 38 | 34 | |
| 39 | - @Schema(description = "评分星级 1-5分", required = true, example = "5") | |
| 40 | - @NotNull(message = "评分星级 1-5分不能为空") | |
| 35 | + @Schema(description = "评分星级 1-5 分", required = true, example = "5") | |
| 36 | + @NotNull(message = "评分星级 1-5 分不能为空") | |
| 41 | 37 | private Integer scores; |
| 42 | 38 | |
| 43 | - @Schema(description = "描述星级 1-5分", required = true, example = "5") | |
| 44 | - @NotNull(message = "描述星级 1-5分不能为空") | |
| 39 | + @Schema(description = "描述星级 1-5 分", required = true, example = "5") | |
| 40 | + @NotNull(message = "描述星级 1-5 分不能为空") | |
| 45 | 41 | private Integer descriptionScores; |
| 46 | 42 | |
| 47 | - @Schema(description = "服务星级 1-5分", required = true, example = "5") | |
| 48 | - @NotNull(message = "服务星级 1-5分不能为空") | |
| 43 | + @Schema(description = "服务星级 1-5 分", required = true, example = "5") | |
| 44 | + @NotNull(message = "服务星级 1-5 分不能为空") | |
| 49 | 45 | private Integer benefitScores; |
| 50 | 46 | |
| 51 | 47 | @Schema(description = "评论内容", required = true, example = "穿身上很漂亮诶(*^▽^*)") |
| 52 | 48 | @NotNull(message = "评论内容不能为空") |
| 53 | 49 | private String content; |
| 54 | 50 | |
| 55 | - @Schema(description = "评论图片地址数组,以逗号分隔最多上传9张", required = true, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xx.png]") | |
| 56 | - @Size(max = 9, message = "评论图片地址数组长度不能超过9张") | |
| 51 | + @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", required = true, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xx.png]") | |
| 52 | + @Size(max = 9, message = "评论图片地址数组长度不能超过 9 张") | |
| 57 | 53 | private List<String> picUrls; |
| 58 | 54 | |
| 59 | 55 | @Schema(description = "评价人名称", required = true, example = "小姑凉") |
| 60 | 56 | @NotNull(message = "评价人名称不能为空") |
| 61 | 57 | private String userNickname; |
| 62 | 58 | |
| 59 | + // TODO @puhui:userAvatar、userAvatar、userId 直接查询出来; | |
| 60 | + | |
| 63 | 61 | @Schema(description = "评价人头像", required = true, example = "https://www.iocoder.cn/xx.png") |
| 64 | 62 | @NotNull(message = "评价人头像不能为空") |
| 65 | 63 | private String userAvatar; | ... | ... |
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; |
| 8 | 8 | import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; |
| 9 | 9 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; |
| 10 | 10 | import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; |
| 11 | -import cn.iocoder.yudao.module.product.api.comment.dto.CommentCreateReqDTO; | |
| 11 | +import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; | |
| 12 | 12 | import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; |
| 13 | 13 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; |
| 14 | 14 | import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateReqDTO; |
| ... | ... | @@ -227,6 +227,7 @@ public interface TradeOrderConvert { |
| 227 | 227 | |
| 228 | 228 | AppProductPropertyValueDetailRespVO convert02(ProductPropertyValueDetailRespDTO bean); |
| 229 | 229 | |
| 230 | + // TODO 芋艿:可简化 | |
| 230 | 231 | default AppTradeOrderDetailRespVO convert02(TradeOrderDO order, List<TradeOrderItemDO> orderItems, |
| 231 | 232 | List<ProductPropertyValueDetailRespDTO> propertyValueDetails, TradeOrderProperties tradeOrderProperties) { |
| 232 | 233 | AppTradeOrderDetailRespVO orderVO = convert3(order, orderItems); |
| ... | ... | @@ -258,7 +259,7 @@ public interface TradeOrderConvert { |
| 258 | 259 | |
| 259 | 260 | AppTradeOrderItemRespVO convert03(TradeOrderItemDO bean); |
| 260 | 261 | |
| 261 | - CommentCreateReqDTO convert04(AppTradeOrderItemCommentCreateReqVO createReqVO); | |
| 262 | + ProductCommentCreateReqDTO convert04(AppTradeOrderItemCommentCreateReqVO createReqVO); | |
| 262 | 263 | |
| 263 | 264 | default TradePriceCalculateReqBO convert(Long userId, AppTradeOrderSettlementReqVO settlementReqVO, |
| 264 | 265 | List<TradeCartDO> cartList) { |
| ... | ... | @@ -302,5 +303,4 @@ public interface TradeOrderConvert { |
| 302 | 303 | |
| 303 | 304 | AppTradeOrderSettlementRespVO convert0(TradePriceCalculateRespBO calculate, AddressRespDTO address); |
| 304 | 305 | |
| 305 | - | |
| 306 | 306 | } | ... | ... |