CoinSnapshotController.cs 1.1 KB

1234567891011121314151617181920212223242526272829
  1. using NTMiner.Core.MinerServer;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Web.Http;
  5. namespace NTMiner.Controllers {
  6. public class CoinSnapshotController : ApiControllerBase, ICoinSnapshotController {
  7. #region LatestSnapshots
  8. [Role.Admin]
  9. [HttpPost]
  10. public GetCoinSnapshotsResponse LatestSnapshots([FromBody]GetCoinSnapshotsRequest request) {
  11. if (request == null) {
  12. return ResponseBase.InvalidInput<GetCoinSnapshotsResponse>("参数错误");
  13. }
  14. try {
  15. List<CoinSnapshotData> data = WebApiRoot.CoinSnapshotSet.GetLatestSnapshots(
  16. request.Limit,
  17. out int totalMiningCount,
  18. out int totalOnlineCount) ?? new List<CoinSnapshotData>();
  19. return GetCoinSnapshotsResponse.Ok(data, totalMiningCount, totalOnlineCount);
  20. }
  21. catch (Exception e) {
  22. Logger.ErrorDebugLine(e);
  23. return ResponseBase.ServerError<GetCoinSnapshotsResponse>(e.Message);
  24. }
  25. }
  26. #endregion
  27. }
  28. }