mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	mall + product:增加评论 mock 逻辑
This commit is contained in:
		| @@ -1,5 +1,6 @@ | |||||||
| package cn.iocoder.yudao.module.product.controller.app.comment; | package cn.iocoder.yudao.module.product.controller.app.comment; | ||||||
|  |  | ||||||
|  | import cn.hutool.core.map.MapUtil; | ||||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||||
| import cn.iocoder.yudao.module.member.api.user.MemberUserApi; | import cn.iocoder.yudao.module.member.api.user.MemberUserApi; | ||||||
| @@ -7,16 +8,20 @@ import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; | |||||||
| import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentCreateReqVO; | import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentCreateReqVO; | ||||||
| import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; | import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; | ||||||
| import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentRespVO; | import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentRespVO; | ||||||
|  | import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO; | ||||||
| import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert; | import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert; | ||||||
| import cn.iocoder.yudao.module.product.service.comment.ProductCommentService; | import cn.iocoder.yudao.module.product.service.comment.ProductCommentService; | ||||||
| import io.swagger.v3.oas.annotations.Operation; | import io.swagger.v3.oas.annotations.Operation; | ||||||
|  | import io.swagger.v3.oas.annotations.Parameter; | ||||||
|  | import io.swagger.v3.oas.annotations.Parameters; | ||||||
| import io.swagger.v3.oas.annotations.tags.Tag; | import io.swagger.v3.oas.annotations.tags.Tag; | ||||||
| import org.springframework.validation.annotation.Validated; | import org.springframework.validation.annotation.Validated; | ||||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||||
|  |  | ||||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||||
| import javax.validation.Valid; | import javax.validation.Valid; | ||||||
| import java.util.Map; | import java.time.LocalDateTime; | ||||||
|  | import java.util.*; | ||||||
|  |  | ||||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||||
| import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | ||||||
| @@ -34,6 +39,66 @@ public class AppCommentController { | |||||||
|     @Resource |     @Resource | ||||||
|     private MemberUserApi memberUserApi; |     private MemberUserApi memberUserApi; | ||||||
|  |  | ||||||
|  |     @GetMapping("/list") | ||||||
|  |     @Operation(summary = "获得最近的 n 条商品评价") | ||||||
|  |     @Parameters({ | ||||||
|  |             @Parameter(name = "spuId", description = "商品 SPU 编号", required = true, example = "1024"), | ||||||
|  |             @Parameter(name = "count", description = "数量", required = true, example = "10") | ||||||
|  |     }) | ||||||
|  |     public CommonResult<List<AppCommentRespVO>> getCommentList(@RequestParam("spuId") Long spuId, | ||||||
|  |                                                                @RequestParam(value = "count", defaultValue = "10") Integer count) { | ||||||
|  |  | ||||||
|  |         List<AppProductPropertyValueDetailRespVO> list = new ArrayList<>(); | ||||||
|  |  | ||||||
|  |         AppProductPropertyValueDetailRespVO item1 = new AppProductPropertyValueDetailRespVO(); | ||||||
|  |         item1.setPropertyId(1L); | ||||||
|  |         item1.setPropertyName("颜色"); | ||||||
|  |         item1.setValueId(1024L); | ||||||
|  |         item1.setValueName("红色"); | ||||||
|  |         list.add(item1); | ||||||
|  |  | ||||||
|  |         AppProductPropertyValueDetailRespVO item2 = new AppProductPropertyValueDetailRespVO(); | ||||||
|  |         item2.setPropertyId(2L); | ||||||
|  |         item2.setPropertyName("尺寸"); | ||||||
|  |         item2.setValueId(2048L); | ||||||
|  |         item2.setValueName("大号"); | ||||||
|  |         list.add(item2); | ||||||
|  |  | ||||||
|  |         AppProductPropertyValueDetailRespVO item3 = new AppProductPropertyValueDetailRespVO(); | ||||||
|  |         item3.setPropertyId(3L); | ||||||
|  |         item3.setPropertyName("重量"); | ||||||
|  |         item3.setValueId(3072L); | ||||||
|  |         item3.setValueName("500克"); | ||||||
|  |         list.add(item3); | ||||||
|  |  | ||||||
|  |         // TODO 生成 mock 的数据 | ||||||
|  |         AppCommentRespVO appCommentRespVO = new AppCommentRespVO(); | ||||||
|  |         appCommentRespVO.setUserId((long) (new Random().nextInt(100000) + 10000)); | ||||||
|  |         appCommentRespVO.setUserNickname("用户" + new Random().nextInt(100)); | ||||||
|  |         appCommentRespVO.setUserAvatar("https://demo26.crmeb.net/uploads/attach/2021/11/15/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg"); | ||||||
|  |         appCommentRespVO.setId((long) (new Random().nextInt(100000) + 10000)); | ||||||
|  |         appCommentRespVO.setAnonymous(new Random().nextBoolean()); | ||||||
|  |         appCommentRespVO.setOrderId((long) (new Random().nextInt(100000) + 10000)); | ||||||
|  |         appCommentRespVO.setOrderItemId((long) (new Random().nextInt(100000) + 10000)); | ||||||
|  |         appCommentRespVO.setReplyStatus(new Random().nextBoolean()); | ||||||
|  |         appCommentRespVO.setReplyUserId((long) (new Random().nextInt(100000) + 10000)); | ||||||
|  |         appCommentRespVO.setReplyContent("回复内容" + new Random().nextInt(100)); | ||||||
|  |         appCommentRespVO.setReplyTime(LocalDateTime.now().minusDays(new Random().nextInt(30))); | ||||||
|  |         appCommentRespVO.setCreateTime(LocalDateTime.now().minusDays(new Random().nextInt(30))); | ||||||
|  |         appCommentRespVO.setFinalScore(new Random().nextInt(5) + 1); | ||||||
|  |         appCommentRespVO.setSpuId((long) (new Random().nextInt(100000) + 10000)); | ||||||
|  |         appCommentRespVO.setSpuName("商品" + new Random().nextInt(100)); | ||||||
|  |         appCommentRespVO.setSkuId((long) (new Random().nextInt(100000) + 10000)); | ||||||
|  |         appCommentRespVO.setSkuProperties(list); | ||||||
|  |         appCommentRespVO.setScores(new Random().nextInt(5) + 1); | ||||||
|  |         appCommentRespVO.setDescriptionScores(new Random().nextInt(5) + 1); | ||||||
|  |         appCommentRespVO.setBenefitScores(new Random().nextInt(5) + 1); | ||||||
|  |         appCommentRespVO.setContent("评论内容" + new Random().nextInt(100)); | ||||||
|  |         appCommentRespVO.setPicUrls(Arrays.asList("https://demo26.crmeb.net/uploads/attach/2021/11/15/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg")); | ||||||
|  |  | ||||||
|  |         return success(Arrays.asList(appCommentRespVO)); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     @GetMapping("/page") |     @GetMapping("/page") | ||||||
|     @Operation(summary = "获得商品评价分页") |     @Operation(summary = "获得商品评价分页") | ||||||
|     public CommonResult<PageResult<AppCommentRespVO>> getCommentPage(@Valid AppCommentPageReqVO pageVO) { |     public CommonResult<PageResult<AppCommentRespVO>> getCommentPage(@Valid AppCommentPageReqVO pageVO) { | ||||||
| @@ -41,10 +106,15 @@ public class AppCommentController { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     // TODO @puhui999:方法名改成 getCommentStatistics?然后搞个对应的 vo?想了下,这样更优雅 |     // TODO @puhui999:方法名改成 getCommentStatistics?然后搞个对应的 vo?想了下,这样更优雅 | ||||||
|     @GetMapping("/get-count") |     @GetMapping("/statistics") | ||||||
|     @Operation(summary = "获得商品的评价统计") // TODO @puhui999:@RequestParam 哈,针对 spuId |     @Operation(summary = "获得商品的评价统计") // TODO @puhui999:@RequestParam 哈,针对 spuId | ||||||
|     public CommonResult<Map<String, Long>> getCommentPage(@Valid Long spuId) { |     public CommonResult<Map<String, Object>> getCommentStatistics(@Valid Long spuId) { | ||||||
|         return success(productCommentService.getCommentPageTabsCount(spuId, Boolean.TRUE)); |         // TODO 生成 mock 的数据 | ||||||
|  |         if (true) { | ||||||
|  |             return success(MapUtil.<String, Object>builder("allCount", 10L).put("goodPercent", "10.33").build()); | ||||||
|  |         } | ||||||
|  |         return null; | ||||||
|  | //        return success(productCommentService.getCommentPageTabsCount(spuId, Boolean.TRUE)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @PostMapping(value = "/create") |     @PostMapping(value = "/create") | ||||||
|   | |||||||
| @@ -1,5 +1,6 @@ | |||||||
| package cn.iocoder.yudao.module.product.controller.app.comment.vo; | package cn.iocoder.yudao.module.product.controller.app.comment.vo; | ||||||
|  |  | ||||||
|  | import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO; | ||||||
| import io.swagger.v3.oas.annotations.media.Schema; | import io.swagger.v3.oas.annotations.media.Schema; | ||||||
| import lombok.Data; | import lombok.Data; | ||||||
|  |  | ||||||
| @@ -7,7 +8,7 @@ import javax.validation.constraints.NotNull; | |||||||
| import javax.validation.constraints.Size; | import javax.validation.constraints.Size; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| // TODO @puhui999:把 Product 前缀给补下哈 | // TODO @puhui999:C 端可以不要 base 哈。 | ||||||
| @Data | @Data | ||||||
| public class AppCommentBaseVO { | public class AppCommentBaseVO { | ||||||
|  |  | ||||||
| @@ -23,6 +24,9 @@ public class AppCommentBaseVO { | |||||||
|     @NotNull(message = "商品SKU编号不能为空") |     @NotNull(message = "商品SKU编号不能为空") | ||||||
|     private Long skuId; |     private Long skuId; | ||||||
|  |  | ||||||
|  |     @Schema(description = "商品 SKU 属性", required = true) | ||||||
|  |     private List<AppProductPropertyValueDetailRespVO> skuProperties; // TODO puhui999:这个需要从数据库查询哈 | ||||||
|  |  | ||||||
|     @Schema(description = "评分星级 1-5分", required = true) |     @Schema(description = "评分星级 1-5分", required = true) | ||||||
|     @NotNull(message = "评分星级 1-5分不能为空") |     @NotNull(message = "评分星级 1-5分不能为空") | ||||||
|     private Integer scores; |     private Integer scores; | ||||||
|   | |||||||
| @@ -6,7 +6,6 @@ import lombok.EqualsAndHashCode; | |||||||
| import lombok.ToString; | import lombok.ToString; | ||||||
|  |  | ||||||
| import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||||
| import java.util.List; |  | ||||||
|  |  | ||||||
| @Schema(description = "用户APP - 商品评价 Response VO") | @Schema(description = "用户APP - 商品评价 Response VO") | ||||||
| @Data | @Data | ||||||
| @@ -49,15 +48,6 @@ public class AppCommentRespVO extends AppCommentBaseVO { | |||||||
|     @Schema(description = "商家回复时间") |     @Schema(description = "商家回复时间") | ||||||
|     private LocalDateTime replyTime; |     private LocalDateTime replyTime; | ||||||
|  |  | ||||||
|     @Schema(description = "追加评价内容") |  | ||||||
|     private String additionalContent; |  | ||||||
|  |  | ||||||
|     @Schema(description = "追评评价图片地址数组,以逗号分隔最多上传9张") |  | ||||||
|     private List<String> additionalPicUrls; |  | ||||||
|  |  | ||||||
|     @Schema(description = "追加评价时间") |  | ||||||
|     private LocalDateTime additionalTime; |  | ||||||
|  |  | ||||||
|     @Schema(description = "创建时间", required = true) |     @Schema(description = "创建时间", required = true) | ||||||
|     private LocalDateTime createTime; |     private LocalDateTime createTime; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -35,7 +35,7 @@ public class ProductCommentDO extends BaseDO { | |||||||
|     private Long id; |     private Long id; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 评价人 用户编号 |      * 评价人的用户编号 | ||||||
|      * |      * | ||||||
|      * 关联 MemberUserDO 的 id 编号 |      * 关联 MemberUserDO 的 id 编号 | ||||||
|      */ |      */ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV