save before flutter upgrade
This commit is contained in:
130
lib/models/content_manager/ad_by_genre.dart
Normal file
130
lib/models/content_manager/ad_by_genre.dart
Normal file
@@ -0,0 +1,130 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class AdsByGenre {
|
||||
String genreName;
|
||||
int videoCount;
|
||||
int rowNumber;
|
||||
List<Video> videos;
|
||||
int genreId;
|
||||
dynamic genrePoster;
|
||||
String? storageCategoryImageFileName;
|
||||
bool isExpanded = false;
|
||||
AdsByGenre({
|
||||
required this.genreName,
|
||||
required this.videoCount,
|
||||
required this.rowNumber,
|
||||
required this.videos,
|
||||
required this.genreId,
|
||||
required this.genrePoster,
|
||||
required this.storageCategoryImageFileName,
|
||||
});
|
||||
|
||||
factory AdsByGenre.fromJson(String str) =>
|
||||
AdsByGenre.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory AdsByGenre.fromMap(Map<String, dynamic> json) => AdsByGenre(
|
||||
genreName: json["genre_name"],
|
||||
videoCount: json["video_count"],
|
||||
rowNumber: json["row_number"],
|
||||
videos: List<Video>.from(json["videos"].map((x) => Video.fromMap(x))),
|
||||
genreId: json["genre_id"],
|
||||
genrePoster: json["genre_poster"],
|
||||
storageCategoryImageFileName: json["poster_image_file"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"genre_name": genreName,
|
||||
"video_count": videoCount,
|
||||
"row_number": rowNumber,
|
||||
"videos": List<dynamic>.from(videos.map((x) => x.toMap())),
|
||||
"genre_id": genreId,
|
||||
"genre_poster": genrePoster,
|
||||
"poster_image_file": storageCategoryImageFileName,
|
||||
};
|
||||
}
|
||||
|
||||
class Video {
|
||||
String title;
|
||||
int points;
|
||||
dynamic status;
|
||||
dynamic urlAd;
|
||||
dynamic partner;
|
||||
int duration;
|
||||
String overview;
|
||||
int priority;
|
||||
int videoId;
|
||||
String videoUrl;
|
||||
List<String> categories;
|
||||
DateTime createdAt;
|
||||
String posterPath;
|
||||
bool videoStatus;
|
||||
dynamic expirationDate;
|
||||
String videoFileName;
|
||||
String posterFileName;
|
||||
|
||||
Video({
|
||||
required this.title,
|
||||
required this.points,
|
||||
required this.status,
|
||||
required this.urlAd,
|
||||
required this.partner,
|
||||
required this.duration,
|
||||
required this.overview,
|
||||
required this.priority,
|
||||
required this.videoId,
|
||||
required this.videoUrl,
|
||||
required this.categories,
|
||||
required this.createdAt,
|
||||
required this.posterPath,
|
||||
required this.videoStatus,
|
||||
required this.expirationDate,
|
||||
required this.videoFileName,
|
||||
required this.posterFileName,
|
||||
});
|
||||
|
||||
factory Video.fromJson(String str) => Video.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory Video.fromMap(Map<String, dynamic> json) => Video(
|
||||
title: json["title"],
|
||||
points: json["points"],
|
||||
status: json["status"],
|
||||
urlAd: json["url_ad"],
|
||||
partner: json["partner"],
|
||||
duration: json["duration"],
|
||||
overview: json["overview"],
|
||||
priority: json["priority"],
|
||||
videoId: json["video_id"],
|
||||
videoUrl: json["video_url"],
|
||||
categories: List<String>.from(json["categories"].map((x) => x)),
|
||||
createdAt: DateTime.parse(json["created_at"]),
|
||||
posterPath: json["poster_path"],
|
||||
videoStatus: json["video_status"],
|
||||
expirationDate: json["expiration_date"],
|
||||
videoFileName: json["video_file_name"],
|
||||
posterFileName: json["poster_file_name"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"title": title,
|
||||
"points": points,
|
||||
"status": status,
|
||||
"url_ad": urlAd,
|
||||
"partner": partner,
|
||||
"duration": duration,
|
||||
"overview": overview,
|
||||
"priority": priority,
|
||||
"video_id": videoId,
|
||||
"video_url": videoUrl,
|
||||
"categories": List<dynamic>.from(categories.map((x) => x)),
|
||||
"created_at": createdAt.toIso8601String(),
|
||||
"poster_path": posterPath,
|
||||
"video_status": videoStatus,
|
||||
"expiration_date": expirationDate,
|
||||
"video_file_name": videoFileName,
|
||||
"poster_file_name": posterFileName,
|
||||
};
|
||||
}
|
||||
125
lib/models/content_manager/all_ads_one_table_model.dart
Normal file
125
lib/models/content_manager/all_ads_one_table_model.dart
Normal file
@@ -0,0 +1,125 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class AllAdsOneTableModel {
|
||||
final int id;
|
||||
final int? rowNumber; // Opcional, para el campo row_number
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
final String overview;
|
||||
final String posterPath;
|
||||
final String title;
|
||||
final String video; // Corresponde a video_url
|
||||
final int durationVideo;
|
||||
final dynamic urlAd; // Añadido para url_ad
|
||||
final int priority;
|
||||
final bool videoStatus; // Cambiado de status text a videoStatus boolean
|
||||
final dynamic expirationDate;
|
||||
final int points;
|
||||
final String? videoFileName;
|
||||
final dynamic partner;
|
||||
final String posterFileName;
|
||||
final List<dynamic> categories;
|
||||
final List<Map<String, dynamic>>
|
||||
qrCodes; // Puede ser List<dynamic> o Map<String, dynamic>
|
||||
final int warningCount;
|
||||
|
||||
AllAdsOneTableModel({
|
||||
required this.id,
|
||||
this.rowNumber,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.overview,
|
||||
required this.posterPath,
|
||||
required this.title,
|
||||
required this.video,
|
||||
required this.durationVideo,
|
||||
this.urlAd, // Añadido
|
||||
required this.priority,
|
||||
required this.videoStatus, // Requerido y de tipo bool
|
||||
this.expirationDate,
|
||||
required this.points,
|
||||
this.videoFileName,
|
||||
this.partner,
|
||||
required this.posterFileName,
|
||||
required this.categories,
|
||||
required this.qrCodes,
|
||||
required this.warningCount,
|
||||
});
|
||||
|
||||
factory AllAdsOneTableModel.fromJson(String str) =>
|
||||
AllAdsOneTableModel.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory AllAdsOneTableModel.fromMap(Map<String, dynamic> json) {
|
||||
// Procesamiento de qrCodes similar al de CouponsModel
|
||||
final rawQrCodes = json["qr_codes"];
|
||||
|
||||
final parsedQrCodes = rawQrCodes is List
|
||||
? rawQrCodes
|
||||
.map((e) {
|
||||
if (e is String) {
|
||||
try {
|
||||
return Map<String, dynamic>.from(jsonDecode(e));
|
||||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
} else if (e is Map) {
|
||||
return Map<String, dynamic>.from(e);
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
})
|
||||
.toList()
|
||||
.cast<Map<String, dynamic>>() // 🔥 necesario sí o sí
|
||||
: [];
|
||||
|
||||
return AllAdsOneTableModel(
|
||||
id: json["video_id"] ?? json["id"],
|
||||
rowNumber: json["row_number"],
|
||||
createdAt: DateTime.parse(json["created_at"]),
|
||||
updatedAt: DateTime.parse(json["updated_at"]),
|
||||
overview: json["overview"],
|
||||
posterPath: json["poster_path"],
|
||||
title: json["title"],
|
||||
video: json["video_url"],
|
||||
durationVideo: json["duration_video"],
|
||||
urlAd: json["url_ad"], // Mapeo para url_ad
|
||||
priority: json["priority"],
|
||||
videoStatus: json["video_status"], // Mapeo para video_status
|
||||
expirationDate: json["expiration_date"],
|
||||
points: json["points"],
|
||||
videoFileName: json["video_file_name"],
|
||||
partner: json["partner"],
|
||||
posterFileName: json["poster_file_name"],
|
||||
categories: json["categories"] == null
|
||||
? []
|
||||
: List<dynamic>.from(json["categories"].map((x) => x)),
|
||||
qrCodes: parsedQrCodes.cast<Map<String, dynamic>>(),
|
||||
warningCount: json["warning_count"],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"video_id": id,
|
||||
"row_number": rowNumber,
|
||||
"created_at": createdAt.toIso8601String(),
|
||||
"updated_at": updatedAt.toIso8601String(),
|
||||
"overview": overview,
|
||||
"poster_path": posterPath,
|
||||
"title": title,
|
||||
"video_url": video,
|
||||
"duration_video": durationVideo,
|
||||
"url_ad": urlAd, // Añadido
|
||||
"priority": priority,
|
||||
"video_status": videoStatus,
|
||||
"expiration_date": expirationDate,
|
||||
"points": points,
|
||||
"video_file_name": videoFileName,
|
||||
"partner": partner,
|
||||
"poster_file_name": posterFileName,
|
||||
"categories": List<dynamic>.from(categories.map((x) => x)),
|
||||
"qr_codes": qrCodes,
|
||||
"warning_count": warningCount,
|
||||
};
|
||||
}
|
||||
83
lib/models/content_manager/all_books_one_table_model.dart
Normal file
83
lib/models/content_manager/all_books_one_table_model.dart
Normal file
@@ -0,0 +1,83 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class AllBooksOneTableModel {
|
||||
int rowNumber;
|
||||
int bookId;
|
||||
DateTime createdAt;
|
||||
String bookDescription;
|
||||
String title;
|
||||
String book;
|
||||
String size;
|
||||
String year;
|
||||
String? bookCover;
|
||||
int autorFk;
|
||||
int statusFk;
|
||||
String bookStatus;
|
||||
String autorFirstName;
|
||||
String autorLastName;
|
||||
String? autorFullName;
|
||||
List<String?> categories;
|
||||
|
||||
AllBooksOneTableModel({
|
||||
required this.rowNumber,
|
||||
required this.bookId,
|
||||
required this.createdAt,
|
||||
required this.bookDescription,
|
||||
required this.title,
|
||||
required this.book,
|
||||
required this.size,
|
||||
required this.year,
|
||||
required this.bookCover,
|
||||
required this.autorFk,
|
||||
required this.statusFk,
|
||||
required this.bookStatus,
|
||||
required this.autorFirstName,
|
||||
required this.autorLastName,
|
||||
required this.autorFullName,
|
||||
required this.categories,
|
||||
});
|
||||
|
||||
factory AllBooksOneTableModel.fromJson(String str) =>
|
||||
AllBooksOneTableModel.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory AllBooksOneTableModel.fromMap(Map<String, dynamic> json) =>
|
||||
AllBooksOneTableModel(
|
||||
rowNumber: json["row_number"],
|
||||
bookId: json["book_id"],
|
||||
createdAt: DateTime.parse(json["created_at"]),
|
||||
bookDescription: json["book_description"],
|
||||
title: json["title"],
|
||||
book: json["book"],
|
||||
size: json["size"],
|
||||
year: json["year"],
|
||||
bookCover: json["book_cover"],
|
||||
autorFk: json["autor_fk"],
|
||||
statusFk: json["status_fk"],
|
||||
bookStatus: json["book_status"],
|
||||
autorFirstName: json["autor_first_name"],
|
||||
autorLastName: json["autor_last_name"],
|
||||
autorFullName: json["autor_name"],
|
||||
categories: List<String?>.from(json["categories"].map((x) => x)),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"row_number": rowNumber,
|
||||
"book_id": bookId,
|
||||
"created_at": createdAt.toIso8601String(),
|
||||
"book_description": bookDescription,
|
||||
"title": title,
|
||||
"book": book,
|
||||
"size": size,
|
||||
"year": year,
|
||||
"book_cover": bookCover,
|
||||
"autor_fk": autorFk,
|
||||
"status_fk": statusFk,
|
||||
"book_status": bookStatus,
|
||||
"autor_first_name": autorFirstName,
|
||||
"autor_last_name": autorLastName,
|
||||
"autor_name": autorFullName,
|
||||
"categories": List<dynamic>.from(categories.map((x) => x)),
|
||||
};
|
||||
}
|
||||
69
lib/models/content_manager/book.dart
Normal file
69
lib/models/content_manager/book.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Book {
|
||||
int bookId;
|
||||
String title;
|
||||
String bookDescription;
|
||||
DateTime createdAt;
|
||||
String book;
|
||||
String bookCover;
|
||||
String size;
|
||||
String year;
|
||||
String bookStatus;
|
||||
int autorId;
|
||||
String autorFirstName;
|
||||
String? autorLastName;
|
||||
String category;
|
||||
|
||||
Book({
|
||||
required this.bookId,
|
||||
required this.title,
|
||||
required this.bookDescription,
|
||||
required this.createdAt,
|
||||
required this.book,
|
||||
required this.bookCover,
|
||||
required this.size,
|
||||
required this.year,
|
||||
required this.bookStatus,
|
||||
required this.autorId,
|
||||
required this.autorFirstName,
|
||||
required this.autorLastName,
|
||||
required this.category,
|
||||
});
|
||||
|
||||
factory Book.fromJson(String str) => Book.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory Book.fromMap(Map<String, dynamic> json) => Book(
|
||||
bookId: json["book_id"],
|
||||
title: json["title"],
|
||||
bookDescription: json["book_description"],
|
||||
createdAt: DateTime.parse(json["created_at"]),
|
||||
book: json["book"],
|
||||
bookCover: json["book_cover"],
|
||||
size: json["size"],
|
||||
year: json["year"],
|
||||
bookStatus: json["book_status"],
|
||||
autorId: json["autor_id"],
|
||||
autorFirstName: json["autor_first_name"],
|
||||
autorLastName: json["autor_last_name"],
|
||||
category: json["category"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"book_id": bookId,
|
||||
"title": title,
|
||||
"book_description": bookDescription,
|
||||
"created_at": createdAt.toIso8601String(),
|
||||
"book": book,
|
||||
"book_cover": bookCover,
|
||||
"size": size,
|
||||
"year": year,
|
||||
"book_status": bookStatus,
|
||||
"autor_id": autorId,
|
||||
"autor_first_name": autorFirstName,
|
||||
"autor_last_name": autorLastName,
|
||||
"category": category,
|
||||
};
|
||||
}
|
||||
124
lib/models/content_manager/book_by_genre.dart
Normal file
124
lib/models/content_manager/book_by_genre.dart
Normal file
@@ -0,0 +1,124 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class BooksByGenreModel {
|
||||
String genreName;
|
||||
int bookCount;
|
||||
int rowNumber;
|
||||
List<Book> books;
|
||||
int genreId;
|
||||
dynamic genrePoster;
|
||||
dynamic posterImageFile;
|
||||
bool isExpanded = false;
|
||||
|
||||
BooksByGenreModel({
|
||||
required this.genreName,
|
||||
required this.bookCount,
|
||||
required this.rowNumber,
|
||||
required this.books,
|
||||
required this.genreId,
|
||||
required this.genrePoster,
|
||||
required this.posterImageFile,
|
||||
});
|
||||
|
||||
factory BooksByGenreModel.fromJson(String str) =>
|
||||
BooksByGenreModel.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory BooksByGenreModel.fromMap(Map<String, dynamic> json) =>
|
||||
BooksByGenreModel(
|
||||
genreName: json["genre_name"],
|
||||
bookCount: json["book_count"],
|
||||
rowNumber: json["row_number"],
|
||||
books: List<Book>.from(json["books"].map((x) => Book.fromMap(x))),
|
||||
genreId: json["genre_id"],
|
||||
genrePoster: json["genre_poster"],
|
||||
posterImageFile: json["poster_image_file"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"genre_name": genreName,
|
||||
"book_count": bookCount,
|
||||
"row_number": rowNumber,
|
||||
"books": List<dynamic>.from(books.map((x) => x.toMap())),
|
||||
"genre_id": genreId,
|
||||
"genre_poster": genrePoster,
|
||||
"poster_image_file": posterImageFile,
|
||||
};
|
||||
}
|
||||
|
||||
class Book {
|
||||
String size;
|
||||
String year;
|
||||
String title;
|
||||
String status;
|
||||
int bookId;
|
||||
int autorId;
|
||||
String bookUrl;
|
||||
String overview;
|
||||
int statusId;
|
||||
String? bookCover;
|
||||
List<String> categories;
|
||||
DateTime createdAt;
|
||||
String autorLastName;
|
||||
String autorFirstName;
|
||||
String? autorFullName = '';
|
||||
|
||||
Book({
|
||||
required this.size,
|
||||
required this.year,
|
||||
required this.title,
|
||||
required this.status,
|
||||
required this.bookId,
|
||||
required this.autorId,
|
||||
required this.bookUrl,
|
||||
required this.overview,
|
||||
required this.statusId,
|
||||
required this.bookCover,
|
||||
required this.categories,
|
||||
required this.createdAt,
|
||||
required this.autorLastName,
|
||||
required this.autorFirstName,
|
||||
required this.autorFullName,
|
||||
});
|
||||
|
||||
factory Book.fromJson(String str) => Book.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory Book.fromMap(Map<String, dynamic> json) => Book(
|
||||
size: json["size"],
|
||||
year: json["year"],
|
||||
title: json["title"],
|
||||
status: json["status"],
|
||||
bookId: json["book_id"],
|
||||
autorId: json["autor_id"],
|
||||
bookUrl: json["book_url"],
|
||||
overview: json["overview"],
|
||||
statusId: json["status_id"],
|
||||
bookCover: json["book_cover"],
|
||||
categories: List<String>.from(json["categories"].map((x) => x)),
|
||||
createdAt: DateTime.parse(json["created_at"]),
|
||||
autorLastName: json["autor_last_name"],
|
||||
autorFirstName: json["autor_first_name"],
|
||||
autorFullName: json["autor_name"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"size": size,
|
||||
"year": year,
|
||||
"title": title,
|
||||
"status": status,
|
||||
"book_id": bookId,
|
||||
"autor_id": autorId,
|
||||
"book_url": bookUrl,
|
||||
"overview": overview,
|
||||
"status_id": statusId,
|
||||
"book_cover": bookCover,
|
||||
"categories": List<dynamic>.from(categories.map((x) => x)),
|
||||
"created_at": createdAt.toIso8601String(),
|
||||
"autor_last_name": autorLastName,
|
||||
"autor_first_name": autorFirstName,
|
||||
"autor_name": autorFullName,
|
||||
};
|
||||
}
|
||||
30
lib/models/content_manager/category_model.dart
Normal file
30
lib/models/content_manager/category_model.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class CategoryModel {
|
||||
int categoryId;
|
||||
DateTime createdAt;
|
||||
String name;
|
||||
|
||||
CategoryModel({
|
||||
required this.categoryId,
|
||||
required this.createdAt,
|
||||
required this.name,
|
||||
});
|
||||
|
||||
factory CategoryModel.fromJson(String str) =>
|
||||
CategoryModel.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory CategoryModel.fromMap(Map<String, dynamic> json) => CategoryModel(
|
||||
categoryId: json["category_id"],
|
||||
createdAt: DateTime.parse(json["created_at"]),
|
||||
name: json["name"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"category_id": categoryId,
|
||||
"created_at": createdAt.toIso8601String(),
|
||||
"name": name,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user