ApiGroupController.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. using Attribute;
  2. using Common;
  3. using Dto;
  4. using Vo;
  5. using Enums;
  6. using Filters;
  7. using Infrastructure;
  8. using Infrastructure.Model;
  9. using Mapster;
  10. using Microsoft.AspNetCore.Mvc;
  11. using Middleware;
  12. using Model;
  13. using Services;
  14. using Model.Base;
  15. namespace Controllers
  16. {
  17. /// <summary>
  18. /// ApiGroup)Controller
  19. /// </summary>
  20. // [Route("ApiGroup")]
  21. // [ApiExplorerSettings(GroupName = "ApiGroup")]
  22. public class ApiGroupController : BaseController
  23. {
  24. /// <summary>
  25. /// api分组接口
  26. /// </summary>
  27. private readonly IApiGroupService _ApiGroupService;
  28. public ApiGroupController(IApiGroupService ApiGroupService)
  29. {
  30. _ApiGroupService = ApiGroupService;
  31. }
  32. /// <summary>
  33. /// api接口分组列表
  34. /// </summary>
  35. /// <param name="parm">请求参数</param>
  36. /// <returns>api接口分组列表</returns>
  37. [HttpGet]
  38. [Route("/v1/api/ApiGroup/list")]
  39. public IActionResult List([FromQuery] ApiGroupListDto parm)
  40. {
  41. var response = _ApiGroupService.List(parm);
  42. return SUCCESS(response);
  43. }
  44. /// <summary>
  45. /// api接口分组详情
  46. /// </summary>
  47. /// <param name="parm">请求参数</param>
  48. /// <returns>api接口分组详情</returns>
  49. [HttpGet]
  50. [Route("/v1/api/ApiGroup/query")]
  51. public IActionResult Query([FromQuery] ApiGroupQueryDto parm)
  52. {
  53. var response = _ApiGroupService.Queryable()
  54. .First(x => x.id == parm.id)
  55. .Adapt<ApiGroupQueryVo>() ?? new ApiGroupQueryVo();
  56. return SUCCESS(response);
  57. }
  58. /// <summary>
  59. /// api接口分组添加
  60. /// </summary>
  61. /// <param name="parm">请求参数</param>
  62. /// <returns>api接口分组添加</returns>
  63. [HttpPost]
  64. [Route("/v1/api/ApiGroup/add")]
  65. public IActionResult Add([FromBody] ApiGroupAddDto parm)
  66. {
  67. var modal = parm.Adapt<ApiGroup>().ToCreate(HttpContext);
  68. var response = _ApiGroupService.Add(modal);
  69. return SUCCESS(response);
  70. }
  71. /// <summary>
  72. /// api接口分组修改
  73. /// </summary>
  74. /// <param name="parm">请求参数</param>
  75. /// <returns>api接口分组修改</returns>
  76. [HttpPut]
  77. [Route("/v1/api/ApiGroup/update")]
  78. public IActionResult Update([FromBody] ApiGroupUpdateDto parm)
  79. {
  80. var modal = parm.Adapt<ApiGroup>().ToUpdate(HttpContext);
  81. var response = _ApiGroupService.Update(modal, true);
  82. return SUCCESS(response);
  83. }
  84. /// <summary>
  85. /// api接口分组删除
  86. /// </summary>
  87. /// <param name="Id">ID</param>
  88. /// <returns>api接口分组删除</returns>
  89. [HttpDelete]
  90. [Route("/v1/api/ApiGroup/delete/{id}")]
  91. public IActionResult Delete(int id)
  92. {
  93. var response = _ApiGroupService.Delete(id);
  94. return SUCCESS(response);
  95. }
  96. /// <summary>
  97. /// api接口分组下拉框数据
  98. /// </summary>
  99. /// <param name="parm">请求参数</param>
  100. /// <returns>api接口分组下拉框数据</returns>
  101. [HttpGet]
  102. [Route("/v1/api/ApiGroup/SelectList")]
  103. public IActionResult SelectList()
  104. {
  105. var response = _ApiGroupService.SelectList();
  106. return SUCCESS(response);
  107. }
  108. }
  109. }