yacreader/YACReaderLibrary/server/controllers/v2/comicfullinfocontroller_v2.cpp
Luis Ángel San Martín 20c7ecadd4 Add new controller for requesting the "full" information for a comic.
For now it doesn't serve the full information, only the information shown in the current/next comic view in iOS. I will see if I create two separated controllers or just on sending all the information when more information is needed in another iOS view.
2018-04-23 19:24:56 +02:00

47 lines
1.2 KiB
C++

#include "comicfullinfocontroller_v2.h"
#include <QUrl>
#include "db_helper.h"
#include "comic_db.h"
#include "folder.h"
#include "yacreader_server_data_helper.h"
#include "qnaturalsorting.h"
#include <ctime>
using namespace std;
ComicFullinfoController_v2::ComicFullinfoController_v2() {}
void ComicFullinfoController_v2::service(HttpRequest& request, HttpResponse& response)
{
response.setHeader("Content-Type", "application/json");
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
QStringList pathElements = path.split('/');
int libraryId = pathElements.at(3).toInt();
qulonglong comicId = pathElements.at(5).toULongLong();
serviceContent(libraryId, comicId, response);
response.setStatus(200,"OK");
response.write("",true);
}
void ComicFullinfoController_v2::serviceContent(const int &libraryId, const qulonglong &comicId, HttpResponse &response)
{
ComicDB comic = DBHelper::getComicInfo(libraryId, comicId);
QJsonObject json = YACReaderServerDataHelper::fullComicToJSON(libraryId, comic);
QJsonDocument output(json);
response.write(output.toJson());
}