mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-20 17:16:29 +08:00
feat: pgc review
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
27
lib/models/bangumi/pgc_review/author.dart
Normal file
27
lib/models/bangumi/pgc_review/author.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'package:PiliPlus/models/model_avatar.dart' show Vip;
|
||||
|
||||
class Author {
|
||||
String? avatar;
|
||||
int? level;
|
||||
int? mid;
|
||||
String? uname;
|
||||
Vip? vip;
|
||||
|
||||
Author({
|
||||
this.avatar,
|
||||
this.level,
|
||||
this.mid,
|
||||
this.uname,
|
||||
this.vip,
|
||||
});
|
||||
|
||||
factory Author.fromJson(Map<String, dynamic> json) => Author(
|
||||
avatar: json['avatar'] as String?,
|
||||
level: json['level'] as int?,
|
||||
mid: json['mid'] as int?,
|
||||
uname: json['uname'] as String?,
|
||||
vip: json['vip'] == null
|
||||
? null
|
||||
: Vip.fromJson(json['vip'] as Map<String, dynamic>),
|
||||
);
|
||||
}
|
||||
17
lib/models/bangumi/pgc_review/data.dart
Normal file
17
lib/models/bangumi/pgc_review/data.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'package:PiliPlus/models/bangumi/pgc_review/list.dart';
|
||||
|
||||
class PgcReviewData {
|
||||
List<PgcReviewItemModel>? list;
|
||||
String? next;
|
||||
int? count;
|
||||
|
||||
PgcReviewData({this.list, this.next, this.count});
|
||||
|
||||
factory PgcReviewData.fromJson(Map<String, dynamic> json) => PgcReviewData(
|
||||
list: (json['list'] as List<dynamic>?)
|
||||
?.map((e) => PgcReviewItemModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
next: json['next'] as String?,
|
||||
count: json['count'] as int?,
|
||||
);
|
||||
}
|
||||
55
lib/models/bangumi/pgc_review/list.dart
Normal file
55
lib/models/bangumi/pgc_review/list.dart
Normal file
@@ -0,0 +1,55 @@
|
||||
import 'package:PiliPlus/models/bangumi/pgc_review/author.dart';
|
||||
import 'package:PiliPlus/models/bangumi/pgc_review/stat.dart';
|
||||
|
||||
class PgcReviewItemModel {
|
||||
Author? author;
|
||||
String? title;
|
||||
String? content;
|
||||
int? ctime;
|
||||
int? mediaId;
|
||||
int? mid;
|
||||
int? mtime;
|
||||
String? progress;
|
||||
String? pushTimeStr;
|
||||
int? reviewId;
|
||||
late int score;
|
||||
Stat? stat;
|
||||
int? articleId;
|
||||
|
||||
PgcReviewItemModel({
|
||||
this.author,
|
||||
this.title,
|
||||
this.content,
|
||||
this.ctime,
|
||||
this.mediaId,
|
||||
this.mid,
|
||||
this.mtime,
|
||||
this.progress,
|
||||
this.pushTimeStr,
|
||||
this.reviewId,
|
||||
required this.score,
|
||||
this.stat,
|
||||
this.articleId,
|
||||
});
|
||||
|
||||
factory PgcReviewItemModel.fromJson(Map<String, dynamic> json) =>
|
||||
PgcReviewItemModel(
|
||||
articleId: json['article_id'],
|
||||
author: json['author'] == null
|
||||
? null
|
||||
: Author.fromJson(json['author'] as Map<String, dynamic>),
|
||||
title: json['title'] as String?,
|
||||
content: json['content'] as String?,
|
||||
ctime: json['ctime'] as int?,
|
||||
mediaId: json['media_id'] as int?,
|
||||
mid: json['mid'] as int?,
|
||||
mtime: json['mtime'] as int?,
|
||||
progress: json['progress'] as String?,
|
||||
pushTimeStr: json['push_time_str'] as String?,
|
||||
reviewId: json['review_id'] as int?,
|
||||
score: json['score'] == null ? 0 : json['score'] ~/ 2,
|
||||
stat: json['stat'] == null
|
||||
? null
|
||||
: Stat.fromJson(json['stat'] as Map<String, dynamic>),
|
||||
);
|
||||
}
|
||||
19
lib/models/bangumi/pgc_review/stat.dart
Normal file
19
lib/models/bangumi/pgc_review/stat.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
class Stat {
|
||||
int? disliked;
|
||||
int? liked;
|
||||
int? likes;
|
||||
|
||||
Stat({this.disliked, this.liked, this.likes});
|
||||
|
||||
factory Stat.fromJson(Map<String, dynamic> json) => Stat(
|
||||
disliked: json['disliked'] as int?,
|
||||
liked: json['liked'] as int?,
|
||||
likes: json['likes'] as int?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'disliked': disliked,
|
||||
'liked': liked,
|
||||
'likes': likes,
|
||||
};
|
||||
}
|
||||
13
lib/models/common/pgc_review_type.dart
Normal file
13
lib/models/common/pgc_review_type.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import 'package:PiliPlus/http/api.dart';
|
||||
|
||||
enum PgcReviewType {
|
||||
long(label: '长评', api: Api.pgcReviewL),
|
||||
short(label: '短评', api: Api.pgcReviewS);
|
||||
|
||||
final String label;
|
||||
final String api;
|
||||
const PgcReviewType({
|
||||
required this.label,
|
||||
required this.api,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user