package com.xhkjedu.sexam.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.io.UnsupportedEncodingException;

/**
 * @author ywx
 * @classname ConfigKey
 * @description 读取配置文件类
 * @date 2020/10/16 9:19
 **/
@Component
public class ConfigKey {
    public static String username;
    public static String password;
    public static String url;
    public static String signName;

    @Value("${zt.username}")
    public void setUsername(String username) {
        ConfigKey.username = username;
    }

    @Value("${zt.password}")
    public void setPassword(String password) {
        ConfigKey.password = password;
    }

    @Value("${zt.url}")
    public void setUrl(String url) {
        ConfigKey.url = url;
    }

    @Value("${signName}")
    private void setSignName(String signName) throws UnsupportedEncodingException {
        //Spring Boot注解读取application.properties或者application-{profile}.properties文件时默认的是ISO_8859_1编码,中文会乱码
        ConfigKey.signName = new String(signName.getBytes("ISO_8859_1"),"UTF-8");
    }
}
