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.

177 lines
6.1 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
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
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 AutoMapper.Internal.Mappers;
  2. using Microsoft.AspNetCore.Authorization;
  3. using Microsoft.AspNetCore.Mvc;
  4. using Shentun.Peis.DiagnosisTemplates;
  5. using Shentun.Peis.GuidTypes;
  6. using Shentun.Peis.HelperDto;
  7. using Shentun.Peis.Models;
  8. using SqlSugar;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using Volo.Abp;
  15. using Volo.Abp.Application.Dtos;
  16. using Volo.Abp.Application.Services;
  17. using Volo.Abp.Domain.Repositories;
  18. using Volo.Abp.Identity;
  19. namespace Shentun.Peis.DiagnosisTemplates
  20. {
  21. /// <summary>
  22. /// 诊断模板
  23. /// </summary>
  24. [ApiExplorerSettings(GroupName = "Work")]
  25. [Authorize]
  26. public class DiagnosisTemplateAppService : CrudAppService<
  27. DiagnosisTemplate, //The Book entity
  28. DiagnosisTemplateDto, //Used to show books
  29. Guid, //Primary key of the book entity
  30. PagedAndSortedResultRequestDto, //Used for paging/sorting
  31. CreateDiagnosisTemplateDto,
  32. UpdateDiagnosisTemplateDto>
  33. {
  34. private readonly IRepository<IdentityUser, Guid> _userRepository;
  35. private readonly DiagnosisTemplateManager _manager;
  36. private readonly CacheService _cacheService;
  37. public DiagnosisTemplateAppService(
  38. IRepository<DiagnosisTemplate, Guid> repository,
  39. IRepository<IdentityUser, Guid> userRepository,
  40. DiagnosisTemplateManager manager,
  41. CacheService cacheService)
  42. : base(repository)
  43. {
  44. this._userRepository = userRepository;
  45. _manager = manager;
  46. _cacheService = cacheService;
  47. }
  48. /// <summary>
  49. /// 获取通过主键
  50. /// </summary>
  51. /// <param name="id"></param>
  52. /// <returns></returns>
  53. public override async Task<DiagnosisTemplateDto> GetAsync(Guid id)
  54. {
  55. var userList = await _userRepository.GetListAsync();
  56. var entityDto = await base.GetAsync(id);
  57. entityDto.CreatorName = EntityHelper.GetSurnameNoSql(userList, entityDto.CreatorId);
  58. entityDto.LastModifierName = EntityHelper.GetSurnameNoSql(userList, entityDto.LastModifierId);
  59. return entityDto;
  60. }
  61. /// <summary>
  62. /// 获取列表 诊断模板 遗弃
  63. /// </summary>
  64. /// <param name="input"></param>
  65. /// <returns></returns>
  66. [RemoteService(false)]
  67. public override async Task<PagedResultDto<DiagnosisTemplateDto>> GetListAsync(PagedAndSortedResultRequestDto input)
  68. {
  69. return await base.GetListAsync(input);
  70. }
  71. /// <summary>
  72. /// 获取列表 诊断模板 带搜索
  73. /// </summary>
  74. /// <param name="input"></param>
  75. /// <returns></returns>
  76. public async Task<List<DiagnosisTemplateDto>> GetListInFilterAsync(GetListInFilterDto input)
  77. {
  78. var entlist = await Repository.GetQueryableAsync();
  79. if (!string.IsNullOrEmpty(input.Filter))
  80. entlist = entlist.Where(m => m.DisplayName.Contains(input.Filter));
  81. var entdto = entlist.Select(s => new DiagnosisTemplateDto
  82. {
  83. CreationTime = s.CreationTime,
  84. CreatorId = s.CreatorId,
  85. DisplayName = s.DisplayName,
  86. DisplayOrder = s.DisplayOrder,
  87. Id = s.Id,
  88. LastModificationTime = s.LastModificationTime,
  89. LastModifierId = s.LastModifierId,
  90. SimpleCode = s.SimpleCode,
  91. CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).Result,
  92. LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).Result
  93. }).OrderBy(o => o.DisplayOrder).ToList();
  94. return entdto;
  95. }
  96. /// <summary>
  97. /// 创建
  98. /// </summary>
  99. /// <param name="input"></param>
  100. /// <returns></returns>
  101. public override async Task<DiagnosisTemplateDto> CreateAsync(CreateDiagnosisTemplateDto input)
  102. {
  103. var createEntity = ObjectMapper.Map<CreateDiagnosisTemplateDto, DiagnosisTemplate>(input);
  104. var entity = await _manager.CreateAsync(createEntity);
  105. entity = await Repository.InsertAsync(entity);
  106. var dto = ObjectMapper.Map<DiagnosisTemplate, DiagnosisTemplateDto>(entity);
  107. return dto;
  108. }
  109. /// <summary>
  110. /// 更新
  111. /// </summary>
  112. /// <param name="id"></param>
  113. /// <param name="input"></param>
  114. /// <returns></returns>
  115. public override async Task<DiagnosisTemplateDto> UpdateAsync(Guid id, UpdateDiagnosisTemplateDto input)
  116. {
  117. var entity = await Repository.GetAsync(id);
  118. var sourceEntity = ObjectMapper.Map<UpdateDiagnosisTemplateDto, DiagnosisTemplate>(input);
  119. await _manager.UpdateAsync(sourceEntity, entity);
  120. entity = await Repository.UpdateAsync(entity);
  121. return ObjectMapper.Map<DiagnosisTemplate, DiagnosisTemplateDto>(entity);
  122. }
  123. /// <summary>
  124. /// 删除
  125. /// </summary>
  126. /// <param name="id"></param>
  127. /// <returns></returns>
  128. public override async Task DeleteAsync(Guid id)
  129. {
  130. await _manager.CheckAndDeleteAsync(id);
  131. }
  132. /// <summary>
  133. /// 修改排序 置顶,置底
  134. /// </summary>
  135. /// <param name="id">需要修改的ID</param>
  136. /// <param name="SortType">修改方式:1 置顶 2 置底</param>
  137. /// <returns></returns>
  138. [HttpPut("api/app/diagnosistemplate/updatemanysort")]
  139. public async Task UpdateManySortAsync(Guid id, int SortType)
  140. {
  141. await _manager.UpdateManySortAsync(id, SortType);
  142. }
  143. /// <summary>
  144. /// 修改排序 拖拽
  145. /// </summary>
  146. /// <param name="input"></param>
  147. /// <returns></returns>
  148. [HttpPut("api/app/diagnosistemplate/updatesortmany")]
  149. public async Task UpdateSortManyAsync(UpdateSortManyDto input)
  150. {
  151. await _manager.UpdateSortManyAsync(input);
  152. }
  153. }
  154. }