diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.csproj b/IRaCIS.Core.API/IRaCIS.Core.API.csproj index cd48e2095..2fb16ca58 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.csproj +++ b/IRaCIS.Core.API/IRaCIS.Core.API.csproj @@ -75,10 +75,10 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + - + diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj index e829ee14b..ac9c48a21 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj @@ -40,7 +40,6 @@ - diff --git a/IRaCIS.Core.Application/Service/Common/MailService.cs b/IRaCIS.Core.Application/Service/Common/MailService.cs index 09ba95a37..a408f4e47 100644 --- a/IRaCIS.Core.Application/Service/Common/MailService.cs +++ b/IRaCIS.Core.Application/Service/Common/MailService.cs @@ -30,7 +30,6 @@ namespace IRaCIS.Core.Application.Service Task AdminResetPwdSendEmailAsync(Guid userId, string pwdNotMd5 = "123456"); - Task UserFeedBackMail(Guid feedBackId); } public class MailVerificationService(IRepository _verificationCodeRepository, @@ -421,154 +420,5 @@ namespace IRaCIS.Core.Application.Service - //用户反馈邮件 - - public async Task UserFeedBackMail(Guid feedBackId) - { - var feedBack = await _userFeedBackRepository.Where(t => t.Id == feedBackId).Include(t => t.CreateUserRole).ThenInclude(t => t.UserTypeRole).FirstNotNullAsync(); - - var messageToSend = new MimeMessage(); - //发件地址 - messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail)); - - var isHaveTrialId = feedBack.TrialId != null; - - var companyName = _userInfo.IsEn_Us ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN; - - var emialScenario = feedBack.VisitTaskId != null ? EmailBusinessScenario.IRImageError : (feedBack.SubjectVisitId != null ? EmailBusinessScenario.TrialSubjectVisitFeedBack : (feedBack.TrialId != null ? EmailBusinessScenario.TrialFeedBack : EmailBusinessScenario.SysFeedBack)); - - var emailConfigInfo = await GetEmailConfigInfoAsync(emialScenario); - - var userTypeEnumList = emailConfigInfo.EmailNoticeUserTypeList.Where(t => t.EmailUserType == EmailUserType.To).Select(t => t.UserType).ToList(); - - var emailList = await _userRoleRepository.Where(t => userTypeEnumList.Contains(t.UserTypeEnum) && - (isHaveTrialId ? t.UserTrials.Any(t => t.TrialId == feedBack.TrialId) : true)).Select(t => new { t.EMail, t.UserTypeEnum, t.FullName }).ToListAsync(); - - - foreach (var email in emailList) - { - messageToSend.To.Add(new MailboxAddress(email.FullName, email.EMail)); - } - - var userNames = string.Join(',', emailList.Select(t => t.FullName)); - - //影像阅片反馈 pm - if (feedBack.VisitTaskId != null) - { - - var emailType = await _dictionaryRepository.Where(t => t.Parent.Code == "Email_BusinessScenario" && t.ParentId != null && t.Code == ((int)EmailBusinessScenario.IRImageError).ToString()).Select(t => _userInfo.IsEn_Us ? t.Value : t.ValueCN).FirstOrDefaultAsync(); - - - var info = await _visitTaskRepository.Where(t => t.Id == feedBack.VisitTaskId).Select(t => new { t.Trial.ResearchProgramNo, t.Trial.TrialCode, SubejctCode = t.Subject.Code, t.SourceSubjectVisit.VisitName }).FirstNotNullAsync(); - - Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input => - { - var topicStr = string.Format(input.topicStr, info.ResearchProgramNo, info.SubejctCode, info.VisitName); - - var htmlBodyStr = string.Format(ReplaceCompanyName(input.htmlBodyStr), - userNames, - info.TrialCode, - info.SubejctCode, - info.VisitName, - feedBack.CreateUserRole.UserTypeRole.UserTypeShortName, - feedBack.CreateUserRole.FullName, - emailType, - feedBack.QuestionDescription, - _systemEmailConfig.SiteUrl - ); - - return (topicStr, htmlBodyStr); - }; - - - await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.IRImageError, messageToSend, emailConfigFunc); - - } - else if (feedBack.SubjectVisitId != null) - { - var emailType = await _dictionaryRepository.Where(t => t.Parent.Code == "Email_BusinessScenario" && t.ParentId != null && t.Code == ((int)EmailBusinessScenario.TrialSubjectVisitFeedBack).ToString()).Select(t => _userInfo.IsEn_Us ? t.Value : t.ValueCN).FirstOrDefaultAsync(); - - - var info = await _subjectVisitRepository.Where(t => t.Id == feedBack.SubjectVisitId).Select(t => new { t.Trial.ResearchProgramNo, t.Trial.TrialCode, SubejctCode = t.Subject.Code, t.VisitName }).FirstNotNullAsync(); - - Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input => - { - var topicStr = string.Format(input.topicStr, info.ResearchProgramNo, info.SubejctCode, info.VisitName); - - var htmlBodyStr = string.Format(ReplaceCompanyName(input.htmlBodyStr), - userNames, - info.TrialCode, - info.SubejctCode, - info.VisitName, - feedBack.CreateUserRole.UserTypeRole.UserTypeShortName, - feedBack.CreateUserRole.FullName, - emailType, - feedBack.QuestionDescription, - _systemEmailConfig.SiteUrl - ); - - return (topicStr, htmlBodyStr); - }; - - - await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.TrialSubjectVisitFeedBack, messageToSend, emailConfigFunc); - } - //项目相关的反馈 pm admin - else if (feedBack.TrialId != null) - { - - var emailType = await _dictionaryRepository.Where(t => t.Parent.Code == "Email_BusinessScenario" && t.ParentId != null && t.Code == ((int)EmailBusinessScenario.TrialFeedBack).ToString()).Select(t => _userInfo.IsEn_Us ? t.Value : t.ValueCN).FirstOrDefaultAsync(); - - - var info = await _trialRepository.Where(t => t.Id == feedBack.TrialId).Select(t => new { t.ResearchProgramNo, t.TrialCode }).FirstNotNullAsync(); - - Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input => - { - var topicStr = string.Format(input.topicStr, info.ResearchProgramNo); - - var htmlBodyStr = string.Format(ReplaceCompanyName(input.htmlBodyStr), - userNames, - info.TrialCode, - feedBack.CreateUserRole.UserTypeRole.UserTypeShortName, - feedBack.CreateUserRole.FullName, - emailType, - feedBack.QuestionDescription, - _systemEmailConfig.SiteUrl - ); - - return (topicStr, htmlBodyStr); - }; - - - await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.TrialFeedBack, messageToSend, emailConfigFunc); - - } - //项目无关的反馈 admin - else - { - - - Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input => - { - var topicStr = string.Format(input.topicStr); - - var htmlBodyStr = string.Format(ReplaceCompanyName(input.htmlBodyStr), - userNames, - feedBack.CreateUserRole.UserTypeRole.UserTypeShortName, - feedBack.CreateUserRole.FullName, - feedBack.QuestionDescription, - _systemEmailConfig.SiteUrl - ); - - return (topicStr, htmlBodyStr); - }; - - - await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.SysFeedBack, messageToSend, emailConfigFunc); - } - - await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig); - - } } } diff --git a/IRaCIS.Core.Application/Service/Management/UserFeedBackService.cs b/IRaCIS.Core.Application/Service/Management/UserFeedBackService.cs index 3083adfc1..d4418dd59 100644 --- a/IRaCIS.Core.Application/Service/Management/UserFeedBackService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserFeedBackService.cs @@ -114,7 +114,7 @@ namespace IRaCIS.Core.Application.Service //任务反馈的添加更新都需要发送邮件,其他的是添加的时候发送 if (addOrEditUserFeedBack.VisitTaskId != null || addOrEditUserFeedBack.Id == null) { - await mailService.UserFeedBackMail(entity.Id); + //await mailService.UserFeedBackMail(entity.Id); } return ResponseOutput.Ok(entity.Id.ToString()); diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index fff35de2a..00e8d1f84 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -944,7 +944,7 @@ namespace IRaCIS.Core.Application.Service { await _fusionCache.RemoveAsync(CacheKeys.UserToken(identityUserId)); - var userName = await _userRoleRepository.Where(t => t.Id == userRoleId).Select(t => t.IdentityUser.UserName).FirstOrDefaultAsync(); + var userName = await _userRoleRepository.Where(t => t.Id == userRoleId).Select(t => t.UserName).FirstOrDefaultAsync(); await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = identityUserId, ActionUserName = userName, OptType = UserOptType.LoginOut }, true); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs index b4cdaf420..4dcab7c27 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs @@ -105,7 +105,7 @@ namespace IRaCIS.Core.Application.Service .ForMember(d => d.UserType, u => u.MapFrom(s => s.UserTypeRole.UserTypeShortName)) .ForMember(d => d.UserId, u => u.MapFrom(s => s.Id)) .ForMember(d => d.TrialId, u => u.MapFrom(s => trialId)) - .ForMember(d => d.IsSelect, u => u.MapFrom(t => t.UserTrials.Any(t => t.TrialId == trialId))); + .ForMember(d => d.IsSelect, u => u.MapFrom(t => t.UserRoleTrials.Any(t => t.TrialId == trialId))); CreateMap() diff --git a/IRaCIS.Core.Domain/BaseModel/Entity.cs b/IRaCIS.Core.Domain/BaseModel/Entity.cs index 55847a041..80c150139 100644 --- a/IRaCIS.Core.Domain/BaseModel/Entity.cs +++ b/IRaCIS.Core.Domain/BaseModel/Entity.cs @@ -109,6 +109,15 @@ public abstract class BaseFullAuditEntity : Entity, IAuditUpdate, IAuditAdd [JsonIgnore] public UserRole CreateUserRole { get; set; } } + +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 04882d186..e72625fcc 100644 --- a/IRaCIS.Core.Domain/Management/HospitalGroup.cs +++ b/IRaCIS.Core.Domain/Management/HospitalGroup.cs @@ -40,14 +40,14 @@ namespace IRaCIS.Core.Domain.Models [Comment("后台 - 系统真实账户表")] [Table("IdentityUser")] - public class IdentityUser : BaseFullAuditEntity + public class IdentityUser : BaseFullAuditEntityNoNavigat { [JsonIgnore] public List UserTrialList { get; set; } [JsonIgnore] - public List UserRoleList { get; set; } = new List(); + public List UserRoleList { get; set; } [Projectable] diff --git a/IRaCIS.Core.Domain/Management/User.cs b/IRaCIS.Core.Domain/Management/User.cs index e8969dbab..49564675b 100644 --- a/IRaCIS.Core.Domain/Management/User.cs +++ b/IRaCIS.Core.Domain/Management/User.cs @@ -5,16 +5,17 @@ namespace IRaCIS.Core.Domain.Models; [Comment("̨ - ϵͳ˻")] [Table("User")] -public class UserRole : BaseFullAuditEntity +public class UserRole : BaseFullAuditEntityNoNavigat { #region + //[ForeignKey("IdentityUserId")] [JsonIgnore] public IdentityUser IdentityUser { get; set; } [JsonIgnore] - public List UserRoleTrials { get; set; } = new List(); + public List UserRoleTrials { get; set; } [JsonIgnore] @@ -22,9 +23,6 @@ public class UserRole : BaseFullAuditEntity public UserType UserTypeRole { get; set; } - [JsonIgnore] - public List UserTrials { get; set; } = new List(); - [JsonIgnore] public List VisitTaskList { get; set; } 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 733c3434a..2f4d53669 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs @@ -51,7 +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.Doctor).WithOne(t => t.User); + //builder.HasOne(t => t.IdentityUser).WithMany(t => t.UserRoleList).HasForeignKey(t => t.IdentityUserId); + } } @@ -71,19 +72,18 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration } } - public class IdentityUserConfigration : IEntityTypeConfiguration - { - //当一个实体,针对同一个类,有两个一对一导航属性,但是是不同的外键,一个外键是一对一,一个是一对多,那么需要显示配置一对多的关系 - public void Configure(EntityTypeBuilder builder) - { - builder.HasMany(s => s.UserRoleList) - .WithOne(t => t.IdentityUser) - .HasForeignKey(s => s.IdentityUserId); + //public class IdentityUserConfigration : IEntityTypeConfiguration + //{ + // //当一个实体,针对同一个类,有两个一对一导航属性,但是是不同的外键,一个外键是一对一,一个是一对多,那么需要显示配置一对多的关系 + // public void Configure(EntityTypeBuilder builder) + // { + // builder.HasMany(s => s.UserRoleList) + // .WithOne(t=>t.IdentityUser) + // .HasForeignKey(s => s.IdentityUserId); - - } - } + // } + //} public class TrialIdentityUserConfigration : IEntityTypeConfiguration diff --git a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj index 383747676..d0b656afe 100644 --- a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj +++ b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj @@ -21,21 +21,22 @@ - + - - - + + + + - - + + 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 ee616207e..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