1.
phpcjl
2024-12-09 fd9ee9caa17d4d722532f6536d53ce40254fa722
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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.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>
 *  前端控制器
 * </p>
 *
 * @author luodangjia
 * @since 2024-11-20
 */
@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);
    }
 
}