DuGuYang 3 gadi atpakaļ
vecāks
revīzija
99ad873d82

+ 30 - 0
AppStart/DictionaryClass/DictionaryClass.cs

@@ -350,6 +350,36 @@ namespace MySystem
 
         #endregion
 
+        #region 新后台管理员角色字典
+
+        public Dictionary<string, string> getSysAdminRoleNewDic()
+        {
+            List<BsModels.SysAdminRoleNew> SysAdminRoleList = bsdb.SysAdminRoleNew.ToList();
+            Dictionary<string, string> SysAdminRoleDic = new Dictionary<string, string>();
+            foreach (BsModels.SysAdminRoleNew subSysAdminRole in SysAdminRoleList)
+            {
+                SysAdminRoleDic.Add(subSysAdminRole.Id.ToString(), subSysAdminRole.Name.ToString());
+            }
+            return SysAdminRoleDic;
+        }
+
+        #endregion
+
+        #region 新后台管理员字典
+
+        public Dictionary<string, string> getSysAdminNewDic()
+        {
+            List<BsModels.SysAdminNew> SysAdminList = bsdb.SysAdminNew.ToList();
+            Dictionary<string, string> SysAdminDic = new Dictionary<string, string>();
+            foreach (BsModels.SysAdminNew subSysAdmin in SysAdminList)
+            {
+                SysAdminDic.Add(subSysAdmin.Id.ToString(), subSysAdmin.AdminName.ToString());
+            }
+            return SysAdminDic;
+        }
+
+        #endregion
+
         #region SmallStoreHouse字典
 
         public Dictionary<string, string> getSmallStoreHouseDic()

+ 91 - 0
AppStart/PublicFunction.cs

@@ -109,6 +109,97 @@ namespace MySystem
             result = result.TrimEnd(',');
             return result;
         }
+
+        public string GetRightJsonNew()
+        {
+            string result = "[";
+            List<BsModels.RightDicNew> list = bsdb.RightDicNew.ToList();
+            List<BsModels.RightDicNew> Level1 = list.Where(m => m.RightLevel == 1).ToList();
+            foreach (BsModels.RightDicNew sub1 in Level1)
+            {
+                result += "{title: '" + sub1.Name + "', id: '" + sub1.Id + "', spread: false, children: [";
+                List<BsModels.RightDicNew> Level2 = list.Where(m => m.RightLevel == 2 && m.Id.StartsWith(sub1.Id)).ToList();
+                if (Level2.Count > 0)
+                {
+                    foreach (BsModels.RightDicNew sub2 in Level2)
+                    {
+                        result += "{title: '" + sub2.Name + "', id: '" + sub2.Id + "', spread: false, children: [";
+                        List<BsModels.RightDicNew> Level3 = list.Where(m => m.RightLevel == 3 && m.Id.StartsWith(sub2.Id)).ToList();
+                        if (Level3.Count > 0)
+                        {
+                            foreach (BsModels.RightDicNew sub3 in Level3)
+                            {
+                                result += "{title: '" + sub3.Name + "', id: '" + sub3.Id + "', spread: false, children: [";
+                                string rightString = ForOperateRight(sub3.Id);
+                                if (!string.IsNullOrEmpty(rightString))
+                                {
+                                    result += rightString;
+                                }
+                                else
+                                { 
+                                    result += "{title: '基本权限', id: '" + sub3.Id + "_base'}";
+                                }
+                                result += "]},";
+                            }
+                            result = result.TrimEnd(',');
+                        }
+                        else
+                        {
+                            string rightString = ForOperateRightNew(sub2.Id);
+                            if (!string.IsNullOrEmpty(rightString))
+                            {
+                                result += rightString;
+                            }
+                            else
+                            {
+                                result += "{title: '基本权限', id: '" + sub2.Id + "_base'}";
+                            }
+                        }
+                        result += "]},";
+                    }
+                    result = result.TrimEnd(',');
+                }
+                else
+                {
+                    result += ForOperateRightNew(sub1.Id);
+                    string rightString = ForOperateRightNew(sub1.Id);
+                    if (!string.IsNullOrEmpty(rightString))
+                    {
+                        result += rightString;
+                    }
+                    else
+                    {
+                        result += "{title: '基本权限', id: '" + sub1.Id + "_base'}";
+                    }
+                }
+                result += "]},";
+            }
+            result = result.TrimEnd(',');
+            result += "]";
+            return result;
+        }
+        //读取当前菜单有哪些权限
+        public string ForOperateRightNew(string Id)
+        {
+            string result = "";
+            List<BsModels.MenuRightNew> rights = bsdb.MenuRightNew.Where(m => m.MenuId.StartsWith(Id)).OrderBy(m => m.MenuId).ToList();
+            foreach (BsModels.MenuRightNew right in rights)
+            {
+                result += "{title: '" + right.Name + "', id: '" + right.MenuId + "'},";
+            }
+            BsModels.RightDicNew rightDic = bsdb.RightDicNew.FirstOrDefault(m => m.Id == Id) ?? new BsModels.RightDicNew();
+            if (!string.IsNullOrEmpty(rightDic.OtherRight))
+            {
+                string[] OtherRightList = rightDic.OtherRight.Split('\n');
+                foreach (string SubOtherRight in OtherRightList)
+                {
+                    string[] SubOtherRightData = SubOtherRight.Split('_');
+                    result += "{title: '" + SubOtherRightData[1] + "', id: '" + Id + "_" + SubOtherRightData[0] + "'},";
+                }
+            }
+            result = result.TrimEnd(',');
+            return result;
+        }
         public string TranslateRightString(string RightString)
         {
             string result = "";

+ 1 - 1
Areas/Admin/Views/BsServer/SysAdminNew/Add.cshtml

@@ -52,7 +52,7 @@
                                 </div>
                             </div>
                             @{
-                                Dictionary<string, string> SysAdminRoleDic = new MySystem.DictionaryClass().getSysAdminRoleDic();
+                                Dictionary<string, string> SysAdminRoleDic = new MySystem.DictionaryClass().getSysAdminRoleNewDic();
                             }
                             <div class="layui-form-item">
                                 <label class="layui-form-label">角色</label>

+ 1 - 1
Areas/Admin/Views/BsServer/SysAdminNew/Edit.cshtml

@@ -53,7 +53,7 @@
                                     placeholder="请输入名称">
                             </div>
                         </div>
-                        @{Dictionary<string, string> SysAdminRoleDic = new MySystem.DictionaryClass().getSysAdminRoleDic();}
+                        @{Dictionary<string, string> SysAdminRoleDic = new MySystem.DictionaryClass().getSysAdminRoleNewDic();}
                         <div class="layui-form-item">
                             <label class="layui-form-label">角色</label>
                             <div class="layui-input-inline">

+ 1 - 1
Areas/Admin/Views/BsServer/SysAdminRoleNew/Add.cshtml

@@ -220,7 +220,7 @@
 
 
             //TreeView,比如权限管理
-            var RightInfoData = @(Html.Raw(new MySystem.PublicFunction().GetRightJson()));
+            var RightInfoData = @(Html.Raw(new MySystem.PublicFunction().GetRightJsonNew()));
             tree.render({
                 elem: '#RightInfoTree'
                 , data: RightInfoData

+ 2 - 2
Areas/Admin/Views/BsServer/SysAdminRoleNew/Edit.cshtml

@@ -1,6 +1,6 @@
 @using MySystem.BsModels;
 @{
-    SysAdminRole editData = ViewBag.data as SysAdminRole;
+    SysAdminRoleNew editData = ViewBag.data as SysAdminRoleNew;
 }
 @{
     string RightInfo = ViewBag.RightInfo as string;
@@ -224,7 +224,7 @@
 
 
             //TreeView,比如权限管理
-            var RightInfoData = @(Html.Raw(new MySystem.PublicFunction().GetRightJson()));
+            var RightInfoData = @(Html.Raw(new MySystem.PublicFunction().GetRightJsonNew()));
             tree.render({
                 elem: '#RightInfoTree'
                 , data: RightInfoData