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

import cn.com.ctop.common.module.entity.SupplierList;
import cn.com.ctop.common.module.mapper.SupplierListMapper;
import cn.com.ctop.common.module.service.ISupplierListService;
import cn.com.ctop.common.module.utils.Check;
import com.alibaba.fastjson.JSONObject;
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
 * @version V1.0
 * @date 2020-07-27
 */
@Service
public class SupplierListServiceImpl extends ServiceImpl<SupplierListMapper, SupplierList> implements ISupplierListService {
    @Autowired
    private SupplierListMapper supplierListMapper;

    @Override
    public Map<String, String> getSupplierMap() {
        Map<String, String> map = new HashMap<>();
        List<JSONObject> list = supplierListMapper.getSupplierMap();
        if (!Check.isNull(list)) {
            for (int i = 0; i < list.size(); i++) {
                JSONObject json = list.get(i);
                map.put(json.getString("code"), json.getString("name"));
            }
        }
        return map;
    }
}
