From d0a4f1260ae71837c125a9f2c4609e6fbf0c5ee1 Mon Sep 17 00:00:00 2001
From: phpcjl <phpcjl@gmail.com>
Date: 星期一, 16 十二月 2024 14:36:44 +0800
Subject: [PATCH] 1
---
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java | 67 +++++++++++++++++++++++++++++++++
1 files changed, 66 insertions(+), 1 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 742ce12..1d9c8ad 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,9 +2,11 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
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;
@@ -19,7 +21,6 @@
import javax.annotation.Resource;
import java.util.List;
-import java.util.stream.Collectors;
/**
* <p>
@@ -84,5 +85,69 @@
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<List<GoodsEvaluate>> list(GoodsEvaluate goodsEvaluate){
+ List<GoodsEvaluate> list = goodsEvaluateService.lambdaQuery()
+ .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)
+ .list();
+
+ list.forEach(this::buildDetail);
+
+ return R.ok(list);
+ }
+
+ 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