ApiDescController.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. [SsName("获取所有可调用api")]
  19. [SsDescription("获取所有可调用api。返回ApiDesc列表")]
  20. public ApiReturn<List<SsApiDesc>> GetActive([SsDescription("route前缀(不指定则返回所有),例如 \"_gover_\"、\"/demo/a.html\" "),SsExample("_gover_")]string r)
  21. {
  22. var apiDescs = GoverApiCenterService.Instance.ApiDesc_GetActive();
  23. if (!string.IsNullOrWhiteSpace(r))
  24. {
  25. if (!r.StartsWith("/")) r = "/" + r;
  26. apiDescs = apiDescs.Where(m=>m.route.StartsWith(r));
  27. }
  28. return new ApiReturn<List<SsApiDesc>> { data= apiDescs.ToList() };
  29. }
  30. [SsRoute("apiDesc/getAll")]
  31. [SsCallerSource(ECallerSource.Internal)]
  32. [SsName("获取所有api")]
  33. [SsDescription("获取所有api。返回ApiDesc列表")]
  34. public ApiReturn<List<SsApiDesc>> GetAll([SsDescription("route前缀(不指定则返回所有),例如 \"_gover_\"、\"/demo/a.html\" "), SsExample("_gover_")]string r)
  35. {
  36. var apiDescs = GoverApiCenterService.Instance.ApiDesc_GetAll();
  37. if (!string.IsNullOrWhiteSpace(r))
  38. {
  39. if (!r.StartsWith("/")) r = "/" + r;
  40. apiDescs = apiDescs.Where(m => m.route.StartsWith(r));
  41. }
  42. return new ApiReturn<List<SsApiDesc>> { data = apiDescs.ToList() };
  43. }
  44. [SsRoute("apiDesc/removeOffline")]
  45. [SsCallerSource(ECallerSource.Internal)]
  46. [SsName("移除离线的api")]
  47. [SsDescription("移除离线的api")]
  48. public ApiReturn RemoveOffline()
  49. {
  50. GoverApiCenterService.Instance.apiStationMng.ApiService_RemoveOffline();
  51. return true;
  52. }
  53. }
  54. }