diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index c4d65f6dd..d8d66fcaa 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -1083,16 +1083,6 @@ - - - 编辑项目中Site 基本信息 - - - - - - - 删除 项目 下某一site diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialSiteViewModel.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialSiteViewModel.cs index b1d70c993..30cdcb7cc 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialSiteViewModel.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialSiteViewModel.cs @@ -33,7 +33,6 @@ namespace IRaCIS.Core.Application.Contracts.DTO public class EditTrialSiteCommand { - //Guid id, Guid trialId, string trialSiteCode, string? trialSiteAliasName [NotDefault] public Guid TrialId { get; set; } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs index b3569b667..098533f4a 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs @@ -13,7 +13,6 @@ namespace IRaCIS.Application.Contracts public bool IsDeleted { get; set; } - public DateTime? RemoveTime { get; set; } public Guid? SiteId { get; set; } public string Phone { get; set; } = String.Empty; public DateTime UpdateTime { get; set; } @@ -37,10 +36,14 @@ namespace IRaCIS.Application.Contracts public class TrialMaintenanceDTO : UserTrialCommand { public bool IsDeleted { get; set; } + + public DateTime? DeletedTime { get; set; } + public DateTime? RemoveTime { get; set; } public DateTime? JoinTime { get; set; } + public DateTime CreateTime { get; set; } public DateTime UpdateTime { get; set; } = DateTime.Now; @@ -117,6 +120,9 @@ namespace IRaCIS.Application.Contracts public string TrialSiteAliasName { get; set; } = String.Empty; public bool IsDeleted { get; set; } + + public DateTime? DeletedTime { get; set; } + public DateTime UpdateTime { get; set; } public string Site { get; set; } = String.Empty; diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/Interface/ITrialSiteService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/Interface/ITrialSiteService.cs index 748ed3c81..306554843 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/Interface/ITrialSiteService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/Interface/ITrialSiteService.cs @@ -10,7 +10,6 @@ namespace IRaCIS.Core.Application.Interfaces Task AssignSiteCRC(List trialSiteCRCList); Task DeleteSiteCRC(Guid id, bool isDelete); Task DeleteTrialSite(Guid id); - Task EditTrialSite(Guid id, Guid trialId, string trialSiteCode, string? trialSiteAliasName); Task> GetSiteCRCList(SiteCrcQueryDTO param); Task> GetSiteCRCSimpleList(SiteCrcQueryDTO param); Task> GetTrialSiteScreeningList(TrialSiteQuery trialSiteQuery); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs index 5c2dcd14e..685718b34 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs @@ -31,8 +31,6 @@ namespace IRaCIS.Application.Services .WhereIf(param.UserTypeId!=null, t => t.User.UserTypeId==param.UserTypeId) .WhereIf(!string.IsNullOrWhiteSpace(param.UserName), t => t.User.UserName.Contains(param.UserName)) - //.WhereIf( param.JoinTime!=null, t => t.JoinTime.to ==param.JoinTime.ToString("yyyy-MM-dd")) - //.WhereIf(param.RemoveTime!=null, t => t.RemoveTime.ToString("yyyy-MM-dd") == param.JoinTime.ToString("yyyy-MM-dd")) .WhereIf(param.IsDeleted != null, t => t.IsDeleted == param.IsDeleted) .WhereIf(!string.IsNullOrWhiteSpace(param.OrganizationName), t => t.User.OrganizationName.Contains(param.OrganizationName)) .WhereIf(!string.IsNullOrWhiteSpace(param.UserRealName), t => (t.User.LastName + " / " + t.User.FirstName).Contains(param.UserRealName)) diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs index c52089778..3a4e1ec98 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs @@ -14,10 +14,12 @@ namespace IRaCIS.Core.Application.Services public class TrialMaintenanceService : BaseService, ITrialSiteService { private readonly IRepository _trialSiteRepository; + private readonly IRepository _trialSiteUserRepository; - public TrialMaintenanceService(IRepository trialSiteRepository) + public TrialMaintenanceService(IRepository trialSiteRepository,IRepository trialSiteUserRepository) { _trialSiteRepository = trialSiteRepository; + _trialSiteUserRepository = trialSiteUserRepository; } /// Pannel 进去 SiteTab @@ -71,7 +73,7 @@ namespace IRaCIS.Core.Application.Services [HttpGet, Route("{trialId:guid}/{siteId:guid}")] public async Task> GetTrialSiteCRCList(Guid trialId, Guid siteId) { - var query = _repository.Where(t => t.TrialId == trialId && t.SiteId == siteId).IgnoreQueryFilters() + var query = _trialSiteUserRepository.Where(t => t.TrialId == trialId && t.SiteId == siteId).IgnoreQueryFilters() .ProjectTo(_mapper.ConfigurationProvider); return await query.ToListAsync(); @@ -149,6 +151,8 @@ namespace IRaCIS.Core.Application.Services //{ // return ResponseOutput.NotOk("The site has been uploaded study, and couldn't be deleted."); //} + + } else { @@ -168,30 +172,47 @@ namespace IRaCIS.Core.Application.Services } - /// - /// 编辑项目中Site 基本信息 - /// - /// - /// - /// - /// - /// - [UnitOfWork] - [HttpPost("{trialId:guid}/{id:guid}/{trialSiteCode}/{trialSiteAliasName?}")] + + /// 批量添加Site下 CRC的负责人 + [HttpPost] + [TrialAudit(AuditType.TrialAudit, AuditOptType.AddTrialSiteCRC)] [TypeFilter(typeof(TrialResourceFilter))] - [Obsolete] - public async Task EditTrialSite(Guid id, Guid trialId, string trialSiteCode, string? trialSiteAliasName) + public async Task AssignSiteCRC(List trialSiteCRCList) { + var addArray = _mapper.Map>(trialSiteCRCList); - if (await _trialSiteRepository.AnyAsync(t => t.Id != id && t.TrialSiteCode == trialSiteCode && t.TrialId == trialId && t.IsDeleted == false, true)) - { - return ResponseOutput.NotOk("Code is not allowed to be repeated"); - } + await _repository.AddRangeAsync(addArray); - await _trialSiteRepository.UpdateFromQueryAsync(t => t.Id == id, u => new TrialSite() { TrialSiteCode = trialSiteCode, TrialSiteAliasName = trialSiteAliasName ?? String.Empty }); - await _repository.SaveChangesAsync(); + return ResponseOutput.Result(await _repository.SaveChangesAsync()); + } - return ResponseOutput.Ok(); + /// 删除CRC人员 + [HttpDelete, Route("{id:guid}/{trialId:guid}/{isDelete:bool}")] + [TypeFilter(typeof(TrialResourceFilter))] + public async Task DeleteSiteCRC(Guid id, bool isDelete) + { + var isSuccess = await _repository.UpdateFromQueryAsync(u => u.Id == id, u => new TrialSiteUser() + { IsDeleted = isDelete, DeletedTime = isDelete ? DateTime.Now : null }); + + return ResponseOutput.Result(isSuccess); + } + + /// + /// 获取项目下的 site 下拉框数据 CRC只看到他负责的 + /// + /// + /// + [HttpGet("{trialId:guid}")] + public async Task> GetTrialSiteSelect(Guid trialId) + { + //CRC只看到他负责的 + + var list = await _trialSiteRepository.Where(t => t.TrialId == trialId) + .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator, t => t.CRCUserList.Any(t => t.UserId == _userInfo.Id)) + .ProjectTo(_mapper.ConfigurationProvider).OrderBy(t => t.TrialSiteCode).ToListAsync(); + + + return list; } @@ -229,52 +250,5 @@ namespace IRaCIS.Core.Application.Services } - - /// 批量添加Site下 CRC的负责人 - [HttpPost] - [TrialAudit(AuditType.TrialAudit, AuditOptType.AddTrialSiteCRC)] - [TypeFilter(typeof(TrialResourceFilter))] - public async Task AssignSiteCRC(List trialSiteCRCList) - { - var addArray = _mapper.Map>(trialSiteCRCList); - - await _repository.AddRangeAsync(addArray); - - return ResponseOutput.Result(await _repository.SaveChangesAsync()); - } - - /// 删除CRC人员 - [HttpDelete, Route("{id:guid}/{trialId:guid}/{isDelete:bool}")] - - //[TrialAudit(AuditType.TrialAudit, AuditOptType.DeleteTrialSiteCRC)] - [TypeFilter(typeof(TrialResourceFilter))] - public async Task DeleteSiteCRC(Guid id, bool isDelete) - { - var isSuccess = await _repository.UpdateFromQueryAsync(u => u.Id == id, u => new TrialSiteUser() - { IsDeleted = isDelete, RemoveTime = isDelete ? DateTime.Now : null }); - - return ResponseOutput.Result(isSuccess); - - } - - /// - /// 获取项目下的 site 下拉框数据 CRC只看到他负责的 - /// - /// - /// - [HttpGet("{trialId:guid}")] - public async Task> GetTrialSiteSelect(Guid trialId) - { - //CRC只看到他负责的 - - var list = await _trialSiteRepository.Where(t => t.TrialId == trialId) - .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator, t => t.CRCUserList.Any(t => t.UserId == _userInfo.Id)) - .ProjectTo(_mapper.ConfigurationProvider).OrderBy(t => t.TrialSiteCode).ToListAsync(); - - - return list; - } - - } } \ No newline at end of file diff --git a/IRaCIS.Core.Domain/BaseModel/ISoftDelete.cs b/IRaCIS.Core.Domain/BaseModel/ISoftDelete.cs index b8da28ade..4ec763857 100644 --- a/IRaCIS.Core.Domain/BaseModel/ISoftDelete.cs +++ b/IRaCIS.Core.Domain/BaseModel/ISoftDelete.cs @@ -2,10 +2,12 @@ namespace IRaCIS.Core.Domain.Models { - + public interface ISoftDelete { bool IsDeleted { get; set; } + + public DateTime? DeletedTime { get; set; } } } diff --git a/IRaCIS.Core.Domain/Image/DicomSeries.cs b/IRaCIS.Core.Domain/Image/DicomSeries.cs index 8096be173..97df3cf33 100644 --- a/IRaCIS.Core.Domain/Image/DicomSeries.cs +++ b/IRaCIS.Core.Domain/Image/DicomSeries.cs @@ -56,6 +56,7 @@ namespace IRaCIS.Core.Domain.Models public DateTime UpdateTime { get; set; } = DateTime.Now; public bool IsDeleted {get;set;} + public DateTime? DeletedTime { get; set; } public bool IsReading { get; set; } = true; diff --git a/IRaCIS.Core.Domain/Image/DicomStudy.cs b/IRaCIS.Core.Domain/Image/DicomStudy.cs index 6325d73c2..aeb943890 100644 --- a/IRaCIS.Core.Domain/Image/DicomStudy.cs +++ b/IRaCIS.Core.Domain/Image/DicomStudy.cs @@ -100,6 +100,8 @@ namespace IRaCIS.Core.Domain.Models //软删除 public bool IsDeleted { get; set; } + public DateTime? DeletedTime { get; set; } + } } diff --git a/IRaCIS.Core.Domain/TrialSiteUser/TrialSite.cs b/IRaCIS.Core.Domain/TrialSiteUser/TrialSite.cs index 49dab1665..d1b4e52f7 100644 --- a/IRaCIS.Core.Domain/TrialSiteUser/TrialSite.cs +++ b/IRaCIS.Core.Domain/TrialSiteUser/TrialSite.cs @@ -21,6 +21,7 @@ namespace IRaCIS.Core.Domain.Models public DateTime UpdateTime { get; set; } public bool IsDeleted { get; set; } + public DateTime? DeletedTime { get; set; } //导航属性 diff --git a/IRaCIS.Core.Domain/TrialSiteUser/TrialSiteUser.cs b/IRaCIS.Core.Domain/TrialSiteUser/TrialSiteUser.cs index ac0f8e2d8..4a220b32a 100644 --- a/IRaCIS.Core.Domain/TrialSiteUser/TrialSiteUser.cs +++ b/IRaCIS.Core.Domain/TrialSiteUser/TrialSiteUser.cs @@ -40,20 +40,13 @@ namespace IRaCIS.Core.Domain.Models public bool IsDeleted { get; set; } + public DateTime? DeletedTime { get; set; } + public DateTime? RemoveTime { get; set; } - //public Guid UserTypeId { get; set; } - //public string UserType { get; set; } = string.Empty; - //public string UserRealName { get; set; } = string.Empty; - //public UserType UserTypeEnum { get; set; } - - - - - [ForeignKey("UserId")] @@ -68,11 +61,6 @@ namespace IRaCIS.Core.Domain.Models - //public DicomStudy DicomStudy { get; set; } - - //public Subject Subject {get;set;} - - //TrialId 不管 其实就是 User和Site 的中间关系表 [ForeignKey("SiteId")] public TrialSite TrialSite { get; set; } diff --git a/IRaCIS.Core.Domain/TrialSiteUser/TrialUser.cs b/IRaCIS.Core.Domain/TrialSiteUser/TrialUser.cs index f5ab6f199..7704d7a38 100644 --- a/IRaCIS.Core.Domain/TrialSiteUser/TrialUser.cs +++ b/IRaCIS.Core.Domain/TrialSiteUser/TrialUser.cs @@ -23,19 +23,6 @@ namespace IRaCIS.Core.Domain.Models public List SiteList { get; set; } - // 0 ʾ 1 ʾͣ - //public int JoinState { get; set; } - - //Ѿȷϵ Ŀĵ - //public List TrialDocUserConfirmedList { get; set; } - //////һû ϶Ӧһû ͨûUserTypeId Ϊ ϵ ֶ - //public TrialDocNeedConfirmedUserType TrialDocNeedConfirmedUserType { get; set; } - //public List TrialDocumentList { get; set; } - //public Guid UserTypeId { get; set; } - //public string UserRealName { get; set; } - //public string UserType { get; set; } - //public UserType UserTypeEnum { get; set; } - public Guid UpdateUserId { get; set; } public DateTime UpdateTime { get; set; } @@ -44,6 +31,9 @@ namespace IRaCIS.Core.Domain.Models public bool IsDeleted { get; set; } + public DateTime? DeletedTime { get; set; } + + public DateTime? RemoveTime { get; set; } public DateTime? JoinTime { get; set; } diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index 192e1eefc..13b9a930b 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -305,6 +305,15 @@ namespace IRaCIS.Core.Infra.EFCore updateEntity1.UpdateTime = DateTime.UtcNow.AddHours(8); updateEntity1.UpdateUserId = _userInfo.Id; } + + if(t.Entity is ISoftDelete updateEntity2) + { + if (updateEntity2.IsDeleted == true) + { + updateEntity2.DeletedTime = DateTime.UtcNow.AddHours(8); + } + } + break; //添加的时候,更新审计字段也赋值 case EntityState.Added: