opt: model (#851)

* opt: readlist model

* opt: video item model
This commit is contained in:
My-Responsitories
2025-05-11 17:00:24 +08:00
committed by GitHub
parent c899ea95e1
commit 8d34e6f340
15 changed files with 130 additions and 397 deletions

View File

@@ -1,84 +0,0 @@
import 'package:PiliPlus/models/dynamics/article_list/category.dart';
import 'package:PiliPlus/models/dynamics/article_list/stats.dart';
class Article {
int? id;
String? title;
int? state;
int? publishTime;
int? words;
List? imageUrls;
Category? category;
List<Category>? categories;
String? summary;
int? type;
String? dynIdStr;
int? attributes;
int? authorUid;
int? onlyFans;
Stats? stats;
int? likeState;
Article({
this.id,
this.title,
this.state,
this.publishTime,
this.words,
this.imageUrls,
this.category,
this.categories,
this.summary,
this.type,
this.dynIdStr,
this.attributes,
this.authorUid,
this.onlyFans,
this.stats,
this.likeState,
});
factory Article.fromJson(Map<String, dynamic> json) => Article(
id: json['id'] as int?,
title: json['title'] as String?,
state: json['state'] as int?,
publishTime: json['publish_time'] as int?,
words: json['words'] as int?,
imageUrls: json['image_urls'],
category: json['category'] == null
? null
: Category.fromJson(json['category'] as Map<String, dynamic>),
categories: (json['categories'] as List<dynamic>?)
?.map((e) => Category.fromJson(e as Map<String, dynamic>))
.toList(),
summary: json['summary'] as String?,
type: json['type'] as int?,
dynIdStr: json['dyn_id_str'] as String?,
attributes: json['attributes'] as int?,
authorUid: json['author_uid'] as int?,
onlyFans: json['only_fans'] as int?,
stats: json['stats'] == null
? null
: Stats.fromJson(json['stats'] as Map<String, dynamic>),
likeState: json['like_state'] as int?,
);
Map<String, dynamic> toJson() => {
'id': id,
'title': title,
'state': state,
'publish_time': publishTime,
'words': words,
'image_urls': imageUrls,
'category': category?.toJson(),
'categories': categories?.map((e) => e.toJson()).toList(),
'summary': summary,
'type': type,
'dyn_id_str': dynIdStr,
'attributes': attributes,
'author_uid': authorUid,
'only_fans': onlyFans,
'stats': stats?.toJson(),
'like_state': likeState,
};
}

View File

@@ -1,23 +0,0 @@
class Author {
int? mid;
String? name;
String? face;
Author({
this.mid,
this.name,
this.face,
});
factory Author.fromJson(Map<String, dynamic> json) => Author(
mid: json['mid'] as int?,
name: json['name'] as String?,
face: json['face'] as String?,
);
Map<String, dynamic> toJson() => {
'mid': mid,
'name': name,
'face': face,
};
}

View File

@@ -1,19 +0,0 @@
class Category {
int? id;
int? parentId;
String? name;
Category({this.id, this.parentId, this.name});
factory Category.fromJson(Map<String, dynamic> json) => Category(
id: json['id'] as int?,
parentId: json['parent_id'] as int?,
name: json['name'] as String?,
);
Map<String, dynamic> toJson() => {
'id': id,
'parent_id': parentId,
'name': name,
};
}

View File

@@ -1,11 +1,11 @@
import 'package:PiliPlus/models/dynamics/article_list/article.dart';
import 'package:PiliPlus/models/dynamics/article_list/author.dart';
import 'package:PiliPlus/models/dynamics/article_list/list.dart';
import 'package:PiliPlus/models/model_owner.dart';
import 'package:PiliPlus/models/space_article/item.dart';
class ArticleListData {
ArticleList? list;
List<Article>? articles;
Author? author;
List<SpaceArticleItem>? articles;
Owner? author;
bool? attention;
ArticleListData({
@@ -21,18 +21,11 @@ class ArticleListData {
? null
: ArticleList.fromJson(json['list'] as Map<String, dynamic>),
articles: (json['articles'] as List<dynamic>?)
?.map((e) => Article.fromJson(e as Map<String, dynamic>))
?.map((e) => SpaceArticleItem.fromJson(e as Map<String, dynamic>))
.toList(),
author: json['author'] == null
? null
: Author.fromJson(json['author'] as Map<String, dynamic>),
: Owner.fromJson(json['author'] as Map<String, dynamic>),
attention: json['attention'] as bool?,
);
Map<String, dynamic> toJson() => {
'list': list?.toJson(),
'articles': articles?.map((e) => e.toJson()).toList(),
'author': author?.toJson(),
'attention': attention,
};
}

View File

@@ -1,43 +0,0 @@
class Stats {
int? view;
int? favorite;
int? like;
int? dislike;
int? reply;
int? share;
int? coin;
int? dynam1c;
Stats({
this.view,
this.favorite,
this.like,
this.dislike,
this.reply,
this.share,
this.coin,
this.dynam1c,
});
factory Stats.fromJson(Map<String, dynamic> json) => Stats(
view: json['view'] as int?,
favorite: json['favorite'] as int?,
like: json['like'] as int?,
dislike: json['dislike'] as int?,
reply: json['reply'] as int?,
share: json['share'] as int?,
coin: json['coin'] as int?,
dynam1c: json['dynamic'] as int?,
);
Map<String, dynamic> toJson() => {
'view': view,
'favorite': favorite,
'like': like,
'dislike': dislike,
'reply': reply,
'share': share,
'coin': coin,
'dynamic': dynam1c,
};
}