added some more entities for work demo
This commit is contained in:
@@ -38,7 +38,7 @@ struct CollectionCenter : core::Model {
|
||||
field::attribute( op, "name", name, 511 );
|
||||
field::attribute( op, "symbol", symbol );
|
||||
field::attribute( op, "type", type );
|
||||
field::has_many( op, "users", users, "collection_center_id", matador::utils::fetch_type::LAZY );
|
||||
field::has_many( op, "collection_center_users", users, "collection_center_id", matador::utils::fetch_type::LAZY );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef USERINFO_HPP
|
||||
#define USERINFO_HPP
|
||||
|
||||
#include "matador/utils/access.hpp"
|
||||
|
||||
namespace work::core {
|
||||
struct UserInfo {
|
||||
unsigned long long user_session_id;
|
||||
std::string user_role;
|
||||
std::string database_name;
|
||||
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
namespace field = matador::access;
|
||||
field::attribute( op, "user_session_id", user_session_id );
|
||||
field::attribute( op, "user_role", user_role, 255 );
|
||||
field::attribute( op, "database_name", database_name, 255 );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif //USERINFO_HPP
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef ID_LIST_PAYLOAD_HPP
|
||||
#define ID_LIST_PAYLOAD_HPP
|
||||
|
||||
#include "Payload.hpp"
|
||||
|
||||
#include "matador/object/collection.hpp"
|
||||
|
||||
namespace work::models::jobs {
|
||||
struct IdListPayload : Payload {
|
||||
matador::object::collection<unsigned long long> ids;
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
namespace field = matador::access;
|
||||
field::process( op, *matador::base_class<Payload>( this ) );
|
||||
field::has_many( op, "payload_ids", ids );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif //ID_LIST_PAYLOAD_HPP
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef ID_PAYLOAD_HPP
|
||||
#define ID_PAYLOAD_HPP
|
||||
|
||||
#include "Payload.hpp"
|
||||
|
||||
namespace work::models::jobs {
|
||||
struct IdPayload : Payload {
|
||||
unsigned long long id;
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
namespace field = matador::access;
|
||||
field::process( op, *matador::base_class<Payload>( this ) );
|
||||
field::attribute( op, "id", id );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif //ID_PAYLOAD_HPP
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef JOB_HPP
|
||||
#define JOB_HPP
|
||||
|
||||
#include "JobMode.hpp"
|
||||
#include "JobState.hpp"
|
||||
#include "Payload.hpp"
|
||||
#include "Task.hpp"
|
||||
|
||||
#include "../core/Model.hpp"
|
||||
#include "../core/Types.hpp"
|
||||
#include "../core/UserInfo.hpp"
|
||||
|
||||
#include "matador/object/object_ptr.hpp"
|
||||
|
||||
#include "matador/utils/base_class.hpp"
|
||||
|
||||
namespace work::models::jobs {
|
||||
|
||||
struct Job : core::Model {
|
||||
std::string name;
|
||||
std::string description;
|
||||
JobState state;
|
||||
JobMode mode;
|
||||
core::timestamp created_at;
|
||||
matador::object::object_ptr<Payload> payload;
|
||||
matador::object::object_ptr<Task> task;
|
||||
core::UserInfo user_info;
|
||||
|
||||
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, "description", description, 511 );
|
||||
field::attribute( op, "state", state );
|
||||
field::attribute( op, "mode", mode );
|
||||
field::attribute( op, "created_at", created_at );
|
||||
field::belongs_to( op, "payload", payload, matador::utils::default_foreign_attributes );
|
||||
field::belongs_to( op, "task", task, matador::utils::default_foreign_attributes );
|
||||
field::attribute( op, "user_info", user_info );
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //JOB_HPP
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef JOB_MODE_HPP
|
||||
#define JOB_MODE_HPP
|
||||
|
||||
#include "matador/utils/enum_mapper.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace work::models::jobs {
|
||||
enum class JobMode : uint8_t {
|
||||
Background,
|
||||
Foreground
|
||||
};
|
||||
|
||||
static const matador::utils::enum_mapper<JobMode> JobModeEnum({
|
||||
{JobMode::Background, "Background"},
|
||||
{JobMode::Foreground, "Foreground"}
|
||||
});
|
||||
}
|
||||
|
||||
#endif //JOB_MODE_HPP
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef JOB_STATE_HPP
|
||||
#define JOB_STATE_HPP
|
||||
|
||||
#include "matador/utils/enum_mapper.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace work::models::jobs {
|
||||
enum class JobState : uint8_t {
|
||||
Pending,
|
||||
Running,
|
||||
Succeeded,
|
||||
Failed,
|
||||
Cancelled
|
||||
};
|
||||
|
||||
static const matador::utils::enum_mapper<JobState> JobStateEnum({
|
||||
{JobState::Pending, "Pending"},
|
||||
{JobState::Running, "Running"},
|
||||
{JobState::Succeeded, "Succeeded"},
|
||||
{JobState::Failed, "Failed"},
|
||||
{JobState::Cancelled, "Cancelled"}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif //JOB_STATE_HPP
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef PAYLOAD_HPP
|
||||
#define PAYLOAD_HPP
|
||||
|
||||
#include "../core/Model.hpp"
|
||||
|
||||
#include "matador/utils/base_class.hpp"
|
||||
|
||||
namespace work::models::jobs {
|
||||
struct Payload : core::Model {
|
||||
std::string type;
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
namespace field = matador::access;
|
||||
field::process( op, *matador::base_class<Model>( this ) );
|
||||
field::attribute( op, "type", type, 255 );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif //PAYLOAD_HPP
|
||||
@@ -0,0 +1,42 @@
|
||||
#ifndef TASK_HPP
|
||||
#define TASK_HPP
|
||||
|
||||
#include "TaskState.hpp"
|
||||
|
||||
#include "../core/Model.hpp"
|
||||
#include "../core/Types.hpp"
|
||||
|
||||
#include "matador/object/object_ptr.hpp"
|
||||
|
||||
#include "matador/utils/base_class.hpp"
|
||||
|
||||
namespace work::models::jobs {
|
||||
struct Task : core::Model {
|
||||
std::string name;
|
||||
std::string description;
|
||||
std::string job_name;
|
||||
TaskState state;
|
||||
matador::object::object_ptr<Payload> payload;
|
||||
JobMode job_mode;
|
||||
core::timestamp start_delay;
|
||||
core::timestamp interval;
|
||||
unsigned long long user_session_id;
|
||||
|
||||
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, "description", description, 511 );
|
||||
field::attribute( op, "job_name", job_name, 511 );
|
||||
field::attribute( op, "state", state );
|
||||
field::belongs_to( op, "payload", payload, matador::utils::default_foreign_attributes );
|
||||
field::attribute( op, "job_mode", job_mode );
|
||||
field::attribute( op, "start_delay", start_delay );
|
||||
field::attribute( op, "interval", interval );
|
||||
field::attribute( op, "user_session_id", user_session_id );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif //TASK_HPP
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef TASK_STATE_HPP
|
||||
#define TASK_STATE_HPP
|
||||
|
||||
#include "matador/utils/enum_mapper.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace work::models::jobs {
|
||||
enum class TaskState : uint8_t {
|
||||
Active,
|
||||
Inactive
|
||||
};
|
||||
|
||||
static const matador::utils::enum_mapper<TaskState> TaskStateEnum({
|
||||
{TaskState::Active, "Active"},
|
||||
{TaskState::Inactive, "Inactive"}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif //TASK_STATE_HPP
|
||||
Reference in New Issue
Block a user