|
|
|
@ -1447,7 +1447,7 @@ public class CommonService : ICommonService
|
|
|
|
|
var userInfo = db.Queryable<SysUser>().First(x => x.Id == long.Parse(user.UserId));
|
|
|
|
|
if (userInfo.UserType == 0)
|
|
|
|
|
{
|
|
|
|
|
return db.Queryable<T>(); //超级管理员特权
|
|
|
|
|
return tenantDb.Queryable<T>(); //超级管理员特权
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var moduleName = typeof(T).Name.ToLower();
|
|
|
|
@ -1461,18 +1461,18 @@ public class CommonService : ICommonService
|
|
|
|
|
|
|
|
|
|
if ((long)rule.VisibleTemplateId == 0)
|
|
|
|
|
{
|
|
|
|
|
return db.Queryable<T>();
|
|
|
|
|
return tenantDb.Queryable<T>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ruleInfo = tenantDb.Queryable<CodeDataRuleTemplate>().First(x => x.Id == (long)rule.VisibleTemplateId);
|
|
|
|
|
|
|
|
|
|
if (ruleInfo.DataRules.IsNull())
|
|
|
|
|
{
|
|
|
|
|
return db.Queryable<T>();
|
|
|
|
|
return tenantDb.Queryable<T>();
|
|
|
|
|
}
|
|
|
|
|
if (ruleInfo.RuleScope == "all")
|
|
|
|
|
{
|
|
|
|
|
return db.Queryable<T>().ClearFilter<IOrgId>();
|
|
|
|
|
return tenantDb.Queryable<T>().ClearFilter<IOrgId>();
|
|
|
|
|
}
|
|
|
|
|
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<SysUser>().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<SysUser>().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<SysUser>().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<T>().ClearFilter<IOrgId>().Where(conditionalModels1);
|
|
|
|
|
return tenantDb.Queryable<T>().ClearFilter<IOrgId>().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<T>().ClearFilter<IOrgId>().Where(conditionalModels2);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
@ -1509,7 +1521,7 @@ public class CommonService : ICommonService
|
|
|
|
|
var conditionalModels =
|
|
|
|
|
db.ConfigQuery.Context.Utilities.JsonToConditionalModels(
|
|
|
|
|
JsonConvert.SerializeObject(conditions));
|
|
|
|
|
return db.Queryable<T>().Where(conditionalModels);
|
|
|
|
|
return tenantDb.Queryable<T>().Where(conditionalModels);
|
|
|
|
|
}
|
|
|
|
|
#region 获取数据库表及字段属性
|
|
|
|
|
|
|
|
|
|