package com.fjhx.mail.service.my.impl;

import com.fjhx.customer.entity.customer.po.Customer;
import com.fjhx.customer.service.customer.CustomerService;
import com.fjhx.mail.service.message.impl.InfoServiceImpl;
import com.fjhx.mail.service.my.MyCustomerService;
import com.ruoyi.common.core.domain.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class MyCustomerServiceImpl implements MyCustomerService {

    @Autowired
    private InfoServiceImpl infoService;

    @Autowired
    private CustomerService customerService;


    @Override
    public List<Customer> getList(Long userId) {
        List<SysUser> userList = infoService.getUserList();

        // 获取用户id
        List<Long> userIdList = userList.stream().map(SysUser::getUserId).collect(Collectors.toList());
        userIdList.add(userId);

        return customerService.list(q -> q.in(Customer::getUserId, userIdList));
    }
}
