package com.friday.custody.utils;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;

import java.util.Map;
import java.util.Objects;

@Slf4j
public class MatchDataDictionaryKeyUtil {

    public static String getKey(Map<String, String> dicMap, String resurceValue) {
//        log.info("the dicMap is :{}", JSON.toJSONString(dicMap));
//        log.info("the originValue is :{}", resurceValue);
        if (!Objects.isNull(dicMap) && StringUtils.isNotBlank(resurceValue)) {
            String key = dicMap.get(resurceValue);
            if (StringUtils.isNotBlank(key)) {
                return key;
            }
        }
        //todo 没匹配上  之后需要往匹配错误的日记记录表中加一条数据
        return null;
    }

    /**
     * 这个方法用于证件类型的查询、开放类型的查询
     *
     * @param custKey
     * @param dicMap
     * @param resurceValue
     * @return
     */
    public static String getKey(String custKey, Map<String, Map<String, String>> dicMap, String resurceValue) {
//        log.info("the custKey is :{}", custKey);
//        log.info("the dicMap is :{}", JSON.toJSONString(dicMap));
//        log.info("the resurceValue is :{}", resurceValue);
        if (!Objects.isNull(dicMap)) {
            Map<String, String> originValKeyDic = dicMap.get(custKey);
            if (!Objects.isNull(originValKeyDic)) {
                String key = originValKeyDic.get(resurceValue);
                if (StringUtils.isNotBlank(key)) {
                    return key;
                }
            }
        }
        //todo 没匹配上  之后需要往匹配错误的日记记录表中加一条数据
        return null;
    }

}
