diff --git a/core/core.pro b/core/core.pro index 5b20f54..785860b 100644 --- a/core/core.pro +++ b/core/core.pro @@ -15,7 +15,9 @@ SOURCES += \ data/user.cpp \ context.cpp \ imetadataplugin.cpp \ - transaction.cpp + transaction.cpp \ + data/role.cpp \ + data/permission.cpp HEADERS += core.h\ core_global.h \ @@ -26,13 +28,15 @@ HEADERS += core.h\ imetadataplugin.h \ autotablemodel.h \ autoform.h \ - transaction.h + transaction.h \ + data/role.h \ + data/permission.h unix { target.path = /usr/lib INSTALLS += target } -ODB_FILES = core/data/user.h +ODB_FILES = core/data/user.h core/data/role.h core/data/permission.h H_DIR = $$PWD/data/*.h include(../odb.pri) diff --git a/core/data/permission.cpp b/core/data/permission.cpp new file mode 100644 index 0000000..e00ec7b --- /dev/null +++ b/core/data/permission.cpp @@ -0,0 +1,76 @@ +#include "permission.h" + +Permission::Permission(QObject *parent) : + QObject(parent) +{ +} +int Permission::id() const +{ + return m_id; +} + +void Permission::setId(int id) +{ + m_id = id; +} +QString Permission::pluginId() const +{ + return m_pluginId; +} + +void Permission::setPluginId(const QString &pluginId) +{ + m_pluginId = pluginId; +} +QString Permission::permissionName() const +{ + return m_permissionName; +} + +void Permission::setPermissionName(const QString &permissionName) +{ + m_permissionName = permissionName; +} +QDateTime Permission::lastModDate() const +{ + return m_lastModDate; +} + +void Permission::setLastModDate(const QDateTime &lastModDate) +{ + m_lastModDate = lastModDate; +} +QDateTime Permission::createDate() const +{ + return m_createDate; +} + +void Permission::setCreateDate(const QDateTime &createDate) +{ + m_createDate = createDate; +} +bool Permission::active() const +{ + return m_active; +} + +void Permission::setActive(bool active) +{ + m_active = active; +} +QList > Permission::listRoles() const +{ + return m_listRoles; +} + +void Permission::setListRoles(const QList > &listRoles) +{ + m_listRoles = listRoles; +} + + + + + + + diff --git a/core/data/permission.h b/core/data/permission.h new file mode 100644 index 0000000..47e5f5d --- /dev/null +++ b/core/data/permission.h @@ -0,0 +1,62 @@ +#ifndef PERMISSION_H +#define PERMISSION_H + +#include +#include "role.h" +#include +#include +#include +#include +#include + +class Role; + +#pragma db object +class Permission : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString pluginId READ pluginId WRITE setPluginId) + Q_PROPERTY(QString permissionName READ permissionName WRITE setPermissionName) + Q_PROPERTY(QDateTime lastModDate READ lastModDate WRITE setLastModDate) + Q_PROPERTY(QDateTime createDate READ createDate WRITE setCreateDate) + Q_PROPERTY(bool active READ active WRITE setActive) +public: + explicit Permission(QObject *parent = 0); + + int id() const; + void setId(int id); + + QString pluginId() const; + void setPluginId(const QString &pluginId); + + QString permissionName() const; + void setPermissionName(const QString &permissionName); + + QDateTime lastModDate() const; + void setLastModDate(const QDateTime &lastModDate); + + QDateTime createDate() const; + void setCreateDate(const QDateTime &createDate); + + bool active() const; + void setActive(bool active); + + QList > listRoles() const; + void setListRoles(const QList > &listRoles); + +private: + friend class odb::access; + +#pragma db id auto + int m_id; + QString m_pluginId; + QString m_permissionName; + QDateTime m_lastModDate; + QDateTime m_createDate; + bool m_active; +#pragma db value_not_null inverse(m_listPermissions) + QList > m_listRoles; + +}; + +#endif // PERMISSION_H diff --git a/core/data/role.cpp b/core/data/role.cpp new file mode 100644 index 0000000..44c725e --- /dev/null +++ b/core/data/role.cpp @@ -0,0 +1,76 @@ +#include "role.h" + +Role::Role(QObject *parent) : + QObject(parent) +{ +} +int Role::id() const +{ + return m_id; +} + +void Role::setId(int id) +{ + m_id = id; +} +QString Role::name() const +{ + return m_name; +} + +void Role::setName(const QString &name) +{ + m_name = name; +} +QDateTime Role::lastModDate() const +{ + return m_lastModDate; +} + +void Role::setLastModDate(const QDateTime &lastModDate) +{ + m_lastModDate = lastModDate; +} +QDateTime Role::createDate() const +{ + return m_createDate; +} + +void Role::setCreateDate(const QDateTime &createDate) +{ + m_createDate = createDate; +} +bool Role::active() const +{ + return m_active; +} + +void Role::setActive(bool active) +{ + m_active = active; +} +QList > Role::listUsers() const +{ + return m_listUsers; +} + +void Role::setListUsers(const QList > &listUsers) +{ + m_listUsers = listUsers; +} +QList > Role::listPermissions() const +{ + return m_listPermissions; +} + +void Role::setListPermissions(const QList > &listPermissions) +{ + m_listPermissions = listPermissions; +} + + + + + + + diff --git a/core/data/role.h b/core/data/role.h new file mode 100644 index 0000000..9eeda92 --- /dev/null +++ b/core/data/role.h @@ -0,0 +1,66 @@ +#ifndef ROLE_H +#define ROLE_H + +#include +#include "user.h" +#include "permission.h" +#include +#include +#include +#include +#include + +class Permission; +class User; + +#pragma db object +class Role : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QDateTime lastModDate READ lastModDate WRITE setLastModDate) + Q_PROPERTY(QDateTime createDate READ createDate WRITE setCreateDate) + Q_PROPERTY(bool active READ active WRITE setActive) +public: + explicit Role(QObject *parent = 0); + + int id() const; + void setId(int id); + + QString name() const; + void setName(const QString &name); + + QDateTime lastModDate() const; + void setLastModDate(const QDateTime &lastModDate); + + QDateTime createDate() const; + void setCreateDate(const QDateTime &createDate); + + bool active() const; + void setActive(bool active); + + QList > listUsers() const; + void setListUsers(const QList > &listUsers); + + QList > listPermissions() const; + void setListPermissions(const QList > &listPermissions); + +private: + friend class odb::access; + +#pragma db id auto + int m_id; + QString m_name; + QDateTime m_lastModDate; + QDateTime m_createDate; + bool m_active; +#pragma db value_not_null inverse(m_listRoles) + QList > m_listUsers; +#pragma db value_not_null unordered + QList > m_listPermissions; + + + +}; + +#endif // ROLE_H diff --git a/core/data/user.cpp b/core/data/user.cpp index f48cb77..1b05ebe 100644 --- a/core/data/user.cpp +++ b/core/data/user.cpp @@ -3,36 +3,97 @@ User::User() { } +int User::id() const +{ + return m_id; +} + +void User::setId(int id) +{ + m_id = id; +} +QList > User::listRoles() const +{ + return m_listRoles; +} -int User::getId() const +void User::setListRoles(const QList > &listRoles) { - return id; + m_listRoles = listRoles; } -void User::setId(int value) +QString User::login() const { - id = value; + return m_login; } -QString User::getLogin() const +void User::setLogin(const QString &login) { - return login; + m_login = login; } -void User::setLogin(const QString &value) +QString User::password() const { - login = value; + return m_password; } -QString User::getPassword() const +void User::setPassword(const QString &password) { - return password; + m_password = password; } -void User::setPassword(const QString &value) +QString User::name() const +{ + return m_name; +} +void User::setName(const QString &name) +{ + m_name = name; +} + +QDateTime User::lastModDate() const +{ + return m_lastModDate; +} +void User::setLastModDate(const QDateTime &lastModDate) +{ + m_lastModDate = lastModDate; +} + +QDateTime User::createDate() const +{ + return m_createDate; +} +void User::setCreateDate(const QDateTime &createDate) { - password = value; + m_createDate = createDate; } +bool User::active() const +{ + return m_active; +} +void User::setActive(bool active) +{ + m_active = active; +} + +bool User::isAdmin() const +{ + return m_isAdmin; +} +void User::setIsAdmin(bool isAdmin) +{ + m_isAdmin = isAdmin; +} + + + + + + + + + diff --git a/core/data/user.h b/core/data/user.h index 90502c7..bace0b2 100644 --- a/core/data/user.h +++ b/core/data/user.h @@ -3,32 +3,73 @@ #include #include +#include "role.h" +#include +#include +#include + #include +class Role; + #pragma db object class User : public QObject { Q_OBJECT + Q_PROPERTY(QString login READ login WRITE setLogin) + Q_PROPERTY(QString password READ password WRITE setPassword) + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QDateTime lastModDate READ lastModDate WRITE setLastModDate) + Q_PROPERTY(QDateTime createDate READ createDate WRITE setCreateDate) + Q_PROPERTY(bool active READ active WRITE setActive) + Q_PROPERTY(bool isAdmin READ isAdmin WRITE setIsAdmin) public: User(); - int getId() const; - void setId(int value); - QString getLogin() const; - void setLogin(const QString &value); + int id() const; + void setId(int id); + + QString login() const; + void setLogin(const QString &login); + + QString password() const; + void setPassword(const QString &password); + + QString name() const; + void setName(const QString &name); + + QDateTime lastModDate() const; + void setLastModDate(const QDateTime &lastModDate); + + QDateTime createDate() const; + void setCreateDate(const QDateTime &createDate); + + bool active() const; + void setActive(bool active); + + bool isAdmin() const; + void setIsAdmin(bool isAdmin); + + QList > listRoles() const; + void setListRoles(const QList > &listRoles); - QString getPassword() const; - void setPassword(const QString &value); private: friend class odb::access; #pragma db id auto - int id; - QString login; - QString password; + int m_id; + QString m_login; + QString m_password; + QString m_name; + QDateTime m_lastModDate; + QDateTime m_createDate; + bool m_active; + bool m_isAdmin; +#pragma db value_not_null unordered + QList > m_listRoles; }; #endif // USER_H