add parameter class
This commit is contained in:
parent
9862749cca
commit
d641aa9fc2
@ -262,7 +262,7 @@ create or replace function update_category_parent_path() returns trigger as $$
|
|||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
-- TODO thumbnail should be a link to file table
|
||||||
create table "category"(
|
create table "category"(
|
||||||
"parent_id" int,
|
"parent_id" int,
|
||||||
"parent_path" ltree,
|
"parent_path" ltree,
|
||||||
@ -273,7 +273,7 @@ create table "category"(
|
|||||||
constraint "fk_category_stat_owner" foreign key ("owner") references "auth_info"("id") deferrable initially immediate
|
constraint "fk_category_stat_owner" foreign key ("owner") references "auth_info"("id") deferrable initially immediate
|
||||||
) inherits (stat);
|
) inherits (stat);
|
||||||
create index "ix_category_parent_path" on "category" using GIST ("parent_path");
|
create index "ix_category_parent_path" on "category" using GIST ("parent_path");
|
||||||
create unique index "ux_category_name" on "category" ( "parent_id", "name" );
|
create unique index "ux_category_name" on "category"("parent_id", "name" );
|
||||||
create trigger "update_category_last_update" before update on "category" for each row execute procedure last_update_column();
|
create trigger "update_category_last_update" before update on "category" for each row execute procedure last_update_column();
|
||||||
create trigger "update_category_parent_path" before insert or update on "category" for each row execute procedure update_category_parent_path();
|
create trigger "update_category_parent_path" before insert or update on "category" for each row execute procedure update_category_parent_path();
|
||||||
comment on table "category" is 'categories of items';
|
comment on table "category" is 'categories of items';
|
||||||
@ -283,35 +283,32 @@ comment on column "category"."description" is '';
|
|||||||
comment on column "category"."thumbnail" is '';
|
comment on column "category"."thumbnail" is '';
|
||||||
|
|
||||||
|
|
||||||
--create table "measurands"(
|
create table "unit"(
|
||||||
-- "id" serial not null primary key,
|
"symbol" text not null,
|
||||||
-- "name" VARCHAR(32) not null unique,
|
"description" text,
|
||||||
-- "description" text
|
"dimension_symbol" text,
|
||||||
--);
|
-- "type" text
|
||||||
|
constraint "pk_unit" primary key ("id")
|
||||||
|
) inherits(stat);
|
||||||
|
create unique index "uk_unit" on "unit"("name", "symbol");
|
||||||
|
create trigger update_unit_last_update before update on "unit" for each row execute PROCEDURE last_update_column();
|
||||||
|
comment on table "unit" is 'categories of items';
|
||||||
|
comment on column "unit"."symbol" is '';
|
||||||
|
comment on column "unit"."description" is '';
|
||||||
|
comment on column "unit"."dimension_symbol" is '';
|
||||||
|
|
||||||
--create table "metric_system"(
|
|
||||||
-- "id" serial not null primary key,
|
|
||||||
-- "name" VARCHAR(32) not null unique,
|
|
||||||
-- "description" text
|
|
||||||
--);
|
|
||||||
|
|
||||||
--create table "unit"(
|
create table "parameter"(
|
||||||
-- "id" serial not null unique primary key,
|
"unit_id" int,
|
||||||
-- "name" text not null unique,
|
"description" text,
|
||||||
-- "symbol" VARCHAR (20) not null,
|
constraint "pk_parameter" primary key ("id"),
|
||||||
-- "description" text,
|
constraint "fk_parameter_unit" foreign key ("unit_id") references "unit"("id") on delete cascade deferrable initially immediate
|
||||||
-- "dimension_symbol" text
|
) inherits(stat);
|
||||||
-- "metric_system" int ,
|
create trigger update_parameter_last_update before update on "parameter" for each row execute PROCEDURE last_update_column();
|
||||||
-- constraint units_pkey primary key (uid),
|
comment on table "parameter" is 'Parameter';
|
||||||
-- constraint units_unique UNIQUE(name, symbol)
|
comment on column "parameter"."unit_id" is '';
|
||||||
--);
|
comment on column "parameter"."description" is '';
|
||||||
|
|
||||||
--create table "parameter"(
|
|
||||||
-- "unit" int,
|
|
||||||
-- constraint "pk_parameter" primary key ("id"),
|
|
||||||
-- constraint "fk_parameter_unit" foreign key ("unit") references "unit"("id") on delete cascade deferrable initially immediate
|
|
||||||
--) inherits(stat);
|
|
||||||
--create trigger update_parameter_last_update before update on parameter for each row execute PROCEDURE last_update_column();
|
|
||||||
|
|
||||||
create table "item"(
|
create table "item"(
|
||||||
"symbol" text not null,
|
"symbol" text not null,
|
||||||
@ -382,18 +379,3 @@ comment on table "category_items" is '';
|
|||||||
|
|
||||||
-- date timestamp not null default now()
|
-- date timestamp not null default now()
|
||||||
--);
|
--);
|
||||||
|
|
||||||
|
|
||||||
-- create INDEX users_stat_index on users (uid, owner, group, unixperms, status) with ( FILLFACTOR=100 );
|
|
||||||
-- create INDEX categories_stat_index on categories (uid, owner, group, unixperms, status) with ( FILLFACTOR=100 );
|
|
||||||
-- create INDEX storages_stat_index on storages (uid, owner, group, unixperms, status) with ( FILLFACTOR=100 );
|
|
||||||
-- create INDEX files_stat_index on files (uid, owner, group, unixperms, status) with ( FILLFACTOR=100 );
|
|
||||||
-- create INDEX items_stat_index on items (uid, owner, group, unixperms, status) with ( FILLFACTOR=100 );
|
|
||||||
|
|
||||||
-- create trigger update_parameters_last_update before update on parameters for each row execute PROCEDURE last_update_column();
|
|
||||||
-- create trigger update_files_last_update before update on files for each row execute PROCEDURE last_update_column();
|
|
||||||
-- create trigger update_packages_last_update before update on packages for each row execute PROCEDURE last_update_column();
|
|
||||||
-- create trigger update_units_last_update before update on units for each row execute PROCEDURE last_update_column();
|
|
||||||
-- create trigger update_items_last_update before update on items for each row execute PROCEDURE last_update_column();
|
|
||||||
-- create trigger update_shelfs_last_update before update on shelfs for each row execute PROCEDURE last_update_column();
|
|
||||||
-- create trigger update_inventory_operations_lats_update before update on inventory_operations for each row execute PROCEDURE last_update_column();
|
|
||||||
|
|||||||
@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <eedb/db/Item.hpp>
|
||||||
|
|
||||||
|
namespace eedb {
|
||||||
|
class PgItems : public Items {};
|
||||||
|
} // namespace eedb
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <eedb/db/Item.hpp>
|
||||||
|
|
||||||
|
#include <utils/spimpl.hpp>
|
||||||
|
|
||||||
|
namespace eedb::db {
|
||||||
|
class PgConnection;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace eedb {
|
||||||
|
class User;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace eedb {
|
||||||
|
class PgItemsRepository : public ItemsRepository {
|
||||||
|
// ItemsRepository interface
|
||||||
|
public:
|
||||||
|
PgItemsRepository(db::PgConnection & db, User * owner);
|
||||||
|
|
||||||
|
std::unique_ptr< Item > create(item::Identyfier id, Values values, std::optional< item::Foto >) const override;
|
||||||
|
|
||||||
|
std::unique_ptr< Items > search(const ItemQueryFilters & filer) const override;
|
||||||
|
|
||||||
|
Parameters listParameters(const Category *) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct PgItemsRepositoryPriv;
|
||||||
|
spimpl::unique_impl_ptr< PgItemsRepositoryPriv > _priv;
|
||||||
|
};
|
||||||
|
} // namespace eedb
|
||||||
@ -5,13 +5,19 @@
|
|||||||
#include <eedb/db/pg/model/auth_token.h>
|
#include <eedb/db/pg/model/auth_token.h>
|
||||||
#include <eedb/db/pg/model/category.h>
|
#include <eedb/db/pg/model/category.h>
|
||||||
#include <eedb/db/pg/model/group.h>
|
#include <eedb/db/pg/model/group.h>
|
||||||
|
#include <eedb/db/pg/model/parameter.h>
|
||||||
#include <eedb/db/pg/model/stat.h>
|
#include <eedb/db/pg/model/stat.h>
|
||||||
#include <eedb/db/pg/model/system_info.h>
|
#include <eedb/db/pg/model/system_info.h>
|
||||||
|
#include <eedb/db/pg/model/unit.h>
|
||||||
#include <eedb/db/pg/model/user_audit.h>
|
#include <eedb/db/pg/model/user_audit.h>
|
||||||
|
|
||||||
constexpr eedb::user_audit t_user_audit;
|
|
||||||
constexpr eedb::auth_identity t_auth_identity;
|
constexpr eedb::auth_identity t_auth_identity;
|
||||||
constexpr eedb::auth_info t_auth_info;
|
constexpr eedb::auth_info t_auth_info;
|
||||||
constexpr eedb::auth_token t_auth_token;
|
constexpr eedb::auth_token t_auth_token;
|
||||||
constexpr eedb::group t_group;
|
|
||||||
constexpr eedb::category t_category;
|
constexpr eedb::category t_category;
|
||||||
|
constexpr eedb::group t_group;
|
||||||
|
constexpr eedb::parameter t_parameter;
|
||||||
|
constexpr eedb::stat t_stat;
|
||||||
|
constexpr eedb::system_info t_system_info;
|
||||||
|
constexpr eedb::unit t_unit;
|
||||||
|
constexpr eedb::user_audit t_user_audit;
|
||||||
|
|||||||
@ -0,0 +1,60 @@
|
|||||||
|
#ifndef EEDB_CATEGORY_ITEMS_H
|
||||||
|
#define EEDB_CATEGORY_ITEMS_H
|
||||||
|
|
||||||
|
#include <sqlpp11/table.h>
|
||||||
|
#include <sqlpp11/char_sequence.h>
|
||||||
|
#include <sqlpp11/column_types.h>
|
||||||
|
|
||||||
|
namespace eedb {
|
||||||
|
|
||||||
|
namespace category_items_ {
|
||||||
|
|
||||||
|
struct Category_id {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("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 Item_id {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("item_id")";
|
||||||
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
|
template<typename T>
|
||||||
|
struct _member_t {
|
||||||
|
T item_id;
|
||||||
|
T &operator()() { return item_id; }
|
||||||
|
const T &operator()() const { return item_id; }
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
using _traits = ::sqlpp::make_traits<::sqlpp::integer, sqlpp::tag::require_insert>;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
struct category_items : sqlpp::table_t<category_items,
|
||||||
|
category_items_::Category_id,
|
||||||
|
category_items_::Item_id> {
|
||||||
|
using _value_type = sqlpp::no_value_t;
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("category_items")";
|
||||||
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
|
template<typename T>
|
||||||
|
struct _member_t {
|
||||||
|
T category_items;
|
||||||
|
T &operator()() { return category_items; }
|
||||||
|
const T &operator()() const { return category_items; }
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
252
src/libs/db/postgresql_connector/include/eedb/db/pg/model/item.h
Normal file
252
src/libs/db/postgresql_connector/include/eedb/db/pg/model/item.h
Normal file
@ -0,0 +1,252 @@
|
|||||||
|
#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 Id {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("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>;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Owner {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("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 Group {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("group")";
|
||||||
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
|
template<typename T>
|
||||||
|
struct _member_t {
|
||||||
|
T group;
|
||||||
|
T &operator()() { return group; }
|
||||||
|
const T &operator()() const { return group; }
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Unixperms {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("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[] = R"("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[] = R"("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 Created {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("created")";
|
||||||
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
|
template<typename T>
|
||||||
|
struct _member_t {
|
||||||
|
T created;
|
||||||
|
T &operator()() { return created; }
|
||||||
|
const T &operator()() const { return created; }
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
using _traits = ::sqlpp::make_traits<::sqlpp::time_point>;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Updated {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("updated")";
|
||||||
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
|
template<typename T>
|
||||||
|
struct _member_t {
|
||||||
|
T updated;
|
||||||
|
T &operator()() { return updated; }
|
||||||
|
const T &operator()() const { return updated; }
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
using _traits = ::sqlpp::make_traits<::sqlpp::time_point, sqlpp::tag::can_be_null>;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Symbol {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("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 Original_symbol {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("original_symbol")";
|
||||||
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
|
template<typename T>
|
||||||
|
struct _member_t {
|
||||||
|
T original_symbol;
|
||||||
|
T &operator()() { return original_symbol; }
|
||||||
|
const T &operator()() const { return original_symbol; }
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::can_be_null>;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Producer {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("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[] = R"("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 Short_desc {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("short_desc")";
|
||||||
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
|
template<typename T>
|
||||||
|
struct _member_t {
|
||||||
|
T short_desc;
|
||||||
|
T &operator()() { return short_desc; }
|
||||||
|
const T &operator()() const { return short_desc; }
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::can_be_null>;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Description {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("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_::Id,
|
||||||
|
item_::Owner,
|
||||||
|
item_::Group,
|
||||||
|
item_::Unixperms,
|
||||||
|
item_::Status,
|
||||||
|
item_::Name,
|
||||||
|
item_::Created,
|
||||||
|
item_::Updated,
|
||||||
|
item_::Symbol,
|
||||||
|
item_::Original_symbol,
|
||||||
|
item_::Producer,
|
||||||
|
item_::Attributes,
|
||||||
|
item_::Short_desc,
|
||||||
|
item_::Description> {
|
||||||
|
using _value_type = sqlpp::no_value_t;
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("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
|
||||||
@ -0,0 +1,188 @@
|
|||||||
|
#ifndef EEDB_PARAMETER_H
|
||||||
|
#define EEDB_PARAMETER_H
|
||||||
|
|
||||||
|
#include <sqlpp11/table.h>
|
||||||
|
#include <sqlpp11/char_sequence.h>
|
||||||
|
#include <sqlpp11/column_types.h>
|
||||||
|
|
||||||
|
namespace eedb {
|
||||||
|
|
||||||
|
namespace parameter_ {
|
||||||
|
|
||||||
|
struct Id {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("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>;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Owner {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("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 Group {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("group")";
|
||||||
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
|
template<typename T>
|
||||||
|
struct _member_t {
|
||||||
|
T group;
|
||||||
|
T &operator()() { return group; }
|
||||||
|
const T &operator()() const { return group; }
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Unixperms {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("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[] = R"("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[] = R"("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 Created {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("created")";
|
||||||
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
|
template<typename T>
|
||||||
|
struct _member_t {
|
||||||
|
T created;
|
||||||
|
T &operator()() { return created; }
|
||||||
|
const T &operator()() const { return created; }
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
using _traits = ::sqlpp::make_traits<::sqlpp::time_point>;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Updated {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("updated")";
|
||||||
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
|
template<typename T>
|
||||||
|
struct _member_t {
|
||||||
|
T updated;
|
||||||
|
T &operator()() { return updated; }
|
||||||
|
const T &operator()() const { return updated; }
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
using _traits = ::sqlpp::make_traits<::sqlpp::time_point, sqlpp::tag::can_be_null>;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Unit_id {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("unit_id")";
|
||||||
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
|
template<typename T>
|
||||||
|
struct _member_t {
|
||||||
|
T unit_id;
|
||||||
|
T &operator()() { return unit_id; }
|
||||||
|
const T &operator()() const { return unit_id; }
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
using _traits = ::sqlpp::make_traits<::sqlpp::integer, sqlpp::tag::can_be_null>;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Description {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("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 parameter : sqlpp::table_t<parameter,
|
||||||
|
parameter_::Id,
|
||||||
|
parameter_::Owner,
|
||||||
|
parameter_::Group,
|
||||||
|
parameter_::Unixperms,
|
||||||
|
parameter_::Status,
|
||||||
|
parameter_::Name,
|
||||||
|
parameter_::Created,
|
||||||
|
parameter_::Updated,
|
||||||
|
parameter_::Unit_id,
|
||||||
|
parameter_::Description> {
|
||||||
|
using _value_type = sqlpp::no_value_t;
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("parameter")";
|
||||||
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
|
template<typename T>
|
||||||
|
struct _member_t {
|
||||||
|
T parameter;
|
||||||
|
T &operator()() { return parameter; }
|
||||||
|
const T &operator()() const { return parameter; }
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
204
src/libs/db/postgresql_connector/include/eedb/db/pg/model/unit.h
Normal file
204
src/libs/db/postgresql_connector/include/eedb/db/pg/model/unit.h
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
#ifndef EEDB_UNIT_H
|
||||||
|
#define EEDB_UNIT_H
|
||||||
|
|
||||||
|
#include <sqlpp11/table.h>
|
||||||
|
#include <sqlpp11/char_sequence.h>
|
||||||
|
#include <sqlpp11/column_types.h>
|
||||||
|
|
||||||
|
namespace eedb {
|
||||||
|
|
||||||
|
namespace unit_ {
|
||||||
|
|
||||||
|
struct Id {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("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>;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Owner {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("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 Group {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("group")";
|
||||||
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
|
template<typename T>
|
||||||
|
struct _member_t {
|
||||||
|
T group;
|
||||||
|
T &operator()() { return group; }
|
||||||
|
const T &operator()() const { return group; }
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
using _traits = ::sqlpp::make_traits<::sqlpp::integer>;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Unixperms {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("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[] = R"("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[] = R"("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 Created {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("created")";
|
||||||
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
|
template<typename T>
|
||||||
|
struct _member_t {
|
||||||
|
T created;
|
||||||
|
T &operator()() { return created; }
|
||||||
|
const T &operator()() const { return created; }
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
using _traits = ::sqlpp::make_traits<::sqlpp::time_point>;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Updated {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("updated")";
|
||||||
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
|
template<typename T>
|
||||||
|
struct _member_t {
|
||||||
|
T updated;
|
||||||
|
T &operator()() { return updated; }
|
||||||
|
const T &operator()() const { return updated; }
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
using _traits = ::sqlpp::make_traits<::sqlpp::time_point, sqlpp::tag::can_be_null>;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Symbol {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("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 Description {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("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 Dimension_symbol {
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("dimension_symbol")";
|
||||||
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
|
template<typename T>
|
||||||
|
struct _member_t {
|
||||||
|
T dimension_symbol;
|
||||||
|
T &operator()() { return dimension_symbol; }
|
||||||
|
const T &operator()() const { return dimension_symbol; }
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
using _traits = ::sqlpp::make_traits<::sqlpp::text, sqlpp::tag::can_be_null>;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
struct unit : sqlpp::table_t<unit,
|
||||||
|
unit_::Id,
|
||||||
|
unit_::Owner,
|
||||||
|
unit_::Group,
|
||||||
|
unit_::Unixperms,
|
||||||
|
unit_::Status,
|
||||||
|
unit_::Name,
|
||||||
|
unit_::Created,
|
||||||
|
unit_::Updated,
|
||||||
|
unit_::Symbol,
|
||||||
|
unit_::Description,
|
||||||
|
unit_::Dimension_symbol> {
|
||||||
|
using _value_type = sqlpp::no_value_t;
|
||||||
|
struct _alias_t {
|
||||||
|
static constexpr const char _literal[] = R"("unit")";
|
||||||
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
|
template<typename T>
|
||||||
|
struct _member_t {
|
||||||
|
T unit;
|
||||||
|
T &operator()() { return unit; }
|
||||||
|
const T &operator()() const { return unit; }
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -5,7 +5,8 @@
|
|||||||
#define CATEGORIESMOCK_HPP
|
#define CATEGORIESMOCK_HPP
|
||||||
|
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include "././eedb/db/Category.hpp"
|
|
||||||
|
#include <eedb/db/Category.hpp>
|
||||||
|
|
||||||
namespace eedb {
|
namespace eedb {
|
||||||
|
|
||||||
|
|||||||
@ -1,22 +1,52 @@
|
|||||||
/*
|
#pragma once
|
||||||
* file generated by gmock: CategoryMock.hpp
|
|
||||||
*/
|
|
||||||
#ifndef CATEGORYMOCK_HPP
|
|
||||||
#define CATEGORYMOCK_HPP
|
|
||||||
|
|
||||||
#include <eedb/db/Category.hpp>
|
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
|
|
||||||
namespace eedb {
|
#include <eedb/mock/db/CategoryMock.hpp>
|
||||||
|
|
||||||
|
#include <eedb/db/pg/connection.hpp>
|
||||||
|
#include <eedb/db/pg/model/all.hpp>
|
||||||
|
|
||||||
|
#include <sqlpp11/postgresql/insert.h>
|
||||||
|
#include <sqlpp11/sqlpp11.h>
|
||||||
|
|
||||||
|
namespace eedb::db::pg {
|
||||||
|
|
||||||
|
class CategoryMock : public ::eedb::CategoryMock {
|
||||||
|
auto _createChild(int64_t parentId, std::string name) {
|
||||||
|
return _db(sqlpp::postgresql::insert_into(t_category) //
|
||||||
|
.set(t_category.name = name, t_category.parent_id = parentId)
|
||||||
|
.returning(t_category.id))
|
||||||
|
.front()
|
||||||
|
.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _root_guard() {
|
||||||
|
if(!_root_id)
|
||||||
|
_initRoot();
|
||||||
|
}
|
||||||
|
|
||||||
class CategoryMock : public Category {
|
|
||||||
public:
|
public:
|
||||||
MOCK_CONST_METHOD0(display_name, std::string_view());
|
CategoryMock(PgConnection & db) : _db{db} {}
|
||||||
MOCK_CONST_METHOD0(parent, Category *());
|
|
||||||
MOCK_CONST_METHOD2(create, std::unique_ptr< Category >(std::string, std::string));
|
void _init_simple(std::string name) {
|
||||||
MOCK_CONST_METHOD0(children, std::unique_ptr< Categories >());
|
_root_guard();
|
||||||
|
_createChild(_root_id, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _initRoot() {
|
||||||
|
using namespace testing;
|
||||||
|
_root_id = _db(sqlpp::postgresql::insert_into(t_category) //
|
||||||
|
.set(t_category.name = "root", t_category.parent_id = sqlpp::null)
|
||||||
|
.returning(t_category.id))
|
||||||
|
.front()
|
||||||
|
.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
PgConnection & _db;
|
||||||
|
|
||||||
|
int64_t _root_id{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace eedb
|
} // namespace eedb::db::pg
|
||||||
|
|
||||||
#endif // CATEGORYMOCK_HPP
|
|
||||||
|
|||||||
@ -1,21 +1,15 @@
|
|||||||
/*
|
#pragma once
|
||||||
* file generated by gmock: ItemMock.hpp
|
|
||||||
*/
|
|
||||||
#ifndef ITEMMOCK_HPP
|
|
||||||
#define ITEMMOCK_HPP
|
|
||||||
|
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include "././eedb/db/Item.hpp"
|
|
||||||
|
|
||||||
namespace eedb {
|
#include <eedb/mock/db/ItemMock.hpp>
|
||||||
|
|
||||||
class ItemMock : public Item
|
namespace eedb::db {
|
||||||
|
|
||||||
|
class PgItemMock : public ::eedb::ItemMock
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MOCK_CONST_METHOD0(values, Values&());
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace eedb
|
} // namespace eedb
|
||||||
|
|
||||||
#endif // ITEMMOCK_HPP
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <eedb/mock/db/ParameterMock.hpp>
|
||||||
|
|
||||||
|
namespace eedb::db::pg {
|
||||||
|
|
||||||
|
class ParameterMock : public ::eedb::ParameterMock {};
|
||||||
|
} // namespace eedb::db::pg
|
||||||
@ -12,12 +12,12 @@
|
|||||||
|
|
||||||
#include <eedb/db/AuthIdentityConst.hpp>
|
#include <eedb/db/AuthIdentityConst.hpp>
|
||||||
|
|
||||||
namespace eedb::db {
|
namespace eedb::db::pg {
|
||||||
|
|
||||||
class UserMock : public ::eedb::UserMock {
|
class UserMock : public ::eedb::UserMock {
|
||||||
public:
|
public:
|
||||||
/// TODO chenge to transaction
|
/// TODO chenge to transaction
|
||||||
UserMock(db::PgConnection & db) : _db{db} {}
|
UserMock(PgConnection & db) : _db{db} {}
|
||||||
|
|
||||||
void _init() {
|
void _init() {
|
||||||
using namespace testing;
|
using namespace testing;
|
||||||
@ -48,9 +48,7 @@ class UserMock : public ::eedb::UserMock {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int64_t _id;
|
int64_t _id;
|
||||||
db::PgConnection & _db;
|
PgConnection & _db;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PgUserMock : public UserMock {};
|
} // namespace eedb::db::pg
|
||||||
|
|
||||||
} // namespace eedb::db
|
|
||||||
|
|||||||
@ -0,0 +1,24 @@
|
|||||||
|
#include <eedb/db/pg/PgItemsRepository.hpp>
|
||||||
|
|
||||||
|
#include <eedb/db/Parameter.hpp>
|
||||||
|
#include <eedb/Value.hpp>
|
||||||
|
#include <eedb/db/User.hpp>
|
||||||
|
|
||||||
|
namespace eedb {
|
||||||
|
struct PgItemsRepository::PgItemsRepositoryPriv {};
|
||||||
|
|
||||||
|
PgItemsRepository::PgItemsRepository(db::PgConnection & db, User * owner) : _priv{spimpl::make_unique_impl< PgItemsRepositoryPriv >()} {}
|
||||||
|
|
||||||
|
std::unique_ptr< Item > PgItemsRepository::create(item::Identyfier id, Values values, std::optional< item::Foto >) const {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr< Items > PgItemsRepository::search(const ItemQueryFilters & filer) const {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
Parameters PgItemsRepository::listParameters(const Category *) const {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace eedb
|
||||||
@ -24,7 +24,7 @@ class PgAuthIdentitiesTest : public DbTestBase< PgAuthIdentitiesTest > {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
eedb::db::UserMock user;
|
eedb::db::pg::UserMock user;
|
||||||
std::unique_ptr< eedb::PgAuthIdentities > sut;
|
std::unique_ptr< eedb::PgAuthIdentities > sut;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,7 @@ class PgAuthTokenTest : public DbTestBase< PgAuthTokenTest > {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
eedb::db::UserMock user;
|
eedb::db::pg::UserMock user;
|
||||||
|
|
||||||
int64_t sutId;
|
int64_t sutId;
|
||||||
std::unique_ptr< eedb::PgAuthToken > sut;
|
std::unique_ptr< eedb::PgAuthToken > sut;
|
||||||
|
|||||||
@ -28,7 +28,7 @@ class PgAuthTokensTest : public DbTestBase< PgAuthTokensTest > {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
eedb::db::UserMock user;
|
eedb::db::pg::UserMock user;
|
||||||
std::unique_ptr< eedb::PgAuthTokens > sut;
|
std::unique_ptr< eedb::PgAuthTokens > sut;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,7 @@ class PgCategoriesTest : public DbTestBase< PgCategoriesTest > {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector< UniquePtrMockWrapper< eedb::CategoryMock > > _categories;
|
// std::vector< UniquePtrMockWrapper< eedb::db:: > > _categories;
|
||||||
|
|
||||||
std::unique_ptr< eedb::PgCategories > sut;
|
std::unique_ptr< eedb::PgCategories > sut;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -20,7 +20,7 @@ class PgCategoriesRepositoryTest : public DbTestBase< PgCategoriesRepositoryTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
eedb::db::UserMock user;
|
eedb::db::pg::UserMock user;
|
||||||
std::unique_ptr< eedb::PgCategoriesRepository > sut;
|
std::unique_ptr< eedb::PgCategoriesRepository > sut;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@ class PgCategoryTest : public DbTestBase< PgCategoryTest > {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
eedb::db::UserMock user;
|
eedb::db::pg::UserMock user;
|
||||||
std::unique_ptr< eedb::PgCategory > sut;
|
std::unique_ptr< eedb::PgCategory > sut;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,40 @@
|
|||||||
|
#include <gmock/gmock.h>
|
||||||
|
|
||||||
|
#include <eedb/db/pg/PgItemsRepository.hpp>
|
||||||
|
|
||||||
|
#include <eedb/db/pg/model/all.hpp>
|
||||||
|
#include <sqlpp11/sqlpp11.h>
|
||||||
|
|
||||||
|
#include "DbTestBase.hpp"
|
||||||
|
|
||||||
|
#include <eedb/mock/db/pg/CategoryMock.hpp>
|
||||||
|
#include <eedb/mock/db/pg/ItemMock.hpp>
|
||||||
|
#include <eedb/mock/db/pg/ParameterMock.hpp>
|
||||||
|
#include <eedb/mock/db/pg/UserMock.hpp>
|
||||||
|
|
||||||
|
class PgItemsRepositoryTest : public DbTestBase< PgItemsRepositoryTest > {
|
||||||
|
public:
|
||||||
|
PgItemsRepositoryTest() : user{db()}, category{db()} {
|
||||||
|
using namespace testing;
|
||||||
|
db().native()->start_transaction();
|
||||||
|
user._init(); // create fake user
|
||||||
|
category._init_simple("main");
|
||||||
|
}
|
||||||
|
|
||||||
|
~PgItemsRepositoryTest() {
|
||||||
|
db().native()->rollback_transaction(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
eedb::db::pg::UserMock user;
|
||||||
|
eedb::db::pg::CategoryMock category;
|
||||||
|
eedb::db::pg::ParameterMock parameter;
|
||||||
|
|
||||||
|
int64_t sutId;
|
||||||
|
std::unique_ptr< eedb::PgItemsRepository > sut;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
std::unique_ptr< PgTestDatabasePrepare > DbTestBase< PgItemsRepositoryTest >::_test_db = {};
|
||||||
|
|
||||||
|
TEST_F(PgItemsRepositoryTest, getListOfParameters) {}
|
||||||
@ -1,13 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <optional>
|
|
||||||
|
|
||||||
#include <eedb/Unit.hpp>
|
|
||||||
|
|
||||||
namespace eedb {
|
|
||||||
|
|
||||||
class Parameter {
|
|
||||||
public:
|
|
||||||
std::optional< Unit > unit() const {}
|
|
||||||
};
|
|
||||||
} // namespace eedb
|
|
||||||
@ -4,7 +4,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
#include <eedb/Parameter.hpp>
|
#include <eedb/db/Parameter.hpp>
|
||||||
|
|
||||||
namespace eedb {
|
namespace eedb {
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ class Value {
|
|||||||
return Type::Numeric;
|
return Type::Numeric;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional< Parameter > parameter() const {}
|
Parameter * parameter() const {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::variant< TextValue, NumericValue > _value;
|
std::variant< TextValue, NumericValue > _value;
|
||||||
|
|||||||
@ -1,8 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <experimental/filesystem>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
|
#include <boost/range/iterator_range.hpp>
|
||||||
|
|
||||||
#include <any_iterator/any_iterator.hpp>
|
#include <any_iterator/any_iterator.hpp>
|
||||||
|
|
||||||
namespace eedb {
|
namespace eedb {
|
||||||
@ -18,15 +22,50 @@ class Parameters;
|
|||||||
*/
|
*/
|
||||||
class ItemQueryFilters {
|
class ItemQueryFilters {
|
||||||
public:
|
public:
|
||||||
virtual ~ItemQueryFilters() = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief category
|
* @brief category
|
||||||
* @return null if category is not taken into consideration
|
* @return null if category is not taken into consideration
|
||||||
*/
|
*/
|
||||||
virtual Category * category() const = 0;
|
Category * category() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace item {
|
||||||
|
|
||||||
|
class Identyfier {
|
||||||
|
public:
|
||||||
|
std::string_view name() const {
|
||||||
|
return _name;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string_view producerSymbol() const {
|
||||||
|
return _prod;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string_view symbol() const {
|
||||||
|
return _sym;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string _name;
|
||||||
|
std::string _prod;
|
||||||
|
std::string _sym;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Foto {
|
||||||
|
using path = std::experimental::filesystem::path;
|
||||||
|
|
||||||
|
public:
|
||||||
|
path thumbnail() const {
|
||||||
|
return _thumbnail;
|
||||||
|
}
|
||||||
|
path photo() const {
|
||||||
|
return _photo;
|
||||||
|
}
|
||||||
|
path _photo;
|
||||||
|
path _thumbnail;
|
||||||
|
};
|
||||||
|
} // namespace item
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The ItemsRepository class
|
* @brief The ItemsRepository class
|
||||||
*/
|
*/
|
||||||
@ -34,7 +73,13 @@ class ItemsRepository {
|
|||||||
public:
|
public:
|
||||||
virtual ~ItemsRepository() = default;
|
virtual ~ItemsRepository() = default;
|
||||||
|
|
||||||
virtual std::unique_ptr< Item > create(std::string name, std::unique_ptr< Values > value, std::string description) const = 0;
|
/**
|
||||||
|
* @brief create
|
||||||
|
* @param id
|
||||||
|
* @param values
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual std::unique_ptr< Item > create(item::Identyfier id, Values values, std::optional< item::Foto >) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief search
|
* @brief search
|
||||||
@ -42,6 +87,13 @@ class ItemsRepository {
|
|||||||
* @return Items based on given query
|
* @return Items based on given query
|
||||||
*/
|
*/
|
||||||
virtual std::unique_ptr< Items > search(const ItemQueryFilters & filer) const = 0;
|
virtual std::unique_ptr< Items > search(const ItemQueryFilters & filer) const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief listParameters
|
||||||
|
* @param filer
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual Parameters listParameters(const Category *) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,6 +134,11 @@ class Items {
|
|||||||
* @brief The Item class
|
* @brief The Item class
|
||||||
*/
|
*/
|
||||||
class Item {
|
class Item {
|
||||||
|
protected:
|
||||||
|
using CategoryIterator = IteratorTypeErasure::any_iterator< Category *, std::random_access_iterator_tag, Category * >;
|
||||||
|
|
||||||
|
using CategoriesIt = boost::iterator_range< CategoryIterator >;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~Item() = default;
|
virtual ~Item() = default;
|
||||||
|
|
||||||
@ -95,12 +152,19 @@ class Item {
|
|||||||
* @brief assignedUnits
|
* @brief assignedUnits
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
virtual Values assignedUnits() const = 0;
|
virtual Values values() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief assignedParameters
|
* @brief attachedToCategories
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
virtual Parameters assignedParameters() const = 0;
|
virtual CategoriesIt attachedToCategories() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief attach
|
||||||
|
* @param category
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual bool attach(const Category * category) = 0;
|
||||||
};
|
};
|
||||||
} // namespace eedb
|
} // namespace eedb
|
||||||
|
|||||||
36
src/libs/eedb/include/eedb/db/Parameter.hpp
Normal file
36
src/libs/eedb/include/eedb/db/Parameter.hpp
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
#include <eedb/Unit.hpp>
|
||||||
|
|
||||||
|
namespace eedb {
|
||||||
|
|
||||||
|
class Parameters{};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The Parameter class
|
||||||
|
*/
|
||||||
|
class Parameter {
|
||||||
|
public:
|
||||||
|
virtual ~Parameter() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief unit
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual std::optional< Unit > unit() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual std::string_view name() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief description
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual std::string_view description() const = 0;
|
||||||
|
};
|
||||||
|
} // namespace eedb
|
||||||
@ -5,17 +5,16 @@
|
|||||||
#define CATEGORIESMOCK_HPP
|
#define CATEGORIESMOCK_HPP
|
||||||
|
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include "././eedb/db/Category.hpp"
|
|
||||||
|
#include <eedb/db/Category.hpp>
|
||||||
|
|
||||||
namespace eedb {
|
namespace eedb {
|
||||||
|
|
||||||
class CategoriesMock : public Categories
|
class CategoriesMock : public Categories {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
MOCK_CONST_METHOD0(size, long());
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace eedb
|
} // namespace eedb
|
||||||
|
|
||||||
#endif // CATEGORIESMOCK_HPP
|
#endif // CATEGORIESMOCK_HPP
|
||||||
|
|
||||||
|
|||||||
@ -5,14 +5,18 @@
|
|||||||
#define CATEGORYMOCK_HPP
|
#define CATEGORYMOCK_HPP
|
||||||
|
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include "././eedb/db/Category.hpp"
|
|
||||||
|
#include <eedb/db/Category.hpp>
|
||||||
|
|
||||||
namespace eedb {
|
namespace eedb {
|
||||||
|
|
||||||
class CategoryMock : public Category
|
class CategoryMock : public Category
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MOCK_CONST_METHOD0(parent, Category*());
|
MOCK_CONST_METHOD0(displayName, std::string_view());
|
||||||
|
MOCK_CONST_METHOD0(parent, Category *());
|
||||||
|
MOCK_CONST_METHOD2(create, std::unique_ptr< Category >(std::string, std::string));
|
||||||
|
MOCK_CONST_METHOD0(children, std::unique_ptr< Categories >());
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace eedb
|
} // namespace eedb
|
||||||
|
|||||||
@ -5,17 +5,21 @@
|
|||||||
#define ITEMMOCK_HPP
|
#define ITEMMOCK_HPP
|
||||||
|
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include "././eedb/db/Item.hpp"
|
|
||||||
|
#include <eedb/db/Item.hpp>
|
||||||
|
|
||||||
|
#include <eedb/Value.hpp>
|
||||||
|
#include <eedb/db/Parameter.hpp>
|
||||||
|
|
||||||
namespace eedb {
|
namespace eedb {
|
||||||
|
|
||||||
class ItemMock : public Item
|
class ItemMock : public Item {
|
||||||
{
|
public:
|
||||||
public:
|
MOCK_CONST_METHOD0(displayName, std::string_view());
|
||||||
MOCK_CONST_METHOD0(values, Values&());
|
MOCK_CONST_METHOD0(assignedUnits, Values());
|
||||||
|
MOCK_CONST_METHOD0(assignedParameters, Parameters());
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace eedb
|
} // namespace eedb
|
||||||
|
|
||||||
#endif // ITEMMOCK_HPP
|
#endif // ITEMMOCK_HPP
|
||||||
|
|
||||||
|
|||||||
16
src/libs/eedb/mock/include/eedb/mock/db/ParameterMock.hpp
Normal file
16
src/libs/eedb/mock/include/eedb/mock/db/ParameterMock.hpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <gmock/gmock.h>
|
||||||
|
|
||||||
|
#include <eedb/db/Parameter.hpp>
|
||||||
|
|
||||||
|
namespace eedb {
|
||||||
|
|
||||||
|
class ParameterMock : public Parameter {
|
||||||
|
public:
|
||||||
|
MOCK_CONST_METHOD0(unit, std::optional< Unit >());
|
||||||
|
MOCK_CONST_METHOD0(name, std::string_view());
|
||||||
|
MOCK_CONST_METHOD0(description, std::string_view());
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace eedb
|
||||||
Loading…
Reference in New Issue
Block a user