sport_step.dart 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import 'package:sport/services/Converter.dart';
  2. class SportStep {
  3. List<Record> records;
  4. Sum sum;
  5. SportStep({this.records, this.sum});
  6. SportStep.fromJson(Map<String, dynamic> json) {
  7. if (json['records'] != null) {
  8. records = new List<Record>();
  9. json['records'].forEach((v) {
  10. records.add(new Record.fromJson(v));
  11. });
  12. }
  13. sum = json['sum'] != null ? new Sum.fromJson(json['sum']) : null;
  14. }
  15. Map<String, dynamic> toJson() {
  16. final Map<String, dynamic> data = new Map<String, dynamic>();
  17. if (this.records != null) {
  18. data['records'] = this.records.map((v) => v.toJson()).toList();
  19. }
  20. if (this.sum != null) {
  21. data['sum'] = this.sum.toJson();
  22. }
  23. return data;
  24. }
  25. }
  26. class Record {
  27. int id;
  28. int userId;
  29. int step;
  30. int distance;
  31. int stepGame;
  32. int stepDaily;
  33. String createdAt;
  34. int year;
  35. int month;
  36. Record({this.id, this.userId, this.step, this.distance, this.stepGame, this.stepDaily, this.createdAt});
  37. Record.fromJson(Map<String, dynamic> json) {
  38. id = json['id'];
  39. userId = json['user_id'];
  40. step = json['step'];
  41. distance = json['distance'];
  42. stepGame = json['step_game'];
  43. stepDaily = json['step_daily'];
  44. createdAt = json['created_at'];
  45. year = json['year'];
  46. month = json['month'];
  47. }
  48. Map<String, dynamic> toJson() {
  49. final Map<String, dynamic> data = new Map<String, dynamic>();
  50. data['id'] = this.id;
  51. data['user_id'] = this.userId;
  52. data['step'] = this.step;
  53. data['distance'] = this.distance;
  54. data['step_game'] = this.stepGame;
  55. data['step_daily'] = this.stepDaily;
  56. data['created_at'] = this.createdAt;
  57. return data;
  58. }
  59. }
  60. class Sum {
  61. int stepDayAvg;
  62. int distance;
  63. int step;
  64. int stepDaily;
  65. int stepGame;
  66. double stepRate;
  67. double stepRateMax;
  68. Sum({this.stepDayAvg, this.distance, this.step, this.stepDaily, this.stepGame, this.stepRate, this.stepRateMax});
  69. Sum.fromJson(Map<String, dynamic> json) {
  70. stepDayAvg = json['step_day_avg'];
  71. distance = json['distance'];
  72. step = json['step'];
  73. stepDaily = json['step_daily'];
  74. stepGame = json['step_game'];
  75. stepRate = Converter.toDouble(json['step_rate']);
  76. stepRateMax = Converter.toDouble(json['step_rate_max']);
  77. }
  78. Map<String, dynamic> toJson() {
  79. final Map<String, dynamic> data = new Map<String, dynamic>();
  80. data['step_day_avg'] = this.stepDayAvg;
  81. data['distance'] = this.distance;
  82. data['step'] = this.step;
  83. data['step_daily'] = this.stepDaily;
  84. data['step_game'] = this.stepGame;
  85. data['step_rate'] = this.stepRate;
  86. data['step_rate_max'] = this.stepRateMax;
  87. return data;
  88. }
  89. }