2022-12-30 10:58:54 +08:00
|
|
|
package com.xaaef.molly;
|
|
|
|
|
|
2023-01-06 18:32:40 +08:00
|
|
|
import cn.hutool.core.io.FileUtil;
|
2023-03-06 16:43:38 +08:00
|
|
|
import cn.hutool.core.lang.tree.Tree;
|
|
|
|
|
import cn.hutool.core.lang.tree.TreeNode;
|
|
|
|
|
import cn.hutool.core.lang.tree.TreeUtil;
|
2023-03-26 01:37:22 +08:00
|
|
|
import cn.hutool.core.net.Ipv4Util;
|
2023-02-06 18:32:22 +08:00
|
|
|
import cn.hutool.core.util.IdUtil;
|
2023-05-16 21:44:15 +08:00
|
|
|
import com.xaaef.molly.auth.jwt.JwtSecurityUtils;
|
2023-03-06 16:43:38 +08:00
|
|
|
import com.xaaef.molly.common.util.JsonUtils;
|
2022-12-30 10:58:54 +08:00
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
|
|
2023-03-26 01:37:22 +08:00
|
|
|
import java.net.*;
|
2023-03-22 16:02:15 +08:00
|
|
|
import java.time.Duration;
|
2022-12-30 10:58:54 +08:00
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.LocalTime;
|
2023-03-26 01:37:22 +08:00
|
|
|
import java.util.*;
|
2023-02-04 17:20:41 +08:00
|
|
|
import java.util.regex.Pattern;
|
2023-03-26 01:37:22 +08:00
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import static com.xaaef.molly.common.util.IpUtils.getLocalIPS;
|
2022-12-30 10:58:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class NoSpringTests {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void test1() {
|
|
|
|
|
boolean after = LocalDateTime.now().isAfter(LocalDateTime.of(LocalDate.of(2023, 12, 28), LocalTime.MAX));
|
|
|
|
|
System.out.println(after);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 18:32:40 +08:00
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void test3() {
|
|
|
|
|
System.out.println(FileUtil.extName("https://images.xaaef.com/base/63b7df8b9e8581f5bff107e2.jpg"));
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-04 17:20:41 +08:00
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void test4() {
|
|
|
|
|
boolean isMatch = Pattern.matches("\\w{4,12}$", "你好啊啊啊dwa541");
|
|
|
|
|
System.out.println(isMatch);
|
|
|
|
|
}
|
2023-03-06 16:43:38 +08:00
|
|
|
|
|
|
|
|
|
2023-02-06 18:32:22 +08:00
|
|
|
@Test
|
|
|
|
|
public void test5() {
|
|
|
|
|
byte[] bytes = IdUtil.getSnowflakeNextIdStr().getBytes();
|
|
|
|
|
System.out.println(new String(bytes));
|
|
|
|
|
System.out.println(bytes.length);
|
|
|
|
|
}
|
2023-02-04 17:20:41 +08:00
|
|
|
|
|
|
|
|
|
2023-03-06 16:43:38 +08:00
|
|
|
@Test
|
|
|
|
|
public void test6() {
|
|
|
|
|
var treeNodes = List.of(
|
|
|
|
|
new TreeNode<>(1001, 10, "部门1", 1),
|
|
|
|
|
new TreeNode<>(1002, 11, "部门2", 3),
|
|
|
|
|
new TreeNode<>(1003, 1002, "部门2", 4),
|
|
|
|
|
new TreeNode<>(1004, 1002, "部门2", 5),
|
|
|
|
|
new TreeNode<>(1005, 1001, "部门2", 6)
|
|
|
|
|
);
|
|
|
|
|
var first = treeNodes.stream().map(TreeNode::getParentId).sorted().findFirst().get();
|
|
|
|
|
List<Tree<Integer>> build = TreeUtil.build(treeNodes, first);
|
|
|
|
|
System.out.println(JsonUtils.toFormatJson(build));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-03-22 16:02:15 +08:00
|
|
|
@Test
|
|
|
|
|
public void test7() {
|
|
|
|
|
var l = Duration.ofMinutes(1).toMillis();
|
|
|
|
|
System.out.println(l);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-03-26 01:37:22 +08:00
|
|
|
@Test
|
|
|
|
|
public void test8() {
|
|
|
|
|
var port = 19222;
|
|
|
|
|
getLocalIPS().stream()
|
|
|
|
|
.map(ip -> String.format("http://%s:%d/doc.html", ip, port))
|
|
|
|
|
.forEach(System.out::println);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-05-16 21:44:15 +08:00
|
|
|
@Test
|
|
|
|
|
public void test9() {
|
|
|
|
|
System.out.println(JwtSecurityUtils.encryptPassword("test123456"));
|
|
|
|
|
System.out.println(JwtSecurityUtils.encryptPassword("test456789"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-12-30 10:58:54 +08:00
|
|
|
}
|