9 天以前 d5cd948848595b0cffe098ba542a9c879b0f9165
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
package cn.iocoder.yudao.module.crm.api.customer;
 
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.crm.api.customer.dto.CrmCustomerRespDTO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
 
import java.util.Collection;
import java.util.List;
import java.util.Map;
 
/**
 * CRM 客户 API 实现类
 *
 * @author 芋道源码
 */
@Service
public class CrmCustomerApiImpl implements CrmCustomerApi {
 
    @Resource
    private CrmCustomerService customerService;
 
    @Override
    public CrmCustomerRespDTO getCustomer(Long id) {
        CrmCustomerDO customer = customerService.getCustomer(id);
        return BeanUtils.toBean(customer, CrmCustomerRespDTO.class);
    }
 
    @Override
    public List<CrmCustomerRespDTO> getCustomerList(Collection<Long> ids) {
        List<CrmCustomerDO> customers = customerService.getCustomerList(ids);
        return BeanUtils.toBean(customers, CrmCustomerRespDTO.class);
    }
 
    @Override
    public Map<Long, CrmCustomerRespDTO> getCustomerMap(Collection<Long> ids) {
        List<CrmCustomerDO> customers = customerService.getCustomerList(ids);
        return customers.stream()
                .collect(java.util.stream.Collectors.toMap(
                        CrmCustomerDO::getId,
                        customer -> BeanUtils.toBean(customer, CrmCustomerRespDTO.class)));
    }
 
    @Override
    public CrmCustomerRespDTO validateCustomer(Long id) {
        customerService.validateCustomer(id);
        return getCustomer(id);
    }
 
}