123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- import 'package:sport/bean/rank_game_info.dart';
- import 'package:sport/bean/sport_target.dart';
- import 'package:sport/services/Converter.dart';
- import 'game.dart' as Game;
- import 'user.dart';
- class SportDetail {
- int durationTotalDay;
- int durationTarget;
- SportTarget target;
- NextAchievement nextAchievement;
- RecordsTodaySum recordsTodaySum, recordsTodayAvg;
- List<RecordsToday> recordsToday;
- List<GamesSum> gamesSum;
- List<Achievement> achievements;
- int step;
- int sportTimes;
- SportDetail(
- {this.durationTotalDay,
- this.durationTarget,
- this.target,
- this.nextAchievement,
- this.recordsTodaySum,
- this.recordsTodayAvg,
- this.recordsToday,
- this.gamesSum,
- this.achievements});
- SportDetail.fromJson(Map<String, dynamic> json) {
- durationTotalDay = json['duration_total_day'];
- durationTarget = json['duration_target'];
- step = json['step'];
- sportTimes = json['sport_times'];
- target = json['target'] != null ? new SportTarget.fromJson(json['target']) : null;
- nextAchievement = json['next_achievement'] != null ? new NextAchievement.fromJson(json['next_achievement']) : null;
- recordsTodaySum = json['records_today_sum'] != null ? new RecordsTodaySum.fromJson(json['records_today_sum']) : null;
- recordsTodayAvg= json['records_today_avg'] != null ? new RecordsTodaySum.fromJson(json['records_today_avg']) : null;
- if (json['records_today'] != null) {
- recordsToday = new List<RecordsToday>();
- json['records_today'].forEach((v) {
- recordsToday.add(new RecordsToday.fromJson(v));
- });
- }
- if (json['games_sum'] != null) {
- gamesSum = new List<GamesSum>();
- json['games_sum'].forEach((v) {
- gamesSum.add(new GamesSum.fromJson(v));
- });
- }
- if (json['achievements'] != null) {
- achievements = new List<Achievement>();
- json['achievements'].forEach((v) {
- achievements.add(new Achievement.fromJson(v));
- });
- }
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['duration_total_day'] = this.durationTotalDay;
- data['duration_target'] = this.durationTarget;
- data['step'] = this.step;
- data['sport_times'] = this.sportTimes;
- if (this.target != null) {
- data['target'] = this.target.toJson();
- }
- if (this.nextAchievement != null) {
- data['next_achievement'] = this.nextAchievement.toJson();
- }
- if (this.recordsTodaySum != null) {
- data['records_today_sum'] = this.recordsTodaySum.toJson();
- }
- if (this.recordsToday != null) {
- data['records_today'] = this.recordsToday.map((v) => v.toJson()).toList();
- }
- if (this.gamesSum != null) {
- data['games_sum'] = this.gamesSum.map((v) => v.toJson()).toList();
- }
- if (this.achievements != null) {
- data['achievements'] = this.achievements.map((v) => v.toJson()).toList();
- }
- return data;
- }
- }
- class NextAchievement {
- Achievement achievement;
- int diff;
- NextAchievement({this.achievement, this.diff});
- NextAchievement.fromJson(Map<String, dynamic> json) {
- achievement = json['achievement'] != null ? new Achievement.fromJson(json['achievement']) : null;
- diff = json['condition_count_diff'];
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- if (this.achievement != null) {
- data['achievement'] = this.achievement.toJson();
- }
- data['condition_count_diff'] = this.diff;
- return data;
- }
- }
- class RecordsTodaySum {
- int id;
- int userId;
- int duration;
- String createdAt;
- int consume;
- int jumpCount;
- int crouchCount;
- int screen ;
- double score;
- int times ;
- int stepCount ;
- double stepRate;
- double stepRateMax;
- int durationMinute;
- double jumpRate;
- double crouchRate;
- double scoreMax;
- double consumeRate;
- int mode;
- RecordsTodaySum({this.id, this.userId, this.duration, this.createdAt, this.consume, this.jumpCount, this.crouchCount, this.screen, this.score, this.stepCount, this.times, this.durationMinute});
- RecordsTodaySum.fromJson(Map<String, dynamic> json) {
- id = json['id'];
- userId = json['user_id'];
- duration = json['duration'];
- createdAt = json['created_at'];
- consume = json['consume'];
- jumpCount = json['jump_count'];
- crouchCount = json['crouch_count'];
- screen = json['screen'];
- score = Converter.toDouble(json['score']);
- times = json['times'];
- stepCount = json['step_count'];
- stepRate = Converter.toDouble(json['step_rate']);
- stepRateMax = Converter.toDouble(json['step_rate_max']);
- durationMinute = json['duration_minute'];
- jumpRate = Converter.toDouble(json['jump_rate']);
- crouchRate = Converter.toDouble(json['crouch_rate']);
- scoreMax = Converter.toDouble(json['score_max']);
- consumeRate = Converter.toDouble(json['consume_rate']);
- mode = json['mode'];
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['id'] = this.id;
- data['user_id'] = this.userId;
- data['duration'] = this.duration;
- data['created_at'] = this.createdAt;
- data['consume'] = this.consume;
- data['jump_count'] = this.jumpCount;
- data['crouch_count'] = this.crouchCount;
- data['screen'] = this.screen;
- return data;
- }
- String get tag => this.createdAt.split(" ")[0];
- }
- class RecordsToday {
- int id;
- int userId;
- int duration;
- String createdAt;
- int month;
- int consume;
- int gameId;
- int jumpCount;
- int crouchCount;
- double score;
- String lastPlayAt;
- String name;
- String cover;
- double todayScoreMax;
- int durationTotalMinute;
- int userCount;
- int times;
- int year;
- RecordsToday({this.id, this.userId, this.duration, this.createdAt,this.month, this.consume, this.gameId, this.jumpCount, this.crouchCount, this.score, this.name, this.cover, this.userCount});
- RecordsToday.fromJson(Map<String, dynamic> json) {
- id = json['id'];
- userId = json['user_id'];
- duration = json['duration'];
- createdAt = json['created_at'];
- month = json['month'];
- consume = json['consume'];
- gameId = json['game_id'];
- jumpCount = json['jump_count'];
- crouchCount = json['crouch_count'];
- score = Converter.toDouble(json['score']);
- lastPlayAt = json['last_play_at'];
- name = json['name'];
- cover = json['cover'];
- todayScoreMax = Converter.toDouble(json['today_score_max']);
- durationTotalMinute = json['duration_minute'];
- userCount = json['user_count'];
- times = json['times'];
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['id'] = this.id;
- data['user_id'] = this.userId;
- data['duration'] = this.duration;
- data['created_at'] = this.createdAt;
- data['consume'] = this.consume;
- data['game_id'] = this.gameId;
- data['jump_count'] = this.jumpCount;
- data['crouch_count'] = this.crouchCount;
- data['score'] = this.score;
- return data;
- }
- }
- class GamesSum {
- int id;
- int userId;
- int gameId;
- String lastPlayAt;
- int playCount;
- int durationTotal;
- double scoreTotal;
- int consumeTotal;
- double scoreMax;
- Game.GameInfoData game;
- GamesSum(
- {this.id, this.userId, this.gameId, this.lastPlayAt, this.playCount, this.durationTotal, this.scoreTotal, this.consumeTotal, this.scoreMax, this.game});
- GamesSum.fromJson(Map<String, dynamic> json) {
- id = json['id'];
- userId = json['user_id'];
- gameId = json['game_id'];
- lastPlayAt = json['last_play_at'];
- playCount = json['times'];
- durationTotal = json['duration'];
- scoreTotal = Converter.toDouble(json['score']);
- consumeTotal = json['consume'];
- scoreMax = Converter.toDouble(json['score_max']);
- game = json['game'] != null ? new Game.GameInfoData.fromJson(json['game']) : null;
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['id'] = this.id;
- data['user_id'] = this.userId;
- data['game_id'] = this.gameId;
- data['last_play_at'] = this.lastPlayAt;
- data['times'] = this.playCount;
- data['duration'] = this.durationTotal;
- data['score_total'] = this.scoreTotal;
- data['consume'] = this.consumeTotal;
- data['score_max'] = this.scoreMax;
- data['game'] = this.game;
- return data;
- }
- }
- class SportDetailSimple {
- RecordsTodaySum sum, avg;
- List<RecordsToday> records;
- SportDetailSimple({this.sum, this.records});
- SportDetailSimple.fromJson(Map<String, dynamic> json) {
- sum = json['sum'] != null ? new RecordsTodaySum.fromJson(json['sum']) : null;
- avg = json['avg'] != null ? new RecordsTodaySum.fromJson(json['avg']) : null;
- if (json['records'] != null) {
- records = new List<RecordsToday>();
- json['records'].forEach((v) {
- records.add(new RecordsToday.fromJson(v));
- });
- }
- }
- }
|