package com.qmth.jkserver.start;

import com.qmth.jkserver.constant.SystemConstant;
import com.qmth.jkserver.service.AuthInfoService;
import com.qmth.jkserver.service.ExamThirdOrgService;
import com.qmth.jkserver.service.SysConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Description: 服务启动时初始化运行，哪个微服务模块需要则拿此模版去用
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/7/3
 */
@Component
public class StartRunning implements CommandLineRunner {
    private final static Logger log = LoggerFactory.getLogger(StartRunning.class);

//    @Resource
//    ExamTaskService examTaskService;

    @Resource
    ExamThirdOrgService examThirdOrgService;

    @Resource
    AuthInfoService authInfoService;

    @Resource
    SysConfigService sysConfigService;


    @Override
    public void run(String... args) throws Exception {
        log.info("服务器启动时执行 start");
//        SystemConstant.initTempFiles();
        sysConfigService.selectAll();
        authInfoService.appInfoInit();
        examThirdOrgService.validAndSave(SystemConstant.THIRD_ORG_CODE_HMJL);
//        examTaskService.updateStatus();
        log.info("服务器启动时执行 end");
    }

//    public static void main(String[] args) {
//        BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
//        //加密所需的salt(盐)
//        textEncryptor.setPassword("H7i9e9BqvZozCvx4VDGBL");
//        //要加密的数据（数据库的用户名或密码）
//        String username = textEncryptor.encrypt("root");
//        String password = textEncryptor.encrypt("123456789");
////        String redisPassword = textEncryptor.encrypt("qmth87863577");
//        System.out.println("username:" + username);
//        System.out.println("password:" + password);
////        System.out.println("redisPassword:" + redisPassword);
//
//        String usernameDecrypt = textEncryptor.decrypt("kphWdjUskPkhDCVbkbYSfYg2HC4uG77i");
//        String passwordDecrypt = textEncryptor.decrypt("tTjorwt5vXerKg6NAjPQa6+bUSXkZkzC");
////        String redisPasswordDecrypt = textEncryptor.decrypt("54A9TS0Lw/36A2wI2sCjbSxR5lhJRlvd");
//        System.out.println("usernameDecrypt:" + usernameDecrypt);
//        System.out.println("passwordDecrypt:" + passwordDecrypt);
////        System.out.println("redisPasswordDecrypt:" + redisPasswordDecrypt);
//    }
}
