Older/Server/Database/Database.h

29 lines
638 B
C
Raw Normal View History

2023-12-30 00:15:03 +08:00
#ifndef __DATABASE_H__
#define __DATABASE_H__
2023-12-30 01:19:36 +08:00
#include "Singleton.h"
2024-01-03 22:44:36 +08:00
#include "Task.h"
2023-12-30 00:15:03 +08:00
#include <string>
2023-12-30 01:19:36 +08:00
struct sqlite3;
2023-12-30 00:15:03 +08:00
class Database {
2023-12-30 01:19:36 +08:00
friend class Amass::Singleton<Database>;
2023-12-30 00:15:03 +08:00
public:
2023-12-30 01:19:36 +08:00
~Database();
2023-12-30 00:15:03 +08:00
bool open(const std::string &path);
2024-01-03 22:44:36 +08:00
Tasks tasks();
2024-01-04 23:32:07 +08:00
bool addTask(uint64_t createTime, const std::string &content, const std::string &comment = "", int parentId = -1,
2024-01-03 22:44:36 +08:00
bool finished = false);
bool removeTask(int id);
2023-12-30 01:19:36 +08:00
void setTaskFinished(int id, bool finished, uint64_t finishedTime);
protected:
void initialize();
private:
sqlite3 *m_sqlite3 = nullptr;
2023-12-30 00:15:03 +08:00
};
#endif // __DATABASE_H__