mirror of
https://github.com/YACReader/yacreader
synced 2025-07-17 20:44:32 -04:00
Add more info to json content + better handling of optionality
This commit is contained in:
@ -4,12 +4,10 @@
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "comic_db.h"
|
||||
#include "folder.h"
|
||||
|
||||
#include "yacreader_libraries.h"
|
||||
#include "yacreader_server_data_helper.h"
|
||||
|
||||
#include "qnaturalsorting.h"
|
||||
|
||||
#include <ctime>
|
||||
|
||||
using stefanfrings::HttpRequest;
|
||||
@ -35,9 +33,11 @@ void ComicFullinfoController_v2::service(HttpRequest &request, HttpResponse &res
|
||||
|
||||
void ComicFullinfoController_v2::serviceContent(const int &libraryId, const qulonglong &comicId, HttpResponse &response)
|
||||
{
|
||||
auto libraryUuid = DBHelper::getLibraries().getLibraryIdFromLegacyId(libraryId);
|
||||
|
||||
ComicDB comic = DBHelper::getComicInfo(libraryId, comicId);
|
||||
|
||||
QJsonObject json = YACReaderServerDataHelper::fullComicToJSON(libraryId, comic);
|
||||
QJsonObject json = YACReaderServerDataHelper::fullComicToJSON(libraryId, libraryUuid, comic);
|
||||
|
||||
QJsonDocument output(json);
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "db_helper.h"
|
||||
#include "comic_db.h"
|
||||
|
||||
#include "yacreader_libraries.h"
|
||||
#include "yacreader_server_data_helper.h"
|
||||
|
||||
using stefanfrings::HttpRequest;
|
||||
@ -25,12 +26,14 @@ void FavoritesControllerV2::service(HttpRequest &request, HttpResponse &response
|
||||
|
||||
void FavoritesControllerV2::serviceContent(const int library, HttpResponse &response)
|
||||
{
|
||||
auto libraryUuid = DBHelper::getLibraries().getLibraryIdFromLegacyId(library);
|
||||
|
||||
QList<ComicDB> comics = DBHelper::getFavorites(library);
|
||||
|
||||
QJsonArray items;
|
||||
|
||||
for (const ComicDB &comic : comics) {
|
||||
items.append(YACReaderServerDataHelper::comicToJSON(library, comic));
|
||||
items.append(YACReaderServerDataHelper::comicToJSON(library, libraryUuid, comic));
|
||||
}
|
||||
|
||||
QJsonDocument output(items);
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "comic_db.h"
|
||||
#include "folder.h"
|
||||
|
||||
#include "yacreader_libraries.h"
|
||||
#include "yacreader_server_data_helper.h"
|
||||
|
||||
#include "qnaturalsorting.h"
|
||||
@ -41,6 +42,8 @@ void FolderContentControllerV2::serviceContent(const int &library, const qulongl
|
||||
#ifdef QT_DEBUG
|
||||
auto started = std::chrono::high_resolution_clock::now();
|
||||
#endif
|
||||
auto libraryUuid = DBHelper::getLibraries().getLibraryIdFromLegacyId(library);
|
||||
|
||||
QList<LibraryItem *> folderContent = DBHelper::getFolderSubfoldersFromLibrary(library, folderId);
|
||||
QList<LibraryItem *> folderComics = DBHelper::getFolderComicsFromLibrary(library, folderId);
|
||||
|
||||
@ -56,10 +59,10 @@ void FolderContentControllerV2::serviceContent(const int &library, const qulongl
|
||||
for (QList<LibraryItem *>::const_iterator itr = folderContent.constBegin(); itr != folderContent.constEnd(); itr++) {
|
||||
if ((*itr)->isDir()) {
|
||||
currentFolder = (Folder *)(*itr);
|
||||
items.append(YACReaderServerDataHelper::folderToJSON(library, *currentFolder));
|
||||
items.append(YACReaderServerDataHelper::folderToJSON(library, libraryUuid, *currentFolder));
|
||||
} else {
|
||||
currentComic = (ComicDB *)(*itr);
|
||||
items.append(YACReaderServerDataHelper::comicToJSON(library, *currentComic));
|
||||
items.append(YACReaderServerDataHelper::comicToJSON(library, libraryUuid, *currentComic));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "db_helper.h"
|
||||
#include "comic_db.h"
|
||||
|
||||
#include "yacreader_libraries.h"
|
||||
#include "yacreader_server_data_helper.h"
|
||||
|
||||
using stefanfrings::HttpRequest;
|
||||
@ -28,12 +29,14 @@ void ReadingComicsControllerV2::service(HttpRequest &request, HttpResponse &resp
|
||||
|
||||
void ReadingComicsControllerV2::serviceContent(const int &library, HttpResponse &response)
|
||||
{
|
||||
auto libraryUuid = DBHelper::getLibraries().getLibraryIdFromLegacyId(library);
|
||||
|
||||
QList<ComicDB> readingComics = DBHelper::getReading(library);
|
||||
|
||||
QJsonArray comics;
|
||||
|
||||
for (const ComicDB &comic : readingComics) {
|
||||
comics.append(YACReaderServerDataHelper::comicToJSON(library, comic));
|
||||
comics.append(YACReaderServerDataHelper::comicToJSON(library, libraryUuid, comic));
|
||||
}
|
||||
|
||||
QJsonDocument output(comics);
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "db_helper.h"
|
||||
#include "comic_db.h"
|
||||
|
||||
#include "yacreader_libraries.h"
|
||||
#include "yacreader_server_data_helper.h"
|
||||
|
||||
using stefanfrings::HttpRequest;
|
||||
@ -28,12 +29,14 @@ void ReadingListContentControllerV2::service(HttpRequest &request, HttpResponse
|
||||
|
||||
void ReadingListContentControllerV2::serviceContent(const int &library, const qulonglong &readingListId, HttpResponse &response)
|
||||
{
|
||||
auto libraryUuid = DBHelper::getLibraries().getLibraryIdFromLegacyId(library);
|
||||
|
||||
QList<ComicDB> comics = DBHelper::getReadingListFullContent(library, readingListId);
|
||||
|
||||
QJsonArray items;
|
||||
|
||||
for (const ComicDB &comic : comics) {
|
||||
items.append(YACReaderServerDataHelper::comicToJSON(library, comic));
|
||||
items.append(YACReaderServerDataHelper::comicToJSON(library, libraryUuid, comic));
|
||||
}
|
||||
|
||||
QJsonDocument output(items);
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "reading_list.h"
|
||||
#include "yacreader_libraries.h"
|
||||
#include "yacreader_server_data_helper.h"
|
||||
|
||||
using stefanfrings::HttpRequest;
|
||||
@ -26,12 +27,14 @@ void ReadingListsControllerV2::service(HttpRequest &request, HttpResponse &respo
|
||||
|
||||
void ReadingListsControllerV2::serviceContent(const int library, HttpResponse &response)
|
||||
{
|
||||
auto libraryUuid = DBHelper::getLibraries().getLibraryIdFromLegacyId(library);
|
||||
|
||||
QList<ReadingList> readingLists = DBHelper::getReadingLists(library);
|
||||
|
||||
QJsonArray items;
|
||||
|
||||
for (QList<ReadingList>::const_iterator itr = readingLists.constBegin(); itr != readingLists.constEnd(); itr++) {
|
||||
items.append(YACReaderServerDataHelper::readingListToJSON(library, *itr));
|
||||
items.append(YACReaderServerDataHelper::readingListToJSON(library, libraryUuid, *itr));
|
||||
}
|
||||
|
||||
QJsonDocument output(items);
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "db_helper.h"
|
||||
#include "comic_db.h"
|
||||
|
||||
#include "yacreader_libraries.h"
|
||||
#include "yacreader_server_data_helper.h"
|
||||
|
||||
#include <QUrl>
|
||||
@ -30,12 +31,14 @@ void TagContentControllerV2::service(HttpRequest &request, HttpResponse &respons
|
||||
|
||||
void TagContentControllerV2::serviceContent(const int &library, const qulonglong &tagId, HttpResponse &response)
|
||||
{
|
||||
auto libraryUuid = DBHelper::getLibraries().getLibraryIdFromLegacyId(library);
|
||||
|
||||
QList<ComicDB> comics = DBHelper::getLabelComics(library, tagId);
|
||||
|
||||
QJsonArray items;
|
||||
|
||||
for (const ComicDB &comic : comics) {
|
||||
items.append(YACReaderServerDataHelper::comicToJSON(library, comic));
|
||||
items.append(YACReaderServerDataHelper::comicToJSON(library, libraryUuid, comic));
|
||||
}
|
||||
|
||||
QJsonDocument output(items);
|
||||
|
@ -4,13 +4,9 @@
|
||||
#include "yacreader_libraries.h"
|
||||
|
||||
#include "reading_list.h"
|
||||
#include "../static.h"
|
||||
#include "yacreader_global.h"
|
||||
|
||||
#include "yacreader_server_data_helper.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
using stefanfrings::HttpRequest;
|
||||
using stefanfrings::HttpResponse;
|
||||
|
||||
@ -26,10 +22,12 @@ void TagsControllerV2::service(HttpRequest &request, HttpResponse &response)
|
||||
|
||||
QList<Label> labels = DBHelper::getLabels(libraryId);
|
||||
|
||||
auto libraryUuid = DBHelper::getLibraries().getLibraryIdFromLegacyId(libraryId);
|
||||
|
||||
QJsonArray items;
|
||||
|
||||
for (QList<Label>::const_iterator itr = labels.constBegin(); itr != labels.constEnd(); itr++) {
|
||||
items.append(YACReaderServerDataHelper::labelToJSON(libraryId, *itr));
|
||||
items.append(YACReaderServerDataHelper::labelToJSON(libraryId, libraryUuid, *itr));
|
||||
}
|
||||
|
||||
QJsonDocument output(items);
|
||||
|
Reference in New Issue
Block a user