import 'dart:convert'; T? asT(dynamic value) { if (value is T) { return value; } return null; } class ComicDetailModel { ComicDetailModel({ required this.data, required this.readingRecord, }); factory ComicDetailModel.fromJson(Map json) => ComicDetailModel( data: ComicDetailDataModel.fromJson( asT>(json['data'])!), readingRecord: ComicDetailReadingRecordModel.fromJson( asT>(json['readingRecord'])!), ); ComicDetailDataModel data; ComicDetailReadingRecordModel readingRecord; @override String toString() { return jsonEncode(this); } Map toJson() => { 'data': data, 'readingRecord': readingRecord, }; } class ComicDetailDataModel { ComicDetailDataModel({ required this.id, required this.title, this.direction, this.islong, this.cover, this.description, this.lastUpdatetime, this.lastUpdateChapterName, this.firstLetter, this.comicPy, this.lastUpdateChapterId, this.types, this.status, this.authors, this.chapters, this.dhUrlLinks, }); factory ComicDetailDataModel.fromJson(Map json) { final List? types = json['types'] is List ? [] : null; if (types != null) { for (final dynamic item in json['types']!) { if (item != null) { types.add(ComicDetailDataTagModel.fromJson( asT>(item)!)); } } } final List? status = json['status'] is List ? [] : null; if (status != null) { for (final dynamic item in json['status']!) { if (item != null) { status.add(ComicDetailDataTagModel.fromJson( asT>(item)!)); } } } final List? authors = json['authors'] is List ? [] : null; if (authors != null) { for (final dynamic item in json['authors']!) { if (item != null) { authors.add(ComicDetailDataTagModel.fromJson( asT>(item)!)); } } } final List? chapters = json['chapters'] is List ? [] : null; if (chapters != null) { for (final dynamic item in json['chapters']!) { if (item != null) { chapters.add(ComicDetailChapterModel.fromJson( asT>(item)!)); } } } final List? dhUrlLinks = json['dh_url_links'] is List ? [] : null; if (dhUrlLinks != null) { for (final dynamic item in json['dh_url_links']!) { if (item != null) { dhUrlLinks.add(DhUrlLinks.fromJson(asT>(item)!)); } } } return ComicDetailDataModel( id: asT(json['id'])!, title: asT(json['title'])!, direction: asT(json['direction']), islong: asT(json['islong']), cover: asT(json['cover']), description: asT(json['description']), lastUpdatetime: asT(json['last_updatetime']), lastUpdateChapterName: asT(json['last_update_chapter_name']), firstLetter: asT(json['first_letter']), comicPy: asT(json['comic_py']), lastUpdateChapterId: asT(json['last_update_chapter_id']), types: types, status: status, authors: authors, chapters: chapters, dhUrlLinks: dhUrlLinks, ); } int id; String title; int? direction; int? islong; String? cover; String? description; int? lastUpdatetime; String? lastUpdateChapterName; String? firstLetter; String? comicPy; int? lastUpdateChapterId; List? types; List? status; List? authors; List? chapters; List? dhUrlLinks; @override String toString() { return jsonEncode(this); } Map toJson() => { 'id': id, 'title': title, 'direction': direction, 'islong': islong, 'cover': cover, 'description': description, 'last_updatetime': lastUpdatetime, 'last_update_chapter_name': lastUpdateChapterName, 'first_letter': firstLetter, 'comic_py': comicPy, 'last_update_chapter_id': lastUpdateChapterId, 'types': types, 'status': status, 'authors': authors, 'chapters': chapters, 'dh_url_links': dhUrlLinks, }; } class ComicDetailDataTagModel { ComicDetailDataTagModel({ required this.tagId, required this.tagName, }); factory ComicDetailDataTagModel.fromJson(Map json) => ComicDetailDataTagModel( tagId: asT(json['tag_id'])!, tagName: asT(json['tag_name'])!, ); int tagId; String tagName; @override String toString() { return jsonEncode(this); } Map toJson() => { 'tag_id': tagId, 'tag_name': tagName, }; } class ComicDetailChapterModel { ComicDetailChapterModel({ this.title, this.data, }); factory ComicDetailChapterModel.fromJson(Map json) { final List? data = json['data'] is List ? [] : null; if (data != null) { for (final dynamic item in json['data']!) { if (item != null) { data.add(ComicDetailChapterDataModel.fromJson( asT>(item)!)); } } } return ComicDetailChapterModel( title: asT(json['title']), data: data, ); } String? title; List? data; @override String toString() { return jsonEncode(this); } Map toJson() => { 'title': title, 'data': data, }; } class ComicDetailChapterDataModel { ComicDetailChapterDataModel({ required this.chapterId, required this.chapterTitle, this.updatetime, required this.chapterOrder, }); factory ComicDetailChapterDataModel.fromJson(Map json) => ComicDetailChapterDataModel( chapterId: asT(json['chapter_id'])!, chapterTitle: asT(json['chapter_title'])!, updatetime: asT(json['updatetime']), chapterOrder: asT(json['chapter_order'])!, ); int chapterId; String chapterTitle; int? updatetime; int chapterOrder; @override String toString() { return jsonEncode(this); } Map toJson() => { 'chapter_id': chapterId, 'chapter_title': chapterTitle, 'updatetime': updatetime, 'chapter_order': chapterOrder, }; } class DhUrlLinks { DhUrlLinks({ this.title, }); factory DhUrlLinks.fromJson(Map json) => DhUrlLinks( title: asT(json['title']), ); String? title; @override String toString() { return jsonEncode(this); } Map toJson() => { 'title': title, }; } class ComicDetailReadingRecordModel { ComicDetailReadingRecordModel({ this.typeName, this.uid, this.source, this.bizId, this.chapterId, this.viewingTime, this.record, this.volumeId, this.totalNum, this.chapterName, this.volumeName, }); factory ComicDetailReadingRecordModel.fromJson(Map json) => ComicDetailReadingRecordModel( typeName: asT(json['type_name']), uid: asT(json['uid']), source: asT(json['source']), bizId: asT(json['biz_id']), chapterId: asT(json['chapter_id']), viewingTime: asT(json['viewing_time']), record: asT(json['record']), volumeId: asT(json['volume_id']), totalNum: asT(json['total_num']), chapterName: asT(json['chapter_name']), volumeName: asT(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 toJson() => { '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, }; }