whycxzp
2022-03-07 286105f4a3bd88c6bf3bf4304fe46d1c1605e233
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.whyc;
 
import com.whyc.dto.Response;
import com.whyc.service.PasswordResetService;
import com.whyc.util.SpringUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ApplicationContext;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
 
import java.util.Scanner;
 
import static java.lang.Thread.enumerate;
import static java.lang.Thread.sleep;
 
/**
 * @Description : 启动类
 * @date 2020/10/15
 **/
@SpringBootApplication
@EnableWebMvc
@ServletComponentScan(basePackages = {"com.whyc.filter","com.whyc.servlet"})
@EnableCaching
public class Application extends WebMvcConfigurerAdapter  implements WebMvcConfigurer {
 
    public static void main(String[] args) {
        SpringApplication.run(Application.class,args);
        ApplicationContext applicationContext = SpringUtil.getApplicationContext();
        PasswordResetService service = (PasswordResetService) applicationContext.getBean("passwordResetService");
        //密码格式预读及手动确认
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用做校验的用户名:");
        String name = sc.nextLine();
        Response response = service.preCheck(name);
        System.out.println("当前密码模式为:"+response.getMsg()+",密码为"+response.getData());
        System.out.println("核查正确请输入y,不正确请输入n");
        String flag = sc.nextLine();
        if(!flag.toUpperCase().equals("Y")){
            System.out.println("密码解析失败,终止程序");
            System.exit(1);
        }
        //进行密码修改
        service.passwordReset();
 
        //密码格式重置
        service.passwordReset();
        int sleepSeconds = 3;
        System.out.println("密码体系升级操作完成,"+sleepSeconds+"秒后自动退出程序...");
        try {
            sleep(sleepSeconds*1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("程序终止");
        System.exit(1);
    }
 
}