FindOrderedListResult.cc 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * Copyright 2009-2017 Alibaba Cloud All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <alibabacloud/csb/model/FindOrderedListResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::CSB;
  19. using namespace AlibabaCloud::CSB::Model;
  20. FindOrderedListResult::FindOrderedListResult() :
  21. ServiceResult()
  22. {}
  23. FindOrderedListResult::FindOrderedListResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. FindOrderedListResult::~FindOrderedListResult()
  29. {}
  30. void FindOrderedListResult::parse(const std::string &payload)
  31. {
  32. Json::Reader reader;
  33. Json::Value value;
  34. reader.parse(payload, value);
  35. setRequestId(value["RequestId"].asString());
  36. auto dataNode = value["Data"];
  37. if(!dataNode["CurrentPage"].isNull())
  38. data_.currentPage = std::stoi(dataNode["CurrentPage"].asString());
  39. if(!dataNode["PageNumber"].isNull())
  40. data_.pageNumber = std::stoi(dataNode["PageNumber"].asString());
  41. auto allOrderListNode = dataNode["OrderList"]["Order"];
  42. for (auto dataNodeOrderListOrder : allOrderListNode)
  43. {
  44. Data::Order orderObject;
  45. if(!dataNodeOrderListOrder["Alias"].isNull())
  46. orderObject.alias = dataNodeOrderListOrder["Alias"].asString();
  47. if(!dataNodeOrderListOrder["ProjectName"].isNull())
  48. orderObject.projectName = dataNodeOrderListOrder["ProjectName"].asString();
  49. if(!dataNodeOrderListOrder["ServiceName"].isNull())
  50. orderObject.serviceName = dataNodeOrderListOrder["ServiceName"].asString();
  51. if(!dataNodeOrderListOrder["ServiceVersion"].isNull())
  52. orderObject.serviceVersion = dataNodeOrderListOrder["ServiceVersion"].asString();
  53. if(!dataNodeOrderListOrder["OrderStatus"].isNull())
  54. orderObject.orderStatus = std::stoi(dataNodeOrderListOrder["OrderStatus"].asString());
  55. if(!dataNodeOrderListOrder["AliveOrderCount"].isNull())
  56. orderObject.aliveOrderCount = std::stoi(dataNodeOrderListOrder["AliveOrderCount"].asString());
  57. if(!dataNodeOrderListOrder["GmtCreate"].isNull())
  58. orderObject.gmtCreate = std::stol(dataNodeOrderListOrder["GmtCreate"].asString());
  59. if(!dataNodeOrderListOrder["MaxRT"].isNull())
  60. orderObject.maxRT = std::stoi(dataNodeOrderListOrder["MaxRT"].asString());
  61. if(!dataNodeOrderListOrder["MinRT"].isNull())
  62. orderObject.minRT = std::stoi(dataNodeOrderListOrder["MinRT"].asString());
  63. if(!dataNodeOrderListOrder["ServiceId"].isNull())
  64. orderObject.serviceId = dataNodeOrderListOrder["ServiceId"].asString();
  65. if(!dataNodeOrderListOrder["ServiceStatus"].isNull())
  66. orderObject.serviceStatus = std::stoi(dataNodeOrderListOrder["ServiceStatus"].asString());
  67. auto allErrorTypeCatagoryListNode = allOrderListNode["ErrorTypeCatagoryList"]["ErrorTypeCatagory"];
  68. for (auto allOrderListNodeErrorTypeCatagoryListErrorTypeCatagory : allErrorTypeCatagoryListNode)
  69. {
  70. Data::Order::ErrorTypeCatagory errorTypeCatagoryListObject;
  71. if(!allOrderListNodeErrorTypeCatagoryListErrorTypeCatagory["Name"].isNull())
  72. errorTypeCatagoryListObject.name = allOrderListNodeErrorTypeCatagoryListErrorTypeCatagory["Name"].asString();
  73. if(!allOrderListNodeErrorTypeCatagoryListErrorTypeCatagory["Total"].isNull())
  74. errorTypeCatagoryListObject.total = std::stol(allOrderListNodeErrorTypeCatagoryListErrorTypeCatagory["Total"].asString());
  75. if(!allOrderListNodeErrorTypeCatagoryListErrorTypeCatagory["ErrorNum"].isNull())
  76. errorTypeCatagoryListObject.errorNum = std::stol(allOrderListNodeErrorTypeCatagoryListErrorTypeCatagory["ErrorNum"].asString());
  77. orderObject.errorTypeCatagoryList.push_back(errorTypeCatagoryListObject);
  78. }
  79. auto allOrdersNode = allOrderListNode["Orders"]["Order"];
  80. for (auto allOrderListNodeOrdersOrder : allOrdersNode)
  81. {
  82. Data::Order::Order1 ordersObject;
  83. if(!allOrderListNodeOrdersOrder["Alias"].isNull())
  84. ordersObject.alias = allOrderListNodeOrdersOrder["Alias"].asString();
  85. if(!allOrderListNodeOrdersOrder["ApproveComments"].isNull())
  86. ordersObject.approveComments = allOrderListNodeOrdersOrder["ApproveComments"].asString();
  87. if(!allOrderListNodeOrdersOrder["CsbId"].isNull())
  88. ordersObject.csbId = std::stol(allOrderListNodeOrdersOrder["CsbId"].asString());
  89. if(!allOrderListNodeOrdersOrder["GmtCreate"].isNull())
  90. ordersObject.gmtCreate = std::stol(allOrderListNodeOrdersOrder["GmtCreate"].asString());
  91. if(!allOrderListNodeOrdersOrder["GmtModified"].isNull())
  92. ordersObject.gmtModified = std::stol(allOrderListNodeOrdersOrder["GmtModified"].asString());
  93. if(!allOrderListNodeOrdersOrder["GroupName"].isNull())
  94. ordersObject.groupName = allOrderListNodeOrdersOrder["GroupName"].asString();
  95. if(!allOrderListNodeOrdersOrder["Id"].isNull())
  96. ordersObject.id = std::stol(allOrderListNodeOrdersOrder["Id"].asString());
  97. if(!allOrderListNodeOrdersOrder["ProjectName"].isNull())
  98. ordersObject.projectName = allOrderListNodeOrdersOrder["ProjectName"].asString();
  99. if(!allOrderListNodeOrdersOrder["ServiceId"].isNull())
  100. ordersObject.serviceId = std::stol(allOrderListNodeOrdersOrder["ServiceId"].asString());
  101. if(!allOrderListNodeOrdersOrder["ServiceName"].isNull())
  102. ordersObject.serviceName = allOrderListNodeOrdersOrder["ServiceName"].asString();
  103. if(!allOrderListNodeOrdersOrder["ServiceStatus"].isNull())
  104. ordersObject.serviceStatus = std::stoi(allOrderListNodeOrdersOrder["ServiceStatus"].asString());
  105. if(!allOrderListNodeOrdersOrder["ServiceVersion"].isNull())
  106. ordersObject.serviceVersion = allOrderListNodeOrdersOrder["ServiceVersion"].asString();
  107. if(!allOrderListNodeOrdersOrder["StatisticName"].isNull())
  108. ordersObject.statisticName = allOrderListNodeOrdersOrder["StatisticName"].asString();
  109. if(!allOrderListNodeOrdersOrder["Status"].isNull())
  110. ordersObject.status = std::stoi(allOrderListNodeOrdersOrder["Status"].asString());
  111. if(!allOrderListNodeOrdersOrder["UserId"].isNull())
  112. ordersObject.userId = allOrderListNodeOrdersOrder["UserId"].asString();
  113. auto slaInfoNode = value["SlaInfo"];
  114. if(!slaInfoNode["Qph"].isNull())
  115. ordersObject.slaInfo.qph = slaInfoNode["Qph"].asString();
  116. if(!slaInfoNode["Qps"].isNull())
  117. ordersObject.slaInfo.qps = slaInfoNode["Qps"].asString();
  118. auto total2Node = value["Total"];
  119. if(!total2Node["ErrorNum"].isNull())
  120. ordersObject.total2.errorNum = std::stoi(total2Node["ErrorNum"].asString());
  121. if(!total2Node["Total"].isNull())
  122. ordersObject.total2.total = std::stoi(total2Node["Total"].asString());
  123. orderObject.orders.push_back(ordersObject);
  124. }
  125. auto totalNode = value["Total"];
  126. if(!totalNode["ErrorNum"].isNull())
  127. orderObject.total.errorNum = std::stoi(totalNode["ErrorNum"].asString());
  128. if(!totalNode["Total"].isNull())
  129. orderObject.total.total = std::stoi(totalNode["Total"].asString());
  130. data_.orderList.push_back(orderObject);
  131. }
  132. if(!value["Code"].isNull())
  133. code_ = std::stoi(value["Code"].asString());
  134. if(!value["Message"].isNull())
  135. message_ = value["Message"].asString();
  136. }
  137. std::string FindOrderedListResult::getMessage()const
  138. {
  139. return message_;
  140. }
  141. FindOrderedListResult::Data FindOrderedListResult::getData()const
  142. {
  143. return data_;
  144. }
  145. int FindOrderedListResult::getCode()const
  146. {
  147. return code_;
  148. }