From e2dca5a3ce717a7708d432955d3dc8d6ee800e5d Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期四, 26 十二月 2024 19:12:16 +0800
Subject: [PATCH] 合并代码
---
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java | 83 ++++++++++++++++++++++++++++++++++++++++-
1 files changed, 81 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 273c58b..b1374df 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
@@ -2,13 +2,19 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.utils.StringUtils;
+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;
@@ -35,6 +41,8 @@
private AppUserClient appUserClient;
@Resource
private GoodsService goodsService;
+ @Resource
+ private TokenService tokenService;
@GetMapping("/goodsList")
@ApiOperation(value = "获取商品评价", tags = {"小程序-获取商品评价"})
@@ -44,6 +52,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);
}
@@ -52,7 +61,7 @@
* 发布商品评价
*/
@PostMapping("/addGoodsEvaluate")
- @ApiOperation(value = "发布商品评价", tags = {"小程序-发布商品评价"})
+ @ApiOperation(value = "发布商品评价", tags = {"小程序-个人中心-我的订单"})
public R<Void> addGoodsEvaluate(@RequestBody GoodsEvaluateVO goodsEvaluateVO){
goodsEvaluateService.addGoodsEvaluate(goodsEvaluateVO);
return R.ok();
@@ -64,14 +73,84 @@
@GetMapping("/detail/{orderId}")
@ApiOperation(value = "评论详情", tags = {"小程序-评论详情"})
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);
}
+
+ /**
+ * 删除评论
+ */
+ @DeleteMapping("/delete/{id}")
+ @ApiOperation(value = "删除评论", tags = {"管理后台-商品管理-评价管理"})
+ public R<Void> delete(@PathVariable("id") Long id){
+ goodsEvaluateService.removeById(id);
+ return R.ok();
+ }
+
+ /**
+ * 评论列表
+ */
+ @GetMapping("/list")
+ @ApiOperation(value = "评论列表", tags = {"管理后台-商品管理-评价管理"})
+ public R<Page<GoodsEvaluate>> list(@ApiParam("页码") @RequestParam Integer pageNum,
+ @ApiParam("每一页数据大小") Integer pageSize,
+ GoodsEvaluate goodsEvaluate){
+ Page<GoodsEvaluate> page = goodsEvaluateService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<GoodsEvaluate>()
+ .like(StringUtils.isNotEmpty(goodsEvaluate.getGoodsName()), GoodsEvaluate::getGoodsName, goodsEvaluate.getComment())
+ .like(StringUtils.isNotEmpty(goodsEvaluate.getUserName()), GoodsEvaluate::getUserName, goodsEvaluate.getUserName())
+ .like(StringUtils.isNotEmpty(goodsEvaluate.getPhone()), GoodsEvaluate::getPhone, goodsEvaluate.getPhone())
+ .eq(goodsEvaluate.getStatus() != null, GoodsEvaluate::getStatus, goodsEvaluate.getStatus())
+ .orderByDesc(GoodsEvaluate::getCreateTime));
+
+
+ page.getRecords().forEach(this::buildDetail);
+
+ return R.ok(page);
+ }
+
+ private void buildDetail(GoodsEvaluate item) {
+ AppUser appUser = appUserClient.getAppUserById(item.getAppUserId());
+ if (appUser == null){
+ throw new RuntimeException("获取用户信息失败");
+ }
+ Goods goods = goodsService.getById(item.getGoodsId());
+ item.setGoodsName(goods.getName());
+ item.setPhone(appUser.getPhone());
+ item.setUserName(appUser.getName());
+ }
+
+ /**
+ * 评论详情
+ */
+ @GetMapping("/{id}")
+ @ApiOperation(value = "评论详情", tags = {"管理后台-商品管理-评价管理"})
+ public R<GoodsEvaluate> getDetail(@PathVariable("id") Long id){
+ GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(id);
+ buildDetail(goodsEvaluate);
+ return R.ok(goodsEvaluate);
+ }
+
+ /**
+ * 评论上/下架
+ */
+ @PutMapping("/changeStatus")
+ @ApiOperation(value = "上/下架", tags = {"管理后台-商品管理-评价管理"})
+ public R<Void> changeStatus(@RequestBody GoodsEvaluate goodsEvaluate){
+ goodsEvaluateService.update(new LambdaUpdateWrapper<GoodsEvaluate>()
+ .eq(GoodsEvaluate::getId, goodsEvaluate.getId())
+ .set(GoodsEvaluate::getStatus, goodsEvaluate.getStatus()));
+ return R.ok();
+ }
+
}
--
Gitblit v1.7.1