package cn.com.ctop.common.module.service.impl;

import cn.com.ctop.common.module.entity.AgentConfig;
import cn.com.ctop.common.module.mapper.AgentConfigMapper;
import cn.com.ctop.common.module.service.IAgentConfigService;
import cn.com.ctop.common.module.utils.Check;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 代理商配置
 *
 * @author jeecg-boot
 * 2022-05-17
 * @version V1.0
 */
@Service
public class AgentConfigServiceImpl extends ServiceImpl<AgentConfigMapper, AgentConfig> implements IAgentConfigService {
    @Autowired
    private AgentConfigMapper agentConfigMapper;

    @Override
    public Map<Long, String> getAgentMap() {
        Map<Long, String> agentMap = new HashMap<>();
        QueryWrapper<AgentConfig> queryWrapper = new QueryWrapper();
        List<AgentConfig> agentConfigs = agentConfigMapper.selectList(queryWrapper);
        if (!Check.isNull(agentConfigs)) {
            for (AgentConfig agentConfig : agentConfigs) {
                agentMap.put(agentConfig.getAgentCode(), agentConfig.getAgentName());
            }
        }

        return agentMap;
    }
}
