mirror of
https://github.com/YACReader/yacreader
synced 2025-06-03 17:18:23 -04:00
Add new class for serving the content of tag.
This commit is contained in:
parent
1d73d1f1bf
commit
4e50c5628d
37
YACReaderLibrary/server/controllers/tagcontentcontroller.cpp
Normal file
37
YACReaderLibrary/server/controllers/tagcontentcontroller.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include "tagcontentcontroller.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "comic_db.h"
|
||||
|
||||
#include "yacreader_server_data_helper.h"
|
||||
|
||||
#include <QUrl>
|
||||
|
||||
TagContentController::TagContentController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TagContentController::service(HttpRequest &request, HttpResponse &response)
|
||||
{
|
||||
response.setHeader("Content-Type", "text/plain; charset=utf-8");
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
int libraryId = pathElements.at(2).toInt();
|
||||
qulonglong tagId = pathElements.at(4).toULongLong();
|
||||
|
||||
serviceContent(libraryId, tagId, response);
|
||||
|
||||
response.write("",true);
|
||||
}
|
||||
|
||||
void TagContentController::serviceContent(const int &library, const qulonglong &tagId, HttpResponse &response)
|
||||
{
|
||||
QList<ComicDB> tagComics = DBHelper::getLabelComics(library, tagId);
|
||||
|
||||
for(const ComicDB &comic : tagComics)
|
||||
{
|
||||
response.write(YACReaderServerDataHelper::comicToYSFormat(library, comic).toUtf8());
|
||||
}
|
||||
}
|
22
YACReaderLibrary/server/controllers/tagcontentcontroller.h
Normal file
22
YACReaderLibrary/server/controllers/tagcontentcontroller.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef TAGCONTENTCONTROLLER_H
|
||||
#define TAGCONTENTCONTROLLER_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class TagContentController : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(TagContentController);
|
||||
public:
|
||||
/** Constructor */
|
||||
TagContentController();
|
||||
|
||||
/** Generates the response */
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
|
||||
private:
|
||||
void serviceContent(const int &library, const qulonglong &tagId, HttpResponse &response);
|
||||
};
|
||||
|
||||
#endif // TAGCONTENTCONTROLLER_H
|
Loading…
x
Reference in New Issue
Block a user