package com.qmth.sop.server.start;

import com.qmth.sop.business.activiti.service.ActivitiService;
import com.qmth.sop.business.service.SysConfigService;
import com.qmth.sop.business.service.TSAuthService;
import com.qmth.sop.common.enums.TFCustomTypeEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * @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
    SysConfigService sysConfigService;

    @Resource
    ActivitiService activitiService;

    @Resource
    TSAuthService tsAuthService;

    @Override
    public void run(String... args) throws Exception {
        log.info("服务器启动时执行 start");
        sysConfigService.selectAll();
        activitiService.createDeployment(Arrays.asList(TFCustomTypeEnum.OFFICE_SOP_FLOW, TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW, TFCustomTypeEnum.DING_EXCEPTION_FLOW, TFCustomTypeEnum.PROJECT_EXCHANGE_FLOW, TFCustomTypeEnum.QUALITY_PROBLEM_FLOW));
        tsAuthService.appInfoInit();
        log.info("服务器启动时执行 end");
    }

//    public static void main(String[] args) {
//        BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
//        //加密所需的salt(盐)
//        textEncryptor.setPassword("IeHbJicLySV08XWixOFjk");
//        //要加密的数据（数据库的用户名或密码）
//        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("vfaatAlDIcsdgGug2iATvQ==");
//        String passwordDecrypt = textEncryptor.decrypt("BfDtvzvWkywnFGKnxelLAMVaxyFl+Sle");
////        String redisPasswordDecrypt = textEncryptor.decrypt("54A9TS0Lw/36A2wI2sCjbSxR5lhJRlvd");
//        System.out.println("usernameDecrypt:" + usernameDecrypt);
//        System.out.println("passwordDecrypt:" + passwordDecrypt);
////        System.out.println("redisPasswordDecrypt:" + redisPasswordDecrypt);
//    }
}
