lcl 2 лет назад
Родитель
Сommit
c96485a6f3

+ 4 - 0
Areas/Admin/Controllers/MainServer/CustomQueryController.cs

@@ -60,6 +60,10 @@ namespace MySystem.Areas.Admin.Controllers
 
 
             string condition = " and Status>-1";
+            if(SysUserName != "admin")
+            {
+                condition += " and CONCAT(',', AdminNames,',') like '%," + SysUserName + ",%'";
+            }
 
 
             Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("CustomQuery", Fields, "Id desc", "0", page, limit, condition);

+ 8 - 0
Areas/Admin/Controllers/MainServer/CustomQueryDoController.cs

@@ -43,6 +43,14 @@ namespace MySystem.Areas.Admin.Controllers
             ViewBag.Id = Id.ToString();
             Dictionary<string, string> query = new Dictionary<string, string>();
             CustomQuery item = db.CustomQuery.FirstOrDefault(m => m.Id == Id) ?? new CustomQuery();
+            if(SysUserName != "admin")
+            {
+                string checkString = "," + item.AdminNames + ",";
+                if(!checkString.Contains("," + SysUserName + ","))
+                {
+                    return Content("无权限");
+                }
+            }
             string sql = item.SqlContent;
             MatchCollection mc = Regex.Matches(sql, @"\$\{.*?\}\$");
             foreach(Match m in mc)