mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 04:54:29 -04:00
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.
This commit is contained in:
@ -0,0 +1,46 @@
|
||||
#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());
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
#ifndef COMICFULLINFOCONTROLLER_V2_H
|
||||
#define COMICFULLINFOCONTROLLER_V2_H
|
||||
|
||||
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
|
||||
|
||||
class ComicFullinfoController_v2 : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(ComicFullinfoController_v2)
|
||||
public:
|
||||
ComicFullinfoController_v2();
|
||||
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
|
||||
private:
|
||||
void serviceContent(const int &library, const qulonglong &comicId, HttpResponse &response);
|
||||
};
|
||||
|
||||
#endif // COMICFULLINFOCONTROLLER_V2_H
|
Reference in New Issue
Block a user