From 2a5bf6800c67bfd53b638ff6f78b3f35365fa330 Mon Sep 17 00:00:00 2001 From: phpcjl <phpcjl@gmail.com> Date: 星期三, 11 十二月 2024 17:50:44 +0800 Subject: [PATCH] 1.后台管理-商品管理 --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java | 35 +++++++++++++++++++++++++++-------- 1 files changed, 27 insertions(+), 8 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 52be078..742ce12 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,13 +1,17 @@ package com.ruoyi.other.controller; +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.common.core.web.page.TableDataInfo; +import com.ruoyi.common.security.service.TokenService; import com.ruoyi.other.api.domain.Goods; 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 com.ruoyi.system.api.model.LoginUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -15,6 +19,7 @@ import javax.annotation.Resource; import java.util.List; +import java.util.stream.Collectors; /** * <p> @@ -32,6 +37,10 @@ private GoodsEvaluateService goodsEvaluateService; @Resource private AppUserClient appUserClient; + @Resource + private GoodsService goodsService; + @Resource + private TokenService tokenService; @GetMapping("/goodsList") @ApiOperation(value = "获取商品评价", tags = {"小程序-获取商品评价"}) @@ -41,6 +50,7 @@ AppUser appUserById = appUserClient.getAppUserById(goodsEvaluate.getAppUserId()); goodsEvaluate.setUserName(appUserById.getName()); goodsEvaluate.setAvatar(appUserById.getAvatar()); + goodsEvaluate.setIdStr(String.valueOf(goodsEvaluate.getId())); } return R.ok(list); } @@ -49,20 +59,29 @@ * 发布商品评价 */ @PostMapping("/addGoodsEvaluate") - @ApiOperation(value = "发布商品评价", tags = {"小程序-发布商品评价"}) - public R<Void> addGoodsEvaluate(GoodsEvaluate goodsEvaluate){ - goodsEvaluateService.save(goodsEvaluate); + @ApiOperation(value = "发布商品评价", tags = {"小程序-个人中心-我的订单"}) + public R<Void> addGoodsEvaluate(@RequestBody GoodsEvaluateVO goodsEvaluateVO){ + goodsEvaluateService.addGoodsEvaluate(goodsEvaluateVO); return R.ok(); } /** * 评论详情 */ - @GetMapping("/detail/{id}") + @GetMapping("/detail/{orderId}") @ApiOperation(value = "评论详情", tags = {"小程序-评论详情"}) - public R<GoodsEvaluate> detail(@PathVariable("id") Long id){ - GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(id); - return R.ok(goodsEvaluate); + public R<List<GoodsEvaluate>> detail(@PathVariable("orderId") Long orderId){ + LoginUser loginUserApplet = tokenService.getLoginUserApplet(); + List<GoodsEvaluate> list = goodsEvaluateService.list(new LambdaQueryWrapper<GoodsEvaluate>() + .eq(GoodsEvaluate::getStatus, 2) + .eq(GoodsEvaluate::getAppUserId,loginUserApplet.getUserid()) + .eq(GoodsEvaluate::getOrderId, orderId)); + for (GoodsEvaluate goodsEvaluate : list) { + Goods goods = goodsService.getById(goodsEvaluate.getGoodsId()); + goodsEvaluate.setGoodsName(goods.getName()); + goodsEvaluate.setGoodsImg(goods.getHomePagePicture()); + } + return R.ok(list); } } -- Gitblit v1.7.1