import 'dart:convert'; import 'package:get/get.dart'; T? asT(dynamic value) { if (value is T) { return value; } return null; } class UserSubscribeNovelModel { UserSubscribeNovelModel({ required this.id, required this.title, this.cover, this.subReaded, this.lastUpdateChapterId, this.lastUpdateChapterName, this.comicPy, this.status, required this.readingRecord, required this.hasNew, }); factory UserSubscribeNovelModel.fromJson(Map json) => UserSubscribeNovelModel( id: asT(json['id'])!, title: asT(json['title'])!, cover: asT(json['cover']), subReaded: asT(json['sub_readed']), lastUpdateChapterId: asT(json['last_update_chapter_id']), lastUpdateChapterName: asT(json['last_update_chapter_name']), comicPy: asT(json['comic_py']), status: asT(json['status']), readingRecord: UserSubscribeNovelReadingRecordModel.fromJson( asT>(json['readingRecord'])!), hasNew: (asT(json['sub_readed']) == 0).obs, ); int id; String title; String? cover; int? subReaded; int? lastUpdateChapterId; String? lastUpdateChapterName; String? comicPy; String? status; UserSubscribeNovelReadingRecordModel readingRecord; var isChecked = false.obs; var hasNew = false.obs; @override String toString() { return jsonEncode(this); } Map toJson() => { 'id': id, 'title': title, 'cover': cover, 'sub_readed': subReaded, 'last_update_chapter_id': lastUpdateChapterId, 'last_update_chapter_name': lastUpdateChapterName, 'comic_py': comicPy, 'status': status, 'readingRecord': readingRecord, }; } class UserSubscribeNovelReadingRecordModel { UserSubscribeNovelReadingRecordModel({ this.typeName, this.uid, this.source, this.bizId, this.chapterId, this.viewingTime, this.record, this.volumeId, this.totalNum, this.chapterName, this.volumeName, }); factory UserSubscribeNovelReadingRecordModel.fromJson( Map json) => UserSubscribeNovelReadingRecordModel( 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, }; }