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.

71 lines
1.9 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. using Shentun.Peis.Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Volo.Abp;
  8. using Volo.Abp.Domain.Repositories;
  9. using Volo.Abp.Domain.Services;
  10. namespace Shentun.Peis.Suggestions
  11. {
  12. public class SuggestionManager : DomainService
  13. {
  14. private readonly IRepository<Suggestion, Guid> _repository;
  15. public SuggestionManager(
  16. IRepository<Suggestion, Guid> repository
  17. )
  18. {
  19. _repository = repository;
  20. }
  21. /// <summary>
  22. /// 创建
  23. /// </summary>
  24. /// <param name="entity"></param>
  25. /// <returns></returns>
  26. public Suggestion CreateAsync(Suggestion entity)
  27. {
  28. DataHelper.CheckGuidIsDefaultValue(entity.DiagnosisId, "诊断ID");
  29. DataHelper.CheckStringIsNull(entity.SuggestionContent, "建议内容");
  30. return entity;
  31. }
  32. /// <summary>
  33. /// 按诊断删除建议
  34. /// </summary>
  35. /// <param name="diagnosisId">诊断ID</param>
  36. /// <param name="suggestionType"></param>
  37. /// <returns></returns>
  38. public async Task CheckAndDeleteInDiagnosisIdAsync(Guid diagnosisId, char suggestionType = '0')
  39. {
  40. var suggestionList = await _repository.GetListAsync(m => m.DiagnosisId == diagnosisId && m.SuggestionType == suggestionType);
  41. if (suggestionList.Any())
  42. {
  43. //删除删除建议
  44. await _repository.DeleteManyAsync(suggestionList);
  45. }
  46. }
  47. /// <summary>
  48. ///删除
  49. /// </summary>
  50. /// <param name="id"></param>
  51. /// <returns></returns>
  52. /// <exception cref="UserFriendlyException"></exception>
  53. public async Task CheckAndDeleteAsync(Guid id)
  54. {
  55. await _repository.DeleteAsync(id);
  56. }
  57. }
  58. }