using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Shentun.Peis.AsbitemDetails; using Shentun.Peis.Models; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Volo.Abp.Application.Services; using Volo.Abp.Domain.Repositories; namespace Shentun.Peis.Suggestions { /// /// 诊断建议 /// [ApiExplorerSettings(GroupName = "Work")] [Authorize] public class SuggestionAppService : ApplicationService { private readonly IRepository _suggestionRepository; private readonly SuggestionManager _manager; public SuggestionAppService( IRepository suggestionRepository, SuggestionManager manager ) { this._suggestionRepository = suggestionRepository; this._manager = manager; } /// /// 批量创建 先删除 /// /// /// [HttpPost("api/app/suggestion/createsuggestionmany")] public async Task CreateSuggestionManyAsync(CreateSuggestionManyDto input) { //先按诊断ID删除所有建议 await _manager.CheckAndDeleteInDiagnosisIdAsync(input.DiagnosisId, input.SuggestionType); if (input.Details.Any()) { List suggestions = new List(); foreach (var item in input.Details) { var entity = new Suggestion { DiagnosisId = input.DiagnosisId, DisplayOrder = input.Details.IndexOf(item) + 1, SuggestionContent = item.SuggestionContent, SuggestionType = input.SuggestionType }; suggestions.Add(_manager.CreateAsync(entity)); } if (suggestions.Count > 0) { await _suggestionRepository.InsertManyAsync(suggestions); } } } } }