-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdao.h
More file actions
122 lines (83 loc) · 2.56 KB
/
Copy pathdao.h
File metadata and controls
122 lines (83 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#pragma once
#include <mariadb/conncpp.hpp>
#include <string>
#include <sstream>
#include <format>
#include <vector>
#include "vo.h"
inline std::chrono::system_clock::time_point fromMySQLDateTime(const sql::SQLString& dt) {
std::chrono::system_clock::time_point tp;
std::istringstream ss(dt.c_str());
std::chrono::from_stream(ss, "%Y-%m-%d %H:%M:%S", tp);
return tp;
}
inline std::string toMySQLDateTime(const std::chrono::system_clock::time_point& tp) {
return std::format("{:%Y-%m-%d %H:%M:%S}", tp);
}
class PlayerDAO {
public:
PlayerDAO(sql::Connection* conn);
void Insert(const PlayerVO& vo);
void Update(const PlayerVO& vo);
void Delete(const PlayerVO& vo);
// Select by primary key
bool Select(int id, PlayerVO& out_vo);
// Select by index columns (if any)
private:
sql::Connection* conn_;
};
// ----------------------------------------
class ItemDAO {
public:
ItemDAO(sql::Connection* conn);
void Insert(const ItemVO& vo);
void Update(const ItemVO& vo);
void Delete(const ItemVO& vo);
// Select by primary key
bool Select(int id, ItemVO& out_vo);
// Select by index columns (if any)
std::vector<ItemVO> SelectByIndex(int player_id);
private:
sql::Connection* conn_;
};
// ----------------------------------------
class SkillDAO {
public:
SkillDAO(sql::Connection* conn);
void Insert(const SkillVO& vo);
void Update(const SkillVO& vo);
void Delete(const SkillVO& vo);
// Select by primary key
bool Select(int id, SkillVO& out_vo);
// Select by index columns (if any)
std::vector<SkillVO> SelectByIndex(int player_id);
private:
sql::Connection* conn_;
};
// ----------------------------------------
class QuestActiveDAO {
public:
QuestActiveDAO(sql::Connection* conn);
void Insert(const QuestActiveVO& vo);
void Update(const QuestActiveVO& vo);
void Delete(const QuestActiveVO& vo);
// Select by primary key
bool Select(int character_id, int quest_id, QuestActiveVO& out_vo);
// Select by index columns (if any)
std::vector<QuestActiveVO> SelectByIndex(int character_id);
private:
sql::Connection* conn_;
};
// ----------------------------------------
class QuestStateDAO {
public:
QuestStateDAO(sql::Connection* conn);
void Insert(const QuestStateVO& vo);
void Update(const QuestStateVO& vo);
void Delete(const QuestStateVO& vo);
// Select by primary key
bool Select(int character_id, QuestStateVO& out_vo);
// Select by index columns (if any)
private:
sql::Connection* conn_;
};