package com.dgtly.wxportal.utils;


import java.util.Map;
import java.util.Set;

/**
 * 不是销售 获取发送文字的方法;
 */
public class CreditGetSendMessageSubAndOffice<T> implements BatchSendGetSendMessage<T>{

    //发送文字模版
    private String temple;
    //发送文字和其他参数的map
    private Map<T,Set<String>> textObject;
    private Map<String,Map<String,Object>> employeeCodeTouser;
    public CreditGetSendMessageSubAndOffice(String template, Map<T,Set<String>> textObject,Map<String,Map<String,Object>> employeeCodeTouser){
        this.temple = template;
        this.textObject = textObject;
        this.employeeCodeTouser = employeeCodeTouser;
    }

    @Override
    public String getSendText(T code) {
        String str = "";
        if(textObject.containsKey(code)&&employeeCodeTouser.containsKey(code)){
            String orgCode = employeeCodeTouser.get(code).get("org_code").toString();
            for(String s :textObject.get(code)){
                str+=s+",";
            }
            str = str.substring(0, str.length() - 1);
            return String.format(temple,str,orgCode);
        }else{
            throw new RuntimeException("未查询到相应组织代码对应的文字参数，code："+code.toString());
        }

    }



}
