TkEndpointController.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using molilian.core;
  2. using dodohold.core;
  3. using Microsoft.AspNetCore.Mvc;
  4. using Org.BouncyCastle.Ocsp;
  5. using System.Text.Json;
  6. using System.Runtime.InteropServices;
  7. using System.Net;
  8. using System.Security.Cryptography;
  9. using Microsoft.AspNetCore.Authentication;
  10. using TencentCloud.Ecm.V20190719.Models;
  11. using COSXML.Network;
  12. using System.Linq;
  13. using static dodohold.core.ZTOExpress.CreateOrderArgs;
  14. using TencentCloud.Lighthouse.V20200324.Models;
  15. using TencentCloud.Ame.V20190916.Models;
  16. using TencentCloud.Omics.V20221128.Models;
  17. using System.Threading.Channels;
  18. namespace molilian.api.Controllers
  19. {
  20. [ApiController]
  21. [Route("api/[controller]/[action]")]
  22. public class TkEndpointController : ControllerBase
  23. {
  24. protected IHttpContextAccessor _accessor;
  25. TaokeOpenCore core;
  26. public TkEndpointController(IHttpContextAccessor accessor)
  27. {
  28. _accessor = accessor;
  29. core = new TaokeOpenCore();
  30. }
  31. [HttpPost]
  32. public async Task<ActionResult> ChangeSuspend([FromForm] JsonElement body)
  33. {
  34. int accountId = body.Read<int>("accountId");
  35. string endpoint = body.Read<string>("accountId");
  36. bool release = body.Read<bool>("release");
  37. if (release)
  38. {
  39. TkEndpointManager.ReleaseSuspend(accountId, endpoint);
  40. }
  41. else
  42. {
  43. await TkEndpointManager.SuspendAsync(accountId, endpoint, TkEndpointManager.SuspendReason.Active);
  44. }
  45. return new APIResult(new
  46. {
  47. success = true,
  48. action = release ? "ReleaseSuspend" : "Suspend",
  49. });
  50. }
  51. [HttpPost]
  52. public ActionResult GetStatus([FromForm] JsonElement body)
  53. {
  54. var ids = body.PathReadArray<int>("accountId[]");
  55. var result = TkEndpointManager.GetStatus(ids);
  56. return new APIResult(new
  57. {
  58. success = true,
  59. data = result
  60. });
  61. }
  62. }
  63. }