v1.0.1
This commit is contained in:
73
lib/models/novel/category_filter_model.dart
Normal file
73
lib/models/novel/category_filter_model.dart
Normal file
@@ -0,0 +1,73 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
T? asT<T>(dynamic value) {
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class NovelCategoryFilterModel {
|
||||
NovelCategoryFilterModel({
|
||||
required this.title,
|
||||
required this.items,
|
||||
});
|
||||
|
||||
factory NovelCategoryFilterModel.fromJson(Map<String, dynamic> json) {
|
||||
final List<NovelCategoryFilterItemModel>? items =
|
||||
json['items'] is List ? <NovelCategoryFilterItemModel>[] : null;
|
||||
if (items != null) {
|
||||
for (final dynamic item in json['items']!) {
|
||||
if (item != null) {
|
||||
items.add(NovelCategoryFilterItemModel.fromJson(
|
||||
asT<Map<String, dynamic>>(item)!));
|
||||
}
|
||||
}
|
||||
}
|
||||
return NovelCategoryFilterModel(
|
||||
title: asT<String>(json['title'])!,
|
||||
items: items!,
|
||||
);
|
||||
}
|
||||
|
||||
String title;
|
||||
List<NovelCategoryFilterItemModel> items;
|
||||
var selectId = 0.obs;
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'title': title,
|
||||
'items': items,
|
||||
};
|
||||
}
|
||||
|
||||
class NovelCategoryFilterItemModel {
|
||||
NovelCategoryFilterItemModel({
|
||||
required this.tagId,
|
||||
required this.tagName,
|
||||
});
|
||||
|
||||
factory NovelCategoryFilterItemModel.fromJson(Map<String, dynamic> json) =>
|
||||
NovelCategoryFilterItemModel(
|
||||
tagId: asT<int>(json['tagId'])!,
|
||||
tagName: asT<String>(json['title'])!,
|
||||
);
|
||||
|
||||
int tagId;
|
||||
String tagName;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'tag_id': tagId,
|
||||
'tag_name': tagName,
|
||||
};
|
||||
}
|
||||
38
lib/models/novel/category_model.dart
Normal file
38
lib/models/novel/category_model.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'dart:convert';
|
||||
|
||||
T? asT<T>(dynamic value) {
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class NovelCategoryModel {
|
||||
NovelCategoryModel({
|
||||
required this.tagId,
|
||||
required this.title,
|
||||
required this.cover,
|
||||
});
|
||||
|
||||
factory NovelCategoryModel.fromJson(Map<String, dynamic> json) =>
|
||||
NovelCategoryModel(
|
||||
tagId: asT<int>(json['tagId'])!,
|
||||
title: asT<String>(json['title'])!,
|
||||
cover: asT<String>(json['cover'])!,
|
||||
);
|
||||
|
||||
int tagId;
|
||||
String title;
|
||||
String cover;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'tag_id': tagId,
|
||||
'title': title,
|
||||
'cover': cover,
|
||||
};
|
||||
}
|
||||
62
lib/models/novel/category_novel_model.dart
Normal file
62
lib/models/novel/category_novel_model.dart
Normal file
@@ -0,0 +1,62 @@
|
||||
import 'dart:convert';
|
||||
|
||||
T? asT<T>(dynamic value) {
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class NovelCategoryNovelModel {
|
||||
NovelCategoryNovelModel({
|
||||
required this.id,
|
||||
required this.title,
|
||||
this.authors,
|
||||
this.cover,
|
||||
this.hotHits,
|
||||
this.lastName,
|
||||
this.status,
|
||||
this.types,
|
||||
this.subNums,
|
||||
});
|
||||
|
||||
factory NovelCategoryNovelModel.fromJson(Map<String, dynamic> json) =>
|
||||
NovelCategoryNovelModel(
|
||||
id: asT<int>(json['id'])!,
|
||||
title: asT<String>(json['title'])!,
|
||||
authors: asT<String?>(json['authors']),
|
||||
cover: asT<String?>(json['cover']),
|
||||
hotHits: asT<int?>(json['hot_hits']),
|
||||
lastName: asT<String?>(json['last_name']),
|
||||
status: asT<String?>(json['status']),
|
||||
types: asT<String?>(json['types']),
|
||||
subNums: asT<int?>(json['sub_nums']),
|
||||
);
|
||||
|
||||
int id;
|
||||
String title;
|
||||
String? authors;
|
||||
String? cover;
|
||||
int? hotHits;
|
||||
String? lastName;
|
||||
String? status;
|
||||
String? types;
|
||||
int? subNums;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'id': id,
|
||||
'title': title,
|
||||
'authors': authors,
|
||||
'cover': cover,
|
||||
'hot_hits': hotHits,
|
||||
'last_name': lastName,
|
||||
'status': status,
|
||||
'types': types,
|
||||
'sub_nums': subNums,
|
||||
};
|
||||
}
|
||||
239
lib/models/novel/detail_model.dart
Normal file
239
lib/models/novel/detail_model.dart
Normal file
@@ -0,0 +1,239 @@
|
||||
import 'dart:convert';
|
||||
|
||||
T? asT<T>(dynamic value) {
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class NovelDetailModel {
|
||||
NovelDetailModel({
|
||||
required this.data,
|
||||
required this.readingRecord,
|
||||
});
|
||||
|
||||
factory NovelDetailModel.fromJson(Map<String, dynamic> json) =>
|
||||
NovelDetailModel(
|
||||
data: NovelDetailDataModel.fromJson(
|
||||
asT<Map<String, dynamic>>(json['data'])!),
|
||||
readingRecord: NovelDetailReadingRecordModel.fromJson(
|
||||
asT<Map<String, dynamic>>(json['readingRecord'])!),
|
||||
);
|
||||
|
||||
NovelDetailDataModel data;
|
||||
NovelDetailReadingRecordModel readingRecord;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'data': data,
|
||||
'readingRecord': readingRecord,
|
||||
};
|
||||
}
|
||||
|
||||
class NovelDetailDataModel {
|
||||
NovelDetailDataModel({
|
||||
required this.novelId,
|
||||
required this.name,
|
||||
required this.zone,
|
||||
required this.status,
|
||||
required this.lastUpdateVolumeName,
|
||||
required this.lastUpdateChapterName,
|
||||
required this.lastUpdateVolumeId,
|
||||
required this.lastUpdateChapterId,
|
||||
required this.lastUpdateTime,
|
||||
required this.cover,
|
||||
required this.hotHits,
|
||||
required this.introduction,
|
||||
required this.types,
|
||||
required this.authors,
|
||||
required this.firstLetter,
|
||||
required this.volume,
|
||||
});
|
||||
|
||||
factory NovelDetailDataModel.fromJson(Map<String, dynamic> json) {
|
||||
final List<String>? types = json['types'] is List ? <String>[] : null;
|
||||
if (types != null) {
|
||||
for (final dynamic item in json['types']!) {
|
||||
if (item != null) {
|
||||
types.add(asT<String>(item)!);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final List<Volume>? volume = json['volume'] is List ? <Volume>[] : null;
|
||||
if (volume != null) {
|
||||
for (final dynamic item in json['volume']!) {
|
||||
if (item != null) {
|
||||
volume.add(Volume.fromJson(asT<Map<String, dynamic>>(item)!));
|
||||
}
|
||||
}
|
||||
}
|
||||
return NovelDetailDataModel(
|
||||
novelId: asT<int>(json['novel_id'])!,
|
||||
name: asT<String>(json['name'])!,
|
||||
zone: asT<String>(json['zone'])!,
|
||||
status: asT<String>(json['status'])!,
|
||||
lastUpdateVolumeName: asT<String>(json['last_update_volume_name'])!,
|
||||
lastUpdateChapterName: asT<String>(json['last_update_chapter_name'])!,
|
||||
lastUpdateVolumeId: asT<int>(json['last_update_volume_id'])!,
|
||||
lastUpdateChapterId: asT<int>(json['last_update_chapter_id'])!,
|
||||
lastUpdateTime: asT<int>(json['last_update_time'])!,
|
||||
cover: asT<String>(json['cover'])!,
|
||||
hotHits: asT<int?>(json['hot_hits']) ?? 0,
|
||||
introduction: asT<String>(json['introduction'])!,
|
||||
types: types!,
|
||||
authors: asT<String>(json['authors'])!,
|
||||
firstLetter: asT<String>(json['first_letter'])!,
|
||||
volume: volume!,
|
||||
);
|
||||
}
|
||||
|
||||
int novelId;
|
||||
String name;
|
||||
String zone;
|
||||
String status;
|
||||
String lastUpdateVolumeName;
|
||||
String lastUpdateChapterName;
|
||||
int lastUpdateVolumeId;
|
||||
int lastUpdateChapterId;
|
||||
int lastUpdateTime;
|
||||
String cover;
|
||||
int hotHits;
|
||||
String introduction;
|
||||
List<String> types;
|
||||
String authors;
|
||||
String firstLetter;
|
||||
List<Volume> volume;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'novel_id': novelId,
|
||||
'name': name,
|
||||
'zone': zone,
|
||||
'status': status,
|
||||
'last_update_volume_name': lastUpdateVolumeName,
|
||||
'last_update_chapter_name': lastUpdateChapterName,
|
||||
'last_update_volume_id': lastUpdateVolumeId,
|
||||
'last_update_chapter_id': lastUpdateChapterId,
|
||||
'last_update_time': lastUpdateTime,
|
||||
'cover': cover,
|
||||
'hot_hits': hotHits,
|
||||
'introduction': introduction,
|
||||
'types': types,
|
||||
'authors': authors,
|
||||
'first_letter': firstLetter,
|
||||
'volume': volume,
|
||||
};
|
||||
}
|
||||
|
||||
class Volume {
|
||||
Volume({
|
||||
required this.volumeId,
|
||||
required this.lnovelId,
|
||||
required this.volumeName,
|
||||
required this.volumeOrder,
|
||||
required this.addtime,
|
||||
required this.sumChapters,
|
||||
});
|
||||
|
||||
factory Volume.fromJson(Map<String, dynamic> json) => Volume(
|
||||
volumeId: asT<int>(json['volume_id'])!,
|
||||
lnovelId: asT<int>(json['lnovel_id'])!,
|
||||
volumeName: asT<String>(json['volume_name'])!,
|
||||
volumeOrder: asT<int>(json['volume_order'])!,
|
||||
addtime: asT<int>(json['addtime'])!,
|
||||
sumChapters: asT<int>(json['sum_chapters'])!,
|
||||
);
|
||||
|
||||
int volumeId;
|
||||
int lnovelId;
|
||||
String volumeName;
|
||||
int volumeOrder;
|
||||
int addtime;
|
||||
int sumChapters;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'volume_id': volumeId,
|
||||
'lnovel_id': lnovelId,
|
||||
'volume_name': volumeName,
|
||||
'volume_order': volumeOrder,
|
||||
'addtime': addtime,
|
||||
'sum_chapters': sumChapters,
|
||||
};
|
||||
}
|
||||
|
||||
class NovelDetailReadingRecordModel {
|
||||
NovelDetailReadingRecordModel({
|
||||
required this.typeName,
|
||||
required this.uid,
|
||||
required this.source,
|
||||
required this.bizId,
|
||||
required this.chapterId,
|
||||
required this.viewingTime,
|
||||
required this.record,
|
||||
required this.volumeId,
|
||||
required this.totalNum,
|
||||
required this.chapterName,
|
||||
required this.volumeName,
|
||||
});
|
||||
|
||||
factory NovelDetailReadingRecordModel.fromJson(Map<String, dynamic> json) =>
|
||||
NovelDetailReadingRecordModel(
|
||||
typeName: asT<String>(json['type_name'])!,
|
||||
uid: asT<int>(json['uid'])!,
|
||||
source: asT<int>(json['source'])!,
|
||||
bizId: asT<int>(json['biz_id'])!,
|
||||
chapterId: asT<int>(json['chapter_id'])!,
|
||||
viewingTime: asT<int>(json['viewing_time'])!,
|
||||
record: asT<int>(json['record'])!,
|
||||
volumeId: asT<int>(json['volume_id'])!,
|
||||
totalNum: asT<int>(json['total_num'])!,
|
||||
chapterName: asT<String>(json['chapter_name'])!,
|
||||
volumeName: asT<String>(json['volume_name'])!,
|
||||
);
|
||||
|
||||
String typeName;
|
||||
int uid;
|
||||
int source;
|
||||
int bizId;
|
||||
int chapterId;
|
||||
int viewingTime;
|
||||
int record;
|
||||
int volumeId;
|
||||
int totalNum;
|
||||
String chapterName;
|
||||
String volumeName;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'type_name': typeName,
|
||||
'uid': uid,
|
||||
'source': source,
|
||||
'biz_id': bizId,
|
||||
'chapter_id': chapterId,
|
||||
'viewing_time': viewingTime,
|
||||
'record': record,
|
||||
'volume_id': volumeId,
|
||||
'total_num': totalNum,
|
||||
'chapter_name': chapterName,
|
||||
'volume_name': volumeName,
|
||||
};
|
||||
}
|
||||
62
lib/models/novel/latest_model.dart
Normal file
62
lib/models/novel/latest_model.dart
Normal file
@@ -0,0 +1,62 @@
|
||||
import 'dart:convert';
|
||||
|
||||
T? asT<T>(dynamic value) {
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class NovelLatestModel {
|
||||
NovelLatestModel({
|
||||
required this.id,
|
||||
required this.title,
|
||||
this.authors,
|
||||
this.cover,
|
||||
this.hotHits,
|
||||
this.lastName,
|
||||
this.status,
|
||||
this.types,
|
||||
this.subNums,
|
||||
});
|
||||
|
||||
factory NovelLatestModel.fromJson(Map<String, dynamic> json) =>
|
||||
NovelLatestModel(
|
||||
id: asT<int>(json['id'])!,
|
||||
title: asT<String>(json['title'])!,
|
||||
authors: asT<String?>(json['authors']),
|
||||
cover: asT<String?>(json['cover']),
|
||||
hotHits: asT<int?>(json['hot_hits']),
|
||||
lastName: asT<String?>(json['last_name']),
|
||||
status: asT<String?>(json['status']),
|
||||
types: asT<String?>(json['types']),
|
||||
subNums: asT<int?>(json['sub_nums']),
|
||||
);
|
||||
|
||||
int id;
|
||||
String title;
|
||||
String? authors;
|
||||
String? cover;
|
||||
int? hotHits;
|
||||
String? lastName;
|
||||
String? status;
|
||||
String? types;
|
||||
int? subNums;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'id': id,
|
||||
'title': title,
|
||||
'authors': authors,
|
||||
'cover': cover,
|
||||
'hot_hits': hotHits,
|
||||
'last_name': lastName,
|
||||
'status': status,
|
||||
'types': types,
|
||||
'sub_nums': subNums,
|
||||
};
|
||||
}
|
||||
193
lib/models/novel/novel_detail_model.dart
Normal file
193
lib/models/novel/novel_detail_model.dart
Normal file
@@ -0,0 +1,193 @@
|
||||
import 'package:flutter_dmzj/models/novel/detail_model.dart';
|
||||
import 'package:flutter_dmzj/models/novel/volume_detail_model.dart';
|
||||
import 'package:flutter_dmzj/models/proto/novel.pb.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
T? asT<T>(dynamic value) {
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class NovelDetailInfo {
|
||||
NovelDetailInfo({
|
||||
required this.novelId,
|
||||
required this.name,
|
||||
required this.zone,
|
||||
required this.status,
|
||||
required this.lastUpdateVolumeName,
|
||||
required this.lastUpdateChapterName,
|
||||
required this.lastUpdateVolumeId,
|
||||
required this.lastUpdateChapterId,
|
||||
required this.lastUpdateTime,
|
||||
required this.cover,
|
||||
required this.hotHits,
|
||||
required this.introduction,
|
||||
required this.types,
|
||||
required this.authors,
|
||||
required this.firstLetter,
|
||||
required this.subscribeNum,
|
||||
});
|
||||
|
||||
factory NovelDetailInfo.empty() => NovelDetailInfo(
|
||||
novelId: 0,
|
||||
name: "",
|
||||
zone: "",
|
||||
status: "",
|
||||
lastUpdateVolumeName: "",
|
||||
lastUpdateChapterName: "",
|
||||
lastUpdateVolumeId: 0,
|
||||
lastUpdateChapterId: 0,
|
||||
lastUpdateTime: 0,
|
||||
cover: "",
|
||||
hotHits: 0,
|
||||
introduction: "",
|
||||
types: [],
|
||||
authors: "",
|
||||
firstLetter: "",
|
||||
subscribeNum: 0,
|
||||
);
|
||||
factory NovelDetailInfo.fromJson(NovelDetailDataModel item) =>
|
||||
NovelDetailInfo(
|
||||
novelId: item.novelId.toInt(),
|
||||
name: item.name,
|
||||
zone: item.zone,
|
||||
status: item.status,
|
||||
lastUpdateVolumeName: item.lastUpdateVolumeName,
|
||||
lastUpdateChapterName: item.lastUpdateChapterName,
|
||||
lastUpdateVolumeId: item.lastUpdateVolumeId.toInt(),
|
||||
lastUpdateChapterId: item.lastUpdateChapterId.toInt(),
|
||||
lastUpdateTime: item.lastUpdateTime.toInt(),
|
||||
cover: item.cover,
|
||||
hotHits: item.hotHits.toInt(),
|
||||
introduction: item.introduction,
|
||||
types: item.types,
|
||||
authors: item.authors,
|
||||
firstLetter: item.firstLetter,
|
||||
subscribeNum: 0,
|
||||
);
|
||||
|
||||
factory NovelDetailInfo.fromV4(NovelDetailProto item) => NovelDetailInfo(
|
||||
novelId: item.novelId.toInt(),
|
||||
name: item.name,
|
||||
zone: item.zone,
|
||||
status: item.status,
|
||||
lastUpdateVolumeName: item.lastUpdateVolumeName,
|
||||
lastUpdateChapterName: item.lastUpdateChapterName,
|
||||
lastUpdateVolumeId: item.lastUpdateVolumeId.toInt(),
|
||||
lastUpdateChapterId: item.lastUpdateChapterId.toInt(),
|
||||
lastUpdateTime: item.lastUpdateTime.toInt(),
|
||||
cover: item.cover,
|
||||
hotHits: item.hotHits.toInt(),
|
||||
introduction: item.introduction,
|
||||
types: item.types,
|
||||
authors: item.authors,
|
||||
firstLetter: item.firstLetter,
|
||||
subscribeNum: item.subscribeNum.toInt(),
|
||||
);
|
||||
|
||||
int novelId;
|
||||
String name;
|
||||
String zone;
|
||||
String status;
|
||||
String lastUpdateVolumeName;
|
||||
String lastUpdateChapterName;
|
||||
int lastUpdateVolumeId;
|
||||
int lastUpdateChapterId;
|
||||
int lastUpdateTime;
|
||||
String cover;
|
||||
int hotHits;
|
||||
String introduction;
|
||||
List<String> types;
|
||||
String authors;
|
||||
String firstLetter;
|
||||
int subscribeNum;
|
||||
RxList<NovelDetailVolume> volume = RxList<NovelDetailVolume>();
|
||||
}
|
||||
|
||||
class NovelDetailVolume {
|
||||
NovelDetailVolume({
|
||||
required this.volumeId,
|
||||
required this.volumeName,
|
||||
required this.volumeOrder,
|
||||
required this.chapters,
|
||||
});
|
||||
factory NovelDetailVolume.fromJson(NovelVolumeDetailModel item) =>
|
||||
NovelDetailVolume(
|
||||
volumeId: item.volumeId.toInt(),
|
||||
volumeName: item.volumeName,
|
||||
volumeOrder: item.volumeOrder,
|
||||
chapters: item.chapters
|
||||
.map(
|
||||
(e) => NovelDetailChapter.fromJson(
|
||||
e,
|
||||
item.volumeId.toInt(),
|
||||
item.volumeName,
|
||||
item.volumeOrder,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
factory NovelDetailVolume.fromV4(NovelVolumeDetailProto item) =>
|
||||
NovelDetailVolume(
|
||||
volumeId: item.volumeId.toInt(),
|
||||
volumeName: item.volumeName,
|
||||
volumeOrder: item.volumeOrder,
|
||||
chapters: item.chapters
|
||||
.map(
|
||||
(e) => NovelDetailChapter.fromV4(
|
||||
e,
|
||||
item.volumeId.toInt(),
|
||||
item.volumeName,
|
||||
item.volumeOrder,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
int volumeId;
|
||||
String volumeName;
|
||||
int volumeOrder;
|
||||
List<NovelDetailChapter> chapters;
|
||||
}
|
||||
|
||||
class NovelDetailChapter {
|
||||
NovelDetailChapter({
|
||||
required this.chapterId,
|
||||
required this.chapterName,
|
||||
required this.chapterOrder,
|
||||
required this.volumeId,
|
||||
required this.volumeName,
|
||||
required this.volumeOrder,
|
||||
});
|
||||
factory NovelDetailChapter.fromJson(NovelVolumeDetailChapterModel item,
|
||||
int volumeId, String volumeName, int volumeOrder) =>
|
||||
NovelDetailChapter(
|
||||
chapterId: item.chapterId.toInt(),
|
||||
chapterName: item.chapterName,
|
||||
chapterOrder: item.chapterOrder,
|
||||
volumeId: volumeId,
|
||||
volumeName: volumeName,
|
||||
volumeOrder: volumeOrder,
|
||||
);
|
||||
|
||||
factory NovelDetailChapter.fromV4(NovelChapterDetailProto item, int volumeId,
|
||||
String volumeName, int volumeOrder) =>
|
||||
NovelDetailChapter(
|
||||
chapterId: item.chapterId.toInt(),
|
||||
chapterName: item.chapterName,
|
||||
chapterOrder: item.chapterOrder,
|
||||
volumeId: volumeId,
|
||||
volumeName: volumeName,
|
||||
volumeOrder: volumeOrder,
|
||||
);
|
||||
|
||||
int chapterId;
|
||||
String chapterName;
|
||||
int chapterOrder;
|
||||
int volumeId;
|
||||
int volumeOrder;
|
||||
String volumeName;
|
||||
}
|
||||
71
lib/models/novel/rank_model.dart
Normal file
71
lib/models/novel/rank_model.dart
Normal file
@@ -0,0 +1,71 @@
|
||||
import 'dart:convert';
|
||||
|
||||
T? asT<T>(dynamic value) {
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class NovelRankModel {
|
||||
NovelRankModel({
|
||||
required this.id,
|
||||
required this.lastUpdateTime,
|
||||
required this.name,
|
||||
required this.types,
|
||||
required this.cover,
|
||||
required this.authors,
|
||||
required this.lastUpdateChapterName,
|
||||
required this.top,
|
||||
required this.subscribeAmount,
|
||||
});
|
||||
|
||||
factory NovelRankModel.fromJson(Map<String, dynamic> json) {
|
||||
final List<String>? types = json['types'] is List ? <String>[] : null;
|
||||
if (types != null) {
|
||||
for (final dynamic item in json['types']!) {
|
||||
if (item != null) {
|
||||
types.add(asT<String>(item)!);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NovelRankModel(
|
||||
id: asT<int>(json['id'])!,
|
||||
lastUpdateTime: asT<int>(json['last_update_time'])!,
|
||||
name: asT<String>(json['name'])!,
|
||||
types: types!,
|
||||
cover: asT<String>(json['cover'])!,
|
||||
authors: asT<String>(json['authors'])!,
|
||||
lastUpdateChapterName: asT<String>(json['last_update_chapter_name'])!,
|
||||
top: asT<int>(json['top'])!,
|
||||
subscribeAmount: asT<int>(json['subscribe_amount'])!,
|
||||
);
|
||||
}
|
||||
|
||||
int id;
|
||||
int lastUpdateTime;
|
||||
String name;
|
||||
List<String> types;
|
||||
String cover;
|
||||
String authors;
|
||||
String lastUpdateChapterName;
|
||||
int top;
|
||||
int subscribeAmount;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'id': id,
|
||||
'last_update_time': lastUpdateTime,
|
||||
'name': name,
|
||||
'types': types,
|
||||
'cover': cover,
|
||||
'authors': authors,
|
||||
'last_update_chapter_name': lastUpdateChapterName,
|
||||
'top': top,
|
||||
'subscribe_amount': subscribeAmount,
|
||||
};
|
||||
}
|
||||
101
lib/models/novel/recommend_model.dart
Normal file
101
lib/models/novel/recommend_model.dart
Normal file
@@ -0,0 +1,101 @@
|
||||
import 'dart:convert';
|
||||
|
||||
T? asT<T>(dynamic value) {
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class NovelRecommendModel {
|
||||
NovelRecommendModel({
|
||||
required this.categoryId,
|
||||
required this.title,
|
||||
required this.sort,
|
||||
required this.data,
|
||||
});
|
||||
|
||||
factory NovelRecommendModel.fromJson(Map<String, dynamic> json) {
|
||||
final List<NovelRecommendItemModel>? data =
|
||||
json['data'] is List ? <NovelRecommendItemModel>[] : null;
|
||||
if (data != null) {
|
||||
for (final dynamic item in json['data']!) {
|
||||
if (item != null) {
|
||||
data.add(NovelRecommendItemModel.fromJson(
|
||||
asT<Map<String, dynamic>>(item)!));
|
||||
}
|
||||
}
|
||||
}
|
||||
return NovelRecommendModel(
|
||||
categoryId: asT<int>(json['category_id'])!,
|
||||
title: asT<String>(json['title'])!,
|
||||
sort: asT<int>(json['sort'])!,
|
||||
data: data!,
|
||||
);
|
||||
}
|
||||
|
||||
int categoryId;
|
||||
String title;
|
||||
int sort;
|
||||
List<NovelRecommendItemModel> data;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'category_id': categoryId,
|
||||
'title': title,
|
||||
'sort': sort,
|
||||
'data': data,
|
||||
};
|
||||
}
|
||||
|
||||
class NovelRecommendItemModel {
|
||||
NovelRecommendItemModel({
|
||||
required this.cover,
|
||||
required this.title,
|
||||
this.subTitle,
|
||||
this.type,
|
||||
this.url,
|
||||
required this.objId,
|
||||
this.status,
|
||||
this.id,
|
||||
});
|
||||
|
||||
factory NovelRecommendItemModel.fromJson(Map<String, dynamic> json) =>
|
||||
NovelRecommendItemModel(
|
||||
id: asT<int?>(json['id']),
|
||||
cover: asT<String>(json['cover'])!,
|
||||
title: asT<String>(json['title'])!,
|
||||
subTitle: asT<String?>(json['sub_title']),
|
||||
type: asT<int?>(json['type']),
|
||||
url: asT<String?>(json['url']),
|
||||
objId: asT<int?>(json['obj_id']),
|
||||
status: asT<String?>(json['status']),
|
||||
);
|
||||
int? id;
|
||||
String cover;
|
||||
String title;
|
||||
String? subTitle;
|
||||
int? type;
|
||||
String? url;
|
||||
int? objId;
|
||||
String? status;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'cover': cover,
|
||||
'title': title,
|
||||
'sub_title': subTitle,
|
||||
'type': type,
|
||||
'url': url,
|
||||
'obj_id': objId,
|
||||
'status': status,
|
||||
};
|
||||
}
|
||||
62
lib/models/novel/search_model.dart
Normal file
62
lib/models/novel/search_model.dart
Normal file
@@ -0,0 +1,62 @@
|
||||
import 'dart:convert';
|
||||
|
||||
T? asT<T>(dynamic value) {
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class NovelSearchModel {
|
||||
NovelSearchModel({
|
||||
required this.id,
|
||||
required this.title,
|
||||
this.authors,
|
||||
this.cover,
|
||||
this.hotHits,
|
||||
this.lastName,
|
||||
this.status,
|
||||
this.types,
|
||||
this.subNums,
|
||||
});
|
||||
|
||||
factory NovelSearchModel.fromJson(Map<String, dynamic> json) =>
|
||||
NovelSearchModel(
|
||||
id: asT<int>(json['id'])!,
|
||||
title: asT<String>(json['title'])!,
|
||||
authors: asT<String?>(json['authors']),
|
||||
cover: asT<String?>(json['cover']),
|
||||
hotHits: asT<int?>(json['hot_hits']),
|
||||
lastName: asT<String?>(json['last_name']),
|
||||
status: asT<String?>(json['status']),
|
||||
types: asT<String?>(json['types']),
|
||||
subNums: asT<int?>(json['sub_nums']),
|
||||
);
|
||||
|
||||
int id;
|
||||
String title;
|
||||
String? authors;
|
||||
String? cover;
|
||||
int? hotHits;
|
||||
String? lastName;
|
||||
String? status;
|
||||
String? types;
|
||||
int? subNums;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'id': id,
|
||||
'title': title,
|
||||
'authors': authors,
|
||||
'cover': cover,
|
||||
'hot_hits': hotHits,
|
||||
'last_name': lastName,
|
||||
'status': status,
|
||||
'types': types,
|
||||
'sub_nums': subNums,
|
||||
};
|
||||
}
|
||||
83
lib/models/novel/volume_detail_model.dart
Normal file
83
lib/models/novel/volume_detail_model.dart
Normal file
@@ -0,0 +1,83 @@
|
||||
import 'dart:convert';
|
||||
|
||||
T? asT<T>(dynamic value) {
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class NovelVolumeDetailModel {
|
||||
NovelVolumeDetailModel({
|
||||
required this.volumeId,
|
||||
required this.volumeName,
|
||||
required this.volumeOrder,
|
||||
required this.chapters,
|
||||
});
|
||||
|
||||
factory NovelVolumeDetailModel.fromJson(Map<String, dynamic> json) {
|
||||
final List<NovelVolumeDetailChapterModel>? chapters =
|
||||
json['chapters'] is List ? <NovelVolumeDetailChapterModel>[] : null;
|
||||
if (chapters != null) {
|
||||
for (final dynamic item in json['chapters']!) {
|
||||
if (item != null) {
|
||||
chapters.add(NovelVolumeDetailChapterModel.fromJson(
|
||||
asT<Map<String, dynamic>>(item)!));
|
||||
}
|
||||
}
|
||||
}
|
||||
return NovelVolumeDetailModel(
|
||||
volumeId: asT<int>(json['volume_id'])!,
|
||||
volumeName: asT<String>(json['volume_name'])!,
|
||||
volumeOrder: asT<int>(json['volume_order'])!,
|
||||
chapters: chapters!,
|
||||
);
|
||||
}
|
||||
|
||||
int volumeId;
|
||||
String volumeName;
|
||||
int volumeOrder;
|
||||
List<NovelVolumeDetailChapterModel> chapters;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'volume_id': volumeId,
|
||||
'volume_name': volumeName,
|
||||
'volume_order': volumeOrder,
|
||||
'chapters': chapters,
|
||||
};
|
||||
}
|
||||
|
||||
class NovelVolumeDetailChapterModel {
|
||||
NovelVolumeDetailChapterModel({
|
||||
required this.chapterId,
|
||||
required this.chapterName,
|
||||
required this.chapterOrder,
|
||||
});
|
||||
|
||||
factory NovelVolumeDetailChapterModel.fromJson(Map<String, dynamic> json) =>
|
||||
NovelVolumeDetailChapterModel(
|
||||
chapterId: asT<int>(json['chapter_id'])!,
|
||||
chapterName: asT<String>(json['chapter_name'])!,
|
||||
chapterOrder: asT<int>(json['chapter_order'])!,
|
||||
);
|
||||
|
||||
int chapterId;
|
||||
String chapterName;
|
||||
int chapterOrder;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{
|
||||
'chapter_id': chapterId,
|
||||
'chapter_name': chapterName,
|
||||
'chapter_order': chapterOrder,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user