CommonResponse.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using Common;
  3. using Newtonsoft.Json;
  4. using Newtonsoft.Json.Linq;
  5. namespace Common.Http
  6. {
  7. public abstract class CommonResponse
  8. {
  9. public string? requestId { get; set; }
  10. public string? errorCode { get; set; }
  11. public string? message { get; set; }
  12. public string? responseTime { get; set; }
  13. public string? totalRow { get; set; }
  14. public string? totalPage { get; set; }
  15. public string? pageNumber { get; set; }
  16. public string? pageSize { get; set; }
  17. public bool? status { get; set; }
  18. public void BuildCommonResponse(String data)
  19. {
  20. JObject jObject = JObject.Parse(data);
  21. if (jObject != null)
  22. {
  23. requestId = (string)jObject[nameof(requestId)];
  24. responseTime = (string)jObject[nameof(responseTime)];
  25. totalRow = (string)jObject[nameof(totalRow)];
  26. totalPage = (string)jObject[nameof(totalPage)];
  27. pageNumber = (string)jObject[nameof(pageNumber)];
  28. pageSize = (string)jObject[nameof(pageSize)];
  29. errorCode = (string)jObject[nameof(errorCode)];
  30. message = (string)jObject[nameof(message)];
  31. status = jObject[nameof(status)] != null ? (bool)jObject[nameof(status)]! : false;
  32. }
  33. }
  34. }
  35. }