危化品全生命周期管理后端
kongzy
2024-09-14 ed36af4d4cc5feac72a384d85f9032fc6dc1223a
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package com.gkhy.hazmat.admin;
 
import cn.hutool.core.codec.Base64;
import com.alibaba.fastjson2.JSONObject;
import com.gkhy.hazmat.common.utils.SecurityUtils;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Random;
 
@RunWith(SpringRunner.class)
@SpringBootTest(classes = GkhyAdminApplication.class)
@ActiveProfiles("dev")
@Slf4j
public class PasswordTest {
 
    @Test
    public void passwordGenerate(){
        String password="Gkhy@c413";
        String enpass= SecurityUtils.encryptPassword(password);
        System.out.println(enpass);
        System.out.println(Base64.encode(password));
 
//        System.out.println(SecurityUtils.encryptPassword(password));
//
//        String pp="R2toeUBjNDEz";
//        System.out.println(SecurityUtils.encryptPassword(Base64.decodeStr(pp)));
    }
 
    @Test
    public void testRand(){
        Random random=new Random();
        for(int i=0;i<10;i++) {
            System.out.println(random.nextInt(20));
        }
    }
 
    @Test
    public void testJSon(){
        String a="{\"a\":123}";
        JSONObject jsonObject = JSONObject.parseObject(a);
        System.out.println(a);
    }
 
    @Test
    public void testData(){
        System.out.println(testB());
 
    }
 
    public List<String> testB(){
        List<String> b=new ArrayList<>();
        List<String>aa=new ArrayList<>();
        b.add("a");
        b.add("b");
 
        aa.addAll(b);
 
        b.add("c");
        return aa;
    }
 
    @Test
    public void testNum(){
        Integer a=null;
        int b=0;
        if(Optional.ofNullable(a).orElse(0)>b){
            System.out.println("gggggg");
        }else{
            System.out.println("hhhhhh");
        }
    }
 
 
    @Test
    public void testList(){
        List<Integer> tmpList=new ArrayList<>();
        tmpList.add(1);
        tmpList.add(2);
        tmpList.add(3);
        tmpList.add(4);
        tmpList.add(5);
        tmpList.add(6);
        tmpList.add(7);
        tmpList.add(8);
        tmpList.add(9);
        Integer pageSize=3;
        while(true){
            List<Integer> subLIst=tmpList.subList(0,tmpList.size()>pageSize?pageSize:tmpList.size());
            System.out.println("subSize="+subLIst.size());
            if(subLIst.size()<pageSize){
                break;
            }
            tmpList=tmpList.subList(pageSize,tmpList.size());
            System.out.println("size="+tmpList.size());
 
        }
    }
}