38 lines
1.5 KiB
C++
38 lines
1.5 KiB
C++
#ifndef DATABASE_HPP
|
|
#define DATABASE_HPP
|
|
#include "types.hpp"
|
|
#include "utils.hpp"
|
|
#include <chrono>
|
|
#include <optional>
|
|
|
|
class PostgresDB {
|
|
private:
|
|
std::string conn_str;
|
|
|
|
public:
|
|
PostgresDB(const std::string& connection) : conn_str(connection) {}
|
|
|
|
User GetUser(int uid);
|
|
User GetUser(const std::string& username, const std::string& password);
|
|
void GetUser(User& user) { user = GetUser(user.uid);};
|
|
|
|
User CreateUser(const std::string& username, const std::string& password, bool is_system);
|
|
void UpdateUserPassowrd(User& user, const std::string& password);
|
|
void DeleteUser(const User& user);
|
|
|
|
void CreateMember(User& user, const std::string& name, const std::string& pronouns, const std::string& description);
|
|
void UpdateMemberDescription(Member& member, const std::string& description);
|
|
void UpdateMemberPronouns(Member& member, const std::string& pronouns);
|
|
void UpdateMemberName(Member& member, const std::string& name);
|
|
void DeleteMember(const Member& member);
|
|
|
|
void CreateAccessToken(User& user);
|
|
void DeleteAccessToken(const User& user);
|
|
User ValidateAccessToken(const std::string& token);
|
|
|
|
void StartFront(const User& user, const Member& member, const std::string& note = "", timestamp::Timestamp start_time = timestamp::Now());
|
|
void EndFront(const User& user, const Member& member, timestamp::Timestamp end_time = timestamp::Now());
|
|
std::vector<Front> GetFronts(const User& user, timestamp::Timestamp start_time, std::optional<timestamp::Timestamp> end_time = std::nullopt);
|
|
};
|
|
|
|
#endif |