From 0a5bcb3eb270be2786677dc748dcbbfe9f9d58e1 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 29 Jun 2023 10:38:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B7=BB=E5=8A=A0=E5=AD=97?= =?UTF-8?q?=E5=85=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Common/DTO/DictionaryModel.cs | 45 +++++++++++++++-- .../Service/Common/DictionaryService.cs | 48 ++++++++++++++----- .../Service/Common/_MapConfig.cs | 3 ++ 3 files changed, 80 insertions(+), 16 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Common/DTO/DictionaryModel.cs b/IRaCIS.Core.Application/Service/Common/DTO/DictionaryModel.cs index 39549319..60b8aba6 100644 --- a/IRaCIS.Core.Application/Service/Common/DTO/DictionaryModel.cs +++ b/IRaCIS.Core.Application/Service/Common/DTO/DictionaryModel.cs @@ -78,6 +78,43 @@ namespace IRaCIS.Application.Contracts } + public class AddBasicDicAndChild + { + [NotDefault] + public Guid ConfigTypeId { get; set; } + + public bool IsEnable { get; set; } + + public string Code { get; set; } = String.Empty; + + public int ShowOrder { get; set; } + public string Description { get; set; } = String.Empty; + + public DicDataTypeEnum DataTypeEnum { get; set; } + + + public List ChildList { get; set;}=new List(); + } + + + public class AddBasicDicChild + { + public string Code { get; set; } = String.Empty; + public string Value { get; set; } = String.Empty; + + public string ValueCN { get; set; } = String.Empty; + + public string ChildGroup { get; set; } = String.Empty; + + public int ShowOrder { get; set; } + + public string Description { get; set; } = String.Empty; + + public bool IsEnable { get; set; } = true; + } + + + public class GetCriterionDictionaryInDto { public Guid? ReadingCriterionId { get; set; } @@ -113,7 +150,7 @@ namespace IRaCIS.Application.Contracts } - public class BasicDicSelectCopy:BasicDicSelect + public class BasicDicSelectCopy : BasicDicSelect { } @@ -138,12 +175,12 @@ namespace IRaCIS.Application.Contracts public DicDataTypeEnum DataTypeEnum { get; set; } - public bool IsEnumInt => System.Text.RegularExpressions.Regex.IsMatch(Code, @"^[-+]?\d*$") && DataTypeEnum== DicDataTypeEnum.Enum; + public bool IsEnumInt => System.Text.RegularExpressions.Regex.IsMatch(Code, @"^[-+]?\d*$") && DataTypeEnum == DicDataTypeEnum.Enum; } - public class BasicDicQuery:PageInput + public class BasicDicQuery : PageInput { public string? keyInfo { get; set; } @@ -181,7 +218,7 @@ namespace IRaCIS.Application.Contracts public class DicViewModelDTO : AddOrUpdateDicDTO { - + } diff --git a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs index 11e02a51..8913d4b1 100644 --- a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs +++ b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs @@ -127,16 +127,6 @@ namespace IRaCIS.Application.Services }; - //// 验证阅片标准是否可禁用 - //if (!addOrEditBasic.IsEnable&&addOrEditBasic.Id!=null) - //{ - // var result = await _readingQuestionService.SetSystemCriterionDisable(addOrEditBasic.Id.Value,addOrEditBasic.ParentId); - // if (!result.IsSuccess) - // { - // return result; - // } - //} - if (addOrEditBasic.Id != null && addOrEditBasic.ParentId==null) { @@ -153,6 +143,42 @@ namespace IRaCIS.Application.Services return ResponseOutput.Ok(entity.Id.ToString()); } + + + /// + /// 添加字典 的同时 一起添加子项 --New + /// + /// + /// + [HttpPost] + public async Task AddBasicDicAndChild(AddBasicDicAndChild addBasicDicAndChild) + { + var verifyExp1 = new EntityVerifyExp() + { + VerifyExp = t => t.Code == addBasicDicAndChild.Code && t.ParentId == null, + VerifyMsg = $"已有{addBasicDicAndChild.Code}名称的字典", + IsVerify = true + }; + + + var entity = await _dicRepository.InsertFromDTOAsync(addBasicDicAndChild, false, verifyExp1); + + var childList = _mapper.Map>(addBasicDicAndChild.ChildList); + + foreach (var item in childList) + { + item.DataTypeEnum = addBasicDicAndChild.DataTypeEnum; + item.ParentId = entity.Id; + } + + await _dicRepository.AddRangeAsync(childList); + + await _dicRepository.SaveChangesAsync(); + return ResponseOutput.Ok(entity.Id.ToString()); + } + + + /// /// 获取子项数组 /// @@ -227,8 +253,6 @@ namespace IRaCIS.Application.Services } - - /// /// 根据父亲字典分组 获取子项 /// diff --git a/IRaCIS.Core.Application/Service/Common/_MapConfig.cs b/IRaCIS.Core.Application/Service/Common/_MapConfig.cs index 142c56b3..eeb64e0b 100644 --- a/IRaCIS.Core.Application/Service/Common/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Common/_MapConfig.cs @@ -39,6 +39,9 @@ namespace IRaCIS.Core.Application.Service CreateMap().ReverseMap(); + CreateMap() .ForMember(o => o.ChildList, t => t.Ignore()); + CreateMap(); + CreateMap() .ForMember(o => o.ParentChildCodeEnum, t => t.MapFrom(u => u.Parent.ChildCodeEnum)) .ForMember(o => o.Value, t => t.MapFrom(u => u.MappedValue))