property_news_entity.g.dart 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import 'package:domain/generated/json/base/json_convert_content.dart';
  2. import 'package:domain/entity/property_news_entity.dart';
  3. PropertyNewsEntity $PropertyNewsEntityFromJson(Map<String, dynamic> json) {
  4. final PropertyNewsEntity propertyNewsEntity = PropertyNewsEntity();
  5. final int? count = jsonConvert.convert<int>(json['count']);
  6. if (count != null) {
  7. propertyNewsEntity.count = count;
  8. }
  9. final int? page = jsonConvert.convert<int>(json['page']);
  10. if (page != null) {
  11. propertyNewsEntity.page = page;
  12. }
  13. final int? limit = jsonConvert.convert<int>(json['limit']);
  14. if (limit != null) {
  15. propertyNewsEntity.limit = limit;
  16. }
  17. final int? countPage = jsonConvert.convert<int>(json['count_page']);
  18. if (countPage != null) {
  19. propertyNewsEntity.countPage = countPage;
  20. }
  21. final List<PropertyNewsList>? list = (json['list'] as List<dynamic>?)
  22. ?.map(
  23. (e) => jsonConvert.convert<PropertyNewsList>(e) as PropertyNewsList)
  24. .toList();
  25. if (list != null) {
  26. propertyNewsEntity.list = list;
  27. }
  28. return propertyNewsEntity;
  29. }
  30. Map<String, dynamic> $PropertyNewsEntityToJson(PropertyNewsEntity 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 PropertyNewsEntityExtension on PropertyNewsEntity {
  40. PropertyNewsEntity copyWith({
  41. int? count,
  42. int? page,
  43. int? limit,
  44. int? countPage,
  45. List<PropertyNewsList>? list,
  46. }) {
  47. return PropertyNewsEntity()
  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. PropertyNewsList $PropertyNewsListFromJson(Map<String, dynamic> json) {
  56. final PropertyNewsList propertyNewsList = PropertyNewsList();
  57. final int? id = jsonConvert.convert<int>(json['id']);
  58. if (id != null) {
  59. propertyNewsList.id = id;
  60. }
  61. final String? title = jsonConvert.convert<String>(json['title']);
  62. if (title != null) {
  63. propertyNewsList.title = title;
  64. }
  65. final String? coverImage = jsonConvert.convert<String>(json['cover_image']);
  66. if (coverImage != null) {
  67. propertyNewsList.coverImage = coverImage;
  68. }
  69. final String? content = jsonConvert.convert<String>(json['content']);
  70. if (content != null) {
  71. propertyNewsList.content = content;
  72. }
  73. final int? likesCount = jsonConvert.convert<int>(json['likes_count']);
  74. if (likesCount != null) {
  75. propertyNewsList.likesCount = likesCount;
  76. }
  77. final bool? liked = jsonConvert.convert<bool>(json['liked']);
  78. if (liked != null) {
  79. propertyNewsList.liked = liked;
  80. }
  81. final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  82. if (createdAt != null) {
  83. propertyNewsList.createdAt = createdAt;
  84. }
  85. return propertyNewsList;
  86. }
  87. Map<String, dynamic> $PropertyNewsListToJson(PropertyNewsList entity) {
  88. final Map<String, dynamic> data = <String, dynamic>{};
  89. data['id'] = entity.id;
  90. data['title'] = entity.title;
  91. data['cover_image'] = entity.coverImage;
  92. data['content'] = entity.content;
  93. data['likes_count'] = entity.likesCount;
  94. data['liked'] = entity.liked;
  95. data['created_at'] = entity.createdAt;
  96. return data;
  97. }
  98. extension PropertyNewsListExtension on PropertyNewsList {
  99. PropertyNewsList copyWith({
  100. int? id,
  101. String? title,
  102. String? coverImage,
  103. String? content,
  104. int? likesCount,
  105. bool? liked,
  106. String? createdAt,
  107. }) {
  108. return PropertyNewsList()
  109. ..id = id ?? this.id
  110. ..title = title ?? this.title
  111. ..coverImage = coverImage ?? this.coverImage
  112. ..content = content ?? this.content
  113. ..likesCount = likesCount ?? this.likesCount
  114. ..liked = liked ?? this.liked
  115. ..createdAt = createdAt ?? this.createdAt;
  116. }
  117. }