newsfeed_foryou_entity.g.dart 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. import 'package:domain/generated/json/base/json_convert_content.dart';
  2. import 'package:domain/entity/newsfeed_foryou_entity.dart';
  3. NewsfeedForyouEntity $NewsfeedForyouEntityFromJson(Map<String, dynamic> json) {
  4. final NewsfeedForyouEntity newsfeedForyouEntity = NewsfeedForyouEntity();
  5. final int? count = jsonConvert.convert<int>(json['count']);
  6. if (count != null) {
  7. newsfeedForyouEntity.count = count;
  8. }
  9. final int? page = jsonConvert.convert<int>(json['page']);
  10. if (page != null) {
  11. newsfeedForyouEntity.page = page;
  12. }
  13. final int? limit = jsonConvert.convert<int>(json['limit']);
  14. if (limit != null) {
  15. newsfeedForyouEntity.limit = limit;
  16. }
  17. final int? countPage = jsonConvert.convert<int>(json['count_page']);
  18. if (countPage != null) {
  19. newsfeedForyouEntity.countPage = countPage;
  20. }
  21. final List<NewsfeedForyouList>? list = (json['list'] as List<dynamic>?)
  22. ?.map(
  23. (e) =>
  24. jsonConvert.convert<NewsfeedForyouList>(e) as NewsfeedForyouList)
  25. .toList();
  26. if (list != null) {
  27. newsfeedForyouEntity.list = list;
  28. }
  29. return newsfeedForyouEntity;
  30. }
  31. Map<String, dynamic> $NewsfeedForyouEntityToJson(NewsfeedForyouEntity entity) {
  32. final Map<String, dynamic> data = <String, dynamic>{};
  33. data['count'] = entity.count;
  34. data['page'] = entity.page;
  35. data['limit'] = entity.limit;
  36. data['count_page'] = entity.countPage;
  37. data['list'] = entity.list?.map((v) => v.toJson()).toList();
  38. return data;
  39. }
  40. extension NewsfeedForyouEntityExtension on NewsfeedForyouEntity {
  41. NewsfeedForyouEntity copyWith({
  42. int? count,
  43. int? page,
  44. int? limit,
  45. int? countPage,
  46. List<NewsfeedForyouList>? list,
  47. }) {
  48. return NewsfeedForyouEntity()
  49. ..count = count ?? this.count
  50. ..page = page ?? this.page
  51. ..limit = limit ?? this.limit
  52. ..countPage = countPage ?? this.countPage
  53. ..list = list ?? this.list;
  54. }
  55. }
  56. NewsfeedForyouList $NewsfeedForyouListFromJson(Map<String, dynamic> json) {
  57. final NewsfeedForyouList newsfeedForyouList = NewsfeedForyouList();
  58. final int? id = jsonConvert.convert<int>(json['id']);
  59. if (id != null) {
  60. newsfeedForyouList.id = id;
  61. }
  62. final String? content = jsonConvert.convert<String>(json['content']);
  63. if (content != null) {
  64. newsfeedForyouList.content = content;
  65. }
  66. final List<String>? resources = (json['resources'] as List<dynamic>?)?.map(
  67. (e) => jsonConvert.convert<String>(e) as String).toList();
  68. if (resources != null) {
  69. newsfeedForyouList.resources = resources;
  70. }
  71. final int? likesCount = jsonConvert.convert<int>(json['likes_count']);
  72. if (likesCount != null) {
  73. newsfeedForyouList.likesCount = likesCount;
  74. }
  75. final int? commentsCount = jsonConvert.convert<int>(json['comments_count']);
  76. if (commentsCount != null) {
  77. newsfeedForyouList.commentsCount = commentsCount;
  78. }
  79. final bool? liked = jsonConvert.convert<bool>(json['liked']);
  80. if (liked != null) {
  81. newsfeedForyouList.liked = liked;
  82. }
  83. final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  84. if (createdAt != null) {
  85. newsfeedForyouList.createdAt = createdAt;
  86. }
  87. final NewsfeedForyouListAccount? account = jsonConvert.convert<
  88. NewsfeedForyouListAccount>(json['account']);
  89. if (account != null) {
  90. newsfeedForyouList.account = account;
  91. }
  92. return newsfeedForyouList;
  93. }
  94. Map<String, dynamic> $NewsfeedForyouListToJson(NewsfeedForyouList entity) {
  95. final Map<String, dynamic> data = <String, dynamic>{};
  96. data['id'] = entity.id;
  97. data['content'] = entity.content;
  98. data['resources'] = entity.resources;
  99. data['likes_count'] = entity.likesCount;
  100. data['comments_count'] = entity.commentsCount;
  101. data['liked'] = entity.liked;
  102. data['created_at'] = entity.createdAt;
  103. data['account'] = entity.account?.toJson();
  104. return data;
  105. }
  106. extension NewsfeedForyouListExtension on NewsfeedForyouList {
  107. NewsfeedForyouList copyWith({
  108. int? id,
  109. String? content,
  110. List<String>? resources,
  111. int? likesCount,
  112. int? commentsCount,
  113. bool? liked,
  114. String? createdAt,
  115. NewsfeedForyouListAccount? account,
  116. }) {
  117. return NewsfeedForyouList()
  118. ..id = id ?? this.id
  119. ..content = content ?? this.content
  120. ..resources = resources ?? this.resources
  121. ..likesCount = likesCount ?? this.likesCount
  122. ..commentsCount = commentsCount ?? this.commentsCount
  123. ..liked = liked ?? this.liked
  124. ..createdAt = createdAt ?? this.createdAt
  125. ..account = account ?? this.account;
  126. }
  127. }
  128. NewsfeedForyouListAccount $NewsfeedForyouListAccountFromJson(
  129. Map<String, dynamic> json) {
  130. final NewsfeedForyouListAccount newsfeedForyouListAccount = NewsfeedForyouListAccount();
  131. final int? id = jsonConvert.convert<int>(json['id']);
  132. if (id != null) {
  133. newsfeedForyouListAccount.id = id;
  134. }
  135. final String? name = jsonConvert.convert<String>(json['name']);
  136. if (name != null) {
  137. newsfeedForyouListAccount.name = name;
  138. }
  139. final String? avatar = jsonConvert.convert<String>(json['avatar']);
  140. if (avatar != null) {
  141. newsfeedForyouListAccount.avatar = avatar;
  142. }
  143. final bool? followed = jsonConvert.convert<bool>(json['followed']);
  144. if (followed != null) {
  145. newsfeedForyouListAccount.followed = followed;
  146. }
  147. return newsfeedForyouListAccount;
  148. }
  149. Map<String, dynamic> $NewsfeedForyouListAccountToJson(
  150. NewsfeedForyouListAccount entity) {
  151. final Map<String, dynamic> data = <String, dynamic>{};
  152. data['id'] = entity.id;
  153. data['name'] = entity.name;
  154. data['avatar'] = entity.avatar;
  155. data['followed'] = entity.followed;
  156. return data;
  157. }
  158. extension NewsfeedForyouListAccountExtension on NewsfeedForyouListAccount {
  159. NewsfeedForyouListAccount copyWith({
  160. int? id,
  161. String? name,
  162. String? avatar,
  163. bool? followed,
  164. }) {
  165. return NewsfeedForyouListAccount()
  166. ..id = id ?? this.id
  167. ..name = name ?? this.name
  168. ..avatar = avatar ?? this.avatar
  169. ..followed = followed ?? this.followed;
  170. }
  171. }