339 lines
8.5 KiB
Dart
339 lines
8.5 KiB
Dart
import 'package:initial_folder/models/reply_announcement_model.dart';
|
|
|
|
class AnnouncementModel {
|
|
AnnouncementModel({
|
|
this.status,
|
|
this.error,
|
|
required this.data,
|
|
});
|
|
|
|
final int? status;
|
|
final bool? error;
|
|
final List<List<AnnouncementDataModel>> data;
|
|
|
|
factory AnnouncementModel.fromJson(Map<String, dynamic> json) =>
|
|
AnnouncementModel(
|
|
status: json["status"],
|
|
error: json["error"],
|
|
data: List<List<AnnouncementDataModel>>.from(json["data"].map((x) =>
|
|
List<AnnouncementDataModel>.from(
|
|
x.map((x) => AnnouncementDataModel.fromJson(x))))),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"status": status,
|
|
"error": error,
|
|
"data": List<dynamic>.from(
|
|
data.map((x) => List<dynamic>.from(x.map((x) => x.toJson())))),
|
|
};
|
|
}
|
|
|
|
class AnnouncementDataModel {
|
|
AnnouncementDataModel({
|
|
this.idAnnouncement,
|
|
this.tokenAnnouncement,
|
|
this.instructorName,
|
|
this.fotoProfile,
|
|
this.bodyContent,
|
|
this.countLike,
|
|
this.likes,
|
|
this.isLike,
|
|
this.comment,
|
|
this.date,
|
|
required this.replies,
|
|
});
|
|
|
|
final String? idAnnouncement;
|
|
final String? tokenAnnouncement;
|
|
final String? instructorName;
|
|
final String? fotoProfile;
|
|
final String? bodyContent;
|
|
final String? countLike;
|
|
final bool? likes;
|
|
final int? isLike;
|
|
final int? comment;
|
|
final String? date;
|
|
final List<ReplyModel> replies;
|
|
|
|
factory AnnouncementDataModel.fromJson(Map<String, dynamic> json) =>
|
|
AnnouncementDataModel(
|
|
idAnnouncement: json["id_announcement"],
|
|
tokenAnnouncement: json["token_announcement"],
|
|
instructorName: json["instructor_name"],
|
|
bodyContent: json["body"],
|
|
fotoProfile: json["foto_profile"],
|
|
likes: json["likes"].length > 0,
|
|
isLike: json["is_like"],
|
|
countLike: json["count_likes"],
|
|
comment: json["comment"],
|
|
date: json["date"],
|
|
replies: List<ReplyModel>.from(
|
|
json["replies"].map((x) => ReplyModel.fromJson(x))).toList(),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"id_announcement": idAnnouncement,
|
|
"token_announcement": tokenAnnouncement,
|
|
"instructor_name": instructorName,
|
|
"body": bodyContent,
|
|
"foto_profile": fotoProfile,
|
|
"likes": likes,
|
|
"is_like": isLike,
|
|
"comment": comment,
|
|
"date": date,
|
|
"replies": List<ReplyModel>.from(replies.map((x) => x)),
|
|
};
|
|
}
|
|
|
|
class AnnouncementPostModel {
|
|
AnnouncementPostModel({
|
|
this.status,
|
|
this.error,
|
|
required this.data,
|
|
});
|
|
|
|
final int? status;
|
|
final bool? error;
|
|
final DataPostAnnouncement data;
|
|
|
|
factory AnnouncementPostModel.fromJson(Map<String, dynamic> json) =>
|
|
AnnouncementPostModel(
|
|
status: json["status"],
|
|
error: json["error"],
|
|
data: DataPostAnnouncement.fromJson(json["data"]),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"status": status,
|
|
"error": error,
|
|
"data": data.toJson(),
|
|
};
|
|
}
|
|
|
|
class DataPostAnnouncement {
|
|
DataPostAnnouncement({this.idUser, this.idCourse, this.body});
|
|
|
|
final String? idUser;
|
|
final String? idCourse;
|
|
final String? body;
|
|
|
|
factory DataPostAnnouncement.fromJson(Map<String, dynamic> json) =>
|
|
DataPostAnnouncement(
|
|
idUser: json["id_user"],
|
|
idCourse: json["course_id"],
|
|
body: json["body"],
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"id_user": idUser,
|
|
"id_course": idCourse,
|
|
"body": body,
|
|
};
|
|
}
|
|
|
|
class AnnouncementLikeModel {
|
|
AnnouncementLikeModel({
|
|
this.userLikes,
|
|
});
|
|
|
|
final String? userLikes;
|
|
|
|
factory AnnouncementLikeModel.fromJson(Map<String, dynamic> json) =>
|
|
AnnouncementLikeModel(
|
|
userLikes: json["user_likes"],
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"user_likes": userLikes,
|
|
};
|
|
}
|
|
|
|
class SectionModel {
|
|
SectionModel({
|
|
this.status,
|
|
this.error,
|
|
this.progress,
|
|
required this.data,
|
|
});
|
|
|
|
int? status;
|
|
bool? error;
|
|
int? progress;
|
|
List<Map<String, Datum>> data;
|
|
|
|
factory SectionModel.fromJson(Map<String, dynamic> json) => SectionModel(
|
|
status: json["status"],
|
|
error: json["error"],
|
|
progress: json["progress"],
|
|
data: List<Map<String, Datum>>.from(json["data"].map((x) => Map.from(x)
|
|
.map((k, v) => MapEntry<String, Datum>(k, Datum.fromJson(v))))),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"status": status,
|
|
"error": error,
|
|
"progress": progress,
|
|
"data": List<dynamic>.from(data.map((x) => Map.from(x)
|
|
.map((k, v) => MapEntry<String, dynamic>(k, v.toJson())))),
|
|
};
|
|
}
|
|
|
|
class Datum {
|
|
Datum({
|
|
this.sectionTitle,
|
|
this.dataLesson,
|
|
});
|
|
|
|
String? sectionTitle;
|
|
List<DataLesson>? dataLesson;
|
|
|
|
factory Datum.fromJson(Map<String, dynamic> json) => Datum(
|
|
sectionTitle: json["section_title"],
|
|
dataLesson: List<DataLesson>.from(
|
|
json["data_lesson"].map((x) => DataLesson.fromJson(x))),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"section_title": sectionTitle,
|
|
"data_lesson": List<dynamic>.from(dataLesson!.map((x) => x.toJson())),
|
|
};
|
|
}
|
|
|
|
class DataLesson {
|
|
DataLesson({
|
|
this.lessonId,
|
|
this.title,
|
|
this.duration,
|
|
this.attachmentType,
|
|
this.videoType,
|
|
this.videoUrl,
|
|
this.lessonType,
|
|
this.attachment,
|
|
this.isSkip,
|
|
this.isFinished,
|
|
this.summary,
|
|
});
|
|
|
|
String? lessonId;
|
|
String? title;
|
|
String? duration;
|
|
String? attachmentType;
|
|
String? videoType;
|
|
String? videoUrl;
|
|
String? lessonType;
|
|
dynamic attachment;
|
|
String? isSkip;
|
|
String? summary;
|
|
int? isFinished;
|
|
|
|
factory DataLesson.fromJson(Map<String, dynamic> json) => DataLesson(
|
|
lessonId: json["lesson_id"],
|
|
title: json["title"],
|
|
duration: json["duration"],
|
|
attachmentType: json["attachment_type"],
|
|
videoType: json["video_type"],
|
|
videoUrl: json["video_url"],
|
|
lessonType: json["lesson_type"],
|
|
attachment: json["attachment"],
|
|
isSkip: json["is_skip"],
|
|
isFinished: json["is_finished"],
|
|
summary: json["summary"],
|
|
);
|
|
|
|
get courseId => null;
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"lesson_id": lessonId,
|
|
"title": title,
|
|
"duration": duration,
|
|
"attachment_type": attachmentType,
|
|
"video_type": videoType,
|
|
"video_url": videoUrl,
|
|
"lesson_type": lessonType,
|
|
"attachment": attachment,
|
|
"is_skip": isSkip,
|
|
"is_finished": isFinished,
|
|
"summary": summary,
|
|
};
|
|
}
|
|
|
|
class NewMap {
|
|
NewMap({
|
|
required this.title,
|
|
});
|
|
|
|
final List<Title> title;
|
|
|
|
factory NewMap.fromMap(Map<String, dynamic> json) => NewMap(
|
|
title: List<Title>.from(json["Title"].map((x) => Title.fromMap(x))),
|
|
);
|
|
|
|
Map<String, dynamic> toMap() => {
|
|
"Title": List<dynamic>.from(title.map((x) => x.toMap())),
|
|
};
|
|
}
|
|
|
|
class Title {
|
|
Title({
|
|
this.courseId,
|
|
this.lessonId,
|
|
this.sectionTitle,
|
|
this.lessonTitle,
|
|
this.duration,
|
|
this.attachmentType,
|
|
this.videoType,
|
|
this.videoUrl,
|
|
this.lessonType,
|
|
this.attachment,
|
|
this.isSkip,
|
|
this.isFinished,
|
|
this.summary,
|
|
});
|
|
|
|
final String? courseId;
|
|
final String? lessonId;
|
|
final String? sectionTitle;
|
|
final String? lessonTitle;
|
|
final String? duration;
|
|
final String? attachmentType;
|
|
final String? videoType;
|
|
final String? videoUrl;
|
|
final String? lessonType;
|
|
final dynamic attachment;
|
|
final String? isSkip;
|
|
final String? summary;
|
|
final int? isFinished;
|
|
|
|
factory Title.fromMap(Map<String, dynamic> json) => Title(
|
|
courseId: json["course_id"],
|
|
lessonId: json["lesson_id"],
|
|
sectionTitle: json["section_title"],
|
|
lessonTitle: json["lesson_title"],
|
|
duration: json["duration"],
|
|
attachmentType: json["attachment_type"],
|
|
videoType: json["video_type"],
|
|
videoUrl: json["video_url"] == '' ? 'a' : json["video_url"],
|
|
lessonType: json["lesson_type"],
|
|
attachment: json["attachment"],
|
|
isSkip: json["is_skip"],
|
|
isFinished: json["is_finished"],
|
|
summary: json["summary"],
|
|
);
|
|
|
|
Map<String, dynamic> toMap() => {
|
|
"course_id": courseId,
|
|
"lesson_id": lessonId,
|
|
"section_title": sectionTitle,
|
|
"lesson_title": lessonTitle,
|
|
"duration": duration,
|
|
"attachment_type": attachmentType,
|
|
"video_type": videoType,
|
|
"video_url": videoUrl,
|
|
"lesson_type": lessonType,
|
|
"attachment": attachment,
|
|
"is_skip": isSkip,
|
|
"is_finished": isFinished,
|
|
"summary": summary,
|
|
};
|
|
}
|