diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 8a0f0bf29..c476667bc 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -11278,6 +11278,11 @@ 系统邮件配置表 + + + 系统邮件配置表 + + ISystemBasicDataService diff --git a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs index 5cc7a99ba..f6ef4a91e 100644 --- a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs +++ b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs @@ -88,6 +88,14 @@ namespace IRaCIS.Application.Services IsVerify = true }; + + if((addBasicDicAndChild.DataTypeEnum == DicDataTypeEnum.Enum || addBasicDicAndChild.DataTypeEnum == DicDataTypeEnum.Bool)) + { + if(addBasicDicAndChild.ChildList.GroupBy(t => t.Code).Where(g => g.Count() > 1).Any()) + { + return ResponseOutput.NotOk(_localizer["Dictionary_RepeateCode"]); + } + } var entity = await _dicRepository.InsertFromDTOAsync(addBasicDicAndChild, false, verifyExp1); @@ -148,16 +156,15 @@ namespace IRaCIS.Application.Services IsVerify = addOrEditBasic.ParentId == null }; + var verifyExp2 = new EntityVerifyExp() + { + VerifyExp = t => t.Code == addOrEditBasic.Code && t.ParentId == addOrEditBasic.ParentId && t.Code==addOrEditBasic.Code, + + VerifyMsg = _localizer["Dictionary_RepeateCode"], + + IsVerify = addOrEditBasic.ParentId != null && (addOrEditBasic.DataTypeEnum == DicDataTypeEnum.Enum || addOrEditBasic.DataTypeEnum == DicDataTypeEnum.Bool) + }; - //// 验证阅片标准是否可禁用 - //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) @@ -167,7 +174,7 @@ namespace IRaCIS.Application.Services //await _dicRepository.BatchUpdateNoTrackingAsync(t => t.ParentId == addOrEditBasic.Id, c => new Dictionary() { DataTypeEnum = addOrEditBasic.DataTypeEnum }); } - var entity = await _dicRepository.InsertOrUpdateAsync(addOrEditBasic, true, verifyExp1); + var entity = await _dicRepository.InsertOrUpdateAsync(addOrEditBasic, true, verifyExp1, verifyExp2); diff --git a/IRaCIS.Core.Application/Service/Common/EmailNoticeConfigService.cs b/IRaCIS.Core.Application/Service/Common/EmailNoticeConfigService.cs index a9d45632e..b8b910bfc 100644 --- a/IRaCIS.Core.Application/Service/Common/EmailNoticeConfigService.cs +++ b/IRaCIS.Core.Application/Service/Common/EmailNoticeConfigService.cs @@ -14,17 +14,10 @@ namespace IRaCIS.Core.Application.Contracts /// 系统邮件配置表 /// [ApiExplorerSettings(GroupName = "Common")] - public class EmailNoticeConfigService : BaseService, IEmailNoticeConfigService + public class EmailNoticeConfigService(IRepository _emailNoticeConfigrepository, + IRepository _emailNoticeUserTypeRepository) : BaseService, IEmailNoticeConfigService { - private readonly IRepository _emailNoticeConfigrepository; - private readonly IRepository _emailNoticeUserTypeRepository; - - public EmailNoticeConfigService(IRepository repository, IRepository emailNoticeUserTypeRepository) - { - _emailNoticeConfigrepository = repository; - _emailNoticeUserTypeRepository = emailNoticeUserTypeRepository; - } - + [HttpPost] public async Task> GetEmailNoticeConfigList(EmailNoticeConfigQuery queryEmailNoticeConfig) { @@ -44,6 +37,14 @@ namespace IRaCIS.Core.Application.Contracts public async Task AddOrUpdateEmailNoticeConfig(EmailNoticeConfigAddOrEdit addOrEditEmailNoticeConfig) { + var verifyExp1 = new EntityVerifyExp() + { + VerifyExp = t => t.BusinessScenarioEnum == addOrEditEmailNoticeConfig.BusinessScenarioEnum, + + VerifyMsg = _localizer["EmailNoticeConfig_RepeatEmailScenario"] + }; + + if (addOrEditEmailNoticeConfig.Id == null) { @@ -63,7 +64,7 @@ namespace IRaCIS.Core.Application.Contracts } - await _emailNoticeConfigrepository.AddAsync(entity, true); + await _emailNoticeConfigrepository.AddAsync(entity, true, verifyExp1); return ResponseOutput.Ok(entity.Id.ToString()); } @@ -86,7 +87,7 @@ namespace IRaCIS.Core.Application.Contracts } - var entity = await _emailNoticeConfigrepository.UpdateFromDTOAsync(addOrEditEmailNoticeConfig, true); + var entity = await _emailNoticeConfigrepository.UpdateFromDTOAsync(addOrEditEmailNoticeConfig, true, false,verifyExp1); return ResponseOutput.Ok(entity.Id.ToString()); diff --git a/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs b/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs index eab56bef7..aa3bfc347 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs @@ -96,7 +96,7 @@ namespace IRaCIS.Core.Infra.EFCore } - public interface ICommandRepository where TEntity : class + public interface ICommandRepository where TEntity : Entity { EntityEntry Attach(TEntity entity); @@ -128,7 +128,7 @@ namespace IRaCIS.Core.Infra.EFCore Task CountAsync(Expression> whereLambda = null, bool ignoreQueryFilters = false); - ValueTask AddAsync(TEntity entity, bool autoSave = false); + ValueTask AddAsync(TEntity entity, bool autoSave = false, params EntityVerifyExp[] verify); Task> AddRangeAsync(IEnumerable entities, bool autoSave = false); diff --git a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs index f9adfda52..d8daf48a1 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs @@ -62,8 +62,9 @@ namespace IRaCIS.Core.Infra.EFCore } /// EF跟踪方式 添加 - public async ValueTask AddAsync(TEntity entity, bool autoSave = false) + public async ValueTask AddAsync(TEntity entity, bool autoSave = false, params EntityVerifyExp[] verify) { + await _dbContext.EntityVerifyAsync(true, verify); await _dbSet.AddAsync(entity).ConfigureAwait(false);