X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/73f478b15a61946b2c78843b968ba69b95551c09..80aca6d78d4ff5d514216fe96c44e2ee75c4e933:/projects/stargazer/plugins/store/mysql/mysql_store.h diff --git a/projects/stargazer/plugins/store/mysql/mysql_store.h b/projects/stargazer/plugins/store/mysql/mysql_store.h index 25cf5a3d..61a13203 100644 --- a/projects/stargazer/plugins/store/mysql/mysql_store.h +++ b/projects/stargazer/plugins/store/mysql/mysql_store.h @@ -1,150 +1,142 @@ - /* - $Revision: 1.5 $ - $Date: 2010/10/07 19:45:52 $ - */ +#pragma once - -#ifndef MYSQL_STORE_H -#define MYSQL_STORE_H - -#include - -#include - -#include "stg/module_settings.h" #include "stg/store.h" +#include "stg/module_settings.h" #include "stg/user_traff.h" #include "stg/logger.h" -using namespace std; -//----------------------------------------------------------------------------- -extern "C" STORE * GetStore(); +#include +#include +#include + +#include + //----------------------------------------------------------------------------- class MYSQL_STORE_SETTINGS { public: MYSQL_STORE_SETTINGS(); virtual ~MYSQL_STORE_SETTINGS() {} - virtual int ParseSettings(const MODULE_SETTINGS & s); - virtual const string & GetStrError() const { return errorStr; } + virtual int ParseSettings(const STG::ModuleSettings & s); + virtual const std::string & GetStrError() const { return errorStr; } - const string & GetDBUser() const { return dbUser; } - const string & GetDBPassword() const { return dbPass; } - const string & GetDBHost() const { return dbHost; } - const string & GetDBName() const { return dbName; } + const std::string & GetDBUser() const { return dbUser; } + const std::string & GetDBPassword() const { return dbPass; } + const std::string & GetDBHost() const { return dbHost; } + const std::string & GetDBName() const { return dbName; } + unsigned int GetDBPort() const { return dbPort; } private: MYSQL_STORE_SETTINGS(const MYSQL_STORE_SETTINGS & rvalue); MYSQL_STORE_SETTINGS & operator=(const MYSQL_STORE_SETTINGS & rvalue); - const MODULE_SETTINGS * settings; + const STG::ModuleSettings * settings; - int ParseParam(const vector & moduleParams, - const string & name, string & result); + int ParseParam(const std::vector & moduleParams, + const std::string & name, std::string & result); - string errorStr; + std::string errorStr; - string dbUser; - string dbPass; - string dbName; - string dbHost; + std::string dbUser; + std::string dbPass; + std::string dbName; + std::string dbHost; + unsigned int dbPort; }; //----------------------------------------------------------------------------- -class MYSQL_STORE: public STORE +class MYSQL_STORE: public STG::Store { public: MYSQL_STORE(); - virtual ~MYSQL_STORE() {} - virtual const string & GetStrError() const { return errorStr; } + const std::string & GetStrError() const override { return errorStr; } //User - virtual int GetUsersList(vector * usersList) const; - virtual int AddUser(const string & login) const; - virtual int DelUser(const string & login) const; - virtual int SaveUserStat(const USER_STAT & stat, const string & login) const; - virtual int SaveUserConf(const USER_CONF & conf, const string & login) const; - virtual int RestoreUserStat(USER_STAT * stat, const string & login) const; - virtual int RestoreUserConf(USER_CONF * conf, const string & login) const; - virtual int WriteUserChgLog(const string & login, - const string & admLogin, - uint32_t admIP, - const string & paramName, - const string & oldValue, - const string & newValue, - const string & message = "") const; - virtual int WriteUserConnect(const string & login, uint32_t ip) const; - virtual int WriteUserDisconnect(const string & login, - const DIR_TRAFF & up, - const DIR_TRAFF & down, - const DIR_TRAFF & sessionUp, - const DIR_TRAFF & sessionDown, - double cash, - double freeMb, - const std::string & reason) const; - - virtual int WriteDetailedStat(const map & statTree, - time_t lastStat, - const string & login) const; - - virtual int AddMessage(STG_MSG * msg, const string & login) const; - virtual int EditMessage(const STG_MSG & msg, const string & login) const; - virtual int GetMessage(uint64_t id, STG_MSG * msg, const string & login) const; - virtual int DelMessage(uint64_t id, const string & login) const; - virtual int GetMessageHdrs(vector * hdrsList, const string & login) const; - - virtual int SaveMonthStat(const USER_STAT & stat, int month, int year, const string & login) const; + int GetUsersList(std::vector * usersList) const override; + int AddUser(const std::string & login) const override; + int DelUser(const std::string & login) const override; + int SaveUserStat(const STG::UserStat & stat, const std::string & login) const override; + int SaveUserConf(const STG::UserConf & conf, const std::string & login) const override; + int RestoreUserStat(STG::UserStat * stat, const std::string & login) const override; + int RestoreUserConf(STG::UserConf * conf, const std::string & login) const override; + int WriteUserChgLog(const std::string & login, + const std::string & admLogin, + uint32_t admIP, + const std::string & paramName, + const std::string & oldValue, + const std::string & newValue, + const std::string & message = "") const override; + int WriteUserConnect(const std::string & login, uint32_t ip) const override; + int WriteUserDisconnect(const std::string & login, + const STG::DirTraff & up, + const STG::DirTraff & down, + const STG::DirTraff & sessionUp, + const STG::DirTraff & sessionDown, + double cash, + double freeMb, + const std::string & reason) const override; + + int WriteDetailedStat(const STG::TraffStat & statTree, + time_t lastStat, + const std::string & login) const override; + + int AddMessage(STG::Message * msg, const std::string & login) const override; + int EditMessage(const STG::Message & msg, const std::string & login) const override; + int GetMessage(uint64_t id, STG::Message * msg, const std::string & login) const override; + int DelMessage(uint64_t id, const std::string & login) const override; + int GetMessageHdrs(std::vector * hdrsList, const std::string & login) const override; + + int SaveMonthStat(const STG::UserStat & stat, int month, int year, const std::string & login) const override; //Admin - virtual int GetAdminsList(vector * adminsList) const; - virtual int AddAdmin(const string & login) const; - virtual int DelAdmin(const string & login) const; - virtual int RestoreAdmin(ADMIN_CONF * ac, const string & login) const; - virtual int SaveAdmin(const ADMIN_CONF & ac) const; + int GetAdminsList(std::vector * adminsList) const override; + int AddAdmin(const std::string & login) const override; + int DelAdmin(const std::string & login) const override; + int RestoreAdmin(STG::AdminConf * ac, const std::string & login) const override; + int SaveAdmin(const STG::AdminConf & ac) const override; //Tariff - virtual int GetTariffsList(vector * tariffsList) const; - virtual int AddTariff(const string & name) const; - virtual int DelTariff(const string & name) const; - virtual int SaveTariff(const TARIFF_DATA & td, const string & tariffName) const; - virtual int RestoreTariff(TARIFF_DATA * td, const string & tariffName) const; + int GetTariffsList(std::vector * tariffsList) const override; + int AddTariff(const std::string & name) const override; + int DelTariff(const std::string & name) const override; + int SaveTariff(const STG::TariffData & td, const std::string & tariffName) const override; + int RestoreTariff(STG::TariffData * td, const std::string & tariffName) const override; //Corparation - virtual int GetCorpsList(vector *) const {return 0;}; - virtual int SaveCorp(const CORP_CONF &) const {return 0;}; - virtual int RestoreCorp(CORP_CONF *, const string &) const {return 0;}; - virtual int AddCorp(const string &) const {return 0;}; - virtual int DelCorp(const string &) const {return 0;}; + int GetCorpsList(std::vector *) const override {return 0;} + int SaveCorp(const STG::CorpConf &) const override {return 0;} + int RestoreCorp(STG::CorpConf *, const std::string &) const override {return 0;} + int AddCorp(const std::string &) const override {return 0;} + int DelCorp(const std::string &) const override {return 0;} // Services - virtual int GetServicesList(vector *) const {return 0;}; - virtual int SaveService(const SERVICE_CONF &) const {return 0;}; - virtual int RestoreService(SERVICE_CONF *, const string &) const {return 0;}; - virtual int AddService(const string &) const {return 0;}; - virtual int DelService(const string &) const {return 0;}; + int GetServicesList(std::vector *) const override {return 0;} + int SaveService(const STG::ServiceConf &) const override {return 0;} + int RestoreService(STG::ServiceConf *, const std::string &) const override {return 0;} + int AddService(const std::string &) const override {return 0;} + int DelService(const std::string &) const override {return 0;} - virtual void SetSettings(const MODULE_SETTINGS & s) { settings = s; } - virtual int ParseSettings(); - virtual const string & GetVersion() const { return version; } + void SetSettings(const STG::ModuleSettings & s) override { settings = s; } + int ParseSettings() override; + const std::string & GetVersion() const override { return version; } private: MYSQL_STORE(const MYSQL_STORE & rvalue); MYSQL_STORE & operator=(const MYSQL_STORE & rvalue); - virtual int WriteLogString(const string & str, const string & login) const; - int GetAllParams(vector * ParamList, const string & table, const string & name) const; + virtual int WriteLogString(const std::string & str, const std::string & login) const; + int GetAllParams(std::vector * ParamList, const std::string & table, const std::string & name) const; int CheckAllTables(MYSQL * sock); - bool IsTablePresent(const string & str,MYSQL * sock); - mutable string errorStr; + int MakeUpdates(MYSQL * sock); + bool IsTablePresent(const std::string & str,MYSQL * sock); + mutable std::string errorStr; int MysqlQuery(const char* sQuery,MYSQL * sock) const; int MysqlGetQuery(const char * Query,MYSQL * & sock) const; int MysqlSetQuery(const char * Query) const; MYSQL * MysqlConnect() const ; - string version; + std::string version; MYSQL_STORE_SETTINGS storeSettings; - MODULE_SETTINGS settings; + STG::ModuleSettings settings; + int schemaVersion; - PLUGIN_LOGGER logger; + STG::PluginLogger logger; }; -//----------------------------------------------------------------------------- - -#endif