package com.xhkjedu.suser.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");;
    }

    public static Integer redisdatatime;//缓存访问数据有效时长
    public static Integer ercodredistime;//二维码登录保存时长60
    public static String secretKey;//secretKey必须为24位

    @Value("${redisdatatime}")
    public void setRedisdatatime(Integer redisdatatime) {
        ConfigKey.redisdatatime = redisdatatime;
    }
    @Value("${ercode.redistime}")
    public void setErcodredistime(Integer ercodredistime) {
        ConfigKey.ercodredistime = ercodredistime;
    }

    @Value("${secretKey}")
    public void setSecretKey(String secretKey) {
        ConfigKey.secretKey = secretKey;
    }

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

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

    public static String cloudapi;//云平台接口地址
    public static boolean cloudsynclogin;//是否同步登录到云平台
    @Value("${cloudapi}")
    public void setCloudapi(String cloudapi){
        ConfigKey.cloudapi = cloudapi;
    }
    @Value("${cloudsynclogin}")
    public void setCloudsynclogin(boolean cloudsynclogin){
        ConfigKey.cloudsynclogin = cloudsynclogin;
    }

    public static Integer buildnum;//构建号

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

    public static Integer redisumtime;//缓存用户权限模块有效时长

    @Value("${redisumtime}")
    public void setRedisumtime(Integer redisumtime){
        this.redisumtime = redisumtime;
    }

    public static Integer loginerrornum;//连续登录出错次数限制

    @Value("${loginerrornum}")
    public void setLoginerrornum(Integer loginerrornum){
        this.loginerrornum = loginerrornum;
    }
}
