package com.sifang.modules.sunshine.partnerManagement.dao;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.sifang.modules.sys.util.SqlBuilder;

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

public class PartnerBrandUtils {

    public static Map<String, String> getBrandList(String materialType, String partnerId) {
        SqlBuilder sql = new SqlBuilder();
        sql.line("SELECT a.brand, a.brand_code");
        sql.line("FROM crm_partner_material_brand a");
        sql.line("WHERE a.partner_id = ? and a.material_type = ?", partnerId, materialType);
        List<Record> list = Db.find(sql.build(), sql.params());
        Map<String, String> map = list.stream().collect(Collectors.toMap(p -> p.getStr("brand"),
                p -> p.getStr("brand_code")));
        return map;
    }
}
