From 47abbfd1e14804bc005bf13e737ace9f65a9cbcf Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期四, 14 八月 2025 16:27:01 +0800
Subject: [PATCH] feat: 接口对接

---
 src/utils/common/common.ts |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/src/utils/common/common.ts b/src/utils/common/common.ts
index b05dfc3..2a52bc0 100644
--- a/src/utils/common/common.ts
+++ b/src/utils/common/common.ts
@@ -106,3 +106,43 @@
 export function filterNumbersFromString(str: string) {
   return str.replace(/\D/g, '');
 }
+
+export function formatRoleName(roleName: string) {
+  let lastUnderscoreIndex = roleName.lastIndexOf('_');
+
+  if (lastUnderscoreIndex !== -1) {
+    roleName = roleName.substring(0, lastUnderscoreIndex);
+  }
+  return roleName;
+}
+
+/**
+ * 鍓旈櫎瀵硅薄涓�间负 ''銆乽ndefined銆乶ull 鐨勯敭锛屾敮鎸佸祵濂楀璞�
+ * @param {Object} obj - 闇�瑕佸鐞嗙殑瀵硅薄
+ * @returns {Object} 澶勭悊鍚庣殑鏂板璞�
+ */
+export function removeEmptyKeys<T extends object>(obj: T) {
+  // 濡傛灉涓嶆槸瀵硅薄鎴栦负null锛岀洿鎺ヨ繑鍥炲師鍊�
+  if (obj === null || typeof obj !== 'object') {
+    return obj;
+  }
+
+  // 澶勭悊鏁扮粍锛堥�掑綊澶勭悊姣忎釜鍏冪礌锛�
+  if (Array.isArray(obj)) {
+    return obj.map((item) => removeEmptyKeys(item));
+  }
+
+  // 澶勭悊瀵硅薄
+  const result = {} as T;
+  for (const key in obj) {
+    if (obj.hasOwnProperty(key)) {
+      //@ts-ignore
+      const value = removeEmptyKeys(obj[key]); // 閫掑綊澶勭悊宓屽瀵硅薄
+      // 鍙繚鐣欓潪绌哄�硷紙鎺掗櫎''銆乽ndefined銆乶ull锛�
+      if (value !== '' && value !== undefined && value !== null) {
+        result[key] = value;
+      }
+    }
+  }
+  return result;
+}

--
Gitblit v1.9.1