ApiDescController.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using Sers.Core.Module.Api.ApiDesc;
  4. using Sers.Core.Module.Rpc;
  5. using Sers.Gover.Base;
  6. using Sers.SersLoader;
  7. using Sers.SersLoader.ApiDesc.Attribute.Valid;
  8. using Vit.Core.Util.ComponentModel.Api;
  9. using Vit.Core.Util.ComponentModel.Data;
  10. using Vit.Core.Util.ComponentModel.Model;
  11. namespace Sers.Gover.Controllers.ApiControllers
  12. {
  13. [SsStationName("_gover_")]
  14. public class ApiDescController : IApiController
  15. {
  16. [SsRoute("apiDesc/getActive")]
  17. [SsCallerSource(ECallerSource.Internal)]
  18. //[CallFromGover]
  19. [SsName("获取所有可调用api")]
  20. [SsDescription("获取所有可调用api。返回ApiDesc列表")]
  21. public ApiReturn<List<SsApiDesc>> GetActive([SsDescription("route前缀(不指定则返回所有),例如 \"_gover_\"、\"/demo/a.html\" "),SsExample("_gover_")]string r)
  22. {
  23. var apiDescs = GoverApiCenterService.Instance.ApiDesc_GetActive();
  24. if (!string.IsNullOrWhiteSpace(r))
  25. {
  26. if (!r.StartsWith("/")) r = "/" + r;
  27. apiDescs = apiDescs.Where(m=>m.route.StartsWith(r));
  28. }
  29. return new ApiReturn<List<SsApiDesc>> { data= apiDescs.ToList() };
  30. }
  31. [SsRoute("apiDesc/getAll")]
  32. [SsCallerSource(ECallerSource.Internal)]
  33. //[CallFromGover]
  34. [SsName("获取所有api")]
  35. [SsDescription("获取所有api。返回ApiDesc列表")]
  36. public ApiReturn<List<SsApiDesc>> GetAll([SsDescription("route前缀(不指定则返回所有),例如 \"_gover_\"、\"/demo/a.html\" "), SsExample("_gover_")]string r)
  37. {
  38. var apiDescs = GoverApiCenterService.Instance.ApiDesc_GetAll();
  39. if (!string.IsNullOrWhiteSpace(r))
  40. {
  41. if (!r.StartsWith("/")) r = "/" + r;
  42. apiDescs = apiDescs.Where(m => m.route.StartsWith(r));
  43. }
  44. return new ApiReturn<List<SsApiDesc>> { data = apiDescs.ToList() };
  45. }
  46. }
  47. }