|
|
@@ -0,0 +1,48 @@
|
|
|
+package org.jeecg.common.zhutils;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Random;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Author: zwq
|
|
|
+ * @Date: Create in 2021/6/2 9:57
|
|
|
+ * @Description: 免前置机模式请求id随机数生成工具类
|
|
|
+ */
|
|
|
+public class RandomRequest {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 小写字母
|
|
|
+ */
|
|
|
+ private static String[] lowercase = {
|
|
|
+ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
|
|
|
+ "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数字
|
|
|
+ */
|
|
|
+ private static String[] number = {
|
|
|
+ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"};
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 静态随机数
|
|
|
+ */
|
|
|
+ private static Random random = new Random();
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取随机数
|
|
|
+ *
|
|
|
+ * @param num 随机数位数
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String getRandom(int num) {
|
|
|
+ ArrayList<String> temp = new ArrayList<String>();
|
|
|
+ StringBuffer code = new StringBuffer();
|
|
|
+ temp.addAll(Arrays.asList(lowercase));
|
|
|
+ temp.addAll(Arrays.asList(number));
|
|
|
+ for (int i = 0; i < num; i++) {
|
|
|
+ code.append(temp.get(random.nextInt(temp.size())));
|
|
|
+ }
|
|
|
+ return code.toString();
|
|
|
+ }
|
|
|
+}
|