query/demo/work/admin/CollectionCenter.hpp

49 lines
1.4 KiB
C++

#ifndef COLLECTION_CENTER_HPP
#define COLLECTION_CENTER_HPP
#include "../core/Model.hpp"
#include "matador/object/collection.hpp"
#include "matador/object/object_ptr.hpp"
#include "matador/utils/base_class.hpp"
#include "matador/utils/enum_mapper.hpp"
#include "matador/utils/fetch_type.hpp"
#include "matador/utils/types.hpp"
namespace work::models::admin {
struct User;
enum class CollectionCenterType : uint8_t {
NoType,
Core,
Unit
};
static const matador::utils::enum_mapper<CollectionCenterType> CollectionCenterTypeEnum({
{CollectionCenterType::NoType, "NoType"},
{CollectionCenterType::Core, "Core"},
{CollectionCenterType::Unit, "Unit"}
});
struct CollectionCenter : core::Model {
std::string name;
matador::utils::blob symbol;
CollectionCenterType type{CollectionCenterType::NoType};
matador::object::collection<matador::object::object_ptr<User>> users;
template<typename Operator>
void process( Operator& op ) {
namespace field = matador::access;
field::process( op, *matador::base_class<Model>( this ) );
field::attribute( op, "name", name, 511 );
field::attribute( op, "symbol", symbol );
field::attribute( op, "type", type );
field::has_many( op, "collection_center_users", users, "collection_center_id", matador::utils::fetch_type::LAZY );
}
};
}
#endif //COLLECTION_CENTER_HPP