From 4048c286285cb3c02d2d95d7a7ce6e534b7102e0 Mon Sep 17 00:00:00 2001 From: hang <87227557@qq.com> Date: Fri, 15 Aug 2025 21:08:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7efcore=20=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=86=85=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Management/UserService.cs | 10 +++++----- IRaCIS.Core.Domain/BaseModel/Entity.cs | 4 ++-- IRaCIS.Core.Domain/Management/HospitalGroup.cs | 2 +- IRaCIS.Core.Domain/Management/User.cs | 10 +++++----- IRaCIS.Core.Domain/Management/UserType.cs | 3 --- IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs | 1 - .../EntityConfigration/SubjectConfigration.cs | 5 ++++- .../IRaCIS.Core.Infra.EFCore.csproj | 6 +++--- .../IRaCIS.Core.Infrastructure.csproj | 2 +- IRaCIS.Core.Test/IRaCIS.Core.Test.csproj | 6 +++--- 10 files changed, 24 insertions(+), 25 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index 22513a761..00e8d1f84 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -1224,11 +1224,11 @@ namespace IRaCIS.Core.Application.Service IdentityUserId = t.IdentityUserId, UserTypeEnum = t.UserTypeEnum, UserTypeId = t.UserTypeId, - //IsTestUser = t.IdentityUser.IsTestUser, - //IsZhiZhun = t.IdentityUser.IsZhiZhun, - //FullName = t.IdentityUser.FullName, - //PermissionStr = t.UserTypeRole.PermissionStr, - //UserName = t.IdentityUser.UserName, + IsTestUser = t.IdentityUser.IsTestUser, + IsZhiZhun = t.IdentityUser.IsZhiZhun, + FullName = t.IdentityUser.FullName, + PermissionStr = t.UserTypeRole.PermissionStr, + UserName = t.IdentityUser.UserName, UserTypeShortName = t.UserTypeRole.UserTypeShortName, }).FirstOrDefaultAsync(); diff --git a/IRaCIS.Core.Domain/BaseModel/Entity.cs b/IRaCIS.Core.Domain/BaseModel/Entity.cs index b26a608c8..80c150139 100644 --- a/IRaCIS.Core.Domain/BaseModel/Entity.cs +++ b/IRaCIS.Core.Domain/BaseModel/Entity.cs @@ -110,14 +110,14 @@ public abstract class BaseFullAuditEntity : Entity, IAuditUpdate, IAuditAdd public UserRole CreateUserRole { get; set; } } -public abstract class BaseFullAuditEntity2 : Entity, IAuditUpdate, IAuditAdd +public abstract class BaseFullAuditEntityNoNavigat : Entity, IAuditUpdate, IAuditAdd { public Guid CreateUserId { get; set; } public DateTime CreateTime { get; set; } public Guid UpdateUserId { get; set; } public DateTime UpdateTime { get; set; } - } + public abstract class BaseFullDeleteAuditEntity : Entity, IAuditUpdate, IAuditAdd, ISoftDelete { public Guid? DeleteUserId { get; set; } diff --git a/IRaCIS.Core.Domain/Management/HospitalGroup.cs b/IRaCIS.Core.Domain/Management/HospitalGroup.cs index ab9be7a36..e72625fcc 100644 --- a/IRaCIS.Core.Domain/Management/HospitalGroup.cs +++ b/IRaCIS.Core.Domain/Management/HospitalGroup.cs @@ -40,7 +40,7 @@ namespace IRaCIS.Core.Domain.Models [Comment("后台 - 系统真实账户表")] [Table("IdentityUser")] - public class IdentityUser : BaseFullAuditEntity2 + public class IdentityUser : BaseFullAuditEntityNoNavigat { [JsonIgnore] diff --git a/IRaCIS.Core.Domain/Management/User.cs b/IRaCIS.Core.Domain/Management/User.cs index ef37dfa3e..49564675b 100644 --- a/IRaCIS.Core.Domain/Management/User.cs +++ b/IRaCIS.Core.Domain/Management/User.cs @@ -5,17 +5,17 @@ namespace IRaCIS.Core.Domain.Models; [Comment("̨ - ϵͳ˻")] [Table("User")] -public class UserRole : BaseFullAuditEntity +public class UserRole : BaseFullAuditEntityNoNavigat { #region - //[NotMapped] - //[JsonIgnore] - //public IdentityUser IdentityUser { get; set; } + //[ForeignKey("IdentityUserId")] + [JsonIgnore] + public IdentityUser IdentityUser { get; set; } [JsonIgnore] - public List UserRoleTrials { get; set; } = new List(); + public List UserRoleTrials { get; set; } [JsonIgnore] diff --git a/IRaCIS.Core.Domain/Management/UserType.cs b/IRaCIS.Core.Domain/Management/UserType.cs index 8a9f5e37f..b449c72d3 100644 --- a/IRaCIS.Core.Domain/Management/UserType.cs +++ b/IRaCIS.Core.Domain/Management/UserType.cs @@ -11,9 +11,6 @@ public class UserType : Entity [JsonIgnore] public List UserTypeGroupList { get; set; } - - [JsonIgnore] - public List UserList { get; set; } #endregion public UserTypeEnum UserTypeEnum { get; set; } diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index de8d84675..33026d115 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -373,7 +373,6 @@ public class IRaCISDBContext : DbContext public virtual DbSet VerificationCodes { get; set; } public virtual DbSet MenuFunctions { get; set; } public virtual DbSet UserTypeMenuFunction { get; set; } - public virtual DbSet Users { get; set; } public virtual DbSet UserType { get; set; } diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs index e8c37d88d..2f4d53669 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs @@ -51,6 +51,8 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration //User 和VisitTask 存在一对多的关系 这里不显式配置就报错,why? builder.HasMany(t => t.VisitTaskList).WithOne(t => t.DoctorUser).HasForeignKey(t => t.DoctorUserId); + //builder.HasOne(t => t.IdentityUser).WithMany(t => t.UserRoleList).HasForeignKey(t => t.IdentityUserId); + } } @@ -76,9 +78,10 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration // public void Configure(EntityTypeBuilder builder) // { // builder.HasMany(s => s.UserRoleList) - // .WithOne(t => t.IdentityUser) + // .WithOne(t=>t.IdentityUser) // .HasForeignKey(s => s.IdentityUserId); + // } //} diff --git a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj index 12aa90fdc..d0b656afe 100644 --- a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj +++ b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj @@ -31,12 +31,12 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj index cac011aba..3550e28f4 100644 --- a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj +++ b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj @@ -14,7 +14,7 @@ - + diff --git a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj index 0d0760041..8e62a5b0f 100644 --- a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj +++ b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj @@ -50,10 +50,10 @@ - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive