AdminFlowController.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using GxPress.Auth;
  4. using GxPress.Repository.Interface;
  5. using GxPress.Repository.Interface.WorkFlow;
  6. using GxPress.Repository.Interface.WorkProcess;
  7. using GxPress.Result.App;
  8. using GxPress.Result.App.Flow;
  9. using GxPress.Service.Interface;
  10. using GxPress.Service.Interface.Doc;
  11. using Microsoft.AspNetCore.Authorization;
  12. using Microsoft.AspNetCore.Mvc;
  13. using Microsoft.Extensions.Logging;
  14. namespace GxPress.Api.AdminControllers
  15. {
  16. /// <summary>
  17. /// 通讯录用户信息
  18. /// </summary>
  19. [Route("api/admin/flow")]
  20. [ApiController]
  21. [Authorize]
  22. public partial class AdminFlowController : ControllerBase
  23. {
  24. private readonly ILogger<AppControllers.AppVersionController> _logger;
  25. private readonly ILoginContext _loginContext;
  26. private readonly IProcessGroupRepository _processGroupRepository;
  27. private readonly IProcessRepository _processRepository;
  28. private readonly IProcessService _processService;
  29. private readonly IFlowService _flowService;
  30. private readonly IUserRepository _userRepository;
  31. private readonly IDepartmentRepository _departmentRepository;
  32. private readonly IFlowTodoRepository _flowTodoRepository;
  33. private readonly IFlowRepository _flowRepository;
  34. private readonly IDocService docService;
  35. public AdminFlowController(ILogger<AppControllers.AppVersionController> logger, ILoginContext loginContext, IProcessService processService, IFlowService flowService, IUserRepository userRepository, IDepartmentRepository departmentRepository, IProcessGroupRepository processGroupRepository, IProcessRepository processRepository, IFlowTodoRepository flowTodoRepository, IFlowRepository flowRepository, IDocService docService)
  36. {
  37. _logger = logger;
  38. _loginContext = loginContext;
  39. _processService = processService;
  40. _flowService = flowService;
  41. _userRepository = userRepository;
  42. _departmentRepository = departmentRepository;
  43. _processGroupRepository = processGroupRepository;
  44. _processRepository = processRepository;
  45. _flowTodoRepository = flowTodoRepository;
  46. _flowRepository = flowRepository;
  47. this.docService = docService;
  48. }
  49. /// <summary>
  50. /// 获取详情
  51. /// </summary>
  52. /// <param name="id"></param>
  53. /// <returns></returns>
  54. [HttpGet("{id}")]
  55. [AllowAnonymous]
  56. public async Task<FlowResult> Get(int id)
  57. {
  58. return await _flowService.GetFlowResult(id);
  59. }
  60. [HttpGet]
  61. [AllowAnonymous]
  62. public async Task<List<Option>> List()
  63. {
  64. var options = new List<Option>();
  65. var groups = await _processGroupRepository.GetListAsync();
  66. foreach (var processGroup in groups)
  67. {
  68. var children = new List<Option>();
  69. var processes = await _processRepository.GetListByGroupIdAsync(processGroup.Id);
  70. foreach (var process in processes)
  71. {
  72. children.Add(new Option
  73. {
  74. Label = process.Name,
  75. Value = process.Id
  76. });
  77. }
  78. options.Add(new Option
  79. {
  80. Label = processGroup.Name,
  81. Value = 0,
  82. Options = children
  83. });
  84. }
  85. return options;
  86. }
  87. /// <summary>
  88. /// 获取工作项
  89. /// </summary>
  90. /// <returns></returns>
  91. [HttpPost]
  92. [AllowAnonymous]
  93. public async Task<ListResult> List([FromBody] ListRequest request)
  94. {
  95. return await _flowService.ListAllAsync(request.Page, request.PerPage, request.ProcessId, request.State, request.StartDate, request.EndDate);
  96. }
  97. }
  98. }