Files
BH-Bookstore-2023/backend/include/database.h
2023-12-13 09:30:38 +00:00

46 lines
1.5 KiB
C++

#ifndef PROTECTOR_DATABASE_HPP
#define PROTECTOR_DATABASE_HPP
#include <string>
#include <vector>
#include "bs-utility.h"
#include "drivearray.hpp"
#include "key2index.hpp"
class UserDataBase {
DriveArray<UserItemClass> full_user_data;
String2Index user_name2index;
public:
UserDataBase() = default;
void Open(std::string file_name);
bool PAM(const std::string &user_id, const std::string &password);
int GetPrevilege(const std::string &user_id);
void AddUser(const std::string &user_id, const std::string &password,
const std::string &user_name, int privilege);
void DeleteUser(const std::string &user_id);
void ChangePassword(const std::string &user_id, const std::string &password);
};
class BookDataBase {
DriveArray<BookItemClass> full_book_data;
String2Index indexer;
public:
void Open(std::string file_name);
void QueryBook(const std::string &ISBN, const std::string &name,
const std::string &author, const std::string &keyword,
std::vector<BookItemClass> &ret);
void ModifyInfo(const std::string &ISBN,const std::string &new_ISBN, const std::string &name,
const std::string &author, const std::string &keyword,
double price);
};
class LogDataBase {
DriveArray<FinanceItemClass> finance_data;
DriveArray<OperationLogItemClass> operation_log_data;
public:
void Open(std::string file_name);
void QueryFinance(int count, std::vector<FinanceItemClass> &ret);
};
#endif // PROTECTOR_DATABASE_HPP