package com.bonus.hn.bearing.capacity.backstage;

import org.jasypt.encryption.StringEncryptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootVersion;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.annotation.Resource;

/**
 * 启动类
 *
 * @author 24526
 */
@SpringBootApplication
@MapperScan("com.bonus.hn.bearing.capacity.backstage.*.dao")
@EnableTransactionManagement
@EnableDiscoveryClient
public class SecurityApplication implements CommandLineRunner {
	@Resource
	private StringEncryptor encryptor;
	public static void main(String[] args) {
		System.err.println(SpringBootVersion.getVersion());
		SpringApplication.run(SecurityApplication.class, args);
		System.err.println( "湖南承载力服务启动成功");
	}


	@Override
	public void run(String... args) throws Exception {
		String nacos = encrypt("6379" );
		String mogodb = encrypt("Hnsmz@070redis!" );

//		System.err.println( "nacos原始明文密码加密后的结果为：" + nacos );
//		System.err.println( "mogodb原始明文密码加密后的结果为：" + decrypt("lj1uFztJiKboX3HFBS50Hb/mOmkBG4qOao5ALg5ePI96pAqmlYor/DApxduukyG6") );
	}

	private String encrypt( String originPassord ) {
		return encryptor.encrypt( originPassord );
	}

	private String decrypt( String encryptedPassword ) {
		return encryptor.decrypt( encryptedPassword );
	}
}
