|
|
@@ -4,11 +4,15 @@ import cn.hutool.core.util.RandomUtil;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.UUID;
|
|
|
|
|
|
public class RandomStr {
|
|
|
private static final List<String> list1 = List.of("07e3138d92454920b975c5a07d8c0e17", "835c9959339f495d921d6555c03aa6dc","057ef6fddb394f7080350bd9237575ba");
|
|
|
private static final List<String> list2 = List.of("weixin.qq.com", "baidu.com", "sina.com", "qq.com", "apple.com.cn", "apple.com", "huawei.com", "mi.com", "jd.com");
|
|
|
private static final String RandomString="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
|
+ private static final String StrRandomAll="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
|
+
|
|
|
+
|
|
|
public static String getRandomStr(String code){
|
|
|
if(Objects.isNull(code)||!list1.contains(code)){
|
|
|
return RandomUtil.randomString(RandomString, 7);
|
|
|
@@ -19,4 +23,28 @@ public class RandomStr {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ public static String generateUniqueId1() {
|
|
|
+ return RandomUtil.randomString(StrRandomAll, 6);
|
|
|
+ // return UUID.randomUUID().toString().substring(0, 6);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static String base62Encode(long value) {
|
|
|
+ final String base62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ while (value > 0) {
|
|
|
+ sb.append(base62.charAt((int)(value % 62)));
|
|
|
+ value /= 62;
|
|
|
+ }
|
|
|
+ while (sb.length() < 6) {
|
|
|
+ sb.insert(0, '0');
|
|
|
+ }
|
|
|
+ return sb.reverse().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String generateUniqueId2() {
|
|
|
+ return base62Encode(System.currentTimeMillis() % 1000000);
|
|
|
+ }
|
|
|
+
|
|
|
}
|