diff --git a/XCode/Membership/Member.xml b/XCode/Membership/Member.xml
index 40662c24b..5b0a91e28 100644
--- a/XCode/Membership/Member.xml
+++ b/XCode/Membership/Member.xml
@@ -118,7 +118,7 @@
-
+
@@ -151,7 +151,8 @@
-
+
+
diff --git a/XCode/Membership/Membership.htm b/XCode/Membership/Membership.htm
index a324933f8..8634ba6cc 100644
--- a/XCode/Membership/Membership.htm
+++ b/XCode/Membership/Membership.htm
@@ -782,7 +782,7 @@ 角色(Role)
String |
50 |
|
- UQ |
+ |
N |
|
diff --git "a/XCode/Membership/\350\247\222\350\211\262.cs" "b/XCode/Membership/\350\247\222\350\211\262.cs"
index c20749020..2bbdc786b 100644
--- "a/XCode/Membership/\350\247\222\350\211\262.cs"
+++ "b/XCode/Membership/\350\247\222\350\211\262.cs"
@@ -17,7 +17,8 @@ namespace XCode.Membership;
[Serializable]
[DataObject]
[Description("角色。业务场景中的岗位,功能权限的集合。不管是用户还是租户,都以角色来管理权限")]
-[BindIndex("IU_Role_Name", true, "Name")]
+[BindIndex("IX_Role_Name", false, "Name")]
+[BindIndex("IX_Role_TenantId_Name", false, "TenantId,Name")]
[BindTable("Role", Description = "角色。业务场景中的岗位,功能权限的集合。不管是用户还是租户,都以角色来管理权限", ConnName = "Membership", DbType = DatabaseType.None)]
public partial class Role : IRole, IEntity
{
@@ -320,6 +321,33 @@ public override Object? this[String name]
#endregion
#region 扩展查询
+ /// 根据名称查找
+ /// 名称
+ /// 实体列表
+ public static IList FindAllByName(String name)
+ {
+ if (name.IsNullOrEmpty()) return [];
+
+ // 实体缓存
+ if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Name.EqualIgnoreCase(name));
+
+ return FindAll(_.Name == name);
+ }
+
+ /// 根据租户、名称查找
+ /// 租户
+ /// 名称
+ /// 实体列表
+ public static IList FindAllByTenantIdAndName(Int32 tenantId, String name)
+ {
+ if (tenantId < 0) return [];
+ if (name.IsNullOrEmpty()) return [];
+
+ // 实体缓存
+ if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.TenantId == tenantId && e.Name.EqualIgnoreCase(name));
+
+ return FindAll(_.TenantId == tenantId & _.Name == name);
+ }
#endregion
#region 字段名
diff --git "a/XCode/Membership/\351\203\250\351\227\250.cs" "b/XCode/Membership/\351\203\250\351\227\250.cs"
index 2cff0a8ae..8c5b28058 100644
--- "a/XCode/Membership/\351\203\250\351\227\250.cs"
+++ "b/XCode/Membership/\351\203\250\351\227\250.cs"
@@ -17,7 +17,7 @@ namespace XCode.Membership;
[Serializable]
[DataObject]
[Description("部门。组织机构,多级树状结构,支持多租户")]
-[BindIndex("IU_Department_TenantId_ParentID_Name", true, "TenantId,ParentID,Name")]
+[BindIndex("IX_Department_TenantId_ParentID_Name", false, "TenantId,ParentID,Name")]
[BindIndex("IX_Department_Name", false, "Name")]
[BindIndex("IX_Department_ParentID_Name", false, "ParentID,Name")]
[BindIndex("IX_Department_Code", false, "Code")]
@@ -380,32 +380,17 @@ public override Object? this[String name]
/// 租户
/// 父级
/// 名称
- /// 实体对象
- public static Department? FindByTenantIdAndParentIDAndName(Int32 tenantId, Int32 parentId, String name)
- {
- if (tenantId < 0) return null;
- if (parentId < 0) return null;
- if (name.IsNullOrEmpty()) return null;
-
- // 实体缓存
- if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.TenantId == tenantId && e.ParentID == parentId && e.Name.EqualIgnoreCase(name));
-
- return Find(_.TenantId == tenantId & _.ParentID == parentId & _.Name == name);
- }
-
- /// 根据租户、父级查找
- /// 租户
- /// 父级
/// 实体列表
- public static IList FindAllByTenantIdAndParentID(Int32 tenantId, Int32 parentId)
+ public static IList FindAllByTenantIdAndParentIDAndName(Int32 tenantId, Int32 parentId, String name)
{
if (tenantId < 0) return [];
if (parentId < 0) return [];
+ if (name.IsNullOrEmpty()) return [];
// 实体缓存
- if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.TenantId == tenantId && e.ParentID == parentId);
+ if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.TenantId == tenantId && e.ParentID == parentId && e.Name.EqualIgnoreCase(name));
- return FindAll(_.TenantId == tenantId & _.ParentID == parentId);
+ return FindAll(_.TenantId == tenantId & _.ParentID == parentId & _.Name == name);
}
/// 根据代码查找