Uat_Study
he 2023-02-03 14:54:26 +08:00
parent dc0de31164
commit bed17af3b2
2 changed files with 10 additions and 8 deletions

View File

@ -202,7 +202,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
public Guid SystemCriterionId { get; set; } public Guid SystemCriterionId { get; set; }
[NotDefault] [NotDefault]
public string Code { get; set; } public List<string> CodeList { get; set; }
} }

View File

@ -80,16 +80,18 @@ namespace IRaCIS.Core.Application.Service.RC
[HttpPost] [HttpPost]
public async Task<IResponseOutput> AddSystemCriterionDictionaryCode(AddSystemCriterionDictionaryCodeInDto inDto) public async Task<IResponseOutput> AddSystemCriterionDictionaryCode(AddSystemCriterionDictionaryCodeInDto inDto)
{ {
if (await _systemCriterionDictionaryCodeRepository.AnyAsync(x => x.SystemCriterionId == inDto.SystemCriterionId && x.Code == inDto.Code))
{
throw new BusinessValidationFailedException("当前标准存在此Code");
}
await _systemCriterionDictionaryCodeRepository.AddAsync(new SystemCriterionDictionaryCode() var codes= await _systemCriterionDictionaryCodeRepository.Where(x => x.SystemCriterionId == inDto.SystemCriterionId).Select(x => x.Code).ToListAsync();
inDto.CodeList= inDto.CodeList.Except(codes).ToList();
await _systemCriterionDictionaryCodeRepository.AddRangeAsync(inDto.CodeList.Select(x=> new SystemCriterionDictionaryCode()
{ {
SystemCriterionId = inDto.SystemCriterionId, SystemCriterionId = inDto.SystemCriterionId,
Code = inDto.Code Code = x
}); }).ToList());
await _systemCriterionDictionaryCodeRepository.SaveChangesAsync(); await _systemCriterionDictionaryCodeRepository.SaveChangesAsync();