Pu Zhibing
2024-12-05 940dd1b292db4c5cc2df2f137fa46c37f2159898
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
package com.ruoyi.other.controller;
 
 
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.other.api.domain.Goods;
import com.ruoyi.other.api.domain.GoodsEvaluate;
import com.ruoyi.other.service.GoodsEvaluateService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
import java.util.List;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author luodangjia
 * @since 2024-11-20
 */
@RestController
@RequestMapping("/goods-evaluate")
public class GoodsEvaluateController {
    @Resource
    private GoodsEvaluateService goodsEvaluateService;
    @Resource
    private AppUserClient appUserClient;
 
    @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());
        }
        return R.ok(list);
    }
 
}