mirror of
https://gitlab.com/spaceti-app/integrations/acs/colnod-connector.git
synced 2026-07-12 13:10:45 +02:00
Fix quotes
This commit is contained in:
parent
9a73a46f61
commit
59363f8997
@ -37,8 +37,6 @@ bool ColnodAPI::downloadData(const qint64 &time)
|
||||
}
|
||||
AuthToken token;
|
||||
|
||||
qDebug(colnod) << "Data:" << login->responseData();
|
||||
|
||||
if (checkResponse(login->responseData())) {
|
||||
qCWarning(colnod) << "empty response data when logging in";
|
||||
emit downloadDataFinished(nullptr);
|
||||
@ -237,11 +235,7 @@ std::shared_ptr<serversdk::Request> ColnodAPI::requestLogin()
|
||||
login.setPassword(encodedPassword);
|
||||
|
||||
auto loginRequest = composeRequest("/AaaManager/authSession", login.jsonData());
|
||||
// loginRequest->setUserName(login.username());
|
||||
// loginRequest->setPassword(login.password());
|
||||
QMap<QString, QString> header;
|
||||
// loginRequest->addHeader("client-id", mClientId);
|
||||
// loginRequest->addHeader("x-api-key", mApiKey);
|
||||
|
||||
mReqMan->processRequest(loginRequest);
|
||||
|
||||
return loginRequest;
|
||||
|
||||
@ -153,9 +153,10 @@ void DatabaseAPI::reupdateDeleted(const QList<QString>& ids)
|
||||
{
|
||||
auto query = mDbMan->createQuery();
|
||||
for (const auto &id : ids){
|
||||
query.prepare("UPDATE colnod_token SET last_update = :last_update WHERE id = :id");
|
||||
query.bindValue(":last_update", QDateTime::fromMSecsSinceEpoch(getNow()).toString("yyyy-MM-dd hh:mm:ss.zzz"));
|
||||
query.bindValue(":id", id);
|
||||
query.prepare("UPDATE colnod_token SET last_update = CURRENT_TIMESTAMP() WHERE id = :id");
|
||||
// query.bindValue(":last_update", QDateTime::fromMSecsSinceEpoch(getNow()).toString("yyyy-MM-dd hh:mm:ss.zzz"));
|
||||
QString tempId = "'" + id + "'";
|
||||
query.bindValue(":id", tempId);
|
||||
if (!executeQuery(query)) {
|
||||
if (!executeQuery(query)) {
|
||||
qWarning(database) << "ERROR during updating last update of deleted token:" << id << ", it will be synced from Colnod to db in next sync. Last modified will be invalid";
|
||||
@ -186,6 +187,9 @@ bool DatabaseAPI::uploadTokens(const QHash<QString, std::shared_ptr<Token>> &tok
|
||||
else {
|
||||
query = utils->insertIntoTable(token.get(), "colnod_token");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!query.isActive()) {
|
||||
mValid = false;
|
||||
qWarning(database) << "ERROR durning inserting/updating of token:" << token->name();
|
||||
@ -230,12 +234,13 @@ bool DatabaseAPI::uploadSubjects(const QHash<QString, std::shared_ptr<Subject>>
|
||||
bool DatabaseAPI::deleteItems(const QList<QString> &ids, const QString &tableName)
|
||||
{
|
||||
auto query = mDbMan->createQuery();
|
||||
QString nowString = QDateTime::fromMSecsSinceEpoch(getLastSync()).toString("yyyy-MM-dd hh:mm:ss.zzz");
|
||||
|
||||
QString nowString = QDateTime::fromMSecsSinceEpoch(getLastSync()).toString("yyyy-MM-dd hh:mm:ss");
|
||||
nowString = "'" + nowString + "'";
|
||||
if (tableName == "colnod_subject") {
|
||||
for (const auto &id : ids) {
|
||||
query.prepare("DELETE FROM colnod_subject_attribute WHERE subject_id = :id");
|
||||
query.bindValue(":id", id);
|
||||
QString tempId = "'" + id + "'";
|
||||
query.bindValue(":id", tempId);
|
||||
if (!executeQuery(query)) {
|
||||
qWarning(database) << "ERROR during marking as deleted:" << id;
|
||||
mValid = false;
|
||||
@ -246,7 +251,8 @@ bool DatabaseAPI::deleteItems(const QList<QString> &ids, const QString &tableNam
|
||||
|
||||
for (const auto &id : ids) {
|
||||
query.prepare(QString("UPDATE %1 SET deleted = true, last_update = :now, last_modified = :now WHERE id = :id").arg(tableName));
|
||||
query.bindValue(":id", id);
|
||||
QString tempId = "'" + id + "'";
|
||||
query.bindValue(":id", tempId);
|
||||
query.bindValue(":now", nowString);
|
||||
if (!executeQuery(query)) {
|
||||
qWarning(database) << "ERROR during marking as deleted:" << id;
|
||||
@ -265,7 +271,6 @@ std::shared_ptr<Token> DatabaseAPI::getToken(const QString &id)
|
||||
query.bindValue(":id", tempId);
|
||||
if (!executeQuery(query)) {
|
||||
qCritical(database) << "ERROR during accessing existing tokens. EXIT";
|
||||
qInfo(database) << "Query error:" << query.lastError().text();
|
||||
return nullptr;
|
||||
}
|
||||
auto list = utils->tableFromQuery<Token>(query);
|
||||
@ -283,7 +288,8 @@ int DatabaseAPI::exists(const QString &id, const QString &tableName)
|
||||
{
|
||||
auto query = mDbMan->createQuery();
|
||||
query.prepare(QString("SELECT 1 FROM %1 WHERE id = :id").arg(tableName));
|
||||
query.bindValue(":id", id);
|
||||
QString tempId = "'" + id + "'";
|
||||
query.bindValue(":id", tempId);
|
||||
if (!executeQuery(query)) {
|
||||
qCritical(database) << "ERROR during accessing existing tokens. EXIT(1)";
|
||||
return -1;
|
||||
@ -295,7 +301,8 @@ qint16 DatabaseAPI::getNumOfTokensOfSubject(const QString &id)
|
||||
{
|
||||
auto query = mDbMan->createQuery();
|
||||
query.prepare("SELECT 1 FROM colnod_token WHERE subject_id = :id AND description = 'mobile'");
|
||||
query.bindValue(":id", id);
|
||||
QString tempId = "'" + id + "'";
|
||||
query.bindValue(":id", tempId);
|
||||
if (!executeQuery(query)) {
|
||||
qCritical(database) << "ERROR during accessing existing tokens. EXIT(1)";
|
||||
return -1;
|
||||
@ -307,7 +314,8 @@ QString DatabaseAPI::getSubjectNameByTokenId(const QString &tokenId)
|
||||
{
|
||||
auto query = mDbMan->createQuery();
|
||||
query.prepare("SELECT name FROM colnod_subject WHERE id = (SELECT subject_id FROM colnod_token WHERE id = :tokenId)");
|
||||
query.bindValue(":tokenId", tokenId);
|
||||
QString tempId = "'" + tokenId + "'";
|
||||
query.bindValue(":tokenId", tempId);
|
||||
if (!executeQuery(query)) {
|
||||
qCritical(database) << "ERROR during accessing existing subject. EXIT(1)";
|
||||
return "error";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user