package com.hzg.tools;

import org.springframework.stereotype.Component;

import java.util.Random;

@Component
public class StrUtil {
    public String generateRandomStr(int strLength) {
        String randomStr = null;

        if (strLength > 0) {
            randomStr = "";
        }

        Random random = new Random();
        char [] str="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
        for ( int i = 0 ; i < strLength ; i++) {
            randomStr += String.valueOf(str[random.nextInt(62)]);
        }

        return randomStr;
    }
}

@@ -136,52 +136,584 @@
    p
-ublic String generateRandomStr(int strLength
+rivate char%5B%5D chars = %220123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%22.toCharArray();%0A    private char%5B%5D numbers = %220123456789%22.toCharArray();%0A%0A%0A    public String generateRandomStr(int strLength) %7B%0A        return generateStr(strLength, chars);%0A    %7D%0A%0A    public String generateDateRandomStr(int strLength) %7B%0A        return System.currentTimeMillis() + generateRandomStr(strLength);%0A    %7D%0A%0A    public String generateRandomNumberStr(int strLength) %7B%0A        return generateStr(strLength, numbers);%0A    %7D%0A%0A    public String generateStr(int strLength, char%5B%5D chars
 ) %7B%0A
@@ -856,107 +856,8 @@
 ();%0A
-        char %5B%5D str=%220123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%22.toCharArray();
 %0A   
@@ -942,19 +942,21 @@
 valueOf(
-str
+chars
 %5Brandom.
@@ -967,10 +967,20 @@
 Int(
-62
+chars.length
 )%5D);

add date perfix to random string