package com.docus.server.message.config;

import com.alibaba.fastjson.JSONArray;
import com.docus.core.util.Func;
import com.docus.server.message.util.TableJsonRead;
import lombok.Data;

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

/**
 * @author wyb
 */
public class ShunDePeopleInterfaceConfig {

    public static List<InterfaceConfig> getTaskConfig() {
        final String configFilePath = "data-config";
        final String configFileName = "sdRy-interface-config.json";
        TableJsonRead tableJsonRead = new TableJsonRead();
        String configJson = tableJsonRead.ReadContent(configFilePath, configFileName);
        return JSONArray.parseArray(configJson, InterfaceConfig.class);
    }

    public static InterfaceConfig getTaskConfig(String key) {
        List<InterfaceConfig> taskConfigs = getTaskConfig();
        if(Func.isNotEmpty(taskConfigs)){
            for (InterfaceConfig taskConfig : taskConfigs) {
                if (key.equals(taskConfig.getKey())) {
                    return taskConfig;
                }
            }
        }
        return null;
    }

    @Data
    public static class InterfaceConfig {
        private String key;
        private String desc;
        private String url;
        private Map<String, String> otherParam;
    }

    public static void main(String[] args) {
        System.out.println(getTaskConfig("HIS_ZY_CYYZ"));
    }

}
