From 79db330e1b30131d83e562b36b677634661806ad Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Mon, 17 Oct 2022 16:23:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Common/DTO/DictionaryModel.cs | 32 ++++++++- .../Service/Common/DictionaryService.cs | 70 ++++++++++++++++++- .../Service/Common/_MapConfig.cs | 3 +- 3 files changed, 100 insertions(+), 5 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Common/DTO/DictionaryModel.cs b/IRaCIS.Core.Application/Service/Common/DTO/DictionaryModel.cs index ad5ecfaf..93d56066 100644 --- a/IRaCIS.Core.Application/Service/Common/DTO/DictionaryModel.cs +++ b/IRaCIS.Core.Application/Service/Common/DTO/DictionaryModel.cs @@ -20,7 +20,24 @@ namespace IRaCIS.Application.Contracts public class GetTrialConfigDictionaryListOutDto { - + + public Guid Id { get; set; } + + public Guid DictionaryId { get; set; } + + public int ShowOrder { get; set; } + + public string Description { get; set; } = string.Empty; + + public string Code { get; set; } + + public string ParentCode { get; set; } + + public string ChildGroup { get; set; } + + public string Value { get; set; } = string.Empty; + + public string ValueCN { get; set; } = string.Empty; } public class GetTrialConfigDictionaryListInDto @@ -33,6 +50,19 @@ namespace IRaCIS.Application.Contracts } + public class GetTrialConfigDictionarySelectOutDto: BasicDicView + { + public bool IsAdded { get; set; } + } + + public class GetTrialConfigDictionarySelectInDto + { + [NotDefault] + public Guid TrialId { get; set; } + + public string Code { get; set; } + } + public class AddTrialConfigDictionaryListInDto { [NotDefault] diff --git a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs index 76102e3c..a8363ccd 100644 --- a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs +++ b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Application.Contracts; +using IRaCIS.Core.Infra.EFCore.Common; namespace IRaCIS.Application.Services { @@ -136,11 +137,52 @@ namespace IRaCIS.Application.Services } + /// + /// 删除项目字典 + /// + /// + /// + [HttpPost("{Id:guid}")] + public async Task DeleteTrialConfigDictionary(Guid Id) + { + await _trialConfigDictionaryRepository.DeleteFromQueryAsync(Id); + await _trialConfigDictionaryRepository.SaveChangesAsync(); + return ResponseOutput.Ok(true); + } + + + /// + /// 获取待添加的项目字典数据 + /// + /// + /// + [HttpPost] + public async Task> GetTrialConfigDictionarySelect(GetTrialConfigDictionarySelectInDto inDto) + { + var parentId = await _dicRepository.Where(x => x.Code == inDto.Code).Select(x => x.Id).FirstNotNullAsync(); + + List result= await _dicRepository.Where(t => t.ParentId == parentId) + .OrderBy(t => t.ShowOrder).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + + + + List addIds = await _trialConfigDictionaryRepository.Where(x => x.Dictionary.ParentId == parentId).Select(x => x.DictionaryId).ToListAsync(); + + result.ForEach(x => { + x.IsAdded = addIds.Contains(x.Id.Value); + }); + + return result; + + } + + /// /// 批量添加项目字典 /// /// /// + [HttpPost] public async Task AddTrialConfigDictionaryList(AddTrialConfigDictionaryListInDto inDto) { @@ -155,11 +197,33 @@ namespace IRaCIS.Application.Services return ResponseOutput.Ok(true); } + /// + /// 获取项目字典 + /// + /// + /// + [HttpPost] + public async Task> GetTrialConfigDictionaryList(GetTrialConfigDictionaryListInDto inDto) + { + List result = await _trialConfigDictionaryRepository.Where(x => x.TrialId == inDto.TrialId) + .WhereIf(!inDto.ParentCode.IsNullOrEmpty(), x => x.Dictionary.Parent.Code == inDto.ParentCode) + .Select(x => new GetTrialConfigDictionaryListOutDto() + { + Id=x.Id, + DictionaryId=x.DictionaryId, + ChildGroup = x.Dictionary.ChildGroup, + Code = x.Dictionary.Code, + Description = x.Dictionary.Description, + ShowOrder = x.Dictionary.ShowOrder, + ParentCode = x.Dictionary.Parent.Code, + Value = x.Dictionary.Value, + ValueCN = x.Dictionary.ValueCN + }).OrderBy(x => x.ParentCode).ThenBy(x => x.ShowOrder).ToListAsync(); + return result; + } + - //public async Task<> GetTrialConfigDictionaryList(GetTrialConfigDictionaryListInDto inDto) - //{ - //} /// diff --git a/IRaCIS.Core.Application/Service/Common/_MapConfig.cs b/IRaCIS.Core.Application/Service/Common/_MapConfig.cs index fee1b758..4844a569 100644 --- a/IRaCIS.Core.Application/Service/Common/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Common/_MapConfig.cs @@ -30,7 +30,8 @@ namespace IRaCIS.Core.Application.Service CreateMap().ReverseMap(); - + CreateMap() + .ForMember(o => o.ConfigType, t => t.MapFrom(u => u.ConfigDictionary.Code)); CreateMap() .ForMember(o => o.ConfigType, t => t.MapFrom(u => u.ConfigDictionary.Code));