无关风月
2024-08-07 2a4abeed50d35b545a634a1ea0095fdd8ffea70f
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TGoodsServiceImpl.java
@@ -1,10 +1,17 @@
package com.ruoyi.other.service.impl;
import com.ruoyi.other.model.TGoods;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.order.api.feignClient.OrderClient;
import com.ruoyi.other.api.domain.TGoods;
import com.ruoyi.other.api.dto.GoodsDTO;
import com.ruoyi.other.mapper.TGoodsMapper;
import com.ruoyi.other.service.TGoodsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
/**
 * <p>
@@ -17,4 +24,27 @@
@Service
public class TGoodsServiceImpl extends ServiceImpl<TGoodsMapper, TGoods> implements TGoodsService {
    @Autowired
    private OrderClient orderClient;
    @Override
    public PageInfo<TGoods> pageList(GoodsDTO dto) {
        PageInfo<TGoods> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize());
        List<TGoods> list = this.baseMapper.pageList(pageInfo,dto);
        StringBuilder stringBuilder = new StringBuilder();
        for (TGoods temp : list) {
            stringBuilder.append(temp.getId()).append(",");
        }
        if (StringUtils.hasLength(stringBuilder)){
            // 去除最后一个字符
            stringBuilder.deleteCharAt(stringBuilder.length()-1);
        }
        String string = stringBuilder.toString();
        List<Integer> data = orderClient.getSalesCountByGoodsId(string).getData();
//        goodsClient
        // 远程调用cha'xun
        pageInfo.setRecords(list);
        return pageInfo;
    }
}