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

1. 增加头像返回字段
2. 调整商户自评userId
3. 控制评论图片数量判断
This commit is contained in:
wangzhs 2023-03-23 14:06:14 +08:00
parent 6fe5f4bc0d
commit 38d7d75f7f
7 changed files with 16 additions and 13 deletions

View File

@ -4,15 +4,12 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List; import java.util.List;
@Data @Data
public class ProductCommentBaseVO { public class ProductCommentBaseVO {
@Schema(description = "评价人 用户编号", required = true, example = "15721")
@NotNull(message = "评价人 用户编号不能为空")
private Long userId;
@Schema(description = "评价人名称", required = true, example = "张三") @Schema(description = "评价人名称", required = true, example = "张三")
@NotNull(message = "评价人名称不能为空") @NotNull(message = "评价人名称不能为空")
private String userNickname; private String userNickname;
@ -54,7 +51,7 @@ public class ProductCommentBaseVO {
private String content; private String content;
@Schema(description = "评论图片地址数组以逗号分隔最多上传9张", required = true) @Schema(description = "评论图片地址数组以逗号分隔最多上传9张", required = true)
@NotNull(message = "评论图片地址数组以逗号分隔最多上传9张不能为空") @Size(max = 9, message = "评论图片地址数组长度不能超过9张")
private List<String> picUrls; private List<String> picUrls;
} }

View File

@ -17,12 +17,15 @@ public class ProductCommentRespVO extends ProductCommentBaseVO {
@Schema(description = "订单项编号", required = true, example = "24965") @Schema(description = "订单项编号", required = true, example = "24965")
private Long id; private Long id;
@Schema(description = "是否匿名:[0:不匿名 1:匿名]", required = true) @Schema(description = "是否匿名:[false:不匿名 true:匿名]", required = true)
private Boolean anonymous; private Boolean anonymous;
@Schema(description = "交易订单编号", required = true, example = "24428") @Schema(description = "交易订单编号", required = true, example = "24428")
private Long orderId; private Long orderId;
@Schema(description = "评价人 用户编号", required = true, example = "15721")
private Long userId;
@Schema(description = "交易订单项编号", required = true, example = "8233") @Schema(description = "交易订单项编号", required = true, example = "8233")
private Long orderItemId; private Long orderItemId;

View File

@ -44,7 +44,6 @@ public class AppCommentController {
@PostMapping(value = "/create") @PostMapping(value = "/create")
@Operation(summary = "创建商品评价") @Operation(summary = "创建商品评价")
public CommonResult<Boolean> createComment(@RequestBody AppCommentCreateReqVO createReqVO) { public CommonResult<Boolean> createComment(@RequestBody AppCommentCreateReqVO createReqVO) {
// 查询会员 todo@艿艿 获取用户头像
// TODO: 2023/3/20 要不要判断订单商品是否存在 // TODO: 2023/3/20 要不要判断订单商品是否存在
MemberUserRespDTO user = memberUserApi.getUser(getLoginUserId()); MemberUserRespDTO user = memberUserApi.getUser(getLoginUserId());
productCommentService.createComment(ProductCommentConvert.INSTANCE.convert(user, createReqVO), Boolean.FALSE); productCommentService.createComment(ProductCommentConvert.INSTANCE.convert(user, createReqVO), Boolean.FALSE);

View File

@ -5,6 +5,7 @@ import lombok.Data;
import lombok.ToString; import lombok.ToString;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List; import java.util.List;
@Schema(description = "用户APP - 商品追加评价创建 Request VO") @Schema(description = "用户APP - 商品追加评价创建 Request VO")
@ -21,7 +22,7 @@ public class AppCommentAdditionalReqVO {
private String additionalContent; private String additionalContent;
@Schema(description = "追评评价图片地址数组以逗号分隔最多上传9张", required = true) @Schema(description = "追评评价图片地址数组以逗号分隔最多上传9张", required = true)
@NotNull(message = "追评评价图片地址数组以逗号分隔最多上传9张不能为空") @Size(max = 9, message = "追评评价图片地址数组长度不能超过9张")
private List<String> additionalPicUrls; private List<String> additionalPicUrls;
} }

View File

@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List; import java.util.List;
@Data @Data
@ -42,7 +43,7 @@ public class AppCommentBaseVO {
private String content; private String content;
@Schema(description = "评论图片地址数组以逗号分隔最多上传9张", required = true) @Schema(description = "评论图片地址数组以逗号分隔最多上传9张", required = true)
@NotNull(message = "评论图片地址数组以逗号分隔最多上传9张不能为空") @Size(max = 9, message = "评论图片地址数组长度不能超过9张")
private List<String> picUrls; private List<String> picUrls;
} }

View File

@ -34,7 +34,7 @@ public interface ProductCommentConvert {
ProductCommentDO productComment = new ProductCommentDO(); ProductCommentDO productComment = new ProductCommentDO();
productComment.setUserId(user.getId()); productComment.setUserId(user.getId());
productComment.setUserNickname(user.getNickname()); productComment.setUserNickname(user.getNickname());
// productComment.setUserAvatar(); productComment.setUserAvatar(user.getAvatar());
productComment.setAnonymous(createReqVO.getAnonymous()); productComment.setAnonymous(createReqVO.getAnonymous());
productComment.setOrderId(createReqVO.getOrderId()); productComment.setOrderId(createReqVO.getOrderId());
productComment.setOrderItemId(createReqVO.getOrderItemId()); productComment.setOrderItemId(createReqVO.getOrderItemId());
@ -52,11 +52,10 @@ public interface ProductCommentConvert {
default ProductCommentDO convert(ProductCommentCreateReqVO createReq) { default ProductCommentDO convert(ProductCommentCreateReqVO createReq) {
ProductCommentDO productComment = new ProductCommentDO(); ProductCommentDO productComment = new ProductCommentDO();
productComment.setUserId(createReq.getUserId()); productComment.setUserId(0L);
productComment.setUserNickname(createReq.getUserNickname()); productComment.setUserNickname(createReq.getUserNickname());
productComment.setUserAvatar(createReq.getUserAvatar()); productComment.setUserAvatar(createReq.getUserAvatar());
productComment.setAnonymous(Boolean.FALSE); productComment.setAnonymous(Boolean.FALSE);
// TODO: 2023/3/21 自评订单ID来源
productComment.setOrderId(0L); productComment.setOrderId(0L);
productComment.setOrderItemId(0L); productComment.setOrderItemId(0L);
productComment.setSpuId(createReq.getSpuId()); productComment.setSpuId(createReq.getSpuId());

View File

@ -25,7 +25,10 @@ public class MemberUserRespDTO {
* 枚举 {@link CommonStatusEnum} * 枚举 {@link CommonStatusEnum}
*/ */
private Integer status; private Integer status;
/**
* 用户头像
*/
private String avatar;
/** /**
* 手机 * 手机
*/ */