gaoluyang
4 天以前 d39e4f7d839167c16425086dfa2f8747bccfdff9
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
package cn.iocoder.yudao.module.erp.api.purchase;
 
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpSupplierMapper;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.Collections;
import java.util.List;
import java.util.Map;
 
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
/**
 * ERP 供应商引用查询 API 实现
 */
@RestController
@RequestMapping(ErpSupplierReferenceApi.PREFIX)
@Validated
public class ErpSupplierReferenceApiImpl implements ErpSupplierReferenceApi {
 
    @Resource
    private ErpSupplierMapper supplierMapper;
 
    @Override
    public CommonResult<List<String>> getSupplierReferenceSources(Long supplierId) {
        if (supplierId == null) {
            return success(Collections.emptyList());
        }
        List<Map<String, Object>> rows = supplierMapper.selectSupplierReferenceCount(supplierId);
        List<String> sources = rows.stream()
                .map(row -> String.valueOf(row.get("source")))
                .toList();
        return success(sources);
    }
 
}