Skip to content

Commit

Permalink
[fix]代码生成器,数字字段为0有意义
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Jan 16, 2025
1 parent 9dcd39a commit 8ad43ea
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 41 deletions.
4 changes: 2 additions & 2 deletions XCode/Code/EntityBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,7 @@ protected virtual Boolean BuildExtendFind(IDataColumn[] columns, Int32 index)
foreach (var dc in columns)
{
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))
{
if (nullable && dc.Nullable)
Expand Down Expand Up @@ -1787,7 +1787,7 @@ protected virtual Boolean BuildExtendFindAll(IDataColumn[] columns, Int32 index)
foreach (var dc in columns)
{
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))
{
if (Option.Nullable && dc.Nullable)
Expand Down
Binary file modified XCode/Membership/xcodetool.exe
Binary file not shown.
4 changes: 2 additions & 2 deletions XUnitTest.XCode/Code/Entity/地区.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public override Object? this[String name]
/// <returns>实体对象</returns>
public static Area? FindByID(Int32 id)
{
if (id <= 0) return null;
if (id < 0) return null;

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ID == id);
Expand All @@ -282,7 +282,7 @@ public override Object? this[String name]
/// <returns>实体列表</returns>
public static IList<Area> FindAllByParentID(Int32 parentId)
{
if (parentId <= 0) return [];
if (parentId < 0) return [];

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.ParentID == parentId);
Expand Down
8 changes: 4 additions & 4 deletions XUnitTest.XCode/Code/Entity/字典参数.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public override Object? this[String name]
/// <returns>实体对象</returns>
public static Parameter? FindByID(Int32 id)
{
if (id <= 0) return null;
if (id < 0) return null;

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ID == id);
Expand All @@ -356,7 +356,7 @@ public override Object? this[String name]
/// <returns>实体对象</returns>
public static Parameter? FindByUserIDAndCategoryAndName(Int32 userId, String? category, String? name)
{
if (userId <= 0) return null;
if (userId < 0) return null;
if (category == null) return null;
if (name == null) return null;

Expand All @@ -371,7 +371,7 @@ public override Object? this[String name]
/// <returns>实体列表</returns>
public static IList<Parameter> FindAllByUserID(Int32 userId)
{
if (userId <= 0) return [];
if (userId < 0) return [];

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.UserID == userId);
Expand All @@ -385,7 +385,7 @@ public static IList<Parameter> FindAllByUserID(Int32 userId)
/// <returns>实体列表</returns>
public static IList<Parameter> FindAllByUserIDAndCategory(Int32 userId, String? category)
{
if (userId <= 0) return [];
if (userId < 0) return [];
if (category == null) return [];

// 实体缓存
Expand Down
6 changes: 3 additions & 3 deletions XUnitTest.XCode/Code/Entity/成员日志.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public override Object? this[String name]
/// <returns>实体对象</returns>
public static MemberLog? FindByID(Int64 id)
{
if (id <= 0) return null;
if (id < 0) return null;

return Find(_.ID == id);
}
Expand All @@ -313,7 +313,7 @@ public static IList<MemberLog> FindAllByActionAndCategory(String? action, String
public static IList<MemberLog> FindAllByCategoryAndLinkID(String? category, Int32 linkId)
{
if (category == null) return [];
if (linkId <= 0) return [];
if (linkId < 0) return [];

return FindAll(_.Category == category & _.LinkID == linkId);
}
Expand All @@ -323,7 +323,7 @@ public static IList<MemberLog> FindAllByCategoryAndLinkID(String? category, Int3
/// <returns>实体列表</returns>
public static IList<MemberLog> FindAllByCreateUserID(Int32 createUserId)
{
if (createUserId <= 0) return [];
if (createUserId < 0) return [];

return FindAll(_.CreateUserID == createUserId);
}
Expand Down
6 changes: 3 additions & 3 deletions XUnitTest.XCode/Code/Entity/日志.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public override Object? this[String name]
/// <returns>实体对象</returns>
public static Log? FindByID(Int64 id)
{
if (id <= 0) return null;
if (id < 0) return null;

return Find(_.ID == id);
}
Expand All @@ -304,7 +304,7 @@ public static IList<Log> FindAllByActionAndCategory(String? action, String? cate
public static IList<Log> FindAllByCategoryAndLinkID(String? category, Int32 linkId)
{
if (category == null) return [];
if (linkId <= 0) return [];
if (linkId < 0) return [];

return FindAll(_.Category == category & _.LinkID == linkId);
}
Expand All @@ -314,7 +314,7 @@ public static IList<Log> FindAllByCategoryAndLinkID(String? category, Int32 link
/// <returns>实体列表</returns>
public static IList<Log> FindAllByCreateUserID(Int32 createUserId)
{
if (createUserId <= 0) return [];
if (createUserId < 0) return [];

return FindAll(_.CreateUserID == createUserId);
}
Expand Down
4 changes: 2 additions & 2 deletions XUnitTest.XCode/Code/Entity/用户.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ public override Object? this[String name]
/// <returns>实体对象</returns>
public static User? FindByID(Int32 id)
{
if (id <= 0) return null;
if (id < 0) return null;

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ID == id);
Expand Down Expand Up @@ -546,7 +546,7 @@ public static IList<User> FindAllByCode(String? code)
/// <returns>实体列表</returns>
public static IList<User> FindAllByRoleID(Int32 roleId)
{
if (roleId <= 0) return [];
if (roleId < 0) return [];

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.RoleID == roleId);
Expand Down
6 changes: 3 additions & 3 deletions XUnitTest.XCode/Code/Entity/用户日志.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public override Object? this[String name]
/// <returns>实体对象</returns>
public static UserLog? FindByID(Int64 id)
{
if (id <= 0) return null;
if (id < 0) return null;

return Find(_.ID == id);
}
Expand All @@ -315,7 +315,7 @@ public static IList<UserLog> FindAllByActionAndCategory(String? action, String?
public static IList<UserLog> FindAllByCategoryAndLinkID(String? category, Int32 linkId)
{
if (category == null) return [];
if (linkId <= 0) return [];
if (linkId < 0) return [];

return FindAll(_.Category == category & _.LinkID == linkId);
}
Expand All @@ -325,7 +325,7 @@ public static IList<UserLog> FindAllByCategoryAndLinkID(String? category, Int32
/// <returns>实体列表</returns>
public static IList<UserLog> FindAllByCreateUserID(Int32 createUserId)
{
if (createUserId <= 0) return [];
if (createUserId < 0) return [];

return FindAll(_.CreateUserID == createUserId);
}
Expand Down
2 changes: 1 addition & 1 deletion XUnitTest.XCode/Code/Entity/租户.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public override Object? this[String name]
/// <returns>实体对象</returns>
public static Tenant? FindById(Int32 id)
{
if (id <= 0) return null;
if (id < 0) return null;

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Id == id);
Expand Down
10 changes: 5 additions & 5 deletions XUnitTest.XCode/Code/Entity/租户关系.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public override Object? this[String name]
/// <returns>实体对象</returns>
public static TenantUser? FindById(Int32 id)
{
if (id <= 0) return null;
if (id < 0) return null;

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Id == id);
Expand All @@ -246,8 +246,8 @@ public override Object? this[String name]
/// <returns>实体对象</returns>
public static TenantUser? FindByTenantIdAndUserId(Int32 tenantId, Int32 userId)
{
if (tenantId <= 0) return null;
if (userId <= 0) return null;
if (tenantId < 0) return null;
if (userId < 0) return null;

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.TenantId == tenantId && e.UserId == userId);
Expand All @@ -260,7 +260,7 @@ public override Object? this[String name]
/// <returns>实体列表</returns>
public static IList<TenantUser> FindAllByTenantId(Int32 tenantId)
{
if (tenantId <= 0) return [];
if (tenantId < 0) return [];

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.TenantId == tenantId);
Expand All @@ -273,7 +273,7 @@ public static IList<TenantUser> FindAllByTenantId(Int32 tenantId)
/// <returns>实体列表</returns>
public static IList<TenantUser> FindAllByUserId(Int32 userId)
{
if (userId <= 0) return [];
if (userId < 0) return [];

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.UserId == userId);
Expand Down
6 changes: 3 additions & 3 deletions XUnitTest.XCode/Code/Entity/菜单.cs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public override Object? this[String name]
/// <returns>实体对象</returns>
public static Menu? FindByID(Int32 id)
{
if (id <= 0) return null;
if (id < 0) return null;

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ID == id);
Expand Down Expand Up @@ -403,7 +403,7 @@ public static IList<Menu> FindAllByName(String name)
/// <returns>实体对象</returns>
public static Menu? FindByParentIDAndName(Int32 parentId, String name)
{
if (parentId <= 0) return null;
if (parentId < 0) return null;
if (name.IsNullOrEmpty()) return null;

// 实体缓存
Expand All @@ -417,7 +417,7 @@ public static IList<Menu> FindAllByName(String name)
/// <returns>实体列表</returns>
public static IList<Menu> FindAllByParentID(Int32 parentId)
{
if (parentId <= 0) return [];
if (parentId < 0) return [];

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.ParentID == parentId);
Expand Down
2 changes: 1 addition & 1 deletion XUnitTest.XCode/Code/Entity/角色.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public override Object? this[String name]
/// <returns>实体对象</returns>
public static Role? FindByID(Int32 id)
{
if (id <= 0) return null;
if (id < 0) return null;

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ID == id);
Expand Down
6 changes: 3 additions & 3 deletions XUnitTest.XCode/Code/Entity/部门.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public override Object? this[String name]
/// <returns>实体对象</returns>
public static Department? FindByID(Int32 id)
{
if (id <= 0) return null;
if (id < 0) return null;

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ID == id);
Expand Down Expand Up @@ -411,7 +411,7 @@ public static IList<Department> FindAllByName(String name)
/// <returns>实体列表</returns>
public static IList<Department> FindAllByParentIDAndName(Int32 parentId, String name)
{
if (parentId <= 0) return [];
if (parentId < 0) return [];
if (name.IsNullOrEmpty()) return [];

// 实体缓存
Expand All @@ -438,7 +438,7 @@ public static IList<Department> FindAllByCode(String? code)
/// <returns>实体列表</returns>
public static IList<Department> FindAllByTenantId(Int32 tenantId)
{
if (tenantId <= 0) return [];
if (tenantId < 0) return [];

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.TenantId == tenantId);
Expand Down
6 changes: 3 additions & 3 deletions XUnitTest.XCode/Code/entity_log_normal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public override Object? this[String name]
/// <returns>实体对象</returns>
public static Log? FindByID(Int64 id)
{
if (id <= 0) return null;
if (id < 0) return null;

return Find(_.ID == id);
}
Expand All @@ -272,7 +272,7 @@ public static IList<Log> FindAllByActionAndCategory(String action, String? categ
public static IList<Log> FindAllByCategoryAndLinkID(String? category, Int64 linkId)
{
if (category == null) return [];
if (linkId <= 0) return [];
if (linkId < 0) return [];

return FindAll(_.Category == category & _.LinkID == linkId);
}
Expand All @@ -282,7 +282,7 @@ public static IList<Log> FindAllByCategoryAndLinkID(String? category, Int64 link
/// <returns>实体列表</returns>
public static IList<Log> FindAllByCreateUserID(Int32 createUserId)
{
if (createUserId <= 0) return [];
if (createUserId < 0) return [];

return FindAll(_.CreateUserID == createUserId);
}
Expand Down
6 changes: 3 additions & 3 deletions XUnitTest.XCode/Code/entity_user_normal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ public override Object? this[String name]
/// <returns>实体对象</returns>
public static User? FindByID(Int32 id)
{
if (id <= 0) return null;
if (id < 0) return null;

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ID == id);
Expand Down Expand Up @@ -539,7 +539,7 @@ public static IList<User> FindAllByCode(String? code)
/// <returns>实体列表</returns>
public static IList<User> FindAllByRoleID(Int32 roleId)
{
if (roleId <= 0) return [];
if (roleId < 0) return [];

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.RoleID == roleId);
Expand All @@ -552,7 +552,7 @@ public static IList<User> FindAllByRoleID(Int32 roleId)
/// <returns>实体列表</returns>
public static IList<User> FindAllByDepartmentID(Int32 departmentId)
{
if (departmentId <= 0) return [];
if (departmentId < 0) return [];

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.DepartmentID == departmentId);
Expand Down
2 changes: 1 addition & 1 deletion XUnitTest.XCode/Model/Code/entity_city.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public static IList<CorePerson> FindAllByPname(String pname)
/// <returns>实体列表</returns>
public static IList<CorePerson> FindAllByBuildID(Int32 buildId)
{
if (buildId <= 0) return [];
if (buildId < 0) return [];

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.BuildID == buildId);
Expand Down
4 changes: 2 additions & 2 deletions XUnitTest.XCode/Model/Code/entity_city_biz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public override Boolean Valid(DataMethod method)
/// <returns>实体对象</returns>
public static CorePerson FindByPersonID(Int32 personId)
{
if (personId <= 0) return null;
if (personId < 0) return null;

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.PersonID == personId);
Expand All @@ -143,7 +143,7 @@ public static CorePerson FindByPersonID(Int32 personId)
/// <returns>实体列表</returns>
public static IList<CorePerson> FindAllByBuild_ID(Int32 build_ID)
{
if (build_ID <= 0) return new List<CorePerson>();
if (build_ID < 0) return new List<CorePerson>();

// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Build_ID == build_ID);
Expand Down

0 comments on commit 8ad43ea

Please sign in to comment.