diff --git a/src/Shentun.WebPeis.Application/Questions/QuestionAppService.cs b/src/Shentun.WebPeis.Application/Questions/QuestionAppService.cs index 8965ac5..1d8da58 100644 --- a/src/Shentun.WebPeis.Application/Questions/QuestionAppService.cs +++ b/src/Shentun.WebPeis.Application/Questions/QuestionAppService.cs @@ -127,7 +127,7 @@ namespace Shentun.WebPeis.Questions [HttpPost("api/app/Question/Update")] public async Task UpdateAsync(UpdateQuestionDto input) { - var entity = await _questionRepository.GetAsync(f => f.QuestionTypeId == input.QuestionTypeId); + var entity = await _questionRepository.GetAsync(f => f.QuestionId == input.QuestionId); var sourceEntity = ObjectMapper.Map(input); _questionManager.UpdateAsync(sourceEntity, entity); entity = await _questionRepository.UpdateAsync(entity); diff --git a/src/Shentun.WebPeis.Domain/QuestionAnswers/QuestionAnswerManager.cs b/src/Shentun.WebPeis.Domain/QuestionAnswers/QuestionAnswerManager.cs index d1bfd2a..f76d0f7 100644 --- a/src/Shentun.WebPeis.Domain/QuestionAnswers/QuestionAnswerManager.cs +++ b/src/Shentun.WebPeis.Domain/QuestionAnswers/QuestionAnswerManager.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; +using Volo.Abp; using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Services; @@ -17,12 +18,13 @@ namespace Shentun.WebPeis.QuestionAnswers public class QuestionAnswerManager : DomainService { private readonly IRepository _questionAnswerRepository; - + private readonly IRepository _questionRegisterAnswerRepository; public QuestionAnswerManager( - IRepository questionAnswerRepository - ) + IRepository questionAnswerRepository, + IRepository questionRegisterAnswerRepository) { _questionAnswerRepository = questionAnswerRepository; + _questionRegisterAnswerRepository = questionRegisterAnswerRepository; } /// @@ -71,7 +73,7 @@ namespace Shentun.WebPeis.QuestionAnswers DataHelper.CheckEntityIsNull(targetEntity); //DataHelper.CheckStringIsNull(sourceEntity.QuestionTypeName, "名称"); - + targetEntity.HealthGuidance = sourceEntity.HealthGuidance; targetEntity.Aliases = sourceEntity.Aliases; @@ -85,7 +87,7 @@ namespace Shentun.WebPeis.QuestionAnswers targetEntity.Reason = sourceEntity.Reason; targetEntity.QuestionId = sourceEntity.QuestionId; targetEntity.SimpleCode = LanguageConverter.GetPYSimpleCode(sourceEntity.QuestionAnswerName); - + } @@ -99,11 +101,11 @@ namespace Shentun.WebPeis.QuestionAnswers public async Task CheckAndDeleteAsync(Guid QuestionAnswerId) { - //var questionEnt = await _questionRepository.FirstOrDefaultAsync(m => m.QuestionTypeId == QuestionTypeId); - //if (questionEnt != null) - //{ - // throw new UserFriendlyException($"问卷类别已被使用,不能删除"); - //} + var questionRegisterAnswerEnt = await _questionRegisterAnswerRepository.FirstOrDefaultAsync(m => m.QuestionAnswerId == QuestionAnswerId); + if (questionRegisterAnswerEnt != null) + { + throw new UserFriendlyException($"问卷答案已被人员登记使用,不能删除"); + } await _questionAnswerRepository.DeleteAsync(d => d.QuestionAnswerId == QuestionAnswerId); diff --git a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/DiseaseRiskLevelConfigure.cs b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/DiseaseRiskLevelConfigure.cs index 25a14a6..c78b356 100644 --- a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/DiseaseRiskLevelConfigure.cs +++ b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/DiseaseRiskLevelConfigure.cs @@ -18,7 +18,8 @@ namespace Shentun.WebPeis.Configures entity.ToTable("disease_risk_level"); - entity.HasIndex(e => e.DiseaseRiskLevelName, "ix_disease_risk_level").IsUnique(); + + entity.Property(e => e.DiseaseRiskLevelId) .ValueGeneratedNever()