From a88a536514b0ee5fb863dd5c992279d5b86ad77f Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期一, 09 十二月 2024 18:18:40 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java | 62 ++++++++++++++++++++++++++++++- 1 files changed, 60 insertions(+), 2 deletions(-) diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java index 2b55eaf..fb99589 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java @@ -1,8 +1,21 @@ package com.ruoyi.other.controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.ruoyi.account.api.feignClient.AppUserClient; +import com.ruoyi.account.api.model.AppUser; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.GoodsEvaluate; +import com.ruoyi.other.service.GoodsEvaluateService; +import com.ruoyi.other.service.GoodsService; +import com.ruoyi.other.vo.GoodsEvaluateVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; /** * <p> @@ -14,7 +27,52 @@ */ @RestController @RequestMapping("/goods-evaluate") +@Api("评论") public class GoodsEvaluateController { + @Resource + private GoodsEvaluateService goodsEvaluateService; + @Resource + private AppUserClient appUserClient; + @Resource + private GoodsService goodsService; + + @GetMapping("/goodsList") + @ApiOperation(value = "获取商品评价", tags = {"小程序-获取商品评价"}) + public R<List<GoodsEvaluate>> goodsList(@ApiParam("商品id") Integer goodsId){ + List<GoodsEvaluate> list = goodsEvaluateService.lambdaQuery().eq(GoodsEvaluate::getGoodsId, goodsId).list(); + for (GoodsEvaluate goodsEvaluate : list) { + AppUser appUserById = appUserClient.getAppUserById(goodsEvaluate.getAppUserId()); + goodsEvaluate.setUserName(appUserById.getName()); + goodsEvaluate.setAvatar(appUserById.getAvatar()); + goodsEvaluate.setIdStr(String.valueOf(goodsEvaluate.getId())); + } + return R.ok(list); + } + + /** + * 发布商品评价 + */ + @PostMapping("/addGoodsEvaluate") + @ApiOperation(value = "发布商品评价", tags = {"小程序-发布商品评价"}) + public R<Void> addGoodsEvaluate(@RequestBody GoodsEvaluateVO goodsEvaluateVO){ + goodsEvaluateService.addGoodsEvaluate(goodsEvaluateVO); + return R.ok(); + } + + /** + * 评论详情 + */ + @GetMapping("/detail/{orderId}") + @ApiOperation(value = "评论详情", tags = {"小程序-评论详情"}) + public R<List<GoodsEvaluate>> detail(@PathVariable("orderId") Long orderId){ + List<GoodsEvaluate> list = goodsEvaluateService.list(new LambdaQueryWrapper<GoodsEvaluate>() + .eq(GoodsEvaluate::getStatus, 2) + .eq(GoodsEvaluate::getOrderId, orderId)); + for (GoodsEvaluate goodsEvaluate : list) { + + } + return R.ok(list); + } } -- Gitblit v1.7.1