add working login widget
This commit is contained in:
parent
daba16a583
commit
530a9c16a2
2
.gitignore
vendored
2
.gitignore
vendored
@ -37,7 +37,7 @@ Thumbs.db
|
||||
|
||||
# qtcreator generated files
|
||||
*.pro.user*
|
||||
|
||||
*.user
|
||||
# xemacs temporary files
|
||||
*.flc
|
||||
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(eedb)
|
||||
|
||||
add_definitions( -std=c++17 -fconcepts )
|
||||
add_definitions( -std=c++17 )
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/usr/share/cmake/Modules/")
|
||||
|
||||
|
||||
#set(EEDB_WT_INSTALL_PATH /usr/local/wt_gcc6/)
|
||||
|
||||
find_package(Wt REQUIRED)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.2.0, 2017-01-26T11:09:09. -->
|
||||
<!-- Written by QtCreator 4.2.0, 2017-02-02T14:25:47. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
@ -248,7 +248,7 @@
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||
<value type="QString"></value>
|
||||
<value type="QString">all</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
@ -334,7 +334,8 @@
|
||||
<value type="int">14</value>
|
||||
</valuelist>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguation.Title">eedb</value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.Arguments"></value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.Arguments">--docroot=/home/bwieczor/src/wt/ --http-port 8080 --http-addr 0.0.0.0</value>
|
||||
<value type="bool" key="CMakeProjectManager.CMakeRunConfiguration.UseTerminal">false</value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"></value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory.default">/home/bwieczor/src/__BUILDS__/eedb-GCC6-Debug/src/app</value>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
|
||||
@ -141,23 +141,23 @@ create table "user" (
|
||||
"address" text check( length(address) <= 1000 ),
|
||||
"config" json DEFAULT ('{}'),
|
||||
"avatar" text,
|
||||
"email" varchar(256) not null,
|
||||
"status" integer not null,
|
||||
constraint "pk_user_uid" primary key ("uid"),
|
||||
constraint "ux_user_name" unique ("name")
|
||||
constraint "ux_user_name" unique ("name"),
|
||||
constraint "ux_user_email" unique ("email")
|
||||
) INHERITS (stat);
|
||||
create trigger update_user_last_update before update on "user" FOR EACH ROW EXECUTE PROCEDURE last_update_column();
|
||||
|
||||
|
||||
create table "auth_info" (
|
||||
"id" serial not null,
|
||||
"version" integer not null,
|
||||
"user_uid" bigint,
|
||||
"password_hash" varchar(100) not null,
|
||||
"password_method" varchar(20) not null,
|
||||
"password_salt" varchar(20) not null,
|
||||
"status" integer not null,
|
||||
"failed_login_attempts" integer not null,
|
||||
"last_login_attempt" timestamp,
|
||||
"email" varchar(256) not null,
|
||||
"unverified_email" varchar(256) not null,
|
||||
"email_token" varchar(64) not null,
|
||||
"email_token_expires" timestamp,
|
||||
@ -168,7 +168,6 @@ create table "auth_info" (
|
||||
|
||||
create table "auth_identity" (
|
||||
"id" serial not null,
|
||||
"version" integer not null,
|
||||
"auth_info_id" bigint,
|
||||
"provider" varchar(64) not null,
|
||||
"identity" varchar(512) not null,
|
||||
|
||||
@ -1,4 +1,15 @@
|
||||
set(SOURCES main.cpp)
|
||||
set(SOURCES
|
||||
Session.cpp
|
||||
main.cpp)
|
||||
|
||||
find_package( Boost 1.54.0 REQUIRED system )
|
||||
|
||||
INCLUDE_DIRECTORIES(${PostgreSQL_INCLUDE_DIRS})
|
||||
add_executable(eedb ${SOURCES} )
|
||||
target_link_libraries(eedb
|
||||
${Wt_LIBRARY} # or {Wt_DEBUG_LIBRARY}
|
||||
${Wt_HTTP_LIBRARY} # or {Wt_HTTP_DEBUG_LIBRARY}
|
||||
${Boost_LIBRARIES}
|
||||
eedb_db auth
|
||||
)
|
||||
|
||||
|
||||
110
src/app/main.cpp
110
src/app/main.cpp
@ -1,9 +1,107 @@
|
||||
#include <locale>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <eedb/auth/PgUserAuth.hpp>
|
||||
#include <eedb/auth/Services.hpp>
|
||||
#include <eedb/db/connection.hpp>
|
||||
|
||||
using namespace std::literals;
|
||||
#include <memory>
|
||||
|
||||
int main()
|
||||
{
|
||||
#include <Wt/WApplication>
|
||||
#include <Wt/WBootstrapTheme>
|
||||
#include <Wt/WBreak>
|
||||
#include <Wt/WContainerWidget>
|
||||
#include <Wt/WHBoxLayout>
|
||||
#include <Wt/WLineEdit>
|
||||
#include <Wt/WPushButton>
|
||||
#include <Wt/WServer>
|
||||
#include <Wt/WText>
|
||||
|
||||
#include <Wt/Auth/PasswordService>
|
||||
#include <Wt/Auth/PasswordStrengthValidator>
|
||||
#include <Wt/Auth/PasswordVerifier>
|
||||
|
||||
#include <Wt/Auth/AuthWidget>
|
||||
#include <Wt/Auth/Dbo/AuthInfo>
|
||||
#include <Wt/Auth/Dbo/UserDatabase>
|
||||
#include <Wt/Auth/FacebookService>
|
||||
#include <Wt/Auth/GoogleService>
|
||||
#include <Wt/Auth/HashFunction>
|
||||
#include <Wt/Auth/Login>
|
||||
|
||||
class AuthApplication : public Wt::WApplication {
|
||||
public:
|
||||
Wt::WLineEdit * nameEdit_;
|
||||
Wt::WText * greeting_;
|
||||
|
||||
AuthApplication(const Wt::WEnvironment & env) : Wt::WApplication(env) {
|
||||
login_.changed().connect(this, &AuthApplication::authEvent);
|
||||
|
||||
auto config = std::make_shared< sqlpp::postgresql::connection_config >();
|
||||
config->host = "10.154.34.245";
|
||||
config->port = 5432;
|
||||
config->user = "postgres";
|
||||
config->password = "postgres";
|
||||
config->dbname = "eedb";
|
||||
config->debug = true;
|
||||
|
||||
conn_ = std::make_unique< eedb::db::PgConnection >(config);
|
||||
userDatabase_ = std::make_unique< eedb::auth::PgUserAuth >(*conn_);
|
||||
userDatabase_->setAuthService(eedb::auth::Services::authService());
|
||||
|
||||
root()->addStyleClass("container");
|
||||
setTheme(new Wt::WBootstrapTheme(this));
|
||||
|
||||
useStyleSheet("css/style.css");
|
||||
|
||||
Wt::Auth::AuthWidget * authWidget = new Wt::Auth::AuthWidget(
|
||||
*eedb::auth::Services::authService(), *userDatabase_, login_);
|
||||
|
||||
authWidget->model()->addPasswordAuth(eedb::auth::Services::passwordService());
|
||||
authWidget->model()->addOAuth(eedb::auth::Services::oAuthServices());
|
||||
authWidget->setRegistrationEnabled(true);
|
||||
|
||||
authWidget->processEnvironment();
|
||||
|
||||
root()->addWidget(authWidget);
|
||||
}
|
||||
|
||||
void authEvent() {
|
||||
if(login_.loggedIn()) {
|
||||
const Wt::Auth::User & u = login_.user();
|
||||
Wt::log("notice") << "User " << u.id() << " (" << u.identity(Wt::Auth::Identity::LoginName) << ")"
|
||||
<< " logged in.";
|
||||
|
||||
root()->addWidget(new Wt::WText("A first widget"));
|
||||
for(unsigned int i = 0; i < 3; ++i) {
|
||||
// A widget can be added to a container by passing the container as
|
||||
// the last constructor argument.
|
||||
new Wt::WText(Wt::WString::fromUTF8("<p>Text {1}</p>").arg(i), root());
|
||||
}
|
||||
|
||||
} else
|
||||
Wt::log("notice") << "User logged out.";
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr< eedb::db::PgConnection > conn_;
|
||||
std::unique_ptr< eedb::auth::PgUserAuth > userDatabase_;
|
||||
Wt::Auth::Login login_;
|
||||
};
|
||||
|
||||
Wt::WApplication * createApplication(const Wt::WEnvironment & env) {
|
||||
return new AuthApplication(env);
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
try {
|
||||
Wt::WServer server(argc, argv, WTHTTP_CONFIGURATION);
|
||||
|
||||
server.addEntryPoint(Wt::Application, createApplication);
|
||||
|
||||
eedb::auth::Services::configureAuth();
|
||||
|
||||
server.run();
|
||||
} catch(Wt::WServer::Exception & e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
} catch(std::exception & e) {
|
||||
std::cerr << "exception: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
file(GLOB SOURCE
|
||||
auth/PgUserAuth.cpp
|
||||
auth/Services.cpp
|
||||
model/*)
|
||||
|
||||
add_subdirectory(db)
|
||||
|
||||
@ -1,72 +1,361 @@
|
||||
#include "PgUserAuth.hpp"
|
||||
|
||||
#include <eedb/db/connection.hpp>
|
||||
|
||||
#include <sqlpp11/sqlpp11.h>
|
||||
|
||||
#include <eedb/model/auth_identity.h>
|
||||
#include <eedb/model/auth_info.h>
|
||||
#include <eedb/model/auth_token.h>
|
||||
#include <eedb/model/user.h>
|
||||
#include <eedb/model/user_history.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <Wt/Auth/AuthService>
|
||||
#include <Wt/Auth/Dbo/AuthInfo>
|
||||
#include <Wt/WLogger>
|
||||
|
||||
using namespace sqlpp;
|
||||
using namespace Wt::Auth;
|
||||
|
||||
namespace eedb::auth {
|
||||
|
||||
PgUserAuth::PgUserAuth(sqlpp::postgresql::connection & _db): db(_db)
|
||||
{
|
||||
namespace {
|
||||
SQLPP_ALIAS_PROVIDER(fk_auth_info_id);
|
||||
SQLPP_ALIAS_PROVIDER(user_status);
|
||||
|
||||
constexpr eedb::user t_user;
|
||||
constexpr eedb::auth_identity auth_identity;
|
||||
constexpr eedb::auth_info auth_info;
|
||||
|
||||
auto auth =
|
||||
t_user.join(auth_info).on(t_user.uid == auth_info.user_uid).join(auth_identity).on(auth_info.id == auth_identity.auth_info_id);
|
||||
|
||||
auto auth_info_identity = auth_info.join(auth_identity).on(auth_info.id == auth_identity.auth_info_id);
|
||||
auto user_auth_info = t_user.join(auth_info).on(auth_info.user_uid == t_user.uid);
|
||||
}
|
||||
|
||||
Wt::Auth::AbstractUserDatabase::Transaction * PgUserAuth::startTransaction() {
|
||||
return nullptr;
|
||||
PgUserAuth::PgUserAuth(eedb::db::PgConnection & _db) : db(_db) {}
|
||||
|
||||
User PgUserAuth::findWithId(const std::string & id) const {
|
||||
const auto uid_eq = t_user.uid == std::atoi(id.c_str());
|
||||
|
||||
if(db(select(exists(select(t_user.uid) //
|
||||
.from(t_user) //
|
||||
.where(uid_eq))))
|
||||
.front()
|
||||
.exists) {
|
||||
return User(id, *this);
|
||||
}
|
||||
return User();
|
||||
}
|
||||
|
||||
Wt::Auth::User PgUserAuth::findWithId( const std::string & id ) const {}
|
||||
|
||||
Wt::Auth::User PgUserAuth::findWithIdentity( const std::string & provider, const Wt::WString & identity ) const {}
|
||||
|
||||
void PgUserAuth::addIdentity( const Wt::Auth::User & user, const std::string & provider, const Wt::WString & id ) {}
|
||||
|
||||
void PgUserAuth::setIdentity( const Wt::Auth::User & user, const std::string & provider, const Wt::WString & id ) {}
|
||||
|
||||
Wt::WString PgUserAuth::identity( const Wt::Auth::User & user, const std::string & provider ) const {}
|
||||
|
||||
void PgUserAuth::removeIdentity( const Wt::Auth::User & user, const std::string & provider ) {}
|
||||
|
||||
Wt::Auth::User PgUserAuth::registerNew() {}
|
||||
|
||||
void PgUserAuth::deleteUser( const Wt::Auth::User & user ) {}
|
||||
|
||||
Wt::Auth::User::Status PgUserAuth::status( const Wt::Auth::User & user ) const {}
|
||||
|
||||
void PgUserAuth::setStatus( const Wt::Auth::User & user, Wt::Auth::User::Status status ) {}
|
||||
|
||||
void PgUserAuth::setPassword( const Wt::Auth::User & user, const Wt::Auth::PasswordHash & password ) {}
|
||||
|
||||
Wt::Auth::PasswordHash PgUserAuth::password( const Wt::Auth::User & user ) const {}
|
||||
|
||||
bool PgUserAuth::setEmail( const Wt::Auth::User & user, const std::string & address ) {}
|
||||
|
||||
std::string PgUserAuth::email( const Wt::Auth::User & user ) const {}
|
||||
|
||||
void PgUserAuth::setUnverifiedEmail( const Wt::Auth::User & user, const std::string & address ) {}
|
||||
|
||||
std::string PgUserAuth::unverifiedEmail( const Wt::Auth::User & user ) const {}
|
||||
|
||||
Wt::Auth::User PgUserAuth::findWithEmail( const std::string & address ) const {}
|
||||
|
||||
void PgUserAuth::setEmailToken( const Wt::Auth::User & user, const Wt::Auth::Token & token, Wt::Auth::User::EmailTokenRole role ) {}
|
||||
|
||||
Wt::Auth::Token PgUserAuth::emailToken( const Wt::Auth::User & user ) const {}
|
||||
|
||||
Wt::Auth::User::EmailTokenRole PgUserAuth::emailTokenRole( const Wt::Auth::User & user ) const {}
|
||||
|
||||
Wt::Auth::User PgUserAuth::findWithEmailToken( const std::string & hash ) const {}
|
||||
|
||||
void PgUserAuth::addAuthToken( const Wt::Auth::User & user, const Wt::Auth::Token & token ) {}
|
||||
|
||||
void PgUserAuth::removeAuthToken( const Wt::Auth::User & user, const std::string & hash ) {}
|
||||
|
||||
Wt::Auth::User PgUserAuth::findWithAuthToken( const std::string & hash ) const {}
|
||||
|
||||
int PgUserAuth::updateAuthToken( const Wt::Auth::User & user, const std::string & oldhash, const std::string & newhash ) {}
|
||||
|
||||
void PgUserAuth::setFailedLoginAttempts( const Wt::Auth::User & user, int count ) {}
|
||||
|
||||
int PgUserAuth::failedLoginAttempts( const Wt::Auth::User & user ) const {}
|
||||
|
||||
void PgUserAuth::setLastLoginAttempt( const Wt::Auth::User & user, const Wt::WDateTime & t ) {}
|
||||
|
||||
Wt::WDateTime PgUserAuth::lastLoginAttempt( const Wt::Auth::User & user ) const {}
|
||||
User PgUserAuth::findWithIdentity(const std::string & provider, const Wt::WString & identity) const {
|
||||
// if(_userProvider != provider || _userIdentity != identity) {
|
||||
auto _identity = identity.toUTF8();
|
||||
if(_authService && _authService->identityPolicy() == EmailAddressIdentity) {
|
||||
std::transform(_identity.begin(), _identity.end(), _identity.begin(), ::tolower);
|
||||
}
|
||||
|
||||
auto identity_eq = auth_identity.identity == _identity;
|
||||
auto provider_eq = auth_identity.provider == provider;
|
||||
|
||||
auto result = db(select(auth_info.user_uid) //
|
||||
.from(auth_info_identity) //
|
||||
.where(provider_eq and identity_eq));
|
||||
|
||||
if(!result.empty()) {
|
||||
_userProvider = provider;
|
||||
_userIdentity = identity.toUTF8();
|
||||
return User(std::to_string(result.front().user_uid), *this);
|
||||
}
|
||||
// }
|
||||
return User();
|
||||
}
|
||||
|
||||
void PgUserAuth::addIdentity(const User & user, const std::string & provider, const Wt::WString & identity) {
|
||||
const auto uid_eq = auth_info.user_uid == std::atoi(user.id().c_str());
|
||||
const auto identity_eq = auth_identity.identity == identity.toUTF8();
|
||||
const auto provider_eq = auth_identity.provider == provider;
|
||||
|
||||
auto res = db(select(auth_info.user_uid, auth_info.id) //
|
||||
.from(auth_info_identity)
|
||||
.where(identity_eq and provider_eq and uid_eq));
|
||||
|
||||
if(!res.empty()) {
|
||||
Wt::log("error") << "cannot add identity " << provider << ":'" << identity << "': already exists";
|
||||
return;
|
||||
}
|
||||
|
||||
auto auth_info_id = db(select(auth_info.id)
|
||||
.from(auth_info) //
|
||||
.where(uid_eq));
|
||||
|
||||
if(auth_info_id.empty()) {
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
db(insert_into(auth_identity)
|
||||
.set(auth_identity.identity = identity.toUTF8(), //
|
||||
auth_identity.provider = provider, //
|
||||
auth_identity.auth_info_id = auth_info_id.front().id));
|
||||
|
||||
Wt::log("info") << "created new identity for user";
|
||||
}
|
||||
|
||||
void PgUserAuth::setIdentity(const User & user, const std::string & provider, const Wt::WString & identity) {
|
||||
const auto uid = std::atoi(user.id().c_str());
|
||||
const auto provider_eq = auth_identity.provider == provider;
|
||||
|
||||
db.native()->start_transaction();
|
||||
auto ret = db(select(auth_info.id) //
|
||||
.from(auth_info) //
|
||||
.where(auth_info.user_uid == uid));
|
||||
|
||||
if(ret.empty()) {
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
auto auth_info_id = ret.front().id;
|
||||
|
||||
db(update(auth_identity) //
|
||||
.set(auth_identity.identity = identity.toUTF8()) //
|
||||
.where(auth_identity.auth_info_id == auth_info_id and provider_eq));
|
||||
|
||||
db.native()->commit_transaction();
|
||||
}
|
||||
|
||||
Wt::WString PgUserAuth::identity(const User & user, const std::string & provider) const {
|
||||
const auto uid = std::atoi(user.id().c_str());
|
||||
const auto id_eq = auth_info.user_uid == uid;
|
||||
const auto provider_eq = auth_identity.provider == provider;
|
||||
|
||||
auto res = db(select(auth_identity.identity) //
|
||||
.from(auth_info_identity) //
|
||||
.where(id_eq and provider_eq));
|
||||
|
||||
if(res.empty())
|
||||
return Wt::WString::Empty;
|
||||
return {res.front().identity};
|
||||
}
|
||||
|
||||
void PgUserAuth::removeIdentity(const User & user, const std::string & provider) {
|
||||
const auto id_eq = auth_identity.id == std::atoi(user.id().c_str());
|
||||
const auto provider_eq = auth_identity.provider == provider;
|
||||
|
||||
db(remove_from(auth_identity) //
|
||||
.where(id_eq and provider_eq));
|
||||
}
|
||||
|
||||
User PgUserAuth::registerNew() {
|
||||
db.native()->start_transaction();
|
||||
|
||||
auto user_id = db(sqlpp::postgresql::insert_into(t_user) //
|
||||
.set(t_user.email = "", //
|
||||
t_user.name = "", //
|
||||
t_user.status = -1)
|
||||
.returning(t_user.uid))
|
||||
.front()
|
||||
.uid;
|
||||
|
||||
auto info_id = db(sqlpp::postgresql::insert_into(auth_info)
|
||||
.set(auth_info.password_hash = "", //
|
||||
auth_info.password_method = "", //
|
||||
auth_info.password_salt = "", //
|
||||
auth_info.failed_login_attempts = 0, //
|
||||
auth_info.user_uid = user_id, //
|
||||
auth_info.unverified_email = "", //
|
||||
auth_info.email_token = "", //
|
||||
auth_info.email_token_role = 0) //
|
||||
.returning(auth_info.id))
|
||||
.front()
|
||||
.id;
|
||||
|
||||
db(insert_into(auth_identity) //
|
||||
.set(auth_identity.identity = "", //
|
||||
auth_identity.provider = "", //
|
||||
auth_identity.auth_info_id = info_id));
|
||||
|
||||
db.native()->commit_transaction();
|
||||
return User{std::to_string(user_id), *this};
|
||||
}
|
||||
|
||||
void PgUserAuth::deleteUser(const User & user) {
|
||||
db(remove_from(auth_info) //
|
||||
.where(auth_info.id == std::atoi(user.id().c_str())));
|
||||
}
|
||||
|
||||
// User::Status PgUserAuth::status(const User & user) const {
|
||||
// const auto id_eq = auth_identity.id == std::atoi(user.id().c_str());
|
||||
|
||||
// auto status = db(select(auth_info.status.as(user_status)) //
|
||||
// .from(join) //
|
||||
// .where(id_eq))
|
||||
// .front()
|
||||
// .user_status;
|
||||
// return status.value() == User::Status::Normal ? User::Status::Normal : User::Status::Disabled;
|
||||
//}
|
||||
|
||||
// void PgUserAuth::setStatus(const User & user, User::Status status) {
|
||||
// db(update(auth_info) //
|
||||
// .set(auth_info.status = static_cast< int >(status)) //
|
||||
// .where(auth_info.id == std::atoi(user.id().c_str())));
|
||||
//}
|
||||
|
||||
void PgUserAuth::setPassword(const User & user, const PasswordHash & password) {
|
||||
db(update(auth_info)
|
||||
.set(auth_info.password_hash = password.value(), //
|
||||
auth_info.password_method = password.function(), //
|
||||
auth_info.password_salt = password.salt())
|
||||
.where(auth_info.user_uid == std::atoi(user.id().c_str())));
|
||||
}
|
||||
|
||||
PasswordHash PgUserAuth::password(const User & user) const {
|
||||
const auto id_eq = auth_info.user_uid == std::atoi(user.id().c_str());
|
||||
|
||||
auto row = db(select(auth_info.password_hash, auth_info.password_method, auth_info.password_salt)
|
||||
.from(auth_info) //
|
||||
.where(id_eq));
|
||||
if(row.empty())
|
||||
return PasswordHash();
|
||||
auto & front = row.front();
|
||||
return {std::move(front.password_method), std::move(front.password_salt), std::move(front.password_hash)};
|
||||
}
|
||||
|
||||
bool PgUserAuth::setEmail(const User & user, const std::string & address) {
|
||||
const auto uid_eq = t_user.uid == std::atoi(user.id().c_str());
|
||||
|
||||
db(update(t_user) //
|
||||
.set(t_user.email = address) //
|
||||
.where(uid_eq));
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string PgUserAuth::email(const User & user) const {
|
||||
auto ret = db(select(t_user.email) //
|
||||
.from(t_user) //
|
||||
.where(t_user.uid == std::atoi(user.id().c_str())));
|
||||
if(ret.empty())
|
||||
return {};
|
||||
return std::move(ret.front().email);
|
||||
}
|
||||
|
||||
void PgUserAuth::setUnverifiedEmail(const User & user, const std::string & address) {
|
||||
db(update(auth_info) //
|
||||
.set(auth_info.unverified_email = address) //
|
||||
.where(auth_info.user_uid == std::atoi(user.id().c_str())));
|
||||
}
|
||||
|
||||
std::string PgUserAuth::unverifiedEmail(const User & user) const {
|
||||
auto ret = db(select(auth_info.unverified_email) //
|
||||
.from(auth_info) //
|
||||
.where(auth_info.user_uid == std::atoi(user.id().c_str())));
|
||||
if(ret.empty())
|
||||
return {};
|
||||
return std::move(ret.front().unverified_email);
|
||||
}
|
||||
|
||||
User PgUserAuth::findWithEmail(const std::string & address) const {
|
||||
auto ret = db(select(t_user.uid) //
|
||||
.from(t_user) //
|
||||
.where(t_user.email == address));
|
||||
|
||||
if(ret.empty())
|
||||
return {};
|
||||
return {std::to_string(ret.front().uid), *this};
|
||||
}
|
||||
|
||||
void PgUserAuth::setEmailToken(const User & user, const Token & token, User::EmailTokenRole role) {
|
||||
auto exp = ::date::floor<::std::chrono::milliseconds >(std::chrono::system_clock::from_time_t(token.expirationTime().toTime_t()));
|
||||
db(update(auth_info) //
|
||||
.set(auth_info.email_token = token.hash(), //
|
||||
auth_info.email_token_expires = exp,
|
||||
auth_info.email_token_role = static_cast< int >(role)) //
|
||||
.where(auth_info.user_uid == std::atoi(user.id().c_str())));
|
||||
}
|
||||
|
||||
Token PgUserAuth::emailToken(const User & user) const {
|
||||
auto ret = db(select(auth_info.email_token, auth_info.email_token_expires) //
|
||||
.from(auth_info) //
|
||||
.where(auth_info.user_uid == std::atoi(user.id().c_str())));
|
||||
if(ret.empty())
|
||||
return {};
|
||||
auto exp = Wt::WDateTime();
|
||||
auto time = ret.front().email_token_expires.value();
|
||||
auto systime = std::chrono::system_clock::to_time_t(time);
|
||||
exp.setTime_t(systime);
|
||||
return {ret.front().email_token, exp};
|
||||
}
|
||||
|
||||
User::EmailTokenRole PgUserAuth::emailTokenRole(const User & user) const {
|
||||
auto ret = db(select(auth_info.email_token_role) //
|
||||
.from(auth_info) //
|
||||
.where(auth_info.user_uid == std::atoi(user.id().c_str())));
|
||||
if(ret.empty())
|
||||
throw std::exception();
|
||||
auto val = ret.front().email_token_role;
|
||||
return static_cast< User::EmailTokenRole >(val.value());
|
||||
}
|
||||
|
||||
User PgUserAuth::findWithEmailToken(const std::string & hash) const {
|
||||
auto ret = db(select(t_user.uid) //
|
||||
.from(user_auth_info) //
|
||||
.where(auth_info.email_token == hash));
|
||||
|
||||
if(ret.empty())
|
||||
return {};
|
||||
return {std::to_string(ret.front().uid), *this};
|
||||
}
|
||||
|
||||
// void PgUserAuth::addAuthToken(const User & user, const Token & token) {}
|
||||
|
||||
// void PgUserAuth::removeAuthToken(const User & user, const std::string & hash) {}
|
||||
|
||||
// User PgUserAuth::findWithAuthToken(const std::string & hash) const {
|
||||
// auto ret = db(select(auth_info.id).from(auth_info).where(auth_info == hash));
|
||||
|
||||
// if(ret.empty())
|
||||
// return {};
|
||||
// return {std::to_string(ret.front().id), *this};
|
||||
//}
|
||||
|
||||
// int PgUserAuth::updateAuthToken(const User & user, const std::string & oldhash, const std::string & newhash) {}
|
||||
|
||||
void PgUserAuth::setFailedLoginAttempts(const User & user, int count) {
|
||||
db(update(auth_info) //
|
||||
.set(auth_info.failed_login_attempts = count) //
|
||||
.where(auth_info.user_uid == std::atoi(user.id().c_str())));
|
||||
}
|
||||
|
||||
int PgUserAuth::failedLoginAttempts(const User & user) const {
|
||||
auto res = db(select(auth_info.failed_login_attempts) //
|
||||
.from(auth_info) //
|
||||
.where(auth_info.user_uid == std::atoi(user.id().c_str())));
|
||||
if(res.empty())
|
||||
return 0;
|
||||
return static_cast< int >(res.front().failed_login_attempts);
|
||||
}
|
||||
|
||||
void PgUserAuth::setLastLoginAttempt(const User & user, const Wt::WDateTime & t) {
|
||||
auto exp = ::date::floor<::std::chrono::milliseconds >(std::chrono::system_clock::from_time_t(t.toTime_t()));
|
||||
db(update(auth_info) //
|
||||
.set(auth_info.last_login_attempt = exp) //
|
||||
.where(auth_info.user_uid == std::atoi(user.id().c_str())));
|
||||
}
|
||||
|
||||
Wt::WDateTime PgUserAuth::lastLoginAttempt(const User & user) const {
|
||||
auto res = db(select(auth_info.last_login_attempt) //
|
||||
.from(auth_info) //
|
||||
.where(auth_info.user_uid == std::atoi(user.id().c_str())));
|
||||
if(res.empty())
|
||||
return {};
|
||||
|
||||
auto lastLogin = Wt::WDateTime();
|
||||
auto time = res.front().last_login_attempt.value();
|
||||
auto systime = std::chrono::system_clock::to_time_t(time);
|
||||
lastLogin.setTime_t(systime);
|
||||
|
||||
return lastLogin;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,30 +2,38 @@
|
||||
|
||||
#include <Wt/Auth/AbstractUserDatabase>
|
||||
|
||||
#include <sqlpp11/postgresql/connection.h>
|
||||
namespace eedb::db {
|
||||
class PgConnection;
|
||||
}
|
||||
|
||||
namespace Wt {
|
||||
class Wt::Auth::AuthService;
|
||||
}
|
||||
|
||||
namespace eedb::auth {
|
||||
|
||||
class PgUserAuth : public Wt::Auth::AbstractUserDatabase {
|
||||
public:
|
||||
PgUserAuth(sqlpp::postgresql::connection & db);
|
||||
void setAuthService(Wt::Auth::AuthService * s) {
|
||||
_authService = s;
|
||||
}
|
||||
|
||||
Transaction * startTransaction() override;
|
||||
|
||||
Wt::Auth::User registerNew() override;
|
||||
void deleteUser(const Wt::Auth::User & user) override;
|
||||
PgUserAuth(eedb::db::PgConnection & db);
|
||||
|
||||
Wt::Auth::User findWithId(const std::string & id) const override;
|
||||
Wt::Auth::User findWithIdentity(const std::string & provider, const Wt::WString & identity) const override;
|
||||
|
||||
Wt::Auth::User::Status status(const Wt::Auth::User & user) const override;
|
||||
void setStatus(const Wt::Auth::User & user, Wt::Auth::User::Status status) override;
|
||||
|
||||
void addIdentity(const Wt::Auth::User & user, const std::string & provider, const Wt::WString & id) override;
|
||||
void setIdentity(const Wt::Auth::User & user, const std::string & provider, const Wt::WString & id) override;
|
||||
Wt::WString identity(const Wt::Auth::User & user, const std::string & provider) const override;
|
||||
void removeIdentity(const Wt::Auth::User & user, const std::string & provider) override;
|
||||
|
||||
Wt::Auth::User registerNew() override;
|
||||
void deleteUser(const Wt::Auth::User & user) override;
|
||||
|
||||
// Wt::Auth::User::Status status(const Wt::Auth::User & user) const override;
|
||||
// void setStatus(const Wt::Auth::User & user, Wt::Auth::User::Status status) override;
|
||||
|
||||
void setPassword(const Wt::Auth::User & user, const Wt::Auth::PasswordHash & password) override;
|
||||
Wt::Auth::PasswordHash password(const Wt::Auth::User & user) const override;
|
||||
|
||||
@ -39,18 +47,24 @@ class PgUserAuth : public Wt::Auth::AbstractUserDatabase {
|
||||
Wt::Auth::User::EmailTokenRole emailTokenRole(const Wt::Auth::User & user) const override;
|
||||
Wt::Auth::User findWithEmailToken(const std::string & hash) const override;
|
||||
|
||||
void addAuthToken(const Wt::Auth::User & user, const Wt::Auth::Token & token) override;
|
||||
void removeAuthToken(const Wt::Auth::User & user, const std::string & hash) override;
|
||||
Wt::Auth::User findWithAuthToken(const std::string & hash) const override;
|
||||
int updateAuthToken(const Wt::Auth::User & user, const std::string & oldhash, const std::string & newhash) override;
|
||||
// void addAuthToken(const Wt::Auth::User & user, const Wt::Auth::Token & token) override;
|
||||
// void removeAuthToken(const Wt::Auth::User & user, const std::string & hash) override;
|
||||
// Wt::Auth::User findWithAuthToken(const std::string & hash) const override;
|
||||
// int updateAuthToken(const Wt::Auth::User & user, const std::string & oldhash, const std::string & newhash) override;
|
||||
|
||||
void setFailedLoginAttempts(const Wt::Auth::User & user, int count) override;
|
||||
int failedLoginAttempts(const Wt::Auth::User & user) const override;
|
||||
|
||||
void setLastLoginAttempt(const Wt::Auth::User & user, const Wt::WDateTime & t) override;
|
||||
Wt::WDateTime lastLoginAttempt(const Wt::Auth::User & user) const override;
|
||||
|
||||
private:
|
||||
sqlpp::postgresql::connection & db;
|
||||
eedb::db::PgConnection & db;
|
||||
const Wt::Auth::AuthService * _authService;
|
||||
|
||||
mutable std::string _userProvider;
|
||||
mutable std::string _userIdentity;
|
||||
|
||||
// AbstractUserDatabase interface
|
||||
public:
|
||||
};
|
||||
}
|
||||
|
||||
63
src/eedb/auth/Services.cpp
Normal file
63
src/eedb/auth/Services.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
#include <eedb/auth/Services.hpp>
|
||||
|
||||
#include <Wt/Auth/PasswordService>
|
||||
#include <Wt/Auth/PasswordStrengthValidator>
|
||||
#include <Wt/Auth/PasswordVerifier>
|
||||
|
||||
#include <Wt/Auth/AuthService>
|
||||
#include <Wt/Auth/AuthWidget>
|
||||
#include <Wt/Auth/Dbo/AuthInfo>
|
||||
#include <Wt/Auth/Dbo/UserDatabase>
|
||||
#include <Wt/Auth/FacebookService>
|
||||
#include <Wt/Auth/GoogleService>
|
||||
#include <Wt/Auth/HashFunction>
|
||||
#include <Wt/Auth/Login>
|
||||
|
||||
namespace {
|
||||
|
||||
class MyOAuth : public std::vector< const Wt::Auth::OAuthService * > {
|
||||
public:
|
||||
~MyOAuth() {
|
||||
for(unsigned i = 0; i < size(); ++i)
|
||||
delete(*this)[i];
|
||||
}
|
||||
};
|
||||
|
||||
Wt::Auth::AuthService myAuthService;
|
||||
Wt::Auth::PasswordService myPasswordService(myAuthService);
|
||||
MyOAuth myOAuthServices;
|
||||
}
|
||||
namespace eedb::auth {
|
||||
Wt::Auth::AuthService * Services::authService() {
|
||||
return &myAuthService;
|
||||
}
|
||||
|
||||
Wt::Auth::AbstractPasswordService * Services::passwordService() {
|
||||
return &myPasswordService;
|
||||
}
|
||||
|
||||
std::vector< const Wt::Auth::OAuthService * > Services::oAuthServices() {
|
||||
return myOAuthServices;
|
||||
}
|
||||
|
||||
void Services::configureAuth() {
|
||||
myAuthService.setAuthTokensEnabled(true, "logincookie");
|
||||
myAuthService.setEmailVerificationEnabled(true);
|
||||
myAuthService.setEmailVerificationRequired(true);
|
||||
|
||||
Wt::Auth::PasswordVerifier * verifier = new Wt::Auth::PasswordVerifier();
|
||||
verifier->addHashFunction(new Wt::Auth::BCryptHashFunction(7));
|
||||
myPasswordService.setVerifier(verifier);
|
||||
myPasswordService.setAttemptThrottlingEnabled(true);
|
||||
myPasswordService.setStrengthValidator(new Wt::Auth::PasswordStrengthValidator());
|
||||
|
||||
if(Wt::Auth::GoogleService::configured())
|
||||
myOAuthServices.push_back(new Wt::Auth::GoogleService(myAuthService));
|
||||
|
||||
if(Wt::Auth::FacebookService::configured())
|
||||
myOAuthServices.push_back(new Wt::Auth::FacebookService(myAuthService));
|
||||
|
||||
for(unsigned i = 0; i < myOAuthServices.size(); ++i)
|
||||
myOAuthServices[i]->generateRedirectEndpoint();
|
||||
}
|
||||
};
|
||||
22
src/eedb/auth/Services.hpp
Normal file
22
src/eedb/auth/Services.hpp
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
|
||||
namespace Wt::Auth {
|
||||
class AuthService;
|
||||
class AbstractPasswordService;
|
||||
class OAuthService;
|
||||
}
|
||||
|
||||
namespace eedb::auth {
|
||||
|
||||
class Services {
|
||||
public:
|
||||
static void configureAuth();
|
||||
|
||||
static Wt::Auth::AuthService * authService();
|
||||
|
||||
static Wt::Auth::AbstractPasswordService * passwordService();
|
||||
|
||||
static std::vector< const Wt::Auth::OAuthService * > oAuthServices();
|
||||
};
|
||||
}
|
||||
@ -1,6 +1,11 @@
|
||||
set(SOURCE
|
||||
session.cpp
|
||||
dbo_object.cpp )
|
||||
connection.cpp
|
||||
)
|
||||
|
||||
find_package(Sqlpp11 REQUIRED)
|
||||
find_package(PostgreSQL REQUIRED)
|
||||
|
||||
INCLUDE_DIRECTORIES( ${PostgreSQL_INCLUDE_DIRS} )
|
||||
|
||||
add_library(eedb_db ${SOURCE})
|
||||
target_link_libraries( eedb_db sqlpp-postgresql )
|
||||
|
||||
8
src/eedb/db/connection.cpp
Normal file
8
src/eedb/db/connection.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include <eedb/db/connection.hpp>
|
||||
|
||||
|
||||
namespace eedb::db {
|
||||
|
||||
|
||||
|
||||
}
|
||||
26
src/eedb/db/connection.hpp
Normal file
26
src/eedb/db/connection.hpp
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <sqlpp11/postgresql/postgresql.h>
|
||||
|
||||
namespace eedb::db {
|
||||
|
||||
class PgConnection {
|
||||
public:
|
||||
PgConnection(std::shared_ptr< sqlpp::postgresql::connection_config > config)
|
||||
: _conn(std::make_unique< sqlpp::postgresql::connection >(config)) {}
|
||||
|
||||
sqlpp::postgresql::connection * native() {
|
||||
return _conn.get();
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
auto operator()(T && t) {
|
||||
return _conn->operator()(std::forward< T >(t));
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr< sqlpp::postgresql::connection > _conn;
|
||||
};
|
||||
}
|
||||
@ -1,4 +0,0 @@
|
||||
#include "dbo_object.hpp"
|
||||
namespace eedb::db
|
||||
{
|
||||
}
|
||||
@ -1,43 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace eedb::db
|
||||
{
|
||||
template < typename T >
|
||||
class DatabaseObject
|
||||
{
|
||||
};
|
||||
|
||||
template < typename T >
|
||||
class DatabaseCacheObject
|
||||
{
|
||||
public:
|
||||
DatabaseObject< T > & operator->()
|
||||
{
|
||||
if( isDirty() )
|
||||
reload();
|
||||
}
|
||||
|
||||
virtual bool isDirty()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void reload() = 0;
|
||||
|
||||
protected:
|
||||
void markDirty()
|
||||
{
|
||||
is_dirty = true;
|
||||
}
|
||||
|
||||
private:
|
||||
bool is_dirty;
|
||||
};
|
||||
|
||||
template < typename T >
|
||||
class DatabaseCacheContainer
|
||||
{
|
||||
};
|
||||
}
|
||||
60
src/eedb/model/action.h
Normal file
60
src/eedb/model/action.h
Normal file
@ -0,0 +1,60 @@
|
||||
#ifndef EEDB_ACTION_H
|
||||
#define EEDB_ACTION_H
|
||||
|
||||
#include <sqlpp11/table.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/column_types.h>
|
||||
|
||||
namespace eedb {
|
||||
|
||||
namespace action_ {
|
||||
|
||||
struct Title {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="title";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T title;
|
||||
T &operator()() { return title; }
|
||||
const T &operator()() const { return title; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Apply_object {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="apply_object";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T apply_object;
|
||||
T &operator()() { return apply_object; }
|
||||
const T &operator()() const { return apply_object; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::boolean, sqlpp::tag::require_insert>;
|
||||
};
|
||||
}
|
||||
|
||||
struct action : sqlpp::table_t<action,
|
||||
action_::Title,
|
||||
action_::Apply_object> {
|
||||
using _value_type = sqlpp::no_value_t;
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] = "action";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T action;
|
||||
T &operator()() { return action; }
|
||||
const T &operator()() const { return action; }
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
92
src/eedb/model/auth_identity.h
Normal file
92
src/eedb/model/auth_identity.h
Normal file
@ -0,0 +1,92 @@
|
||||
#ifndef EEDB_AUTH_IDENTITY_H
|
||||
#define EEDB_AUTH_IDENTITY_H
|
||||
|
||||
#include <sqlpp11/table.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/column_types.h>
|
||||
|
||||
namespace eedb {
|
||||
|
||||
namespace auth_identity_ {
|
||||
|
||||
struct Id {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="id";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T id;
|
||||
T &operator()() { return id; }
|
||||
const T &operator()() const { return id; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer, sqlpp::tag::must_not_insert, sqlpp::tag::must_not_update>;
|
||||
};
|
||||
|
||||
struct Auth_info_id {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="auth_info_id";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T auth_info_id;
|
||||
T &operator()() { return auth_info_id; }
|
||||
const T &operator()() const { return auth_info_id; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::bigint, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
|
||||
struct Provider {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="provider";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T provider;
|
||||
T &operator()() { return provider; }
|
||||
const T &operator()() const { return provider; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::varchar, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Identity {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="identity";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T identity;
|
||||
T &operator()() { return identity; }
|
||||
const T &operator()() const { return identity; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::varchar, sqlpp::tag::require_insert>;
|
||||
};
|
||||
}
|
||||
|
||||
struct auth_identity : sqlpp::table_t<auth_identity,
|
||||
auth_identity_::Id,
|
||||
auth_identity_::Auth_info_id,
|
||||
auth_identity_::Provider,
|
||||
auth_identity_::Identity> {
|
||||
using _value_type = sqlpp::no_value_t;
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] = "auth_identity";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T auth_identity;
|
||||
T &operator()() { return auth_identity; }
|
||||
const T &operator()() const { return auth_identity; }
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
204
src/eedb/model/auth_info.h
Normal file
204
src/eedb/model/auth_info.h
Normal file
@ -0,0 +1,204 @@
|
||||
#ifndef EEDB_AUTH_INFO_H
|
||||
#define EEDB_AUTH_INFO_H
|
||||
|
||||
#include <sqlpp11/table.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/column_types.h>
|
||||
|
||||
namespace eedb {
|
||||
|
||||
namespace auth_info_ {
|
||||
|
||||
struct Id {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="id";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T id;
|
||||
T &operator()() { return id; }
|
||||
const T &operator()() const { return id; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer, sqlpp::tag::must_not_insert, sqlpp::tag::must_not_update>;
|
||||
};
|
||||
|
||||
struct User_uid {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="user_uid";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T user_uid;
|
||||
T &operator()() { return user_uid; }
|
||||
const T &operator()() const { return user_uid; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::bigint, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
|
||||
struct Password_hash {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="password_hash";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T password_hash;
|
||||
T &operator()() { return password_hash; }
|
||||
const T &operator()() const { return password_hash; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::varchar, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Password_method {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="password_method";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T password_method;
|
||||
T &operator()() { return password_method; }
|
||||
const T &operator()() const { return password_method; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::varchar, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Password_salt {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="password_salt";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T password_salt;
|
||||
T &operator()() { return password_salt; }
|
||||
const T &operator()() const { return password_salt; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::varchar, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Failed_login_attempts {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="failed_login_attempts";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T failed_login_attempts;
|
||||
T &operator()() { return failed_login_attempts; }
|
||||
const T &operator()() const { return failed_login_attempts; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Last_login_attempt {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="last_login_attempt";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T last_login_attempt;
|
||||
T &operator()() { return last_login_attempt; }
|
||||
const T &operator()() const { return last_login_attempt; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::time_point, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
|
||||
struct Unverified_email {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="unverified_email";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T unverified_email;
|
||||
T &operator()() { return unverified_email; }
|
||||
const T &operator()() const { return unverified_email; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::varchar, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Email_token {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="email_token";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T email_token;
|
||||
T &operator()() { return email_token; }
|
||||
const T &operator()() const { return email_token; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::varchar, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Email_token_expires {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="email_token_expires";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T email_token_expires;
|
||||
T &operator()() { return email_token_expires; }
|
||||
const T &operator()() const { return email_token_expires; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::time_point, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
|
||||
struct Email_token_role {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="email_token_role";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T email_token_role;
|
||||
T &operator()() { return email_token_role; }
|
||||
const T &operator()() const { return email_token_role; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer, sqlpp::tag::require_insert>;
|
||||
};
|
||||
}
|
||||
|
||||
struct auth_info : sqlpp::table_t<auth_info,
|
||||
auth_info_::Id,
|
||||
auth_info_::User_uid,
|
||||
auth_info_::Password_hash,
|
||||
auth_info_::Password_method,
|
||||
auth_info_::Password_salt,
|
||||
auth_info_::Failed_login_attempts,
|
||||
auth_info_::Last_login_attempt,
|
||||
auth_info_::Unverified_email,
|
||||
auth_info_::Email_token,
|
||||
auth_info_::Email_token_expires,
|
||||
auth_info_::Email_token_role> {
|
||||
using _value_type = sqlpp::no_value_t;
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] = "auth_info";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T auth_info;
|
||||
T &operator()() { return auth_info; }
|
||||
const T &operator()() const { return auth_info; }
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
108
src/eedb/model/auth_token.h
Normal file
108
src/eedb/model/auth_token.h
Normal file
@ -0,0 +1,108 @@
|
||||
#ifndef EEDB_AUTH_TOKEN_H
|
||||
#define EEDB_AUTH_TOKEN_H
|
||||
|
||||
#include <sqlpp11/table.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/column_types.h>
|
||||
|
||||
namespace eedb {
|
||||
|
||||
namespace auth_token_ {
|
||||
|
||||
struct Id {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="id";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T id;
|
||||
T &operator()() { return id; }
|
||||
const T &operator()() const { return id; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer, sqlpp::tag::must_not_insert, sqlpp::tag::must_not_update>;
|
||||
};
|
||||
|
||||
struct Version {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="version";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T version;
|
||||
T &operator()() { return version; }
|
||||
const T &operator()() const { return version; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Auth_info_id {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="auth_info_id";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T auth_info_id;
|
||||
T &operator()() { return auth_info_id; }
|
||||
const T &operator()() const { return auth_info_id; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::bigint, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
|
||||
struct Value {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="value";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T value;
|
||||
T &operator()() { return value; }
|
||||
const T &operator()() const { return value; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::varchar, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Expires {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="expires";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T expires;
|
||||
T &operator()() { return expires; }
|
||||
const T &operator()() const { return expires; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::time_point, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
}
|
||||
|
||||
struct auth_token : sqlpp::table_t<auth_token,
|
||||
auth_token_::Id,
|
||||
auth_token_::Version,
|
||||
auth_token_::Auth_info_id,
|
||||
auth_token_::Value,
|
||||
auth_token_::Expires> {
|
||||
using _value_type = sqlpp::no_value_t;
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] = "auth_token";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T auth_token;
|
||||
T &operator()() { return auth_token; }
|
||||
const T &operator()() const { return auth_token; }
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
204
src/eedb/model/category.h
Normal file
204
src/eedb/model/category.h
Normal file
@ -0,0 +1,204 @@
|
||||
#ifndef EEDB_CATEGORY_H
|
||||
#define EEDB_CATEGORY_H
|
||||
|
||||
#include <sqlpp11/table.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/column_types.h>
|
||||
|
||||
namespace eedb {
|
||||
|
||||
namespace category_ {
|
||||
|
||||
struct Uid {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="uid";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T uid;
|
||||
T &operator()() { return uid; }
|
||||
const T &operator()() const { return uid; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Owner {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="owner";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T owner;
|
||||
T &operator()() { return owner; }
|
||||
const T &operator()() const { return owner; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Stat_group {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="stat_group";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T stat_group;
|
||||
T &operator()() { return stat_group; }
|
||||
const T &operator()() const { return stat_group; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Unixperms {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="unixperms";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T unixperms;
|
||||
T &operator()() { return unixperms; }
|
||||
const T &operator()() const { return unixperms; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Status {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="status";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T status;
|
||||
T &operator()() { return status; }
|
||||
const T &operator()() const { return status; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Name {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="name";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T name;
|
||||
T &operator()() { return name; }
|
||||
const T &operator()() const { return name; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Creation_date {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="creation_date";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T creation_date;
|
||||
T &operator()() { return creation_date; }
|
||||
const T &operator()() const { return creation_date; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::time_point>;
|
||||
};
|
||||
|
||||
struct Last_update {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="last_update";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T last_update;
|
||||
T &operator()() { return last_update; }
|
||||
const T &operator()() const { return last_update; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::time_point, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
|
||||
struct Parent_id {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="parent_id";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T parent_id;
|
||||
T &operator()() { return parent_id; }
|
||||
const T &operator()() const { return parent_id; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
|
||||
struct Description {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="description";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T description;
|
||||
T &operator()() { return description; }
|
||||
const T &operator()() const { return description; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
|
||||
struct Parent_path {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="parent_path";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T parent_path;
|
||||
T &operator()() { return parent_path; }
|
||||
const T &operator()() const { return parent_path; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::varchar, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
}
|
||||
|
||||
struct category : sqlpp::table_t<category,
|
||||
category_::Uid,
|
||||
category_::Owner,
|
||||
category_::Stat_group,
|
||||
category_::Unixperms,
|
||||
category_::Status,
|
||||
category_::Name,
|
||||
category_::Creation_date,
|
||||
category_::Last_update,
|
||||
category_::Parent_id,
|
||||
category_::Description,
|
||||
category_::Parent_path> {
|
||||
using _value_type = sqlpp::no_value_t;
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] = "category";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T category;
|
||||
T &operator()() { return category; }
|
||||
const T &operator()() const { return category; }
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
76
src/eedb/model/implemented_action.h
Normal file
76
src/eedb/model/implemented_action.h
Normal file
@ -0,0 +1,76 @@
|
||||
#ifndef EEDB_IMPLEMENTED_ACTION_H
|
||||
#define EEDB_IMPLEMENTED_ACTION_H
|
||||
|
||||
#include <sqlpp11/table.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/column_types.h>
|
||||
|
||||
namespace eedb {
|
||||
|
||||
namespace implemented_action_ {
|
||||
|
||||
struct Table_name {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="table_name";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T table_name;
|
||||
T &operator()() { return table_name; }
|
||||
const T &operator()() const { return table_name; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Action {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="action";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T action;
|
||||
T &operator()() { return action; }
|
||||
const T &operator()() const { return action; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Status {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="status";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T status;
|
||||
T &operator()() { return status; }
|
||||
const T &operator()() const { return status; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer, sqlpp::tag::require_insert>;
|
||||
};
|
||||
}
|
||||
|
||||
struct implemented_action : sqlpp::table_t<implemented_action,
|
||||
implemented_action_::Table_name,
|
||||
implemented_action_::Action,
|
||||
implemented_action_::Status> {
|
||||
using _value_type = sqlpp::no_value_t;
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] = "implemented_action";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T implemented_action;
|
||||
T &operator()() { return implemented_action; }
|
||||
const T &operator()() const { return implemented_action; }
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
172
src/eedb/model/inventory.h
Normal file
172
src/eedb/model/inventory.h
Normal file
@ -0,0 +1,172 @@
|
||||
#ifndef EEDB_INVENTORY_H
|
||||
#define EEDB_INVENTORY_H
|
||||
|
||||
#include <sqlpp11/table.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/column_types.h>
|
||||
|
||||
namespace eedb {
|
||||
|
||||
namespace inventory_ {
|
||||
|
||||
struct Uid {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="uid";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T uid;
|
||||
T &operator()() { return uid; }
|
||||
const T &operator()() const { return uid; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Owner {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="owner";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T owner;
|
||||
T &operator()() { return owner; }
|
||||
const T &operator()() const { return owner; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Stat_group {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="stat_group";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T stat_group;
|
||||
T &operator()() { return stat_group; }
|
||||
const T &operator()() const { return stat_group; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Unixperms {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="unixperms";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T unixperms;
|
||||
T &operator()() { return unixperms; }
|
||||
const T &operator()() const { return unixperms; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Status {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="status";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T status;
|
||||
T &operator()() { return status; }
|
||||
const T &operator()() const { return status; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Name {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="name";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T name;
|
||||
T &operator()() { return name; }
|
||||
const T &operator()() const { return name; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Creation_date {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="creation_date";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T creation_date;
|
||||
T &operator()() { return creation_date; }
|
||||
const T &operator()() const { return creation_date; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::time_point>;
|
||||
};
|
||||
|
||||
struct Last_update {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="last_update";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T last_update;
|
||||
T &operator()() { return last_update; }
|
||||
const T &operator()() const { return last_update; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::time_point, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
|
||||
struct Description {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="description";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T description;
|
||||
T &operator()() { return description; }
|
||||
const T &operator()() const { return description; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
}
|
||||
|
||||
struct inventory : sqlpp::table_t<inventory,
|
||||
inventory_::Uid,
|
||||
inventory_::Owner,
|
||||
inventory_::Stat_group,
|
||||
inventory_::Unixperms,
|
||||
inventory_::Status,
|
||||
inventory_::Name,
|
||||
inventory_::Creation_date,
|
||||
inventory_::Last_update,
|
||||
inventory_::Description> {
|
||||
using _value_type = sqlpp::no_value_t;
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] = "inventory";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T inventory;
|
||||
T &operator()() { return inventory; }
|
||||
const T &operator()() const { return inventory; }
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
236
src/eedb/model/item.h
Normal file
236
src/eedb/model/item.h
Normal file
@ -0,0 +1,236 @@
|
||||
#ifndef EEDB_ITEM_H
|
||||
#define EEDB_ITEM_H
|
||||
|
||||
#include <sqlpp11/table.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/column_types.h>
|
||||
|
||||
namespace eedb {
|
||||
|
||||
namespace item_ {
|
||||
|
||||
struct Uid {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="uid";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T uid;
|
||||
T &operator()() { return uid; }
|
||||
const T &operator()() const { return uid; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Owner {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="owner";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T owner;
|
||||
T &operator()() { return owner; }
|
||||
const T &operator()() const { return owner; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Stat_group {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="stat_group";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T stat_group;
|
||||
T &operator()() { return stat_group; }
|
||||
const T &operator()() const { return stat_group; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Unixperms {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="unixperms";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T unixperms;
|
||||
T &operator()() { return unixperms; }
|
||||
const T &operator()() const { return unixperms; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Status {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="status";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T status;
|
||||
T &operator()() { return status; }
|
||||
const T &operator()() const { return status; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Name {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="name";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T name;
|
||||
T &operator()() { return name; }
|
||||
const T &operator()() const { return name; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Creation_date {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="creation_date";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T creation_date;
|
||||
T &operator()() { return creation_date; }
|
||||
const T &operator()() const { return creation_date; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::time_point>;
|
||||
};
|
||||
|
||||
struct Last_update {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="last_update";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T last_update;
|
||||
T &operator()() { return last_update; }
|
||||
const T &operator()() const { return last_update; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::time_point, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
|
||||
struct Category_id {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="category_id";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T category_id;
|
||||
T &operator()() { return category_id; }
|
||||
const T &operator()() const { return category_id; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Symbol {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="symbol";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T symbol;
|
||||
T &operator()() { return symbol; }
|
||||
const T &operator()() const { return symbol; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Producer {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="producer";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T producer;
|
||||
T &operator()() { return producer; }
|
||||
const T &operator()() const { return producer; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
|
||||
struct Attributes {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="attributes";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T attributes;
|
||||
T &operator()() { return attributes; }
|
||||
const T &operator()() const { return attributes; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text>;
|
||||
};
|
||||
|
||||
struct Description {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="description";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T description;
|
||||
T &operator()() { return description; }
|
||||
const T &operator()() const { return description; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
}
|
||||
|
||||
struct item : sqlpp::table_t<item,
|
||||
item_::Uid,
|
||||
item_::Owner,
|
||||
item_::Stat_group,
|
||||
item_::Unixperms,
|
||||
item_::Status,
|
||||
item_::Name,
|
||||
item_::Creation_date,
|
||||
item_::Last_update,
|
||||
item_::Category_id,
|
||||
item_::Symbol,
|
||||
item_::Producer,
|
||||
item_::Attributes,
|
||||
item_::Description> {
|
||||
using _value_type = sqlpp::no_value_t;
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] = "item";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T item;
|
||||
T &operator()() { return item; }
|
||||
const T &operator()() const { return item; }
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
124
src/eedb/model/privilege.h
Normal file
124
src/eedb/model/privilege.h
Normal file
@ -0,0 +1,124 @@
|
||||
#ifndef EEDB_PRIVILEGE_H
|
||||
#define EEDB_PRIVILEGE_H
|
||||
|
||||
#include <sqlpp11/table.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/column_types.h>
|
||||
|
||||
namespace eedb {
|
||||
|
||||
namespace privilege_ {
|
||||
|
||||
struct Role {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="role";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T role;
|
||||
T &operator()() { return role; }
|
||||
const T &operator()() const { return role; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::varchar, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Who {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="who";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T who;
|
||||
T &operator()() { return who; }
|
||||
const T &operator()() const { return who; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Action {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="action";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T action;
|
||||
T &operator()() { return action; }
|
||||
const T &operator()() const { return action; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Type {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="type";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T type;
|
||||
T &operator()() { return type; }
|
||||
const T &operator()() const { return type; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::varchar, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Related_table_name {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="related_table_name";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T related_table_name;
|
||||
T &operator()() { return related_table_name; }
|
||||
const T &operator()() const { return related_table_name; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::varchar, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Related_object_uid {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="related_object_uid";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T related_object_uid;
|
||||
T &operator()() { return related_object_uid; }
|
||||
const T &operator()() const { return related_object_uid; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
}
|
||||
|
||||
struct privilege : sqlpp::table_t<privilege,
|
||||
privilege_::Role,
|
||||
privilege_::Who,
|
||||
privilege_::Action,
|
||||
privilege_::Type,
|
||||
privilege_::Related_table_name,
|
||||
privilege_::Related_object_uid> {
|
||||
using _value_type = sqlpp::no_value_t;
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] = "privilege";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T privilege;
|
||||
T &operator()() { return privilege; }
|
||||
const T &operator()() const { return privilege; }
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
156
src/eedb/model/stat.h
Normal file
156
src/eedb/model/stat.h
Normal file
@ -0,0 +1,156 @@
|
||||
#ifndef EEDB_STAT_H
|
||||
#define EEDB_STAT_H
|
||||
|
||||
#include <sqlpp11/table.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/column_types.h>
|
||||
|
||||
namespace eedb {
|
||||
|
||||
namespace stat_ {
|
||||
|
||||
struct Uid {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="uid";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T uid;
|
||||
T &operator()() { return uid; }
|
||||
const T &operator()() const { return uid; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer, sqlpp::tag::must_not_insert, sqlpp::tag::must_not_update>;
|
||||
};
|
||||
|
||||
struct Owner {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="owner";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T owner;
|
||||
T &operator()() { return owner; }
|
||||
const T &operator()() const { return owner; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Stat_group {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="stat_group";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T stat_group;
|
||||
T &operator()() { return stat_group; }
|
||||
const T &operator()() const { return stat_group; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Unixperms {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="unixperms";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T unixperms;
|
||||
T &operator()() { return unixperms; }
|
||||
const T &operator()() const { return unixperms; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Status {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="status";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T status;
|
||||
T &operator()() { return status; }
|
||||
const T &operator()() const { return status; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Name {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="name";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T name;
|
||||
T &operator()() { return name; }
|
||||
const T &operator()() const { return name; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Creation_date {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="creation_date";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T creation_date;
|
||||
T &operator()() { return creation_date; }
|
||||
const T &operator()() const { return creation_date; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::time_point>;
|
||||
};
|
||||
|
||||
struct Last_update {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="last_update";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T last_update;
|
||||
T &operator()() { return last_update; }
|
||||
const T &operator()() const { return last_update; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::time_point, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
}
|
||||
|
||||
struct stat : sqlpp::table_t<stat,
|
||||
stat_::Uid,
|
||||
stat_::Owner,
|
||||
stat_::Stat_group,
|
||||
stat_::Unixperms,
|
||||
stat_::Status,
|
||||
stat_::Name,
|
||||
stat_::Creation_date,
|
||||
stat_::Last_update> {
|
||||
using _value_type = sqlpp::no_value_t;
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] = "stat";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T stat;
|
||||
T &operator()() { return stat; }
|
||||
const T &operator()() const { return stat; }
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
92
src/eedb/model/system_info.h
Normal file
92
src/eedb/model/system_info.h
Normal file
@ -0,0 +1,92 @@
|
||||
#ifndef EEDB_SYSTEM_INFO_H
|
||||
#define EEDB_SYSTEM_INFO_H
|
||||
|
||||
#include <sqlpp11/table.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/column_types.h>
|
||||
|
||||
namespace eedb {
|
||||
|
||||
namespace system_info_ {
|
||||
|
||||
struct Id {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="id";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T id;
|
||||
T &operator()() { return id; }
|
||||
const T &operator()() const { return id; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer, sqlpp::tag::must_not_insert, sqlpp::tag::must_not_update>;
|
||||
};
|
||||
|
||||
struct Name {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="name";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T name;
|
||||
T &operator()() { return name; }
|
||||
const T &operator()() const { return name; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
|
||||
struct Value {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="value";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T value;
|
||||
T &operator()() { return value; }
|
||||
const T &operator()() const { return value; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
|
||||
struct Creation_time {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="creation_time";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T creation_time;
|
||||
T &operator()() { return creation_time; }
|
||||
const T &operator()() const { return creation_time; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::time_point, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
}
|
||||
|
||||
struct system_info : sqlpp::table_t<system_info,
|
||||
system_info_::Id,
|
||||
system_info_::Name,
|
||||
system_info_::Value,
|
||||
system_info_::Creation_time> {
|
||||
using _value_type = sqlpp::no_value_t;
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] = "system_info";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T system_info;
|
||||
T &operator()() { return system_info; }
|
||||
const T &operator()() const { return system_info; }
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
220
src/eedb/model/user.h
Normal file
220
src/eedb/model/user.h
Normal file
@ -0,0 +1,220 @@
|
||||
#ifndef EEDB_USER_H
|
||||
#define EEDB_USER_H
|
||||
|
||||
#include <sqlpp11/table.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/column_types.h>
|
||||
|
||||
namespace eedb {
|
||||
|
||||
namespace user_ {
|
||||
|
||||
struct Uid {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="uid";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T uid;
|
||||
T &operator()() { return uid; }
|
||||
const T &operator()() const { return uid; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Owner {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="owner";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T owner;
|
||||
T &operator()() { return owner; }
|
||||
const T &operator()() const { return owner; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Stat_group {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="stat_group";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T stat_group;
|
||||
T &operator()() { return stat_group; }
|
||||
const T &operator()() const { return stat_group; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Unixperms {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="unixperms";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T unixperms;
|
||||
T &operator()() { return unixperms; }
|
||||
const T &operator()() const { return unixperms; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Status {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="status";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T status;
|
||||
T &operator()() { return status; }
|
||||
const T &operator()() const { return status; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||
};
|
||||
|
||||
struct Name {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="name";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T name;
|
||||
T &operator()() { return name; }
|
||||
const T &operator()() const { return name; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Creation_date {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="creation_date";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T creation_date;
|
||||
T &operator()() { return creation_date; }
|
||||
const T &operator()() const { return creation_date; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::time_point>;
|
||||
};
|
||||
|
||||
struct Last_update {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="last_update";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T last_update;
|
||||
T &operator()() { return last_update; }
|
||||
const T &operator()() const { return last_update; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::time_point, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
|
||||
struct Address {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="address";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T address;
|
||||
T &operator()() { return address; }
|
||||
const T &operator()() const { return address; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
|
||||
struct Config {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="config";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T config;
|
||||
T &operator()() { return config; }
|
||||
const T &operator()() const { return config; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
|
||||
struct Avatar {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="avatar";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T avatar;
|
||||
T &operator()() { return avatar; }
|
||||
const T &operator()() const { return avatar; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
|
||||
struct Email {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="email";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T email;
|
||||
T &operator()() { return email; }
|
||||
const T &operator()() const { return email; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::varchar, sqlpp::tag::require_insert>;
|
||||
};
|
||||
}
|
||||
|
||||
struct user : sqlpp::table_t<user,
|
||||
user_::Uid,
|
||||
user_::Owner,
|
||||
user_::Stat_group,
|
||||
user_::Unixperms,
|
||||
user_::Status,
|
||||
user_::Name,
|
||||
user_::Creation_date,
|
||||
user_::Last_update,
|
||||
user_::Address,
|
||||
user_::Config,
|
||||
user_::Avatar,
|
||||
user_::Email> {
|
||||
using _value_type = sqlpp::no_value_t;
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] = "\"user\"";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T user;
|
||||
T &operator()() { return user; }
|
||||
const T &operator()() const { return user; }
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
92
src/eedb/model/user_history.h
Normal file
92
src/eedb/model/user_history.h
Normal file
@ -0,0 +1,92 @@
|
||||
#ifndef EEDB_USER_HISTORY_H
|
||||
#define EEDB_USER_HISTORY_H
|
||||
|
||||
#include <sqlpp11/table.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/column_types.h>
|
||||
|
||||
namespace eedb {
|
||||
|
||||
namespace user_history_ {
|
||||
|
||||
struct Id {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="id";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T id;
|
||||
T &operator()() { return id; }
|
||||
const T &operator()() const { return id; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer, sqlpp::tag::must_not_insert, sqlpp::tag::must_not_update>;
|
||||
};
|
||||
|
||||
struct Uid {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="uid";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T uid;
|
||||
T &operator()() { return uid; }
|
||||
const T &operator()() const { return uid; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Action {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="action";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T action;
|
||||
T &operator()() { return action; }
|
||||
const T &operator()() const { return action; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct When {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="when";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T when;
|
||||
T &operator()() { return when; }
|
||||
const T &operator()() const { return when; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::time_point, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
}
|
||||
|
||||
struct user_history : sqlpp::table_t<user_history,
|
||||
user_history_::Id,
|
||||
user_history_::Uid,
|
||||
user_history_::Action,
|
||||
user_history_::When> {
|
||||
using _value_type = sqlpp::no_value_t;
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] = "user_history";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T user_history;
|
||||
T &operator()() { return user_history; }
|
||||
const T &operator()() const { return user_history; }
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
60
src/eedb/model/user_inventory.h
Normal file
60
src/eedb/model/user_inventory.h
Normal file
@ -0,0 +1,60 @@
|
||||
#ifndef EEDB_USER_INVENTORY_H
|
||||
#define EEDB_USER_INVENTORY_H
|
||||
|
||||
#include <sqlpp11/table.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
#include <sqlpp11/column_types.h>
|
||||
|
||||
namespace eedb {
|
||||
|
||||
namespace user_inventory_ {
|
||||
|
||||
struct User_id {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="user_id";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T user_id;
|
||||
T &operator()() { return user_id; }
|
||||
const T &operator()() const { return user_id; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer, sqlpp::tag::require_insert>;
|
||||
};
|
||||
|
||||
struct Inventory_id {
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] ="inventory_id";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T inventory_id;
|
||||
T &operator()() { return inventory_id; }
|
||||
const T &operator()() const { return inventory_id; }
|
||||
};
|
||||
};
|
||||
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::integer, sqlpp::tag::require_insert>;
|
||||
};
|
||||
}
|
||||
|
||||
struct user_inventory : sqlpp::table_t<user_inventory,
|
||||
user_inventory_::User_id,
|
||||
user_inventory_::Inventory_id> {
|
||||
using _value_type = sqlpp::no_value_t;
|
||||
struct _alias_t {
|
||||
static constexpr const char _literal[] = "user_inventory";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
struct _member_t {
|
||||
T user_inventory;
|
||||
T &operator()() { return user_inventory; }
|
||||
const T &operator()() const { return user_inventory; }
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace eedb::model{
|
||||
|
||||
|
||||
|
||||
}
|
||||
0
src/eedb/widgets/MainWindow.hpp
Normal file
0
src/eedb/widgets/MainWindow.hpp
Normal file
Loading…
Reference in New Issue
Block a user