stat_log_entry.dart 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import 'dart:convert';
  2. /// 解析 JSON 字符串
  3. StatLogEntry statLogEntryFromJson(String str) =>
  4. StatLogEntry.fromJson(json.decode(str));
  5. /// 序列化为 JSON 字符串
  6. String statLogEntryToJson(StatLogEntry data) => json.encode(data.toJson());
  7. class StatLogEntry {
  8. final String? id;
  9. final int? time;
  10. final String? level;
  11. final String? module;
  12. final String? category;
  13. final Fields? fields;
  14. StatLogEntry({
  15. this.id,
  16. this.time,
  17. this.level,
  18. this.module,
  19. this.category,
  20. this.fields,
  21. });
  22. factory StatLogEntry.fromJson(Map<String, dynamic> json) => StatLogEntry(
  23. id: json["id"],
  24. time: json["time"],
  25. level: json["level"],
  26. module: json["module"],
  27. category: json["category"],
  28. fields: json["fields"] == null ? null : Fields.fromJson(json["fields"]),
  29. );
  30. Map<String, dynamic> toJson() => {
  31. "id": id,
  32. "time": time,
  33. "level": level,
  34. "module": module,
  35. "category": category,
  36. "fields": fields?.toJson(),
  37. };
  38. }
  39. class Fields {
  40. final int? code;
  41. final String? boostSessionId;
  42. final bool? success;
  43. final int? locationId;
  44. final List<ConnectionHistory>? connectionHistory;
  45. final String? locationCode;
  46. final int? generatedTime;
  47. Fields({
  48. this.code,
  49. this.boostSessionId,
  50. this.success,
  51. this.locationId,
  52. this.connectionHistory,
  53. this.locationCode,
  54. this.generatedTime,
  55. });
  56. factory Fields.fromJson(Map<String, dynamic> json) => Fields(
  57. code: json["code"],
  58. boostSessionId: json["boostSessionId"],
  59. success: json["success"],
  60. locationId: json["locationId"],
  61. connectionHistory: json["connectionHistory"] == null
  62. ? []
  63. : List<ConnectionHistory>.from(
  64. json["connectionHistory"]!.map(
  65. (x) => ConnectionHistory.fromJson(x),
  66. ),
  67. ),
  68. locationCode: json["locationCode"],
  69. generatedTime: json["generatedTime"],
  70. );
  71. Map<String, dynamic> toJson() => {
  72. "code": code,
  73. "boostSessionId": boostSessionId,
  74. "success": success,
  75. "locationId": locationId,
  76. "connectionHistory": connectionHistory == null
  77. ? []
  78. : List<dynamic>.from(connectionHistory!.map((x) => x.toJson())),
  79. "locationCode": locationCode,
  80. "generatedTime": generatedTime,
  81. };
  82. }
  83. class ConnectionHistory {
  84. final String? firstHop;
  85. final int? duration;
  86. final String? address;
  87. final int? code;
  88. final int? startTime;
  89. final int? endTime;
  90. final String? nodeId;
  91. ConnectionHistory({
  92. this.firstHop,
  93. this.duration,
  94. this.address,
  95. this.code,
  96. this.startTime,
  97. this.endTime,
  98. this.nodeId,
  99. });
  100. factory ConnectionHistory.fromJson(Map<String, dynamic> json) =>
  101. ConnectionHistory(
  102. firstHop: json["firstHop"],
  103. duration: json["duration"],
  104. address: json["address"],
  105. code: json["code"],
  106. startTime: json["startTime"],
  107. endTime: json["endTime"],
  108. nodeId: json["nodeId"],
  109. );
  110. Map<String, dynamic> toJson() => {
  111. "firstHop": firstHop,
  112. "duration": duration,
  113. "address": address,
  114. "code": code,
  115. "startTime": startTime,
  116. "endTime": endTime,
  117. "nodeId": nodeId,
  118. };
  119. }