AdminFlowController.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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,
  36. ILoginContext loginContext, IProcessService processService,
  37. IFlowService flowService, IUserRepository userRepository,
  38. IDepartmentRepository departmentRepository, IProcessGroupRepository processGroupRepository, IProcessRepository processRepository, IFlowTodoRepository flowTodoRepository, IFlowRepository flowRepository, IDocService docService)
  39. {
  40. _logger = logger;
  41. _loginContext = loginContext;
  42. _processService = processService;
  43. _flowService = flowService;
  44. _userRepository = userRepository;
  45. _departmentRepository = departmentRepository;
  46. _processGroupRepository = processGroupRepository;
  47. _processRepository = processRepository;
  48. _flowTodoRepository = flowTodoRepository;
  49. _flowRepository = flowRepository;
  50. this.docService = docService;
  51. }
  52. /// <summary>
  53. /// 获取详情
  54. /// </summary>
  55. /// <param name="id"></param>
  56. /// <returns></returns>
  57. [HttpGet("{id}")]
  58. [AllowAnonymous]
  59. public async Task<FlowResult> Get(int id)
  60. {
  61. return await _flowService.GetFlowResult(id);
  62. }
  63. [HttpGet]
  64. [AllowAnonymous]
  65. public async Task<List<Option>> List()
  66. {
  67. var options = new List<Option>();
  68. var groups = await _processGroupRepository.GetListAsync();
  69. foreach (var processGroup in groups)
  70. {
  71. var children = new List<Option>();
  72. var processes = await _processRepository.GetListByGroupIdAsync(processGroup.Id);
  73. foreach (var process in processes)
  74. {
  75. children.Add(new Option
  76. {
  77. Label = process.Name,
  78. Value = process.Id
  79. });
  80. }
  81. options.Add(new Option
  82. {
  83. Label = processGroup.Name,
  84. Value = 0,
  85. Options = children
  86. });
  87. }
  88. return options;
  89. }
  90. /// <summary>
  91. /// 获取工作项
  92. /// </summary>
  93. /// <returns></returns>
  94. [HttpPost]
  95. [AllowAnonymous]
  96. public async Task<ListResult> List([FromBody] ListRequest request)
  97. {
  98. return await _flowService.ListAllAsync(request.Page, request.PerPage, request.ProcessId, request.State, request.StartDate, request.EndDate);
  99. }
  100. }
  101. }