forked from ondra/colnod-connector
61 lines
1.8 KiB
C++
61 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include "entity.h"
|
|
#include <QSet>
|
|
#include <qsqlquery.h>
|
|
#include <QVariant>
|
|
#include <QDebug>
|
|
#include <QDateTime>
|
|
|
|
class Token : public Entity {
|
|
public:
|
|
// using Entity::Entity;
|
|
|
|
Token() = default;
|
|
Token(const QString& name, QString tokenData, const QString& decription = "mobile");
|
|
Token(const QString& name);
|
|
|
|
friend bool operator<(const Token &lToken, const Token &rToken){
|
|
return lToken.getLastModified() < rToken.getLastUpdate();
|
|
}
|
|
friend bool operator>(const Token &lToken, const Token &rToken){
|
|
return lToken.getLastModified() > rToken.getLastUpdate();
|
|
}
|
|
|
|
const QString &getTokenType() const;
|
|
void setTokenType(const QString &tokenType);
|
|
int getTokenBits() const;
|
|
void setTokenBits(int tokenBits);
|
|
const QString &getTokenData() const;
|
|
void setTokenData(const QString &tokenData);
|
|
int getTimeToLive() const;
|
|
void setTimeToLive(int timeToLive);
|
|
int getAuthErrors() const;
|
|
void setAuthErrors(int authErrors);
|
|
const QSet<QString> &getFlags() const;
|
|
void setFlags(const QSet<QString> &flags);
|
|
const QUuid &getSubjectId() const;
|
|
void setSubjectId(const QUuid &subjectId);
|
|
quint64 getLastModified() const;
|
|
void setLastModified(const quint64 &lastModified);
|
|
bool getDeleted() const;
|
|
void setDeleted(const bool &deleted);
|
|
|
|
QString subjectIdToStringWithoutBraces();
|
|
|
|
void fromSQLRecord(QSqlQuery* query);
|
|
void fromJSON(const QJsonObject &json) override;
|
|
QJsonObject toJSON() const override;
|
|
|
|
private:
|
|
QString tokenType;
|
|
int tokenBits{};
|
|
QString tokenData;
|
|
int timeToLive{};
|
|
int authErrors{};
|
|
QSet<QString> flags;
|
|
QUuid subjectId;
|
|
quint64 lastModified{};
|
|
bool deleted{};
|
|
};
|