From 60accb2f87c23ddaec1de016a5915fcd73f87b4b Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Wed, 4 Jun 2025 14:21:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Document/DTO/SystemDocumentViewModel.cs | 46 +++++++++++++++++ .../Document/DTO/TrialDocumentViewModel.cs | 1 + .../Service/Document/TrialDocumentService.cs | 50 +++++++++++++++++++ .../Service/Document/_MapConfig.cs | 3 ++ IRaCIS.Core.Domain/Document/TrialDocument.cs | 2 +- 5 files changed, 101 insertions(+), 1 deletion(-) diff --git a/IRaCIS.Core.Application/Service/Document/DTO/SystemDocumentViewModel.cs b/IRaCIS.Core.Application/Service/Document/DTO/SystemDocumentViewModel.cs index d19563995..dd2a41d35 100644 --- a/IRaCIS.Core.Application/Service/Document/DTO/SystemDocumentViewModel.cs +++ b/IRaCIS.Core.Application/Service/Document/DTO/SystemDocumentViewModel.cs @@ -370,6 +370,52 @@ namespace IRaCIS.Core.Application.Contracts public List Ids { get; set; } } + public class TrialDocumentAttachmentView : TrialDocumentAttachmentAddOrEdit + { + + public DateTime CreateTime { get; set; } + + public DateTime UpdateTime { get; set; } + + } + + + public class TrialDocumentAttachmentAddOrEdit + { + public Guid? Id { get; set; } + + public string FileFormat { get; set; } + + public string FileName { get; set; } + + public string FilePath { get; set; } + + public decimal? FileSize { get; set; } + + public string Name { get; set; } + + public bool OffLine { get; set; } + + public Guid TrialDocumentId { get; set; } + } + + public class TrialDocumentAttachmentQuery : PageInput + { + public string? FileFormat { get; set; } + + public string? FileName { get; set; } + + public string? FilePath { get; set; } + + public decimal? FileSize { get; set; } + + public string? Name { get; set; } + + public bool? OffLine { get; set; } + + public Guid? TrialDocumentId { get; set; } + } + public class AddOrEditSystemDocument : SystemDocumentAddOrEdit { diff --git a/IRaCIS.Core.Application/Service/Document/DTO/TrialDocumentViewModel.cs b/IRaCIS.Core.Application/Service/Document/DTO/TrialDocumentViewModel.cs index 36d16b663..d6f281023 100644 --- a/IRaCIS.Core.Application/Service/Document/DTO/TrialDocumentViewModel.cs +++ b/IRaCIS.Core.Application/Service/Document/DTO/TrialDocumentViewModel.cs @@ -13,6 +13,7 @@ namespace IRaCIS.Core.Application.Contracts { public string FullFilePath { get; set; } = String.Empty; + public int AttachmentCount { get; set; } public bool IsSomeUserSigned { get; set; } public DateTime CreateTime { get; set; } diff --git a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs index a2fe41a6b..4306464eb 100644 --- a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs @@ -26,6 +26,7 @@ namespace IRaCIS.Core.Application.Services [ApiExplorerSettings(GroupName = "Trial")] public class TrialDocumentService(IRepository _trialDocumentRepository, IRepository _trialRepository, + IRepository _trialDocumentAttachmentRepository, ISystemDocumentService _systemDocumentService, IRepository _systemDocConfirmedUserRepository, IRepository _systemDocNeedConfirmedUserTypeRepository, @@ -39,6 +40,55 @@ namespace IRaCIS.Core.Application.Services IRepository _readingQuestionCriterionTrialRepository, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, ITrialDocumentService { + + /// + /// 获取项目文档附件列表 + /// + /// + /// + [HttpPost] + public async Task> GetTrialDocumentAttachmentList(TrialDocumentAttachmentQuery inQuery) + { + + var trialDocumentAttachmentQueryable = _trialDocumentAttachmentRepository + .WhereIf(inQuery.TrialDocumentId!=null,x=>x.TrialDocumentId==inQuery.TrialDocumentId) + .WhereIf(inQuery.Name != null, x => x.Name.Contains(inQuery.Name)) + .WhereIf(inQuery.FileFormat != null, x => x.FileFormat == inQuery.FileFormat) + .ProjectTo(_mapper.ConfigurationProvider); + + var pageList = await trialDocumentAttachmentQueryable.ToPagedListAsync(inQuery); + + return pageList; + } + + + /// + /// 添加或更新项目文档附件 + /// + /// + /// + public async Task AddOrUpdateTrialDocumentAttachment(TrialDocumentAttachmentAddOrEdit addOrEditTrialDocumentAttachment) + { + // 在此处拷贝automapper 映射 + + var entity = await _trialDocumentAttachmentRepository.InsertOrUpdateAsync(addOrEditTrialDocumentAttachment, true); + + return ResponseOutput.Ok(entity.Id.ToString()); + + } + + /// + /// 删除项目文档附件 + /// + /// + /// + [HttpDelete("{trialDocumentAttachmentId:guid}")] + public async Task DeleteTrialDocumentAttachment(Guid trialDocumentAttachmentId) + { + var success = await _trialDocumentAttachmentRepository.DeleteFromQueryAsync(t => t.Id == trialDocumentAttachmentId, true); + return ResponseOutput.Ok(); + } + /// /// 发布项目文档 /// diff --git a/IRaCIS.Core.Application/Service/Document/_MapConfig.cs b/IRaCIS.Core.Application/Service/Document/_MapConfig.cs index 0cd170208..3418be142 100644 --- a/IRaCIS.Core.Application/Service/Document/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Document/_MapConfig.cs @@ -16,6 +16,8 @@ namespace IRaCIS.Core.Application.Service var isEn_Us = false; // 在此处拷贝automapper 映射 + CreateMap(); + CreateMap().ReverseMap(); CreateMap(); CreateMap().ReverseMap(); @@ -40,6 +42,7 @@ namespace IRaCIS.Core.Application.Service .ForMember(dest => dest.CreateUserRole, opt => opt.Ignore()); CreateMap() + .ForMember(d => d.AttachmentCount, u => u.MapFrom(s =>s.TrialDocumentAttachmentList)) .ForMember(d => d.FileType, u => u.MapFrom(s => isEn_Us ? s.FileType.Value : s.FileType.ValueCN)) .ForMember(d => d.IsSomeUserSigned, u => u.MapFrom(s => s.TrialDocConfirmedUserList.Any(t => t.ConfirmTime != null))) .ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path)); diff --git a/IRaCIS.Core.Domain/Document/TrialDocument.cs b/IRaCIS.Core.Domain/Document/TrialDocument.cs index fde813162..8e9e989c8 100644 --- a/IRaCIS.Core.Domain/Document/TrialDocument.cs +++ b/IRaCIS.Core.Domain/Document/TrialDocument.cs @@ -14,7 +14,7 @@ public class TrialDocument : BaseFullDeleteAuditEntity [JsonIgnore] - public List SystemDocumentAttachmentList { get; set; } + public List TrialDocumentAttachmentList { get; set; } [JsonIgnore] [ForeignKey("FileTypeId")]