PropertiesConfiguration.java 3.29 KB
package com.viontech.configuration;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.InputStream;
import java.util.Properties;

/**
 * .
 *
 * @author 谢明辉
 * @date 2020/8/31
 */
@Configuration
@Slf4j
public class PropertiesConfiguration {

    public static String username;
    public static String password;

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

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

    @Bean(name = "directionProp")
    public Properties directionProp() {
        Properties properties = new Properties();
        try (InputStream inputStream = PropertiesConfiguration.class.getResourceAsStream("/fxlb.properties")) {
            properties.load(inputStream);
        } catch (Exception e) {
            log.error("读取 fxlb.properties 失败", e);
        }
        return properties;
    }

    @Bean(name = "manufactureLogoProp")
    public Properties manufactureLogoProp() {
        Properties properties = new Properties();
        try (InputStream inputStream = PropertiesConfiguration.class.getResourceAsStream("/clpp.properties")) {
            properties.load(inputStream);
        } catch (Exception e) {
            log.error("读取 clpp.properties 失败", e);
        }
        return properties;
    }

    @Bean(name = "vehicleColorProp")
    public Properties vehicleColorProp() {
        Properties properties = new Properties();
        try (InputStream inputStream = PropertiesConfiguration.class.getResourceAsStream("/csys.properties")) {
            properties.load(inputStream);
        } catch (Exception e) {
            log.error("读取 csys.properties 失败", e);
        }
        return properties;
    }

    @Bean(name = "illegalTypeProp")
    public Properties illegalTypeProp() {
        Properties properties = new Properties();
        try (InputStream inputStream = PropertiesConfiguration.class.getResourceAsStream("/wzlx.properties")) {
            properties.load(inputStream);
        } catch (Exception e) {
            log.error("读取 wzlx.properties 失败", e);
        }
        return properties;
    }

    @Bean(name = "eventProp")
    public Properties behaviorProp() {
        Properties properties = new Properties();
        try (InputStream inputStream = PropertiesConfiguration.class.getResourceAsStream("/sjlx.properties")) {
            properties.load(inputStream);
        } catch (Exception e) {
            log.error("读取 sjlx.properties 失败", e);
        }
        return properties;
    }

    /**
     * 车牌类型
     * 博康的车牌类型指文安的号牌颜色
     * @return
     */
    @Bean(name = "plateTypeProp")
    public Properties plateTypeProp() {
        Properties properties = new Properties();
        try (InputStream inputStream = PropertiesConfiguration.class.getResourceAsStream("/hpys.properties")) {
            properties.load(inputStream);
        } catch (Exception e) {
            log.error("读取 hpys.properties 失败", e);
        }
        return properties;
    }


}