feat: init commit

This commit is contained in:
merlin
2025-10-16 16:57:27 +08:00
commit 4f84603d82
57 changed files with 2243 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
package xin.merlin.myblog_server.utils;
import java.util.Random;
public class RandomCode {
private static final Random rand = new Random();
public static String generateID(){
// 生成一个0到999999999的随机数然后格式化为9位数字字符串
return String.format("%09d", rand.nextInt(1000000000));
}
public static String generateCode(){
// 生成一个0到999999的随机数然后格式化为6位数字字符串
return String.format("%06d", rand.nextInt(1000000));
}
}