From f63d8ead25bdb3c32dacca817a059bd30390e9bc Mon Sep 17 00:00:00 2001 From: yzh <snbbt@21cn.com> Date: 星期三, 15 六月 2022 22:20:07 +0800 Subject: [PATCH] 1.系统账户数据库优化: 修改“账户类型”的数据类型为VARCHAR2(1024),多个角色时以半角“,”分隔。 加密盐。 密码加密优化;账户登录优化;角色权限管理(作废用户权限); 2.字典类型管理(定义:用户角色) 3.字典数据管理(初始化用户角色数据) 3.角色权限管理 4.系统账户管理,账户类型对应用户角色(可多选)。 --- web/Common/DataConverter.cs | 98 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 98 insertions(+), 0 deletions(-) diff --git a/web/Common/DataConverter.cs b/web/Common/DataConverter.cs index 421765e..652c45d 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 { @@ -179,6 +181,102 @@ [FieldOffset(0)] public DataConverter.IPAdress _IP; } + + //鑾峰彇闅忔満鐮� + public static string getRandom(int strLength) + { + string random = ""; + if (strLength <= 0) + { + strLength = 6; //榛樿6浣嶉暱搴� + } + //random = Guid.NewGuid().ToString().Replace("-", "").Substring(0, strLength); + random = Guid.NewGuid().ToString(); + random = random.Replace("-", ""); + random = random.Substring(0, strLength); + + 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); + } + + //妫�鏌ユ暟缁勪腑鏄惁鍖呭惈鏌愬厓绱� + 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