123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- import 'package:sport/bean/achievement_info.dart';
- import 'package:sport/bean/exer_record_sum.dart';
- import 'package:sport/bean/user.dart';
- import 'package:sport/services/Converter.dart';
- class UserInfo {
- int? id;
- String? name;
- String? avatar;
- int? sportTargetId;
- int? topSubjectId;
- int? level;
- String? levelLogo;
- double? score;
- int? isBan;
- int? provinceId;
- int? cityId;
- int? districtId;
- String? createdAt;
- int? gender;
- int? age;
- String? province;
- String? city;
- String? district;
- SportRecordSum? sportRecordSum;
- List<Achievement>? achievements;
- String? followStatus;
- int? activeDay;
- ExerRecordSum? exerRecordSum;
- Level? levelInfo;
- bool? blockedFromMe;
- UserInfo(
- {this.id,
- this.name,
- this.avatar,
- this.sportTargetId,
- this.topSubjectId,
- this.level,
- this.score,
- this.isBan,
- this.provinceId,
- this.cityId,
- this.districtId,
- this.createdAt,
- this.gender,
- this.age,
- this.province,
- this.city,
- this.district,
- this.sportRecordSum,
- this.achievements});
- UserInfo.fromJson(Map<String, dynamic> json) {
- id = Converter.toInt(json['id']);
- if (json.containsKey("uid")) {
- id = Converter.toInt(json['uid']);
- }
- name = json['name'] ?? json['user_name'];
- avatar = json['avatar'] ?? json['user_avatar'];
- sportTargetId = json['sport_target_id'];
- topSubjectId = json['top_subject_id'];
- level = Converter.toInt(json['level']);
- levelLogo = json['level_logo'];
- score = Converter.toDouble(json['score']);
- isBan = Converter.toInt(json['is_ban']);
- provinceId = Converter.toInt(json['province_id']);
- cityId = Converter.toInt(json['city_id']);
- districtId = Converter.toInt(json['district_id']);
- createdAt = json['created_at'];
- gender = Converter.toInt(json['gender']);
- age = Converter.toInt(json['age']);
- province = json['province'];
- city = json['city'];
- district = json['district'];
- sportRecordSum = json['sport_record_sum'] != null
- ? new SportRecordSum.fromJson(json['sport_record_sum'])
- : null;
- if (json['achievements_show'] != null) {
- achievements = [];
- json['achievements_show'].forEach((v) {
- achievements!.add(new Achievement.fromJson(v));
- });
- }
- followStatus = json['follow_status'];
- activeDay = json['active_day'];
- exerRecordSum = json['exer_record_sum'] != null
- ? new ExerRecordSum.fromMap(json['exer_record_sum'])
- : null;
- levelInfo = json['level_info'] != null ? new Level.fromJson(json['level_info']) : null;
- blockedFromMe = json['blocked_from_me'];
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['id'] = this.id;
- data['name'] = this.name;
- data['avatar'] = this.avatar;
- data['sport_target_id'] = this.sportTargetId;
- data['top_subject_id'] = this.topSubjectId;
- data['level'] = this.level;
- data['level_logo'] = this.levelLogo;
- data['score'] = this.score;
- data['is_ban'] = this.isBan;
- data['province_id'] = this.provinceId;
- data['city_id'] = this.cityId;
- data['district_id'] = this.districtId;
- data['created_at'] = this.createdAt;
- data['gender'] = this.gender;
- data['age'] = this.age;
- data['province'] = this.province;
- data['city'] = this.city;
- data['district'] = this.district;
- if (this.sportRecordSum != null) {
- data['sport_record_sum'] = this.sportRecordSum!.toJson();
- }
- if (this.achievements != null) {
- data['achievements_show'] =
- this.achievements!.map((v) => v.toJson()).toList();
- }
- data['follow_status'] = this.followStatus;
- data['active_day'] = this.activeDay;
- if (this.exerRecordSum != null) {
- data['exer_record_sum'] = this.exerRecordSum!.toJson();
- }
- if(this.levelInfo != null)
- data['level_info'] = this.levelInfo!.toJson();
- return data;
- }
- Map<String, dynamic> toJsonSimple() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['id'] = this.id;
- data['nickname'] = this.name;
- data['gender'] = this.gender;
- data['avatar'] = this.avatar;
- return data;
- }
- bool isFriend() {
- return followStatus == "friends" || followStatus == "followed";
- }
- }
- class SportRecordSum {
- int? id;
- int? userId;
- int? consume;
- int? duration;
- int? jumpCount;
- int? crouchCount;
- SportRecordSum(
- {this.id,
- this.userId,
- this.consume,
- this.duration,
- this.jumpCount,
- this.crouchCount});
- SportRecordSum.fromJson(Map<String, dynamic> json) {
- id = json['id'];
- userId = json['user_id'];
- consume = json['consume'];
- duration = json['duration'];
- jumpCount = json['jump_count'];
- crouchCount = json['crouch_count'];
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['id'] = this.id;
- data['user_id'] = this.userId;
- data['consume'] = this.consume;
- data['duration'] = this.duration;
- data['jump_count'] = this.jumpCount;
- data['crouch_count'] = this.crouchCount;
- return data;
- }
- }
|