sport_target_day.dart 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. class SportTargetDay {
  2. int id;
  3. int userId;
  4. int consume;
  5. int duration;
  6. int consumeTarget;
  7. int durationTarget;
  8. bool finish;
  9. String type;
  10. String createdAt;
  11. int durationMinute;
  12. int durationTargetMinute;
  13. SportTargetDay(
  14. {this.id,
  15. this.userId,
  16. this.consume,
  17. this.duration,
  18. this.consumeTarget,
  19. this.durationTarget,
  20. this.finish,
  21. this.type,
  22. this.createdAt,
  23. this.durationMinute,
  24. this.durationTargetMinute});
  25. SportTargetDay.fromJson(Map<String, dynamic> json) {
  26. id = json['id'];
  27. userId = json['user_id'];
  28. consume = json['consume'];
  29. duration = json['duration'];
  30. consumeTarget = json['consume_target'];
  31. durationTarget = json['duration_target'];
  32. finish = json['finish'];
  33. type = json['type'];
  34. createdAt = json['created_at'];
  35. durationMinute = json['duration_minute'];
  36. durationTargetMinute = json['duration_target_minute'];
  37. }
  38. Map<String, dynamic> toJson() {
  39. final Map<String, dynamic> data = new Map<String, dynamic>();
  40. data['id'] = this.id;
  41. data['user_id'] = this.userId;
  42. data['consume'] = this.consume;
  43. data['duration'] = this.duration;
  44. data['consume_target'] = this.consumeTarget;
  45. data['duration_target'] = this.durationTarget;
  46. data['finish'] = this.finish;
  47. data['type'] = this.type;
  48. data['created_at'] = this.createdAt;
  49. data['duration_minute'] = this.durationMinute;
  50. data['duration_target_minute'] = this.durationTargetMinute;
  51. return data;
  52. }
  53. int get value => type == "consume" ? consume : durationMinute;
  54. int get valueTarget => type == "consume" ? consumeTarget : durationTargetMinute;
  55. String get label => type == "consume" ? "卡" : "分钟";
  56. }