package com.foreverwin.mesnac.console.initMethod;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;


/**
 * APP启动时自动执行
 * Created by Administrator on 2018/1/15.
 */
@Component
@Order(value = 1)
public class ApplicationRunnerInitial implements ApplicationRunner {

    private static Logger logger = LoggerFactory.getLogger(ApplicationRunnerInitial.class);
    @Value("${ws.erp.server}")
    private String erpServer;
    @Value("${ws.erp.port}")
    private String erpServerPort;
    @Value("${ws.erp.user}")
    private String erpUser;
    @Value("${ws.erp.pwd}")
    private String erpPwd;
    @Value("${ws.erp.valid}")
    private String valid;

    @Override
    public void run(ApplicationArguments applicationArguments) {

        System.setProperty("ws.erp.server", erpServer);
        System.setProperty("ws.erp.port", erpServerPort);
        System.setProperty("ws.erp.username", erpUser);
        System.setProperty("ws.erp.password", erpPwd);
        System.setProperty("ws.erp.valid", valid);

        logger.info(System.getProperty("ws.erp.server"));
        logger.info(System.getProperty("ws.erp.port"));
        logger.info(System.getProperty("ws.erp.username"));
        logger.info(System.getProperty("ws.erp.password"));
        logger.info(System.getProperty("ws.erp.valid"));
    }

}
