From 9486766c806fe1d9e082b2fd02ea1cc558f1b443 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期四, 08 五月 2025 09:21:57 +0800
Subject: [PATCH] bug修改

---
 cloud-server-management/src/main/java/com/dsh/course/util/StringUtil.java |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/cloud-server-management/src/main/java/com/dsh/course/util/StringUtil.java b/cloud-server-management/src/main/java/com/dsh/course/util/StringUtil.java
new file mode 100644
index 0000000..1b4b56e
--- /dev/null
+++ b/cloud-server-management/src/main/java/com/dsh/course/util/StringUtil.java
@@ -0,0 +1,36 @@
+package com.dsh.course.util;
+
+import cn.mb.cloud.common.core.exception.BusinessException;
+import org.springframework.util.StringUtils;
+
+import java.util.Objects;
+
+/**
+ * 判断字符串不能为空和null,以及号码格式效验,
+ * 否则则抛出异常信息
+ */
+public class StringUtil {
+    private StringUtil() {
+    }
+
+    public static void checkNull(String str, String message) throws BusinessException {
+        if (!StringUtils.hasLength(str)) {
+            throw new BusinessException(message);
+        }
+    }
+
+    public static void checkFormat(String str, String message) throws BusinessException {
+        if (!str.matches("^1[2|3|4|5|6|7|8|9][0-9]{9}$")) {
+            throw new BusinessException(message);
+        }
+    }
+
+    public static boolean isOneEmpty(Object... os) {
+        for (Object o : os) {
+            if (Objects.isNull(o)) {
+                return true;
+            }
+        }
+        return false;
+    }
+}

--
Gitblit v1.7.1