Commit 38d7d75f7f13edba2ad169fad6abaf56e870a5f9

Authored by wangzhs
1 parent 6fe5f4bc

[新增][商品评价]管理后台/APP端

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