From f6fe09539d37e44b199d6c1d09798088209d6d72 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期三, 24 七月 2024 19:34:02 +0800
Subject: [PATCH] 玩湃门店数据权限修改 收入管理增加世界杯记录
---
cloud-server-competition/src/main/java/com/dsh/competition/util/StrUtils.java | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 105 insertions(+), 0 deletions(-)
diff --git a/cloud-server-competition/src/main/java/com/dsh/competition/util/StrUtils.java b/cloud-server-competition/src/main/java/com/dsh/competition/util/StrUtils.java
new file mode 100644
index 0000000..f81b296
--- /dev/null
+++ b/cloud-server-competition/src/main/java/com/dsh/competition/util/StrUtils.java
@@ -0,0 +1,105 @@
+package com.dsh.competition.util;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+
+public class StrUtils {
+ /**
+ * 把逗号分隔的字符串转换字符串数组
+ * Convert comma-separated string to string array.
+ *
+ * @param str
+ * @return
+ */
+ public static String[] splitStr2StrArr(String str, String split) {
+ if (str != null && !str.equals("")) {
+ return str.split(split);
+ }
+ return null;
+ }
+
+
+ /**
+ * 把逗号分隔字符串转换List的Long
+ *
+ * @param str
+ * @return
+ */
+ public static List<Long> splitStr2LongArr(String str) {
+ String[] strings = splitStr2StrArr(str, ",");
+ if (strings == null) return null;
+
+ List<Long> result = new ArrayList<>();
+ for (String string : strings) {
+ result.add(Long.parseLong(string));
+ }
+
+ return result;
+ }
+
+ /**
+ * 把逗号分隔字符串转换List的Long
+ *
+ * @param str
+ * @return
+ */
+ public static List<Long> splitStr2LongArr(String str, String split) {
+ String[] strings = splitStr2StrArr(str, split);
+ if (strings == null) return null;
+
+ List<Long> result = new ArrayList<>();
+ for (String string : strings) {
+ result.add(Long.parseLong(string));
+ }
+
+ return result;
+ }
+
+ public static String getRandomString(int length) {
+ String str = "0123456789";
+ Random random = new Random();
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < length; i++) {
+ int number = random.nextInt(10);
+ sb.append(str.charAt(number));
+ }
+ return sb.toString();
+
+ }
+
+ public static String getComplexRandomString(int length) {
+ String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+ Random random = new Random();
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < length; i++) {
+ int number = random.nextInt(62);
+ sb.append(str.charAt(number));
+ }
+ return sb.toString();
+ }
+
+ public static String getClassCodeString(int length) {
+ String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+ Random random = new Random();
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < length; i++) {
+ int number = random.nextInt(36);
+ sb.append(str.charAt(number));
+ }
+ return sb.toString();
+ }
+
+ public static String convertPropertiesToHtml(String properties) {
+ //1:容量:6:32GB_4:样式:12:塑料壳
+ StringBuilder sBuilder = new StringBuilder();
+ String[] propArr = properties.split("_");
+ for (String props : propArr) {
+ String[] valueArr = props.split(":");
+ sBuilder.append(valueArr[1]).append(":").append(valueArr[3]).append("<br>");
+ }
+ return sBuilder.toString();
+ }
+
+}
--
Gitblit v1.7.1