123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- import 'package:domain/generated/json/base/json_convert_content.dart';
- import 'package:domain/entity/newsfeed_detail_entity.dart';
- NewsfeedDetailEntity $NewsfeedDetailEntityFromJson(Map<String, dynamic> json) {
- final NewsfeedDetailEntity newsfeedDetailEntity = NewsfeedDetailEntity();
- final int? id = jsonConvert.convert<int>(json['id']);
- if (id != null) {
- newsfeedDetailEntity.id = id;
- }
- final String? content = jsonConvert.convert<String>(json['content']);
- if (content != null) {
- newsfeedDetailEntity.content = content;
- }
- final List<String>? resources = (json['resources'] as List<dynamic>?)?.map(
- (e) => jsonConvert.convert<String>(e) as String).toList();
- if (resources != null) {
- newsfeedDetailEntity.resources = resources;
- }
- final int? clicks = jsonConvert.convert<int>(json['clicks']);
- if (clicks != null) {
- newsfeedDetailEntity.clicks = clicks;
- }
- final int? share = jsonConvert.convert<int>(json['share']);
- if (share != null) {
- newsfeedDetailEntity.share = share;
- }
- final String? createdAt = jsonConvert.convert<String>(json['created_at']);
- if (createdAt != null) {
- newsfeedDetailEntity.createdAt = createdAt;
- }
- final int? likesCount = jsonConvert.convert<int>(json['likes_count']);
- if (likesCount != null) {
- newsfeedDetailEntity.likesCount = likesCount;
- }
- final int? commentsCount = jsonConvert.convert<int>(json['comments_count']);
- if (commentsCount != null) {
- newsfeedDetailEntity.commentsCount = commentsCount;
- }
- final bool? liked = jsonConvert.convert<bool>(json['liked']);
- if (liked != null) {
- newsfeedDetailEntity.liked = liked;
- }
- final NewsfeedDetailAccount? account = jsonConvert.convert<
- NewsfeedDetailAccount>(json['account']);
- if (account != null) {
- newsfeedDetailEntity.account = account;
- }
- final List<NewsfeedDetailComments>? comments = (json['comments'] as List<
- dynamic>?)
- ?.map(
- (e) =>
- jsonConvert.convert<NewsfeedDetailComments>(e) as NewsfeedDetailComments)
- .toList();
- if (comments != null) {
- newsfeedDetailEntity.comments = comments;
- }
- return newsfeedDetailEntity;
- }
- Map<String, dynamic> $NewsfeedDetailEntityToJson(NewsfeedDetailEntity entity) {
- final Map<String, dynamic> data = <String, dynamic>{};
- data['id'] = entity.id;
- data['content'] = entity.content;
- data['resources'] = entity.resources;
- data['clicks'] = entity.clicks;
- data['share'] = entity.share;
- data['created_at'] = entity.createdAt;
- data['likes_count'] = entity.likesCount;
- data['comments_count'] = entity.commentsCount;
- data['liked'] = entity.liked;
- data['account'] = entity.account?.toJson();
- data['comments'] = entity.comments?.map((v) => v.toJson()).toList();
- return data;
- }
- extension NewsfeedDetailEntityExtension on NewsfeedDetailEntity {
- NewsfeedDetailEntity copyWith({
- int? id,
- String? content,
- List<String>? resources,
- int? clicks,
- int? share,
- String? createdAt,
- int? likesCount,
- int? commentsCount,
- bool? liked,
- NewsfeedDetailAccount? account,
- List<NewsfeedDetailComments>? comments,
- }) {
- return NewsfeedDetailEntity()
- ..id = id ?? this.id
- ..content = content ?? this.content
- ..resources = resources ?? this.resources
- ..clicks = clicks ?? this.clicks
- ..share = share ?? this.share
- ..createdAt = createdAt ?? this.createdAt
- ..likesCount = likesCount ?? this.likesCount
- ..commentsCount = commentsCount ?? this.commentsCount
- ..liked = liked ?? this.liked
- ..account = account ?? this.account
- ..comments = comments ?? this.comments;
- }
- }
- NewsfeedDetailAccount $NewsfeedDetailAccountFromJson(
- Map<String, dynamic> json) {
- final NewsfeedDetailAccount newsfeedDetailAccount = NewsfeedDetailAccount();
- final int? id = jsonConvert.convert<int>(json['id']);
- if (id != null) {
- newsfeedDetailAccount.id = id;
- }
- final String? name = jsonConvert.convert<String>(json['name']);
- if (name != null) {
- newsfeedDetailAccount.name = name;
- }
- final String? avatar = jsonConvert.convert<String>(json['avatar']);
- if (avatar != null) {
- newsfeedDetailAccount.avatar = avatar;
- }
- final bool? followed = jsonConvert.convert<bool>(json['followed']);
- if (followed != null) {
- newsfeedDetailAccount.followed = followed;
- }
- return newsfeedDetailAccount;
- }
- Map<String, dynamic> $NewsfeedDetailAccountToJson(
- NewsfeedDetailAccount entity) {
- final Map<String, dynamic> data = <String, dynamic>{};
- data['id'] = entity.id;
- data['name'] = entity.name;
- data['avatar'] = entity.avatar;
- data['followed'] = entity.followed;
- return data;
- }
- extension NewsfeedDetailAccountExtension on NewsfeedDetailAccount {
- NewsfeedDetailAccount copyWith({
- int? id,
- String? name,
- String? avatar,
- bool? followed,
- }) {
- return NewsfeedDetailAccount()
- ..id = id ?? this.id
- ..name = name ?? this.name
- ..avatar = avatar ?? this.avatar
- ..followed = followed ?? this.followed;
- }
- }
- NewsfeedDetailComments $NewsfeedDetailCommentsFromJson(
- Map<String, dynamic> json) {
- final NewsfeedDetailComments newsfeedDetailComments = NewsfeedDetailComments();
- final int? id = jsonConvert.convert<int>(json['id']);
- if (id != null) {
- newsfeedDetailComments.id = id;
- }
- final String? content = jsonConvert.convert<String>(json['content']);
- if (content != null) {
- newsfeedDetailComments.content = content;
- }
- final String? createdAt = jsonConvert.convert<String>(json['created_at']);
- if (createdAt != null) {
- newsfeedDetailComments.createdAt = createdAt;
- }
- final NewsfeedDetailCommentsAccount? account = jsonConvert.convert<
- NewsfeedDetailCommentsAccount>(json['account']);
- if (account != null) {
- newsfeedDetailComments.account = account;
- }
- final NewsfeedDetailCommentsToAccount? toAccount = jsonConvert.convert<
- NewsfeedDetailCommentsToAccount>(json['to_account']);
- if (toAccount != null) {
- newsfeedDetailComments.toAccount = toAccount;
- }
- return newsfeedDetailComments;
- }
- Map<String, dynamic> $NewsfeedDetailCommentsToJson(
- NewsfeedDetailComments entity) {
- final Map<String, dynamic> data = <String, dynamic>{};
- data['id'] = entity.id;
- data['content'] = entity.content;
- data['created_at'] = entity.createdAt;
- data['account'] = entity.account?.toJson();
- data['to_account'] = entity.toAccount?.toJson();
- return data;
- }
- extension NewsfeedDetailCommentsExtension on NewsfeedDetailComments {
- NewsfeedDetailComments copyWith({
- int? id,
- String? content,
- String? createdAt,
- NewsfeedDetailCommentsAccount? account,
- NewsfeedDetailCommentsToAccount? toAccount,
- }) {
- return NewsfeedDetailComments()
- ..id = id ?? this.id
- ..content = content ?? this.content
- ..createdAt = createdAt ?? this.createdAt
- ..account = account ?? this.account
- ..toAccount = toAccount ?? this.toAccount;
- }
- }
- NewsfeedDetailCommentsAccount $NewsfeedDetailCommentsAccountFromJson(
- Map<String, dynamic> json) {
- final NewsfeedDetailCommentsAccount newsfeedDetailCommentsAccount = NewsfeedDetailCommentsAccount();
- final int? id = jsonConvert.convert<int>(json['id']);
- if (id != null) {
- newsfeedDetailCommentsAccount.id = id;
- }
- final String? name = jsonConvert.convert<String>(json['name']);
- if (name != null) {
- newsfeedDetailCommentsAccount.name = name;
- }
- final String? avatar = jsonConvert.convert<String>(json['avatar']);
- if (avatar != null) {
- newsfeedDetailCommentsAccount.avatar = avatar;
- }
- return newsfeedDetailCommentsAccount;
- }
- Map<String, dynamic> $NewsfeedDetailCommentsAccountToJson(
- NewsfeedDetailCommentsAccount entity) {
- final Map<String, dynamic> data = <String, dynamic>{};
- data['id'] = entity.id;
- data['name'] = entity.name;
- data['avatar'] = entity.avatar;
- return data;
- }
- extension NewsfeedDetailCommentsAccountExtension on NewsfeedDetailCommentsAccount {
- NewsfeedDetailCommentsAccount copyWith({
- int? id,
- String? name,
- String? avatar,
- }) {
- return NewsfeedDetailCommentsAccount()
- ..id = id ?? this.id
- ..name = name ?? this.name
- ..avatar = avatar ?? this.avatar;
- }
- }
- NewsfeedDetailCommentsToAccount $NewsfeedDetailCommentsToAccountFromJson(
- Map<String, dynamic> json) {
- final NewsfeedDetailCommentsToAccount newsfeedDetailCommentsToAccount = NewsfeedDetailCommentsToAccount();
- final int? id = jsonConvert.convert<int>(json['id']);
- if (id != null) {
- newsfeedDetailCommentsToAccount.id = id;
- }
- final String? name = jsonConvert.convert<String>(json['name']);
- if (name != null) {
- newsfeedDetailCommentsToAccount.name = name;
- }
- final String? avatar = jsonConvert.convert<String>(json['avatar']);
- if (avatar != null) {
- newsfeedDetailCommentsToAccount.avatar = avatar;
- }
- return newsfeedDetailCommentsToAccount;
- }
- Map<String, dynamic> $NewsfeedDetailCommentsToAccountToJson(
- NewsfeedDetailCommentsToAccount entity) {
- final Map<String, dynamic> data = <String, dynamic>{};
- data['id'] = entity.id;
- data['name'] = entity.name;
- data['avatar'] = entity.avatar;
- return data;
- }
- extension NewsfeedDetailCommentsToAccountExtension on NewsfeedDetailCommentsToAccount {
- NewsfeedDetailCommentsToAccount copyWith({
- int? id,
- String? name,
- String? avatar,
- }) {
- return NewsfeedDetailCommentsToAccount()
- ..id = id ?? this.id
- ..name = name ?? this.name
- ..avatar = avatar ?? this.avatar;
- }
- }
|