Commit 38d7d75f7f13edba2ad169fad6abaf56e870a5f9
1 parent
6fe5f4bc
[新增][商品评价]管理后台/APP端
1. 增加头像返回字段 2. 调整商户自评userId 3. 控制评论图片数量判断
Showing
7 changed files
with
16 additions
and
13 deletions
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentBaseVO.java
| ... | ... | @@ -4,15 +4,12 @@ import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | 6 | import javax.validation.constraints.NotNull; |
| 7 | +import javax.validation.constraints.Size; | |
| 7 | 8 | import java.util.List; |
| 8 | 9 | |
| 9 | 10 | @Data |
| 10 | 11 | public class ProductCommentBaseVO { |
| 11 | 12 | |
| 12 | - @Schema(description = "评价人 用户编号", required = true, example = "15721") | |
| 13 | - @NotNull(message = "评价人 用户编号不能为空") | |
| 14 | - private Long userId; | |
| 15 | - | |
| 16 | 13 | @Schema(description = "评价人名称", required = true, example = "张三") |
| 17 | 14 | @NotNull(message = "评价人名称不能为空") |
| 18 | 15 | private String userNickname; |
| ... | ... | @@ -54,7 +51,7 @@ public class ProductCommentBaseVO { |
| 54 | 51 | private String content; |
| 55 | 52 | |
| 56 | 53 | @Schema(description = "评论图片地址数组,以逗号分隔最多上传9张", required = true) |
| 57 | - @NotNull(message = "评论图片地址数组,以逗号分隔最多上传9张不能为空") | |
| 54 | + @Size(max = 9, message = "评论图片地址数组长度不能超过9张") | |
| 58 | 55 | private List<String> picUrls; |
| 59 | 56 | |
| 60 | 57 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java
| ... | ... | @@ -17,12 +17,15 @@ public class ProductCommentRespVO extends ProductCommentBaseVO { |
| 17 | 17 | @Schema(description = "订单项编号", required = true, example = "24965") |
| 18 | 18 | private Long id; |
| 19 | 19 | |
| 20 | - @Schema(description = "是否匿名:[0:不匿名 1:匿名]", required = true) | |
| 20 | + @Schema(description = "是否匿名:[false:不匿名 true:匿名]", required = true) | |
| 21 | 21 | private Boolean anonymous; |
| 22 | 22 | |
| 23 | 23 | @Schema(description = "交易订单编号", required = true, example = "24428") |
| 24 | 24 | private Long orderId; |
| 25 | 25 | |
| 26 | + @Schema(description = "评价人 用户编号", required = true, example = "15721") | |
| 27 | + private Long userId; | |
| 28 | + | |
| 26 | 29 | @Schema(description = "交易订单项编号", required = true, example = "8233") |
| 27 | 30 | private Long orderItemId; |
| 28 | 31 | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppCommentController.java
| ... | ... | @@ -44,7 +44,6 @@ public class AppCommentController { |
| 44 | 44 | @PostMapping(value = "/create") |
| 45 | 45 | @Operation(summary = "创建商品评价") |
| 46 | 46 | public CommonResult<Boolean> createComment(@RequestBody AppCommentCreateReqVO createReqVO) { |
| 47 | - // 查询会员 todo@艿艿 获取用户头像 | |
| 48 | 47 | // TODO: 2023/3/20 要不要判断订单、商品是否存在 |
| 49 | 48 | MemberUserRespDTO user = memberUserApi.getUser(getLoginUserId()); |
| 50 | 49 | productCommentService.createComment(ProductCommentConvert.INSTANCE.convert(user, createReqVO), Boolean.FALSE); | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentAdditionalReqVO.java
| ... | ... | @@ -5,6 +5,7 @@ import lombok.Data; |
| 5 | 5 | import lombok.ToString; |
| 6 | 6 | |
| 7 | 7 | import javax.validation.constraints.NotNull; |
| 8 | +import javax.validation.constraints.Size; | |
| 8 | 9 | import java.util.List; |
| 9 | 10 | |
| 10 | 11 | @Schema(description = "用户APP - 商品追加评价创建 Request VO") |
| ... | ... | @@ -21,7 +22,7 @@ public class AppCommentAdditionalReqVO { |
| 21 | 22 | private String additionalContent; |
| 22 | 23 | |
| 23 | 24 | @Schema(description = "追评评价图片地址数组,以逗号分隔最多上传9张", required = true) |
| 24 | - @NotNull(message = "追评评价图片地址数组,以逗号分隔最多上传9张不能为空") | |
| 25 | + @Size(max = 9, message = "追评评价图片地址数组长度不能超过9张") | |
| 25 | 26 | private List<String> additionalPicUrls; |
| 26 | 27 | |
| 27 | 28 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentBaseVO.java
| ... | ... | @@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | 6 | import javax.validation.constraints.NotNull; |
| 7 | +import javax.validation.constraints.Size; | |
| 7 | 8 | import java.util.List; |
| 8 | 9 | |
| 9 | 10 | @Data |
| ... | ... | @@ -42,7 +43,7 @@ public class AppCommentBaseVO { |
| 42 | 43 | private String content; |
| 43 | 44 | |
| 44 | 45 | @Schema(description = "评论图片地址数组,以逗号分隔最多上传9张", required = true) |
| 45 | - @NotNull(message = "评论图片地址数组,以逗号分隔最多上传9张不能为空") | |
| 46 | + @Size(max = 9, message = "评论图片地址数组长度不能超过9张") | |
| 46 | 47 | private List<String> picUrls; |
| 47 | 48 | |
| 48 | 49 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java
| ... | ... | @@ -34,7 +34,7 @@ public interface ProductCommentConvert { |
| 34 | 34 | ProductCommentDO productComment = new ProductCommentDO(); |
| 35 | 35 | productComment.setUserId(user.getId()); |
| 36 | 36 | productComment.setUserNickname(user.getNickname()); |
| 37 | -// productComment.setUserAvatar(); | |
| 37 | + productComment.setUserAvatar(user.getAvatar()); | |
| 38 | 38 | productComment.setAnonymous(createReqVO.getAnonymous()); |
| 39 | 39 | productComment.setOrderId(createReqVO.getOrderId()); |
| 40 | 40 | productComment.setOrderItemId(createReqVO.getOrderItemId()); |
| ... | ... | @@ -52,11 +52,10 @@ public interface ProductCommentConvert { |
| 52 | 52 | |
| 53 | 53 | default ProductCommentDO convert(ProductCommentCreateReqVO createReq) { |
| 54 | 54 | ProductCommentDO productComment = new ProductCommentDO(); |
| 55 | - productComment.setUserId(createReq.getUserId()); | |
| 55 | + productComment.setUserId(0L); | |
| 56 | 56 | productComment.setUserNickname(createReq.getUserNickname()); |
| 57 | 57 | productComment.setUserAvatar(createReq.getUserAvatar()); |
| 58 | 58 | productComment.setAnonymous(Boolean.FALSE); |
| 59 | - // TODO: 2023/3/21 自评订单ID来源 | |
| 60 | 59 | productComment.setOrderId(0L); |
| 61 | 60 | productComment.setOrderItemId(0L); |
| 62 | 61 | productComment.setSpuId(createReq.getSpuId()); | ... | ... |
yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/dto/MemberUserRespDTO.java