Older/Database/Task.h

33 lines
792 B
C
Raw Normal View History

2024-01-03 22:44:36 +08:00
#ifndef __TASK_H__
#define __TASK_H__
2024-11-26 22:58:54 +08:00
#include <Wt/Dbo/Dbo.h>
2024-11-27 00:08:24 +08:00
#include <Wt/Dbo/StdSqlTraits.h>
2024-01-03 22:44:36 +08:00
#include <string>
2024-01-04 23:32:07 +08:00
class Task;
2024-11-26 22:58:54 +08:00
using Tasks = Wt::Dbo::collection<Wt::Dbo::ptr<Task>>;
2024-01-04 23:32:07 +08:00
2024-01-03 22:44:36 +08:00
class Task {
public:
bool finished = false;
2024-11-27 00:08:24 +08:00
std::chrono::system_clock::time_point createTime;
2024-01-03 22:44:36 +08:00
std::string content;
std::string comment;
2024-11-26 22:58:54 +08:00
Wt::Dbo::ptr<Task> parent;
2024-01-04 23:32:07 +08:00
Tasks children;
2024-11-26 19:31:09 +08:00
template <class Action>
void persist(Action &a) {
2024-11-26 22:58:54 +08:00
Wt::Dbo::field(a, content, "content");
Wt::Dbo::field(a, comment, "comment");
Wt::Dbo::field(a, finished, "finished");
Wt::Dbo::field(a, createTime, "create_time");
Wt::Dbo::belongsTo(a, parent, "parent");
Wt::Dbo::hasMany(a, children, Wt::Dbo::ManyToOne, "parent");
2024-11-26 19:31:09 +08:00
}
2024-01-03 22:44:36 +08:00
};
#endif // __TASK_H__