package com.tzld.piaoquan.growth.common.service.Impl;

import com.tzld.piaoquan.growth.common.dao.mapper.StaffMapper;
import com.tzld.piaoquan.growth.common.model.po.Staff;
import com.tzld.piaoquan.growth.common.model.po.StaffExample;
import com.tzld.piaoquan.growth.common.service.WeComStaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service
public class WeComStaffServiceImpl implements WeComStaffService {

    @Autowired
    private StaffMapper staffMapper;

    @Override
    public Long getStaffIdByCarrierId(String carrierId) {
        StaffExample example = new StaffExample();
        example.createCriteria().andCarrierIdEqualTo(carrierId);
        List<Staff> staffs = staffMapper.selectByExample(example);
        if (CollectionUtils.isEmpty(staffs)) {
            return null;
        }
        return staffs.get(0).getId();
    }
}
