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");
    }

    //socket地址
    public static String examscoket;
    //图像失败识别地址
    public static String examface;

    @Value("${exam.socket}")
    public void setExamsocket(String examscoket) {
        ConfigKey.examscoket = examscoket;
    }

    @Value("${exam.face}")
    public void setExamface(String examface) {
        ConfigKey.examface = examface;
    }

    //考试结束时间范围
    public static Integer endtime;

    @Value("${exam.endtime}")
    public void setEndtime(Integer endtime) {
        ConfigKey.endtime = endtime;
    }

    public static Integer buildnum;//构建号

    @Value("${buildnum}")
    public void setBuildnum(Integer buildnum){
        this.buildnum = buildnum;
    }

    public static String ipregiondb;//解析ip地址归属地

    @Value("${ipregiondb}")
    public void setIpregiondb(String ipregiondb){
        ConfigKey.ipregiondb = ipregiondb;
    }

    public static boolean examHaspdf;//考试是否生产pdf报告

    @Value("${exam.haspdf}")
    public void setExamHaspdf(boolean examHaspdf){
        ConfigKey.examHaspdf = examHaspdf;
    }

}
