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