From 790c2ba4a0b46edf191e3bac84931f796bd42b8f Mon Sep 17 00:00:00 2001
From: zhangf <1603559716@qq.com>
Date: 星期三, 24 七月 2024 09:02:49 +0800
Subject: [PATCH] 三方对接接口优化

---
 ruoyi-common/src/main/java/com/ruoyi/common/utils/RandomUtil.java |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/RandomUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/RandomUtil.java
new file mode 100644
index 0000000..1ef77b8
--- /dev/null
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/RandomUtil.java
@@ -0,0 +1,40 @@
+package com.ruoyi.common.utils;
+
+
+import java.util.Random;
+
+public class RandomUtil {
+    /**
+     * 字符串池
+     */
+    private static String[] STR_ARR = new String[] { "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", "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", "1", "2", "3", "4", "5",
+            "6", "7", "8", "9", "0" };
+
+    /**
+     *
+     * 根据指定的长度生成的含有大小写字母及数字的字符串
+     *
+     * @param length
+     *            指定的长度
+     * @return 按照指定的长度生成的含有大小写字母及数字的字符串
+     */
+    public static String generateRandomString(int length) {
+        StringBuilder sb = new StringBuilder();
+        Random rand = new Random();
+        for (int i = 0; i < length; i++) {
+            sb.append(STR_ARR[rand.nextInt(STR_ARR.length)]);
+        }
+        return sb.toString();
+    }
+
+    public static void main(String[] args) {
+        String s = generateRandomString(26);
+        System.out.println(s);
+
+    }
+
+}

--
Gitblit v1.9.2