feat: 初始代码
AM初始代码,迁移自gitlabwh Log: Task: https://pms.uniontech.com/task-view-108539.html Influence: Change-Id: I6096f97e5d68d13796ff5dc51d9858c0f40264a0
This commit is contained in:
18
src/modules/methods/basic.h
Normal file
18
src/modules/methods/basic.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef BASIC_H_
|
||||
#define BASIC_H_
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace Methods {
|
||||
struct Basic {
|
||||
std::string type;
|
||||
};
|
||||
|
||||
using json = nlohmann::json;
|
||||
inline void from_json(const json &j, Basic &basic) {
|
||||
j.at("type").get_to(basic.type);
|
||||
}
|
||||
|
||||
} // namespace Methods
|
||||
|
||||
#endif // BASIC_H_
|
25
src/modules/methods/instance.hpp
Normal file
25
src/modules/methods/instance.hpp
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef C664E26D_6517_412B_950F_07E20963349E
|
||||
#define C664E26D_6517_412B_950F_07E20963349E
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace Methods {
|
||||
struct Instance {
|
||||
std::string hash;
|
||||
std::string type{ "instance" };
|
||||
};
|
||||
|
||||
using json = nlohmann::json;
|
||||
inline void to_json(json &j, const Instance &instance)
|
||||
{
|
||||
j = json{ { "type", instance.type }, { "hash", instance.hash } };
|
||||
}
|
||||
|
||||
inline void from_json(const json &j, Instance &instance)
|
||||
{
|
||||
j.at("hash").get_to(instance.hash);
|
||||
}
|
||||
|
||||
} // namespace Methods
|
||||
|
||||
#endif /* C664E26D_6517_412B_950F_07E20963349E */
|
27
src/modules/methods/quit.hpp
Normal file
27
src/modules/methods/quit.hpp
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef QUIT_H_
|
||||
#define QUIT_H_
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace Methods {
|
||||
struct Quit {
|
||||
std::string date;
|
||||
std::string type{ "quit" };
|
||||
std::string id;
|
||||
int code;
|
||||
};
|
||||
using json = nlohmann::json;
|
||||
inline void to_json(json &j, const Quit &quit)
|
||||
{
|
||||
j = json{ { "type", quit.type }, { "date", quit.date }, { "id", quit.id }, { "code", quit.code } };
|
||||
}
|
||||
|
||||
inline void from_json(const json &j, Quit &quit)
|
||||
{
|
||||
j.at("id").get_to(quit.id);
|
||||
j.at("date").get_to(quit.date);
|
||||
j.at("code").get_to(quit.code);
|
||||
}
|
||||
} // namespace Methods
|
||||
|
||||
#endif // QUIT_H_
|
29
src/modules/methods/registe.hpp
Normal file
29
src/modules/methods/registe.hpp
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef REGISTER_H_
|
||||
#define REGISTER_H_
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace Methods {
|
||||
struct Registe {
|
||||
std::string date;
|
||||
std::string id;
|
||||
std::string type{ "registe" };
|
||||
std::string hash;
|
||||
bool state;
|
||||
};
|
||||
|
||||
using json = nlohmann::json;
|
||||
inline void to_json(json &j, const Registe ®iste)
|
||||
{
|
||||
j = json{ { "type", registe.type }, { "id", registe.id }, { "hash", registe.hash }, { "state", registe.state }, { "date", registe.date } };
|
||||
}
|
||||
inline void from_json(const json &j, Registe ®iste)
|
||||
{
|
||||
j.at("id").get_to(registe.id);
|
||||
j.at("date").get_to(registe.date);
|
||||
j.at("hash").get_to(registe.hash);
|
||||
j.at("state").get_to(registe.state);
|
||||
}
|
||||
} // namespace Methods
|
||||
|
||||
#endif // REGISTER_H_
|
36
src/modules/methods/task.hpp
Normal file
36
src/modules/methods/task.hpp
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef B0B88BD6_CF1E_4E87_926A_E6DBE6B9B19C
|
||||
#define B0B88BD6_CF1E_4E87_926A_E6DBE6B9B19C
|
||||
|
||||
#include <map>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace Methods {
|
||||
struct Task {
|
||||
std::string id;
|
||||
std::string runId;
|
||||
std::string type{ "task" };
|
||||
std::string date;
|
||||
std::vector<std::string> arguments;
|
||||
std::multimap<std::string, std::string> environments;
|
||||
};
|
||||
|
||||
using json = nlohmann::json;
|
||||
inline void to_json(json &j, const Task &task)
|
||||
{
|
||||
j = json{ { "type", task.type }, { "id", task.id }, { "run_id", task.runId }, { "date", task.date }, { "arguments", task.arguments }, { "environments", task.environments } };
|
||||
}
|
||||
|
||||
inline void from_json(const json &j, Task &task)
|
||||
{
|
||||
j.at("id").get_to(task.id);
|
||||
j.at("run_id").get_to(task.runId);
|
||||
j.at("date").get_to(task.date);
|
||||
j.at("arguments").get_to(task.arguments);
|
||||
j.at("environments").get_to(task.environments);
|
||||
}
|
||||
|
||||
} // namespace Methods
|
||||
|
||||
#endif /* B0B88BD6_CF1E_4E87_926A_E6DBE6B9B19C */
|
Reference in New Issue
Block a user