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.

93 lines
3.9 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
  1. using Microsoft.AspNetCore.Authorization;
  2. using Microsoft.AspNetCore.Mvc;
  3. using Microsoft.CodeAnalysis;
  4. using Microsoft.CodeAnalysis.CSharp;
  5. using Microsoft.DotNet.PlatformAbstractions;
  6. using Microsoft.Extensions.DependencyModel;
  7. using Shentun.Peis.Models;
  8. using Shentun.Peis.RegisterCheckSummarys;
  9. using System;
  10. using System.CodeDom;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. using System.Reflection;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using Volo.Abp;
  17. using Volo.Abp.Application.Services;
  18. using Volo.Abp.Domain.Repositories;
  19. using Volo.Abp.Identity;
  20. namespace Shentun.Peis.RegisterCheckSuggestions
  21. {
  22. /// <summary>
  23. /// 建议
  24. /// </summary>
  25. [ApiExplorerSettings(GroupName = "Work")]
  26. [Authorize]
  27. public class RegisterCheckSuggestionAppService : ApplicationService
  28. {
  29. private readonly IRepository<RegisterCheckSuggestion, Guid> _registerCheckSuggestionRepository;
  30. private readonly IRepository<IdentityUser, Guid> _userRepository;
  31. private readonly RegisterCheckSuggestionManager _registerCheckSuggestionManager;
  32. public RegisterCheckSuggestionAppService(
  33. IRepository<RegisterCheckSuggestion, Guid> registerCheckSuggestionRepository,
  34. IRepository<IdentityUser, Guid> userRepository,
  35. RegisterCheckSuggestionManager registerCheckSuggestionManager
  36. )
  37. {
  38. this._registerCheckSuggestionRepository = registerCheckSuggestionRepository;
  39. this._userRepository = userRepository;
  40. this._registerCheckSuggestionManager = registerCheckSuggestionManager;
  41. }
  42. /// <summary>
  43. /// 批量生成建议 先删除全部,然后批量创建,前台调用直接传所有的建议就行
  44. /// </summary>
  45. /// <param name="input"></param>
  46. /// <returns></returns>
  47. [HttpPost("api/app/registerchecksuggestion/createregisterchecksuggestionmany")]
  48. public async Task CreateRegisterCheckSuggestionManyAsync(CreateRegisterCheckSuggestionDto input)
  49. {
  50. throw new Exception("禁止");
  51. List<RegisterCheckSuggestion> dtolist = ObjectMapper.Map<List<CreateRegisterCheckSuggestion_Detail>, List<RegisterCheckSuggestion>>(input.Details);
  52. // await _registerCheckSuggestionRepository.DeleteAsync(m => m.RegisterCheckId == input[0].RegisterCheckId, true);
  53. await _registerCheckSuggestionManager.CheckAndDeleteAsync(input.RegisterCheckId);
  54. await _registerCheckSuggestionManager.CreateRegisterCheckSuggestionManyAsync(dtolist);
  55. }
  56. /// <summary>
  57. /// 根据RegisterCheckId获取检查建议数据
  58. /// </summary>
  59. /// <param name="RegisterCheckId">RegisterCheck表ID</param>
  60. /// <returns></returns>
  61. [HttpGet("api/app/registerchecksuggestion/getregisterchecksuggestionlist")]
  62. public async Task<List<RegisterCheckSuggestionDto>> GetRegisterCheckSuggestionListAsync(Guid RegisterCheckId)
  63. {
  64. var entlist = (await _registerCheckSuggestionRepository.GetListAsync(m => m.RegisterCheckId == RegisterCheckId)).OrderBy(o => o.DisplayOrder).ToList();
  65. var userList = await _userRepository.GetListAsync();
  66. var entlistdto = entlist.Select(s => new RegisterCheckSuggestionDto
  67. {
  68. CreationTime = s.CreationTime,
  69. DisplayOrder = s.DisplayOrder,
  70. CreatorId = s.CreatorId,
  71. Id = s.Id,
  72. LastModificationTime = s.LastModificationTime,
  73. LastModifierId = s.LastModifierId,
  74. RegisterCheckId = s.RegisterCheckId,
  75. Suggestion = s.Suggestion,
  76. CreatorName = EntityHelper.GetUserNameNoSql(userList, s.CreatorId),
  77. LastModifierName = EntityHelper.GetUserNameNoSql(userList, s.LastModifierId)
  78. }).ToList();
  79. return entlistdto;
  80. }
  81. }
  82. }