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..22513a761 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); @@ -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.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..b26a608c8 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 BaseFullAuditEntity2 : 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..ab9be7a36 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 : BaseFullAuditEntity2 { [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..ef37dfa3e 100644 --- a/IRaCIS.Core.Domain/Management/User.cs +++ b/IRaCIS.Core.Domain/Management/User.cs @@ -9,8 +9,9 @@ public class UserRole : BaseFullAuditEntity { #region - [JsonIgnore] - public IdentityUser IdentityUser { get; set; } + //[NotMapped] + //[JsonIgnore] + //public IdentityUser IdentityUser { 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.Infra.EFCore/EntityConfigration/SubjectConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs index 733c3434a..e8c37d88d 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/SubjectConfigration.cs @@ -51,7 +51,6 @@ 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); } } @@ -71,19 +70,17 @@ 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..12aa90fdc 100644 --- a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj +++ b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj @@ -21,17 +21,18 @@ - + - - - + + + + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj index ee616207e..0d0760041 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