mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Rewrite LibrariesControllerV2 to be safer and include the library uuid
This commit is contained in:
parent
7c1e9298ee
commit
a5d1036886
@ -2,11 +2,6 @@
|
|||||||
#include "db_helper.h" //get libraries
|
#include "db_helper.h" //get libraries
|
||||||
#include "yacreader_libraries.h"
|
#include "yacreader_libraries.h"
|
||||||
|
|
||||||
#include "template.h"
|
|
||||||
#include "../static.h"
|
|
||||||
|
|
||||||
#include "QsLog.h"
|
|
||||||
|
|
||||||
using stefanfrings::HttpRequest;
|
using stefanfrings::HttpRequest;
|
||||||
using stefanfrings::HttpResponse;
|
using stefanfrings::HttpResponse;
|
||||||
|
|
||||||
@ -16,20 +11,18 @@ void LibrariesControllerV2::service(HttpRequest & /* request */, HttpResponse &r
|
|||||||
{
|
{
|
||||||
response.setHeader("Content-Type", "application/json");
|
response.setHeader("Content-Type", "application/json");
|
||||||
|
|
||||||
YACReaderLibraries libraries = DBHelper::getLibraries();
|
auto libraries = DBHelper::getLibraries().sortedLibraries();
|
||||||
QList<QString> names = DBHelper::getLibrariesNames();
|
|
||||||
|
|
||||||
QJsonArray librariesJson;
|
QJsonArray librariesJson;
|
||||||
|
|
||||||
int currentId = 0;
|
foreach (YACReaderLibrary library, libraries) {
|
||||||
foreach (QString name, names) {
|
QJsonObject libraryJson;
|
||||||
currentId = libraries.getId(name);
|
|
||||||
QJsonObject library;
|
|
||||||
|
|
||||||
library["name"] = name;
|
libraryJson["name"] = library.getName();
|
||||||
library["id"] = currentId;
|
libraryJson["id"] = library.getLegacyId();
|
||||||
|
libraryJson["uuid"] = library.getId().toString();
|
||||||
|
|
||||||
librariesJson.append(library);
|
librariesJson.append(libraryJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonDocument output(librariesJson);
|
QJsonDocument output(librariesJson);
|
||||||
|
Loading…
Reference in New Issue
Block a user