From adee7a71ba7ab1b63cab63381dfe1846437853d6 Mon Sep 17 00:00:00 2001
From: wzp <2040239371@qq.com>
Date: 星期四, 02 三月 2023 17:37:05 +0800
Subject: [PATCH] 增加分销商配置

---
 web/Common/DataConverter.cs |   80 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 80 insertions(+), 0 deletions(-)

diff --git a/web/Common/DataConverter.cs b/web/Common/DataConverter.cs
index 5b9bf15..39c3785 100644
--- a/web/Common/DataConverter.cs
+++ b/web/Common/DataConverter.cs
@@ -1,8 +1,10 @@
 锘縩amespace Common
 {
     using System;
+    using System.Collections.Generic;
     using System.Runtime.InteropServices;
     using System.Text.RegularExpressions;
+    using System.Linq;
 
     public class DataConverter
     {
@@ -196,6 +198,84 @@
             return random;
         }
 
+        //瀛楃涓茶浆鏁扮粍
+        public static object[] stringToArray(string str)
+        {
+            object[] array = str.Split(',');
+            return array;
+        }
+
+        //鏁扮粍杞瓧绗︿覆
+        public static string arrayToString(object[] array)
+        {
+            if (array == null)
+                return "";
+            string str = string.Join(",", array);
+            return str;
+        }
+
+        //鏁扮粍杞崲List锛歴tring[] str ={ "str","string","abc"}杞� List<string>
+        public static List<object> arrayToList(object[] array)
+        {
+            List<object> list = new List<object>(array);
+
+            return list;
+        }
+
+        //List杞崲鏁扮粍锛歀ist<string>杞埌string[]
+        public static object[] listToArray(List<object> list)
+        {
+            object[] array = list.ToArray();
+
+            return array;
+        }
+
+        //瀛楃涓茶浆List
+        public static List<object> stringToList(string str)
+        {
+            if (string.IsNullOrEmpty(str))
+                return null;
+
+            List<object> list = new List<object>();
+            //瀛楃涓茶浆鏁扮粍锛屽啀鏁扮粍鍚堝苟
+            list.AddRange(str.Split(','));
+
+            return list;
+        }
+
+        //鏁扮粍鍘婚噸锛岀Щ闄ゆ暟缁勪腑閲嶅鏁版嵁
+        public static string[] DelRepeatData(string[] array)
+        {
+            return array.GroupBy(p => p).Select(p => p.Key).ToArray();
+        }
+
+        //妫�鏌ユ暟缁勬牸寮忓瓧绗︿覆涓槸鍚﹀寘鍚煇鍏冪礌
+        public static bool checkStrForArrayStr(object str, string arrayStr )
+        {
+            return stringToArray(arrayStr).Contains(str.ToString() );
+        }
+
+        //妫�鏌ユ暟缁勪腑鏄惁鍖呭惈鏌愬厓绱�
+        public static bool checkStrForArray(object str, object[] array)
+        {
+            return array.Contains(str);
+        }
+
+        //鏍规嵁鏁扮粍瀛楃涓茶浆鎹㈠瓧鍏�
+        public Dictionary<string, object> arrayStrToDict(object userId, string arrayStr)
+        {
+            Dictionary<string, object> dictionary = new Dictionary<string, object>();
+            if (string.IsNullOrEmpty(arrayStr))
+                return dictionary;
+
+            List<object> list = DataConverter.stringToList(arrayStr);
+            for (int i = 0; i < list.Count; i++)
+            {
+                dictionary[userId.ToString()] = list[i];
+            }
+            return dictionary;
+        }
+
     }
 
 }

--
Gitblit v1.9.1