| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- /*
- Flutter3.x完全开发手册 https://www.flutterschool.cn/
- */
- import 'package:news_app/extension/base.dart';
- class ActivityModelRecord {
- String? contentId;
- String? title;
- String? content;
- String? summary;
- String? videoUrl;
- String? image;
- String? registerStartTime;
- String? registerEndTime;
- String? activityStartTime;
- String? activityEndTime;
- int? registerLimit;
- String? activityLocation;
- String? activityOrg;
- String? status;
- String? contentType;
- //0.未报名 1.已报名 2.审核通过 3.审核不通过
- String? registerStatus;
- //可否报名
- bool? canRegister;
- int? likeCount;
- int? commentCount;
- int? favoriteCount;
- int? viewCount;
- int? shareCount;
- bool? isLiked;
- bool? isFavorite;
- String? shareUrl;
- String? shareDesc;
- ActivityModelRecord({
- this.contentId,
- this.title,
- this.content,
- this.summary,
- this.videoUrl,
- this.image,
- this.registerStartTime,
- this.registerEndTime,
- this.activityStartTime,
- this.activityEndTime,
- this.registerLimit,
- this.activityLocation,
- this.activityOrg,
- this.status,
- this.contentType,
- this.registerStatus,
- this.canRegister,
- this.likeCount,
- this.commentCount,
- this.favoriteCount,
- this.viewCount,
- this.shareCount,
- this.isLiked,
- this.isFavorite,
- this.shareUrl,
- this.shareDesc,
- });
- ActivityModelRecord.fromJson(Map<String, dynamic> json) {
- contentId = json['contentId']?.toString();
- title = json['title']?.toString();
- content = json['content']?.toString();
- summary = json['summary']?.toString();
- videoUrl = json['videoUrl']?.toString();
- image = json['image']?.toString();
- registerStartTime = json['registerStartTime']?.toString();
- registerEndTime = json['registerEndTime']?.toString();
- activityStartTime = json['activityStartTime']?.toString();
- activityEndTime = json['activityEndTime']?.toString();
- registerLimit = json['registerLimit']?.toInt();
- activityLocation = json['activityLocation']?.toString();
- activityOrg = json['activityOrg']?.toString();
- status = json['status']?.toString();
- contentType = json['contentType']?.toString();
- registerStatus = json['registerStatus']?.toString();
- canRegister = json['canRegister'] == true;
- likeCount = json['likeCount']?.toInt();
- commentCount = json['commentCount']?.toInt();
- favoriteCount = json['favoriteCount']?.toInt();
- viewCount = json['viewCount']?.toInt();
- shareCount = json['shareCount']?.toInt();
- isLiked = json['isLiked'] == true;
- isFavorite = json['isFavorite'] == true;
- shareUrl = json['shareUrl']?.toString();
- shareDesc = json['shareDesc']?.toString();
- }
- Map<String, dynamic> toJson() {
- final data = <String, dynamic>{};
- data['contentId'] = contentId;
- data['title'] = title;
- data['content'] = content;
- data['summary'] = summary;
- data['videoUrl'] = videoUrl;
- data['image'] = image;
- data['registerStartTime'] = registerStartTime;
- data['registerEndTime'] = registerEndTime;
- data['activityStartTime'] = activityStartTime;
- data['activityEndTime'] = activityEndTime;
- data['registerLimit'] = registerLimit;
- data['activityLocation'] = activityLocation;
- data['activityOrg'] = activityOrg;
- data['status'] = status;
- data['contentType'] = contentType;
- data['registerStatus'] = registerStatus;
- data['canRegister'] = canRegister;
- data['likeCount'] = likeCount;
- data['commentCount'] = commentCount;
- data['favoriteCount'] = favoriteCount;
- data['viewCount'] = viewCount;
- data['shareCount'] = shareCount;
- data['isLiked'] = isLiked;
- data['isFavorite'] = isFavorite;
- data['shareUrl'] = shareUrl;
- data['shareDesc'] = shareDesc;
- return data;
- }
- //生成copyWith方法
- ActivityModelRecord copyWith({
- String? contentId,
- String? title,
- String? content,
- String? summary,
- String? videoUrl,
- String? image,
- String? registerStartTime,
- String? registerEndTime,
- String? activityStartTime,
- String? activityEndTime,
- int? registerLimit,
- String? activityLocation,
- String? activityOrg,
- String? status,
- String? contentType,
- String? registerStatus,
- bool? canRegister,
- int? likeCount,
- int? commentCount,
- int? favoriteCount,
- int? viewCount,
- int? shareCount,
- bool? isLiked,
- bool? isFavorite,
- String? shareUrl,
- String? shareDesc,
- }) {
- return ActivityModelRecord(
- contentId: contentId ?? this.contentId,
- title: title ?? this.title,
- content: content ?? this.content,
- summary: summary ?? this.summary,
- videoUrl: videoUrl ?? this.videoUrl,
- image: image ?? this.image,
- registerStartTime: registerStartTime ?? this.registerStartTime,
- registerEndTime: registerEndTime ?? this.registerEndTime,
- activityStartTime: activityStartTime ?? this.activityStartTime,
- activityEndTime: activityEndTime ?? this.activityEndTime,
- registerLimit: registerLimit ?? this.registerLimit,
- activityLocation: activityLocation ?? this.activityLocation,
- activityOrg: activityOrg ?? this.activityOrg,
- status: status ?? this.status,
- contentType: contentType ?? this.contentType,
- registerStatus: registerStatus ?? this.registerStatus,
- canRegister: canRegister ?? this.canRegister,
- likeCount: likeCount ?? this.likeCount,
- commentCount: commentCount ?? this.commentCount,
- favoriteCount: favoriteCount ?? this.favoriteCount,
- viewCount: viewCount ?? this.viewCount,
- shareCount: shareCount ?? this.shareCount,
- isLiked: isLiked ?? this.isLiked,
- isFavorite: isFavorite ?? this.isFavorite,
- shareUrl:shareUrl ?? this.shareUrl,
- shareDesc:shareDesc ?? this.shareDesc,
- );
- }
- }
- class ActivityModel {
- List<ActivityModelRecord?>? records;
- int? total;
- int? size;
- int? current;
- int? pages;
- ActivityModel({
- this.records,
- this.total,
- this.size,
- this.current,
- this.pages,
- });
- ActivityModel.fromJson(Map<String, dynamic> json) {
- if (json['records'] != null) {
- final v = json['records'];
- final arr0 = <ActivityModelRecord>[];
- v.forEach((v) {
- arr0.add(ActivityModelRecord.fromJson(v));
- });
- records = arr0;
- }
- total = json['total']?.toString().convertInt;
- size = json['size']?.toString().convertInt;
- current = json['current']?.toString().convertInt;
- pages = json['pages']?.toString().convertInt;
- }
- Map<String, dynamic> toJson() {
- final data = <String, dynamic>{};
- if (records != null) {
- final v = records;
- final arr0 = [];
- for (var v in v!) {
- arr0.add(v!.toJson());
- }
- data['records'] = arr0;
- }
- data['total'] = total;
- data['size'] = size;
- data['current'] = current;
- data['pages'] = pages;
- return data;
- }
- //生成copyWith方法
- ActivityModel copyWith({
- List<ActivityModelRecord?>? records,
- int? total,
- int? size,
- int? current,
- int? pages,
- }) {
- return ActivityModel(
- records: records ?? this.records,
- total: total ?? this.total,
- size: size ?? this.size,
- current: current ?? this.current,
- pages: pages ?? this.pages,
- );
- }
- }
|