mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-30 23:58:13 +08:00
refa: video model (#523)
This commit is contained in:
committed by
GitHub
parent
bf464994df
commit
7a6085e923
@@ -1,55 +1,19 @@
|
||||
import './model_owner.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'model_video.dart';
|
||||
|
||||
part 'model_rec_video_item.g.dart';
|
||||
|
||||
@HiveType(typeId: 0)
|
||||
class RecVideoItemModel {
|
||||
RecVideoItemModel({
|
||||
this.id,
|
||||
this.bvid,
|
||||
this.cid,
|
||||
this.goto,
|
||||
this.uri,
|
||||
this.pic,
|
||||
this.title,
|
||||
this.duration,
|
||||
this.pubdate,
|
||||
this.owner,
|
||||
this.stat,
|
||||
this.isFollowed,
|
||||
this.rcmdReason,
|
||||
});
|
||||
|
||||
@HiveField(0)
|
||||
int? id = -1;
|
||||
@HiveField(1)
|
||||
String? bvid = '';
|
||||
@HiveField(2)
|
||||
int? cid = -1;
|
||||
@HiveField(3)
|
||||
String? goto = '';
|
||||
@HiveField(4)
|
||||
String? uri = '';
|
||||
@HiveField(5)
|
||||
String? pic = '';
|
||||
@HiveField(6)
|
||||
String? title = '';
|
||||
@HiveField(7)
|
||||
int? duration = -1;
|
||||
@HiveField(8)
|
||||
int? pubdate = -1;
|
||||
@HiveField(9)
|
||||
Owner? owner;
|
||||
@HiveField(10)
|
||||
Stat? stat;
|
||||
@HiveField(11)
|
||||
int? isFollowed;
|
||||
@HiveField(12)
|
||||
abstract class BaseRecVideoItemModel extends BaseVideoItemModel {
|
||||
String? goto;
|
||||
String? uri;
|
||||
String? rcmdReason;
|
||||
|
||||
// app推荐专属
|
||||
int? param;
|
||||
String? bangumiBadge;
|
||||
}
|
||||
|
||||
class RecVideoItemModel extends BaseRecVideoItemModel {
|
||||
RecVideoItemModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json["id"];
|
||||
aid = json["id"];
|
||||
bvid = json["bvid"];
|
||||
cid = json["cid"];
|
||||
goto = json["goto"];
|
||||
@@ -60,34 +24,15 @@ class RecVideoItemModel {
|
||||
pubdate = json["pubdate"];
|
||||
owner = Owner.fromJson(json["owner"]);
|
||||
stat = Stat.fromJson(json["stat"]);
|
||||
isFollowed = json["is_followed"] ?? 0;
|
||||
isFollowed = json["is_followed"] == 1;
|
||||
// rcmdReason = json["rcmd_reason"] != null
|
||||
// ? RcmdReason.fromJson(json["rcmd_reason"])
|
||||
// : RcmdReason(content: '');
|
||||
rcmdReason = json["rcmd_reason"]?['content'];
|
||||
}
|
||||
}
|
||||
|
||||
@HiveType(typeId: 1)
|
||||
class Stat {
|
||||
Stat({
|
||||
this.view,
|
||||
this.like,
|
||||
this.danmu,
|
||||
});
|
||||
@HiveField(0)
|
||||
int? view;
|
||||
@HiveField(1)
|
||||
int? like;
|
||||
@HiveField(2)
|
||||
int? danmu;
|
||||
|
||||
Stat.fromJson(Map<String, dynamic> json) {
|
||||
// 无需在model中转换以保留原始数据,在view层处理即可
|
||||
view = json["view"];
|
||||
like = json["like"];
|
||||
danmu = json['danmaku'];
|
||||
}
|
||||
// @override
|
||||
// String? get desc => null;
|
||||
}
|
||||
|
||||
// @HiveType(typeId: 2)
|
||||
@@ -96,10 +41,8 @@ class Stat {
|
||||
// this.reasonType,
|
||||
// this.content,
|
||||
// });
|
||||
// @HiveField(0)
|
||||
// int? reasonType;
|
||||
// @HiveField(1)
|
||||
// String? content = '';
|
||||
// // int? reasonType;
|
||||
// // String? content;
|
||||
//
|
||||
// RcmdReason.fromJson(Map<String, dynamic> json) {
|
||||
// reasonType = json["reason_type"];
|
||||
|
||||
Reference in New Issue
Block a user