package cn.superdesk.uniorder.common.mq.redis.constants;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description: 开始扩展了
 * @Author: linjinyu
 * @CreateDate: 2021/8/27 上午11:49
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021/8/27 上午11:49
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public enum RedisKeyPrefix {

	TOKEN_CACHE("token_cache", "TOKEN缓存"),
	DICTIONARY_CACHE("dictionary_cache", "字典缓存"),

	PERMISSION_OPEN_API_CACHE("PERMISSION_OPEN_API_CACHE", "PERMISSION_OPEN_API_CACHE"),


	关联性校验_前缀("relation", "关联性校验_前缀"),

	//	key = table + field
	关联性校验_销方主体("invoice_bank_info", "关联性校验_销方主体"),
	关联性校验_销方主体_发票抬头("invoice_bank_info:company_name", "关联性校验_销方主体_发票抬头"),

	关联性校验_购方主体("sys_enterprise_ext_invoice", "关联性校验_购方主体"),
	关联性校验_购方主体_发票抬头("sys_enterprise_ext_invoice:company_name", "关联性校验_购方主体_发票抬头"),
	关联性校验_购方主体_纳税人识别码("sys_enterprise_ext_invoice:taxpayers_i_d_code", "关联性校验_购方主体_纳税人识别码"),

	关联性校验_发票种类("invoice_type", "关联性校验_发票种类"),
	关联性校验_发票种类_种类名称("invoice_type:type_name", "关联性校验_发票种类_种类名称"),
	关联性校验_发票种类_种类ID("invoice_type:id", "关联性校验_发票种类_种类ID"),

	;

	private String key;
	private String desc;

	private RedisKeyPrefix(String key, String desc) {
		this.key = key;
		this.desc = desc;
	}

	public String getKey() {
		return key;
	}

	public String getDesc() {
		return desc;
	}


	public static String getDesc(String key) {
		for (RedisKeyPrefix c : RedisKeyPrefix.values()) {
			if (c.key.equals(key)) {
				return c.getDesc();
			}
		}
		return "未知";
	}

	private static final Map<String, RedisKeyPrefix> LOOKUP = new HashMap<>();

	static {
		for (RedisKeyPrefix s : EnumSet.allOf(RedisKeyPrefix.class)) {
			LOOKUP.put(s.getKey(), s);
		}
	}

	public static RedisKeyPrefix get(String key) {
		return LOOKUP.get(key);
	}

}
