ApiInfoController.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. /// ApiInfo)Controller
  19. /// </summary>
  20. // [Route("ApiInfo")]
  21. // [ApiExplorerSettings(GroupName = "ApiInfo")]
  22. public class ApiInfoController : BaseController
  23. {
  24. /// <summary>
  25. /// api分组接口
  26. /// </summary>
  27. private readonly IApiInfoService _ApiInfoService;
  28. public ApiInfoController(IApiInfoService ApiInfoService)
  29. {
  30. _ApiInfoService = ApiInfoService;
  31. }
  32. /// <summary>
  33. /// api接口列表
  34. /// </summary>
  35. /// <param name="parm">请求参数</param>
  36. /// <returns>api接口列表</returns>
  37. [HttpGet]
  38. [Route("/v1/api/ApiInfo/list")]
  39. public IActionResult List([FromQuery] PagerInfo page, [FromQuery] ApiInfoListDto parm)
  40. {
  41. var response = _ApiInfoService.List(page, 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/ApiInfo/query")]
  51. public IActionResult Query([FromQuery] ApiInfoQueryDto parm)
  52. {
  53. var response = _ApiInfoService.Queryable()
  54. .First(x => x.id == parm.id)
  55. .Adapt<ApiInfoQueryVo>() ?? new ApiInfoQueryVo();
  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/ApiInfo/add")]
  65. public IActionResult Add([FromBody] ApiInfoAddDto parm)
  66. {
  67. var modal = parm.Adapt<ApiInfo>().ToCreate(HttpContext);
  68. var response = _ApiInfoService.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/ApiInfo/setVersion")]
  78. public IActionResult SetVersion([FromBody] ApiInfoSetVersionDto parm)
  79. {
  80. var modal = parm.Adapt<ApiInfo>().ToUpdate(HttpContext);
  81. var response = _ApiInfoService.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/ApiInfo/delete/{id}")]
  91. public IActionResult Delete(int id)
  92. {
  93. var response = _ApiInfoService.Delete(id);
  94. return SUCCESS(response);
  95. }
  96. /// <summary>
  97. /// api接口修改
  98. /// </summary>
  99. /// <param name="parm">请求参数</param>
  100. /// <returns>api接口修改</returns>
  101. [HttpPut]
  102. [Route("/v1/api/ApiInfo/update")]
  103. public IActionResult Update([FromBody] ApiInfoUpdateDto parm)
  104. {
  105. var modal = parm.Adapt<ApiInfo>().ToUpdate(HttpContext);
  106. var response = _ApiInfoService.Update(modal, true);
  107. return SUCCESS(response);
  108. }
  109. /// <summary>
  110. /// api接口设置请求地址
  111. /// </summary>
  112. /// <param name="parm">请求参数</param>
  113. /// <returns>api接口设置请求地址</returns>
  114. [HttpPut]
  115. [Route("/v1/api/ApiInfo/setRouter")]
  116. public IActionResult SetRouter([FromBody] ApiInfoSetRouterDto parm)
  117. {
  118. var modal = parm.Adapt<ApiInfo>().ToUpdate(HttpContext);
  119. var response = _ApiInfoService.Update(modal, true);
  120. return SUCCESS(response);
  121. }
  122. }
  123. }