mirror of
https://github.com/YACReader/yacreader
synced 2025-06-03 09:08:20 -04:00
Migrate some more controllers to json.
This commit is contained in:
parent
a9887a2d46
commit
0305377c28
@ -28,8 +28,14 @@ void ReadingListContentControllerV2::serviceContent(const int &library, const qu
|
|||||||
{
|
{
|
||||||
QList<ComicDB> comics = DBHelper::getReadingListFullContent(library, readingListId);
|
QList<ComicDB> comics = DBHelper::getReadingListFullContent(library, readingListId);
|
||||||
|
|
||||||
|
QJsonArray items;
|
||||||
|
|
||||||
for(const ComicDB &comic : comics)
|
for(const ComicDB &comic : comics)
|
||||||
{
|
{
|
||||||
response.write(YACReaderServerDataHelper::comicToYSFormat(library, comic).toUtf8());
|
items.append(YACReaderServerDataHelper::comicToJSON(library, comic));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QJsonDocument output(items);
|
||||||
|
|
||||||
|
response.write(output.toJson());
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
#include "db_helper.h"
|
#include "db_helper.h"
|
||||||
#include "reading_list.h"
|
#include "reading_list.h"
|
||||||
|
#include "yacreader_server_data_helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ReadingListsControllerV2::ReadingListsControllerV2()
|
ReadingListsControllerV2::ReadingListsControllerV2()
|
||||||
{
|
{
|
||||||
@ -25,8 +28,14 @@ void ReadingListsControllerV2::serviceContent(const int library, HttpResponse &r
|
|||||||
{
|
{
|
||||||
QList<ReadingList> readingLists = DBHelper::getReadingLists(library);
|
QList<ReadingList> readingLists = DBHelper::getReadingLists(library);
|
||||||
|
|
||||||
foreach(const ReadingList &item, readingLists)
|
QJsonArray items;
|
||||||
|
|
||||||
|
for(QList<ReadingList>::const_iterator itr = readingLists.constBegin();itr!=readingLists.constEnd();itr++)
|
||||||
{
|
{
|
||||||
response.write(QString("%1\t%2\t%3\r\n").arg(library).arg(item.getId()).arg(item.getName()).toUtf8());
|
items.append(YACReaderServerDataHelper::readingListToJSON(library, *itr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QJsonDocument output(items);
|
||||||
|
|
||||||
|
response.write(output.toJson());
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include "../static.h"
|
#include "../static.h"
|
||||||
#include "yacreader_global.h"
|
#include "yacreader_global.h"
|
||||||
|
|
||||||
|
#include "yacreader_server_data_helper.h"
|
||||||
|
|
||||||
#include "QsLog.h"
|
#include "QsLog.h"
|
||||||
|
|
||||||
TagsControllerV2::TagsControllerV2() {}
|
TagsControllerV2::TagsControllerV2() {}
|
||||||
@ -19,12 +21,16 @@ void TagsControllerV2::service(HttpRequest& request, HttpResponse& response)
|
|||||||
QStringList pathElements = path.split('/');
|
QStringList pathElements = path.split('/');
|
||||||
int libraryId = pathElements.at(3).toInt();
|
int libraryId = pathElements.at(3).toInt();
|
||||||
|
|
||||||
QList<Label> tags = DBHelper::getLabels(libraryId);
|
QList<Label> labels = DBHelper::getLabels(libraryId);
|
||||||
|
|
||||||
foreach(const Label &tag, tags)
|
QJsonArray items;
|
||||||
|
|
||||||
|
for(QList<Label>::const_iterator itr = labels.constBegin();itr!=labels.constEnd();itr++)
|
||||||
{
|
{
|
||||||
response.write(QString("%1\t%2\t%3\t%4\r\n").arg(libraryId).arg(tag.getId()).arg(tag.getName()).arg(labelColorToRGBString(tag.getColorID())).toUtf8());
|
items.append(YACReaderServerDataHelper::labelToJSON(libraryId, *itr));
|
||||||
}
|
}
|
||||||
|
|
||||||
response.write("",true);
|
QJsonDocument output(items);
|
||||||
|
|
||||||
|
response.write(output.toJson());;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user