package com.cusc.nirvana.user.rnr.fp.common.config;



import com.alibaba.fastjson.JSONObject;
import com.cusc.nirvana.user.rnr.fp.dto.EncryptionKeyDTO;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.Map;

/**
 * @className: SystemConfigMap
 * @description: 密钥配置
 * @author: jk
 * @date: 2022/7/19 14:03
 * @version: 1.0
 **/
@Data
@Configuration
@ConfigurationProperties(prefix = "encryptionkey")
public class EncryptionConfig {

    /** 第三方接口token */
    private  Map<String, String> keymap;

    public EncryptionKeyDTO getKey(String keyCoder){
        EncryptionKeyDTO encryptionKeyDATO = null;
        String json = keymap.get(keyCoder);
        if(StringUtils.isEmpty(json)){
            return new EncryptionKeyDTO();
        }
        encryptionKeyDATO = JSONObject.parseObject(json, EncryptionKeyDTO.class);

        return encryptionKeyDATO;
    }
}
