You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.2 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. using Microsoft.AspNetCore.Authorization;
  2. using Microsoft.AspNetCore.Mvc;
  3. using Shentun.Peis.AsbitemDetails;
  4. using Shentun.Peis.Models;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using TencentCloud.Ame.V20190916.Models;
  11. using Volo.Abp.Application.Services;
  12. using Volo.Abp.Domain.Repositories;
  13. namespace Shentun.Peis.Suggestions
  14. {
  15. /// <summary>
  16. /// 诊断建议
  17. /// </summary>
  18. [ApiExplorerSettings(GroupName = "Work")]
  19. [Authorize]
  20. public class SuggestionAppService : ApplicationService
  21. {
  22. private readonly IRepository<Suggestion, Guid> _suggestionRepository;
  23. private readonly SuggestionManager _manager;
  24. public SuggestionAppService(
  25. IRepository<Suggestion, Guid> suggestionRepository,
  26. SuggestionManager manager
  27. )
  28. {
  29. this._suggestionRepository = suggestionRepository;
  30. this._manager = manager;
  31. }
  32. /// <summary>
  33. /// 批量创建 先删除
  34. /// </summary>
  35. /// <param name="input"></param>
  36. /// <returns></returns>
  37. [HttpPost("api/app/suggestion/createsuggestionmany")]
  38. public async Task CreateSuggestionManyAsync(CreateSuggestionManyDto input)
  39. {
  40. //先按诊断ID删除所有建议
  41. await _manager.CheckAndDeleteInDiagnosisIdAsync(input.DiagnosisId);
  42. if (input.Details.Any())
  43. {
  44. List<Suggestion> suggestions = new List<Suggestion>();
  45. foreach (var item in input.Details)
  46. {
  47. var entity = new Suggestion
  48. {
  49. DiagnosisId = input.DiagnosisId,
  50. DisplayOrder = input.Details.IndexOf(item) + 1,
  51. SuggestionContent = item.SuggestionContent
  52. };
  53. suggestions.Add(_manager.CreateAsbitemAsync(entity));
  54. }
  55. if (suggestions.Count > 0)
  56. {
  57. await _suggestionRepository.InsertManyAsync(suggestions);
  58. }
  59. }
  60. }
  61. }
  62. }