代码生成器生成查询方法时,根据可空配置生成不同的字符串参数判空方式
This commit is contained in:
parent
1c0a974d70
commit
aecc97f73a
|
@ -1,4 +1,5 @@
|
||||||
using System.Text;
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
using NewLife;
|
using NewLife;
|
||||||
using NewLife.Collections;
|
using NewLife.Collections;
|
||||||
using NewLife.Log;
|
using NewLife.Log;
|
||||||
|
@ -325,8 +326,13 @@ public class EntityBuilder : ClassBuilder
|
||||||
if (!Business)
|
if (!Business)
|
||||||
{
|
{
|
||||||
// 读取biz文件,识别其中已生成的扩展查询方法,避免在数据类中重复生成
|
// 读取biz文件,识别其中已生成的扩展查询方法,避免在数据类中重复生成
|
||||||
var bizFile = GetFileName(".Biz.cs", Option.ChineseFileName);
|
var codeFile = GetFileName(".Biz.cs", Option.ChineseFileName);
|
||||||
LoadCodeFile(bizFile);
|
LoadCodeFile(codeFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var codeFile = GetFileName(".cs", Option.ChineseFileName);
|
||||||
|
LoadCodeFile(codeFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -600,6 +606,9 @@ public class EntityBuilder : ClassBuilder
|
||||||
WriteLine();
|
WriteLine();
|
||||||
BuildExtendSearch();
|
BuildExtendSearch();
|
||||||
|
|
||||||
|
//todo 条件暂时未成熟,生成的高级查询有些缺陷,需要人工介入修改
|
||||||
|
//BuildAdvanceSearch();
|
||||||
|
|
||||||
if (ScaleColumn != null)
|
if (ScaleColumn != null)
|
||||||
{
|
{
|
||||||
WriteLine();
|
WriteLine();
|
||||||
|
@ -1615,19 +1624,7 @@ public class EntityBuilder : ClassBuilder
|
||||||
var methodName = columns.Select(e => e.Name).Join("And");
|
var methodName = columns.Select(e => e.Name).Join("And");
|
||||||
methodName = $"FindBy{methodName}";
|
methodName = $"FindBy{methodName}";
|
||||||
|
|
||||||
var ps = new Dictionary<String, String>();
|
var (ps, ps2) = GetParameters(columns);
|
||||||
var ps2 = new Dictionary<String, String>();
|
|
||||||
foreach (var dc in columns)
|
|
||||||
{
|
|
||||||
var type = dc.Properties["Type"];
|
|
||||||
if (type.IsNullOrEmpty()) type = dc.DataType?.Name + "";
|
|
||||||
|
|
||||||
ps[dc.CamelName()] = type;
|
|
||||||
|
|
||||||
var p = type.LastIndexOf('.');
|
|
||||||
if (p > 0) type = type[(p + 1)..];
|
|
||||||
ps2[dc.CamelName()] = type;
|
|
||||||
}
|
|
||||||
var args = ps.Join(", ", e => $"{e.Value} {e.Key}");
|
var args = ps.Join(", ", e => $"{e.Value} {e.Key}");
|
||||||
|
|
||||||
// 如果方法名已存在,则不生成
|
// 如果方法名已存在,则不生成
|
||||||
|
@ -1654,7 +1651,12 @@ public class EntityBuilder : ClassBuilder
|
||||||
if (dc.DataType != null && dc.DataType.IsInt())
|
if (dc.DataType != null && dc.DataType.IsInt())
|
||||||
WriteLine("if ({0} < 0) return null;", dc.CamelName());
|
WriteLine("if ({0} < 0) return null;", dc.CamelName());
|
||||||
else if (dc.DataType == typeof(String))
|
else if (dc.DataType == typeof(String))
|
||||||
WriteLine("if ({0}.IsNullOrEmpty()) return null;", dc.CamelName());
|
{
|
||||||
|
if (nullable)
|
||||||
|
WriteLine("if ({0} == null) return null;", dc.CamelName());
|
||||||
|
else
|
||||||
|
WriteLine("if ({0}.IsNullOrEmpty()) return null;", dc.CamelName());
|
||||||
|
}
|
||||||
else if (dc.DataType == typeof(DateTime) && dc.ItemType.EqualIgnoreCase("date"))
|
else if (dc.DataType == typeof(DateTime) && dc.ItemType.EqualIgnoreCase("date"))
|
||||||
WriteLine("if ({0}.Year < 2000) return null;", dc.CamelName());
|
WriteLine("if ({0}.Year < 2000) return null;", dc.CamelName());
|
||||||
|
|
||||||
|
@ -1725,19 +1727,7 @@ public class EntityBuilder : ClassBuilder
|
||||||
var methodName = columns.Select(e => e.Name).Join("And");
|
var methodName = columns.Select(e => e.Name).Join("And");
|
||||||
methodName = $"FindAllBy{methodName}";
|
methodName = $"FindAllBy{methodName}";
|
||||||
|
|
||||||
var ps = new Dictionary<String, String>();
|
var (ps, ps2) = GetParameters(columns);
|
||||||
var ps2 = new Dictionary<String, String>();
|
|
||||||
foreach (var dc in columns)
|
|
||||||
{
|
|
||||||
var type = dc.Properties["Type"];
|
|
||||||
if (type.IsNullOrEmpty()) type = dc.DataType?.Name + "";
|
|
||||||
|
|
||||||
ps[dc.CamelName()] = type;
|
|
||||||
|
|
||||||
var p = type.LastIndexOf('.');
|
|
||||||
if (p > 0) type = type[(p + 1)..];
|
|
||||||
ps2[dc.CamelName()] = type;
|
|
||||||
}
|
|
||||||
var args = ps.Join(", ", e => $"{e.Value} {e.Key}");
|
var args = ps.Join(", ", e => $"{e.Value} {e.Key}");
|
||||||
|
|
||||||
// 如果方法名已存在,则不生成
|
// 如果方法名已存在,则不生成
|
||||||
|
@ -1762,7 +1752,12 @@ public class EntityBuilder : ClassBuilder
|
||||||
if (dc.DataType != null && dc.DataType.IsInt())
|
if (dc.DataType != null && dc.DataType.IsInt())
|
||||||
WriteLine("if ({0} < 0) return [];", dc.CamelName(), ClassName);
|
WriteLine("if ({0} < 0) return [];", dc.CamelName(), ClassName);
|
||||||
else if (dc.DataType == typeof(String))
|
else if (dc.DataType == typeof(String))
|
||||||
WriteLine("if ({0}.IsNullOrEmpty()) return [];", dc.CamelName(), ClassName);
|
{
|
||||||
|
if (Option.Nullable)
|
||||||
|
WriteLine("if ({0} == null) return [];", dc.CamelName());
|
||||||
|
else
|
||||||
|
WriteLine("if ({0}.IsNullOrEmpty()) return [];", dc.CamelName(), ClassName);
|
||||||
|
}
|
||||||
else if (dc.DataType == typeof(DateTime) && dc.ItemType.EqualIgnoreCase("date"))
|
else if (dc.DataType == typeof(DateTime) && dc.ItemType.EqualIgnoreCase("date"))
|
||||||
WriteLine("if ({0}.Year < 2000) return [];", dc.CamelName());
|
WriteLine("if ({0}.Year < 2000) return [];", dc.CamelName());
|
||||||
|
|
||||||
|
@ -1798,116 +1793,40 @@ public class EntityBuilder : ClassBuilder
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>高级查询</summary>
|
private (IDictionary<String, String>, IDictionary<String, String>) GetParameters(IList<IDataColumn> columns)
|
||||||
|
{
|
||||||
|
var ps = new Dictionary<String, String>();
|
||||||
|
var ps2 = new Dictionary<String, String>();
|
||||||
|
foreach (var dc in columns)
|
||||||
|
{
|
||||||
|
var type = dc.Properties["Type"];
|
||||||
|
if (type.IsNullOrEmpty()) type = dc.DataType?.Name + "";
|
||||||
|
|
||||||
|
if (dc.DataType == typeof(Boolean))
|
||||||
|
type += "?";
|
||||||
|
|
||||||
|
ps[dc.CamelName()] = type;
|
||||||
|
|
||||||
|
var p = type.LastIndexOf('.');
|
||||||
|
if (p > 0) type = type[(p + 1)..];
|
||||||
|
ps2[dc.CamelName()] = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ps, ps2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>自定义查询区域</summary>
|
||||||
protected virtual void BuildSearch()
|
protected virtual void BuildSearch()
|
||||||
{
|
{
|
||||||
// 收集索引信息,索引中的所有字段都参与,构造一个高级查询模板
|
WriteLine("#region 高级查询");
|
||||||
|
|
||||||
|
var cs = BuildAdvanceSearch();
|
||||||
|
|
||||||
var idx = Table.Indexes ?? [];
|
var idx = Table.Indexes ?? [];
|
||||||
var cs = new List<IDataColumn>();
|
|
||||||
if (idx != null && idx.Count > 0)
|
|
||||||
{
|
|
||||||
// 索引中的所有字段,按照表字段顺序
|
|
||||||
var dcs = idx.SelectMany(e => e.Columns).Distinct().ToArray();
|
|
||||||
foreach (var dc in Table.Columns)
|
|
||||||
{
|
|
||||||
// 主键和自增,不参与
|
|
||||||
if (dc.PrimaryKey || dc.Identity) continue;
|
|
||||||
|
|
||||||
if (dc.Name.EqualIgnoreCase(dcs) || dc.ColumnName.EqualIgnoreCase(dcs)) cs.Add(dc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var returnName = ClassName;
|
var returnName = ClassName;
|
||||||
|
|
||||||
WriteLine("#region 高级查询");
|
|
||||||
if (cs.Count > 0)
|
|
||||||
{
|
|
||||||
// 时间字段。无差别支持UpdateTime/CreateTime
|
|
||||||
var dcTime = cs.FirstOrDefault(e => e.DataScale.StartsWithIgnoreCase("time"));
|
|
||||||
dcTime ??= cs.FirstOrDefault(e => e.DataType == typeof(DateTime));
|
|
||||||
dcTime ??= Table.GetColumns(["UpdateTime", "CreateTime"])?.FirstOrDefault();
|
|
||||||
var dcSnow = cs.FirstOrDefault(e => e.PrimaryKey && !e.Identity && e.DataType == typeof(Int64));
|
|
||||||
|
|
||||||
if (dcTime != null) cs.Remove(dcTime);
|
|
||||||
cs.RemoveAll(e => e.Name.EqualIgnoreCase("key", "page"));
|
|
||||||
if (dcSnow != null || dcTime != null)
|
|
||||||
cs.RemoveAll(e => e.Name.EqualIgnoreCase("start", "end"));
|
|
||||||
|
|
||||||
// 可用于关键字模糊搜索的字段
|
|
||||||
var keys = Table.Columns.Where(e => e.DataType == typeof(String)).ToList();
|
|
||||||
|
|
||||||
// 注释部分
|
|
||||||
WriteLine("/// <summary>高级查询</summary>");
|
|
||||||
foreach (var dc in cs)
|
|
||||||
{
|
|
||||||
WriteLine("/// <param name=\"{0}\">{1}</param>", dc.CamelName(), dc.Description);
|
|
||||||
}
|
|
||||||
if (dcTime != null)
|
|
||||||
{
|
|
||||||
WriteLine("/// <param name=\"start\">{0}开始</param>", dcTime.DisplayName);
|
|
||||||
WriteLine("/// <param name=\"end\">{0}结束</param>", dcTime.DisplayName);
|
|
||||||
}
|
|
||||||
else if (dcSnow != null)
|
|
||||||
{
|
|
||||||
WriteLine("/// <param name=\"start\">{0}开始</param>", dcSnow.DisplayName);
|
|
||||||
WriteLine("/// <param name=\"end\">{0}结束</param>", dcSnow.DisplayName);
|
|
||||||
}
|
|
||||||
WriteLine("/// <param name=\"key\">关键字</param>");
|
|
||||||
WriteLine("/// <param name=\"page\">分页参数信息。可携带统计和数据权限扩展查询等信息</param>");
|
|
||||||
WriteLine("/// <returns>实体列表</returns>");
|
|
||||||
|
|
||||||
// 参数部分
|
|
||||||
//var pis = cs.Join(", ", dc => $"{dc.DataType.Name} {dc.CamelName()}");
|
|
||||||
var pis = new StringBuilder();
|
|
||||||
foreach (var dc in cs)
|
|
||||||
{
|
|
||||||
if (pis.Length > 0) pis.Append(", ");
|
|
||||||
|
|
||||||
var type = dc.Properties["Type"];
|
|
||||||
if (type.IsNullOrEmpty()) type = dc.DataType?.Name;
|
|
||||||
|
|
||||||
if (dc.DataType == typeof(Boolean))
|
|
||||||
pis.Append($"{type}? {dc.CamelName()}");
|
|
||||||
else
|
|
||||||
pis.Append($"{type} {dc.CamelName()}");
|
|
||||||
}
|
|
||||||
var piTime = dcTime == null ? "" : "DateTime start, DateTime end, ";
|
|
||||||
if (pis.Length > 0)
|
|
||||||
WriteLine("public static IList<{0}> Search({1}, {2}String key, PageParameter page)", returnName, pis, piTime);
|
|
||||||
else
|
|
||||||
WriteLine("public static IList<{0}> Search({2}String key, PageParameter page)", returnName, pis, piTime);
|
|
||||||
WriteLine("{");
|
|
||||||
{
|
|
||||||
WriteLine("var exp = new WhereExpression();");
|
|
||||||
|
|
||||||
// 构造表达式
|
|
||||||
WriteLine();
|
|
||||||
foreach (var dc in cs)
|
|
||||||
{
|
|
||||||
if (dc.DataType.IsInt())
|
|
||||||
WriteLine("if ({0} >= 0) exp &= _.{1} == {0};", dc.CamelName(), dc.Name);
|
|
||||||
else if (dc.DataType == typeof(Boolean))
|
|
||||||
WriteLine("if ({0} != null) exp &= _.{1} == {0};", dc.CamelName(), dc.Name);
|
|
||||||
else if (dc.DataType == typeof(String))
|
|
||||||
WriteLine("if (!{0}.IsNullOrEmpty()) exp &= _.{1} == {0};", dc.CamelName(), dc.Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dcSnow != null)
|
|
||||||
WriteLine("exp &= _.{0}.Between(start, end, Meta.Factory.Snow);", dcSnow.Name);
|
|
||||||
else if (dcTime != null)
|
|
||||||
WriteLine("exp &= _.{0}.Between(start, end);", dcTime.Name);
|
|
||||||
|
|
||||||
if (keys.Count > 0)
|
|
||||||
WriteLine("if (!key.IsNullOrEmpty()) exp &= {0};", keys.Join(" | ", k => $"_.{k.Name}.Contains(key)"));
|
|
||||||
|
|
||||||
// 查询返回
|
|
||||||
WriteLine();
|
|
||||||
WriteLine("return FindAll(exp, page);");
|
|
||||||
}
|
|
||||||
WriteLine("}");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 字段缓存,用于魔方前台下拉选择
|
// 字段缓存,用于魔方前台下拉选择
|
||||||
|
if (idx != null && idx.Count > 0)
|
||||||
{
|
{
|
||||||
// 主键和时间字段
|
// 主键和时间字段
|
||||||
var pk = Table.Columns.FirstOrDefault(e => e.Identity);
|
var pk = Table.Columns.FirstOrDefault(e => e.Identity);
|
||||||
|
@ -1970,6 +1889,117 @@ public class EntityBuilder : ClassBuilder
|
||||||
WriteLine("#endregion");
|
WriteLine("#endregion");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>生成高级查询</summary>
|
||||||
|
protected virtual IList<IDataColumn> BuildAdvanceSearch()
|
||||||
|
{
|
||||||
|
// 收集索引信息,索引中的所有字段都参与,构造一个高级查询模板
|
||||||
|
var idx = Table.Indexes ?? [];
|
||||||
|
var cs = new List<IDataColumn>();
|
||||||
|
if (idx != null && idx.Count > 0)
|
||||||
|
{
|
||||||
|
// 索引中的所有字段,按照表字段顺序
|
||||||
|
var dcs = idx.SelectMany(e => e.Columns).Distinct().ToArray();
|
||||||
|
foreach (var dc in Table.Columns)
|
||||||
|
{
|
||||||
|
// 主键和自增,不参与
|
||||||
|
if (dc.PrimaryKey || dc.Identity) continue;
|
||||||
|
|
||||||
|
if (dc.Name.EqualIgnoreCase(dcs) || dc.ColumnName.EqualIgnoreCase(dcs)) cs.Add(dc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cs.Count <= 0) return cs;
|
||||||
|
|
||||||
|
var returnName = ClassName;
|
||||||
|
|
||||||
|
// 时间字段。无差别支持UpdateTime/CreateTime
|
||||||
|
var dcTime = cs.FirstOrDefault(e => e.DataScale.StartsWithIgnoreCase("time"));
|
||||||
|
dcTime ??= cs.FirstOrDefault(e => e.DataType == typeof(DateTime));
|
||||||
|
dcTime ??= Table.GetColumns(["UpdateTime", "CreateTime"])?.FirstOrDefault();
|
||||||
|
var dcSnow = cs.FirstOrDefault(e => e.PrimaryKey && !e.Identity && e.DataType == typeof(Int64));
|
||||||
|
|
||||||
|
if (dcTime != null) cs.Remove(dcTime);
|
||||||
|
cs.RemoveAll(e => e.Name.EqualIgnoreCase("key", "page"));
|
||||||
|
if (dcSnow != null || dcTime != null)
|
||||||
|
cs.RemoveAll(e => e.Name.EqualIgnoreCase("start", "end"));
|
||||||
|
|
||||||
|
var (ps, ps2) = GetParameters(cs);
|
||||||
|
|
||||||
|
// 如果方法名已存在,则不生成
|
||||||
|
if (dcTime != null)
|
||||||
|
{
|
||||||
|
ps2["start"] = "DateTime";
|
||||||
|
ps2["end"] = "DateTime";
|
||||||
|
}
|
||||||
|
ps2["key"] = "String";
|
||||||
|
ps2["page"] = "PageParameter";
|
||||||
|
var key = $"Search({ps2.Join(",", e => e.Value)})";
|
||||||
|
if (Members.Contains(key)) return cs;
|
||||||
|
Members.Add(key);
|
||||||
|
|
||||||
|
// 可用于关键字模糊搜索的字段
|
||||||
|
var keys = Table.Columns.Where(e => e.DataType == typeof(String)).ToList();
|
||||||
|
|
||||||
|
// 注释部分
|
||||||
|
WriteLine("/// <summary>高级查询</summary>");
|
||||||
|
foreach (var dc in cs)
|
||||||
|
{
|
||||||
|
WriteLine("/// <param name=\"{0}\">{1}</param>", dc.CamelName(), dc.Description);
|
||||||
|
}
|
||||||
|
if (dcTime != null)
|
||||||
|
{
|
||||||
|
WriteLine("/// <param name=\"start\">{0}开始</param>", dcTime.DisplayName);
|
||||||
|
WriteLine("/// <param name=\"end\">{0}结束</param>", dcTime.DisplayName);
|
||||||
|
}
|
||||||
|
else if (dcSnow != null)
|
||||||
|
{
|
||||||
|
WriteLine("/// <param name=\"start\">{0}开始</param>", dcSnow.DisplayName);
|
||||||
|
WriteLine("/// <param name=\"end\">{0}结束</param>", dcSnow.DisplayName);
|
||||||
|
}
|
||||||
|
WriteLine("/// <param name=\"key\">关键字</param>");
|
||||||
|
WriteLine("/// <param name=\"page\">分页参数信息。可携带统计和数据权限扩展查询等信息</param>");
|
||||||
|
WriteLine("/// <returns>实体列表</returns>");
|
||||||
|
|
||||||
|
// 参数部分
|
||||||
|
var pis = ps.Join(", ", e => $"{e.Value} {e.Key}");
|
||||||
|
var piTime = dcTime == null ? "" : "DateTime start, DateTime end, ";
|
||||||
|
if (pis.Length > 0)
|
||||||
|
WriteLine("public static IList<{0}> Search({1}, {2}String key, PageParameter page)", returnName, pis, piTime);
|
||||||
|
else
|
||||||
|
WriteLine("public static IList<{0}> Search({2}String key, PageParameter page)", returnName, pis, piTime);
|
||||||
|
WriteLine("{");
|
||||||
|
{
|
||||||
|
WriteLine("var exp = new WhereExpression();");
|
||||||
|
|
||||||
|
// 构造表达式
|
||||||
|
WriteLine();
|
||||||
|
foreach (var dc in cs)
|
||||||
|
{
|
||||||
|
if (dc.DataType.IsInt())
|
||||||
|
WriteLine("if ({0} >= 0) exp &= _.{1} == {0};", dc.CamelName(), dc.Name);
|
||||||
|
else if (dc.DataType == typeof(Boolean))
|
||||||
|
WriteLine("if ({0} != null) exp &= _.{1} == {0};", dc.CamelName(), dc.Name);
|
||||||
|
else if (dc.DataType == typeof(String))
|
||||||
|
WriteLine("if (!{0}.IsNullOrEmpty()) exp &= _.{1} == {0};", dc.CamelName(), dc.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dcSnow != null)
|
||||||
|
WriteLine("exp &= _.{0}.Between(start, end, Meta.Factory.Snow);", dcSnow.Name);
|
||||||
|
else if (dcTime != null)
|
||||||
|
WriteLine("exp &= _.{0}.Between(start, end);", dcTime.Name);
|
||||||
|
|
||||||
|
if (keys.Count > 0)
|
||||||
|
WriteLine("if (!key.IsNullOrEmpty()) exp &= {0};", keys.Join(" | ", k => $"_.{k.Name}.Contains(key)"));
|
||||||
|
|
||||||
|
// 查询返回
|
||||||
|
WriteLine();
|
||||||
|
WriteLine("return FindAll(exp, page);");
|
||||||
|
}
|
||||||
|
WriteLine("}");
|
||||||
|
|
||||||
|
return cs;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>业务操作</summary>
|
/// <summary>业务操作</summary>
|
||||||
protected virtual void BuildBusiness()
|
protected virtual void BuildBusiness()
|
||||||
{
|
{
|
||||||
|
|
|
@ -295,7 +295,7 @@ public partial class Area : IArea, IEntity<IArea>
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<Area> FindAllByName(String name)
|
public static IList<Area> FindAllByName(String name)
|
||||||
{
|
{
|
||||||
if (name.IsNullOrEmpty()) return [];
|
if (name == null) return [];
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Name.EqualIgnoreCase(name));
|
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Name.EqualIgnoreCase(name));
|
||||||
|
@ -308,7 +308,7 @@ public partial class Area : IArea, IEntity<IArea>
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<Area> FindAllByPinYin(String pinYin)
|
public static IList<Area> FindAllByPinYin(String pinYin)
|
||||||
{
|
{
|
||||||
if (pinYin.IsNullOrEmpty()) return [];
|
if (pinYin == null) return [];
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.PinYin.EqualIgnoreCase(pinYin));
|
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.PinYin.EqualIgnoreCase(pinYin));
|
||||||
|
@ -321,7 +321,7 @@ public partial class Area : IArea, IEntity<IArea>
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<Area> FindAllByJianPin(String jianPin)
|
public static IList<Area> FindAllByJianPin(String jianPin)
|
||||||
{
|
{
|
||||||
if (jianPin.IsNullOrEmpty()) return [];
|
if (jianPin == null) return [];
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.JianPin.EqualIgnoreCase(jianPin));
|
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.JianPin.EqualIgnoreCase(jianPin));
|
||||||
|
@ -334,7 +334,7 @@ public partial class Area : IArea, IEntity<IArea>
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<Area> FindAllByGeoHash(String geoHash)
|
public static IList<Area> FindAllByGeoHash(String geoHash)
|
||||||
{
|
{
|
||||||
if (geoHash.IsNullOrEmpty()) return [];
|
if (geoHash == null) return [];
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.GeoHash.EqualIgnoreCase(geoHash));
|
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.GeoHash.EqualIgnoreCase(geoHash));
|
||||||
|
|
|
@ -357,8 +357,8 @@ public partial class Parameter : IParameter, IEntity<IParameter>
|
||||||
public static Parameter? FindByUserIDAndCategoryAndName(Int32 userId, String category, String name)
|
public static Parameter? FindByUserIDAndCategoryAndName(Int32 userId, String category, String name)
|
||||||
{
|
{
|
||||||
if (userId < 0) return null;
|
if (userId < 0) return null;
|
||||||
if (category.IsNullOrEmpty()) return null;
|
if (category == null) return null;
|
||||||
if (name.IsNullOrEmpty()) return null;
|
if (name == null) return null;
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.UserID == userId && e.Category.EqualIgnoreCase(category) && e.Name.EqualIgnoreCase(name));
|
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.UserID == userId && e.Category.EqualIgnoreCase(category) && e.Name.EqualIgnoreCase(name));
|
||||||
|
@ -386,7 +386,7 @@ public partial class Parameter : IParameter, IEntity<IParameter>
|
||||||
public static IList<Parameter> FindAllByUserIDAndCategory(Int32 userId, String category)
|
public static IList<Parameter> FindAllByUserIDAndCategory(Int32 userId, String category)
|
||||||
{
|
{
|
||||||
if (userId < 0) return [];
|
if (userId < 0) return [];
|
||||||
if (category.IsNullOrEmpty()) return [];
|
if (category == null) return [];
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.UserID == userId && e.Category.EqualIgnoreCase(category));
|
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.UserID == userId && e.Category.EqualIgnoreCase(category));
|
||||||
|
@ -400,8 +400,8 @@ public partial class Parameter : IParameter, IEntity<IParameter>
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<Parameter> FindAllByCategoryAndName(String category, String name)
|
public static IList<Parameter> FindAllByCategoryAndName(String category, String name)
|
||||||
{
|
{
|
||||||
if (category.IsNullOrEmpty()) return [];
|
if (category == null) return [];
|
||||||
if (name.IsNullOrEmpty()) return [];
|
if (name == null) return [];
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Category.EqualIgnoreCase(category) && e.Name.EqualIgnoreCase(name));
|
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Category.EqualIgnoreCase(category) && e.Name.EqualIgnoreCase(name));
|
||||||
|
|
|
@ -300,8 +300,8 @@ public partial class MemberLog : IMemberLog, IEntity<IMemberLog>
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<MemberLog> FindAllByActionAndCategory(String action, String category)
|
public static IList<MemberLog> FindAllByActionAndCategory(String action, String category)
|
||||||
{
|
{
|
||||||
if (action.IsNullOrEmpty()) return [];
|
if (action == null) return [];
|
||||||
if (category.IsNullOrEmpty()) return [];
|
if (category == null) return [];
|
||||||
|
|
||||||
return FindAll(_.Action == action & _.Category == category);
|
return FindAll(_.Action == action & _.Category == category);
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@ public partial class MemberLog : IMemberLog, IEntity<IMemberLog>
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<MemberLog> FindAllByCategoryAndLinkID(String category, Int32 linkId)
|
public static IList<MemberLog> FindAllByCategoryAndLinkID(String category, Int32 linkId)
|
||||||
{
|
{
|
||||||
if (category.IsNullOrEmpty()) return [];
|
if (category == null) return [];
|
||||||
if (linkId < 0) return [];
|
if (linkId < 0) return [];
|
||||||
|
|
||||||
return FindAll(_.Category == category & _.LinkID == linkId);
|
return FindAll(_.Category == category & _.LinkID == linkId);
|
||||||
|
|
|
@ -291,8 +291,8 @@ public partial class Log : ILog, IEntity<ILog>
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<Log> FindAllByActionAndCategory(String action, String category)
|
public static IList<Log> FindAllByActionAndCategory(String action, String category)
|
||||||
{
|
{
|
||||||
if (action.IsNullOrEmpty()) return [];
|
if (action == null) return [];
|
||||||
if (category.IsNullOrEmpty()) return [];
|
if (category == null) return [];
|
||||||
|
|
||||||
return FindAll(_.Action == action & _.Category == category);
|
return FindAll(_.Action == action & _.Category == category);
|
||||||
}
|
}
|
||||||
|
@ -303,7 +303,7 @@ public partial class Log : ILog, IEntity<ILog>
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<Log> FindAllByCategoryAndLinkID(String category, Int32 linkId)
|
public static IList<Log> FindAllByCategoryAndLinkID(String category, Int32 linkId)
|
||||||
{
|
{
|
||||||
if (category.IsNullOrEmpty()) return [];
|
if (category == null) return [];
|
||||||
if (linkId < 0) return [];
|
if (linkId < 0) return [];
|
||||||
|
|
||||||
return FindAll(_.Category == category & _.LinkID == linkId);
|
return FindAll(_.Category == category & _.LinkID == linkId);
|
||||||
|
|
|
@ -491,7 +491,7 @@ public partial class User : IUser, IEntity<IUser>
|
||||||
/// <returns>实体对象</returns>
|
/// <returns>实体对象</returns>
|
||||||
public static User? FindByName(String name)
|
public static User? FindByName(String name)
|
||||||
{
|
{
|
||||||
if (name.IsNullOrEmpty()) return null;
|
if (name == null) return null;
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Name.EqualIgnoreCase(name));
|
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Name.EqualIgnoreCase(name));
|
||||||
|
@ -507,7 +507,7 @@ public partial class User : IUser, IEntity<IUser>
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<User> FindAllByMail(String mail)
|
public static IList<User> FindAllByMail(String mail)
|
||||||
{
|
{
|
||||||
if (mail.IsNullOrEmpty()) return [];
|
if (mail == null) return [];
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Mail.EqualIgnoreCase(mail));
|
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Mail.EqualIgnoreCase(mail));
|
||||||
|
@ -520,7 +520,7 @@ public partial class User : IUser, IEntity<IUser>
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<User> FindAllByMobile(String mobile)
|
public static IList<User> FindAllByMobile(String mobile)
|
||||||
{
|
{
|
||||||
if (mobile.IsNullOrEmpty()) return [];
|
if (mobile == null) return [];
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Mobile.EqualIgnoreCase(mobile));
|
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Mobile.EqualIgnoreCase(mobile));
|
||||||
|
@ -533,7 +533,7 @@ public partial class User : IUser, IEntity<IUser>
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<User> FindAllByCode(String code)
|
public static IList<User> FindAllByCode(String code)
|
||||||
{
|
{
|
||||||
if (code.IsNullOrEmpty()) return [];
|
if (code == null) return [];
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Code.EqualIgnoreCase(code));
|
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Code.EqualIgnoreCase(code));
|
||||||
|
|
|
@ -302,8 +302,8 @@ public partial class UserLog : IUserLog, IEntity<IUserLog>
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<UserLog> FindAllByActionAndCategory(String action, String category)
|
public static IList<UserLog> FindAllByActionAndCategory(String action, String category)
|
||||||
{
|
{
|
||||||
if (action.IsNullOrEmpty()) return [];
|
if (action == null) return [];
|
||||||
if (category.IsNullOrEmpty()) return [];
|
if (category == null) return [];
|
||||||
|
|
||||||
return FindAll(_.Action == action & _.Category == category);
|
return FindAll(_.Action == action & _.Category == category);
|
||||||
}
|
}
|
||||||
|
@ -314,7 +314,7 @@ public partial class UserLog : IUserLog, IEntity<IUserLog>
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<UserLog> FindAllByCategoryAndLinkID(String category, Int32 linkId)
|
public static IList<UserLog> FindAllByCategoryAndLinkID(String category, Int32 linkId)
|
||||||
{
|
{
|
||||||
if (category.IsNullOrEmpty()) return [];
|
if (category == null) return [];
|
||||||
if (linkId < 0) return [];
|
if (linkId < 0) return [];
|
||||||
|
|
||||||
return FindAll(_.Category == category & _.LinkID == linkId);
|
return FindAll(_.Category == category & _.LinkID == linkId);
|
||||||
|
|
|
@ -272,7 +272,7 @@ public partial class Tenant : ITenant, IEntity<ITenant>
|
||||||
/// <returns>实体对象</returns>
|
/// <returns>实体对象</returns>
|
||||||
public static Tenant? FindByCode(String code)
|
public static Tenant? FindByCode(String code)
|
||||||
{
|
{
|
||||||
if (code.IsNullOrEmpty()) return null;
|
if (code == null) return null;
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Code.EqualIgnoreCase(code));
|
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Code.EqualIgnoreCase(code));
|
||||||
|
|
|
@ -389,7 +389,7 @@ public partial class Menu : IMenu, IEntity<IMenu>
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<Menu> FindAllByName(String name)
|
public static IList<Menu> FindAllByName(String name)
|
||||||
{
|
{
|
||||||
if (name.IsNullOrEmpty()) return [];
|
if (name == null) return [];
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Name.EqualIgnoreCase(name));
|
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Name.EqualIgnoreCase(name));
|
||||||
|
@ -404,7 +404,7 @@ public partial class Menu : IMenu, IEntity<IMenu>
|
||||||
public static Menu? FindByParentIDAndName(Int32 parentId, String name)
|
public static Menu? FindByParentIDAndName(Int32 parentId, String name)
|
||||||
{
|
{
|
||||||
if (parentId < 0) return null;
|
if (parentId < 0) return null;
|
||||||
if (name.IsNullOrEmpty()) return null;
|
if (name == null) return null;
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ParentID == parentId && e.Name.EqualIgnoreCase(name));
|
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ParentID == parentId && e.Name.EqualIgnoreCase(name));
|
||||||
|
|
|
@ -322,7 +322,7 @@ public partial class Role : IRole, IEntity<IRole>
|
||||||
/// <returns>实体对象</returns>
|
/// <returns>实体对象</returns>
|
||||||
public static Role? FindByName(String name)
|
public static Role? FindByName(String name)
|
||||||
{
|
{
|
||||||
if (name.IsNullOrEmpty()) return null;
|
if (name == null) return null;
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Name.EqualIgnoreCase(name));
|
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Name.EqualIgnoreCase(name));
|
||||||
|
|
|
@ -397,7 +397,7 @@ public partial class Department : IDepartment, IEntity<IDepartment>
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<Department> FindAllByName(String name)
|
public static IList<Department> FindAllByName(String name)
|
||||||
{
|
{
|
||||||
if (name.IsNullOrEmpty()) return [];
|
if (name == null) return [];
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Name.EqualIgnoreCase(name));
|
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Name.EqualIgnoreCase(name));
|
||||||
|
@ -412,7 +412,7 @@ public partial class Department : IDepartment, IEntity<IDepartment>
|
||||||
public static IList<Department> FindAllByParentIDAndName(Int32 parentId, String name)
|
public static IList<Department> FindAllByParentIDAndName(Int32 parentId, String name)
|
||||||
{
|
{
|
||||||
if (parentId < 0) return [];
|
if (parentId < 0) return [];
|
||||||
if (name.IsNullOrEmpty()) return [];
|
if (name == null) return [];
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.ParentID == parentId && e.Name.EqualIgnoreCase(name));
|
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.ParentID == parentId && e.Name.EqualIgnoreCase(name));
|
||||||
|
@ -425,7 +425,7 @@ public partial class Department : IDepartment, IEntity<IDepartment>
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<Department> FindAllByCode(String code)
|
public static IList<Department> FindAllByCode(String code)
|
||||||
{
|
{
|
||||||
if (code.IsNullOrEmpty()) return [];
|
if (code == null) return [];
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Code.EqualIgnoreCase(code));
|
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Code.EqualIgnoreCase(code));
|
||||||
|
|
|
@ -259,8 +259,8 @@ public partial class Log
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<Log> FindAllByActionAndCategory(String action, String category)
|
public static IList<Log> FindAllByActionAndCategory(String action, String category)
|
||||||
{
|
{
|
||||||
if (action.IsNullOrEmpty()) return [];
|
if (action == null) return [];
|
||||||
if (category.IsNullOrEmpty()) return [];
|
if (category == null) return [];
|
||||||
|
|
||||||
return FindAll(_.Action == action & _.Category == category);
|
return FindAll(_.Action == action & _.Category == category);
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,7 @@ public partial class Log
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<Log> FindAllByCategoryAndLinkID(String category, Int64 linkId)
|
public static IList<Log> FindAllByCategoryAndLinkID(String category, Int64 linkId)
|
||||||
{
|
{
|
||||||
if (category.IsNullOrEmpty()) return [];
|
if (category == null) return [];
|
||||||
if (linkId < 0) return [];
|
if (linkId < 0) return [];
|
||||||
|
|
||||||
return FindAll(_.Category == category & _.LinkID == linkId);
|
return FindAll(_.Category == category & _.LinkID == linkId);
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace Company.MyName;
|
||||||
[BindIndex("IX_User_Mobile", false, "Mobile")]
|
[BindIndex("IX_User_Mobile", false, "Mobile")]
|
||||||
[BindIndex("IX_User_Code", false, "Code")]
|
[BindIndex("IX_User_Code", false, "Code")]
|
||||||
[BindIndex("IX_User_RoleID", false, "RoleID")]
|
[BindIndex("IX_User_RoleID", false, "RoleID")]
|
||||||
|
[BindIndex("IX_User_DepartmentID", false, "DepartmentID")]
|
||||||
[BindIndex("IX_User_UpdateTime", false, "UpdateTime")]
|
[BindIndex("IX_User_UpdateTime", false, "UpdateTime")]
|
||||||
[BindTable("User", Description = "用户。用户帐号信息,以身份验证为中心,拥有多种角色,可加入多个租户", ConnName = "MyConn", DbType = DatabaseType.None)]
|
[BindTable("User", Description = "用户。用户帐号信息,以身份验证为中心,拥有多种角色,可加入多个租户", ConnName = "MyConn", DbType = DatabaseType.None)]
|
||||||
public partial class User
|
public partial class User
|
||||||
|
@ -463,7 +464,7 @@ public partial class User
|
||||||
/// <returns>实体对象</returns>
|
/// <returns>实体对象</returns>
|
||||||
public static User? FindByName(String name)
|
public static User? FindByName(String name)
|
||||||
{
|
{
|
||||||
if (name.IsNullOrEmpty()) return null;
|
if (name == null) return null;
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Name.EqualIgnoreCase(name));
|
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Name.EqualIgnoreCase(name));
|
||||||
|
@ -479,7 +480,7 @@ public partial class User
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<User> FindAllByMail(String mail)
|
public static IList<User> FindAllByMail(String mail)
|
||||||
{
|
{
|
||||||
if (mail.IsNullOrEmpty()) return [];
|
if (mail == null) return [];
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Mail.EqualIgnoreCase(mail));
|
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Mail.EqualIgnoreCase(mail));
|
||||||
|
@ -492,7 +493,7 @@ public partial class User
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<User> FindAllByMobile(String mobile)
|
public static IList<User> FindAllByMobile(String mobile)
|
||||||
{
|
{
|
||||||
if (mobile.IsNullOrEmpty()) return [];
|
if (mobile == null) return [];
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Mobile.EqualIgnoreCase(mobile));
|
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Mobile.EqualIgnoreCase(mobile));
|
||||||
|
@ -505,7 +506,7 @@ public partial class User
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<User> FindAllByCode(String code)
|
public static IList<User> FindAllByCode(String code)
|
||||||
{
|
{
|
||||||
if (code.IsNullOrEmpty()) return [];
|
if (code == null) return [];
|
||||||
|
|
||||||
// 实体缓存
|
// 实体缓存
|
||||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Code.EqualIgnoreCase(code));
|
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Code.EqualIgnoreCase(code));
|
||||||
|
@ -525,6 +526,19 @@ public partial class User
|
||||||
|
|
||||||
return FindAll(_.RoleID == roleId);
|
return FindAll(_.RoleID == roleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>根据部门查找</summary>
|
||||||
|
/// <param name="departmentId">部门</param>
|
||||||
|
/// <returns>实体列表</returns>
|
||||||
|
public static IList<User> FindAllByDepartmentID(Int32 departmentId)
|
||||||
|
{
|
||||||
|
if (departmentId < 0) return [];
|
||||||
|
|
||||||
|
// 实体缓存
|
||||||
|
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.DepartmentID == departmentId);
|
||||||
|
|
||||||
|
return FindAll(_.DepartmentID == departmentId);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 字段名
|
#region 字段名
|
||||||
|
|
|
@ -154,12 +154,13 @@ public partial class User : Entity<User>
|
||||||
/// <param name="mobile">手机。支持登录</param>
|
/// <param name="mobile">手机。支持登录</param>
|
||||||
/// <param name="code">代码。身份证、员工编码等,支持登录</param>
|
/// <param name="code">代码。身份证、员工编码等,支持登录</param>
|
||||||
/// <param name="roleId">角色。主要角色</param>
|
/// <param name="roleId">角色。主要角色</param>
|
||||||
|
/// <param name="departmentId">部门。组织机构</param>
|
||||||
/// <param name="start">更新时间开始</param>
|
/// <param name="start">更新时间开始</param>
|
||||||
/// <param name="end">更新时间结束</param>
|
/// <param name="end">更新时间结束</param>
|
||||||
/// <param name="key">关键字</param>
|
/// <param name="key">关键字</param>
|
||||||
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
|
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
|
||||||
/// <returns>实体列表</returns>
|
/// <returns>实体列表</returns>
|
||||||
public static IList<User> Search(String name, String mail, String mobile, String code, Int32 roleId, DateTime start, DateTime end, String key, PageParameter page)
|
public static IList<User> Search(String name, String mail, String mobile, String code, Int32 roleId, Int32 departmentId, DateTime start, DateTime end, String key, PageParameter page)
|
||||||
{
|
{
|
||||||
var exp = new WhereExpression();
|
var exp = new WhereExpression();
|
||||||
|
|
||||||
|
@ -168,6 +169,7 @@ public partial class User : Entity<User>
|
||||||
if (!mobile.IsNullOrEmpty()) exp &= _.Mobile == mobile;
|
if (!mobile.IsNullOrEmpty()) exp &= _.Mobile == mobile;
|
||||||
if (!code.IsNullOrEmpty()) exp &= _.Code == code;
|
if (!code.IsNullOrEmpty()) exp &= _.Code == code;
|
||||||
if (roleId >= 0) exp &= _.RoleID == roleId;
|
if (roleId >= 0) exp &= _.RoleID == roleId;
|
||||||
|
if (departmentId >= 0) exp &= _.DepartmentID == departmentId;
|
||||||
exp &= _.UpdateTime.Between(start, end);
|
exp &= _.UpdateTime.Between(start, end);
|
||||||
if (!key.IsNullOrEmpty()) exp &= _.Name.Contains(key) | _.Password.Contains(key) | _.DisplayName.Contains(key) | _.Mail.Contains(key) | _.Mobile.Contains(key) | _.Code.Contains(key) | _.Avatar.Contains(key) | _.RoleIds.Contains(key) | _.LastLoginIP.Contains(key) | _.RegisterIP.Contains(key) | _.Ex4.Contains(key) | _.Ex5.Contains(key) | _.Ex6.Contains(key) | _.UpdateUser.Contains(key) | _.UpdateIP.Contains(key) | _.Remark.Contains(key);
|
if (!key.IsNullOrEmpty()) exp &= _.Name.Contains(key) | _.Password.Contains(key) | _.DisplayName.Contains(key) | _.Mail.Contains(key) | _.Mobile.Contains(key) | _.Code.Contains(key) | _.Avatar.Contains(key) | _.RoleIds.Contains(key) | _.LastLoginIP.Contains(key) | _.RegisterIP.Contains(key) | _.Ex4.Contains(key) | _.Ex5.Contains(key) | _.Ex6.Contains(key) | _.UpdateUser.Contains(key) | _.UpdateIP.Contains(key) | _.Remark.Contains(key);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue