From 7ecddd6698e2eb91eff3c0eea67fa1636011a8aa Mon Sep 17 00:00:00 2001 From: cjy Date: Fri, 13 Sep 2024 17:24:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=BD=93=E5=89=8D=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=9A=84=E5=8F=AF=E8=A7=86=E6=9D=83=E9=99=90=E8=8C=83?= =?UTF-8?q?=E5=9B=B4=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DS.WMS.Core/Sys/Method/CommonService.cs | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/ds-wms-service/DS.WMS.Core/Sys/Method/CommonService.cs b/ds-wms-service/DS.WMS.Core/Sys/Method/CommonService.cs index aee297a0..6aeeee64 100644 --- a/ds-wms-service/DS.WMS.Core/Sys/Method/CommonService.cs +++ b/ds-wms-service/DS.WMS.Core/Sys/Method/CommonService.cs @@ -1447,7 +1447,7 @@ public class CommonService : ICommonService var userInfo = db.Queryable().First(x => x.Id == long.Parse(user.UserId)); if (userInfo.UserType == 0) { - return db.Queryable(); //超级管理员特权 + return tenantDb.Queryable(); //超级管理员特权 } var moduleName = typeof(T).Name.ToLower(); @@ -1461,18 +1461,18 @@ public class CommonService : ICommonService if ((long)rule.VisibleTemplateId == 0) { - return db.Queryable(); + return tenantDb.Queryable(); } var ruleInfo = tenantDb.Queryable().First(x => x.Id == (long)rule.VisibleTemplateId); if (ruleInfo.DataRules.IsNull()) { - return db.Queryable(); + return tenantDb.Queryable(); } if (ruleInfo.RuleScope == "all") { - return db.Queryable().ClearFilter(); + return tenantDb.Queryable().ClearFilter(); } if (ruleInfo.RuleScope == "none") { @@ -1488,18 +1488,30 @@ public class CommonService : ICommonService } if (ruleInfo.RuleScope == "self_dept") { + if (String.IsNullOrEmpty(userInfo.DeptName)) + { + SqlSugar.Check.ExceptionEasy("NO Operation", "当前员工没有默认归属部门!"); + } var deptUsers = db.Queryable().Where(x => x.DeptId == userInfo.DeptId).Select(x => x.Id).ToList(); ruleInfo.DataRules = ruleInfo.DataRules.Replace(DataRuleConst.LoginDept, string.Join(",", deptUsers)); } if (ruleInfo.RuleScope == "select_org") { - var orgUsers = db.Queryable().Where(x => x.DefaultOrgId == userInfo.DefaultOrgId).Select(x => x.Id).ToList(); - ruleInfo.DataRules = ruleInfo.DataRules.Replace(DataRuleConst.LoginDept, string.Join(",", orgUsers)); + //var orgUsers = db.Queryable().Where(x => x.DefaultOrgId == userInfo.DefaultOrgId).Select(x => x.Id).ToList(); + //ruleInfo.DataRules = ruleInfo.DataRules.Replace(DataRuleConst.LoginDept, string.Join(",", orgUsers)); var conditions1 = ruleInfo.DataRules.ConvertSqlSugarExpression(); var conditionalModels1 = db.ConfigQuery.Context.Utilities.JsonToConditionalModels( JsonConvert.SerializeObject(conditions1)); - return db.Queryable().ClearFilter().Where(conditionalModels1); + return tenantDb.Queryable().ClearFilter().Where(conditionalModels1); + } + if (ruleInfo.RuleScope == "select_user") + { + var conditions2 = ruleInfo.DataRules.ConvertSqlSugarExpression(); + var conditionalModels2 = + db.ConfigQuery.Context.Utilities.JsonToConditionalModels( + JsonConvert.SerializeObject(conditions2)); + return tenantDb.Queryable().ClearFilter().Where(conditionalModels2); } #endregion @@ -1509,7 +1521,7 @@ public class CommonService : ICommonService var conditionalModels = db.ConfigQuery.Context.Utilities.JsonToConditionalModels( JsonConvert.SerializeObject(conditions)); - return db.Queryable().Where(conditionalModels); + return tenantDb.Queryable().Where(conditionalModels); } #region 获取数据库表及字段属性