newsfeed_news_entity.g.dart 5.9 KB

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