activity_model.dart 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. /*
  2. Flutter3.x完全开发手册 https://www.flutterschool.cn/
  3. */
  4. import 'package:news_app/extension/base.dart';
  5. class ActivityModelRecord {
  6. String? contentId;
  7. String? title;
  8. String? content;
  9. String? summary;
  10. String? videoUrl;
  11. String? image;
  12. String? registerStartTime;
  13. String? registerEndTime;
  14. String? activityStartTime;
  15. String? activityEndTime;
  16. int? registerLimit;
  17. String? activityLocation;
  18. String? activityOrg;
  19. String? status;
  20. String? contentType;
  21. //0.未报名 1.已报名 2.审核通过 3.审核不通过
  22. String? registerStatus;
  23. //可否报名
  24. bool? canRegister;
  25. int? likeCount;
  26. int? commentCount;
  27. int? favoriteCount;
  28. int? viewCount;
  29. int? shareCount;
  30. bool? isLiked;
  31. bool? isFavorite;
  32. String? shareUrl;
  33. String? shareDesc;
  34. ActivityModelRecord({
  35. this.contentId,
  36. this.title,
  37. this.content,
  38. this.summary,
  39. this.videoUrl,
  40. this.image,
  41. this.registerStartTime,
  42. this.registerEndTime,
  43. this.activityStartTime,
  44. this.activityEndTime,
  45. this.registerLimit,
  46. this.activityLocation,
  47. this.activityOrg,
  48. this.status,
  49. this.contentType,
  50. this.registerStatus,
  51. this.canRegister,
  52. this.likeCount,
  53. this.commentCount,
  54. this.favoriteCount,
  55. this.viewCount,
  56. this.shareCount,
  57. this.isLiked,
  58. this.isFavorite,
  59. this.shareUrl,
  60. this.shareDesc,
  61. });
  62. ActivityModelRecord.fromJson(Map<String, dynamic> json) {
  63. contentId = json['contentId']?.toString();
  64. title = json['title']?.toString();
  65. content = json['content']?.toString();
  66. summary = json['summary']?.toString();
  67. videoUrl = json['videoUrl']?.toString();
  68. image = json['image']?.toString();
  69. registerStartTime = json['registerStartTime']?.toString();
  70. registerEndTime = json['registerEndTime']?.toString();
  71. activityStartTime = json['activityStartTime']?.toString();
  72. activityEndTime = json['activityEndTime']?.toString();
  73. registerLimit = json['registerLimit']?.toInt();
  74. activityLocation = json['activityLocation']?.toString();
  75. activityOrg = json['activityOrg']?.toString();
  76. status = json['status']?.toString();
  77. contentType = json['contentType']?.toString();
  78. registerStatus = json['registerStatus']?.toString();
  79. canRegister = json['canRegister'] == true;
  80. likeCount = json['likeCount']?.toInt();
  81. commentCount = json['commentCount']?.toInt();
  82. favoriteCount = json['favoriteCount']?.toInt();
  83. viewCount = json['viewCount']?.toInt();
  84. shareCount = json['shareCount']?.toInt();
  85. isLiked = json['isLiked'] == true;
  86. isFavorite = json['isFavorite'] == true;
  87. shareUrl = json['shareUrl']?.toString();
  88. shareDesc = json['shareDesc']?.toString();
  89. }
  90. Map<String, dynamic> toJson() {
  91. final data = <String, dynamic>{};
  92. data['contentId'] = contentId;
  93. data['title'] = title;
  94. data['content'] = content;
  95. data['summary'] = summary;
  96. data['videoUrl'] = videoUrl;
  97. data['image'] = image;
  98. data['registerStartTime'] = registerStartTime;
  99. data['registerEndTime'] = registerEndTime;
  100. data['activityStartTime'] = activityStartTime;
  101. data['activityEndTime'] = activityEndTime;
  102. data['registerLimit'] = registerLimit;
  103. data['activityLocation'] = activityLocation;
  104. data['activityOrg'] = activityOrg;
  105. data['status'] = status;
  106. data['contentType'] = contentType;
  107. data['registerStatus'] = registerStatus;
  108. data['canRegister'] = canRegister;
  109. data['likeCount'] = likeCount;
  110. data['commentCount'] = commentCount;
  111. data['favoriteCount'] = favoriteCount;
  112. data['viewCount'] = viewCount;
  113. data['shareCount'] = shareCount;
  114. data['isLiked'] = isLiked;
  115. data['isFavorite'] = isFavorite;
  116. data['shareUrl'] = shareUrl;
  117. data['shareDesc'] = shareDesc;
  118. return data;
  119. }
  120. //生成copyWith方法
  121. ActivityModelRecord copyWith({
  122. String? contentId,
  123. String? title,
  124. String? content,
  125. String? summary,
  126. String? videoUrl,
  127. String? image,
  128. String? registerStartTime,
  129. String? registerEndTime,
  130. String? activityStartTime,
  131. String? activityEndTime,
  132. int? registerLimit,
  133. String? activityLocation,
  134. String? activityOrg,
  135. String? status,
  136. String? contentType,
  137. String? registerStatus,
  138. bool? canRegister,
  139. int? likeCount,
  140. int? commentCount,
  141. int? favoriteCount,
  142. int? viewCount,
  143. int? shareCount,
  144. bool? isLiked,
  145. bool? isFavorite,
  146. String? shareUrl,
  147. String? shareDesc,
  148. }) {
  149. return ActivityModelRecord(
  150. contentId: contentId ?? this.contentId,
  151. title: title ?? this.title,
  152. content: content ?? this.content,
  153. summary: summary ?? this.summary,
  154. videoUrl: videoUrl ?? this.videoUrl,
  155. image: image ?? this.image,
  156. registerStartTime: registerStartTime ?? this.registerStartTime,
  157. registerEndTime: registerEndTime ?? this.registerEndTime,
  158. activityStartTime: activityStartTime ?? this.activityStartTime,
  159. activityEndTime: activityEndTime ?? this.activityEndTime,
  160. registerLimit: registerLimit ?? this.registerLimit,
  161. activityLocation: activityLocation ?? this.activityLocation,
  162. activityOrg: activityOrg ?? this.activityOrg,
  163. status: status ?? this.status,
  164. contentType: contentType ?? this.contentType,
  165. registerStatus: registerStatus ?? this.registerStatus,
  166. canRegister: canRegister ?? this.canRegister,
  167. likeCount: likeCount ?? this.likeCount,
  168. commentCount: commentCount ?? this.commentCount,
  169. favoriteCount: favoriteCount ?? this.favoriteCount,
  170. viewCount: viewCount ?? this.viewCount,
  171. shareCount: shareCount ?? this.shareCount,
  172. isLiked: isLiked ?? this.isLiked,
  173. isFavorite: isFavorite ?? this.isFavorite,
  174. shareUrl:shareUrl ?? this.shareUrl,
  175. shareDesc:shareDesc ?? this.shareDesc,
  176. );
  177. }
  178. }
  179. class ActivityModel {
  180. List<ActivityModelRecord?>? records;
  181. int? total;
  182. int? size;
  183. int? current;
  184. int? pages;
  185. ActivityModel({
  186. this.records,
  187. this.total,
  188. this.size,
  189. this.current,
  190. this.pages,
  191. });
  192. ActivityModel.fromJson(Map<String, dynamic> json) {
  193. if (json['records'] != null) {
  194. final v = json['records'];
  195. final arr0 = <ActivityModelRecord>[];
  196. v.forEach((v) {
  197. arr0.add(ActivityModelRecord.fromJson(v));
  198. });
  199. records = arr0;
  200. }
  201. total = json['total']?.toString().convertInt;
  202. size = json['size']?.toString().convertInt;
  203. current = json['current']?.toString().convertInt;
  204. pages = json['pages']?.toString().convertInt;
  205. }
  206. Map<String, dynamic> toJson() {
  207. final data = <String, dynamic>{};
  208. if (records != null) {
  209. final v = records;
  210. final arr0 = [];
  211. for (var v in v!) {
  212. arr0.add(v!.toJson());
  213. }
  214. data['records'] = arr0;
  215. }
  216. data['total'] = total;
  217. data['size'] = size;
  218. data['current'] = current;
  219. data['pages'] = pages;
  220. return data;
  221. }
  222. //生成copyWith方法
  223. ActivityModel copyWith({
  224. List<ActivityModelRecord?>? records,
  225. int? total,
  226. int? size,
  227. int? current,
  228. int? pages,
  229. }) {
  230. return ActivityModel(
  231. records: records ?? this.records,
  232. total: total ?? this.total,
  233. size: size ?? this.size,
  234. current: current ?? this.current,
  235. pages: pages ?? this.pages,
  236. );
  237. }
  238. }