mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-07 09:02:26 +00:00
commit
09e0b09649
@ -26,21 +26,24 @@
|
|||||||
#include "../../common/crash.h"
|
#include "../../common/crash.h"
|
||||||
#include "../../common/rulesys.h"
|
#include "../../common/rulesys.h"
|
||||||
#include "../../common/string_util.h"
|
#include "../../common/string_util.h"
|
||||||
|
#include "../../common/content/world_content_service.h"
|
||||||
|
|
||||||
EQEmuLogSys LogSys;
|
EQEmuLogSys LogSys;
|
||||||
|
WorldContentService content_service;
|
||||||
|
|
||||||
void ExportSpells(SharedDatabase *db);
|
void ExportSpells(SharedDatabase *db);
|
||||||
void ExportSkillCaps(SharedDatabase *db);
|
void ExportSkillCaps(SharedDatabase *db);
|
||||||
void ExportBaseData(SharedDatabase *db);
|
void ExportBaseData(SharedDatabase *db);
|
||||||
void ExportDBStrings(SharedDatabase *db);
|
void ExportDBStrings(SharedDatabase *db);
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
RegisterExecutablePlatform(ExePlatformClientExport);
|
RegisterExecutablePlatform(ExePlatformClientExport);
|
||||||
LogSys.LoadLogSettingsDefaults();
|
LogSys.LoadLogSettingsDefaults();
|
||||||
set_exception_handler();
|
set_exception_handler();
|
||||||
|
|
||||||
LogInfo("Client Files Export Utility");
|
LogInfo("Client Files Export Utility");
|
||||||
if(!EQEmuConfig::LoadConfig()) {
|
if (!EQEmuConfig::LoadConfig()) {
|
||||||
LogError("Unable to load configuration file");
|
LogError("Unable to load configuration file");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -48,14 +51,38 @@ int main(int argc, char **argv) {
|
|||||||
auto Config = EQEmuConfig::get();
|
auto Config = EQEmuConfig::get();
|
||||||
|
|
||||||
SharedDatabase database;
|
SharedDatabase database;
|
||||||
|
SharedDatabase content_db;
|
||||||
|
|
||||||
LogInfo("Connecting to database");
|
LogInfo("Connecting to database");
|
||||||
if(!database.Connect(Config->DatabaseHost.c_str(), Config->DatabaseUsername.c_str(),
|
if (!database.Connect(
|
||||||
Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort)) {
|
Config->DatabaseHost.c_str(),
|
||||||
|
Config->DatabaseUsername.c_str(),
|
||||||
|
Config->DatabasePassword.c_str(),
|
||||||
|
Config->DatabaseDB.c_str(),
|
||||||
|
Config->DatabasePort
|
||||||
|
)) {
|
||||||
LogError("Unable to connect to the database, cannot continue without a database connection");
|
LogError("Unable to connect to the database, cannot continue without a database connection");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register Log System and Settings */
|
/**
|
||||||
|
* Multi-tenancy: Content database
|
||||||
|
*/
|
||||||
|
if (!Config->ContentDbHost.empty()) {
|
||||||
|
if (!content_db.Connect(
|
||||||
|
Config->ContentDbHost.c_str() ,
|
||||||
|
Config->ContentDbUsername.c_str(),
|
||||||
|
Config->ContentDbPassword.c_str(),
|
||||||
|
Config->ContentDbName.c_str(),
|
||||||
|
Config->ContentDbPort
|
||||||
|
)) {
|
||||||
|
LogError("Cannot continue without a content database connection");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
content_db.SetMysql(database.getMySQL());
|
||||||
|
}
|
||||||
|
|
||||||
database.LoadLogSettings(LogSys.log_settings);
|
database.LoadLogSettings(LogSys.log_settings);
|
||||||
LogSys.StartFileLogs();
|
LogSys.StartFileLogs();
|
||||||
|
|
||||||
@ -66,15 +93,15 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (arg_1 == "spells") {
|
if (arg_1 == "spells") {
|
||||||
ExportSpells(&database);
|
ExportSpells(&content_db);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (arg_1 == "skills") {
|
if (arg_1 == "skills") {
|
||||||
ExportSkillCaps(&database);
|
ExportSkillCaps(&content_db);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (arg_1 == "basedata") {
|
if (arg_1 == "basedata") {
|
||||||
ExportBaseData(&database);
|
ExportBaseData(&content_db);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (arg_1 == "dbstring") {
|
if (arg_1 == "dbstring") {
|
||||||
@ -82,9 +109,9 @@ int main(int argc, char **argv) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExportSpells(&database);
|
ExportSpells(&content_db);
|
||||||
ExportSkillCaps(&database);
|
ExportSkillCaps(&content_db);
|
||||||
ExportBaseData(&database);
|
ExportBaseData(&content_db);
|
||||||
ExportDBStrings(&database);
|
ExportDBStrings(&database);
|
||||||
|
|
||||||
LogSys.CloseFileLogs();
|
LogSys.CloseFileLogs();
|
||||||
@ -92,11 +119,12 @@ int main(int argc, char **argv) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportSpells(SharedDatabase *db) {
|
void ExportSpells(SharedDatabase *db)
|
||||||
|
{
|
||||||
LogInfo("Exporting Spells");
|
LogInfo("Exporting Spells");
|
||||||
|
|
||||||
FILE *f = fopen("export/spells_us.txt", "w");
|
FILE *f = fopen("export/spells_us.txt", "w");
|
||||||
if(!f) {
|
if (!f) {
|
||||||
LogError("Unable to open export/spells_us.txt to write, skipping.");
|
LogError("Unable to open export/spells_us.txt to write, skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -104,81 +132,92 @@ void ExportSpells(SharedDatabase *db) {
|
|||||||
const std::string query = "SELECT * FROM spells_new ORDER BY id";
|
const std::string query = "SELECT * FROM spells_new ORDER BY id";
|
||||||
auto results = db->QueryDatabase(query);
|
auto results = db->QueryDatabase(query);
|
||||||
|
|
||||||
if(results.Success()) {
|
if (results.Success()) {
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
std::string line;
|
std::string line;
|
||||||
unsigned int fields = results.ColumnCount();
|
unsigned int fields = results.ColumnCount();
|
||||||
for(unsigned int i = 0; i < fields; ++i) {
|
for (unsigned int i = 0; i < fields; ++i) {
|
||||||
if(i != 0) {
|
if (i != 0) {
|
||||||
line.push_back('^');
|
line.push_back('^');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(row[i] != nullptr) {
|
if (row[i] != nullptr) {
|
||||||
line += row[i];
|
line += row[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(f, "%s\n", line.c_str());
|
fprintf(f, "%s\n", line.c_str());
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkillUsable(SharedDatabase *db, int skill_id, int class_id) {
|
bool SkillUsable(SharedDatabase *db, int skill_id, int class_id)
|
||||||
|
{
|
||||||
|
|
||||||
bool res = false;
|
bool res = false;
|
||||||
|
|
||||||
std::string query = StringFormat("SELECT max(cap) FROM skill_caps WHERE class=%d AND skillID=%d",
|
std::string query = StringFormat(
|
||||||
class_id, skill_id);
|
"SELECT max(cap) FROM skill_caps WHERE class=%d AND skillID=%d",
|
||||||
|
class_id, skill_id
|
||||||
|
);
|
||||||
auto results = db->QueryDatabase(query);
|
auto results = db->QueryDatabase(query);
|
||||||
if(!results.Success()) {
|
if (!results.Success()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (results.RowCount() == 0)
|
if (results.RowCount() == 0) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto row = results.begin();
|
auto row = results.begin();
|
||||||
if(row[0] && atoi(row[0]) > 0)
|
if (row[0] && atoi(row[0]) > 0) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetSkill(SharedDatabase *db, int skill_id, int class_id, int level) {
|
int GetSkill(SharedDatabase *db, int skill_id, int class_id, int level)
|
||||||
|
{
|
||||||
|
|
||||||
std::string query = StringFormat("SELECT cap FROM skill_caps WHERE class=%d AND skillID=%d AND level=%d",
|
std::string query = StringFormat(
|
||||||
class_id, skill_id, level);
|
"SELECT cap FROM skill_caps WHERE class=%d AND skillID=%d AND level=%d",
|
||||||
|
class_id, skill_id, level
|
||||||
|
);
|
||||||
auto results = db->QueryDatabase(query);
|
auto results = db->QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (results.RowCount() == 0)
|
if (results.RowCount() == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
auto row = results.begin();
|
auto row = results.begin();
|
||||||
return atoi(row[0]);
|
return atoi(row[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportSkillCaps(SharedDatabase *db) {
|
void ExportSkillCaps(SharedDatabase *db)
|
||||||
|
{
|
||||||
LogInfo("Exporting Skill Caps");
|
LogInfo("Exporting Skill Caps");
|
||||||
|
|
||||||
FILE *f = fopen("export/SkillCaps.txt", "w");
|
FILE *f = fopen("export/SkillCaps.txt", "w");
|
||||||
if(!f) {
|
if (!f) {
|
||||||
LogError("Unable to open export/SkillCaps.txt to write, skipping.");
|
LogError("Unable to open export/SkillCaps.txt to write, skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int cl = 1; cl <= 16; ++cl) {
|
for (int cl = 1; cl <= 16; ++cl) {
|
||||||
for(int skill = 0; skill <= 77; ++skill) {
|
for (int skill = 0; skill <= 77; ++skill) {
|
||||||
if(SkillUsable(db, skill, cl)) {
|
if (SkillUsable(db, skill, cl)) {
|
||||||
int previous_cap = 0;
|
int previous_cap = 0;
|
||||||
for(int level = 1; level <= 100; ++level) {
|
for (int level = 1; level <= 100; ++level) {
|
||||||
int cap = GetSkill(db, skill, cl, level);
|
int cap = GetSkill(db, skill, cl, level);
|
||||||
if(cap < previous_cap) {
|
if (cap < previous_cap) {
|
||||||
cap = previous_cap;
|
cap = previous_cap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,26 +231,28 @@ void ExportSkillCaps(SharedDatabase *db) {
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportBaseData(SharedDatabase *db) {
|
void ExportBaseData(SharedDatabase *db)
|
||||||
|
{
|
||||||
LogInfo("Exporting Base Data");
|
LogInfo("Exporting Base Data");
|
||||||
|
|
||||||
FILE *f = fopen("export/BaseData.txt", "w");
|
FILE *f = fopen("export/BaseData.txt", "w");
|
||||||
if(!f) {
|
if (!f) {
|
||||||
LogError("Unable to open export/BaseData.txt to write, skipping.");
|
LogError("Unable to open export/BaseData.txt to write, skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string query = "SELECT * FROM base_data ORDER BY level, class";
|
const std::string query = "SELECT * FROM base_data ORDER BY level, class";
|
||||||
auto results = db->QueryDatabase(query);
|
auto results = db->QueryDatabase(query);
|
||||||
if(results.Success()) {
|
if (results.Success()) {
|
||||||
for (auto row = results.begin();row != results.end();++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
std::string line;
|
std::string line;
|
||||||
unsigned int fields = results.ColumnCount();
|
unsigned int fields = results.ColumnCount();
|
||||||
for(unsigned int rowIndex = 0; rowIndex < fields; ++rowIndex) {
|
for (unsigned int rowIndex = 0; rowIndex < fields; ++rowIndex) {
|
||||||
if(rowIndex != 0)
|
if (rowIndex != 0) {
|
||||||
line.push_back('^');
|
line.push_back('^');
|
||||||
|
}
|
||||||
|
|
||||||
if(row[rowIndex] != nullptr) {
|
if (row[rowIndex] != nullptr) {
|
||||||
line += row[rowIndex];
|
line += row[rowIndex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -223,11 +264,12 @@ void ExportBaseData(SharedDatabase *db) {
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportDBStrings(SharedDatabase *db) {
|
void ExportDBStrings(SharedDatabase *db)
|
||||||
|
{
|
||||||
LogInfo("Exporting DB Strings");
|
LogInfo("Exporting DB Strings");
|
||||||
|
|
||||||
FILE *f = fopen("export/dbstr_us.txt", "w");
|
FILE *f = fopen("export/dbstr_us.txt", "w");
|
||||||
if(!f) {
|
if (!f) {
|
||||||
LogError("Unable to open export/dbstr_us.txt to write, skipping.");
|
LogError("Unable to open export/dbstr_us.txt to write, skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -235,15 +277,16 @@ void ExportDBStrings(SharedDatabase *db) {
|
|||||||
fprintf(f, "Major^Minor^String(New)\n");
|
fprintf(f, "Major^Minor^String(New)\n");
|
||||||
const std::string query = "SELECT * FROM db_str ORDER BY id, type";
|
const std::string query = "SELECT * FROM db_str ORDER BY id, type";
|
||||||
auto results = db->QueryDatabase(query);
|
auto results = db->QueryDatabase(query);
|
||||||
if(results.Success()) {
|
if (results.Success()) {
|
||||||
for(auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
std::string line;
|
std::string line;
|
||||||
unsigned int fields = results.ColumnCount();
|
unsigned int fields = results.ColumnCount();
|
||||||
for(unsigned int rowIndex = 0; rowIndex < fields; ++rowIndex) {
|
for (unsigned int rowIndex = 0; rowIndex < fields; ++rowIndex) {
|
||||||
if(rowIndex != 0)
|
if (rowIndex != 0) {
|
||||||
line.push_back('^');
|
line.push_back('^');
|
||||||
|
}
|
||||||
|
|
||||||
if(row[rowIndex] != nullptr) {
|
if (row[rowIndex] != nullptr) {
|
||||||
line += row[rowIndex];
|
line += row[rowIndex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,8 +24,10 @@
|
|||||||
#include "../../common/crash.h"
|
#include "../../common/crash.h"
|
||||||
#include "../../common/rulesys.h"
|
#include "../../common/rulesys.h"
|
||||||
#include "../../common/string_util.h"
|
#include "../../common/string_util.h"
|
||||||
|
#include "../../common/content/world_content_service.h"
|
||||||
|
|
||||||
EQEmuLogSys LogSys;
|
EQEmuLogSys LogSys;
|
||||||
|
WorldContentService content_service;
|
||||||
|
|
||||||
void ImportSpells(SharedDatabase *db);
|
void ImportSpells(SharedDatabase *db);
|
||||||
void ImportSkillCaps(SharedDatabase *db);
|
void ImportSkillCaps(SharedDatabase *db);
|
||||||
@ -46,20 +48,44 @@ int main(int argc, char **argv) {
|
|||||||
auto Config = EQEmuConfig::get();
|
auto Config = EQEmuConfig::get();
|
||||||
|
|
||||||
SharedDatabase database;
|
SharedDatabase database;
|
||||||
|
SharedDatabase content_db;
|
||||||
|
|
||||||
LogInfo("Connecting to database");
|
LogInfo("Connecting to database");
|
||||||
if(!database.Connect(Config->DatabaseHost.c_str(), Config->DatabaseUsername.c_str(),
|
if (!database.Connect(
|
||||||
Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort)) {
|
Config->DatabaseHost.c_str(),
|
||||||
LogError("Unable to connect to the database, cannot continue without a "
|
Config->DatabaseUsername.c_str(),
|
||||||
"database connection");
|
Config->DatabasePassword.c_str(),
|
||||||
|
Config->DatabaseDB.c_str(),
|
||||||
|
Config->DatabasePort
|
||||||
|
)) {
|
||||||
|
LogError("Unable to connect to the database, cannot continue without a database connection");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multi-tenancy: Content database
|
||||||
|
*/
|
||||||
|
if (!Config->ContentDbHost.empty()) {
|
||||||
|
if (!content_db.Connect(
|
||||||
|
Config->ContentDbHost.c_str() ,
|
||||||
|
Config->ContentDbUsername.c_str(),
|
||||||
|
Config->ContentDbPassword.c_str(),
|
||||||
|
Config->ContentDbName.c_str(),
|
||||||
|
Config->ContentDbPort
|
||||||
|
)) {
|
||||||
|
LogError("Cannot continue without a content database connection");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
content_db.SetMysql(database.getMySQL());
|
||||||
|
}
|
||||||
|
|
||||||
database.LoadLogSettings(LogSys.log_settings);
|
database.LoadLogSettings(LogSys.log_settings);
|
||||||
LogSys.StartFileLogs();
|
LogSys.StartFileLogs();
|
||||||
|
|
||||||
ImportSpells(&database);
|
ImportSpells(&content_db);
|
||||||
ImportSkillCaps(&database);
|
ImportSkillCaps(&content_db);
|
||||||
ImportBaseData(&database);
|
ImportBaseData(&content_db);
|
||||||
ImportDBStrings(&database);
|
ImportDBStrings(&database);
|
||||||
|
|
||||||
LogSys.CloseFileLogs();
|
LogSys.CloseFileLogs();
|
||||||
|
|||||||
@ -6,6 +6,7 @@ SET(common_sources
|
|||||||
cli/eqemu_command_handler.cpp
|
cli/eqemu_command_handler.cpp
|
||||||
compression.cpp
|
compression.cpp
|
||||||
condition.cpp
|
condition.cpp
|
||||||
|
content/world_content_service.cpp
|
||||||
crash.cpp
|
crash.cpp
|
||||||
crc16.cpp
|
crc16.cpp
|
||||||
crc32.cpp
|
crc32.cpp
|
||||||
@ -108,6 +109,331 @@ SET(common_sources
|
|||||||
util/directory.cpp
|
util/directory.cpp
|
||||||
util/uuid.cpp)
|
util/uuid.cpp)
|
||||||
|
|
||||||
|
SET(repositories
|
||||||
|
|
||||||
|
# Criteria
|
||||||
|
repositories/criteria/content_filter_criteria.h
|
||||||
|
|
||||||
|
# Base Repositories
|
||||||
|
repositories/base/base_aa_ability_repository.h
|
||||||
|
repositories/base/base_aa_ranks_repository.h
|
||||||
|
repositories/base/base_aa_rank_effects_repository.h
|
||||||
|
repositories/base/base_aa_rank_prereqs_repository.h
|
||||||
|
repositories/base/base_account_repository.h
|
||||||
|
repositories/base/base_account_flags_repository.h
|
||||||
|
repositories/base/base_account_ip_repository.h
|
||||||
|
repositories/base/base_account_rewards_repository.h
|
||||||
|
repositories/base/base_adventure_details_repository.h
|
||||||
|
repositories/base/base_adventure_members_repository.h
|
||||||
|
repositories/base/base_adventure_stats_repository.h
|
||||||
|
repositories/base/base_adventure_template_repository.h
|
||||||
|
repositories/base/base_adventure_template_entry_repository.h
|
||||||
|
repositories/base/base_adventure_template_entry_flavor_repository.h
|
||||||
|
repositories/base/base_alternate_currency_repository.h
|
||||||
|
repositories/base/base_auras_repository.h
|
||||||
|
repositories/base/base_base_data_repository.h
|
||||||
|
repositories/base/base_blocked_spells_repository.h
|
||||||
|
repositories/base/base_bugs_repository.h
|
||||||
|
repositories/base/base_bug_reports_repository.h
|
||||||
|
repositories/base/base_buyer_repository.h
|
||||||
|
repositories/base/base_character_activities_repository.h
|
||||||
|
repositories/base/base_character_alternate_abilities_repository.h
|
||||||
|
repositories/base/base_character_alt_currency_repository.h
|
||||||
|
repositories/base/base_character_auras_repository.h
|
||||||
|
repositories/base/base_character_bandolier_repository.h
|
||||||
|
repositories/base/base_character_bind_repository.h
|
||||||
|
repositories/base/base_character_buffs_repository.h
|
||||||
|
repositories/base/base_character_corpses_repository.h
|
||||||
|
repositories/base/base_character_corpse_items_repository.h
|
||||||
|
repositories/base/base_character_currency_repository.h
|
||||||
|
repositories/base/base_character_data_repository.h
|
||||||
|
repositories/base/base_character_disciplines_repository.h
|
||||||
|
repositories/base/base_character_inspect_messages_repository.h
|
||||||
|
repositories/base/base_character_item_recast_repository.h
|
||||||
|
repositories/base/base_character_languages_repository.h
|
||||||
|
repositories/base/base_character_leadership_abilities_repository.h
|
||||||
|
repositories/base/base_character_material_repository.h
|
||||||
|
repositories/base/base_character_memmed_spells_repository.h
|
||||||
|
repositories/base/base_character_pet_buffs_repository.h
|
||||||
|
repositories/base/base_character_pet_info_repository.h
|
||||||
|
repositories/base/base_character_pet_inventory_repository.h
|
||||||
|
repositories/base/base_character_potionbelt_repository.h
|
||||||
|
repositories/base/base_character_skills_repository.h
|
||||||
|
repositories/base/base_character_spells_repository.h
|
||||||
|
repositories/base/base_character_tasks_repository.h
|
||||||
|
repositories/base/base_char_create_combinations_repository.h
|
||||||
|
repositories/base/base_char_create_point_allocations_repository.h
|
||||||
|
repositories/base/base_char_recipe_list_repository.h
|
||||||
|
repositories/base/base_completed_tasks_repository.h
|
||||||
|
repositories/base/base_content_flags_repository.h
|
||||||
|
repositories/base/base_data_buckets_repository.h
|
||||||
|
repositories/base/base_db_str_repository.h
|
||||||
|
repositories/base/base_discovered_items_repository.h
|
||||||
|
repositories/base/base_doors_repository.h
|
||||||
|
repositories/base/base_eventlog_repository.h
|
||||||
|
repositories/base/base_faction_base_data_repository.h
|
||||||
|
repositories/base/base_faction_list_repository.h
|
||||||
|
repositories/base/base_faction_list_mod_repository.h
|
||||||
|
repositories/base/base_faction_values_repository.h
|
||||||
|
repositories/base/base_fishing_repository.h
|
||||||
|
repositories/base/base_forage_repository.h
|
||||||
|
repositories/base/base_friends_repository.h
|
||||||
|
repositories/base/base_global_loot_repository.h
|
||||||
|
repositories/base/base_gm_ips_repository.h
|
||||||
|
repositories/base/base_goallists_repository.h
|
||||||
|
repositories/base/base_graveyard_repository.h
|
||||||
|
repositories/base/base_grid_repository.h
|
||||||
|
repositories/base/base_grid_entries_repository.h
|
||||||
|
repositories/base/base_ground_spawns_repository.h
|
||||||
|
repositories/base/base_group_id_repository.h
|
||||||
|
repositories/base/base_group_leaders_repository.h
|
||||||
|
repositories/base/base_guilds_repository.h
|
||||||
|
repositories/base/base_guild_members_repository.h
|
||||||
|
repositories/base/base_guild_ranks_repository.h
|
||||||
|
repositories/base/base_guild_relations_repository.h
|
||||||
|
repositories/base/base_hackers_repository.h
|
||||||
|
repositories/base/base_instance_list_repository.h
|
||||||
|
repositories/base/base_instance_list_player_repository.h
|
||||||
|
repositories/base/base_inventory_repository.h
|
||||||
|
repositories/base/base_inventory_snapshots_repository.h
|
||||||
|
repositories/base/base_ip_exemptions_repository.h
|
||||||
|
repositories/base/base_items_repository.h
|
||||||
|
repositories/base/base_item_tick_repository.h
|
||||||
|
repositories/base/base_ldon_trap_entries_repository.h
|
||||||
|
repositories/base/base_ldon_trap_templates_repository.h
|
||||||
|
repositories/base/base_level_exp_mods_repository.h
|
||||||
|
repositories/base/base_lfguild_repository.h
|
||||||
|
repositories/base/base_login_accounts_repository.h
|
||||||
|
repositories/base/base_login_api_tokens_repository.h
|
||||||
|
repositories/base/base_login_server_admins_repository.h
|
||||||
|
repositories/base/base_login_server_list_types_repository.h
|
||||||
|
repositories/base/base_login_world_servers_repository.h
|
||||||
|
repositories/base/base_logsys_categories_repository.h
|
||||||
|
repositories/base/base_lootdrop_repository.h
|
||||||
|
repositories/base/base_lootdrop_entries_repository.h
|
||||||
|
repositories/base/base_loottable_repository.h
|
||||||
|
repositories/base/base_loottable_entries_repository.h
|
||||||
|
repositories/base/base_mail_repository.h
|
||||||
|
repositories/base/base_merchantlist_repository.h
|
||||||
|
repositories/base/base_merchantlist_temp_repository.h
|
||||||
|
repositories/base/base_name_filter_repository.h
|
||||||
|
repositories/base/base_npc_emotes_repository.h
|
||||||
|
repositories/base/base_npc_faction_repository.h
|
||||||
|
repositories/base/base_npc_faction_entries_repository.h
|
||||||
|
repositories/base/base_npc_scale_global_base_repository.h
|
||||||
|
repositories/base/base_npc_spells_repository.h
|
||||||
|
repositories/base/base_npc_spells_effects_repository.h
|
||||||
|
repositories/base/base_npc_spells_effects_entries_repository.h
|
||||||
|
repositories/base/base_npc_spells_entries_repository.h
|
||||||
|
repositories/base/base_npc_types_repository.h
|
||||||
|
repositories/base/base_npc_types_tint_repository.h
|
||||||
|
repositories/base/base_object_repository.h
|
||||||
|
repositories/base/base_object_contents_repository.h
|
||||||
|
repositories/base/base_perl_event_export_settings_repository.h
|
||||||
|
repositories/base/base_petitions_repository.h
|
||||||
|
repositories/base/base_pets_repository.h
|
||||||
|
repositories/base/base_pets_equipmentset_repository.h
|
||||||
|
repositories/base/base_pets_equipmentset_entries_repository.h
|
||||||
|
repositories/base/base_player_titlesets_repository.h
|
||||||
|
repositories/base/base_proximities_repository.h
|
||||||
|
repositories/base/base_quest_globals_repository.h
|
||||||
|
repositories/base/base_raid_details_repository.h
|
||||||
|
repositories/base/base_raid_members_repository.h
|
||||||
|
repositories/base/base_reports_repository.h
|
||||||
|
repositories/base/base_respawn_times_repository.h
|
||||||
|
repositories/base/base_rule_sets_repository.h
|
||||||
|
repositories/base/base_rule_values_repository.h
|
||||||
|
repositories/base/base_saylink_repository.h
|
||||||
|
repositories/base/base_skill_caps_repository.h
|
||||||
|
repositories/base/base_spawn2_repository.h
|
||||||
|
repositories/base/base_spawnentry_repository.h
|
||||||
|
repositories/base/base_spawngroup_repository.h
|
||||||
|
repositories/base/base_spawn_conditions_repository.h
|
||||||
|
repositories/base/base_spawn_condition_values_repository.h
|
||||||
|
repositories/base/base_spawn_events_repository.h
|
||||||
|
repositories/base/base_spells_new_repository.h
|
||||||
|
repositories/base/base_spell_buckets_repository.h
|
||||||
|
repositories/base/base_spell_globals_repository.h
|
||||||
|
repositories/base/base_starting_items_repository.h
|
||||||
|
repositories/base/base_start_zones_repository.h
|
||||||
|
repositories/base/base_tasks_repository.h
|
||||||
|
repositories/base/base_tasksets_repository.h
|
||||||
|
repositories/base/base_task_activities_repository.h
|
||||||
|
repositories/base/base_timers_repository.h
|
||||||
|
repositories/base/base_titles_repository.h
|
||||||
|
repositories/base/base_trader_repository.h
|
||||||
|
repositories/base/base_tradeskill_recipe_repository.h
|
||||||
|
repositories/base/base_tradeskill_recipe_entries_repository.h
|
||||||
|
repositories/base/base_traps_repository.h
|
||||||
|
repositories/base/base_tributes_repository.h
|
||||||
|
repositories/base/base_tribute_levels_repository.h
|
||||||
|
repositories/base/base_variables_repository.h
|
||||||
|
repositories/base/base_veteran_reward_templates_repository.h
|
||||||
|
repositories/base/base_zone_repository.h
|
||||||
|
repositories/base/base_zone_points_repository.h
|
||||||
|
|
||||||
|
# Extended Repositories
|
||||||
|
repositories/aa_ability_repository.h
|
||||||
|
repositories/aa_ranks_repository.h
|
||||||
|
repositories/aa_rank_effects_repository.h
|
||||||
|
repositories/aa_rank_prereqs_repository.h
|
||||||
|
repositories/account_repository.h
|
||||||
|
repositories/account_flags_repository.h
|
||||||
|
repositories/account_ip_repository.h
|
||||||
|
repositories/account_rewards_repository.h
|
||||||
|
repositories/adventure_details_repository.h
|
||||||
|
repositories/adventure_members_repository.h
|
||||||
|
repositories/adventure_stats_repository.h
|
||||||
|
repositories/adventure_template_repository.h
|
||||||
|
repositories/adventure_template_entry_repository.h
|
||||||
|
repositories/adventure_template_entry_flavor_repository.h
|
||||||
|
repositories/alternate_currency_repository.h
|
||||||
|
repositories/auras_repository.h
|
||||||
|
repositories/base_data_repository.h
|
||||||
|
repositories/blocked_spells_repository.h
|
||||||
|
repositories/bugs_repository.h
|
||||||
|
repositories/bug_reports_repository.h
|
||||||
|
repositories/buyer_repository.h
|
||||||
|
repositories/character_activities_repository.h
|
||||||
|
repositories/character_alternate_abilities_repository.h
|
||||||
|
repositories/character_alt_currency_repository.h
|
||||||
|
repositories/character_auras_repository.h
|
||||||
|
repositories/character_bandolier_repository.h
|
||||||
|
repositories/character_bind_repository.h
|
||||||
|
repositories/character_buffs_repository.h
|
||||||
|
repositories/character_corpses_repository.h
|
||||||
|
repositories/character_corpse_items_repository.h
|
||||||
|
repositories/character_currency_repository.h
|
||||||
|
repositories/character_data_repository.h
|
||||||
|
repositories/character_disciplines_repository.h
|
||||||
|
repositories/character_inspect_messages_repository.h
|
||||||
|
repositories/character_item_recast_repository.h
|
||||||
|
repositories/character_languages_repository.h
|
||||||
|
repositories/character_leadership_abilities_repository.h
|
||||||
|
repositories/character_material_repository.h
|
||||||
|
repositories/character_memmed_spells_repository.h
|
||||||
|
repositories/character_pet_buffs_repository.h
|
||||||
|
repositories/character_pet_info_repository.h
|
||||||
|
repositories/character_pet_inventory_repository.h
|
||||||
|
repositories/character_potionbelt_repository.h
|
||||||
|
repositories/character_skills_repository.h
|
||||||
|
repositories/character_spells_repository.h
|
||||||
|
repositories/character_tasks_repository.h
|
||||||
|
repositories/char_create_combinations_repository.h
|
||||||
|
repositories/char_create_point_allocations_repository.h
|
||||||
|
repositories/char_recipe_list_repository.h
|
||||||
|
repositories/completed_tasks_repository.h
|
||||||
|
repositories/content_flags_repository.h
|
||||||
|
repositories/data_buckets_repository.h
|
||||||
|
repositories/db_str_repository.h
|
||||||
|
repositories/discovered_items_repository.h
|
||||||
|
repositories/doors_repository.h
|
||||||
|
repositories/eventlog_repository.h
|
||||||
|
repositories/faction_base_data_repository.h
|
||||||
|
repositories/faction_list_repository.h
|
||||||
|
repositories/faction_list_mod_repository.h
|
||||||
|
repositories/faction_values_repository.h
|
||||||
|
repositories/fishing_repository.h
|
||||||
|
repositories/forage_repository.h
|
||||||
|
repositories/friends_repository.h
|
||||||
|
repositories/global_loot_repository.h
|
||||||
|
repositories/gm_ips_repository.h
|
||||||
|
repositories/goallists_repository.h
|
||||||
|
repositories/graveyard_repository.h
|
||||||
|
repositories/grid_repository.h
|
||||||
|
repositories/grid_entries_repository.h
|
||||||
|
repositories/ground_spawns_repository.h
|
||||||
|
repositories/group_id_repository.h
|
||||||
|
repositories/group_leaders_repository.h
|
||||||
|
repositories/guilds_repository.h
|
||||||
|
repositories/guild_members_repository.h
|
||||||
|
repositories/guild_ranks_repository.h
|
||||||
|
repositories/guild_relations_repository.h
|
||||||
|
repositories/hackers_repository.h
|
||||||
|
repositories/instance_list_repository.h
|
||||||
|
repositories/instance_list_player_repository.h
|
||||||
|
repositories/inventory_repository.h
|
||||||
|
repositories/inventory_snapshots_repository.h
|
||||||
|
repositories/ip_exemptions_repository.h
|
||||||
|
repositories/items_repository.h
|
||||||
|
repositories/item_tick_repository.h
|
||||||
|
repositories/ldon_trap_entries_repository.h
|
||||||
|
repositories/ldon_trap_templates_repository.h
|
||||||
|
repositories/level_exp_mods_repository.h
|
||||||
|
repositories/lfguild_repository.h
|
||||||
|
repositories/login_accounts_repository.h
|
||||||
|
repositories/login_api_tokens_repository.h
|
||||||
|
repositories/login_server_admins_repository.h
|
||||||
|
repositories/login_server_list_types_repository.h
|
||||||
|
repositories/login_world_servers_repository.h
|
||||||
|
repositories/logsys_categories_repository.h
|
||||||
|
repositories/lootdrop_repository.h
|
||||||
|
repositories/lootdrop_entries_repository.h
|
||||||
|
repositories/loottable_repository.h
|
||||||
|
repositories/loottable_entries_repository.h
|
||||||
|
repositories/mail_repository.h
|
||||||
|
repositories/merchantlist_repository.h
|
||||||
|
repositories/merchantlist_temp_repository.h
|
||||||
|
repositories/name_filter_repository.h
|
||||||
|
repositories/npc_emotes_repository.h
|
||||||
|
repositories/npc_faction_repository.h
|
||||||
|
repositories/npc_faction_entries_repository.h
|
||||||
|
repositories/npc_scale_global_base_repository.h
|
||||||
|
repositories/npc_spells_repository.h
|
||||||
|
repositories/npc_spells_effects_repository.h
|
||||||
|
repositories/npc_spells_effects_entries_repository.h
|
||||||
|
repositories/npc_spells_entries_repository.h
|
||||||
|
repositories/npc_types_repository.h
|
||||||
|
repositories/npc_types_tint_repository.h
|
||||||
|
repositories/object_repository.h
|
||||||
|
repositories/object_contents_repository.h
|
||||||
|
repositories/perl_event_export_settings_repository.h
|
||||||
|
repositories/petitions_repository.h
|
||||||
|
repositories/pets_repository.h
|
||||||
|
repositories/pets_equipmentset_repository.h
|
||||||
|
repositories/pets_equipmentset_entries_repository.h
|
||||||
|
repositories/player_titlesets_repository.h
|
||||||
|
repositories/proximities_repository.h
|
||||||
|
repositories/quest_globals_repository.h
|
||||||
|
repositories/raid_details_repository.h
|
||||||
|
repositories/raid_members_repository.h
|
||||||
|
repositories/reports_repository.h
|
||||||
|
repositories/respawn_times_repository.h
|
||||||
|
repositories/rule_sets_repository.h
|
||||||
|
repositories/rule_values_repository.h
|
||||||
|
repositories/saylink_repository.h
|
||||||
|
repositories/skill_caps_repository.h
|
||||||
|
repositories/spawn2_repository.h
|
||||||
|
repositories/spawnentry_repository.h
|
||||||
|
repositories/spawngroup_repository.h
|
||||||
|
repositories/spawn_conditions_repository.h
|
||||||
|
repositories/spawn_condition_values_repository.h
|
||||||
|
repositories/spawn_events_repository.h
|
||||||
|
repositories/spells_new_repository.h
|
||||||
|
repositories/spell_buckets_repository.h
|
||||||
|
repositories/spell_globals_repository.h
|
||||||
|
repositories/starting_items_repository.h
|
||||||
|
repositories/start_zones_repository.h
|
||||||
|
repositories/tasks_repository.h
|
||||||
|
repositories/tasksets_repository.h
|
||||||
|
repositories/task_activities_repository.h
|
||||||
|
repositories/timers_repository.h
|
||||||
|
repositories/titles_repository.h
|
||||||
|
repositories/trader_repository.h
|
||||||
|
repositories/tradeskill_recipe_repository.h
|
||||||
|
repositories/tradeskill_recipe_entries_repository.h
|
||||||
|
repositories/traps_repository.h
|
||||||
|
repositories/tributes_repository.h
|
||||||
|
repositories/tribute_levels_repository.h
|
||||||
|
repositories/variables_repository.h
|
||||||
|
repositories/veteran_reward_templates_repository.h
|
||||||
|
repositories/zone_repository.h
|
||||||
|
repositories/zone_points_repository.h
|
||||||
|
|
||||||
|
# Non-Comformative
|
||||||
|
repositories/character_recipe_list_repository.h
|
||||||
|
)
|
||||||
|
|
||||||
SET(common_headers
|
SET(common_headers
|
||||||
any.h
|
any.h
|
||||||
base_packet.h
|
base_packet.h
|
||||||
@ -116,6 +442,7 @@ SET(common_headers
|
|||||||
classes.h
|
classes.h
|
||||||
compression.h
|
compression.h
|
||||||
condition.h
|
condition.h
|
||||||
|
content/world_content_service.h
|
||||||
crash.h
|
crash.h
|
||||||
crc16.h
|
crc16.h
|
||||||
crc32.h
|
crc32.h
|
||||||
@ -380,7 +707,7 @@ SOURCE_GROUP(Util FILES
|
|||||||
|
|
||||||
INCLUDE_DIRECTORIES(Patches SocketLib StackWalker)
|
INCLUDE_DIRECTORIES(Patches SocketLib StackWalker)
|
||||||
|
|
||||||
ADD_LIBRARY(common ${common_sources} ${common_headers})
|
ADD_LIBRARY(common ${common_sources} ${common_headers} ${repositories})
|
||||||
|
|
||||||
IF(UNIX)
|
IF(UNIX)
|
||||||
SET_SOURCE_FILES_PROPERTIES("SocketLib/Mime.cpp" PROPERTY COMPILE_FLAGS -Wno-unused-result)
|
SET_SOURCE_FILES_PROPERTIES("SocketLib/Mime.cpp" PROPERTY COMPILE_FLAGS -Wno-unused-result)
|
||||||
|
|||||||
@ -77,7 +77,7 @@ namespace EQEmuCommand {
|
|||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!arguments_filled || argc == 2) {
|
if (!arguments_filled || argc == 2 || cmd[{"-h", "--help"}]) {
|
||||||
std::string arguments_string;
|
std::string arguments_string;
|
||||||
for (auto &arg : arguments) {
|
for (auto &arg : arguments) {
|
||||||
arguments_string += " " + arg;
|
arguments_string += " " + arg;
|
||||||
@ -101,7 +101,7 @@ namespace EQEmuCommand {
|
|||||||
|
|
||||||
std::cout << command_string.str() << std::endl;
|
std::cout << command_string.str() << std::endl;
|
||||||
|
|
||||||
exit(1);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,6 +168,11 @@ namespace EQEmuCommand {
|
|||||||
* Print section header
|
* Print section header
|
||||||
*/
|
*/
|
||||||
std::string command_prefix = it.first.substr(0, it.first.find(":"));
|
std::string command_prefix = it.first.substr(0, it.first.find(":"));
|
||||||
|
|
||||||
|
if (command_prefix.find("test") != std::string::npos) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (command_section != command_prefix) {
|
if (command_section != command_prefix) {
|
||||||
command_section = command_prefix;
|
command_section = command_prefix;
|
||||||
std::cout << termcolor::reset << command_prefix << std::endl;
|
std::cout << termcolor::reset << command_prefix << std::endl;
|
||||||
@ -183,11 +188,11 @@ namespace EQEmuCommand {
|
|||||||
|
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
std::exit(1);
|
std::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ran_command) {
|
if (ran_command) {
|
||||||
std::exit(1);
|
std::exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
101
common/content/world_content_service.cpp
Normal file
101
common/content/world_content_service.cpp
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2019 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "world_content_service.h"
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../rulesys.h"
|
||||||
|
#include "../eqemu_logsys.h"
|
||||||
|
|
||||||
|
|
||||||
|
WorldContentService::WorldContentService()
|
||||||
|
{
|
||||||
|
SetCurrentExpansion(Expansion::EXPANSION_ALL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int WorldContentService::GetCurrentExpansion() const
|
||||||
|
{
|
||||||
|
return current_expansion;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldContentService::SetExpansionContext()
|
||||||
|
{
|
||||||
|
int expansion = RuleI(Expansion, CurrentExpansion);
|
||||||
|
if (expansion >= Expansion::Classic && expansion <= Expansion::MaxId) {
|
||||||
|
content_service.SetCurrentExpansion(expansion);
|
||||||
|
}
|
||||||
|
|
||||||
|
LogInfo(
|
||||||
|
"Current expansion is [{}] ({})",
|
||||||
|
GetCurrentExpansion(),
|
||||||
|
GetCurrentExpansionName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string WorldContentService::GetCurrentExpansionName()
|
||||||
|
{
|
||||||
|
if (content_service.GetCurrentExpansion() == Expansion::EXPANSION_ALL) {
|
||||||
|
return "All Expansions";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current_expansion >= Expansion::Classic && current_expansion <= Expansion::MaxId) {
|
||||||
|
return Expansion::ExpansionName[content_service.GetCurrentExpansion()];
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Unknown Expansion";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param current_expansion
|
||||||
|
*/
|
||||||
|
void WorldContentService::SetCurrentExpansion(int current_expansion)
|
||||||
|
{
|
||||||
|
WorldContentService::current_expansion = current_expansion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
const std::vector<std::string> &WorldContentService::GetContentFlags() const
|
||||||
|
{
|
||||||
|
return content_flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param content_flags
|
||||||
|
*/
|
||||||
|
void WorldContentService::SetContentFlags(std::vector<std::string> content_flags)
|
||||||
|
{
|
||||||
|
WorldContentService::content_flags = content_flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param content_flag
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
bool WorldContentService::IsContentFlagEnabled(const std::string& content_flag)
|
||||||
|
{
|
||||||
|
for (auto &flag : GetContentFlags()) {
|
||||||
|
if (flag == content_flag) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
173
common/content/world_content_service.h
Normal file
173
common/content/world_content_service.h
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2019 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_WORLD_CONTENT_SERVICE_H
|
||||||
|
#define EQEMU_WORLD_CONTENT_SERVICE_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace Expansion {
|
||||||
|
static const int EXPANSION_ALL = -1;
|
||||||
|
static const int EXPANSION_FILTER_MAX = 99;
|
||||||
|
|
||||||
|
enum ExpansionNumber {
|
||||||
|
Classic = 0,
|
||||||
|
TheRuinsOfKunark,
|
||||||
|
TheScarsOfVelious,
|
||||||
|
TheShadowsOfLuclin,
|
||||||
|
ThePlanesOfPower,
|
||||||
|
TheLegacyOfYkesha,
|
||||||
|
LostDungeonsOfNorrath,
|
||||||
|
GatesOfDiscord,
|
||||||
|
OmensOfWar,
|
||||||
|
DragonsOfNorrath,
|
||||||
|
DepthsOfDarkhollow,
|
||||||
|
ProphecyOfRo,
|
||||||
|
TheSerpentsSpine,
|
||||||
|
TheBuriedSea,
|
||||||
|
SecretsOfFaydwer,
|
||||||
|
SeedsOfDestruction,
|
||||||
|
Underfoot,
|
||||||
|
HouseOfThule,
|
||||||
|
VeilOfAlaris,
|
||||||
|
RainOfFear,
|
||||||
|
CallOfTheForsaken,
|
||||||
|
TheDarkendSea,
|
||||||
|
TheBrokenMirror,
|
||||||
|
EmpiresOfKunark,
|
||||||
|
RingOfScale,
|
||||||
|
TheBurningLands,
|
||||||
|
TormentOfVelious,
|
||||||
|
MaxId
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If you add to this, make sure you update LogCategory
|
||||||
|
*/
|
||||||
|
static const char *ExpansionName[ExpansionNumber::MaxId] = {
|
||||||
|
"Classic",
|
||||||
|
"The Ruins of Kunark",
|
||||||
|
"The Scars of Velious",
|
||||||
|
"The Shadows of Luclin",
|
||||||
|
"The Planes of Power",
|
||||||
|
"The Legacy of Ykesha",
|
||||||
|
"Lost Dungeons of Norrath",
|
||||||
|
"Gates of Discord",
|
||||||
|
"Omens of War",
|
||||||
|
"Dragons of Norrath",
|
||||||
|
"Depths of Darkhollow",
|
||||||
|
"Prophecy of Ro",
|
||||||
|
"The Serpent's Spine",
|
||||||
|
"The Buried Sea",
|
||||||
|
"Secrets of Faydwer",
|
||||||
|
"Seeds of Destruction",
|
||||||
|
"Underfoot",
|
||||||
|
"House of Thule",
|
||||||
|
"Veil of Alaris",
|
||||||
|
"Rain of Fear",
|
||||||
|
"Call of the Forsaken",
|
||||||
|
"The Darkened Sea",
|
||||||
|
"The Broken Mirror",
|
||||||
|
"Empires of Kunark",
|
||||||
|
"Ring of Scale",
|
||||||
|
"The Burning Lands",
|
||||||
|
"Torment of Velious",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class WorldContentService {
|
||||||
|
public:
|
||||||
|
|
||||||
|
WorldContentService();
|
||||||
|
|
||||||
|
std::string GetCurrentExpansionName();
|
||||||
|
int GetCurrentExpansion() const;
|
||||||
|
void SetCurrentExpansion(int current_expansion);
|
||||||
|
|
||||||
|
bool IsClassicEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::Classic || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsTheRuinsOfKunarkEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheRuinsOfKunark || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsTheScarsOfVeliousEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheScarsOfVelious || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsTheShadowsOfLuclinEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheShadowsOfLuclin || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsThePlanesOfPowerEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::ThePlanesOfPower || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsTheLegacyOfYkeshaEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheLegacyOfYkesha || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsLostDungeonsOfNorrathEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::LostDungeonsOfNorrath || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsGatesOfDiscordEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::GatesOfDiscord || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsOmensOfWarEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::OmensOfWar || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsDragonsOfNorrathEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::DragonsOfNorrath || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsDepthsOfDarkhollowEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::DepthsOfDarkhollow || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsProphecyOfRoEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::ProphecyOfRo || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsTheSerpentsSpineEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheSerpentsSpine || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsTheBuriedSeaEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheBuriedSea || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsSecretsOfFaydwerEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::SecretsOfFaydwer || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsSeedsOfDestructionEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::SeedsOfDestruction || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsUnderfootEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::Underfoot || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsHouseOfThuleEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::HouseOfThule || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsVeilOfAlarisEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::VeilOfAlaris || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsRainOfFearEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::RainOfFear || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsCallOfTheForsakenEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::CallOfTheForsaken || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsTheDarkendSeaEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheDarkendSea || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsTheBrokenMirrorEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheBrokenMirror || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsEmpiresOfKunarkEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::EmpiresOfKunark || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsRingOfScaleEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::RingOfScale || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsTheBurningLandsEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TheBurningLands || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
bool IsTormentOfVeliousEnabled() { return GetCurrentExpansion() >= Expansion::ExpansionNumber::TormentOfVelious || GetCurrentExpansion() == Expansion::EXPANSION_ALL; }
|
||||||
|
|
||||||
|
bool IsCurrentExpansionClassic() { return current_expansion == Expansion::ExpansionNumber::Classic; }
|
||||||
|
bool IsCurrentExpansionTheRuinsOfKunark() { return current_expansion == Expansion::ExpansionNumber::TheRuinsOfKunark; }
|
||||||
|
bool IsCurrentExpansionTheScarsOfVelious() { return current_expansion == Expansion::ExpansionNumber::TheScarsOfVelious; }
|
||||||
|
bool IsCurrentExpansionTheShadowsOfLuclin() { return current_expansion == Expansion::ExpansionNumber::TheShadowsOfLuclin; }
|
||||||
|
bool IsCurrentExpansionThePlanesOfPower() { return current_expansion == Expansion::ExpansionNumber::ThePlanesOfPower; }
|
||||||
|
bool IsCurrentExpansionTheLegacyOfYkesha() { return current_expansion == Expansion::ExpansionNumber::TheLegacyOfYkesha; }
|
||||||
|
bool IsCurrentExpansionLostDungeonsOfNorrath() { return current_expansion == Expansion::ExpansionNumber::LostDungeonsOfNorrath; }
|
||||||
|
bool IsCurrentExpansionGatesOfDiscord() { return current_expansion == Expansion::ExpansionNumber::GatesOfDiscord; }
|
||||||
|
bool IsCurrentExpansionOmensOfWar() { return current_expansion == Expansion::ExpansionNumber::OmensOfWar; }
|
||||||
|
bool IsCurrentExpansionDragonsOfNorrath() { return current_expansion == Expansion::ExpansionNumber::DragonsOfNorrath; }
|
||||||
|
bool IsCurrentExpansionDepthsOfDarkhollow() { return current_expansion == Expansion::ExpansionNumber::DepthsOfDarkhollow; }
|
||||||
|
bool IsCurrentExpansionProphecyOfRo() { return current_expansion == Expansion::ExpansionNumber::ProphecyOfRo; }
|
||||||
|
bool IsCurrentExpansionTheSerpentsSpine() { return current_expansion == Expansion::ExpansionNumber::TheSerpentsSpine; }
|
||||||
|
bool IsCurrentExpansionTheBuriedSea() { return current_expansion == Expansion::ExpansionNumber::TheBuriedSea; }
|
||||||
|
bool IsCurrentExpansionSecretsOfFaydwer() { return current_expansion == Expansion::ExpansionNumber::SecretsOfFaydwer; }
|
||||||
|
bool IsCurrentExpansionSeedsOfDestruction() { return current_expansion == Expansion::ExpansionNumber::SeedsOfDestruction; }
|
||||||
|
bool IsCurrentExpansionUnderfoot() { return current_expansion == Expansion::ExpansionNumber::Underfoot; }
|
||||||
|
bool IsCurrentExpansionHouseOfThule() { return current_expansion == Expansion::ExpansionNumber::HouseOfThule; }
|
||||||
|
bool IsCurrentExpansionVeilOfAlaris() { return current_expansion == Expansion::ExpansionNumber::VeilOfAlaris; }
|
||||||
|
bool IsCurrentExpansionRainOfFear() { return current_expansion == Expansion::ExpansionNumber::RainOfFear; }
|
||||||
|
bool IsCurrentExpansionCallOfTheForsaken() { return current_expansion == Expansion::ExpansionNumber::CallOfTheForsaken; }
|
||||||
|
bool IsCurrentExpansionTheDarkendSea() { return current_expansion == Expansion::ExpansionNumber::TheDarkendSea; }
|
||||||
|
bool IsCurrentExpansionTheBrokenMirror() { return current_expansion == Expansion::ExpansionNumber::TheBrokenMirror; }
|
||||||
|
bool IsCurrentExpansionEmpiresOfKunark() { return current_expansion == Expansion::ExpansionNumber::EmpiresOfKunark; }
|
||||||
|
bool IsCurrentExpansionRingOfScale() { return current_expansion == Expansion::ExpansionNumber::RingOfScale; }
|
||||||
|
bool IsCurrentExpansionTheBurningLands() { return current_expansion == Expansion::ExpansionNumber::TheBurningLands; }
|
||||||
|
bool IsCurrentExpansionTormentOfVelious() { return current_expansion == Expansion::ExpansionNumber::TormentOfVelious; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
int current_expansion{};
|
||||||
|
std::vector<std::string> content_flags;
|
||||||
|
public:
|
||||||
|
const std::vector<std::string> &GetContentFlags() const;
|
||||||
|
bool IsContentFlagEnabled(const std::string& content_flag);
|
||||||
|
void SetContentFlags(std::vector<std::string> content_flags);
|
||||||
|
void SetExpansionContext();
|
||||||
|
};
|
||||||
|
|
||||||
|
extern WorldContentService content_service;
|
||||||
|
|
||||||
|
#endif //EQEMU_WORLD_CONTENT_SERVICE_H
|
||||||
@ -61,15 +61,15 @@ Database::Database(const char* host, const char* user, const char* passwd, const
|
|||||||
Connect(host, user, passwd, database, port);
|
Connect(host, user, passwd, database, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::Connect(const char* host, const char* user, const char* passwd, const char* database, uint32 port) {
|
bool Database::Connect(const char* host, const char* user, const char* passwd, const char* database, uint32 port, std::string connection_label) {
|
||||||
uint32 errnum= 0;
|
uint32 errnum= 0;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||||
if (!Open(host, user, passwd, database, port, &errnum, errbuf)) {
|
if (!Open(host, user, passwd, database, port, &errnum, errbuf)) {
|
||||||
LogError("Failed to connect to database: Error: {}", errbuf);
|
LogError("[MySQL] Connection [{}] Failed to connect to database: Error [{}]", connection_label, errbuf);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogInfo("Using database [{}] at [{}]:[{}]", database, host,port);
|
LogInfo("[MySQL] Connection [{}] database [{}] at [{}]:[{}]", connection_label, database, host,port);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -750,61 +750,6 @@ bool Database::SaveCharacterCreate(uint32 character_id, uint32 account_id, Playe
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This only for new Character creation storing */
|
|
||||||
bool Database::StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, EQ::InventoryProfile* inv) {
|
|
||||||
uint32 charid = 0;
|
|
||||||
char zone[50];
|
|
||||||
float x, y, z;
|
|
||||||
charid = GetCharacterID(pp->name);
|
|
||||||
|
|
||||||
if(!charid) {
|
|
||||||
LogError("StoreCharacter: no character id");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *zname = GetZoneName(pp->zone_id);
|
|
||||||
if(zname == nullptr) {
|
|
||||||
/* Zone not in the DB, something to prevent crash... */
|
|
||||||
strn0cpy(zone, "qeynos", 49);
|
|
||||||
pp->zone_id = 1;
|
|
||||||
}
|
|
||||||
else{ strn0cpy(zone, zname, 49); }
|
|
||||||
|
|
||||||
x = pp->x;
|
|
||||||
y = pp->y;
|
|
||||||
z = pp->z;
|
|
||||||
|
|
||||||
/* Saves Player Profile Data */
|
|
||||||
SaveCharacterCreate(charid, account_id, pp);
|
|
||||||
|
|
||||||
/* Insert starting inventory... */
|
|
||||||
std::string invquery;
|
|
||||||
for (int16 i = EQ::invslot::EQUIPMENT_BEGIN; i <= EQ::invbag::BANK_BAGS_END;) {
|
|
||||||
const EQ::ItemInstance* newinv = inv->GetItem(i);
|
|
||||||
if (newinv) {
|
|
||||||
invquery = StringFormat("INSERT INTO `inventory` (charid, slotid, itemid, charges, color) VALUES (%u, %i, %u, %i, %u)",
|
|
||||||
charid, i, newinv->GetItem()->ID, newinv->GetCharges(), newinv->GetColor());
|
|
||||||
|
|
||||||
auto results = QueryDatabase(invquery);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == EQ::invslot::slotCursor) {
|
|
||||||
i = EQ::invbag::GENERAL_BAGS_BEGIN;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (i == EQ::invbag::CURSOR_BAG_END) {
|
|
||||||
i = EQ::invslot::BANK_BEGIN;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (i == EQ::invslot::BANK_END) {
|
|
||||||
i = EQ::invbag::BANK_BAGS_BEGIN;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32 Database::GetCharacterID(const char *name) {
|
uint32 Database::GetCharacterID(const char *name) {
|
||||||
std::string query = StringFormat("SELECT `id` FROM `character_data` WHERE `name` = '%s'", name);
|
std::string query = StringFormat("SELECT `id` FROM `character_data` WHERE `name` = '%s'", name);
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
@ -1137,50 +1082,6 @@ bool Database::GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zon
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::LoadZoneNames() {
|
|
||||||
std::string query("SELECT zoneidnumber, short_name FROM zone");
|
|
||||||
|
|
||||||
auto results = QueryDatabase(query);
|
|
||||||
|
|
||||||
if (!results.Success())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto row= results.begin();row != results.end();++row)
|
|
||||||
{
|
|
||||||
uint32 zoneid = atoi(row[0]);
|
|
||||||
std::string zonename = row[1];
|
|
||||||
zonename_array.insert(std::pair<uint32,std::string>(zoneid,zonename));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32 Database::GetZoneID(const char* zonename) {
|
|
||||||
|
|
||||||
if (zonename == nullptr)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (auto iter = zonename_array.begin(); iter != zonename_array.end(); ++iter)
|
|
||||||
if (strcasecmp(iter->second.c_str(), zonename) == 0)
|
|
||||||
return iter->first;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* Database::GetZoneName(uint32 zoneID, bool ErrorUnknown) {
|
|
||||||
auto iter = zonename_array.find(zoneID);
|
|
||||||
|
|
||||||
if (iter != zonename_array.end())
|
|
||||||
return iter->second.c_str();
|
|
||||||
|
|
||||||
if (ErrorUnknown)
|
|
||||||
return "UNKNOWN";
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8 Database::GetPEQZone(uint32 zoneID, uint32 version){
|
uint8 Database::GetPEQZone(uint32 zoneID, uint32 version){
|
||||||
|
|
||||||
std::string query = StringFormat("SELECT peqzone from zone where zoneidnumber='%i' AND (version=%i OR version=0) ORDER BY version DESC", zoneID, version);
|
std::string query = StringFormat("SELECT peqzone from zone where zoneidnumber='%i' AND (version=%i OR version=0) ORDER BY version DESC", zoneID, version);
|
||||||
@ -1397,29 +1298,31 @@ uint8 Database::GetServerType() {
|
|||||||
return atoi(row[0]);
|
return atoi(row[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::MoveCharacterToZone(const char* charname, const char* zonename, uint32 zoneid) {
|
bool Database::MoveCharacterToZone(uint32 character_id, uint32 zone_id)
|
||||||
if(zonename == nullptr || strlen(zonename) == 0)
|
{
|
||||||
return false;
|
std::string query = StringFormat(
|
||||||
|
"UPDATE `character_data` SET `zone_id` = %i, `x` = -1, `y` = -1, `z` = -1 WHERE `id` = %i",
|
||||||
|
zone_id,
|
||||||
|
character_id
|
||||||
|
);
|
||||||
|
|
||||||
std::string query = StringFormat("UPDATE `character_data` SET `zone_id` = %i, `x` = -1, `y` = -1, `z` = -1 WHERE `name` = '%s'", zoneid, charname);
|
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (results.RowsAffected() == 0)
|
return results.RowsAffected() != 0;
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::MoveCharacterToZone(const char* charname, const char* zonename) {
|
bool Database::MoveCharacterToZone(const char *charname, uint32 zone_id)
|
||||||
return MoveCharacterToZone(charname, zonename, GetZoneID(zonename));
|
{
|
||||||
}
|
std::string query = StringFormat(
|
||||||
|
"UPDATE `character_data` SET `zone_id` = %i, `x` = -1, `y` = -1, `z` = -1 WHERE `name` = '%s'",
|
||||||
|
zone_id,
|
||||||
|
charname
|
||||||
|
);
|
||||||
|
|
||||||
bool Database::MoveCharacterToZone(uint32 iCharID, const char* iZonename) {
|
|
||||||
std::string query = StringFormat("UPDATE `character_data` SET `zone_id` = %i, `x` = -1, `y` = -1, `z` = -1 WHERE `id` = %i", GetZoneID(iZonename), iCharID);
|
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
@ -2406,3 +2309,141 @@ int Database::GetInstanceID(uint32 char_id, uint32 zone_id) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param source_character_name
|
||||||
|
* @param destination_character_name
|
||||||
|
* @param destination_account_name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
bool Database::CopyCharacter(
|
||||||
|
std::string source_character_name,
|
||||||
|
std::string destination_character_name,
|
||||||
|
std::string destination_account_name
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT id FROM character_data WHERE name = '{}' and deleted_at is NULL LIMIT 1",
|
||||||
|
source_character_name
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.RowCount() == 0) {
|
||||||
|
LogError("No character found with name [{}]", source_character_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
std::string source_character_id = row[0];
|
||||||
|
|
||||||
|
results = QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT id FROM account WHERE name = '{}' LIMIT 1",
|
||||||
|
destination_account_name
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.RowCount() == 0) {
|
||||||
|
LogError("No account found with name [{}]", destination_account_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
row = results.begin();
|
||||||
|
std::string source_account_id = row[0];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fresh ID
|
||||||
|
*/
|
||||||
|
results = QueryDatabase("SELECT (MAX(id) + 1) as new_id from character_data");
|
||||||
|
row = results.begin();
|
||||||
|
std::string new_character_id = row[0];
|
||||||
|
|
||||||
|
TransactionBegin();
|
||||||
|
for (const auto &iter : DatabaseSchema::GetCharacterTables()) {
|
||||||
|
std::string table_name = iter.first;
|
||||||
|
std::string character_id_column_name = iter.second;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Columns
|
||||||
|
*/
|
||||||
|
results = QueryDatabase(fmt::format("SHOW COLUMNS FROM {}", table_name));
|
||||||
|
std::vector<std::string> columns = {};
|
||||||
|
int column_count = 0;
|
||||||
|
for (row = results.begin(); row != results.end(); ++row) {
|
||||||
|
columns.emplace_back(row[0]);
|
||||||
|
column_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
results = QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT {} FROM {} WHERE {} = {}",
|
||||||
|
implode(",", wrap(columns, "`")),
|
||||||
|
table_name,
|
||||||
|
character_id_column_name,
|
||||||
|
source_character_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
std::vector<std::vector<std::string>> new_rows;
|
||||||
|
for (row = results.begin(); row != results.end(); ++row) {
|
||||||
|
std::vector<std::string> new_values = {};
|
||||||
|
for (int column_index = 0; column_index < column_count; column_index++) {
|
||||||
|
std::string column = columns[column_index];
|
||||||
|
std::string value = row[column_index] ? row[column_index] : "null";
|
||||||
|
|
||||||
|
if (column == character_id_column_name) {
|
||||||
|
value = new_character_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (column == "name" && table_name == "character_data") {
|
||||||
|
value = destination_character_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (column == "account_id" && table_name == "character_data") {
|
||||||
|
value = source_account_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
new_values.emplace_back(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
new_rows.emplace_back(new_values);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string insert_values;
|
||||||
|
std::vector<std::string> insert_rows;
|
||||||
|
|
||||||
|
for (auto &r: new_rows) {
|
||||||
|
std::string insert_row = "(" + implode(",", wrap(r, "'")) + ")";
|
||||||
|
insert_rows.emplace_back(insert_row);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!insert_rows.empty()) {
|
||||||
|
QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
table_name,
|
||||||
|
character_id_column_name,
|
||||||
|
new_character_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto insert = QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"INSERT INTO {} ({}) VALUES {}",
|
||||||
|
table_name,
|
||||||
|
implode(",", wrap(columns, "`")),
|
||||||
|
implode(",", insert_rows)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!insert.ErrorMessage().empty()) {
|
||||||
|
TransactionRollback();
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TransactionCommit();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -100,23 +100,40 @@ class Database : public DBcore {
|
|||||||
public:
|
public:
|
||||||
Database();
|
Database();
|
||||||
Database(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
|
Database(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
|
||||||
bool Connect(const char* host, const char* user, const char* passwd, const char* database, uint32 port);
|
bool Connect(const char* host, const char* user, const char* passwd, const char* database, uint32 port, std::string connection_label = "default");
|
||||||
~Database();
|
~Database();
|
||||||
|
|
||||||
/* Character Creation */
|
/* Character Creation */
|
||||||
|
|
||||||
bool AddToNameFilter(const char* name);
|
bool AddToNameFilter(const char *name);
|
||||||
bool CreateCharacter(uint32 account_id, char* name, uint16 gender, uint16 race, uint16 class_, uint8 str, uint8 sta, uint8 cha, uint8 dex, uint8 int_, uint8 agi, uint8 wis, uint8 face);
|
bool CreateCharacter(
|
||||||
bool DeleteCharacter(char* character_name);
|
uint32 account_id,
|
||||||
bool MoveCharacterToZone(const char* charname, const char* zonename);
|
char *name,
|
||||||
bool MoveCharacterToZone(const char* charname, const char* zonename,uint32 zoneid);
|
uint16 gender,
|
||||||
bool MoveCharacterToZone(uint32 iCharID, const char* iZonename);
|
uint16 race,
|
||||||
bool ReserveName(uint32 account_id, char* name);
|
uint16 class_,
|
||||||
bool SaveCharacterCreate(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp);
|
uint8 str,
|
||||||
bool SetHackerFlag(const char* accountname, const char* charactername, const char* hacked);
|
uint8 sta,
|
||||||
bool SetMQDetectionFlag(const char* accountname, const char* charactername, const char* hacked, const char* zone);
|
uint8 cha,
|
||||||
bool StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, EQ::InventoryProfile* inv);
|
uint8 dex,
|
||||||
bool UpdateName(const char* oldname, const char* newname);
|
uint8 int_,
|
||||||
|
uint8 agi,
|
||||||
|
uint8 wis,
|
||||||
|
uint8 face
|
||||||
|
);
|
||||||
|
bool DeleteCharacter(char *character_name);
|
||||||
|
bool MoveCharacterToZone(const char *charname, uint32 zone_id);
|
||||||
|
bool MoveCharacterToZone(uint32 character_id, uint32 zone_id);
|
||||||
|
bool ReserveName(uint32 account_id, char *name);
|
||||||
|
bool SaveCharacterCreate(uint32 character_id, uint32 account_id, PlayerProfile_Struct *pp);
|
||||||
|
bool SetHackerFlag(const char *accountname, const char *charactername, const char *hacked);
|
||||||
|
bool SetMQDetectionFlag(const char *accountname, const char *charactername, const char *hacked, const char *zone);
|
||||||
|
bool UpdateName(const char *oldname, const char *newname);
|
||||||
|
bool CopyCharacter(
|
||||||
|
std::string source_character_name,
|
||||||
|
std::string destination_character_name,
|
||||||
|
std::string destination_account_name
|
||||||
|
);
|
||||||
|
|
||||||
/* General Information Queries */
|
/* General Information Queries */
|
||||||
|
|
||||||
@ -156,7 +173,6 @@ public:
|
|||||||
bool VerifyInstanceAlive(uint16 instance_id, uint32 char_id);
|
bool VerifyInstanceAlive(uint16 instance_id, uint32 char_id);
|
||||||
bool VerifyZoneInstance(uint32 zone_id, uint16 instance_id);
|
bool VerifyZoneInstance(uint32 zone_id, uint16 instance_id);
|
||||||
|
|
||||||
uint16 GetInstanceID(const char* zone, uint32 charid, int16 version);
|
|
||||||
uint16 GetInstanceID(uint32 zone, uint32 charid, int16 version);
|
uint16 GetInstanceID(uint32 zone, uint32 charid, int16 version);
|
||||||
uint16 GetInstanceVersion(uint16 instance_id);
|
uint16 GetInstanceVersion(uint16 instance_id);
|
||||||
uint32 GetTimeRemainingInstance(uint16 instance_id, bool &is_perma);
|
uint32 GetTimeRemainingInstance(uint16 instance_id, bool &is_perma);
|
||||||
@ -244,16 +260,11 @@ public:
|
|||||||
/* General Queries */
|
/* General Queries */
|
||||||
|
|
||||||
bool GetSafePoints(const char* short_name, uint32 version, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, int16* minstatus = 0, uint8* minlevel = 0, char *flag_needed = nullptr);
|
bool GetSafePoints(const char* short_name, uint32 version, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, int16* minstatus = 0, uint8* minlevel = 0, char *flag_needed = nullptr);
|
||||||
bool GetSafePoints(uint32 zoneID, uint32 version, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, int16* minstatus = 0, uint8* minlevel = 0, char *flag_needed = nullptr) { return GetSafePoints(GetZoneName(zoneID), version, safe_x, safe_y, safe_z, minstatus, minlevel, flag_needed); }
|
|
||||||
bool GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zoneid = 0, float* graveyard_x = 0, float* graveyard_y = 0, float* graveyard_z = 0, float* graveyard_heading = 0);
|
bool GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zoneid = 0, float* graveyard_x = 0, float* graveyard_y = 0, float* graveyard_z = 0, float* graveyard_heading = 0);
|
||||||
bool GetZoneLongName(const char* short_name, char** long_name, char* file_name = 0, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, uint32* graveyard_id = 0, uint32* maxclients = 0);
|
bool GetZoneLongName(const char* short_name, char** long_name, char* file_name = 0, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, uint32* graveyard_id = 0, uint32* maxclients = 0);
|
||||||
bool LoadPTimers(uint32 charid, PTimerList &into);
|
bool LoadPTimers(uint32 charid, PTimerList &into);
|
||||||
bool LoadZoneNames();
|
|
||||||
|
|
||||||
const char* GetZoneName(uint32 zoneID, bool ErrorUnknown = false);
|
|
||||||
|
|
||||||
uint32 GetZoneGraveyardID(uint32 zone_id, uint32 version);
|
uint32 GetZoneGraveyardID(uint32 zone_id, uint32 version);
|
||||||
uint32 GetZoneID(const char* zonename);
|
|
||||||
|
|
||||||
uint8 GetPEQZone(uint32 zoneID, uint32 version);
|
uint8 GetPEQZone(uint32 zoneID, uint32 version);
|
||||||
uint8 GetRaceSkill(uint8 skillid, uint8 in_race);
|
uint8 GetRaceSkill(uint8 skillid, uint8 in_race);
|
||||||
@ -277,7 +288,6 @@ public:
|
|||||||
void LoadLogSettings(EQEmuLogSys::LogSettings* log_settings);
|
void LoadLogSettings(EQEmuLogSys::LogSettings* log_settings);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<uint32,std::string> zonename_array;
|
|
||||||
|
|
||||||
Mutex Mvarcache;
|
Mutex Mvarcache;
|
||||||
VarCache_Struct varcache;
|
VarCache_Struct varcache;
|
||||||
|
|||||||
@ -128,12 +128,23 @@ std::string DatabaseDumpService::GetMySQLVersion()
|
|||||||
std::string DatabaseDumpService::GetBaseMySQLDumpCommand()
|
std::string DatabaseDumpService::GetBaseMySQLDumpCommand()
|
||||||
{
|
{
|
||||||
auto config = EQEmuConfig::get();
|
auto config = EQEmuConfig::get();
|
||||||
|
if (IsDumpContentTables() && !config->ContentDbHost.empty()) {
|
||||||
|
return fmt::format(
|
||||||
|
"mysqldump -u {} -p{} -h {} --port={} {}",
|
||||||
|
config->ContentDbUsername,
|
||||||
|
config->ContentDbPassword,
|
||||||
|
config->ContentDbHost,
|
||||||
|
config->ContentDbPort,
|
||||||
|
config->ContentDbName
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return fmt::format(
|
return fmt::format(
|
||||||
"mysqldump -u {} -p{} -h {} {}",
|
"mysqldump -u {} -p{} -h {} --port={} {}",
|
||||||
config->DatabaseUsername,
|
config->DatabaseUsername,
|
||||||
config->DatabasePassword,
|
config->DatabasePassword,
|
||||||
config->DatabaseHost,
|
config->DatabaseHost,
|
||||||
|
config->DatabasePort,
|
||||||
config->DatabaseDB
|
config->DatabaseDB
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,6 +34,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
#define strcasecmp _stricmp
|
#define strcasecmp _stricmp
|
||||||
#else
|
#else
|
||||||
#include "unix.h"
|
#include "unix.h"
|
||||||
|
#include "../zone/zonedb.h"
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
@ -305,36 +306,6 @@ bool Database::VerifyZoneInstance(uint32 zone_id, uint16 instance_id)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16 Database::GetInstanceID(const char* zone, uint32 character_id, int16 version) {
|
|
||||||
|
|
||||||
std::string query = StringFormat(
|
|
||||||
"SELECT "
|
|
||||||
"instance_list.id "
|
|
||||||
"FROM "
|
|
||||||
"instance_list, "
|
|
||||||
"instance_list_player "
|
|
||||||
"WHERE "
|
|
||||||
"instance_list.zone = %u "
|
|
||||||
"AND instance_list.version = %u "
|
|
||||||
"AND instance_list.id = instance_list_player.id "
|
|
||||||
"AND instance_list_player.charid = %u "
|
|
||||||
"LIMIT 1 ",
|
|
||||||
GetZoneID(zone),
|
|
||||||
version,
|
|
||||||
character_id
|
|
||||||
);
|
|
||||||
auto results = QueryDatabase(query);
|
|
||||||
|
|
||||||
if (!results.Success())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (results.RowCount() == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
auto row = results.begin();
|
|
||||||
return atoi(row[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16 Database::GetInstanceID(uint32 zone, uint32 character_id, int16 version)
|
uint16 Database::GetInstanceID(uint32 zone, uint32 character_id, int16 version)
|
||||||
{
|
{
|
||||||
if (!zone)
|
if (!zone)
|
||||||
@ -501,15 +472,12 @@ void Database::AssignRaidToInstance(uint32 raid_id, uint32 instance_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Database::BuryCorpsesInInstance(uint16 instance_id) {
|
void Database::BuryCorpsesInInstance(uint16 instance_id) {
|
||||||
std::string query = StringFormat(
|
QueryDatabase(
|
||||||
"UPDATE `character_corpses` "
|
fmt::format(
|
||||||
"SET `is_buried` = 1, "
|
"UPDATE character_corpses SET is_buried = 1, instance_id = 0 WHERE instance_id = {}",
|
||||||
"`instance_id` = 0 "
|
|
||||||
"WHERE "
|
|
||||||
"`instance_id` = %u ",
|
|
||||||
instance_id
|
instance_id
|
||||||
|
)
|
||||||
);
|
);
|
||||||
auto results = QueryDatabase(query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::DeleteInstance(uint16 instance_id)
|
void Database::DeleteInstance(uint16 instance_id)
|
||||||
|
|||||||
@ -166,16 +166,12 @@ namespace DatabaseSchema {
|
|||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
"aa_ability",
|
"aa_ability",
|
||||||
"aa_actions",
|
|
||||||
"aa_effects",
|
|
||||||
"aa_rank_effects",
|
"aa_rank_effects",
|
||||||
"aa_rank_prereqs",
|
"aa_rank_prereqs",
|
||||||
"aa_ranks",
|
"aa_ranks",
|
||||||
"aa_required_level_cost",
|
|
||||||
"adventure_template",
|
"adventure_template",
|
||||||
"adventure_template_entry",
|
"adventure_template_entry",
|
||||||
"adventure_template_entry_flavor",
|
"adventure_template_entry_flavor",
|
||||||
"altadv_vars",
|
|
||||||
"alternate_currency",
|
"alternate_currency",
|
||||||
"auras",
|
"auras",
|
||||||
"base_data",
|
"base_data",
|
||||||
@ -183,13 +179,11 @@ namespace DatabaseSchema {
|
|||||||
"books",
|
"books",
|
||||||
"char_create_combinations",
|
"char_create_combinations",
|
||||||
"char_create_point_allocations",
|
"char_create_point_allocations",
|
||||||
"class_skill",
|
|
||||||
"damageshieldtypes",
|
"damageshieldtypes",
|
||||||
"doors",
|
"doors",
|
||||||
"faction_base_data",
|
"faction_base_data",
|
||||||
"faction_list",
|
"faction_list",
|
||||||
"faction_list_mod",
|
"faction_list_mod",
|
||||||
"fear_hints",
|
|
||||||
"fishing",
|
"fishing",
|
||||||
"forage",
|
"forage",
|
||||||
"global_loot",
|
"global_loot",
|
||||||
@ -199,7 +193,6 @@ namespace DatabaseSchema {
|
|||||||
"grid_entries",
|
"grid_entries",
|
||||||
"ground_spawns",
|
"ground_spawns",
|
||||||
"horses",
|
"horses",
|
||||||
"instance_list",
|
|
||||||
"items",
|
"items",
|
||||||
"ldon_trap_entries",
|
"ldon_trap_entries",
|
||||||
"ldon_trap_templates",
|
"ldon_trap_templates",
|
||||||
@ -217,19 +210,15 @@ namespace DatabaseSchema {
|
|||||||
"npc_spells_effects_entries",
|
"npc_spells_effects_entries",
|
||||||
"npc_spells_entries",
|
"npc_spells_entries",
|
||||||
"npc_types",
|
"npc_types",
|
||||||
"npc_types_metadata",
|
|
||||||
"npc_types_tint",
|
"npc_types_tint",
|
||||||
"object",
|
"object",
|
||||||
"pets",
|
"pets",
|
||||||
"pets_equipmentset",
|
"pets_equipmentset",
|
||||||
"pets_equipmentset_entries",
|
"pets_equipmentset_entries",
|
||||||
"proximities",
|
"proximities",
|
||||||
"races",
|
|
||||||
"skill_caps",
|
"skill_caps",
|
||||||
"spawn2",
|
"spawn2",
|
||||||
"spawn_condition_values",
|
|
||||||
"spawn_conditions",
|
"spawn_conditions",
|
||||||
"spawn_events",
|
|
||||||
"spawnentry",
|
"spawnentry",
|
||||||
"spawngroup",
|
"spawngroup",
|
||||||
"spells_new",
|
"spells_new",
|
||||||
@ -246,8 +235,6 @@ namespace DatabaseSchema {
|
|||||||
"veteran_reward_templates",
|
"veteran_reward_templates",
|
||||||
"zone",
|
"zone",
|
||||||
"zone_points",
|
"zone_points",
|
||||||
"zone_server",
|
|
||||||
"zoneserver_auth",
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,10 +248,13 @@ namespace DatabaseSchema {
|
|||||||
return {
|
return {
|
||||||
"chatchannels",
|
"chatchannels",
|
||||||
"command_settings",
|
"command_settings",
|
||||||
|
"content_flags",
|
||||||
"db_str",
|
"db_str",
|
||||||
"eqtime",
|
"eqtime",
|
||||||
"launcher",
|
"launcher",
|
||||||
"launcher_zones",
|
"launcher_zones",
|
||||||
|
"spawn_condition_values",
|
||||||
|
"spawn_events",
|
||||||
"level_exp_mods",
|
"level_exp_mods",
|
||||||
"logsys_categories",
|
"logsys_categories",
|
||||||
"name_filter",
|
"name_filter",
|
||||||
@ -321,6 +311,7 @@ namespace DatabaseSchema {
|
|||||||
"group_leaders",
|
"group_leaders",
|
||||||
"hackers",
|
"hackers",
|
||||||
"ip_exemptions",
|
"ip_exemptions",
|
||||||
|
"instance_list",
|
||||||
"item_tick",
|
"item_tick",
|
||||||
"lfguild",
|
"lfguild",
|
||||||
"merchantlist_temp",
|
"merchantlist_temp",
|
||||||
|
|||||||
@ -35,10 +35,10 @@
|
|||||||
DBcore::DBcore()
|
DBcore::DBcore()
|
||||||
{
|
{
|
||||||
mysql_init(&mysql);
|
mysql_init(&mysql);
|
||||||
pHost = 0;
|
pHost = nullptr;
|
||||||
pUser = 0;
|
pUser = nullptr;
|
||||||
pPassword = 0;
|
pPassword = nullptr;
|
||||||
pDatabase = 0;
|
pDatabase = nullptr;
|
||||||
pCompress = false;
|
pCompress = false;
|
||||||
pSSL = false;
|
pSSL = false;
|
||||||
pStatus = Closed;
|
pStatus = Closed;
|
||||||
@ -46,6 +46,20 @@ DBcore::DBcore()
|
|||||||
|
|
||||||
DBcore::~DBcore()
|
DBcore::~DBcore()
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* This prevents us from doing a double free in multi-tenancy setups where we
|
||||||
|
* are re-using the default database connection pointer when we dont have an
|
||||||
|
* external configuration setup ex: (content_database)
|
||||||
|
*/
|
||||||
|
std::string mysql_connection_host;
|
||||||
|
if (mysql.host) {
|
||||||
|
mysql_connection_host = mysql.host;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GetOriginHost() != mysql_connection_host) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mysql_close(&mysql);
|
mysql_close(&mysql);
|
||||||
safe_delete_array(pHost);
|
safe_delete_array(pHost);
|
||||||
safe_delete_array(pUser);
|
safe_delete_array(pUser);
|
||||||
@ -69,6 +83,13 @@ MySQLRequestResult DBcore::QueryDatabase(std::string query, bool retryOnFailureO
|
|||||||
return QueryDatabase(query.c_str(), query.length(), retryOnFailureOnce);
|
return QueryDatabase(query.c_str(), query.length(), retryOnFailureOnce);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DBcore::DoesTableExist(std::string table_name)
|
||||||
|
{
|
||||||
|
auto results = QueryDatabase(fmt::format("SHOW TABLES LIKE '{}'", table_name));
|
||||||
|
|
||||||
|
return results.RowCount() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
MySQLRequestResult DBcore::QueryDatabase(const char *query, uint32 querylen, bool retryOnFailureOnce)
|
MySQLRequestResult DBcore::QueryDatabase(const char *query, uint32 querylen, bool retryOnFailureOnce)
|
||||||
{
|
{
|
||||||
BenchTimer timer;
|
BenchTimer timer;
|
||||||
@ -81,6 +102,8 @@ MySQLRequestResult DBcore::QueryDatabase(const char *query, uint32 querylen, boo
|
|||||||
Open();
|
Open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// request query. != 0 indicates some kind of error.
|
// request query. != 0 indicates some kind of error.
|
||||||
if (mysql_real_query(&mysql, query, querylen) != 0) {
|
if (mysql_real_query(&mysql, query, querylen) != 0) {
|
||||||
unsigned int errorNumber = mysql_errno(&mysql);
|
unsigned int errorNumber = mysql_errno(&mysql);
|
||||||
@ -244,6 +267,10 @@ bool DBcore::Open(uint32 *errnum, char *errbuf)
|
|||||||
}
|
}
|
||||||
if (mysql_real_connect(&mysql, pHost, pUser, pPassword, pDatabase, pPort, 0, flags)) {
|
if (mysql_real_connect(&mysql, pHost, pUser, pPassword, pDatabase, pPort, 0, flags)) {
|
||||||
pStatus = Connected;
|
pStatus = Connected;
|
||||||
|
|
||||||
|
std::string connected_origin_host = pHost;
|
||||||
|
SetOriginHost(connected_origin_host);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -258,8 +285,17 @@ bool DBcore::Open(uint32 *errnum, char *errbuf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DBcore::SetMysql(MYSQL *mysql)
|
||||||
|
{
|
||||||
|
DBcore::mysql = *mysql;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &DBcore::GetOriginHost() const
|
||||||
|
{
|
||||||
|
return origin_host;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DBcore::SetOriginHost(const std::string &origin_host)
|
||||||
|
{
|
||||||
|
DBcore::origin_host = origin_host;
|
||||||
|
}
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
#define DBCORE_H
|
#define DBCORE_H
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../common/mutex.h"
|
#include "../common/mutex.h"
|
||||||
@ -15,33 +15,54 @@
|
|||||||
|
|
||||||
class DBcore {
|
class DBcore {
|
||||||
public:
|
public:
|
||||||
enum eStatus { Closed, Connected, Error };
|
enum eStatus {
|
||||||
|
Closed, Connected, Error
|
||||||
|
};
|
||||||
|
|
||||||
DBcore();
|
DBcore();
|
||||||
~DBcore();
|
~DBcore();
|
||||||
eStatus GetStatus() { return pStatus; }
|
eStatus GetStatus() { return pStatus; }
|
||||||
MySQLRequestResult QueryDatabase(const char* query, uint32 querylen, bool retryOnFailureOnce = true);
|
MySQLRequestResult QueryDatabase(const char *query, uint32 querylen, bool retryOnFailureOnce = true);
|
||||||
MySQLRequestResult QueryDatabase(std::string query, bool retryOnFailureOnce = true);
|
MySQLRequestResult QueryDatabase(std::string query, bool retryOnFailureOnce = true);
|
||||||
void TransactionBegin();
|
void TransactionBegin();
|
||||||
void TransactionCommit();
|
void TransactionCommit();
|
||||||
void TransactionRollback();
|
void TransactionRollback();
|
||||||
uint32 DoEscapeString(char* tobuf, const char* frombuf, uint32 fromlen);
|
uint32 DoEscapeString(char *tobuf, const char *frombuf, uint32 fromlen);
|
||||||
void ping();
|
void ping();
|
||||||
MYSQL* getMySQL(){ return &mysql; }
|
MYSQL *getMySQL() { return &mysql; }
|
||||||
|
void SetMysql(MYSQL *mysql);
|
||||||
|
|
||||||
|
const std::string &GetOriginHost() const;
|
||||||
|
void SetOriginHost(const std::string &origin_host);
|
||||||
|
|
||||||
|
bool DoesTableExist(std::string table_name);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool Open(const char* iHost, const char* iUser, const char* iPassword, const char* iDatabase, uint32 iPort, uint32* errnum = 0, char* errbuf = 0, bool iCompress = false, bool iSSL = false);
|
bool Open(
|
||||||
|
const char *iHost,
|
||||||
|
const char *iUser,
|
||||||
|
const char *iPassword,
|
||||||
|
const char *iDatabase,
|
||||||
|
uint32 iPort,
|
||||||
|
uint32 *errnum = 0,
|
||||||
|
char *errbuf = 0,
|
||||||
|
bool iCompress = false,
|
||||||
|
bool iSSL = false
|
||||||
|
);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool Open(uint32* errnum = 0, char* errbuf = 0);
|
bool Open(uint32 *errnum = nullptr, char *errbuf = nullptr);
|
||||||
|
|
||||||
MYSQL mysql;
|
MYSQL mysql;
|
||||||
Mutex MDatabase;
|
Mutex MDatabase;
|
||||||
eStatus pStatus;
|
eStatus pStatus;
|
||||||
|
|
||||||
char* pHost;
|
std::string origin_host;
|
||||||
char* pUser;
|
|
||||||
char* pPassword;
|
char *pHost;
|
||||||
char* pDatabase;
|
char *pUser;
|
||||||
|
char *pPassword;
|
||||||
|
char *pDatabase;
|
||||||
bool pCompress;
|
bool pCompress;
|
||||||
uint32 pPort;
|
uint32 pPort;
|
||||||
bool pSSL;
|
bool pSSL;
|
||||||
|
|||||||
@ -5351,8 +5351,10 @@ struct ServerLootItem_Struct {
|
|||||||
uint32 aug_5; // uint32 aug_5;
|
uint32 aug_5; // uint32 aug_5;
|
||||||
uint32 aug_6; // uint32 aug_5;
|
uint32 aug_6; // uint32 aug_5;
|
||||||
uint8 attuned;
|
uint8 attuned;
|
||||||
uint8 min_level;
|
uint16 trivial_min_level;
|
||||||
uint8 max_level;
|
uint16 trivial_max_level;
|
||||||
|
uint16 npc_min_level;
|
||||||
|
uint16 npc_max_level;
|
||||||
};
|
};
|
||||||
|
|
||||||
//Found in client near a ref to the string:
|
//Found in client near a ref to the string:
|
||||||
|
|||||||
@ -104,6 +104,15 @@ void EQEmuConfig::parse_config()
|
|||||||
DatabasePort = atoi(_root["server"]["database"].get("port", "3306").asString().c_str());
|
DatabasePort = atoi(_root["server"]["database"].get("port", "3306").asString().c_str());
|
||||||
DatabaseDB = _root["server"]["database"].get("db", "eq").asString();
|
DatabaseDB = _root["server"]["database"].get("db", "eq").asString();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Content Database
|
||||||
|
*/
|
||||||
|
ContentDbUsername = _root["server"]["content_database"].get("username", "").asString();
|
||||||
|
ContentDbPassword = _root["server"]["content_database"].get("password", "").asString();
|
||||||
|
ContentDbHost = _root["server"]["content_database"].get("host", "").asString();
|
||||||
|
ContentDbPort = atoi(_root["server"]["content_database"].get("port", 0).asString().c_str());
|
||||||
|
ContentDbName = _root["server"]["content_database"].get("db", "").asString();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* QS
|
* QS
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -74,6 +74,13 @@ class EQEmuConfig
|
|||||||
std::string DatabaseDB;
|
std::string DatabaseDB;
|
||||||
uint16 DatabasePort;
|
uint16 DatabasePort;
|
||||||
|
|
||||||
|
// From <content_database/>
|
||||||
|
std::string ContentDbHost;
|
||||||
|
std::string ContentDbUsername;
|
||||||
|
std::string ContentDbPassword;
|
||||||
|
std::string ContentDbName;
|
||||||
|
uint16 ContentDbPort;
|
||||||
|
|
||||||
// From <qsdatabase> // QueryServ
|
// From <qsdatabase> // QueryServ
|
||||||
std::string QSDatabaseHost;
|
std::string QSDatabaseHost;
|
||||||
std::string QSDatabaseUsername;
|
std::string QSDatabaseUsername;
|
||||||
|
|||||||
@ -126,6 +126,7 @@ void EQEmuLogSys::LoadLogSettingsDefaults()
|
|||||||
log_settings[Logs::NPCScaling].log_to_gmsay = static_cast<uint8>(Logs::General);
|
log_settings[Logs::NPCScaling].log_to_gmsay = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::HotReload].log_to_gmsay = static_cast<uint8>(Logs::General);
|
log_settings[Logs::HotReload].log_to_gmsay = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::HotReload].log_to_console = static_cast<uint8>(Logs::General);
|
log_settings[Logs::HotReload].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
|
log_settings[Logs::Loot].log_to_gmsay = static_cast<uint8>(Logs::General);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RFC 5424
|
* RFC 5424
|
||||||
|
|||||||
@ -115,6 +115,9 @@ namespace Logs {
|
|||||||
Flee,
|
Flee,
|
||||||
Aura,
|
Aura,
|
||||||
HotReload,
|
HotReload,
|
||||||
|
Merchants,
|
||||||
|
ZonePoints,
|
||||||
|
Loot,
|
||||||
MaxCategoryID /* Don't Remove this */
|
MaxCategoryID /* Don't Remove this */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -189,6 +192,9 @@ namespace Logs {
|
|||||||
"Flee",
|
"Flee",
|
||||||
"Aura",
|
"Aura",
|
||||||
"HotReload",
|
"HotReload",
|
||||||
|
"Merchants",
|
||||||
|
"ZonePoints",
|
||||||
|
"Loot"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -571,6 +571,36 @@
|
|||||||
OutF(LogSys, Logs::Detail, Logs::HotReload, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
OutF(LogSys, Logs::Detail, Logs::HotReload, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define LogMerchants(message, ...) do {\
|
||||||
|
if (LogSys.log_settings[Logs::Merchants].is_category_enabled == 1)\
|
||||||
|
OutF(LogSys, Logs::General, Logs::Merchants, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define LogMerchantsDetail(message, ...) do {\
|
||||||
|
if (LogSys.log_settings[Logs::Merchants].is_category_enabled == 1)\
|
||||||
|
OutF(LogSys, Logs::Detail, Logs::Merchants, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define LogZonePoints(message, ...) do {\
|
||||||
|
if (LogSys.log_settings[Logs::ZonePoints].is_category_enabled == 1)\
|
||||||
|
OutF(LogSys, Logs::General, Logs::ZonePoints, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define LogZonePointsDetail(message, ...) do {\
|
||||||
|
if (LogSys.log_settings[Logs::ZonePoints].is_category_enabled == 1)\
|
||||||
|
OutF(LogSys, Logs::Detail, Logs::ZonePoints, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define LogLoot(message, ...) do {\
|
||||||
|
if (LogSys.log_settings[Logs::Loot].is_category_enabled == 1)\
|
||||||
|
OutF(LogSys, Logs::General, Logs::Loot, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define LogLootDetail(message, ...) do {\
|
||||||
|
if (LogSys.log_settings[Logs::Loot].is_category_enabled == 1)\
|
||||||
|
OutF(LogSys, Logs::Detail, Logs::Loot, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define Log(debug_level, log_category, message, ...) do {\
|
#define Log(debug_level, log_category, message, ...) do {\
|
||||||
if (LogSys.log_settings[log_category].is_category_enabled == 1)\
|
if (LogSys.log_settings[log_category].is_category_enabled == 1)\
|
||||||
LogSys.Out(debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
LogSys.Out(debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||||
@ -910,6 +940,18 @@
|
|||||||
#define LogHotReloadDetail(message, ...) do {\
|
#define LogHotReloadDetail(message, ...) do {\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define LogMerchants(message, ...) do {\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define LogMerchantsDetail(message, ...) do {\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define LogZonePoints(message, ...) do {\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define LogZonePointsDetail(message, ...) do {\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define Log(debug_level, log_category, message, ...) do {\
|
#define Log(debug_level, log_category, message, ...) do {\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|||||||
@ -43,8 +43,10 @@ struct LootDropEntries_Struct {
|
|||||||
int8 item_charges;
|
int8 item_charges;
|
||||||
uint8 equip_item;
|
uint8 equip_item;
|
||||||
float chance;
|
float chance;
|
||||||
uint8 minlevel;
|
uint16 trivial_min_level;
|
||||||
uint8 maxlevel;
|
uint16 trivial_max_level;
|
||||||
|
uint16 npc_min_level;
|
||||||
|
uint16 npc_max_level;
|
||||||
uint8 multiplier;
|
uint8 multiplier;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
70
common/repositories/aa_ability_repository.h
Normal file
70
common/repositories/aa_ability_repository.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_AA_ABILITY_REPOSITORY_H
|
||||||
|
#define EQEMU_AA_ABILITY_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../string_util.h"
|
||||||
|
#include "base/base_aa_ability_repository.h"
|
||||||
|
|
||||||
|
class AaAbilityRepository: public BaseAaAbilityRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* AaAbilityRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* AaAbilityRepository::GetWhereNeverExpires()
|
||||||
|
* AaAbilityRepository::GetWhereXAndY()
|
||||||
|
* AaAbilityRepository::DeleteWhereXAndY()
|
||||||
|
*
|
||||||
|
* Most of the above could be covered by base methods, but if you as a developer
|
||||||
|
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||||
|
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||||
|
* method and encapsulate filters there
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Custom extended repository methods here
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_AA_ABILITY_REPOSITORY_H
|
||||||
70
common/repositories/aa_rank_effects_repository.h
Normal file
70
common/repositories/aa_rank_effects_repository.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_AA_RANK_EFFECTS_REPOSITORY_H
|
||||||
|
#define EQEMU_AA_RANK_EFFECTS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../string_util.h"
|
||||||
|
#include "base/base_aa_rank_effects_repository.h"
|
||||||
|
|
||||||
|
class AaRankEffectsRepository: public BaseAaRankEffectsRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* AaRankEffectsRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* AaRankEffectsRepository::GetWhereNeverExpires()
|
||||||
|
* AaRankEffectsRepository::GetWhereXAndY()
|
||||||
|
* AaRankEffectsRepository::DeleteWhereXAndY()
|
||||||
|
*
|
||||||
|
* Most of the above could be covered by base methods, but if you as a developer
|
||||||
|
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||||
|
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||||
|
* method and encapsulate filters there
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Custom extended repository methods here
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_AA_RANK_EFFECTS_REPOSITORY_H
|
||||||
70
common/repositories/aa_rank_prereqs_repository.h
Normal file
70
common/repositories/aa_rank_prereqs_repository.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_AA_RANK_PREREQS_REPOSITORY_H
|
||||||
|
#define EQEMU_AA_RANK_PREREQS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../string_util.h"
|
||||||
|
#include "base/base_aa_rank_prereqs_repository.h"
|
||||||
|
|
||||||
|
class AaRankPrereqsRepository: public BaseAaRankPrereqsRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* AaRankPrereqsRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* AaRankPrereqsRepository::GetWhereNeverExpires()
|
||||||
|
* AaRankPrereqsRepository::GetWhereXAndY()
|
||||||
|
* AaRankPrereqsRepository::DeleteWhereXAndY()
|
||||||
|
*
|
||||||
|
* Most of the above could be covered by base methods, but if you as a developer
|
||||||
|
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||||
|
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||||
|
* method and encapsulate filters there
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Custom extended repository methods here
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_AA_RANK_PREREQS_REPOSITORY_H
|
||||||
70
common/repositories/aa_ranks_repository.h
Normal file
70
common/repositories/aa_ranks_repository.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_AA_RANKS_REPOSITORY_H
|
||||||
|
#define EQEMU_AA_RANKS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../string_util.h"
|
||||||
|
#include "base/base_aa_ranks_repository.h"
|
||||||
|
|
||||||
|
class AaRanksRepository: public BaseAaRanksRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* AaRanksRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* AaRanksRepository::GetWhereNeverExpires()
|
||||||
|
* AaRanksRepository::GetWhereXAndY()
|
||||||
|
* AaRanksRepository::DeleteWhereXAndY()
|
||||||
|
*
|
||||||
|
* Most of the above could be covered by base methods, but if you as a developer
|
||||||
|
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||||
|
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||||
|
* method and encapsulate filters there
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Custom extended repository methods here
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_AA_RANKS_REPOSITORY_H
|
||||||
70
common/repositories/account_flags_repository.h
Normal file
70
common/repositories/account_flags_repository.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_ACCOUNT_FLAGS_REPOSITORY_H
|
||||||
|
#define EQEMU_ACCOUNT_FLAGS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../string_util.h"
|
||||||
|
#include "base/base_account_flags_repository.h"
|
||||||
|
|
||||||
|
class AccountFlagsRepository: public BaseAccountFlagsRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* AccountFlagsRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* AccountFlagsRepository::GetWhereNeverExpires()
|
||||||
|
* AccountFlagsRepository::GetWhereXAndY()
|
||||||
|
* AccountFlagsRepository::DeleteWhereXAndY()
|
||||||
|
*
|
||||||
|
* Most of the above could be covered by base methods, but if you as a developer
|
||||||
|
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||||
|
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||||
|
* method and encapsulate filters there
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Custom extended repository methods here
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_ACCOUNT_FLAGS_REPOSITORY_H
|
||||||
70
common/repositories/account_ip_repository.h
Normal file
70
common/repositories/account_ip_repository.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_ACCOUNT_IP_REPOSITORY_H
|
||||||
|
#define EQEMU_ACCOUNT_IP_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../string_util.h"
|
||||||
|
#include "base/base_account_ip_repository.h"
|
||||||
|
|
||||||
|
class AccountIpRepository: public BaseAccountIpRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* AccountIpRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* AccountIpRepository::GetWhereNeverExpires()
|
||||||
|
* AccountIpRepository::GetWhereXAndY()
|
||||||
|
* AccountIpRepository::DeleteWhereXAndY()
|
||||||
|
*
|
||||||
|
* Most of the above could be covered by base methods, but if you as a developer
|
||||||
|
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||||
|
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||||
|
* method and encapsulate filters there
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Custom extended repository methods here
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_ACCOUNT_IP_REPOSITORY_H
|
||||||
70
common/repositories/account_repository.h
Normal file
70
common/repositories/account_repository.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_ACCOUNT_REPOSITORY_H
|
||||||
|
#define EQEMU_ACCOUNT_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../string_util.h"
|
||||||
|
#include "base/base_account_repository.h"
|
||||||
|
|
||||||
|
class AccountRepository: public BaseAccountRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* AccountRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* AccountRepository::GetWhereNeverExpires()
|
||||||
|
* AccountRepository::GetWhereXAndY()
|
||||||
|
* AccountRepository::DeleteWhereXAndY()
|
||||||
|
*
|
||||||
|
* Most of the above could be covered by base methods, but if you as a developer
|
||||||
|
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||||
|
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||||
|
* method and encapsulate filters there
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Custom extended repository methods here
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_ACCOUNT_REPOSITORY_H
|
||||||
70
common/repositories/account_rewards_repository.h
Normal file
70
common/repositories/account_rewards_repository.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_ACCOUNT_REWARDS_REPOSITORY_H
|
||||||
|
#define EQEMU_ACCOUNT_REWARDS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../string_util.h"
|
||||||
|
#include "base/base_account_rewards_repository.h"
|
||||||
|
|
||||||
|
class AccountRewardsRepository: public BaseAccountRewardsRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* AccountRewardsRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* AccountRewardsRepository::GetWhereNeverExpires()
|
||||||
|
* AccountRewardsRepository::GetWhereXAndY()
|
||||||
|
* AccountRewardsRepository::DeleteWhereXAndY()
|
||||||
|
*
|
||||||
|
* Most of the above could be covered by base methods, but if you as a developer
|
||||||
|
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||||
|
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||||
|
* method and encapsulate filters there
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Custom extended repository methods here
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_ACCOUNT_REWARDS_REPOSITORY_H
|
||||||
70
common/repositories/adventure_details_repository.h
Normal file
70
common/repositories/adventure_details_repository.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_ADVENTURE_DETAILS_REPOSITORY_H
|
||||||
|
#define EQEMU_ADVENTURE_DETAILS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../string_util.h"
|
||||||
|
#include "base/base_adventure_details_repository.h"
|
||||||
|
|
||||||
|
class AdventureDetailsRepository: public BaseAdventureDetailsRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* AdventureDetailsRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* AdventureDetailsRepository::GetWhereNeverExpires()
|
||||||
|
* AdventureDetailsRepository::GetWhereXAndY()
|
||||||
|
* AdventureDetailsRepository::DeleteWhereXAndY()
|
||||||
|
*
|
||||||
|
* Most of the above could be covered by base methods, but if you as a developer
|
||||||
|
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||||
|
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||||
|
* method and encapsulate filters there
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Custom extended repository methods here
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_ADVENTURE_DETAILS_REPOSITORY_H
|
||||||
70
common/repositories/adventure_members_repository.h
Normal file
70
common/repositories/adventure_members_repository.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_ADVENTURE_MEMBERS_REPOSITORY_H
|
||||||
|
#define EQEMU_ADVENTURE_MEMBERS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../string_util.h"
|
||||||
|
#include "base/base_adventure_members_repository.h"
|
||||||
|
|
||||||
|
class AdventureMembersRepository: public BaseAdventureMembersRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* AdventureMembersRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* AdventureMembersRepository::GetWhereNeverExpires()
|
||||||
|
* AdventureMembersRepository::GetWhereXAndY()
|
||||||
|
* AdventureMembersRepository::DeleteWhereXAndY()
|
||||||
|
*
|
||||||
|
* Most of the above could be covered by base methods, but if you as a developer
|
||||||
|
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||||
|
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||||
|
* method and encapsulate filters there
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Custom extended repository methods here
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_ADVENTURE_MEMBERS_REPOSITORY_H
|
||||||
70
common/repositories/adventure_stats_repository.h
Normal file
70
common/repositories/adventure_stats_repository.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_ADVENTURE_STATS_REPOSITORY_H
|
||||||
|
#define EQEMU_ADVENTURE_STATS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../string_util.h"
|
||||||
|
#include "base/base_adventure_stats_repository.h"
|
||||||
|
|
||||||
|
class AdventureStatsRepository: public BaseAdventureStatsRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* AdventureStatsRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* AdventureStatsRepository::GetWhereNeverExpires()
|
||||||
|
* AdventureStatsRepository::GetWhereXAndY()
|
||||||
|
* AdventureStatsRepository::DeleteWhereXAndY()
|
||||||
|
*
|
||||||
|
* Most of the above could be covered by base methods, but if you as a developer
|
||||||
|
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||||
|
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||||
|
* method and encapsulate filters there
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Custom extended repository methods here
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_ADVENTURE_STATS_REPOSITORY_H
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_ADVENTURE_TEMPLATE_ENTRY_FLAVOR_REPOSITORY_H
|
||||||
|
#define EQEMU_ADVENTURE_TEMPLATE_ENTRY_FLAVOR_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../string_util.h"
|
||||||
|
#include "base/base_adventure_template_entry_flavor_repository.h"
|
||||||
|
|
||||||
|
class AdventureTemplateEntryFlavorRepository: public BaseAdventureTemplateEntryFlavorRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* AdventureTemplateEntryFlavorRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* AdventureTemplateEntryFlavorRepository::GetWhereNeverExpires()
|
||||||
|
* AdventureTemplateEntryFlavorRepository::GetWhereXAndY()
|
||||||
|
* AdventureTemplateEntryFlavorRepository::DeleteWhereXAndY()
|
||||||
|
*
|
||||||
|
* Most of the above could be covered by base methods, but if you as a developer
|
||||||
|
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||||
|
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||||
|
* method and encapsulate filters there
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Custom extended repository methods here
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_ADVENTURE_TEMPLATE_ENTRY_FLAVOR_REPOSITORY_H
|
||||||
70
common/repositories/adventure_template_entry_repository.h
Normal file
70
common/repositories/adventure_template_entry_repository.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_ADVENTURE_TEMPLATE_ENTRY_REPOSITORY_H
|
||||||
|
#define EQEMU_ADVENTURE_TEMPLATE_ENTRY_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../string_util.h"
|
||||||
|
#include "base/base_adventure_template_entry_repository.h"
|
||||||
|
|
||||||
|
class AdventureTemplateEntryRepository: public BaseAdventureTemplateEntryRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* AdventureTemplateEntryRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* AdventureTemplateEntryRepository::GetWhereNeverExpires()
|
||||||
|
* AdventureTemplateEntryRepository::GetWhereXAndY()
|
||||||
|
* AdventureTemplateEntryRepository::DeleteWhereXAndY()
|
||||||
|
*
|
||||||
|
* Most of the above could be covered by base methods, but if you as a developer
|
||||||
|
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||||
|
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||||
|
* method and encapsulate filters there
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Custom extended repository methods here
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_ADVENTURE_TEMPLATE_ENTRY_REPOSITORY_H
|
||||||
70
common/repositories/adventure_template_repository.h
Normal file
70
common/repositories/adventure_template_repository.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_ADVENTURE_TEMPLATE_REPOSITORY_H
|
||||||
|
#define EQEMU_ADVENTURE_TEMPLATE_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../string_util.h"
|
||||||
|
#include "base/base_adventure_template_repository.h"
|
||||||
|
|
||||||
|
class AdventureTemplateRepository: public BaseAdventureTemplateRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* AdventureTemplateRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* AdventureTemplateRepository::GetWhereNeverExpires()
|
||||||
|
* AdventureTemplateRepository::GetWhereXAndY()
|
||||||
|
* AdventureTemplateRepository::DeleteWhereXAndY()
|
||||||
|
*
|
||||||
|
* Most of the above could be covered by base methods, but if you as a developer
|
||||||
|
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||||
|
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||||
|
* method and encapsulate filters there
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Custom extended repository methods here
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_ADVENTURE_TEMPLATE_REPOSITORY_H
|
||||||
70
common/repositories/alternate_currency_repository.h
Normal file
70
common/repositories/alternate_currency_repository.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_ALTERNATE_CURRENCY_REPOSITORY_H
|
||||||
|
#define EQEMU_ALTERNATE_CURRENCY_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../string_util.h"
|
||||||
|
#include "base/base_alternate_currency_repository.h"
|
||||||
|
|
||||||
|
class AlternateCurrencyRepository: public BaseAlternateCurrencyRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* AlternateCurrencyRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* AlternateCurrencyRepository::GetWhereNeverExpires()
|
||||||
|
* AlternateCurrencyRepository::GetWhereXAndY()
|
||||||
|
* AlternateCurrencyRepository::DeleteWhereXAndY()
|
||||||
|
*
|
||||||
|
* Most of the above could be covered by base methods, but if you as a developer
|
||||||
|
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||||
|
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||||
|
* method and encapsulate filters there
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Custom extended repository methods here
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_ALTERNATE_CURRENCY_REPOSITORY_H
|
||||||
70
common/repositories/auras_repository.h
Normal file
70
common/repositories/auras_repository.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_AURAS_REPOSITORY_H
|
||||||
|
#define EQEMU_AURAS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../string_util.h"
|
||||||
|
#include "base/base_auras_repository.h"
|
||||||
|
|
||||||
|
class AurasRepository: public BaseAurasRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* AurasRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* AurasRepository::GetWhereNeverExpires()
|
||||||
|
* AurasRepository::GetWhereXAndY()
|
||||||
|
* AurasRepository::DeleteWhereXAndY()
|
||||||
|
*
|
||||||
|
* Most of the above could be covered by base methods, but if you as a developer
|
||||||
|
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||||
|
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||||
|
* method and encapsulate filters there
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Custom extended repository methods here
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_AURAS_REPOSITORY_H
|
||||||
428
common/repositories/base/base_aa_ability_repository.h
Normal file
428
common/repositories/base/base_aa_ability_repository.h
Normal file
@ -0,0 +1,428 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_AA_ABILITY_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_AA_ABILITY_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseAaAbilityRepository {
|
||||||
|
public:
|
||||||
|
struct AaAbility {
|
||||||
|
int id;
|
||||||
|
std::string name;
|
||||||
|
int category;
|
||||||
|
int classes;
|
||||||
|
int races;
|
||||||
|
int drakkin_heritage;
|
||||||
|
int deities;
|
||||||
|
int status;
|
||||||
|
int type;
|
||||||
|
int charges;
|
||||||
|
int grant_only;
|
||||||
|
int first_rank_id;
|
||||||
|
int enabled;
|
||||||
|
int reset_on_death;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"category",
|
||||||
|
"classes",
|
||||||
|
"races",
|
||||||
|
"drakkin_heritage",
|
||||||
|
"deities",
|
||||||
|
"status",
|
||||||
|
"type",
|
||||||
|
"charges",
|
||||||
|
"grant_only",
|
||||||
|
"first_rank_id",
|
||||||
|
"enabled",
|
||||||
|
"reset_on_death",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("aa_ability");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AaAbility NewEntity()
|
||||||
|
{
|
||||||
|
AaAbility entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.name = "";
|
||||||
|
entry.category = -1;
|
||||||
|
entry.classes = 131070;
|
||||||
|
entry.races = 65535;
|
||||||
|
entry.drakkin_heritage = 127;
|
||||||
|
entry.deities = 131071;
|
||||||
|
entry.status = 0;
|
||||||
|
entry.type = 0;
|
||||||
|
entry.charges = 0;
|
||||||
|
entry.grant_only = 0;
|
||||||
|
entry.first_rank_id = -1;
|
||||||
|
entry.enabled = 1;
|
||||||
|
entry.reset_on_death = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static AaAbility GetAaAbilityEntry(
|
||||||
|
const std::vector<AaAbility> &aa_abilitys,
|
||||||
|
int aa_ability_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &aa_ability : aa_abilitys) {
|
||||||
|
if (aa_ability.id == aa_ability_id) {
|
||||||
|
return aa_ability;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static AaAbility FindOne(
|
||||||
|
int aa_ability_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
aa_ability_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
AaAbility entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.name = row[1] ? row[1] : "";
|
||||||
|
entry.category = atoi(row[2]);
|
||||||
|
entry.classes = atoi(row[3]);
|
||||||
|
entry.races = atoi(row[4]);
|
||||||
|
entry.drakkin_heritage = atoi(row[5]);
|
||||||
|
entry.deities = atoi(row[6]);
|
||||||
|
entry.status = atoi(row[7]);
|
||||||
|
entry.type = atoi(row[8]);
|
||||||
|
entry.charges = atoi(row[9]);
|
||||||
|
entry.grant_only = atoi(row[10]);
|
||||||
|
entry.first_rank_id = atoi(row[11]);
|
||||||
|
entry.enabled = atoi(row[12]);
|
||||||
|
entry.reset_on_death = atoi(row[13]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int aa_ability_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
aa_ability_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
AaAbility aa_ability_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(aa_ability_entry.id));
|
||||||
|
update_values.push_back(columns[1] + " = '" + EscapeString(aa_ability_entry.name) + "'");
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(aa_ability_entry.category));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(aa_ability_entry.classes));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(aa_ability_entry.races));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(aa_ability_entry.drakkin_heritage));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(aa_ability_entry.deities));
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(aa_ability_entry.status));
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(aa_ability_entry.type));
|
||||||
|
update_values.push_back(columns[9] + " = " + std::to_string(aa_ability_entry.charges));
|
||||||
|
update_values.push_back(columns[10] + " = " + std::to_string(aa_ability_entry.grant_only));
|
||||||
|
update_values.push_back(columns[11] + " = " + std::to_string(aa_ability_entry.first_rank_id));
|
||||||
|
update_values.push_back(columns[12] + " = " + std::to_string(aa_ability_entry.enabled));
|
||||||
|
update_values.push_back(columns[13] + " = " + std::to_string(aa_ability_entry.reset_on_death));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
aa_ability_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AaAbility InsertOne(
|
||||||
|
AaAbility aa_ability_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.id));
|
||||||
|
insert_values.push_back("'" + EscapeString(aa_ability_entry.name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.category));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.classes));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.races));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.drakkin_heritage));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.deities));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.status));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.type));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.charges));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.grant_only));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.first_rank_id));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.enabled));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.reset_on_death));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
aa_ability_entry.id = results.LastInsertedID();
|
||||||
|
return aa_ability_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
aa_ability_entry = NewEntity();
|
||||||
|
|
||||||
|
return aa_ability_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<AaAbility> aa_ability_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &aa_ability_entry: aa_ability_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.id));
|
||||||
|
insert_values.push_back("'" + EscapeString(aa_ability_entry.name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.category));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.classes));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.races));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.drakkin_heritage));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.deities));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.status));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.type));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.charges));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.grant_only));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.first_rank_id));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.enabled));
|
||||||
|
insert_values.push_back(std::to_string(aa_ability_entry.reset_on_death));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AaAbility> All()
|
||||||
|
{
|
||||||
|
std::vector<AaAbility> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AaAbility entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.name = row[1] ? row[1] : "";
|
||||||
|
entry.category = atoi(row[2]);
|
||||||
|
entry.classes = atoi(row[3]);
|
||||||
|
entry.races = atoi(row[4]);
|
||||||
|
entry.drakkin_heritage = atoi(row[5]);
|
||||||
|
entry.deities = atoi(row[6]);
|
||||||
|
entry.status = atoi(row[7]);
|
||||||
|
entry.type = atoi(row[8]);
|
||||||
|
entry.charges = atoi(row[9]);
|
||||||
|
entry.grant_only = atoi(row[10]);
|
||||||
|
entry.first_rank_id = atoi(row[11]);
|
||||||
|
entry.enabled = atoi(row[12]);
|
||||||
|
entry.reset_on_death = atoi(row[13]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AaAbility> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<AaAbility> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AaAbility entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.name = row[1] ? row[1] : "";
|
||||||
|
entry.category = atoi(row[2]);
|
||||||
|
entry.classes = atoi(row[3]);
|
||||||
|
entry.races = atoi(row[4]);
|
||||||
|
entry.drakkin_heritage = atoi(row[5]);
|
||||||
|
entry.deities = atoi(row[6]);
|
||||||
|
entry.status = atoi(row[7]);
|
||||||
|
entry.type = atoi(row[8]);
|
||||||
|
entry.charges = atoi(row[9]);
|
||||||
|
entry.grant_only = atoi(row[10]);
|
||||||
|
entry.first_rank_id = atoi(row[11]);
|
||||||
|
entry.enabled = atoi(row[12]);
|
||||||
|
entry.reset_on_death = atoi(row[13]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_AA_ABILITY_REPOSITORY_H
|
||||||
347
common/repositories/base/base_aa_rank_effects_repository.h
Normal file
347
common/repositories/base/base_aa_rank_effects_repository.h
Normal file
@ -0,0 +1,347 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_AA_RANK_EFFECTS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_AA_RANK_EFFECTS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseAaRankEffectsRepository {
|
||||||
|
public:
|
||||||
|
struct AaRankEffects {
|
||||||
|
int rank_id;
|
||||||
|
int slot;
|
||||||
|
int effect_id;
|
||||||
|
int base1;
|
||||||
|
int base2;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("rank_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"rank_id",
|
||||||
|
"slot",
|
||||||
|
"effect_id",
|
||||||
|
"base1",
|
||||||
|
"base2",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("aa_rank_effects");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AaRankEffects NewEntity()
|
||||||
|
{
|
||||||
|
AaRankEffects entry{};
|
||||||
|
|
||||||
|
entry.rank_id = 0;
|
||||||
|
entry.slot = 1;
|
||||||
|
entry.effect_id = 0;
|
||||||
|
entry.base1 = 0;
|
||||||
|
entry.base2 = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static AaRankEffects GetAaRankEffectsEntry(
|
||||||
|
const std::vector<AaRankEffects> &aa_rank_effectss,
|
||||||
|
int aa_rank_effects_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &aa_rank_effects : aa_rank_effectss) {
|
||||||
|
if (aa_rank_effects.rank_id == aa_rank_effects_id) {
|
||||||
|
return aa_rank_effects;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static AaRankEffects FindOne(
|
||||||
|
int aa_rank_effects_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
aa_rank_effects_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
AaRankEffects entry{};
|
||||||
|
|
||||||
|
entry.rank_id = atoi(row[0]);
|
||||||
|
entry.slot = atoi(row[1]);
|
||||||
|
entry.effect_id = atoi(row[2]);
|
||||||
|
entry.base1 = atoi(row[3]);
|
||||||
|
entry.base2 = atoi(row[4]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int aa_rank_effects_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
aa_rank_effects_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
AaRankEffects aa_rank_effects_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(aa_rank_effects_entry.rank_id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(aa_rank_effects_entry.slot));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(aa_rank_effects_entry.effect_id));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(aa_rank_effects_entry.base1));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(aa_rank_effects_entry.base2));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
aa_rank_effects_entry.rank_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AaRankEffects InsertOne(
|
||||||
|
AaRankEffects aa_rank_effects_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(aa_rank_effects_entry.rank_id));
|
||||||
|
insert_values.push_back(std::to_string(aa_rank_effects_entry.slot));
|
||||||
|
insert_values.push_back(std::to_string(aa_rank_effects_entry.effect_id));
|
||||||
|
insert_values.push_back(std::to_string(aa_rank_effects_entry.base1));
|
||||||
|
insert_values.push_back(std::to_string(aa_rank_effects_entry.base2));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
aa_rank_effects_entry.rank_id = results.LastInsertedID();
|
||||||
|
return aa_rank_effects_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
aa_rank_effects_entry = NewEntity();
|
||||||
|
|
||||||
|
return aa_rank_effects_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<AaRankEffects> aa_rank_effects_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &aa_rank_effects_entry: aa_rank_effects_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(aa_rank_effects_entry.rank_id));
|
||||||
|
insert_values.push_back(std::to_string(aa_rank_effects_entry.slot));
|
||||||
|
insert_values.push_back(std::to_string(aa_rank_effects_entry.effect_id));
|
||||||
|
insert_values.push_back(std::to_string(aa_rank_effects_entry.base1));
|
||||||
|
insert_values.push_back(std::to_string(aa_rank_effects_entry.base2));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AaRankEffects> All()
|
||||||
|
{
|
||||||
|
std::vector<AaRankEffects> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AaRankEffects entry{};
|
||||||
|
|
||||||
|
entry.rank_id = atoi(row[0]);
|
||||||
|
entry.slot = atoi(row[1]);
|
||||||
|
entry.effect_id = atoi(row[2]);
|
||||||
|
entry.base1 = atoi(row[3]);
|
||||||
|
entry.base2 = atoi(row[4]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AaRankEffects> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<AaRankEffects> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AaRankEffects entry{};
|
||||||
|
|
||||||
|
entry.rank_id = atoi(row[0]);
|
||||||
|
entry.slot = atoi(row[1]);
|
||||||
|
entry.effect_id = atoi(row[2]);
|
||||||
|
entry.base1 = atoi(row[3]);
|
||||||
|
entry.base2 = atoi(row[4]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_AA_RANK_EFFECTS_REPOSITORY_H
|
||||||
329
common/repositories/base/base_aa_rank_prereqs_repository.h
Normal file
329
common/repositories/base/base_aa_rank_prereqs_repository.h
Normal file
@ -0,0 +1,329 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_AA_RANK_PREREQS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_AA_RANK_PREREQS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseAaRankPrereqsRepository {
|
||||||
|
public:
|
||||||
|
struct AaRankPrereqs {
|
||||||
|
int rank_id;
|
||||||
|
int aa_id;
|
||||||
|
int points;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("rank_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"rank_id",
|
||||||
|
"aa_id",
|
||||||
|
"points",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("aa_rank_prereqs");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AaRankPrereqs NewEntity()
|
||||||
|
{
|
||||||
|
AaRankPrereqs entry{};
|
||||||
|
|
||||||
|
entry.rank_id = 0;
|
||||||
|
entry.aa_id = 0;
|
||||||
|
entry.points = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static AaRankPrereqs GetAaRankPrereqsEntry(
|
||||||
|
const std::vector<AaRankPrereqs> &aa_rank_prereqss,
|
||||||
|
int aa_rank_prereqs_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &aa_rank_prereqs : aa_rank_prereqss) {
|
||||||
|
if (aa_rank_prereqs.rank_id == aa_rank_prereqs_id) {
|
||||||
|
return aa_rank_prereqs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static AaRankPrereqs FindOne(
|
||||||
|
int aa_rank_prereqs_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
aa_rank_prereqs_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
AaRankPrereqs entry{};
|
||||||
|
|
||||||
|
entry.rank_id = atoi(row[0]);
|
||||||
|
entry.aa_id = atoi(row[1]);
|
||||||
|
entry.points = atoi(row[2]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int aa_rank_prereqs_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
aa_rank_prereqs_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
AaRankPrereqs aa_rank_prereqs_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(aa_rank_prereqs_entry.rank_id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(aa_rank_prereqs_entry.aa_id));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(aa_rank_prereqs_entry.points));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
aa_rank_prereqs_entry.rank_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AaRankPrereqs InsertOne(
|
||||||
|
AaRankPrereqs aa_rank_prereqs_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(aa_rank_prereqs_entry.rank_id));
|
||||||
|
insert_values.push_back(std::to_string(aa_rank_prereqs_entry.aa_id));
|
||||||
|
insert_values.push_back(std::to_string(aa_rank_prereqs_entry.points));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
aa_rank_prereqs_entry.rank_id = results.LastInsertedID();
|
||||||
|
return aa_rank_prereqs_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
aa_rank_prereqs_entry = NewEntity();
|
||||||
|
|
||||||
|
return aa_rank_prereqs_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<AaRankPrereqs> aa_rank_prereqs_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &aa_rank_prereqs_entry: aa_rank_prereqs_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(aa_rank_prereqs_entry.rank_id));
|
||||||
|
insert_values.push_back(std::to_string(aa_rank_prereqs_entry.aa_id));
|
||||||
|
insert_values.push_back(std::to_string(aa_rank_prereqs_entry.points));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AaRankPrereqs> All()
|
||||||
|
{
|
||||||
|
std::vector<AaRankPrereqs> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AaRankPrereqs entry{};
|
||||||
|
|
||||||
|
entry.rank_id = atoi(row[0]);
|
||||||
|
entry.aa_id = atoi(row[1]);
|
||||||
|
entry.points = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AaRankPrereqs> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<AaRankPrereqs> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AaRankPrereqs entry{};
|
||||||
|
|
||||||
|
entry.rank_id = atoi(row[0]);
|
||||||
|
entry.aa_id = atoi(row[1]);
|
||||||
|
entry.points = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_AA_RANK_PREREQS_REPOSITORY_H
|
||||||
419
common/repositories/base/base_aa_ranks_repository.h
Normal file
419
common/repositories/base/base_aa_ranks_repository.h
Normal file
@ -0,0 +1,419 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_AA_RANKS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_AA_RANKS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseAaRanksRepository {
|
||||||
|
public:
|
||||||
|
struct AaRanks {
|
||||||
|
int id;
|
||||||
|
int upper_hotkey_sid;
|
||||||
|
int lower_hotkey_sid;
|
||||||
|
int title_sid;
|
||||||
|
int desc_sid;
|
||||||
|
int cost;
|
||||||
|
int level_req;
|
||||||
|
int spell;
|
||||||
|
int spell_type;
|
||||||
|
int recast_time;
|
||||||
|
int expansion;
|
||||||
|
int prev_id;
|
||||||
|
int next_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"upper_hotkey_sid",
|
||||||
|
"lower_hotkey_sid",
|
||||||
|
"title_sid",
|
||||||
|
"desc_sid",
|
||||||
|
"cost",
|
||||||
|
"level_req",
|
||||||
|
"spell",
|
||||||
|
"spell_type",
|
||||||
|
"recast_time",
|
||||||
|
"expansion",
|
||||||
|
"prev_id",
|
||||||
|
"next_id",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("aa_ranks");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AaRanks NewEntity()
|
||||||
|
{
|
||||||
|
AaRanks entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.upper_hotkey_sid = -1;
|
||||||
|
entry.lower_hotkey_sid = -1;
|
||||||
|
entry.title_sid = -1;
|
||||||
|
entry.desc_sid = -1;
|
||||||
|
entry.cost = 1;
|
||||||
|
entry.level_req = 51;
|
||||||
|
entry.spell = -1;
|
||||||
|
entry.spell_type = 0;
|
||||||
|
entry.recast_time = 0;
|
||||||
|
entry.expansion = 0;
|
||||||
|
entry.prev_id = -1;
|
||||||
|
entry.next_id = -1;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static AaRanks GetAaRanksEntry(
|
||||||
|
const std::vector<AaRanks> &aa_rankss,
|
||||||
|
int aa_ranks_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &aa_ranks : aa_rankss) {
|
||||||
|
if (aa_ranks.id == aa_ranks_id) {
|
||||||
|
return aa_ranks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static AaRanks FindOne(
|
||||||
|
int aa_ranks_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
aa_ranks_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
AaRanks entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.upper_hotkey_sid = atoi(row[1]);
|
||||||
|
entry.lower_hotkey_sid = atoi(row[2]);
|
||||||
|
entry.title_sid = atoi(row[3]);
|
||||||
|
entry.desc_sid = atoi(row[4]);
|
||||||
|
entry.cost = atoi(row[5]);
|
||||||
|
entry.level_req = atoi(row[6]);
|
||||||
|
entry.spell = atoi(row[7]);
|
||||||
|
entry.spell_type = atoi(row[8]);
|
||||||
|
entry.recast_time = atoi(row[9]);
|
||||||
|
entry.expansion = atoi(row[10]);
|
||||||
|
entry.prev_id = atoi(row[11]);
|
||||||
|
entry.next_id = atoi(row[12]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int aa_ranks_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
aa_ranks_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
AaRanks aa_ranks_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(aa_ranks_entry.id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(aa_ranks_entry.upper_hotkey_sid));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(aa_ranks_entry.lower_hotkey_sid));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(aa_ranks_entry.title_sid));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(aa_ranks_entry.desc_sid));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(aa_ranks_entry.cost));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(aa_ranks_entry.level_req));
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(aa_ranks_entry.spell));
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(aa_ranks_entry.spell_type));
|
||||||
|
update_values.push_back(columns[9] + " = " + std::to_string(aa_ranks_entry.recast_time));
|
||||||
|
update_values.push_back(columns[10] + " = " + std::to_string(aa_ranks_entry.expansion));
|
||||||
|
update_values.push_back(columns[11] + " = " + std::to_string(aa_ranks_entry.prev_id));
|
||||||
|
update_values.push_back(columns[12] + " = " + std::to_string(aa_ranks_entry.next_id));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
aa_ranks_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AaRanks InsertOne(
|
||||||
|
AaRanks aa_ranks_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.upper_hotkey_sid));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.lower_hotkey_sid));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.title_sid));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.desc_sid));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.cost));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.level_req));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.spell));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.spell_type));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.recast_time));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.expansion));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.prev_id));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.next_id));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
aa_ranks_entry.id = results.LastInsertedID();
|
||||||
|
return aa_ranks_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
aa_ranks_entry = NewEntity();
|
||||||
|
|
||||||
|
return aa_ranks_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<AaRanks> aa_ranks_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &aa_ranks_entry: aa_ranks_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.upper_hotkey_sid));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.lower_hotkey_sid));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.title_sid));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.desc_sid));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.cost));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.level_req));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.spell));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.spell_type));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.recast_time));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.expansion));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.prev_id));
|
||||||
|
insert_values.push_back(std::to_string(aa_ranks_entry.next_id));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AaRanks> All()
|
||||||
|
{
|
||||||
|
std::vector<AaRanks> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AaRanks entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.upper_hotkey_sid = atoi(row[1]);
|
||||||
|
entry.lower_hotkey_sid = atoi(row[2]);
|
||||||
|
entry.title_sid = atoi(row[3]);
|
||||||
|
entry.desc_sid = atoi(row[4]);
|
||||||
|
entry.cost = atoi(row[5]);
|
||||||
|
entry.level_req = atoi(row[6]);
|
||||||
|
entry.spell = atoi(row[7]);
|
||||||
|
entry.spell_type = atoi(row[8]);
|
||||||
|
entry.recast_time = atoi(row[9]);
|
||||||
|
entry.expansion = atoi(row[10]);
|
||||||
|
entry.prev_id = atoi(row[11]);
|
||||||
|
entry.next_id = atoi(row[12]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AaRanks> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<AaRanks> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AaRanks entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.upper_hotkey_sid = atoi(row[1]);
|
||||||
|
entry.lower_hotkey_sid = atoi(row[2]);
|
||||||
|
entry.title_sid = atoi(row[3]);
|
||||||
|
entry.desc_sid = atoi(row[4]);
|
||||||
|
entry.cost = atoi(row[5]);
|
||||||
|
entry.level_req = atoi(row[6]);
|
||||||
|
entry.spell = atoi(row[7]);
|
||||||
|
entry.spell_type = atoi(row[8]);
|
||||||
|
entry.recast_time = atoi(row[9]);
|
||||||
|
entry.expansion = atoi(row[10]);
|
||||||
|
entry.prev_id = atoi(row[11]);
|
||||||
|
entry.next_id = atoi(row[12]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_AA_RANKS_REPOSITORY_H
|
||||||
329
common/repositories/base/base_account_flags_repository.h
Normal file
329
common/repositories/base/base_account_flags_repository.h
Normal file
@ -0,0 +1,329 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_ACCOUNT_FLAGS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_ACCOUNT_FLAGS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseAccountFlagsRepository {
|
||||||
|
public:
|
||||||
|
struct AccountFlags {
|
||||||
|
int p_accid;
|
||||||
|
std::string p_flag;
|
||||||
|
std::string p_value;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("p_accid");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"p_accid",
|
||||||
|
"p_flag",
|
||||||
|
"p_value",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("account_flags");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AccountFlags NewEntity()
|
||||||
|
{
|
||||||
|
AccountFlags entry{};
|
||||||
|
|
||||||
|
entry.p_accid = 0;
|
||||||
|
entry.p_flag = "";
|
||||||
|
entry.p_value = "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static AccountFlags GetAccountFlagsEntry(
|
||||||
|
const std::vector<AccountFlags> &account_flagss,
|
||||||
|
int account_flags_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &account_flags : account_flagss) {
|
||||||
|
if (account_flags.p_accid == account_flags_id) {
|
||||||
|
return account_flags;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static AccountFlags FindOne(
|
||||||
|
int account_flags_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
account_flags_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
AccountFlags entry{};
|
||||||
|
|
||||||
|
entry.p_accid = atoi(row[0]);
|
||||||
|
entry.p_flag = row[1] ? row[1] : "";
|
||||||
|
entry.p_value = row[2] ? row[2] : "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int account_flags_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
account_flags_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
AccountFlags account_flags_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(account_flags_entry.p_accid));
|
||||||
|
update_values.push_back(columns[1] + " = '" + EscapeString(account_flags_entry.p_flag) + "'");
|
||||||
|
update_values.push_back(columns[2] + " = '" + EscapeString(account_flags_entry.p_value) + "'");
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
account_flags_entry.p_accid
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AccountFlags InsertOne(
|
||||||
|
AccountFlags account_flags_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(account_flags_entry.p_accid));
|
||||||
|
insert_values.push_back("'" + EscapeString(account_flags_entry.p_flag) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(account_flags_entry.p_value) + "'");
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
account_flags_entry.p_accid = results.LastInsertedID();
|
||||||
|
return account_flags_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
account_flags_entry = NewEntity();
|
||||||
|
|
||||||
|
return account_flags_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<AccountFlags> account_flags_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &account_flags_entry: account_flags_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(account_flags_entry.p_accid));
|
||||||
|
insert_values.push_back("'" + EscapeString(account_flags_entry.p_flag) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(account_flags_entry.p_value) + "'");
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AccountFlags> All()
|
||||||
|
{
|
||||||
|
std::vector<AccountFlags> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AccountFlags entry{};
|
||||||
|
|
||||||
|
entry.p_accid = atoi(row[0]);
|
||||||
|
entry.p_flag = row[1] ? row[1] : "";
|
||||||
|
entry.p_value = row[2] ? row[2] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AccountFlags> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<AccountFlags> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AccountFlags entry{};
|
||||||
|
|
||||||
|
entry.p_accid = atoi(row[0]);
|
||||||
|
entry.p_flag = row[1] ? row[1] : "";
|
||||||
|
entry.p_value = row[2] ? row[2] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_ACCOUNT_FLAGS_REPOSITORY_H
|
||||||
338
common/repositories/base/base_account_ip_repository.h
Normal file
338
common/repositories/base/base_account_ip_repository.h
Normal file
@ -0,0 +1,338 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_ACCOUNT_IP_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_ACCOUNT_IP_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseAccountIpRepository {
|
||||||
|
public:
|
||||||
|
struct AccountIp {
|
||||||
|
int accid;
|
||||||
|
std::string ip;
|
||||||
|
int count;
|
||||||
|
std::string lastused;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("accid");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"accid",
|
||||||
|
"ip",
|
||||||
|
"count",
|
||||||
|
"lastused",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("account_ip");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AccountIp NewEntity()
|
||||||
|
{
|
||||||
|
AccountIp entry{};
|
||||||
|
|
||||||
|
entry.accid = 0;
|
||||||
|
entry.ip = "";
|
||||||
|
entry.count = 1;
|
||||||
|
entry.lastused = current_timestamp();
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static AccountIp GetAccountIpEntry(
|
||||||
|
const std::vector<AccountIp> &account_ips,
|
||||||
|
int account_ip_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &account_ip : account_ips) {
|
||||||
|
if (account_ip.accid == account_ip_id) {
|
||||||
|
return account_ip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static AccountIp FindOne(
|
||||||
|
int account_ip_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
account_ip_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
AccountIp entry{};
|
||||||
|
|
||||||
|
entry.accid = atoi(row[0]);
|
||||||
|
entry.ip = row[1] ? row[1] : "";
|
||||||
|
entry.count = atoi(row[2]);
|
||||||
|
entry.lastused = row[3] ? row[3] : "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int account_ip_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
account_ip_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
AccountIp account_ip_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(account_ip_entry.accid));
|
||||||
|
update_values.push_back(columns[1] + " = '" + EscapeString(account_ip_entry.ip) + "'");
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(account_ip_entry.count));
|
||||||
|
update_values.push_back(columns[3] + " = '" + EscapeString(account_ip_entry.lastused) + "'");
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
account_ip_entry.accid
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AccountIp InsertOne(
|
||||||
|
AccountIp account_ip_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(account_ip_entry.accid));
|
||||||
|
insert_values.push_back("'" + EscapeString(account_ip_entry.ip) + "'");
|
||||||
|
insert_values.push_back(std::to_string(account_ip_entry.count));
|
||||||
|
insert_values.push_back("'" + EscapeString(account_ip_entry.lastused) + "'");
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
account_ip_entry.accid = results.LastInsertedID();
|
||||||
|
return account_ip_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
account_ip_entry = NewEntity();
|
||||||
|
|
||||||
|
return account_ip_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<AccountIp> account_ip_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &account_ip_entry: account_ip_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(account_ip_entry.accid));
|
||||||
|
insert_values.push_back("'" + EscapeString(account_ip_entry.ip) + "'");
|
||||||
|
insert_values.push_back(std::to_string(account_ip_entry.count));
|
||||||
|
insert_values.push_back("'" + EscapeString(account_ip_entry.lastused) + "'");
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AccountIp> All()
|
||||||
|
{
|
||||||
|
std::vector<AccountIp> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AccountIp entry{};
|
||||||
|
|
||||||
|
entry.accid = atoi(row[0]);
|
||||||
|
entry.ip = row[1] ? row[1] : "";
|
||||||
|
entry.count = atoi(row[2]);
|
||||||
|
entry.lastused = row[3] ? row[3] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AccountIp> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<AccountIp> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AccountIp entry{};
|
||||||
|
|
||||||
|
entry.accid = atoi(row[0]);
|
||||||
|
entry.ip = row[1] ? row[1] : "";
|
||||||
|
entry.count = atoi(row[2]);
|
||||||
|
entry.lastused = row[3] ? row[3] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_ACCOUNT_IP_REPOSITORY_H
|
||||||
470
common/repositories/base/base_account_repository.h
Normal file
470
common/repositories/base/base_account_repository.h
Normal file
@ -0,0 +1,470 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_ACCOUNT_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_ACCOUNT_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseAccountRepository {
|
||||||
|
public:
|
||||||
|
struct Account {
|
||||||
|
int id;
|
||||||
|
std::string name;
|
||||||
|
std::string charname;
|
||||||
|
int sharedplat;
|
||||||
|
std::string password;
|
||||||
|
int status;
|
||||||
|
std::string ls_id;
|
||||||
|
int lsaccount_id;
|
||||||
|
int gmspeed;
|
||||||
|
int revoked;
|
||||||
|
int karma;
|
||||||
|
std::string minilogin_ip;
|
||||||
|
int hideme;
|
||||||
|
int rulesflag;
|
||||||
|
std::string suspendeduntil;
|
||||||
|
int time_creation;
|
||||||
|
int expansion;
|
||||||
|
std::string ban_reason;
|
||||||
|
std::string suspend_reason;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"charname",
|
||||||
|
"sharedplat",
|
||||||
|
"password",
|
||||||
|
"status",
|
||||||
|
"ls_id",
|
||||||
|
"lsaccount_id",
|
||||||
|
"gmspeed",
|
||||||
|
"revoked",
|
||||||
|
"karma",
|
||||||
|
"minilogin_ip",
|
||||||
|
"hideme",
|
||||||
|
"rulesflag",
|
||||||
|
"suspendeduntil",
|
||||||
|
"time_creation",
|
||||||
|
"expansion",
|
||||||
|
"ban_reason",
|
||||||
|
"suspend_reason",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("account");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Account NewEntity()
|
||||||
|
{
|
||||||
|
Account entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.name = "";
|
||||||
|
entry.charname = "";
|
||||||
|
entry.sharedplat = 0;
|
||||||
|
entry.password = "";
|
||||||
|
entry.status = 0;
|
||||||
|
entry.ls_id = "eqemu";
|
||||||
|
entry.lsaccount_id = 0;
|
||||||
|
entry.gmspeed = 0;
|
||||||
|
entry.revoked = 0;
|
||||||
|
entry.karma = 0;
|
||||||
|
entry.minilogin_ip = "";
|
||||||
|
entry.hideme = 0;
|
||||||
|
entry.rulesflag = 0;
|
||||||
|
entry.suspendeduntil = "0000-00-00 00:00:00";
|
||||||
|
entry.time_creation = 0;
|
||||||
|
entry.expansion = 0;
|
||||||
|
entry.ban_reason = "";
|
||||||
|
entry.suspend_reason = "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Account GetAccountEntry(
|
||||||
|
const std::vector<Account> &accounts,
|
||||||
|
int account_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &account : accounts) {
|
||||||
|
if (account.id == account_id) {
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Account FindOne(
|
||||||
|
int account_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
account_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
Account entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.name = row[1] ? row[1] : "";
|
||||||
|
entry.charname = row[2] ? row[2] : "";
|
||||||
|
entry.sharedplat = atoi(row[3]);
|
||||||
|
entry.password = row[4] ? row[4] : "";
|
||||||
|
entry.status = atoi(row[5]);
|
||||||
|
entry.ls_id = row[6] ? row[6] : "";
|
||||||
|
entry.lsaccount_id = atoi(row[7]);
|
||||||
|
entry.gmspeed = atoi(row[8]);
|
||||||
|
entry.revoked = atoi(row[9]);
|
||||||
|
entry.karma = atoi(row[10]);
|
||||||
|
entry.minilogin_ip = row[11] ? row[11] : "";
|
||||||
|
entry.hideme = atoi(row[12]);
|
||||||
|
entry.rulesflag = atoi(row[13]);
|
||||||
|
entry.suspendeduntil = row[14] ? row[14] : "";
|
||||||
|
entry.time_creation = atoi(row[15]);
|
||||||
|
entry.expansion = atoi(row[16]);
|
||||||
|
entry.ban_reason = row[17] ? row[17] : "";
|
||||||
|
entry.suspend_reason = row[18] ? row[18] : "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int account_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
account_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Account account_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[1] + " = '" + EscapeString(account_entry.name) + "'");
|
||||||
|
update_values.push_back(columns[2] + " = '" + EscapeString(account_entry.charname) + "'");
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(account_entry.sharedplat));
|
||||||
|
update_values.push_back(columns[4] + " = '" + EscapeString(account_entry.password) + "'");
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(account_entry.status));
|
||||||
|
update_values.push_back(columns[6] + " = '" + EscapeString(account_entry.ls_id) + "'");
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(account_entry.lsaccount_id));
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(account_entry.gmspeed));
|
||||||
|
update_values.push_back(columns[9] + " = " + std::to_string(account_entry.revoked));
|
||||||
|
update_values.push_back(columns[10] + " = " + std::to_string(account_entry.karma));
|
||||||
|
update_values.push_back(columns[11] + " = '" + EscapeString(account_entry.minilogin_ip) + "'");
|
||||||
|
update_values.push_back(columns[12] + " = " + std::to_string(account_entry.hideme));
|
||||||
|
update_values.push_back(columns[13] + " = " + std::to_string(account_entry.rulesflag));
|
||||||
|
update_values.push_back(columns[14] + " = '" + EscapeString(account_entry.suspendeduntil) + "'");
|
||||||
|
update_values.push_back(columns[15] + " = " + std::to_string(account_entry.time_creation));
|
||||||
|
update_values.push_back(columns[16] + " = " + std::to_string(account_entry.expansion));
|
||||||
|
update_values.push_back(columns[17] + " = '" + EscapeString(account_entry.ban_reason) + "'");
|
||||||
|
update_values.push_back(columns[18] + " = '" + EscapeString(account_entry.suspend_reason) + "'");
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
account_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Account InsertOne(
|
||||||
|
Account account_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back("'" + EscapeString(account_entry.name) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(account_entry.charname) + "'");
|
||||||
|
insert_values.push_back(std::to_string(account_entry.sharedplat));
|
||||||
|
insert_values.push_back("'" + EscapeString(account_entry.password) + "'");
|
||||||
|
insert_values.push_back(std::to_string(account_entry.status));
|
||||||
|
insert_values.push_back("'" + EscapeString(account_entry.ls_id) + "'");
|
||||||
|
insert_values.push_back(std::to_string(account_entry.lsaccount_id));
|
||||||
|
insert_values.push_back(std::to_string(account_entry.gmspeed));
|
||||||
|
insert_values.push_back(std::to_string(account_entry.revoked));
|
||||||
|
insert_values.push_back(std::to_string(account_entry.karma));
|
||||||
|
insert_values.push_back("'" + EscapeString(account_entry.minilogin_ip) + "'");
|
||||||
|
insert_values.push_back(std::to_string(account_entry.hideme));
|
||||||
|
insert_values.push_back(std::to_string(account_entry.rulesflag));
|
||||||
|
insert_values.push_back("'" + EscapeString(account_entry.suspendeduntil) + "'");
|
||||||
|
insert_values.push_back(std::to_string(account_entry.time_creation));
|
||||||
|
insert_values.push_back(std::to_string(account_entry.expansion));
|
||||||
|
insert_values.push_back("'" + EscapeString(account_entry.ban_reason) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(account_entry.suspend_reason) + "'");
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
account_entry.id = results.LastInsertedID();
|
||||||
|
return account_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
account_entry = NewEntity();
|
||||||
|
|
||||||
|
return account_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<Account> account_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &account_entry: account_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back("'" + EscapeString(account_entry.name) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(account_entry.charname) + "'");
|
||||||
|
insert_values.push_back(std::to_string(account_entry.sharedplat));
|
||||||
|
insert_values.push_back("'" + EscapeString(account_entry.password) + "'");
|
||||||
|
insert_values.push_back(std::to_string(account_entry.status));
|
||||||
|
insert_values.push_back("'" + EscapeString(account_entry.ls_id) + "'");
|
||||||
|
insert_values.push_back(std::to_string(account_entry.lsaccount_id));
|
||||||
|
insert_values.push_back(std::to_string(account_entry.gmspeed));
|
||||||
|
insert_values.push_back(std::to_string(account_entry.revoked));
|
||||||
|
insert_values.push_back(std::to_string(account_entry.karma));
|
||||||
|
insert_values.push_back("'" + EscapeString(account_entry.minilogin_ip) + "'");
|
||||||
|
insert_values.push_back(std::to_string(account_entry.hideme));
|
||||||
|
insert_values.push_back(std::to_string(account_entry.rulesflag));
|
||||||
|
insert_values.push_back("'" + EscapeString(account_entry.suspendeduntil) + "'");
|
||||||
|
insert_values.push_back(std::to_string(account_entry.time_creation));
|
||||||
|
insert_values.push_back(std::to_string(account_entry.expansion));
|
||||||
|
insert_values.push_back("'" + EscapeString(account_entry.ban_reason) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(account_entry.suspend_reason) + "'");
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Account> All()
|
||||||
|
{
|
||||||
|
std::vector<Account> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Account entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.name = row[1] ? row[1] : "";
|
||||||
|
entry.charname = row[2] ? row[2] : "";
|
||||||
|
entry.sharedplat = atoi(row[3]);
|
||||||
|
entry.password = row[4] ? row[4] : "";
|
||||||
|
entry.status = atoi(row[5]);
|
||||||
|
entry.ls_id = row[6] ? row[6] : "";
|
||||||
|
entry.lsaccount_id = atoi(row[7]);
|
||||||
|
entry.gmspeed = atoi(row[8]);
|
||||||
|
entry.revoked = atoi(row[9]);
|
||||||
|
entry.karma = atoi(row[10]);
|
||||||
|
entry.minilogin_ip = row[11] ? row[11] : "";
|
||||||
|
entry.hideme = atoi(row[12]);
|
||||||
|
entry.rulesflag = atoi(row[13]);
|
||||||
|
entry.suspendeduntil = row[14] ? row[14] : "";
|
||||||
|
entry.time_creation = atoi(row[15]);
|
||||||
|
entry.expansion = atoi(row[16]);
|
||||||
|
entry.ban_reason = row[17] ? row[17] : "";
|
||||||
|
entry.suspend_reason = row[18] ? row[18] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Account> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<Account> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Account entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.name = row[1] ? row[1] : "";
|
||||||
|
entry.charname = row[2] ? row[2] : "";
|
||||||
|
entry.sharedplat = atoi(row[3]);
|
||||||
|
entry.password = row[4] ? row[4] : "";
|
||||||
|
entry.status = atoi(row[5]);
|
||||||
|
entry.ls_id = row[6] ? row[6] : "";
|
||||||
|
entry.lsaccount_id = atoi(row[7]);
|
||||||
|
entry.gmspeed = atoi(row[8]);
|
||||||
|
entry.revoked = atoi(row[9]);
|
||||||
|
entry.karma = atoi(row[10]);
|
||||||
|
entry.minilogin_ip = row[11] ? row[11] : "";
|
||||||
|
entry.hideme = atoi(row[12]);
|
||||||
|
entry.rulesflag = atoi(row[13]);
|
||||||
|
entry.suspendeduntil = row[14] ? row[14] : "";
|
||||||
|
entry.time_creation = atoi(row[15]);
|
||||||
|
entry.expansion = atoi(row[16]);
|
||||||
|
entry.ban_reason = row[17] ? row[17] : "";
|
||||||
|
entry.suspend_reason = row[18] ? row[18] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_ACCOUNT_REPOSITORY_H
|
||||||
329
common/repositories/base/base_account_rewards_repository.h
Normal file
329
common/repositories/base/base_account_rewards_repository.h
Normal file
@ -0,0 +1,329 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_ACCOUNT_REWARDS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_ACCOUNT_REWARDS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseAccountRewardsRepository {
|
||||||
|
public:
|
||||||
|
struct AccountRewards {
|
||||||
|
int account_id;
|
||||||
|
int reward_id;
|
||||||
|
int amount;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("account_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"account_id",
|
||||||
|
"reward_id",
|
||||||
|
"amount",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("account_rewards");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AccountRewards NewEntity()
|
||||||
|
{
|
||||||
|
AccountRewards entry{};
|
||||||
|
|
||||||
|
entry.account_id = 0;
|
||||||
|
entry.reward_id = 0;
|
||||||
|
entry.amount = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static AccountRewards GetAccountRewardsEntry(
|
||||||
|
const std::vector<AccountRewards> &account_rewardss,
|
||||||
|
int account_rewards_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &account_rewards : account_rewardss) {
|
||||||
|
if (account_rewards.account_id == account_rewards_id) {
|
||||||
|
return account_rewards;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static AccountRewards FindOne(
|
||||||
|
int account_rewards_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
account_rewards_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
AccountRewards entry{};
|
||||||
|
|
||||||
|
entry.account_id = atoi(row[0]);
|
||||||
|
entry.reward_id = atoi(row[1]);
|
||||||
|
entry.amount = atoi(row[2]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int account_rewards_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
account_rewards_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
AccountRewards account_rewards_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(account_rewards_entry.account_id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(account_rewards_entry.reward_id));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(account_rewards_entry.amount));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
account_rewards_entry.account_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AccountRewards InsertOne(
|
||||||
|
AccountRewards account_rewards_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(account_rewards_entry.account_id));
|
||||||
|
insert_values.push_back(std::to_string(account_rewards_entry.reward_id));
|
||||||
|
insert_values.push_back(std::to_string(account_rewards_entry.amount));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
account_rewards_entry.account_id = results.LastInsertedID();
|
||||||
|
return account_rewards_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
account_rewards_entry = NewEntity();
|
||||||
|
|
||||||
|
return account_rewards_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<AccountRewards> account_rewards_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &account_rewards_entry: account_rewards_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(account_rewards_entry.account_id));
|
||||||
|
insert_values.push_back(std::to_string(account_rewards_entry.reward_id));
|
||||||
|
insert_values.push_back(std::to_string(account_rewards_entry.amount));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AccountRewards> All()
|
||||||
|
{
|
||||||
|
std::vector<AccountRewards> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AccountRewards entry{};
|
||||||
|
|
||||||
|
entry.account_id = atoi(row[0]);
|
||||||
|
entry.reward_id = atoi(row[1]);
|
||||||
|
entry.amount = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AccountRewards> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<AccountRewards> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AccountRewards entry{};
|
||||||
|
|
||||||
|
entry.account_id = atoi(row[0]);
|
||||||
|
entry.reward_id = atoi(row[1]);
|
||||||
|
entry.amount = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_ACCOUNT_REWARDS_REPOSITORY_H
|
||||||
380
common/repositories/base/base_adventure_details_repository.h
Normal file
380
common/repositories/base/base_adventure_details_repository.h
Normal file
@ -0,0 +1,380 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_ADVENTURE_DETAILS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_ADVENTURE_DETAILS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseAdventureDetailsRepository {
|
||||||
|
public:
|
||||||
|
struct AdventureDetails {
|
||||||
|
int id;
|
||||||
|
int adventure_id;
|
||||||
|
int instance_id;
|
||||||
|
int count;
|
||||||
|
int assassinate_count;
|
||||||
|
int status;
|
||||||
|
int time_created;
|
||||||
|
int time_zoned;
|
||||||
|
int time_completed;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"adventure_id",
|
||||||
|
"instance_id",
|
||||||
|
"count",
|
||||||
|
"assassinate_count",
|
||||||
|
"status",
|
||||||
|
"time_created",
|
||||||
|
"time_zoned",
|
||||||
|
"time_completed",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("adventure_details");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureDetails NewEntity()
|
||||||
|
{
|
||||||
|
AdventureDetails entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.adventure_id = 0;
|
||||||
|
entry.instance_id = -1;
|
||||||
|
entry.count = 0;
|
||||||
|
entry.assassinate_count = 0;
|
||||||
|
entry.status = 0;
|
||||||
|
entry.time_created = 0;
|
||||||
|
entry.time_zoned = 0;
|
||||||
|
entry.time_completed = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureDetails GetAdventureDetailsEntry(
|
||||||
|
const std::vector<AdventureDetails> &adventure_detailss,
|
||||||
|
int adventure_details_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &adventure_details : adventure_detailss) {
|
||||||
|
if (adventure_details.id == adventure_details_id) {
|
||||||
|
return adventure_details;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureDetails FindOne(
|
||||||
|
int adventure_details_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
adventure_details_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
AdventureDetails entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.adventure_id = atoi(row[1]);
|
||||||
|
entry.instance_id = atoi(row[2]);
|
||||||
|
entry.count = atoi(row[3]);
|
||||||
|
entry.assassinate_count = atoi(row[4]);
|
||||||
|
entry.status = atoi(row[5]);
|
||||||
|
entry.time_created = atoi(row[6]);
|
||||||
|
entry.time_zoned = atoi(row[7]);
|
||||||
|
entry.time_completed = atoi(row[8]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int adventure_details_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
adventure_details_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
AdventureDetails adventure_details_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(adventure_details_entry.adventure_id));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(adventure_details_entry.instance_id));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(adventure_details_entry.count));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(adventure_details_entry.assassinate_count));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(adventure_details_entry.status));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(adventure_details_entry.time_created));
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(adventure_details_entry.time_zoned));
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(adventure_details_entry.time_completed));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
adventure_details_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureDetails InsertOne(
|
||||||
|
AdventureDetails adventure_details_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(adventure_details_entry.adventure_id));
|
||||||
|
insert_values.push_back(std::to_string(adventure_details_entry.instance_id));
|
||||||
|
insert_values.push_back(std::to_string(adventure_details_entry.count));
|
||||||
|
insert_values.push_back(std::to_string(adventure_details_entry.assassinate_count));
|
||||||
|
insert_values.push_back(std::to_string(adventure_details_entry.status));
|
||||||
|
insert_values.push_back(std::to_string(adventure_details_entry.time_created));
|
||||||
|
insert_values.push_back(std::to_string(adventure_details_entry.time_zoned));
|
||||||
|
insert_values.push_back(std::to_string(adventure_details_entry.time_completed));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
adventure_details_entry.id = results.LastInsertedID();
|
||||||
|
return adventure_details_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
adventure_details_entry = NewEntity();
|
||||||
|
|
||||||
|
return adventure_details_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<AdventureDetails> adventure_details_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &adventure_details_entry: adventure_details_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(adventure_details_entry.adventure_id));
|
||||||
|
insert_values.push_back(std::to_string(adventure_details_entry.instance_id));
|
||||||
|
insert_values.push_back(std::to_string(adventure_details_entry.count));
|
||||||
|
insert_values.push_back(std::to_string(adventure_details_entry.assassinate_count));
|
||||||
|
insert_values.push_back(std::to_string(adventure_details_entry.status));
|
||||||
|
insert_values.push_back(std::to_string(adventure_details_entry.time_created));
|
||||||
|
insert_values.push_back(std::to_string(adventure_details_entry.time_zoned));
|
||||||
|
insert_values.push_back(std::to_string(adventure_details_entry.time_completed));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AdventureDetails> All()
|
||||||
|
{
|
||||||
|
std::vector<AdventureDetails> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AdventureDetails entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.adventure_id = atoi(row[1]);
|
||||||
|
entry.instance_id = atoi(row[2]);
|
||||||
|
entry.count = atoi(row[3]);
|
||||||
|
entry.assassinate_count = atoi(row[4]);
|
||||||
|
entry.status = atoi(row[5]);
|
||||||
|
entry.time_created = atoi(row[6]);
|
||||||
|
entry.time_zoned = atoi(row[7]);
|
||||||
|
entry.time_completed = atoi(row[8]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AdventureDetails> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<AdventureDetails> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AdventureDetails entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.adventure_id = atoi(row[1]);
|
||||||
|
entry.instance_id = atoi(row[2]);
|
||||||
|
entry.count = atoi(row[3]);
|
||||||
|
entry.assassinate_count = atoi(row[4]);
|
||||||
|
entry.status = atoi(row[5]);
|
||||||
|
entry.time_created = atoi(row[6]);
|
||||||
|
entry.time_zoned = atoi(row[7]);
|
||||||
|
entry.time_completed = atoi(row[8]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_ADVENTURE_DETAILS_REPOSITORY_H
|
||||||
320
common/repositories/base/base_adventure_members_repository.h
Normal file
320
common/repositories/base/base_adventure_members_repository.h
Normal file
@ -0,0 +1,320 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_ADVENTURE_MEMBERS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_ADVENTURE_MEMBERS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseAdventureMembersRepository {
|
||||||
|
public:
|
||||||
|
struct AdventureMembers {
|
||||||
|
int id;
|
||||||
|
int charid;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("charid");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"charid",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("adventure_members");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureMembers NewEntity()
|
||||||
|
{
|
||||||
|
AdventureMembers entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.charid = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureMembers GetAdventureMembersEntry(
|
||||||
|
const std::vector<AdventureMembers> &adventure_memberss,
|
||||||
|
int adventure_members_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &adventure_members : adventure_memberss) {
|
||||||
|
if (adventure_members.charid == adventure_members_id) {
|
||||||
|
return adventure_members;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureMembers FindOne(
|
||||||
|
int adventure_members_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
adventure_members_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
AdventureMembers entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.charid = atoi(row[1]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int adventure_members_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
adventure_members_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
AdventureMembers adventure_members_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(adventure_members_entry.id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(adventure_members_entry.charid));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
adventure_members_entry.charid
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureMembers InsertOne(
|
||||||
|
AdventureMembers adventure_members_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(adventure_members_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(adventure_members_entry.charid));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
adventure_members_entry.charid = results.LastInsertedID();
|
||||||
|
return adventure_members_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
adventure_members_entry = NewEntity();
|
||||||
|
|
||||||
|
return adventure_members_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<AdventureMembers> adventure_members_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &adventure_members_entry: adventure_members_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(adventure_members_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(adventure_members_entry.charid));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AdventureMembers> All()
|
||||||
|
{
|
||||||
|
std::vector<AdventureMembers> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AdventureMembers entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.charid = atoi(row[1]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AdventureMembers> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<AdventureMembers> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AdventureMembers entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.charid = atoi(row[1]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_ADVENTURE_MEMBERS_REPOSITORY_H
|
||||||
401
common/repositories/base/base_adventure_stats_repository.h
Normal file
401
common/repositories/base/base_adventure_stats_repository.h
Normal file
@ -0,0 +1,401 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_ADVENTURE_STATS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_ADVENTURE_STATS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseAdventureStatsRepository {
|
||||||
|
public:
|
||||||
|
struct AdventureStats {
|
||||||
|
int player_id;
|
||||||
|
int guk_wins;
|
||||||
|
int mir_wins;
|
||||||
|
int mmc_wins;
|
||||||
|
int ruj_wins;
|
||||||
|
int tak_wins;
|
||||||
|
int guk_losses;
|
||||||
|
int mir_losses;
|
||||||
|
int mmc_losses;
|
||||||
|
int ruj_losses;
|
||||||
|
int tak_losses;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("player_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"player_id",
|
||||||
|
"guk_wins",
|
||||||
|
"mir_wins",
|
||||||
|
"mmc_wins",
|
||||||
|
"ruj_wins",
|
||||||
|
"tak_wins",
|
||||||
|
"guk_losses",
|
||||||
|
"mir_losses",
|
||||||
|
"mmc_losses",
|
||||||
|
"ruj_losses",
|
||||||
|
"tak_losses",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("adventure_stats");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureStats NewEntity()
|
||||||
|
{
|
||||||
|
AdventureStats entry{};
|
||||||
|
|
||||||
|
entry.player_id = 0;
|
||||||
|
entry.guk_wins = 0;
|
||||||
|
entry.mir_wins = 0;
|
||||||
|
entry.mmc_wins = 0;
|
||||||
|
entry.ruj_wins = 0;
|
||||||
|
entry.tak_wins = 0;
|
||||||
|
entry.guk_losses = 0;
|
||||||
|
entry.mir_losses = 0;
|
||||||
|
entry.mmc_losses = 0;
|
||||||
|
entry.ruj_losses = 0;
|
||||||
|
entry.tak_losses = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureStats GetAdventureStatsEntry(
|
||||||
|
const std::vector<AdventureStats> &adventure_statss,
|
||||||
|
int adventure_stats_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &adventure_stats : adventure_statss) {
|
||||||
|
if (adventure_stats.player_id == adventure_stats_id) {
|
||||||
|
return adventure_stats;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureStats FindOne(
|
||||||
|
int adventure_stats_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
adventure_stats_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
AdventureStats entry{};
|
||||||
|
|
||||||
|
entry.player_id = atoi(row[0]);
|
||||||
|
entry.guk_wins = atoi(row[1]);
|
||||||
|
entry.mir_wins = atoi(row[2]);
|
||||||
|
entry.mmc_wins = atoi(row[3]);
|
||||||
|
entry.ruj_wins = atoi(row[4]);
|
||||||
|
entry.tak_wins = atoi(row[5]);
|
||||||
|
entry.guk_losses = atoi(row[6]);
|
||||||
|
entry.mir_losses = atoi(row[7]);
|
||||||
|
entry.mmc_losses = atoi(row[8]);
|
||||||
|
entry.ruj_losses = atoi(row[9]);
|
||||||
|
entry.tak_losses = atoi(row[10]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int adventure_stats_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
adventure_stats_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
AdventureStats adventure_stats_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(adventure_stats_entry.player_id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(adventure_stats_entry.guk_wins));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(adventure_stats_entry.mir_wins));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(adventure_stats_entry.mmc_wins));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(adventure_stats_entry.ruj_wins));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(adventure_stats_entry.tak_wins));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(adventure_stats_entry.guk_losses));
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(adventure_stats_entry.mir_losses));
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(adventure_stats_entry.mmc_losses));
|
||||||
|
update_values.push_back(columns[9] + " = " + std::to_string(adventure_stats_entry.ruj_losses));
|
||||||
|
update_values.push_back(columns[10] + " = " + std::to_string(adventure_stats_entry.tak_losses));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
adventure_stats_entry.player_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureStats InsertOne(
|
||||||
|
AdventureStats adventure_stats_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.player_id));
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.guk_wins));
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.mir_wins));
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.mmc_wins));
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.ruj_wins));
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.tak_wins));
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.guk_losses));
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.mir_losses));
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.mmc_losses));
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.ruj_losses));
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.tak_losses));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
adventure_stats_entry.player_id = results.LastInsertedID();
|
||||||
|
return adventure_stats_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
adventure_stats_entry = NewEntity();
|
||||||
|
|
||||||
|
return adventure_stats_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<AdventureStats> adventure_stats_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &adventure_stats_entry: adventure_stats_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.player_id));
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.guk_wins));
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.mir_wins));
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.mmc_wins));
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.ruj_wins));
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.tak_wins));
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.guk_losses));
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.mir_losses));
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.mmc_losses));
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.ruj_losses));
|
||||||
|
insert_values.push_back(std::to_string(adventure_stats_entry.tak_losses));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AdventureStats> All()
|
||||||
|
{
|
||||||
|
std::vector<AdventureStats> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AdventureStats entry{};
|
||||||
|
|
||||||
|
entry.player_id = atoi(row[0]);
|
||||||
|
entry.guk_wins = atoi(row[1]);
|
||||||
|
entry.mir_wins = atoi(row[2]);
|
||||||
|
entry.mmc_wins = atoi(row[3]);
|
||||||
|
entry.ruj_wins = atoi(row[4]);
|
||||||
|
entry.tak_wins = atoi(row[5]);
|
||||||
|
entry.guk_losses = atoi(row[6]);
|
||||||
|
entry.mir_losses = atoi(row[7]);
|
||||||
|
entry.mmc_losses = atoi(row[8]);
|
||||||
|
entry.ruj_losses = atoi(row[9]);
|
||||||
|
entry.tak_losses = atoi(row[10]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AdventureStats> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<AdventureStats> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AdventureStats entry{};
|
||||||
|
|
||||||
|
entry.player_id = atoi(row[0]);
|
||||||
|
entry.guk_wins = atoi(row[1]);
|
||||||
|
entry.mir_wins = atoi(row[2]);
|
||||||
|
entry.mmc_wins = atoi(row[3]);
|
||||||
|
entry.ruj_wins = atoi(row[4]);
|
||||||
|
entry.tak_wins = atoi(row[5]);
|
||||||
|
entry.guk_losses = atoi(row[6]);
|
||||||
|
entry.mir_losses = atoi(row[7]);
|
||||||
|
entry.mmc_losses = atoi(row[8]);
|
||||||
|
entry.ruj_losses = atoi(row[9]);
|
||||||
|
entry.tak_losses = atoi(row[10]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_ADVENTURE_STATS_REPOSITORY_H
|
||||||
@ -0,0 +1,320 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_ADVENTURE_TEMPLATE_ENTRY_FLAVOR_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_ADVENTURE_TEMPLATE_ENTRY_FLAVOR_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseAdventureTemplateEntryFlavorRepository {
|
||||||
|
public:
|
||||||
|
struct AdventureTemplateEntryFlavor {
|
||||||
|
int id;
|
||||||
|
std::string text;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"text",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("adventure_template_entry_flavor");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureTemplateEntryFlavor NewEntity()
|
||||||
|
{
|
||||||
|
AdventureTemplateEntryFlavor entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.text = "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureTemplateEntryFlavor GetAdventureTemplateEntryFlavorEntry(
|
||||||
|
const std::vector<AdventureTemplateEntryFlavor> &adventure_template_entry_flavors,
|
||||||
|
int adventure_template_entry_flavor_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &adventure_template_entry_flavor : adventure_template_entry_flavors) {
|
||||||
|
if (adventure_template_entry_flavor.id == adventure_template_entry_flavor_id) {
|
||||||
|
return adventure_template_entry_flavor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureTemplateEntryFlavor FindOne(
|
||||||
|
int adventure_template_entry_flavor_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
adventure_template_entry_flavor_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
AdventureTemplateEntryFlavor entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.text = row[1] ? row[1] : "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int adventure_template_entry_flavor_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
adventure_template_entry_flavor_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
AdventureTemplateEntryFlavor adventure_template_entry_flavor_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(adventure_template_entry_flavor_entry.id));
|
||||||
|
update_values.push_back(columns[1] + " = '" + EscapeString(adventure_template_entry_flavor_entry.text) + "'");
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
adventure_template_entry_flavor_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureTemplateEntryFlavor InsertOne(
|
||||||
|
AdventureTemplateEntryFlavor adventure_template_entry_flavor_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry_flavor_entry.id));
|
||||||
|
insert_values.push_back("'" + EscapeString(adventure_template_entry_flavor_entry.text) + "'");
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
adventure_template_entry_flavor_entry.id = results.LastInsertedID();
|
||||||
|
return adventure_template_entry_flavor_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
adventure_template_entry_flavor_entry = NewEntity();
|
||||||
|
|
||||||
|
return adventure_template_entry_flavor_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<AdventureTemplateEntryFlavor> adventure_template_entry_flavor_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &adventure_template_entry_flavor_entry: adventure_template_entry_flavor_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry_flavor_entry.id));
|
||||||
|
insert_values.push_back("'" + EscapeString(adventure_template_entry_flavor_entry.text) + "'");
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AdventureTemplateEntryFlavor> All()
|
||||||
|
{
|
||||||
|
std::vector<AdventureTemplateEntryFlavor> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AdventureTemplateEntryFlavor entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.text = row[1] ? row[1] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AdventureTemplateEntryFlavor> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<AdventureTemplateEntryFlavor> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AdventureTemplateEntryFlavor entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.text = row[1] ? row[1] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_ADVENTURE_TEMPLATE_ENTRY_FLAVOR_REPOSITORY_H
|
||||||
@ -0,0 +1,320 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_ADVENTURE_TEMPLATE_ENTRY_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_ADVENTURE_TEMPLATE_ENTRY_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseAdventureTemplateEntryRepository {
|
||||||
|
public:
|
||||||
|
struct AdventureTemplateEntry {
|
||||||
|
int id;
|
||||||
|
int template_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"template_id",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("adventure_template_entry");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureTemplateEntry NewEntity()
|
||||||
|
{
|
||||||
|
AdventureTemplateEntry entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.template_id = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureTemplateEntry GetAdventureTemplateEntryEntry(
|
||||||
|
const std::vector<AdventureTemplateEntry> &adventure_template_entrys,
|
||||||
|
int adventure_template_entry_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &adventure_template_entry : adventure_template_entrys) {
|
||||||
|
if (adventure_template_entry.id == adventure_template_entry_id) {
|
||||||
|
return adventure_template_entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureTemplateEntry FindOne(
|
||||||
|
int adventure_template_entry_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
adventure_template_entry_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
AdventureTemplateEntry entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.template_id = atoi(row[1]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int adventure_template_entry_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
adventure_template_entry_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
AdventureTemplateEntry adventure_template_entry_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(adventure_template_entry_entry.id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(adventure_template_entry_entry.template_id));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
adventure_template_entry_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureTemplateEntry InsertOne(
|
||||||
|
AdventureTemplateEntry adventure_template_entry_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry_entry.template_id));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
adventure_template_entry_entry.id = results.LastInsertedID();
|
||||||
|
return adventure_template_entry_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
adventure_template_entry_entry = NewEntity();
|
||||||
|
|
||||||
|
return adventure_template_entry_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<AdventureTemplateEntry> adventure_template_entry_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &adventure_template_entry_entry: adventure_template_entry_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry_entry.template_id));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AdventureTemplateEntry> All()
|
||||||
|
{
|
||||||
|
std::vector<AdventureTemplateEntry> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AdventureTemplateEntry entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.template_id = atoi(row[1]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AdventureTemplateEntry> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<AdventureTemplateEntry> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AdventureTemplateEntry entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.template_id = atoi(row[1]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_ADVENTURE_TEMPLATE_ENTRY_REPOSITORY_H
|
||||||
599
common/repositories/base/base_adventure_template_repository.h
Normal file
599
common/repositories/base/base_adventure_template_repository.h
Normal file
@ -0,0 +1,599 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_ADVENTURE_TEMPLATE_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_ADVENTURE_TEMPLATE_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseAdventureTemplateRepository {
|
||||||
|
public:
|
||||||
|
struct AdventureTemplate {
|
||||||
|
int id;
|
||||||
|
std::string zone;
|
||||||
|
int zone_version;
|
||||||
|
int is_hard;
|
||||||
|
int is_raid;
|
||||||
|
int min_level;
|
||||||
|
int max_level;
|
||||||
|
int type;
|
||||||
|
int type_data;
|
||||||
|
int type_count;
|
||||||
|
float assa_x;
|
||||||
|
float assa_y;
|
||||||
|
float assa_z;
|
||||||
|
float assa_h;
|
||||||
|
std::string text;
|
||||||
|
int duration;
|
||||||
|
int zone_in_time;
|
||||||
|
int win_points;
|
||||||
|
int lose_points;
|
||||||
|
int theme;
|
||||||
|
int zone_in_zone_id;
|
||||||
|
float zone_in_x;
|
||||||
|
float zone_in_y;
|
||||||
|
int zone_in_object_id;
|
||||||
|
float dest_x;
|
||||||
|
float dest_y;
|
||||||
|
float dest_z;
|
||||||
|
float dest_h;
|
||||||
|
int graveyard_zone_id;
|
||||||
|
float graveyard_x;
|
||||||
|
float graveyard_y;
|
||||||
|
float graveyard_z;
|
||||||
|
float graveyard_radius;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"zone",
|
||||||
|
"zone_version",
|
||||||
|
"is_hard",
|
||||||
|
"is_raid",
|
||||||
|
"min_level",
|
||||||
|
"max_level",
|
||||||
|
"type",
|
||||||
|
"type_data",
|
||||||
|
"type_count",
|
||||||
|
"assa_x",
|
||||||
|
"assa_y",
|
||||||
|
"assa_z",
|
||||||
|
"assa_h",
|
||||||
|
"text",
|
||||||
|
"duration",
|
||||||
|
"zone_in_time",
|
||||||
|
"win_points",
|
||||||
|
"lose_points",
|
||||||
|
"theme",
|
||||||
|
"zone_in_zone_id",
|
||||||
|
"zone_in_x",
|
||||||
|
"zone_in_y",
|
||||||
|
"zone_in_object_id",
|
||||||
|
"dest_x",
|
||||||
|
"dest_y",
|
||||||
|
"dest_z",
|
||||||
|
"dest_h",
|
||||||
|
"graveyard_zone_id",
|
||||||
|
"graveyard_x",
|
||||||
|
"graveyard_y",
|
||||||
|
"graveyard_z",
|
||||||
|
"graveyard_radius",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("adventure_template");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureTemplate NewEntity()
|
||||||
|
{
|
||||||
|
AdventureTemplate entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.zone = "";
|
||||||
|
entry.zone_version = 0;
|
||||||
|
entry.is_hard = 0;
|
||||||
|
entry.is_raid = 0;
|
||||||
|
entry.min_level = 1;
|
||||||
|
entry.max_level = 65;
|
||||||
|
entry.type = 0;
|
||||||
|
entry.type_data = 0;
|
||||||
|
entry.type_count = 0;
|
||||||
|
entry.assa_x = 0;
|
||||||
|
entry.assa_y = 0;
|
||||||
|
entry.assa_z = 0;
|
||||||
|
entry.assa_h = 0;
|
||||||
|
entry.text = "";
|
||||||
|
entry.duration = 7200;
|
||||||
|
entry.zone_in_time = 1800;
|
||||||
|
entry.win_points = 0;
|
||||||
|
entry.lose_points = 0;
|
||||||
|
entry.theme = 1;
|
||||||
|
entry.zone_in_zone_id = 0;
|
||||||
|
entry.zone_in_x = 0;
|
||||||
|
entry.zone_in_y = 0;
|
||||||
|
entry.zone_in_object_id = 0;
|
||||||
|
entry.dest_x = 0;
|
||||||
|
entry.dest_y = 0;
|
||||||
|
entry.dest_z = 0;
|
||||||
|
entry.dest_h = 0;
|
||||||
|
entry.graveyard_zone_id = 0;
|
||||||
|
entry.graveyard_x = 0;
|
||||||
|
entry.graveyard_y = 0;
|
||||||
|
entry.graveyard_z = 0;
|
||||||
|
entry.graveyard_radius = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureTemplate GetAdventureTemplateEntry(
|
||||||
|
const std::vector<AdventureTemplate> &adventure_templates,
|
||||||
|
int adventure_template_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &adventure_template : adventure_templates) {
|
||||||
|
if (adventure_template.id == adventure_template_id) {
|
||||||
|
return adventure_template;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureTemplate FindOne(
|
||||||
|
int adventure_template_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
adventure_template_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
AdventureTemplate entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.zone = row[1] ? row[1] : "";
|
||||||
|
entry.zone_version = atoi(row[2]);
|
||||||
|
entry.is_hard = atoi(row[3]);
|
||||||
|
entry.is_raid = atoi(row[4]);
|
||||||
|
entry.min_level = atoi(row[5]);
|
||||||
|
entry.max_level = atoi(row[6]);
|
||||||
|
entry.type = atoi(row[7]);
|
||||||
|
entry.type_data = atoi(row[8]);
|
||||||
|
entry.type_count = atoi(row[9]);
|
||||||
|
entry.assa_x = static_cast<float>(atof(row[10]));
|
||||||
|
entry.assa_y = static_cast<float>(atof(row[11]));
|
||||||
|
entry.assa_z = static_cast<float>(atof(row[12]));
|
||||||
|
entry.assa_h = static_cast<float>(atof(row[13]));
|
||||||
|
entry.text = row[14] ? row[14] : "";
|
||||||
|
entry.duration = atoi(row[15]);
|
||||||
|
entry.zone_in_time = atoi(row[16]);
|
||||||
|
entry.win_points = atoi(row[17]);
|
||||||
|
entry.lose_points = atoi(row[18]);
|
||||||
|
entry.theme = atoi(row[19]);
|
||||||
|
entry.zone_in_zone_id = atoi(row[20]);
|
||||||
|
entry.zone_in_x = static_cast<float>(atof(row[21]));
|
||||||
|
entry.zone_in_y = static_cast<float>(atof(row[22]));
|
||||||
|
entry.zone_in_object_id = atoi(row[23]);
|
||||||
|
entry.dest_x = static_cast<float>(atof(row[24]));
|
||||||
|
entry.dest_y = static_cast<float>(atof(row[25]));
|
||||||
|
entry.dest_z = static_cast<float>(atof(row[26]));
|
||||||
|
entry.dest_h = static_cast<float>(atof(row[27]));
|
||||||
|
entry.graveyard_zone_id = atoi(row[28]);
|
||||||
|
entry.graveyard_x = static_cast<float>(atof(row[29]));
|
||||||
|
entry.graveyard_y = static_cast<float>(atof(row[30]));
|
||||||
|
entry.graveyard_z = static_cast<float>(atof(row[31]));
|
||||||
|
entry.graveyard_radius = static_cast<float>(atof(row[32]));
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int adventure_template_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
adventure_template_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
AdventureTemplate adventure_template_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(adventure_template_entry.id));
|
||||||
|
update_values.push_back(columns[1] + " = '" + EscapeString(adventure_template_entry.zone) + "'");
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(adventure_template_entry.zone_version));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(adventure_template_entry.is_hard));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(adventure_template_entry.is_raid));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(adventure_template_entry.min_level));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(adventure_template_entry.max_level));
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(adventure_template_entry.type));
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(adventure_template_entry.type_data));
|
||||||
|
update_values.push_back(columns[9] + " = " + std::to_string(adventure_template_entry.type_count));
|
||||||
|
update_values.push_back(columns[10] + " = " + std::to_string(adventure_template_entry.assa_x));
|
||||||
|
update_values.push_back(columns[11] + " = " + std::to_string(adventure_template_entry.assa_y));
|
||||||
|
update_values.push_back(columns[12] + " = " + std::to_string(adventure_template_entry.assa_z));
|
||||||
|
update_values.push_back(columns[13] + " = " + std::to_string(adventure_template_entry.assa_h));
|
||||||
|
update_values.push_back(columns[14] + " = '" + EscapeString(adventure_template_entry.text) + "'");
|
||||||
|
update_values.push_back(columns[15] + " = " + std::to_string(adventure_template_entry.duration));
|
||||||
|
update_values.push_back(columns[16] + " = " + std::to_string(adventure_template_entry.zone_in_time));
|
||||||
|
update_values.push_back(columns[17] + " = " + std::to_string(adventure_template_entry.win_points));
|
||||||
|
update_values.push_back(columns[18] + " = " + std::to_string(adventure_template_entry.lose_points));
|
||||||
|
update_values.push_back(columns[19] + " = " + std::to_string(adventure_template_entry.theme));
|
||||||
|
update_values.push_back(columns[20] + " = " + std::to_string(adventure_template_entry.zone_in_zone_id));
|
||||||
|
update_values.push_back(columns[21] + " = " + std::to_string(adventure_template_entry.zone_in_x));
|
||||||
|
update_values.push_back(columns[22] + " = " + std::to_string(adventure_template_entry.zone_in_y));
|
||||||
|
update_values.push_back(columns[23] + " = " + std::to_string(adventure_template_entry.zone_in_object_id));
|
||||||
|
update_values.push_back(columns[24] + " = " + std::to_string(adventure_template_entry.dest_x));
|
||||||
|
update_values.push_back(columns[25] + " = " + std::to_string(adventure_template_entry.dest_y));
|
||||||
|
update_values.push_back(columns[26] + " = " + std::to_string(adventure_template_entry.dest_z));
|
||||||
|
update_values.push_back(columns[27] + " = " + std::to_string(adventure_template_entry.dest_h));
|
||||||
|
update_values.push_back(columns[28] + " = " + std::to_string(adventure_template_entry.graveyard_zone_id));
|
||||||
|
update_values.push_back(columns[29] + " = " + std::to_string(adventure_template_entry.graveyard_x));
|
||||||
|
update_values.push_back(columns[30] + " = " + std::to_string(adventure_template_entry.graveyard_y));
|
||||||
|
update_values.push_back(columns[31] + " = " + std::to_string(adventure_template_entry.graveyard_z));
|
||||||
|
update_values.push_back(columns[32] + " = " + std::to_string(adventure_template_entry.graveyard_radius));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
adventure_template_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AdventureTemplate InsertOne(
|
||||||
|
AdventureTemplate adventure_template_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.id));
|
||||||
|
insert_values.push_back("'" + EscapeString(adventure_template_entry.zone) + "'");
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.zone_version));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.is_hard));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.is_raid));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.min_level));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.max_level));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.type));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.type_data));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.type_count));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.assa_x));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.assa_y));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.assa_z));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.assa_h));
|
||||||
|
insert_values.push_back("'" + EscapeString(adventure_template_entry.text) + "'");
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.duration));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_time));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.win_points));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.lose_points));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.theme));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_zone_id));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_x));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_y));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_object_id));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.dest_x));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.dest_y));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.dest_z));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.dest_h));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_zone_id));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_x));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_y));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_z));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_radius));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
adventure_template_entry.id = results.LastInsertedID();
|
||||||
|
return adventure_template_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
adventure_template_entry = NewEntity();
|
||||||
|
|
||||||
|
return adventure_template_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<AdventureTemplate> adventure_template_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &adventure_template_entry: adventure_template_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.id));
|
||||||
|
insert_values.push_back("'" + EscapeString(adventure_template_entry.zone) + "'");
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.zone_version));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.is_hard));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.is_raid));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.min_level));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.max_level));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.type));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.type_data));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.type_count));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.assa_x));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.assa_y));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.assa_z));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.assa_h));
|
||||||
|
insert_values.push_back("'" + EscapeString(adventure_template_entry.text) + "'");
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.duration));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_time));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.win_points));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.lose_points));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.theme));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_zone_id));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_x));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_y));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_object_id));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.dest_x));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.dest_y));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.dest_z));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.dest_h));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_zone_id));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_x));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_y));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_z));
|
||||||
|
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_radius));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AdventureTemplate> All()
|
||||||
|
{
|
||||||
|
std::vector<AdventureTemplate> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AdventureTemplate entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.zone = row[1] ? row[1] : "";
|
||||||
|
entry.zone_version = atoi(row[2]);
|
||||||
|
entry.is_hard = atoi(row[3]);
|
||||||
|
entry.is_raid = atoi(row[4]);
|
||||||
|
entry.min_level = atoi(row[5]);
|
||||||
|
entry.max_level = atoi(row[6]);
|
||||||
|
entry.type = atoi(row[7]);
|
||||||
|
entry.type_data = atoi(row[8]);
|
||||||
|
entry.type_count = atoi(row[9]);
|
||||||
|
entry.assa_x = static_cast<float>(atof(row[10]));
|
||||||
|
entry.assa_y = static_cast<float>(atof(row[11]));
|
||||||
|
entry.assa_z = static_cast<float>(atof(row[12]));
|
||||||
|
entry.assa_h = static_cast<float>(atof(row[13]));
|
||||||
|
entry.text = row[14] ? row[14] : "";
|
||||||
|
entry.duration = atoi(row[15]);
|
||||||
|
entry.zone_in_time = atoi(row[16]);
|
||||||
|
entry.win_points = atoi(row[17]);
|
||||||
|
entry.lose_points = atoi(row[18]);
|
||||||
|
entry.theme = atoi(row[19]);
|
||||||
|
entry.zone_in_zone_id = atoi(row[20]);
|
||||||
|
entry.zone_in_x = static_cast<float>(atof(row[21]));
|
||||||
|
entry.zone_in_y = static_cast<float>(atof(row[22]));
|
||||||
|
entry.zone_in_object_id = atoi(row[23]);
|
||||||
|
entry.dest_x = static_cast<float>(atof(row[24]));
|
||||||
|
entry.dest_y = static_cast<float>(atof(row[25]));
|
||||||
|
entry.dest_z = static_cast<float>(atof(row[26]));
|
||||||
|
entry.dest_h = static_cast<float>(atof(row[27]));
|
||||||
|
entry.graveyard_zone_id = atoi(row[28]);
|
||||||
|
entry.graveyard_x = static_cast<float>(atof(row[29]));
|
||||||
|
entry.graveyard_y = static_cast<float>(atof(row[30]));
|
||||||
|
entry.graveyard_z = static_cast<float>(atof(row[31]));
|
||||||
|
entry.graveyard_radius = static_cast<float>(atof(row[32]));
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AdventureTemplate> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<AdventureTemplate> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AdventureTemplate entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.zone = row[1] ? row[1] : "";
|
||||||
|
entry.zone_version = atoi(row[2]);
|
||||||
|
entry.is_hard = atoi(row[3]);
|
||||||
|
entry.is_raid = atoi(row[4]);
|
||||||
|
entry.min_level = atoi(row[5]);
|
||||||
|
entry.max_level = atoi(row[6]);
|
||||||
|
entry.type = atoi(row[7]);
|
||||||
|
entry.type_data = atoi(row[8]);
|
||||||
|
entry.type_count = atoi(row[9]);
|
||||||
|
entry.assa_x = static_cast<float>(atof(row[10]));
|
||||||
|
entry.assa_y = static_cast<float>(atof(row[11]));
|
||||||
|
entry.assa_z = static_cast<float>(atof(row[12]));
|
||||||
|
entry.assa_h = static_cast<float>(atof(row[13]));
|
||||||
|
entry.text = row[14] ? row[14] : "";
|
||||||
|
entry.duration = atoi(row[15]);
|
||||||
|
entry.zone_in_time = atoi(row[16]);
|
||||||
|
entry.win_points = atoi(row[17]);
|
||||||
|
entry.lose_points = atoi(row[18]);
|
||||||
|
entry.theme = atoi(row[19]);
|
||||||
|
entry.zone_in_zone_id = atoi(row[20]);
|
||||||
|
entry.zone_in_x = static_cast<float>(atof(row[21]));
|
||||||
|
entry.zone_in_y = static_cast<float>(atof(row[22]));
|
||||||
|
entry.zone_in_object_id = atoi(row[23]);
|
||||||
|
entry.dest_x = static_cast<float>(atof(row[24]));
|
||||||
|
entry.dest_y = static_cast<float>(atof(row[25]));
|
||||||
|
entry.dest_z = static_cast<float>(atof(row[26]));
|
||||||
|
entry.dest_h = static_cast<float>(atof(row[27]));
|
||||||
|
entry.graveyard_zone_id = atoi(row[28]);
|
||||||
|
entry.graveyard_x = static_cast<float>(atof(row[29]));
|
||||||
|
entry.graveyard_y = static_cast<float>(atof(row[30]));
|
||||||
|
entry.graveyard_z = static_cast<float>(atof(row[31]));
|
||||||
|
entry.graveyard_radius = static_cast<float>(atof(row[32]));
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_ADVENTURE_TEMPLATE_REPOSITORY_H
|
||||||
320
common/repositories/base/base_alternate_currency_repository.h
Normal file
320
common/repositories/base/base_alternate_currency_repository.h
Normal file
@ -0,0 +1,320 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_ALTERNATE_CURRENCY_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_ALTERNATE_CURRENCY_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseAlternateCurrencyRepository {
|
||||||
|
public:
|
||||||
|
struct AlternateCurrency {
|
||||||
|
int id;
|
||||||
|
int item_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"item_id",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("alternate_currency");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AlternateCurrency NewEntity()
|
||||||
|
{
|
||||||
|
AlternateCurrency entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.item_id = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static AlternateCurrency GetAlternateCurrencyEntry(
|
||||||
|
const std::vector<AlternateCurrency> &alternate_currencys,
|
||||||
|
int alternate_currency_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &alternate_currency : alternate_currencys) {
|
||||||
|
if (alternate_currency.id == alternate_currency_id) {
|
||||||
|
return alternate_currency;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static AlternateCurrency FindOne(
|
||||||
|
int alternate_currency_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
alternate_currency_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
AlternateCurrency entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.item_id = atoi(row[1]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int alternate_currency_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
alternate_currency_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
AlternateCurrency alternate_currency_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(alternate_currency_entry.id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(alternate_currency_entry.item_id));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
alternate_currency_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static AlternateCurrency InsertOne(
|
||||||
|
AlternateCurrency alternate_currency_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(alternate_currency_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(alternate_currency_entry.item_id));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
alternate_currency_entry.id = results.LastInsertedID();
|
||||||
|
return alternate_currency_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
alternate_currency_entry = NewEntity();
|
||||||
|
|
||||||
|
return alternate_currency_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<AlternateCurrency> alternate_currency_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &alternate_currency_entry: alternate_currency_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(alternate_currency_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(alternate_currency_entry.item_id));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AlternateCurrency> All()
|
||||||
|
{
|
||||||
|
std::vector<AlternateCurrency> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AlternateCurrency entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.item_id = atoi(row[1]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<AlternateCurrency> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<AlternateCurrency> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
AlternateCurrency entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.item_id = atoi(row[1]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_ALTERNATE_CURRENCY_REPOSITORY_H
|
||||||
401
common/repositories/base/base_auras_repository.h
Normal file
401
common/repositories/base/base_auras_repository.h
Normal file
@ -0,0 +1,401 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_AURAS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_AURAS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseAurasRepository {
|
||||||
|
public:
|
||||||
|
struct Auras {
|
||||||
|
int type;
|
||||||
|
int npc_type;
|
||||||
|
std::string name;
|
||||||
|
int spell_id;
|
||||||
|
int distance;
|
||||||
|
int aura_type;
|
||||||
|
int spawn_type;
|
||||||
|
int movement;
|
||||||
|
int duration;
|
||||||
|
int icon;
|
||||||
|
int cast_time;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("type");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"type",
|
||||||
|
"npc_type",
|
||||||
|
"name",
|
||||||
|
"spell_id",
|
||||||
|
"distance",
|
||||||
|
"aura_type",
|
||||||
|
"spawn_type",
|
||||||
|
"movement",
|
||||||
|
"duration",
|
||||||
|
"icon",
|
||||||
|
"cast_time",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("auras");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Auras NewEntity()
|
||||||
|
{
|
||||||
|
Auras entry{};
|
||||||
|
|
||||||
|
entry.type = 0;
|
||||||
|
entry.npc_type = 0;
|
||||||
|
entry.name = "";
|
||||||
|
entry.spell_id = 0;
|
||||||
|
entry.distance = 60;
|
||||||
|
entry.aura_type = 1;
|
||||||
|
entry.spawn_type = 0;
|
||||||
|
entry.movement = 0;
|
||||||
|
entry.duration = 5400;
|
||||||
|
entry.icon = -1;
|
||||||
|
entry.cast_time = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Auras GetAurasEntry(
|
||||||
|
const std::vector<Auras> &aurass,
|
||||||
|
int auras_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &auras : aurass) {
|
||||||
|
if (auras.type == auras_id) {
|
||||||
|
return auras;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Auras FindOne(
|
||||||
|
int auras_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
auras_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
Auras entry{};
|
||||||
|
|
||||||
|
entry.type = atoi(row[0]);
|
||||||
|
entry.npc_type = atoi(row[1]);
|
||||||
|
entry.name = row[2] ? row[2] : "";
|
||||||
|
entry.spell_id = atoi(row[3]);
|
||||||
|
entry.distance = atoi(row[4]);
|
||||||
|
entry.aura_type = atoi(row[5]);
|
||||||
|
entry.spawn_type = atoi(row[6]);
|
||||||
|
entry.movement = atoi(row[7]);
|
||||||
|
entry.duration = atoi(row[8]);
|
||||||
|
entry.icon = atoi(row[9]);
|
||||||
|
entry.cast_time = atoi(row[10]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int auras_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
auras_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Auras auras_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(auras_entry.type));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(auras_entry.npc_type));
|
||||||
|
update_values.push_back(columns[2] + " = '" + EscapeString(auras_entry.name) + "'");
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(auras_entry.spell_id));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(auras_entry.distance));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(auras_entry.aura_type));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(auras_entry.spawn_type));
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(auras_entry.movement));
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(auras_entry.duration));
|
||||||
|
update_values.push_back(columns[9] + " = " + std::to_string(auras_entry.icon));
|
||||||
|
update_values.push_back(columns[10] + " = " + std::to_string(auras_entry.cast_time));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
auras_entry.type
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Auras InsertOne(
|
||||||
|
Auras auras_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(auras_entry.type));
|
||||||
|
insert_values.push_back(std::to_string(auras_entry.npc_type));
|
||||||
|
insert_values.push_back("'" + EscapeString(auras_entry.name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(auras_entry.spell_id));
|
||||||
|
insert_values.push_back(std::to_string(auras_entry.distance));
|
||||||
|
insert_values.push_back(std::to_string(auras_entry.aura_type));
|
||||||
|
insert_values.push_back(std::to_string(auras_entry.spawn_type));
|
||||||
|
insert_values.push_back(std::to_string(auras_entry.movement));
|
||||||
|
insert_values.push_back(std::to_string(auras_entry.duration));
|
||||||
|
insert_values.push_back(std::to_string(auras_entry.icon));
|
||||||
|
insert_values.push_back(std::to_string(auras_entry.cast_time));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
auras_entry.type = results.LastInsertedID();
|
||||||
|
return auras_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
auras_entry = NewEntity();
|
||||||
|
|
||||||
|
return auras_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<Auras> auras_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &auras_entry: auras_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(auras_entry.type));
|
||||||
|
insert_values.push_back(std::to_string(auras_entry.npc_type));
|
||||||
|
insert_values.push_back("'" + EscapeString(auras_entry.name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(auras_entry.spell_id));
|
||||||
|
insert_values.push_back(std::to_string(auras_entry.distance));
|
||||||
|
insert_values.push_back(std::to_string(auras_entry.aura_type));
|
||||||
|
insert_values.push_back(std::to_string(auras_entry.spawn_type));
|
||||||
|
insert_values.push_back(std::to_string(auras_entry.movement));
|
||||||
|
insert_values.push_back(std::to_string(auras_entry.duration));
|
||||||
|
insert_values.push_back(std::to_string(auras_entry.icon));
|
||||||
|
insert_values.push_back(std::to_string(auras_entry.cast_time));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Auras> All()
|
||||||
|
{
|
||||||
|
std::vector<Auras> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Auras entry{};
|
||||||
|
|
||||||
|
entry.type = atoi(row[0]);
|
||||||
|
entry.npc_type = atoi(row[1]);
|
||||||
|
entry.name = row[2] ? row[2] : "";
|
||||||
|
entry.spell_id = atoi(row[3]);
|
||||||
|
entry.distance = atoi(row[4]);
|
||||||
|
entry.aura_type = atoi(row[5]);
|
||||||
|
entry.spawn_type = atoi(row[6]);
|
||||||
|
entry.movement = atoi(row[7]);
|
||||||
|
entry.duration = atoi(row[8]);
|
||||||
|
entry.icon = atoi(row[9]);
|
||||||
|
entry.cast_time = atoi(row[10]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Auras> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<Auras> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Auras entry{};
|
||||||
|
|
||||||
|
entry.type = atoi(row[0]);
|
||||||
|
entry.npc_type = atoi(row[1]);
|
||||||
|
entry.name = row[2] ? row[2] : "";
|
||||||
|
entry.spell_id = atoi(row[3]);
|
||||||
|
entry.distance = atoi(row[4]);
|
||||||
|
entry.aura_type = atoi(row[5]);
|
||||||
|
entry.spawn_type = atoi(row[6]);
|
||||||
|
entry.movement = atoi(row[7]);
|
||||||
|
entry.duration = atoi(row[8]);
|
||||||
|
entry.icon = atoi(row[9]);
|
||||||
|
entry.cast_time = atoi(row[10]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_AURAS_REPOSITORY_H
|
||||||
392
common/repositories/base/base_base_data_repository.h
Normal file
392
common/repositories/base/base_base_data_repository.h
Normal file
@ -0,0 +1,392 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_BASE_DATA_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_BASE_DATA_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseBaseDataRepository {
|
||||||
|
public:
|
||||||
|
struct BaseData {
|
||||||
|
int level;
|
||||||
|
int class;
|
||||||
|
float hp;
|
||||||
|
float mana;
|
||||||
|
float end;
|
||||||
|
float unk1;
|
||||||
|
float unk2;
|
||||||
|
float hp_fac;
|
||||||
|
float mana_fac;
|
||||||
|
float end_fac;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("level");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"level",
|
||||||
|
"class",
|
||||||
|
"hp",
|
||||||
|
"mana",
|
||||||
|
"end",
|
||||||
|
"unk1",
|
||||||
|
"unk2",
|
||||||
|
"hp_fac",
|
||||||
|
"mana_fac",
|
||||||
|
"end_fac",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("base_data");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static BaseData NewEntity()
|
||||||
|
{
|
||||||
|
BaseData entry{};
|
||||||
|
|
||||||
|
entry.level = 0;
|
||||||
|
entry.class = 0;
|
||||||
|
entry.hp = 0;
|
||||||
|
entry.mana = 0;
|
||||||
|
entry.end = 0;
|
||||||
|
entry.unk1 = 0;
|
||||||
|
entry.unk2 = 0;
|
||||||
|
entry.hp_fac = 0;
|
||||||
|
entry.mana_fac = 0;
|
||||||
|
entry.end_fac = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BaseData GetBaseDataEntry(
|
||||||
|
const std::vector<BaseData> &base_datas,
|
||||||
|
int base_data_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &base_data : base_datas) {
|
||||||
|
if (base_data.level == base_data_id) {
|
||||||
|
return base_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static BaseData FindOne(
|
||||||
|
int base_data_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
base_data_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
BaseData entry{};
|
||||||
|
|
||||||
|
entry.level = atoi(row[0]);
|
||||||
|
entry.class = atoi(row[1]);
|
||||||
|
entry.hp = static_cast<float>(atof(row[2]));
|
||||||
|
entry.mana = static_cast<float>(atof(row[3]));
|
||||||
|
entry.end = static_cast<float>(atof(row[4]));
|
||||||
|
entry.unk1 = static_cast<float>(atof(row[5]));
|
||||||
|
entry.unk2 = static_cast<float>(atof(row[6]));
|
||||||
|
entry.hp_fac = static_cast<float>(atof(row[7]));
|
||||||
|
entry.mana_fac = static_cast<float>(atof(row[8]));
|
||||||
|
entry.end_fac = static_cast<float>(atof(row[9]));
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int base_data_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
base_data_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
BaseData base_data_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(base_data_entry.level));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(base_data_entry.class));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(base_data_entry.hp));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(base_data_entry.mana));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(base_data_entry.end));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(base_data_entry.unk1));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(base_data_entry.unk2));
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(base_data_entry.hp_fac));
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(base_data_entry.mana_fac));
|
||||||
|
update_values.push_back(columns[9] + " = " + std::to_string(base_data_entry.end_fac));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
base_data_entry.level
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static BaseData InsertOne(
|
||||||
|
BaseData base_data_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(base_data_entry.level));
|
||||||
|
insert_values.push_back(std::to_string(base_data_entry.class));
|
||||||
|
insert_values.push_back(std::to_string(base_data_entry.hp));
|
||||||
|
insert_values.push_back(std::to_string(base_data_entry.mana));
|
||||||
|
insert_values.push_back(std::to_string(base_data_entry.end));
|
||||||
|
insert_values.push_back(std::to_string(base_data_entry.unk1));
|
||||||
|
insert_values.push_back(std::to_string(base_data_entry.unk2));
|
||||||
|
insert_values.push_back(std::to_string(base_data_entry.hp_fac));
|
||||||
|
insert_values.push_back(std::to_string(base_data_entry.mana_fac));
|
||||||
|
insert_values.push_back(std::to_string(base_data_entry.end_fac));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
base_data_entry.level = results.LastInsertedID();
|
||||||
|
return base_data_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
base_data_entry = NewEntity();
|
||||||
|
|
||||||
|
return base_data_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<BaseData> base_data_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &base_data_entry: base_data_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(base_data_entry.level));
|
||||||
|
insert_values.push_back(std::to_string(base_data_entry.class));
|
||||||
|
insert_values.push_back(std::to_string(base_data_entry.hp));
|
||||||
|
insert_values.push_back(std::to_string(base_data_entry.mana));
|
||||||
|
insert_values.push_back(std::to_string(base_data_entry.end));
|
||||||
|
insert_values.push_back(std::to_string(base_data_entry.unk1));
|
||||||
|
insert_values.push_back(std::to_string(base_data_entry.unk2));
|
||||||
|
insert_values.push_back(std::to_string(base_data_entry.hp_fac));
|
||||||
|
insert_values.push_back(std::to_string(base_data_entry.mana_fac));
|
||||||
|
insert_values.push_back(std::to_string(base_data_entry.end_fac));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<BaseData> All()
|
||||||
|
{
|
||||||
|
std::vector<BaseData> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
BaseData entry{};
|
||||||
|
|
||||||
|
entry.level = atoi(row[0]);
|
||||||
|
entry.class = atoi(row[1]);
|
||||||
|
entry.hp = static_cast<float>(atof(row[2]));
|
||||||
|
entry.mana = static_cast<float>(atof(row[3]));
|
||||||
|
entry.end = static_cast<float>(atof(row[4]));
|
||||||
|
entry.unk1 = static_cast<float>(atof(row[5]));
|
||||||
|
entry.unk2 = static_cast<float>(atof(row[6]));
|
||||||
|
entry.hp_fac = static_cast<float>(atof(row[7]));
|
||||||
|
entry.mana_fac = static_cast<float>(atof(row[8]));
|
||||||
|
entry.end_fac = static_cast<float>(atof(row[9]));
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<BaseData> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<BaseData> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
BaseData entry{};
|
||||||
|
|
||||||
|
entry.level = atoi(row[0]);
|
||||||
|
entry.class = atoi(row[1]);
|
||||||
|
entry.hp = static_cast<float>(atof(row[2]));
|
||||||
|
entry.mana = static_cast<float>(atof(row[3]));
|
||||||
|
entry.end = static_cast<float>(atof(row[4]));
|
||||||
|
entry.unk1 = static_cast<float>(atof(row[5]));
|
||||||
|
entry.unk2 = static_cast<float>(atof(row[6]));
|
||||||
|
entry.hp_fac = static_cast<float>(atof(row[7]));
|
||||||
|
entry.mana_fac = static_cast<float>(atof(row[8]));
|
||||||
|
entry.end_fac = static_cast<float>(atof(row[9]));
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_BASE_DATA_REPOSITORY_H
|
||||||
407
common/repositories/base/base_blocked_spells_repository.h
Normal file
407
common/repositories/base/base_blocked_spells_repository.h
Normal file
@ -0,0 +1,407 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_BLOCKED_SPELLS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_BLOCKED_SPELLS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseBlockedSpellsRepository {
|
||||||
|
public:
|
||||||
|
struct BlockedSpells {
|
||||||
|
int id;
|
||||||
|
int spellid;
|
||||||
|
int type;
|
||||||
|
int zoneid;
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
float x_diff;
|
||||||
|
float y_diff;
|
||||||
|
float z_diff;
|
||||||
|
std::string message;
|
||||||
|
std::string description;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"spellid",
|
||||||
|
"type",
|
||||||
|
"zoneid",
|
||||||
|
"x",
|
||||||
|
"y",
|
||||||
|
"z",
|
||||||
|
"x_diff",
|
||||||
|
"y_diff",
|
||||||
|
"z_diff",
|
||||||
|
"message",
|
||||||
|
"description",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("blocked_spells");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static BlockedSpells NewEntity()
|
||||||
|
{
|
||||||
|
BlockedSpells entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.spellid = 0;
|
||||||
|
entry.type = 0;
|
||||||
|
entry.zoneid = 0;
|
||||||
|
entry.x = 0;
|
||||||
|
entry.y = 0;
|
||||||
|
entry.z = 0;
|
||||||
|
entry.x_diff = 0;
|
||||||
|
entry.y_diff = 0;
|
||||||
|
entry.z_diff = 0;
|
||||||
|
entry.message = "";
|
||||||
|
entry.description = "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BlockedSpells GetBlockedSpellsEntry(
|
||||||
|
const std::vector<BlockedSpells> &blocked_spellss,
|
||||||
|
int blocked_spells_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &blocked_spells : blocked_spellss) {
|
||||||
|
if (blocked_spells.id == blocked_spells_id) {
|
||||||
|
return blocked_spells;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static BlockedSpells FindOne(
|
||||||
|
int blocked_spells_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
blocked_spells_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
BlockedSpells entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.spellid = atoi(row[1]);
|
||||||
|
entry.type = atoi(row[2]);
|
||||||
|
entry.zoneid = atoi(row[3]);
|
||||||
|
entry.x = static_cast<float>(atof(row[4]));
|
||||||
|
entry.y = static_cast<float>(atof(row[5]));
|
||||||
|
entry.z = static_cast<float>(atof(row[6]));
|
||||||
|
entry.x_diff = static_cast<float>(atof(row[7]));
|
||||||
|
entry.y_diff = static_cast<float>(atof(row[8]));
|
||||||
|
entry.z_diff = static_cast<float>(atof(row[9]));
|
||||||
|
entry.message = row[10] ? row[10] : "";
|
||||||
|
entry.description = row[11] ? row[11] : "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int blocked_spells_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
blocked_spells_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
BlockedSpells blocked_spells_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(blocked_spells_entry.spellid));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(blocked_spells_entry.type));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(blocked_spells_entry.zoneid));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(blocked_spells_entry.x));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(blocked_spells_entry.y));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(blocked_spells_entry.z));
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(blocked_spells_entry.x_diff));
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(blocked_spells_entry.y_diff));
|
||||||
|
update_values.push_back(columns[9] + " = " + std::to_string(blocked_spells_entry.z_diff));
|
||||||
|
update_values.push_back(columns[10] + " = '" + EscapeString(blocked_spells_entry.message) + "'");
|
||||||
|
update_values.push_back(columns[11] + " = '" + EscapeString(blocked_spells_entry.description) + "'");
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
blocked_spells_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static BlockedSpells InsertOne(
|
||||||
|
BlockedSpells blocked_spells_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(blocked_spells_entry.spellid));
|
||||||
|
insert_values.push_back(std::to_string(blocked_spells_entry.type));
|
||||||
|
insert_values.push_back(std::to_string(blocked_spells_entry.zoneid));
|
||||||
|
insert_values.push_back(std::to_string(blocked_spells_entry.x));
|
||||||
|
insert_values.push_back(std::to_string(blocked_spells_entry.y));
|
||||||
|
insert_values.push_back(std::to_string(blocked_spells_entry.z));
|
||||||
|
insert_values.push_back(std::to_string(blocked_spells_entry.x_diff));
|
||||||
|
insert_values.push_back(std::to_string(blocked_spells_entry.y_diff));
|
||||||
|
insert_values.push_back(std::to_string(blocked_spells_entry.z_diff));
|
||||||
|
insert_values.push_back("'" + EscapeString(blocked_spells_entry.message) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(blocked_spells_entry.description) + "'");
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
blocked_spells_entry.id = results.LastInsertedID();
|
||||||
|
return blocked_spells_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
blocked_spells_entry = NewEntity();
|
||||||
|
|
||||||
|
return blocked_spells_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<BlockedSpells> blocked_spells_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &blocked_spells_entry: blocked_spells_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(blocked_spells_entry.spellid));
|
||||||
|
insert_values.push_back(std::to_string(blocked_spells_entry.type));
|
||||||
|
insert_values.push_back(std::to_string(blocked_spells_entry.zoneid));
|
||||||
|
insert_values.push_back(std::to_string(blocked_spells_entry.x));
|
||||||
|
insert_values.push_back(std::to_string(blocked_spells_entry.y));
|
||||||
|
insert_values.push_back(std::to_string(blocked_spells_entry.z));
|
||||||
|
insert_values.push_back(std::to_string(blocked_spells_entry.x_diff));
|
||||||
|
insert_values.push_back(std::to_string(blocked_spells_entry.y_diff));
|
||||||
|
insert_values.push_back(std::to_string(blocked_spells_entry.z_diff));
|
||||||
|
insert_values.push_back("'" + EscapeString(blocked_spells_entry.message) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(blocked_spells_entry.description) + "'");
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<BlockedSpells> All()
|
||||||
|
{
|
||||||
|
std::vector<BlockedSpells> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
BlockedSpells entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.spellid = atoi(row[1]);
|
||||||
|
entry.type = atoi(row[2]);
|
||||||
|
entry.zoneid = atoi(row[3]);
|
||||||
|
entry.x = static_cast<float>(atof(row[4]));
|
||||||
|
entry.y = static_cast<float>(atof(row[5]));
|
||||||
|
entry.z = static_cast<float>(atof(row[6]));
|
||||||
|
entry.x_diff = static_cast<float>(atof(row[7]));
|
||||||
|
entry.y_diff = static_cast<float>(atof(row[8]));
|
||||||
|
entry.z_diff = static_cast<float>(atof(row[9]));
|
||||||
|
entry.message = row[10] ? row[10] : "";
|
||||||
|
entry.description = row[11] ? row[11] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<BlockedSpells> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<BlockedSpells> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
BlockedSpells entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.spellid = atoi(row[1]);
|
||||||
|
entry.type = atoi(row[2]);
|
||||||
|
entry.zoneid = atoi(row[3]);
|
||||||
|
entry.x = static_cast<float>(atof(row[4]));
|
||||||
|
entry.y = static_cast<float>(atof(row[5]));
|
||||||
|
entry.z = static_cast<float>(atof(row[6]));
|
||||||
|
entry.x_diff = static_cast<float>(atof(row[7]));
|
||||||
|
entry.y_diff = static_cast<float>(atof(row[8]));
|
||||||
|
entry.z_diff = static_cast<float>(atof(row[9]));
|
||||||
|
entry.message = row[10] ? row[10] : "";
|
||||||
|
entry.description = row[11] ? row[11] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_BLOCKED_SPELLS_REPOSITORY_H
|
||||||
587
common/repositories/base/base_bug_reports_repository.h
Normal file
587
common/repositories/base/base_bug_reports_repository.h
Normal file
@ -0,0 +1,587 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_BUG_REPORTS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_BUG_REPORTS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseBugReportsRepository {
|
||||||
|
public:
|
||||||
|
struct BugReports {
|
||||||
|
int id;
|
||||||
|
std::string zone;
|
||||||
|
int client_version_id;
|
||||||
|
std::string client_version_name;
|
||||||
|
int account_id;
|
||||||
|
int character_id;
|
||||||
|
std::string character_name;
|
||||||
|
int reporter_spoof;
|
||||||
|
int category_id;
|
||||||
|
std::string category_name;
|
||||||
|
std::string reporter_name;
|
||||||
|
std::string ui_path;
|
||||||
|
float pos_x;
|
||||||
|
float pos_y;
|
||||||
|
float pos_z;
|
||||||
|
int heading;
|
||||||
|
int time_played;
|
||||||
|
int target_id;
|
||||||
|
std::string target_name;
|
||||||
|
int optional_info_mask;
|
||||||
|
int _can_duplicate;
|
||||||
|
int _crash_bug;
|
||||||
|
int _target_info;
|
||||||
|
int _character_flags;
|
||||||
|
int _unknown_value;
|
||||||
|
std::string bug_report;
|
||||||
|
std::string system_info;
|
||||||
|
std::string report_datetime;
|
||||||
|
int bug_status;
|
||||||
|
std::string last_review;
|
||||||
|
std::string last_reviewer;
|
||||||
|
std::string reviewer_notes;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"zone",
|
||||||
|
"client_version_id",
|
||||||
|
"client_version_name",
|
||||||
|
"account_id",
|
||||||
|
"character_id",
|
||||||
|
"character_name",
|
||||||
|
"reporter_spoof",
|
||||||
|
"category_id",
|
||||||
|
"category_name",
|
||||||
|
"reporter_name",
|
||||||
|
"ui_path",
|
||||||
|
"pos_x",
|
||||||
|
"pos_y",
|
||||||
|
"pos_z",
|
||||||
|
"heading",
|
||||||
|
"time_played",
|
||||||
|
"target_id",
|
||||||
|
"target_name",
|
||||||
|
"optional_info_mask",
|
||||||
|
"_can_duplicate",
|
||||||
|
"_crash_bug",
|
||||||
|
"_target_info",
|
||||||
|
"_character_flags",
|
||||||
|
"_unknown_value",
|
||||||
|
"bug_report",
|
||||||
|
"system_info",
|
||||||
|
"report_datetime",
|
||||||
|
"bug_status",
|
||||||
|
"last_review",
|
||||||
|
"last_reviewer",
|
||||||
|
"reviewer_notes",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("bug_reports");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static BugReports NewEntity()
|
||||||
|
{
|
||||||
|
BugReports entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.zone = "Unknown";
|
||||||
|
entry.client_version_id = 0;
|
||||||
|
entry.client_version_name = "Unknown";
|
||||||
|
entry.account_id = 0;
|
||||||
|
entry.character_id = 0;
|
||||||
|
entry.character_name = "Unknown";
|
||||||
|
entry.reporter_spoof = 1;
|
||||||
|
entry.category_id = 0;
|
||||||
|
entry.category_name = "Other";
|
||||||
|
entry.reporter_name = "Unknown";
|
||||||
|
entry.ui_path = "Unknown";
|
||||||
|
entry.pos_x = 0;
|
||||||
|
entry.pos_y = 0;
|
||||||
|
entry.pos_z = 0;
|
||||||
|
entry.heading = 0;
|
||||||
|
entry.time_played = 0;
|
||||||
|
entry.target_id = 0;
|
||||||
|
entry.target_name = "Unknown";
|
||||||
|
entry.optional_info_mask = 0;
|
||||||
|
entry._can_duplicate = 0;
|
||||||
|
entry._crash_bug = 0;
|
||||||
|
entry._target_info = 0;
|
||||||
|
entry._character_flags = 0;
|
||||||
|
entry._unknown_value = 0;
|
||||||
|
entry.bug_report = "";
|
||||||
|
entry.system_info = "";
|
||||||
|
entry.report_datetime = current_timestamp();
|
||||||
|
entry.bug_status = 0;
|
||||||
|
entry.last_review = current_timestamp();
|
||||||
|
entry.last_reviewer = "None";
|
||||||
|
entry.reviewer_notes = "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BugReports GetBugReportsEntry(
|
||||||
|
const std::vector<BugReports> &bug_reportss,
|
||||||
|
int bug_reports_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &bug_reports : bug_reportss) {
|
||||||
|
if (bug_reports.id == bug_reports_id) {
|
||||||
|
return bug_reports;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static BugReports FindOne(
|
||||||
|
int bug_reports_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
bug_reports_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
BugReports entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.zone = row[1] ? row[1] : "";
|
||||||
|
entry.client_version_id = atoi(row[2]);
|
||||||
|
entry.client_version_name = row[3] ? row[3] : "";
|
||||||
|
entry.account_id = atoi(row[4]);
|
||||||
|
entry.character_id = atoi(row[5]);
|
||||||
|
entry.character_name = row[6] ? row[6] : "";
|
||||||
|
entry.reporter_spoof = atoi(row[7]);
|
||||||
|
entry.category_id = atoi(row[8]);
|
||||||
|
entry.category_name = row[9] ? row[9] : "";
|
||||||
|
entry.reporter_name = row[10] ? row[10] : "";
|
||||||
|
entry.ui_path = row[11] ? row[11] : "";
|
||||||
|
entry.pos_x = static_cast<float>(atof(row[12]));
|
||||||
|
entry.pos_y = static_cast<float>(atof(row[13]));
|
||||||
|
entry.pos_z = static_cast<float>(atof(row[14]));
|
||||||
|
entry.heading = atoi(row[15]);
|
||||||
|
entry.time_played = atoi(row[16]);
|
||||||
|
entry.target_id = atoi(row[17]);
|
||||||
|
entry.target_name = row[18] ? row[18] : "";
|
||||||
|
entry.optional_info_mask = atoi(row[19]);
|
||||||
|
entry._can_duplicate = atoi(row[20]);
|
||||||
|
entry._crash_bug = atoi(row[21]);
|
||||||
|
entry._target_info = atoi(row[22]);
|
||||||
|
entry._character_flags = atoi(row[23]);
|
||||||
|
entry._unknown_value = atoi(row[24]);
|
||||||
|
entry.bug_report = row[25] ? row[25] : "";
|
||||||
|
entry.system_info = row[26] ? row[26] : "";
|
||||||
|
entry.report_datetime = row[27] ? row[27] : "";
|
||||||
|
entry.bug_status = atoi(row[28]);
|
||||||
|
entry.last_review = row[29] ? row[29] : "";
|
||||||
|
entry.last_reviewer = row[30] ? row[30] : "";
|
||||||
|
entry.reviewer_notes = row[31] ? row[31] : "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int bug_reports_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
bug_reports_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
BugReports bug_reports_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[1] + " = '" + EscapeString(bug_reports_entry.zone) + "'");
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(bug_reports_entry.client_version_id));
|
||||||
|
update_values.push_back(columns[3] + " = '" + EscapeString(bug_reports_entry.client_version_name) + "'");
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(bug_reports_entry.account_id));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(bug_reports_entry.character_id));
|
||||||
|
update_values.push_back(columns[6] + " = '" + EscapeString(bug_reports_entry.character_name) + "'");
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(bug_reports_entry.reporter_spoof));
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(bug_reports_entry.category_id));
|
||||||
|
update_values.push_back(columns[9] + " = '" + EscapeString(bug_reports_entry.category_name) + "'");
|
||||||
|
update_values.push_back(columns[10] + " = '" + EscapeString(bug_reports_entry.reporter_name) + "'");
|
||||||
|
update_values.push_back(columns[11] + " = '" + EscapeString(bug_reports_entry.ui_path) + "'");
|
||||||
|
update_values.push_back(columns[12] + " = " + std::to_string(bug_reports_entry.pos_x));
|
||||||
|
update_values.push_back(columns[13] + " = " + std::to_string(bug_reports_entry.pos_y));
|
||||||
|
update_values.push_back(columns[14] + " = " + std::to_string(bug_reports_entry.pos_z));
|
||||||
|
update_values.push_back(columns[15] + " = " + std::to_string(bug_reports_entry.heading));
|
||||||
|
update_values.push_back(columns[16] + " = " + std::to_string(bug_reports_entry.time_played));
|
||||||
|
update_values.push_back(columns[17] + " = " + std::to_string(bug_reports_entry.target_id));
|
||||||
|
update_values.push_back(columns[18] + " = '" + EscapeString(bug_reports_entry.target_name) + "'");
|
||||||
|
update_values.push_back(columns[19] + " = " + std::to_string(bug_reports_entry.optional_info_mask));
|
||||||
|
update_values.push_back(columns[20] + " = " + std::to_string(bug_reports_entry._can_duplicate));
|
||||||
|
update_values.push_back(columns[21] + " = " + std::to_string(bug_reports_entry._crash_bug));
|
||||||
|
update_values.push_back(columns[22] + " = " + std::to_string(bug_reports_entry._target_info));
|
||||||
|
update_values.push_back(columns[23] + " = " + std::to_string(bug_reports_entry._character_flags));
|
||||||
|
update_values.push_back(columns[24] + " = " + std::to_string(bug_reports_entry._unknown_value));
|
||||||
|
update_values.push_back(columns[25] + " = '" + EscapeString(bug_reports_entry.bug_report) + "'");
|
||||||
|
update_values.push_back(columns[26] + " = '" + EscapeString(bug_reports_entry.system_info) + "'");
|
||||||
|
update_values.push_back(columns[27] + " = '" + EscapeString(bug_reports_entry.report_datetime) + "'");
|
||||||
|
update_values.push_back(columns[28] + " = " + std::to_string(bug_reports_entry.bug_status));
|
||||||
|
update_values.push_back(columns[29] + " = '" + EscapeString(bug_reports_entry.last_review) + "'");
|
||||||
|
update_values.push_back(columns[30] + " = '" + EscapeString(bug_reports_entry.last_reviewer) + "'");
|
||||||
|
update_values.push_back(columns[31] + " = '" + EscapeString(bug_reports_entry.reviewer_notes) + "'");
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
bug_reports_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static BugReports InsertOne(
|
||||||
|
BugReports bug_reports_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.zone) + "'");
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.client_version_id));
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.client_version_name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.account_id));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.character_id));
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.character_name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.reporter_spoof));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.category_id));
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.category_name) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.reporter_name) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.ui_path) + "'");
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.pos_x));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.pos_y));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.pos_z));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.heading));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.time_played));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.target_id));
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.target_name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.optional_info_mask));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry._can_duplicate));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry._crash_bug));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry._target_info));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry._character_flags));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry._unknown_value));
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.bug_report) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.system_info) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.report_datetime) + "'");
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.bug_status));
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.last_review) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.last_reviewer) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.reviewer_notes) + "'");
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
bug_reports_entry.id = results.LastInsertedID();
|
||||||
|
return bug_reports_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
bug_reports_entry = NewEntity();
|
||||||
|
|
||||||
|
return bug_reports_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<BugReports> bug_reports_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &bug_reports_entry: bug_reports_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.zone) + "'");
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.client_version_id));
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.client_version_name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.account_id));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.character_id));
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.character_name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.reporter_spoof));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.category_id));
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.category_name) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.reporter_name) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.ui_path) + "'");
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.pos_x));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.pos_y));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.pos_z));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.heading));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.time_played));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.target_id));
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.target_name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.optional_info_mask));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry._can_duplicate));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry._crash_bug));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry._target_info));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry._character_flags));
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry._unknown_value));
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.bug_report) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.system_info) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.report_datetime) + "'");
|
||||||
|
insert_values.push_back(std::to_string(bug_reports_entry.bug_status));
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.last_review) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.last_reviewer) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(bug_reports_entry.reviewer_notes) + "'");
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<BugReports> All()
|
||||||
|
{
|
||||||
|
std::vector<BugReports> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
BugReports entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.zone = row[1] ? row[1] : "";
|
||||||
|
entry.client_version_id = atoi(row[2]);
|
||||||
|
entry.client_version_name = row[3] ? row[3] : "";
|
||||||
|
entry.account_id = atoi(row[4]);
|
||||||
|
entry.character_id = atoi(row[5]);
|
||||||
|
entry.character_name = row[6] ? row[6] : "";
|
||||||
|
entry.reporter_spoof = atoi(row[7]);
|
||||||
|
entry.category_id = atoi(row[8]);
|
||||||
|
entry.category_name = row[9] ? row[9] : "";
|
||||||
|
entry.reporter_name = row[10] ? row[10] : "";
|
||||||
|
entry.ui_path = row[11] ? row[11] : "";
|
||||||
|
entry.pos_x = static_cast<float>(atof(row[12]));
|
||||||
|
entry.pos_y = static_cast<float>(atof(row[13]));
|
||||||
|
entry.pos_z = static_cast<float>(atof(row[14]));
|
||||||
|
entry.heading = atoi(row[15]);
|
||||||
|
entry.time_played = atoi(row[16]);
|
||||||
|
entry.target_id = atoi(row[17]);
|
||||||
|
entry.target_name = row[18] ? row[18] : "";
|
||||||
|
entry.optional_info_mask = atoi(row[19]);
|
||||||
|
entry._can_duplicate = atoi(row[20]);
|
||||||
|
entry._crash_bug = atoi(row[21]);
|
||||||
|
entry._target_info = atoi(row[22]);
|
||||||
|
entry._character_flags = atoi(row[23]);
|
||||||
|
entry._unknown_value = atoi(row[24]);
|
||||||
|
entry.bug_report = row[25] ? row[25] : "";
|
||||||
|
entry.system_info = row[26] ? row[26] : "";
|
||||||
|
entry.report_datetime = row[27] ? row[27] : "";
|
||||||
|
entry.bug_status = atoi(row[28]);
|
||||||
|
entry.last_review = row[29] ? row[29] : "";
|
||||||
|
entry.last_reviewer = row[30] ? row[30] : "";
|
||||||
|
entry.reviewer_notes = row[31] ? row[31] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<BugReports> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<BugReports> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
BugReports entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.zone = row[1] ? row[1] : "";
|
||||||
|
entry.client_version_id = atoi(row[2]);
|
||||||
|
entry.client_version_name = row[3] ? row[3] : "";
|
||||||
|
entry.account_id = atoi(row[4]);
|
||||||
|
entry.character_id = atoi(row[5]);
|
||||||
|
entry.character_name = row[6] ? row[6] : "";
|
||||||
|
entry.reporter_spoof = atoi(row[7]);
|
||||||
|
entry.category_id = atoi(row[8]);
|
||||||
|
entry.category_name = row[9] ? row[9] : "";
|
||||||
|
entry.reporter_name = row[10] ? row[10] : "";
|
||||||
|
entry.ui_path = row[11] ? row[11] : "";
|
||||||
|
entry.pos_x = static_cast<float>(atof(row[12]));
|
||||||
|
entry.pos_y = static_cast<float>(atof(row[13]));
|
||||||
|
entry.pos_z = static_cast<float>(atof(row[14]));
|
||||||
|
entry.heading = atoi(row[15]);
|
||||||
|
entry.time_played = atoi(row[16]);
|
||||||
|
entry.target_id = atoi(row[17]);
|
||||||
|
entry.target_name = row[18] ? row[18] : "";
|
||||||
|
entry.optional_info_mask = atoi(row[19]);
|
||||||
|
entry._can_duplicate = atoi(row[20]);
|
||||||
|
entry._crash_bug = atoi(row[21]);
|
||||||
|
entry._target_info = atoi(row[22]);
|
||||||
|
entry._character_flags = atoi(row[23]);
|
||||||
|
entry._unknown_value = atoi(row[24]);
|
||||||
|
entry.bug_report = row[25] ? row[25] : "";
|
||||||
|
entry.system_info = row[26] ? row[26] : "";
|
||||||
|
entry.report_datetime = row[27] ? row[27] : "";
|
||||||
|
entry.bug_status = atoi(row[28]);
|
||||||
|
entry.last_review = row[29] ? row[29] : "";
|
||||||
|
entry.last_reviewer = row[30] ? row[30] : "";
|
||||||
|
entry.reviewer_notes = row[31] ? row[31] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_BUG_REPORTS_REPOSITORY_H
|
||||||
416
common/repositories/base/base_bugs_repository.h
Normal file
416
common/repositories/base/base_bugs_repository.h
Normal file
@ -0,0 +1,416 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_BUGS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_BUGS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseBugsRepository {
|
||||||
|
public:
|
||||||
|
struct Bugs {
|
||||||
|
int id;
|
||||||
|
std::string zone;
|
||||||
|
std::string name;
|
||||||
|
std::string ui;
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
std::string type;
|
||||||
|
int flag;
|
||||||
|
std::string target;
|
||||||
|
std::string bug;
|
||||||
|
std::string date;
|
||||||
|
int status;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"zone",
|
||||||
|
"name",
|
||||||
|
"ui",
|
||||||
|
"x",
|
||||||
|
"y",
|
||||||
|
"z",
|
||||||
|
"type",
|
||||||
|
"flag",
|
||||||
|
"target",
|
||||||
|
"bug",
|
||||||
|
"date",
|
||||||
|
"status",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("bugs");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Bugs NewEntity()
|
||||||
|
{
|
||||||
|
Bugs entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.zone = "";
|
||||||
|
entry.name = "";
|
||||||
|
entry.ui = "";
|
||||||
|
entry.x = 0;
|
||||||
|
entry.y = 0;
|
||||||
|
entry.z = 0;
|
||||||
|
entry.type = "";
|
||||||
|
entry.flag = 0;
|
||||||
|
entry.target = "";
|
||||||
|
entry.bug = "";
|
||||||
|
entry.date = 0;
|
||||||
|
entry.status = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Bugs GetBugsEntry(
|
||||||
|
const std::vector<Bugs> &bugss,
|
||||||
|
int bugs_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &bugs : bugss) {
|
||||||
|
if (bugs.id == bugs_id) {
|
||||||
|
return bugs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Bugs FindOne(
|
||||||
|
int bugs_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
bugs_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
Bugs entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.zone = row[1] ? row[1] : "";
|
||||||
|
entry.name = row[2] ? row[2] : "";
|
||||||
|
entry.ui = row[3] ? row[3] : "";
|
||||||
|
entry.x = static_cast<float>(atof(row[4]));
|
||||||
|
entry.y = static_cast<float>(atof(row[5]));
|
||||||
|
entry.z = static_cast<float>(atof(row[6]));
|
||||||
|
entry.type = row[7] ? row[7] : "";
|
||||||
|
entry.flag = atoi(row[8]);
|
||||||
|
entry.target = row[9] ? row[9] : "";
|
||||||
|
entry.bug = row[10] ? row[10] : "";
|
||||||
|
entry.date = row[11] ? row[11] : "";
|
||||||
|
entry.status = atoi(row[12]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int bugs_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
bugs_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Bugs bugs_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[1] + " = '" + EscapeString(bugs_entry.zone) + "'");
|
||||||
|
update_values.push_back(columns[2] + " = '" + EscapeString(bugs_entry.name) + "'");
|
||||||
|
update_values.push_back(columns[3] + " = '" + EscapeString(bugs_entry.ui) + "'");
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(bugs_entry.x));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(bugs_entry.y));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(bugs_entry.z));
|
||||||
|
update_values.push_back(columns[7] + " = '" + EscapeString(bugs_entry.type) + "'");
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(bugs_entry.flag));
|
||||||
|
update_values.push_back(columns[9] + " = '" + EscapeString(bugs_entry.target) + "'");
|
||||||
|
update_values.push_back(columns[10] + " = '" + EscapeString(bugs_entry.bug) + "'");
|
||||||
|
update_values.push_back(columns[11] + " = '" + EscapeString(bugs_entry.date) + "'");
|
||||||
|
update_values.push_back(columns[12] + " = " + std::to_string(bugs_entry.status));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
bugs_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Bugs InsertOne(
|
||||||
|
Bugs bugs_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back("'" + EscapeString(bugs_entry.zone) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(bugs_entry.name) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(bugs_entry.ui) + "'");
|
||||||
|
insert_values.push_back(std::to_string(bugs_entry.x));
|
||||||
|
insert_values.push_back(std::to_string(bugs_entry.y));
|
||||||
|
insert_values.push_back(std::to_string(bugs_entry.z));
|
||||||
|
insert_values.push_back("'" + EscapeString(bugs_entry.type) + "'");
|
||||||
|
insert_values.push_back(std::to_string(bugs_entry.flag));
|
||||||
|
insert_values.push_back("'" + EscapeString(bugs_entry.target) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(bugs_entry.bug) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(bugs_entry.date) + "'");
|
||||||
|
insert_values.push_back(std::to_string(bugs_entry.status));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
bugs_entry.id = results.LastInsertedID();
|
||||||
|
return bugs_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
bugs_entry = NewEntity();
|
||||||
|
|
||||||
|
return bugs_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<Bugs> bugs_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &bugs_entry: bugs_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back("'" + EscapeString(bugs_entry.zone) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(bugs_entry.name) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(bugs_entry.ui) + "'");
|
||||||
|
insert_values.push_back(std::to_string(bugs_entry.x));
|
||||||
|
insert_values.push_back(std::to_string(bugs_entry.y));
|
||||||
|
insert_values.push_back(std::to_string(bugs_entry.z));
|
||||||
|
insert_values.push_back("'" + EscapeString(bugs_entry.type) + "'");
|
||||||
|
insert_values.push_back(std::to_string(bugs_entry.flag));
|
||||||
|
insert_values.push_back("'" + EscapeString(bugs_entry.target) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(bugs_entry.bug) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(bugs_entry.date) + "'");
|
||||||
|
insert_values.push_back(std::to_string(bugs_entry.status));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Bugs> All()
|
||||||
|
{
|
||||||
|
std::vector<Bugs> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Bugs entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.zone = row[1] ? row[1] : "";
|
||||||
|
entry.name = row[2] ? row[2] : "";
|
||||||
|
entry.ui = row[3] ? row[3] : "";
|
||||||
|
entry.x = static_cast<float>(atof(row[4]));
|
||||||
|
entry.y = static_cast<float>(atof(row[5]));
|
||||||
|
entry.z = static_cast<float>(atof(row[6]));
|
||||||
|
entry.type = row[7] ? row[7] : "";
|
||||||
|
entry.flag = atoi(row[8]);
|
||||||
|
entry.target = row[9] ? row[9] : "";
|
||||||
|
entry.bug = row[10] ? row[10] : "";
|
||||||
|
entry.date = row[11] ? row[11] : "";
|
||||||
|
entry.status = atoi(row[12]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Bugs> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<Bugs> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Bugs entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.zone = row[1] ? row[1] : "";
|
||||||
|
entry.name = row[2] ? row[2] : "";
|
||||||
|
entry.ui = row[3] ? row[3] : "";
|
||||||
|
entry.x = static_cast<float>(atof(row[4]));
|
||||||
|
entry.y = static_cast<float>(atof(row[5]));
|
||||||
|
entry.z = static_cast<float>(atof(row[6]));
|
||||||
|
entry.type = row[7] ? row[7] : "";
|
||||||
|
entry.flag = atoi(row[8]);
|
||||||
|
entry.target = row[9] ? row[9] : "";
|
||||||
|
entry.bug = row[10] ? row[10] : "";
|
||||||
|
entry.date = row[11] ? row[11] : "";
|
||||||
|
entry.status = atoi(row[12]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_BUGS_REPOSITORY_H
|
||||||
356
common/repositories/base/base_buyer_repository.h
Normal file
356
common/repositories/base/base_buyer_repository.h
Normal file
@ -0,0 +1,356 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_BUYER_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_BUYER_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseBuyerRepository {
|
||||||
|
public:
|
||||||
|
struct Buyer {
|
||||||
|
int charid;
|
||||||
|
int buyslot;
|
||||||
|
int itemid;
|
||||||
|
std::string itemname;
|
||||||
|
int quantity;
|
||||||
|
int price;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("charid");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"charid",
|
||||||
|
"buyslot",
|
||||||
|
"itemid",
|
||||||
|
"itemname",
|
||||||
|
"quantity",
|
||||||
|
"price",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("buyer");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Buyer NewEntity()
|
||||||
|
{
|
||||||
|
Buyer entry{};
|
||||||
|
|
||||||
|
entry.charid = 0;
|
||||||
|
entry.buyslot = 0;
|
||||||
|
entry.itemid = 0;
|
||||||
|
entry.itemname = "";
|
||||||
|
entry.quantity = 0;
|
||||||
|
entry.price = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Buyer GetBuyerEntry(
|
||||||
|
const std::vector<Buyer> &buyers,
|
||||||
|
int buyer_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &buyer : buyers) {
|
||||||
|
if (buyer.charid == buyer_id) {
|
||||||
|
return buyer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Buyer FindOne(
|
||||||
|
int buyer_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
buyer_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
Buyer entry{};
|
||||||
|
|
||||||
|
entry.charid = atoi(row[0]);
|
||||||
|
entry.buyslot = atoi(row[1]);
|
||||||
|
entry.itemid = atoi(row[2]);
|
||||||
|
entry.itemname = row[3] ? row[3] : "";
|
||||||
|
entry.quantity = atoi(row[4]);
|
||||||
|
entry.price = atoi(row[5]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int buyer_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
buyer_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Buyer buyer_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(buyer_entry.charid));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(buyer_entry.buyslot));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(buyer_entry.itemid));
|
||||||
|
update_values.push_back(columns[3] + " = '" + EscapeString(buyer_entry.itemname) + "'");
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(buyer_entry.quantity));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(buyer_entry.price));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
buyer_entry.charid
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Buyer InsertOne(
|
||||||
|
Buyer buyer_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(buyer_entry.charid));
|
||||||
|
insert_values.push_back(std::to_string(buyer_entry.buyslot));
|
||||||
|
insert_values.push_back(std::to_string(buyer_entry.itemid));
|
||||||
|
insert_values.push_back("'" + EscapeString(buyer_entry.itemname) + "'");
|
||||||
|
insert_values.push_back(std::to_string(buyer_entry.quantity));
|
||||||
|
insert_values.push_back(std::to_string(buyer_entry.price));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
buyer_entry.charid = results.LastInsertedID();
|
||||||
|
return buyer_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
buyer_entry = NewEntity();
|
||||||
|
|
||||||
|
return buyer_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<Buyer> buyer_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &buyer_entry: buyer_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(buyer_entry.charid));
|
||||||
|
insert_values.push_back(std::to_string(buyer_entry.buyslot));
|
||||||
|
insert_values.push_back(std::to_string(buyer_entry.itemid));
|
||||||
|
insert_values.push_back("'" + EscapeString(buyer_entry.itemname) + "'");
|
||||||
|
insert_values.push_back(std::to_string(buyer_entry.quantity));
|
||||||
|
insert_values.push_back(std::to_string(buyer_entry.price));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Buyer> All()
|
||||||
|
{
|
||||||
|
std::vector<Buyer> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Buyer entry{};
|
||||||
|
|
||||||
|
entry.charid = atoi(row[0]);
|
||||||
|
entry.buyslot = atoi(row[1]);
|
||||||
|
entry.itemid = atoi(row[2]);
|
||||||
|
entry.itemname = row[3] ? row[3] : "";
|
||||||
|
entry.quantity = atoi(row[4]);
|
||||||
|
entry.price = atoi(row[5]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Buyer> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<Buyer> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Buyer entry{};
|
||||||
|
|
||||||
|
entry.charid = atoi(row[0]);
|
||||||
|
entry.buyslot = atoi(row[1]);
|
||||||
|
entry.itemid = atoi(row[2]);
|
||||||
|
entry.itemname = row[3] ? row[3] : "";
|
||||||
|
entry.quantity = atoi(row[4]);
|
||||||
|
entry.price = atoi(row[5]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_BUYER_REPOSITORY_H
|
||||||
@ -0,0 +1,356 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHAR_CREATE_COMBINATIONS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHAR_CREATE_COMBINATIONS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharCreateCombinationsRepository {
|
||||||
|
public:
|
||||||
|
struct CharCreateCombinations {
|
||||||
|
int allocation_id;
|
||||||
|
int race;
|
||||||
|
int class;
|
||||||
|
int deity;
|
||||||
|
int start_zone;
|
||||||
|
int expansions_req;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("race");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"allocation_id",
|
||||||
|
"race",
|
||||||
|
"class",
|
||||||
|
"deity",
|
||||||
|
"start_zone",
|
||||||
|
"expansions_req",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("char_create_combinations");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharCreateCombinations NewEntity()
|
||||||
|
{
|
||||||
|
CharCreateCombinations entry{};
|
||||||
|
|
||||||
|
entry.allocation_id = 0;
|
||||||
|
entry.race = 0;
|
||||||
|
entry.class = 0;
|
||||||
|
entry.deity = 0;
|
||||||
|
entry.start_zone = 0;
|
||||||
|
entry.expansions_req = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharCreateCombinations GetCharCreateCombinationsEntry(
|
||||||
|
const std::vector<CharCreateCombinations> &char_create_combinationss,
|
||||||
|
int char_create_combinations_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &char_create_combinations : char_create_combinationss) {
|
||||||
|
if (char_create_combinations.race == char_create_combinations_id) {
|
||||||
|
return char_create_combinations;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharCreateCombinations FindOne(
|
||||||
|
int char_create_combinations_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
char_create_combinations_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharCreateCombinations entry{};
|
||||||
|
|
||||||
|
entry.allocation_id = atoi(row[0]);
|
||||||
|
entry.race = atoi(row[1]);
|
||||||
|
entry.class = atoi(row[2]);
|
||||||
|
entry.deity = atoi(row[3]);
|
||||||
|
entry.start_zone = atoi(row[4]);
|
||||||
|
entry.expansions_req = atoi(row[5]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int char_create_combinations_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
char_create_combinations_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharCreateCombinations char_create_combinations_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(char_create_combinations_entry.allocation_id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(char_create_combinations_entry.race));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(char_create_combinations_entry.class));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(char_create_combinations_entry.deity));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(char_create_combinations_entry.start_zone));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(char_create_combinations_entry.expansions_req));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
char_create_combinations_entry.race
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharCreateCombinations InsertOne(
|
||||||
|
CharCreateCombinations char_create_combinations_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(char_create_combinations_entry.allocation_id));
|
||||||
|
insert_values.push_back(std::to_string(char_create_combinations_entry.race));
|
||||||
|
insert_values.push_back(std::to_string(char_create_combinations_entry.class));
|
||||||
|
insert_values.push_back(std::to_string(char_create_combinations_entry.deity));
|
||||||
|
insert_values.push_back(std::to_string(char_create_combinations_entry.start_zone));
|
||||||
|
insert_values.push_back(std::to_string(char_create_combinations_entry.expansions_req));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
char_create_combinations_entry.race = results.LastInsertedID();
|
||||||
|
return char_create_combinations_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
char_create_combinations_entry = NewEntity();
|
||||||
|
|
||||||
|
return char_create_combinations_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharCreateCombinations> char_create_combinations_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &char_create_combinations_entry: char_create_combinations_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(char_create_combinations_entry.allocation_id));
|
||||||
|
insert_values.push_back(std::to_string(char_create_combinations_entry.race));
|
||||||
|
insert_values.push_back(std::to_string(char_create_combinations_entry.class));
|
||||||
|
insert_values.push_back(std::to_string(char_create_combinations_entry.deity));
|
||||||
|
insert_values.push_back(std::to_string(char_create_combinations_entry.start_zone));
|
||||||
|
insert_values.push_back(std::to_string(char_create_combinations_entry.expansions_req));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharCreateCombinations> All()
|
||||||
|
{
|
||||||
|
std::vector<CharCreateCombinations> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharCreateCombinations entry{};
|
||||||
|
|
||||||
|
entry.allocation_id = atoi(row[0]);
|
||||||
|
entry.race = atoi(row[1]);
|
||||||
|
entry.class = atoi(row[2]);
|
||||||
|
entry.deity = atoi(row[3]);
|
||||||
|
entry.start_zone = atoi(row[4]);
|
||||||
|
entry.expansions_req = atoi(row[5]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharCreateCombinations> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharCreateCombinations> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharCreateCombinations entry{};
|
||||||
|
|
||||||
|
entry.allocation_id = atoi(row[0]);
|
||||||
|
entry.race = atoi(row[1]);
|
||||||
|
entry.class = atoi(row[2]);
|
||||||
|
entry.deity = atoi(row[3]);
|
||||||
|
entry.start_zone = atoi(row[4]);
|
||||||
|
entry.expansions_req = atoi(row[5]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHAR_CREATE_COMBINATIONS_REPOSITORY_H
|
||||||
@ -0,0 +1,437 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHAR_CREATE_POINT_ALLOCATIONS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHAR_CREATE_POINT_ALLOCATIONS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharCreatePointAllocationsRepository {
|
||||||
|
public:
|
||||||
|
struct CharCreatePointAllocations {
|
||||||
|
int id;
|
||||||
|
int base_str;
|
||||||
|
int base_sta;
|
||||||
|
int base_dex;
|
||||||
|
int base_agi;
|
||||||
|
int base_int;
|
||||||
|
int base_wis;
|
||||||
|
int base_cha;
|
||||||
|
int alloc_str;
|
||||||
|
int alloc_sta;
|
||||||
|
int alloc_dex;
|
||||||
|
int alloc_agi;
|
||||||
|
int alloc_int;
|
||||||
|
int alloc_wis;
|
||||||
|
int alloc_cha;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"base_str",
|
||||||
|
"base_sta",
|
||||||
|
"base_dex",
|
||||||
|
"base_agi",
|
||||||
|
"base_int",
|
||||||
|
"base_wis",
|
||||||
|
"base_cha",
|
||||||
|
"alloc_str",
|
||||||
|
"alloc_sta",
|
||||||
|
"alloc_dex",
|
||||||
|
"alloc_agi",
|
||||||
|
"alloc_int",
|
||||||
|
"alloc_wis",
|
||||||
|
"alloc_cha",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("char_create_point_allocations");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharCreatePointAllocations NewEntity()
|
||||||
|
{
|
||||||
|
CharCreatePointAllocations entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.base_str = 0;
|
||||||
|
entry.base_sta = 0;
|
||||||
|
entry.base_dex = 0;
|
||||||
|
entry.base_agi = 0;
|
||||||
|
entry.base_int = 0;
|
||||||
|
entry.base_wis = 0;
|
||||||
|
entry.base_cha = 0;
|
||||||
|
entry.alloc_str = 0;
|
||||||
|
entry.alloc_sta = 0;
|
||||||
|
entry.alloc_dex = 0;
|
||||||
|
entry.alloc_agi = 0;
|
||||||
|
entry.alloc_int = 0;
|
||||||
|
entry.alloc_wis = 0;
|
||||||
|
entry.alloc_cha = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharCreatePointAllocations GetCharCreatePointAllocationsEntry(
|
||||||
|
const std::vector<CharCreatePointAllocations> &char_create_point_allocationss,
|
||||||
|
int char_create_point_allocations_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &char_create_point_allocations : char_create_point_allocationss) {
|
||||||
|
if (char_create_point_allocations.id == char_create_point_allocations_id) {
|
||||||
|
return char_create_point_allocations;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharCreatePointAllocations FindOne(
|
||||||
|
int char_create_point_allocations_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
char_create_point_allocations_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharCreatePointAllocations entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.base_str = atoi(row[1]);
|
||||||
|
entry.base_sta = atoi(row[2]);
|
||||||
|
entry.base_dex = atoi(row[3]);
|
||||||
|
entry.base_agi = atoi(row[4]);
|
||||||
|
entry.base_int = atoi(row[5]);
|
||||||
|
entry.base_wis = atoi(row[6]);
|
||||||
|
entry.base_cha = atoi(row[7]);
|
||||||
|
entry.alloc_str = atoi(row[8]);
|
||||||
|
entry.alloc_sta = atoi(row[9]);
|
||||||
|
entry.alloc_dex = atoi(row[10]);
|
||||||
|
entry.alloc_agi = atoi(row[11]);
|
||||||
|
entry.alloc_int = atoi(row[12]);
|
||||||
|
entry.alloc_wis = atoi(row[13]);
|
||||||
|
entry.alloc_cha = atoi(row[14]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int char_create_point_allocations_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
char_create_point_allocations_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharCreatePointAllocations char_create_point_allocations_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(char_create_point_allocations_entry.id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(char_create_point_allocations_entry.base_str));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(char_create_point_allocations_entry.base_sta));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(char_create_point_allocations_entry.base_dex));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(char_create_point_allocations_entry.base_agi));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(char_create_point_allocations_entry.base_int));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(char_create_point_allocations_entry.base_wis));
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(char_create_point_allocations_entry.base_cha));
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(char_create_point_allocations_entry.alloc_str));
|
||||||
|
update_values.push_back(columns[9] + " = " + std::to_string(char_create_point_allocations_entry.alloc_sta));
|
||||||
|
update_values.push_back(columns[10] + " = " + std::to_string(char_create_point_allocations_entry.alloc_dex));
|
||||||
|
update_values.push_back(columns[11] + " = " + std::to_string(char_create_point_allocations_entry.alloc_agi));
|
||||||
|
update_values.push_back(columns[12] + " = " + std::to_string(char_create_point_allocations_entry.alloc_int));
|
||||||
|
update_values.push_back(columns[13] + " = " + std::to_string(char_create_point_allocations_entry.alloc_wis));
|
||||||
|
update_values.push_back(columns[14] + " = " + std::to_string(char_create_point_allocations_entry.alloc_cha));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
char_create_point_allocations_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharCreatePointAllocations InsertOne(
|
||||||
|
CharCreatePointAllocations char_create_point_allocations_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_str));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_sta));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_dex));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_agi));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_int));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_wis));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_cha));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_str));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_sta));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_dex));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_agi));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_int));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_wis));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_cha));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
char_create_point_allocations_entry.id = results.LastInsertedID();
|
||||||
|
return char_create_point_allocations_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
char_create_point_allocations_entry = NewEntity();
|
||||||
|
|
||||||
|
return char_create_point_allocations_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharCreatePointAllocations> char_create_point_allocations_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &char_create_point_allocations_entry: char_create_point_allocations_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_str));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_sta));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_dex));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_agi));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_int));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_wis));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_cha));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_str));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_sta));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_dex));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_agi));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_int));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_wis));
|
||||||
|
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_cha));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharCreatePointAllocations> All()
|
||||||
|
{
|
||||||
|
std::vector<CharCreatePointAllocations> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharCreatePointAllocations entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.base_str = atoi(row[1]);
|
||||||
|
entry.base_sta = atoi(row[2]);
|
||||||
|
entry.base_dex = atoi(row[3]);
|
||||||
|
entry.base_agi = atoi(row[4]);
|
||||||
|
entry.base_int = atoi(row[5]);
|
||||||
|
entry.base_wis = atoi(row[6]);
|
||||||
|
entry.base_cha = atoi(row[7]);
|
||||||
|
entry.alloc_str = atoi(row[8]);
|
||||||
|
entry.alloc_sta = atoi(row[9]);
|
||||||
|
entry.alloc_dex = atoi(row[10]);
|
||||||
|
entry.alloc_agi = atoi(row[11]);
|
||||||
|
entry.alloc_int = atoi(row[12]);
|
||||||
|
entry.alloc_wis = atoi(row[13]);
|
||||||
|
entry.alloc_cha = atoi(row[14]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharCreatePointAllocations> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharCreatePointAllocations> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharCreatePointAllocations entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.base_str = atoi(row[1]);
|
||||||
|
entry.base_sta = atoi(row[2]);
|
||||||
|
entry.base_dex = atoi(row[3]);
|
||||||
|
entry.base_agi = atoi(row[4]);
|
||||||
|
entry.base_int = atoi(row[5]);
|
||||||
|
entry.base_wis = atoi(row[6]);
|
||||||
|
entry.base_cha = atoi(row[7]);
|
||||||
|
entry.alloc_str = atoi(row[8]);
|
||||||
|
entry.alloc_sta = atoi(row[9]);
|
||||||
|
entry.alloc_dex = atoi(row[10]);
|
||||||
|
entry.alloc_agi = atoi(row[11]);
|
||||||
|
entry.alloc_int = atoi(row[12]);
|
||||||
|
entry.alloc_wis = atoi(row[13]);
|
||||||
|
entry.alloc_cha = atoi(row[14]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHAR_CREATE_POINT_ALLOCATIONS_REPOSITORY_H
|
||||||
329
common/repositories/base/base_char_recipe_list_repository.h
Normal file
329
common/repositories/base/base_char_recipe_list_repository.h
Normal file
@ -0,0 +1,329 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHAR_RECIPE_LIST_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHAR_RECIPE_LIST_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharRecipeListRepository {
|
||||||
|
public:
|
||||||
|
struct CharRecipeList {
|
||||||
|
int char_id;
|
||||||
|
int recipe_id;
|
||||||
|
int madecount;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("char_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"char_id",
|
||||||
|
"recipe_id",
|
||||||
|
"madecount",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("char_recipe_list");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharRecipeList NewEntity()
|
||||||
|
{
|
||||||
|
CharRecipeList entry{};
|
||||||
|
|
||||||
|
entry.char_id = 0;
|
||||||
|
entry.recipe_id = 0;
|
||||||
|
entry.madecount = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharRecipeList GetCharRecipeListEntry(
|
||||||
|
const std::vector<CharRecipeList> &char_recipe_lists,
|
||||||
|
int char_recipe_list_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &char_recipe_list : char_recipe_lists) {
|
||||||
|
if (char_recipe_list.char_id == char_recipe_list_id) {
|
||||||
|
return char_recipe_list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharRecipeList FindOne(
|
||||||
|
int char_recipe_list_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
char_recipe_list_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharRecipeList entry{};
|
||||||
|
|
||||||
|
entry.char_id = atoi(row[0]);
|
||||||
|
entry.recipe_id = atoi(row[1]);
|
||||||
|
entry.madecount = atoi(row[2]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int char_recipe_list_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
char_recipe_list_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharRecipeList char_recipe_list_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(char_recipe_list_entry.char_id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(char_recipe_list_entry.recipe_id));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(char_recipe_list_entry.madecount));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
char_recipe_list_entry.char_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharRecipeList InsertOne(
|
||||||
|
CharRecipeList char_recipe_list_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(char_recipe_list_entry.char_id));
|
||||||
|
insert_values.push_back(std::to_string(char_recipe_list_entry.recipe_id));
|
||||||
|
insert_values.push_back(std::to_string(char_recipe_list_entry.madecount));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
char_recipe_list_entry.char_id = results.LastInsertedID();
|
||||||
|
return char_recipe_list_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
char_recipe_list_entry = NewEntity();
|
||||||
|
|
||||||
|
return char_recipe_list_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharRecipeList> char_recipe_list_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &char_recipe_list_entry: char_recipe_list_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(char_recipe_list_entry.char_id));
|
||||||
|
insert_values.push_back(std::to_string(char_recipe_list_entry.recipe_id));
|
||||||
|
insert_values.push_back(std::to_string(char_recipe_list_entry.madecount));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharRecipeList> All()
|
||||||
|
{
|
||||||
|
std::vector<CharRecipeList> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharRecipeList entry{};
|
||||||
|
|
||||||
|
entry.char_id = atoi(row[0]);
|
||||||
|
entry.recipe_id = atoi(row[1]);
|
||||||
|
entry.madecount = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharRecipeList> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharRecipeList> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharRecipeList entry{};
|
||||||
|
|
||||||
|
entry.char_id = atoi(row[0]);
|
||||||
|
entry.recipe_id = atoi(row[1]);
|
||||||
|
entry.madecount = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHAR_RECIPE_LIST_REPOSITORY_H
|
||||||
347
common/repositories/base/base_character_activities_repository.h
Normal file
347
common/repositories/base/base_character_activities_repository.h
Normal file
@ -0,0 +1,347 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_ACTIVITIES_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_ACTIVITIES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterActivitiesRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterActivities {
|
||||||
|
int charid;
|
||||||
|
int taskid;
|
||||||
|
int activityid;
|
||||||
|
int donecount;
|
||||||
|
int completed;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("charid");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"charid",
|
||||||
|
"taskid",
|
||||||
|
"activityid",
|
||||||
|
"donecount",
|
||||||
|
"completed",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_activities");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterActivities NewEntity()
|
||||||
|
{
|
||||||
|
CharacterActivities entry{};
|
||||||
|
|
||||||
|
entry.charid = 0;
|
||||||
|
entry.taskid = 0;
|
||||||
|
entry.activityid = 0;
|
||||||
|
entry.donecount = 0;
|
||||||
|
entry.completed = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterActivities GetCharacterActivitiesEntry(
|
||||||
|
const std::vector<CharacterActivities> &character_activitiess,
|
||||||
|
int character_activities_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_activities : character_activitiess) {
|
||||||
|
if (character_activities.charid == character_activities_id) {
|
||||||
|
return character_activities;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterActivities FindOne(
|
||||||
|
int character_activities_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_activities_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterActivities entry{};
|
||||||
|
|
||||||
|
entry.charid = atoi(row[0]);
|
||||||
|
entry.taskid = atoi(row[1]);
|
||||||
|
entry.activityid = atoi(row[2]);
|
||||||
|
entry.donecount = atoi(row[3]);
|
||||||
|
entry.completed = atoi(row[4]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_activities_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_activities_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterActivities character_activities_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(character_activities_entry.charid));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_activities_entry.taskid));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_activities_entry.activityid));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(character_activities_entry.donecount));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(character_activities_entry.completed));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_activities_entry.charid
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterActivities InsertOne(
|
||||||
|
CharacterActivities character_activities_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_activities_entry.charid));
|
||||||
|
insert_values.push_back(std::to_string(character_activities_entry.taskid));
|
||||||
|
insert_values.push_back(std::to_string(character_activities_entry.activityid));
|
||||||
|
insert_values.push_back(std::to_string(character_activities_entry.donecount));
|
||||||
|
insert_values.push_back(std::to_string(character_activities_entry.completed));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_activities_entry.charid = results.LastInsertedID();
|
||||||
|
return character_activities_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_activities_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_activities_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterActivities> character_activities_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_activities_entry: character_activities_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_activities_entry.charid));
|
||||||
|
insert_values.push_back(std::to_string(character_activities_entry.taskid));
|
||||||
|
insert_values.push_back(std::to_string(character_activities_entry.activityid));
|
||||||
|
insert_values.push_back(std::to_string(character_activities_entry.donecount));
|
||||||
|
insert_values.push_back(std::to_string(character_activities_entry.completed));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterActivities> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterActivities> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterActivities entry{};
|
||||||
|
|
||||||
|
entry.charid = atoi(row[0]);
|
||||||
|
entry.taskid = atoi(row[1]);
|
||||||
|
entry.activityid = atoi(row[2]);
|
||||||
|
entry.donecount = atoi(row[3]);
|
||||||
|
entry.completed = atoi(row[4]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterActivities> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterActivities> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterActivities entry{};
|
||||||
|
|
||||||
|
entry.charid = atoi(row[0]);
|
||||||
|
entry.taskid = atoi(row[1]);
|
||||||
|
entry.activityid = atoi(row[2]);
|
||||||
|
entry.donecount = atoi(row[3]);
|
||||||
|
entry.completed = atoi(row[4]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_ACTIVITIES_REPOSITORY_H
|
||||||
@ -0,0 +1,329 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_ALT_CURRENCY_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_ALT_CURRENCY_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterAltCurrencyRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterAltCurrency {
|
||||||
|
int char_id;
|
||||||
|
int currency_id;
|
||||||
|
int amount;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("char_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"char_id",
|
||||||
|
"currency_id",
|
||||||
|
"amount",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_alt_currency");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterAltCurrency NewEntity()
|
||||||
|
{
|
||||||
|
CharacterAltCurrency entry{};
|
||||||
|
|
||||||
|
entry.char_id = 0;
|
||||||
|
entry.currency_id = 0;
|
||||||
|
entry.amount = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterAltCurrency GetCharacterAltCurrencyEntry(
|
||||||
|
const std::vector<CharacterAltCurrency> &character_alt_currencys,
|
||||||
|
int character_alt_currency_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_alt_currency : character_alt_currencys) {
|
||||||
|
if (character_alt_currency.char_id == character_alt_currency_id) {
|
||||||
|
return character_alt_currency;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterAltCurrency FindOne(
|
||||||
|
int character_alt_currency_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_alt_currency_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterAltCurrency entry{};
|
||||||
|
|
||||||
|
entry.char_id = atoi(row[0]);
|
||||||
|
entry.currency_id = atoi(row[1]);
|
||||||
|
entry.amount = atoi(row[2]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_alt_currency_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_alt_currency_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterAltCurrency character_alt_currency_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(character_alt_currency_entry.char_id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_alt_currency_entry.currency_id));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_alt_currency_entry.amount));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_alt_currency_entry.char_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterAltCurrency InsertOne(
|
||||||
|
CharacterAltCurrency character_alt_currency_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_alt_currency_entry.char_id));
|
||||||
|
insert_values.push_back(std::to_string(character_alt_currency_entry.currency_id));
|
||||||
|
insert_values.push_back(std::to_string(character_alt_currency_entry.amount));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_alt_currency_entry.char_id = results.LastInsertedID();
|
||||||
|
return character_alt_currency_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_alt_currency_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_alt_currency_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterAltCurrency> character_alt_currency_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_alt_currency_entry: character_alt_currency_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_alt_currency_entry.char_id));
|
||||||
|
insert_values.push_back(std::to_string(character_alt_currency_entry.currency_id));
|
||||||
|
insert_values.push_back(std::to_string(character_alt_currency_entry.amount));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterAltCurrency> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterAltCurrency> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterAltCurrency entry{};
|
||||||
|
|
||||||
|
entry.char_id = atoi(row[0]);
|
||||||
|
entry.currency_id = atoi(row[1]);
|
||||||
|
entry.amount = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterAltCurrency> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterAltCurrency> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterAltCurrency entry{};
|
||||||
|
|
||||||
|
entry.char_id = atoi(row[0]);
|
||||||
|
entry.currency_id = atoi(row[1]);
|
||||||
|
entry.amount = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_ALT_CURRENCY_REPOSITORY_H
|
||||||
@ -0,0 +1,338 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_ALTERNATE_ABILITIES_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_ALTERNATE_ABILITIES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterAlternateAbilitiesRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterAlternateAbilities {
|
||||||
|
int id;
|
||||||
|
int aa_id;
|
||||||
|
int aa_value;
|
||||||
|
int charges;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"aa_id",
|
||||||
|
"aa_value",
|
||||||
|
"charges",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_alternate_abilities");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterAlternateAbilities NewEntity()
|
||||||
|
{
|
||||||
|
CharacterAlternateAbilities entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.aa_id = 0;
|
||||||
|
entry.aa_value = 0;
|
||||||
|
entry.charges = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterAlternateAbilities GetCharacterAlternateAbilitiesEntry(
|
||||||
|
const std::vector<CharacterAlternateAbilities> &character_alternate_abilitiess,
|
||||||
|
int character_alternate_abilities_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_alternate_abilities : character_alternate_abilitiess) {
|
||||||
|
if (character_alternate_abilities.id == character_alternate_abilities_id) {
|
||||||
|
return character_alternate_abilities;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterAlternateAbilities FindOne(
|
||||||
|
int character_alternate_abilities_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_alternate_abilities_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterAlternateAbilities entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.aa_id = atoi(row[1]);
|
||||||
|
entry.aa_value = atoi(row[2]);
|
||||||
|
entry.charges = atoi(row[3]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_alternate_abilities_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_alternate_abilities_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterAlternateAbilities character_alternate_abilities_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(character_alternate_abilities_entry.id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_alternate_abilities_entry.aa_id));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_alternate_abilities_entry.aa_value));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(character_alternate_abilities_entry.charges));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_alternate_abilities_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterAlternateAbilities InsertOne(
|
||||||
|
CharacterAlternateAbilities character_alternate_abilities_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_alternate_abilities_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(character_alternate_abilities_entry.aa_id));
|
||||||
|
insert_values.push_back(std::to_string(character_alternate_abilities_entry.aa_value));
|
||||||
|
insert_values.push_back(std::to_string(character_alternate_abilities_entry.charges));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_alternate_abilities_entry.id = results.LastInsertedID();
|
||||||
|
return character_alternate_abilities_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_alternate_abilities_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_alternate_abilities_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterAlternateAbilities> character_alternate_abilities_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_alternate_abilities_entry: character_alternate_abilities_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_alternate_abilities_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(character_alternate_abilities_entry.aa_id));
|
||||||
|
insert_values.push_back(std::to_string(character_alternate_abilities_entry.aa_value));
|
||||||
|
insert_values.push_back(std::to_string(character_alternate_abilities_entry.charges));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterAlternateAbilities> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterAlternateAbilities> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterAlternateAbilities entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.aa_id = atoi(row[1]);
|
||||||
|
entry.aa_value = atoi(row[2]);
|
||||||
|
entry.charges = atoi(row[3]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterAlternateAbilities> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterAlternateAbilities> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterAlternateAbilities entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.aa_id = atoi(row[1]);
|
||||||
|
entry.aa_value = atoi(row[2]);
|
||||||
|
entry.charges = atoi(row[3]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_ALTERNATE_ABILITIES_REPOSITORY_H
|
||||||
329
common/repositories/base/base_character_auras_repository.h
Normal file
329
common/repositories/base/base_character_auras_repository.h
Normal file
@ -0,0 +1,329 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_AURAS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_AURAS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterAurasRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterAuras {
|
||||||
|
int id;
|
||||||
|
int slot;
|
||||||
|
int spell_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"slot",
|
||||||
|
"spell_id",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_auras");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterAuras NewEntity()
|
||||||
|
{
|
||||||
|
CharacterAuras entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.slot = 0;
|
||||||
|
entry.spell_id = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterAuras GetCharacterAurasEntry(
|
||||||
|
const std::vector<CharacterAuras> &character_aurass,
|
||||||
|
int character_auras_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_auras : character_aurass) {
|
||||||
|
if (character_auras.id == character_auras_id) {
|
||||||
|
return character_auras;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterAuras FindOne(
|
||||||
|
int character_auras_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_auras_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterAuras entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot = atoi(row[1]);
|
||||||
|
entry.spell_id = atoi(row[2]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_auras_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_auras_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterAuras character_auras_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(character_auras_entry.id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_auras_entry.slot));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_auras_entry.spell_id));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_auras_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterAuras InsertOne(
|
||||||
|
CharacterAuras character_auras_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_auras_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(character_auras_entry.slot));
|
||||||
|
insert_values.push_back(std::to_string(character_auras_entry.spell_id));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_auras_entry.id = results.LastInsertedID();
|
||||||
|
return character_auras_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_auras_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_auras_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterAuras> character_auras_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_auras_entry: character_auras_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_auras_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(character_auras_entry.slot));
|
||||||
|
insert_values.push_back(std::to_string(character_auras_entry.spell_id));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterAuras> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterAuras> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterAuras entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot = atoi(row[1]);
|
||||||
|
entry.spell_id = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterAuras> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterAuras> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterAuras entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot = atoi(row[1]);
|
||||||
|
entry.spell_id = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_AURAS_REPOSITORY_H
|
||||||
356
common/repositories/base/base_character_bandolier_repository.h
Normal file
356
common/repositories/base/base_character_bandolier_repository.h
Normal file
@ -0,0 +1,356 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_BANDOLIER_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_BANDOLIER_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterBandolierRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterBandolier {
|
||||||
|
int id;
|
||||||
|
int bandolier_id;
|
||||||
|
int bandolier_slot;
|
||||||
|
int item_id;
|
||||||
|
int icon;
|
||||||
|
std::string bandolier_name;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"bandolier_id",
|
||||||
|
"bandolier_slot",
|
||||||
|
"item_id",
|
||||||
|
"icon",
|
||||||
|
"bandolier_name",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_bandolier");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterBandolier NewEntity()
|
||||||
|
{
|
||||||
|
CharacterBandolier entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.bandolier_id = 0;
|
||||||
|
entry.bandolier_slot = 0;
|
||||||
|
entry.item_id = 0;
|
||||||
|
entry.icon = 0;
|
||||||
|
entry.bandolier_name = "0";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterBandolier GetCharacterBandolierEntry(
|
||||||
|
const std::vector<CharacterBandolier> &character_bandoliers,
|
||||||
|
int character_bandolier_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_bandolier : character_bandoliers) {
|
||||||
|
if (character_bandolier.id == character_bandolier_id) {
|
||||||
|
return character_bandolier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterBandolier FindOne(
|
||||||
|
int character_bandolier_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_bandolier_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterBandolier entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.bandolier_id = atoi(row[1]);
|
||||||
|
entry.bandolier_slot = atoi(row[2]);
|
||||||
|
entry.item_id = atoi(row[3]);
|
||||||
|
entry.icon = atoi(row[4]);
|
||||||
|
entry.bandolier_name = row[5] ? row[5] : "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_bandolier_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_bandolier_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterBandolier character_bandolier_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(character_bandolier_entry.id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_bandolier_entry.bandolier_id));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_bandolier_entry.bandolier_slot));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(character_bandolier_entry.item_id));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(character_bandolier_entry.icon));
|
||||||
|
update_values.push_back(columns[5] + " = '" + EscapeString(character_bandolier_entry.bandolier_name) + "'");
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_bandolier_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterBandolier InsertOne(
|
||||||
|
CharacterBandolier character_bandolier_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_bandolier_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(character_bandolier_entry.bandolier_id));
|
||||||
|
insert_values.push_back(std::to_string(character_bandolier_entry.bandolier_slot));
|
||||||
|
insert_values.push_back(std::to_string(character_bandolier_entry.item_id));
|
||||||
|
insert_values.push_back(std::to_string(character_bandolier_entry.icon));
|
||||||
|
insert_values.push_back("'" + EscapeString(character_bandolier_entry.bandolier_name) + "'");
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_bandolier_entry.id = results.LastInsertedID();
|
||||||
|
return character_bandolier_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_bandolier_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_bandolier_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterBandolier> character_bandolier_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_bandolier_entry: character_bandolier_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_bandolier_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(character_bandolier_entry.bandolier_id));
|
||||||
|
insert_values.push_back(std::to_string(character_bandolier_entry.bandolier_slot));
|
||||||
|
insert_values.push_back(std::to_string(character_bandolier_entry.item_id));
|
||||||
|
insert_values.push_back(std::to_string(character_bandolier_entry.icon));
|
||||||
|
insert_values.push_back("'" + EscapeString(character_bandolier_entry.bandolier_name) + "'");
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterBandolier> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterBandolier> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterBandolier entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.bandolier_id = atoi(row[1]);
|
||||||
|
entry.bandolier_slot = atoi(row[2]);
|
||||||
|
entry.item_id = atoi(row[3]);
|
||||||
|
entry.icon = atoi(row[4]);
|
||||||
|
entry.bandolier_name = row[5] ? row[5] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterBandolier> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterBandolier> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterBandolier entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.bandolier_id = atoi(row[1]);
|
||||||
|
entry.bandolier_slot = atoi(row[2]);
|
||||||
|
entry.item_id = atoi(row[3]);
|
||||||
|
entry.icon = atoi(row[4]);
|
||||||
|
entry.bandolier_name = row[5] ? row[5] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_BANDOLIER_REPOSITORY_H
|
||||||
371
common/repositories/base/base_character_bind_repository.h
Normal file
371
common/repositories/base/base_character_bind_repository.h
Normal file
@ -0,0 +1,371 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_BIND_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_BIND_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterBindRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterBind {
|
||||||
|
int id;
|
||||||
|
int slot;
|
||||||
|
int zone_id;
|
||||||
|
int instance_id;
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
float heading;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"slot",
|
||||||
|
"zone_id",
|
||||||
|
"instance_id",
|
||||||
|
"x",
|
||||||
|
"y",
|
||||||
|
"z",
|
||||||
|
"heading",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_bind");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterBind NewEntity()
|
||||||
|
{
|
||||||
|
CharacterBind entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.slot = 0;
|
||||||
|
entry.zone_id = 0;
|
||||||
|
entry.instance_id = 0;
|
||||||
|
entry.x = 0;
|
||||||
|
entry.y = 0;
|
||||||
|
entry.z = 0;
|
||||||
|
entry.heading = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterBind GetCharacterBindEntry(
|
||||||
|
const std::vector<CharacterBind> &character_binds,
|
||||||
|
int character_bind_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_bind : character_binds) {
|
||||||
|
if (character_bind.id == character_bind_id) {
|
||||||
|
return character_bind;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterBind FindOne(
|
||||||
|
int character_bind_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_bind_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterBind entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot = atoi(row[1]);
|
||||||
|
entry.zone_id = atoi(row[2]);
|
||||||
|
entry.instance_id = atoi(row[3]);
|
||||||
|
entry.x = static_cast<float>(atof(row[4]));
|
||||||
|
entry.y = static_cast<float>(atof(row[5]));
|
||||||
|
entry.z = static_cast<float>(atof(row[6]));
|
||||||
|
entry.heading = static_cast<float>(atof(row[7]));
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_bind_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_bind_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterBind character_bind_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_bind_entry.slot));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_bind_entry.zone_id));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(character_bind_entry.instance_id));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(character_bind_entry.x));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(character_bind_entry.y));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(character_bind_entry.z));
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(character_bind_entry.heading));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_bind_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterBind InsertOne(
|
||||||
|
CharacterBind character_bind_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_bind_entry.slot));
|
||||||
|
insert_values.push_back(std::to_string(character_bind_entry.zone_id));
|
||||||
|
insert_values.push_back(std::to_string(character_bind_entry.instance_id));
|
||||||
|
insert_values.push_back(std::to_string(character_bind_entry.x));
|
||||||
|
insert_values.push_back(std::to_string(character_bind_entry.y));
|
||||||
|
insert_values.push_back(std::to_string(character_bind_entry.z));
|
||||||
|
insert_values.push_back(std::to_string(character_bind_entry.heading));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_bind_entry.id = results.LastInsertedID();
|
||||||
|
return character_bind_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_bind_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_bind_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterBind> character_bind_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_bind_entry: character_bind_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_bind_entry.slot));
|
||||||
|
insert_values.push_back(std::to_string(character_bind_entry.zone_id));
|
||||||
|
insert_values.push_back(std::to_string(character_bind_entry.instance_id));
|
||||||
|
insert_values.push_back(std::to_string(character_bind_entry.x));
|
||||||
|
insert_values.push_back(std::to_string(character_bind_entry.y));
|
||||||
|
insert_values.push_back(std::to_string(character_bind_entry.z));
|
||||||
|
insert_values.push_back(std::to_string(character_bind_entry.heading));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterBind> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterBind> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterBind entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot = atoi(row[1]);
|
||||||
|
entry.zone_id = atoi(row[2]);
|
||||||
|
entry.instance_id = atoi(row[3]);
|
||||||
|
entry.x = static_cast<float>(atof(row[4]));
|
||||||
|
entry.y = static_cast<float>(atof(row[5]));
|
||||||
|
entry.z = static_cast<float>(atof(row[6]));
|
||||||
|
entry.heading = static_cast<float>(atof(row[7]));
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterBind> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterBind> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterBind entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot = atoi(row[1]);
|
||||||
|
entry.zone_id = atoi(row[2]);
|
||||||
|
entry.instance_id = atoi(row[3]);
|
||||||
|
entry.x = static_cast<float>(atof(row[4]));
|
||||||
|
entry.y = static_cast<float>(atof(row[5]));
|
||||||
|
entry.z = static_cast<float>(atof(row[6]));
|
||||||
|
entry.heading = static_cast<float>(atof(row[7]));
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_BIND_REPOSITORY_H
|
||||||
455
common/repositories/base/base_character_buffs_repository.h
Normal file
455
common/repositories/base/base_character_buffs_repository.h
Normal file
@ -0,0 +1,455 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_BUFFS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_BUFFS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterBuffsRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterBuffs {
|
||||||
|
int character_id;
|
||||||
|
int slot_id;
|
||||||
|
int spell_id;
|
||||||
|
int caster_level;
|
||||||
|
std::string caster_name;
|
||||||
|
int ticsremaining;
|
||||||
|
int counters;
|
||||||
|
int numhits;
|
||||||
|
int melee_rune;
|
||||||
|
int magic_rune;
|
||||||
|
int persistent;
|
||||||
|
int dot_rune;
|
||||||
|
int caston_x;
|
||||||
|
int caston_y;
|
||||||
|
int caston_z;
|
||||||
|
int ExtraDIChance;
|
||||||
|
int instrument_mod;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("character_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"character_id",
|
||||||
|
"slot_id",
|
||||||
|
"spell_id",
|
||||||
|
"caster_level",
|
||||||
|
"caster_name",
|
||||||
|
"ticsremaining",
|
||||||
|
"counters",
|
||||||
|
"numhits",
|
||||||
|
"melee_rune",
|
||||||
|
"magic_rune",
|
||||||
|
"persistent",
|
||||||
|
"dot_rune",
|
||||||
|
"caston_x",
|
||||||
|
"caston_y",
|
||||||
|
"caston_z",
|
||||||
|
"ExtraDIChance",
|
||||||
|
"instrument_mod",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_buffs");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterBuffs NewEntity()
|
||||||
|
{
|
||||||
|
CharacterBuffs entry{};
|
||||||
|
|
||||||
|
entry.character_id = 0;
|
||||||
|
entry.slot_id = 0;
|
||||||
|
entry.spell_id = 0;
|
||||||
|
entry.caster_level = 0;
|
||||||
|
entry.caster_name = "";
|
||||||
|
entry.ticsremaining = 0;
|
||||||
|
entry.counters = 0;
|
||||||
|
entry.numhits = 0;
|
||||||
|
entry.melee_rune = 0;
|
||||||
|
entry.magic_rune = 0;
|
||||||
|
entry.persistent = 0;
|
||||||
|
entry.dot_rune = 0;
|
||||||
|
entry.caston_x = 0;
|
||||||
|
entry.caston_y = 0;
|
||||||
|
entry.caston_z = 0;
|
||||||
|
entry.ExtraDIChance = 0;
|
||||||
|
entry.instrument_mod = 10;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterBuffs GetCharacterBuffsEntry(
|
||||||
|
const std::vector<CharacterBuffs> &character_buffss,
|
||||||
|
int character_buffs_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_buffs : character_buffss) {
|
||||||
|
if (character_buffs.character_id == character_buffs_id) {
|
||||||
|
return character_buffs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterBuffs FindOne(
|
||||||
|
int character_buffs_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_buffs_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterBuffs entry{};
|
||||||
|
|
||||||
|
entry.character_id = atoi(row[0]);
|
||||||
|
entry.slot_id = atoi(row[1]);
|
||||||
|
entry.spell_id = atoi(row[2]);
|
||||||
|
entry.caster_level = atoi(row[3]);
|
||||||
|
entry.caster_name = row[4] ? row[4] : "";
|
||||||
|
entry.ticsremaining = atoi(row[5]);
|
||||||
|
entry.counters = atoi(row[6]);
|
||||||
|
entry.numhits = atoi(row[7]);
|
||||||
|
entry.melee_rune = atoi(row[8]);
|
||||||
|
entry.magic_rune = atoi(row[9]);
|
||||||
|
entry.persistent = atoi(row[10]);
|
||||||
|
entry.dot_rune = atoi(row[11]);
|
||||||
|
entry.caston_x = atoi(row[12]);
|
||||||
|
entry.caston_y = atoi(row[13]);
|
||||||
|
entry.caston_z = atoi(row[14]);
|
||||||
|
entry.ExtraDIChance = atoi(row[15]);
|
||||||
|
entry.instrument_mod = atoi(row[16]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_buffs_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_buffs_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterBuffs character_buffs_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(character_buffs_entry.character_id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_buffs_entry.slot_id));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_buffs_entry.spell_id));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(character_buffs_entry.caster_level));
|
||||||
|
update_values.push_back(columns[4] + " = '" + EscapeString(character_buffs_entry.caster_name) + "'");
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(character_buffs_entry.ticsremaining));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(character_buffs_entry.counters));
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(character_buffs_entry.numhits));
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(character_buffs_entry.melee_rune));
|
||||||
|
update_values.push_back(columns[9] + " = " + std::to_string(character_buffs_entry.magic_rune));
|
||||||
|
update_values.push_back(columns[10] + " = " + std::to_string(character_buffs_entry.persistent));
|
||||||
|
update_values.push_back(columns[11] + " = " + std::to_string(character_buffs_entry.dot_rune));
|
||||||
|
update_values.push_back(columns[12] + " = " + std::to_string(character_buffs_entry.caston_x));
|
||||||
|
update_values.push_back(columns[13] + " = " + std::to_string(character_buffs_entry.caston_y));
|
||||||
|
update_values.push_back(columns[14] + " = " + std::to_string(character_buffs_entry.caston_z));
|
||||||
|
update_values.push_back(columns[15] + " = " + std::to_string(character_buffs_entry.ExtraDIChance));
|
||||||
|
update_values.push_back(columns[16] + " = " + std::to_string(character_buffs_entry.instrument_mod));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_buffs_entry.character_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterBuffs InsertOne(
|
||||||
|
CharacterBuffs character_buffs_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.character_id));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.slot_id));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.spell_id));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.caster_level));
|
||||||
|
insert_values.push_back("'" + EscapeString(character_buffs_entry.caster_name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.ticsremaining));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.counters));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.numhits));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.melee_rune));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.magic_rune));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.persistent));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.dot_rune));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.caston_x));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.caston_y));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.caston_z));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.ExtraDIChance));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.instrument_mod));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_buffs_entry.character_id = results.LastInsertedID();
|
||||||
|
return character_buffs_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_buffs_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_buffs_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterBuffs> character_buffs_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_buffs_entry: character_buffs_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.character_id));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.slot_id));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.spell_id));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.caster_level));
|
||||||
|
insert_values.push_back("'" + EscapeString(character_buffs_entry.caster_name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.ticsremaining));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.counters));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.numhits));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.melee_rune));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.magic_rune));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.persistent));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.dot_rune));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.caston_x));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.caston_y));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.caston_z));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.ExtraDIChance));
|
||||||
|
insert_values.push_back(std::to_string(character_buffs_entry.instrument_mod));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterBuffs> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterBuffs> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterBuffs entry{};
|
||||||
|
|
||||||
|
entry.character_id = atoi(row[0]);
|
||||||
|
entry.slot_id = atoi(row[1]);
|
||||||
|
entry.spell_id = atoi(row[2]);
|
||||||
|
entry.caster_level = atoi(row[3]);
|
||||||
|
entry.caster_name = row[4] ? row[4] : "";
|
||||||
|
entry.ticsremaining = atoi(row[5]);
|
||||||
|
entry.counters = atoi(row[6]);
|
||||||
|
entry.numhits = atoi(row[7]);
|
||||||
|
entry.melee_rune = atoi(row[8]);
|
||||||
|
entry.magic_rune = atoi(row[9]);
|
||||||
|
entry.persistent = atoi(row[10]);
|
||||||
|
entry.dot_rune = atoi(row[11]);
|
||||||
|
entry.caston_x = atoi(row[12]);
|
||||||
|
entry.caston_y = atoi(row[13]);
|
||||||
|
entry.caston_z = atoi(row[14]);
|
||||||
|
entry.ExtraDIChance = atoi(row[15]);
|
||||||
|
entry.instrument_mod = atoi(row[16]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterBuffs> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterBuffs> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterBuffs entry{};
|
||||||
|
|
||||||
|
entry.character_id = atoi(row[0]);
|
||||||
|
entry.slot_id = atoi(row[1]);
|
||||||
|
entry.spell_id = atoi(row[2]);
|
||||||
|
entry.caster_level = atoi(row[3]);
|
||||||
|
entry.caster_name = row[4] ? row[4] : "";
|
||||||
|
entry.ticsremaining = atoi(row[5]);
|
||||||
|
entry.counters = atoi(row[6]);
|
||||||
|
entry.numhits = atoi(row[7]);
|
||||||
|
entry.melee_rune = atoi(row[8]);
|
||||||
|
entry.magic_rune = atoi(row[9]);
|
||||||
|
entry.persistent = atoi(row[10]);
|
||||||
|
entry.dot_rune = atoi(row[11]);
|
||||||
|
entry.caston_x = atoi(row[12]);
|
||||||
|
entry.caston_y = atoi(row[13]);
|
||||||
|
entry.caston_z = atoi(row[14]);
|
||||||
|
entry.ExtraDIChance = atoi(row[15]);
|
||||||
|
entry.instrument_mod = atoi(row[16]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_BUFFS_REPOSITORY_H
|
||||||
@ -0,0 +1,401 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_CORPSE_ITEMS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_CORPSE_ITEMS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterCorpseItemsRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterCorpseItems {
|
||||||
|
int corpse_id;
|
||||||
|
int equip_slot;
|
||||||
|
int item_id;
|
||||||
|
int charges;
|
||||||
|
int aug_1;
|
||||||
|
int aug_2;
|
||||||
|
int aug_3;
|
||||||
|
int aug_4;
|
||||||
|
int aug_5;
|
||||||
|
int aug_6;
|
||||||
|
int attuned;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("corpse_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"corpse_id",
|
||||||
|
"equip_slot",
|
||||||
|
"item_id",
|
||||||
|
"charges",
|
||||||
|
"aug_1",
|
||||||
|
"aug_2",
|
||||||
|
"aug_3",
|
||||||
|
"aug_4",
|
||||||
|
"aug_5",
|
||||||
|
"aug_6",
|
||||||
|
"attuned",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_corpse_items");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterCorpseItems NewEntity()
|
||||||
|
{
|
||||||
|
CharacterCorpseItems entry{};
|
||||||
|
|
||||||
|
entry.corpse_id = 0;
|
||||||
|
entry.equip_slot = 0;
|
||||||
|
entry.item_id = 0;
|
||||||
|
entry.charges = 0;
|
||||||
|
entry.aug_1 = 0;
|
||||||
|
entry.aug_2 = 0;
|
||||||
|
entry.aug_3 = 0;
|
||||||
|
entry.aug_4 = 0;
|
||||||
|
entry.aug_5 = 0;
|
||||||
|
entry.aug_6 = 0;
|
||||||
|
entry.attuned = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterCorpseItems GetCharacterCorpseItemsEntry(
|
||||||
|
const std::vector<CharacterCorpseItems> &character_corpse_itemss,
|
||||||
|
int character_corpse_items_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_corpse_items : character_corpse_itemss) {
|
||||||
|
if (character_corpse_items.corpse_id == character_corpse_items_id) {
|
||||||
|
return character_corpse_items;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterCorpseItems FindOne(
|
||||||
|
int character_corpse_items_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_corpse_items_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterCorpseItems entry{};
|
||||||
|
|
||||||
|
entry.corpse_id = atoi(row[0]);
|
||||||
|
entry.equip_slot = atoi(row[1]);
|
||||||
|
entry.item_id = atoi(row[2]);
|
||||||
|
entry.charges = atoi(row[3]);
|
||||||
|
entry.aug_1 = atoi(row[4]);
|
||||||
|
entry.aug_2 = atoi(row[5]);
|
||||||
|
entry.aug_3 = atoi(row[6]);
|
||||||
|
entry.aug_4 = atoi(row[7]);
|
||||||
|
entry.aug_5 = atoi(row[8]);
|
||||||
|
entry.aug_6 = atoi(row[9]);
|
||||||
|
entry.attuned = atoi(row[10]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_corpse_items_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_corpse_items_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterCorpseItems character_corpse_items_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(character_corpse_items_entry.corpse_id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_corpse_items_entry.equip_slot));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_corpse_items_entry.item_id));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(character_corpse_items_entry.charges));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(character_corpse_items_entry.aug_1));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(character_corpse_items_entry.aug_2));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(character_corpse_items_entry.aug_3));
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(character_corpse_items_entry.aug_4));
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(character_corpse_items_entry.aug_5));
|
||||||
|
update_values.push_back(columns[9] + " = " + std::to_string(character_corpse_items_entry.aug_6));
|
||||||
|
update_values.push_back(columns[10] + " = " + std::to_string(character_corpse_items_entry.attuned));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_corpse_items_entry.corpse_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterCorpseItems InsertOne(
|
||||||
|
CharacterCorpseItems character_corpse_items_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.corpse_id));
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.equip_slot));
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.item_id));
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.charges));
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_1));
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_2));
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_3));
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_4));
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_5));
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_6));
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.attuned));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_corpse_items_entry.corpse_id = results.LastInsertedID();
|
||||||
|
return character_corpse_items_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_corpse_items_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_corpse_items_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterCorpseItems> character_corpse_items_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_corpse_items_entry: character_corpse_items_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.corpse_id));
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.equip_slot));
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.item_id));
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.charges));
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_1));
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_2));
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_3));
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_4));
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_5));
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_6));
|
||||||
|
insert_values.push_back(std::to_string(character_corpse_items_entry.attuned));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterCorpseItems> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterCorpseItems> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterCorpseItems entry{};
|
||||||
|
|
||||||
|
entry.corpse_id = atoi(row[0]);
|
||||||
|
entry.equip_slot = atoi(row[1]);
|
||||||
|
entry.item_id = atoi(row[2]);
|
||||||
|
entry.charges = atoi(row[3]);
|
||||||
|
entry.aug_1 = atoi(row[4]);
|
||||||
|
entry.aug_2 = atoi(row[5]);
|
||||||
|
entry.aug_3 = atoi(row[6]);
|
||||||
|
entry.aug_4 = atoi(row[7]);
|
||||||
|
entry.aug_5 = atoi(row[8]);
|
||||||
|
entry.aug_6 = atoi(row[9]);
|
||||||
|
entry.attuned = atoi(row[10]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterCorpseItems> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterCorpseItems> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterCorpseItems entry{};
|
||||||
|
|
||||||
|
entry.corpse_id = atoi(row[0]);
|
||||||
|
entry.equip_slot = atoi(row[1]);
|
||||||
|
entry.item_id = atoi(row[2]);
|
||||||
|
entry.charges = atoi(row[3]);
|
||||||
|
entry.aug_1 = atoi(row[4]);
|
||||||
|
entry.aug_2 = atoi(row[5]);
|
||||||
|
entry.aug_3 = atoi(row[6]);
|
||||||
|
entry.aug_4 = atoi(row[7]);
|
||||||
|
entry.aug_5 = atoi(row[8]);
|
||||||
|
entry.aug_6 = atoi(row[9]);
|
||||||
|
entry.attuned = atoi(row[10]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_CORPSE_ITEMS_REPOSITORY_H
|
||||||
722
common/repositories/base/base_character_corpses_repository.h
Normal file
722
common/repositories/base/base_character_corpses_repository.h
Normal file
@ -0,0 +1,722 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_CORPSES_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_CORPSES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterCorpsesRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterCorpses {
|
||||||
|
int id;
|
||||||
|
int charid;
|
||||||
|
std::string charname;
|
||||||
|
int zone_id;
|
||||||
|
int instance_id;
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
float heading;
|
||||||
|
std::string time_of_death;
|
||||||
|
int guild_consent_id;
|
||||||
|
int is_rezzed;
|
||||||
|
int is_buried;
|
||||||
|
int was_at_graveyard;
|
||||||
|
int is_locked;
|
||||||
|
int exp;
|
||||||
|
int size;
|
||||||
|
int level;
|
||||||
|
int race;
|
||||||
|
int gender;
|
||||||
|
int class;
|
||||||
|
int deity;
|
||||||
|
int texture;
|
||||||
|
int helm_texture;
|
||||||
|
int copper;
|
||||||
|
int silver;
|
||||||
|
int gold;
|
||||||
|
int platinum;
|
||||||
|
int hair_color;
|
||||||
|
int beard_color;
|
||||||
|
int eye_color_1;
|
||||||
|
int eye_color_2;
|
||||||
|
int hair_style;
|
||||||
|
int face;
|
||||||
|
int beard;
|
||||||
|
int drakkin_heritage;
|
||||||
|
int drakkin_tattoo;
|
||||||
|
int drakkin_details;
|
||||||
|
int wc_1;
|
||||||
|
int wc_2;
|
||||||
|
int wc_3;
|
||||||
|
int wc_4;
|
||||||
|
int wc_5;
|
||||||
|
int wc_6;
|
||||||
|
int wc_7;
|
||||||
|
int wc_8;
|
||||||
|
int wc_9;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"charid",
|
||||||
|
"charname",
|
||||||
|
"zone_id",
|
||||||
|
"instance_id",
|
||||||
|
"x",
|
||||||
|
"y",
|
||||||
|
"z",
|
||||||
|
"heading",
|
||||||
|
"time_of_death",
|
||||||
|
"guild_consent_id",
|
||||||
|
"is_rezzed",
|
||||||
|
"is_buried",
|
||||||
|
"was_at_graveyard",
|
||||||
|
"is_locked",
|
||||||
|
"exp",
|
||||||
|
"size",
|
||||||
|
"level",
|
||||||
|
"race",
|
||||||
|
"gender",
|
||||||
|
"class",
|
||||||
|
"deity",
|
||||||
|
"texture",
|
||||||
|
"helm_texture",
|
||||||
|
"copper",
|
||||||
|
"silver",
|
||||||
|
"gold",
|
||||||
|
"platinum",
|
||||||
|
"hair_color",
|
||||||
|
"beard_color",
|
||||||
|
"eye_color_1",
|
||||||
|
"eye_color_2",
|
||||||
|
"hair_style",
|
||||||
|
"face",
|
||||||
|
"beard",
|
||||||
|
"drakkin_heritage",
|
||||||
|
"drakkin_tattoo",
|
||||||
|
"drakkin_details",
|
||||||
|
"wc_1",
|
||||||
|
"wc_2",
|
||||||
|
"wc_3",
|
||||||
|
"wc_4",
|
||||||
|
"wc_5",
|
||||||
|
"wc_6",
|
||||||
|
"wc_7",
|
||||||
|
"wc_8",
|
||||||
|
"wc_9",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_corpses");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterCorpses NewEntity()
|
||||||
|
{
|
||||||
|
CharacterCorpses entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.charid = 0;
|
||||||
|
entry.charname = "";
|
||||||
|
entry.zone_id = 0;
|
||||||
|
entry.instance_id = 0;
|
||||||
|
entry.x = 0;
|
||||||
|
entry.y = 0;
|
||||||
|
entry.z = 0;
|
||||||
|
entry.heading = 0;
|
||||||
|
entry.time_of_death = "0000-00-00 00:00:00";
|
||||||
|
entry.guild_consent_id = 0;
|
||||||
|
entry.is_rezzed = 0;
|
||||||
|
entry.is_buried = 0;
|
||||||
|
entry.was_at_graveyard = 0;
|
||||||
|
entry.is_locked = 0;
|
||||||
|
entry.exp = 0;
|
||||||
|
entry.size = 0;
|
||||||
|
entry.level = 0;
|
||||||
|
entry.race = 0;
|
||||||
|
entry.gender = 0;
|
||||||
|
entry.class = 0;
|
||||||
|
entry.deity = 0;
|
||||||
|
entry.texture = 0;
|
||||||
|
entry.helm_texture = 0;
|
||||||
|
entry.copper = 0;
|
||||||
|
entry.silver = 0;
|
||||||
|
entry.gold = 0;
|
||||||
|
entry.platinum = 0;
|
||||||
|
entry.hair_color = 0;
|
||||||
|
entry.beard_color = 0;
|
||||||
|
entry.eye_color_1 = 0;
|
||||||
|
entry.eye_color_2 = 0;
|
||||||
|
entry.hair_style = 0;
|
||||||
|
entry.face = 0;
|
||||||
|
entry.beard = 0;
|
||||||
|
entry.drakkin_heritage = 0;
|
||||||
|
entry.drakkin_tattoo = 0;
|
||||||
|
entry.drakkin_details = 0;
|
||||||
|
entry.wc_1 = 0;
|
||||||
|
entry.wc_2 = 0;
|
||||||
|
entry.wc_3 = 0;
|
||||||
|
entry.wc_4 = 0;
|
||||||
|
entry.wc_5 = 0;
|
||||||
|
entry.wc_6 = 0;
|
||||||
|
entry.wc_7 = 0;
|
||||||
|
entry.wc_8 = 0;
|
||||||
|
entry.wc_9 = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterCorpses GetCharacterCorpsesEntry(
|
||||||
|
const std::vector<CharacterCorpses> &character_corpsess,
|
||||||
|
int character_corpses_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_corpses : character_corpsess) {
|
||||||
|
if (character_corpses.id == character_corpses_id) {
|
||||||
|
return character_corpses;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterCorpses FindOne(
|
||||||
|
int character_corpses_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_corpses_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterCorpses entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.charid = atoi(row[1]);
|
||||||
|
entry.charname = row[2] ? row[2] : "";
|
||||||
|
entry.zone_id = atoi(row[3]);
|
||||||
|
entry.instance_id = atoi(row[4]);
|
||||||
|
entry.x = static_cast<float>(atof(row[5]));
|
||||||
|
entry.y = static_cast<float>(atof(row[6]));
|
||||||
|
entry.z = static_cast<float>(atof(row[7]));
|
||||||
|
entry.heading = static_cast<float>(atof(row[8]));
|
||||||
|
entry.time_of_death = row[9] ? row[9] : "";
|
||||||
|
entry.guild_consent_id = atoi(row[10]);
|
||||||
|
entry.is_rezzed = atoi(row[11]);
|
||||||
|
entry.is_buried = atoi(row[12]);
|
||||||
|
entry.was_at_graveyard = atoi(row[13]);
|
||||||
|
entry.is_locked = atoi(row[14]);
|
||||||
|
entry.exp = atoi(row[15]);
|
||||||
|
entry.size = atoi(row[16]);
|
||||||
|
entry.level = atoi(row[17]);
|
||||||
|
entry.race = atoi(row[18]);
|
||||||
|
entry.gender = atoi(row[19]);
|
||||||
|
entry.class = atoi(row[20]);
|
||||||
|
entry.deity = atoi(row[21]);
|
||||||
|
entry.texture = atoi(row[22]);
|
||||||
|
entry.helm_texture = atoi(row[23]);
|
||||||
|
entry.copper = atoi(row[24]);
|
||||||
|
entry.silver = atoi(row[25]);
|
||||||
|
entry.gold = atoi(row[26]);
|
||||||
|
entry.platinum = atoi(row[27]);
|
||||||
|
entry.hair_color = atoi(row[28]);
|
||||||
|
entry.beard_color = atoi(row[29]);
|
||||||
|
entry.eye_color_1 = atoi(row[30]);
|
||||||
|
entry.eye_color_2 = atoi(row[31]);
|
||||||
|
entry.hair_style = atoi(row[32]);
|
||||||
|
entry.face = atoi(row[33]);
|
||||||
|
entry.beard = atoi(row[34]);
|
||||||
|
entry.drakkin_heritage = atoi(row[35]);
|
||||||
|
entry.drakkin_tattoo = atoi(row[36]);
|
||||||
|
entry.drakkin_details = atoi(row[37]);
|
||||||
|
entry.wc_1 = atoi(row[38]);
|
||||||
|
entry.wc_2 = atoi(row[39]);
|
||||||
|
entry.wc_3 = atoi(row[40]);
|
||||||
|
entry.wc_4 = atoi(row[41]);
|
||||||
|
entry.wc_5 = atoi(row[42]);
|
||||||
|
entry.wc_6 = atoi(row[43]);
|
||||||
|
entry.wc_7 = atoi(row[44]);
|
||||||
|
entry.wc_8 = atoi(row[45]);
|
||||||
|
entry.wc_9 = atoi(row[46]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_corpses_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_corpses_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterCorpses character_corpses_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_corpses_entry.charid));
|
||||||
|
update_values.push_back(columns[2] + " = '" + EscapeString(character_corpses_entry.charname) + "'");
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(character_corpses_entry.zone_id));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(character_corpses_entry.instance_id));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(character_corpses_entry.x));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(character_corpses_entry.y));
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(character_corpses_entry.z));
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(character_corpses_entry.heading));
|
||||||
|
update_values.push_back(columns[9] + " = '" + EscapeString(character_corpses_entry.time_of_death) + "'");
|
||||||
|
update_values.push_back(columns[10] + " = " + std::to_string(character_corpses_entry.guild_consent_id));
|
||||||
|
update_values.push_back(columns[11] + " = " + std::to_string(character_corpses_entry.is_rezzed));
|
||||||
|
update_values.push_back(columns[12] + " = " + std::to_string(character_corpses_entry.is_buried));
|
||||||
|
update_values.push_back(columns[13] + " = " + std::to_string(character_corpses_entry.was_at_graveyard));
|
||||||
|
update_values.push_back(columns[14] + " = " + std::to_string(character_corpses_entry.is_locked));
|
||||||
|
update_values.push_back(columns[15] + " = " + std::to_string(character_corpses_entry.exp));
|
||||||
|
update_values.push_back(columns[16] + " = " + std::to_string(character_corpses_entry.size));
|
||||||
|
update_values.push_back(columns[17] + " = " + std::to_string(character_corpses_entry.level));
|
||||||
|
update_values.push_back(columns[18] + " = " + std::to_string(character_corpses_entry.race));
|
||||||
|
update_values.push_back(columns[19] + " = " + std::to_string(character_corpses_entry.gender));
|
||||||
|
update_values.push_back(columns[20] + " = " + std::to_string(character_corpses_entry.class));
|
||||||
|
update_values.push_back(columns[21] + " = " + std::to_string(character_corpses_entry.deity));
|
||||||
|
update_values.push_back(columns[22] + " = " + std::to_string(character_corpses_entry.texture));
|
||||||
|
update_values.push_back(columns[23] + " = " + std::to_string(character_corpses_entry.helm_texture));
|
||||||
|
update_values.push_back(columns[24] + " = " + std::to_string(character_corpses_entry.copper));
|
||||||
|
update_values.push_back(columns[25] + " = " + std::to_string(character_corpses_entry.silver));
|
||||||
|
update_values.push_back(columns[26] + " = " + std::to_string(character_corpses_entry.gold));
|
||||||
|
update_values.push_back(columns[27] + " = " + std::to_string(character_corpses_entry.platinum));
|
||||||
|
update_values.push_back(columns[28] + " = " + std::to_string(character_corpses_entry.hair_color));
|
||||||
|
update_values.push_back(columns[29] + " = " + std::to_string(character_corpses_entry.beard_color));
|
||||||
|
update_values.push_back(columns[30] + " = " + std::to_string(character_corpses_entry.eye_color_1));
|
||||||
|
update_values.push_back(columns[31] + " = " + std::to_string(character_corpses_entry.eye_color_2));
|
||||||
|
update_values.push_back(columns[32] + " = " + std::to_string(character_corpses_entry.hair_style));
|
||||||
|
update_values.push_back(columns[33] + " = " + std::to_string(character_corpses_entry.face));
|
||||||
|
update_values.push_back(columns[34] + " = " + std::to_string(character_corpses_entry.beard));
|
||||||
|
update_values.push_back(columns[35] + " = " + std::to_string(character_corpses_entry.drakkin_heritage));
|
||||||
|
update_values.push_back(columns[36] + " = " + std::to_string(character_corpses_entry.drakkin_tattoo));
|
||||||
|
update_values.push_back(columns[37] + " = " + std::to_string(character_corpses_entry.drakkin_details));
|
||||||
|
update_values.push_back(columns[38] + " = " + std::to_string(character_corpses_entry.wc_1));
|
||||||
|
update_values.push_back(columns[39] + " = " + std::to_string(character_corpses_entry.wc_2));
|
||||||
|
update_values.push_back(columns[40] + " = " + std::to_string(character_corpses_entry.wc_3));
|
||||||
|
update_values.push_back(columns[41] + " = " + std::to_string(character_corpses_entry.wc_4));
|
||||||
|
update_values.push_back(columns[42] + " = " + std::to_string(character_corpses_entry.wc_5));
|
||||||
|
update_values.push_back(columns[43] + " = " + std::to_string(character_corpses_entry.wc_6));
|
||||||
|
update_values.push_back(columns[44] + " = " + std::to_string(character_corpses_entry.wc_7));
|
||||||
|
update_values.push_back(columns[45] + " = " + std::to_string(character_corpses_entry.wc_8));
|
||||||
|
update_values.push_back(columns[46] + " = " + std::to_string(character_corpses_entry.wc_9));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_corpses_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterCorpses InsertOne(
|
||||||
|
CharacterCorpses character_corpses_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.charid));
|
||||||
|
insert_values.push_back("'" + EscapeString(character_corpses_entry.charname) + "'");
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.zone_id));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.instance_id));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.x));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.y));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.z));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.heading));
|
||||||
|
insert_values.push_back("'" + EscapeString(character_corpses_entry.time_of_death) + "'");
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.guild_consent_id));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.is_rezzed));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.is_buried));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.was_at_graveyard));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.is_locked));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.exp));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.size));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.level));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.race));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.gender));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.class));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.deity));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.texture));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.helm_texture));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.copper));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.silver));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.gold));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.platinum));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.hair_color));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.beard_color));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.eye_color_1));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.eye_color_2));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.hair_style));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.face));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.beard));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.drakkin_heritage));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.drakkin_tattoo));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.drakkin_details));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.wc_1));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.wc_2));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.wc_3));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.wc_4));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.wc_5));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.wc_6));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.wc_7));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.wc_8));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.wc_9));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_corpses_entry.id = results.LastInsertedID();
|
||||||
|
return character_corpses_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_corpses_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_corpses_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterCorpses> character_corpses_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_corpses_entry: character_corpses_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.charid));
|
||||||
|
insert_values.push_back("'" + EscapeString(character_corpses_entry.charname) + "'");
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.zone_id));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.instance_id));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.x));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.y));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.z));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.heading));
|
||||||
|
insert_values.push_back("'" + EscapeString(character_corpses_entry.time_of_death) + "'");
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.guild_consent_id));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.is_rezzed));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.is_buried));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.was_at_graveyard));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.is_locked));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.exp));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.size));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.level));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.race));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.gender));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.class));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.deity));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.texture));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.helm_texture));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.copper));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.silver));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.gold));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.platinum));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.hair_color));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.beard_color));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.eye_color_1));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.eye_color_2));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.hair_style));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.face));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.beard));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.drakkin_heritage));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.drakkin_tattoo));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.drakkin_details));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.wc_1));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.wc_2));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.wc_3));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.wc_4));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.wc_5));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.wc_6));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.wc_7));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.wc_8));
|
||||||
|
insert_values.push_back(std::to_string(character_corpses_entry.wc_9));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterCorpses> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterCorpses> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterCorpses entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.charid = atoi(row[1]);
|
||||||
|
entry.charname = row[2] ? row[2] : "";
|
||||||
|
entry.zone_id = atoi(row[3]);
|
||||||
|
entry.instance_id = atoi(row[4]);
|
||||||
|
entry.x = static_cast<float>(atof(row[5]));
|
||||||
|
entry.y = static_cast<float>(atof(row[6]));
|
||||||
|
entry.z = static_cast<float>(atof(row[7]));
|
||||||
|
entry.heading = static_cast<float>(atof(row[8]));
|
||||||
|
entry.time_of_death = row[9] ? row[9] : "";
|
||||||
|
entry.guild_consent_id = atoi(row[10]);
|
||||||
|
entry.is_rezzed = atoi(row[11]);
|
||||||
|
entry.is_buried = atoi(row[12]);
|
||||||
|
entry.was_at_graveyard = atoi(row[13]);
|
||||||
|
entry.is_locked = atoi(row[14]);
|
||||||
|
entry.exp = atoi(row[15]);
|
||||||
|
entry.size = atoi(row[16]);
|
||||||
|
entry.level = atoi(row[17]);
|
||||||
|
entry.race = atoi(row[18]);
|
||||||
|
entry.gender = atoi(row[19]);
|
||||||
|
entry.class = atoi(row[20]);
|
||||||
|
entry.deity = atoi(row[21]);
|
||||||
|
entry.texture = atoi(row[22]);
|
||||||
|
entry.helm_texture = atoi(row[23]);
|
||||||
|
entry.copper = atoi(row[24]);
|
||||||
|
entry.silver = atoi(row[25]);
|
||||||
|
entry.gold = atoi(row[26]);
|
||||||
|
entry.platinum = atoi(row[27]);
|
||||||
|
entry.hair_color = atoi(row[28]);
|
||||||
|
entry.beard_color = atoi(row[29]);
|
||||||
|
entry.eye_color_1 = atoi(row[30]);
|
||||||
|
entry.eye_color_2 = atoi(row[31]);
|
||||||
|
entry.hair_style = atoi(row[32]);
|
||||||
|
entry.face = atoi(row[33]);
|
||||||
|
entry.beard = atoi(row[34]);
|
||||||
|
entry.drakkin_heritage = atoi(row[35]);
|
||||||
|
entry.drakkin_tattoo = atoi(row[36]);
|
||||||
|
entry.drakkin_details = atoi(row[37]);
|
||||||
|
entry.wc_1 = atoi(row[38]);
|
||||||
|
entry.wc_2 = atoi(row[39]);
|
||||||
|
entry.wc_3 = atoi(row[40]);
|
||||||
|
entry.wc_4 = atoi(row[41]);
|
||||||
|
entry.wc_5 = atoi(row[42]);
|
||||||
|
entry.wc_6 = atoi(row[43]);
|
||||||
|
entry.wc_7 = atoi(row[44]);
|
||||||
|
entry.wc_8 = atoi(row[45]);
|
||||||
|
entry.wc_9 = atoi(row[46]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterCorpses> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterCorpses> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterCorpses entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.charid = atoi(row[1]);
|
||||||
|
entry.charname = row[2] ? row[2] : "";
|
||||||
|
entry.zone_id = atoi(row[3]);
|
||||||
|
entry.instance_id = atoi(row[4]);
|
||||||
|
entry.x = static_cast<float>(atof(row[5]));
|
||||||
|
entry.y = static_cast<float>(atof(row[6]));
|
||||||
|
entry.z = static_cast<float>(atof(row[7]));
|
||||||
|
entry.heading = static_cast<float>(atof(row[8]));
|
||||||
|
entry.time_of_death = row[9] ? row[9] : "";
|
||||||
|
entry.guild_consent_id = atoi(row[10]);
|
||||||
|
entry.is_rezzed = atoi(row[11]);
|
||||||
|
entry.is_buried = atoi(row[12]);
|
||||||
|
entry.was_at_graveyard = atoi(row[13]);
|
||||||
|
entry.is_locked = atoi(row[14]);
|
||||||
|
entry.exp = atoi(row[15]);
|
||||||
|
entry.size = atoi(row[16]);
|
||||||
|
entry.level = atoi(row[17]);
|
||||||
|
entry.race = atoi(row[18]);
|
||||||
|
entry.gender = atoi(row[19]);
|
||||||
|
entry.class = atoi(row[20]);
|
||||||
|
entry.deity = atoi(row[21]);
|
||||||
|
entry.texture = atoi(row[22]);
|
||||||
|
entry.helm_texture = atoi(row[23]);
|
||||||
|
entry.copper = atoi(row[24]);
|
||||||
|
entry.silver = atoi(row[25]);
|
||||||
|
entry.gold = atoi(row[26]);
|
||||||
|
entry.platinum = atoi(row[27]);
|
||||||
|
entry.hair_color = atoi(row[28]);
|
||||||
|
entry.beard_color = atoi(row[29]);
|
||||||
|
entry.eye_color_1 = atoi(row[30]);
|
||||||
|
entry.eye_color_2 = atoi(row[31]);
|
||||||
|
entry.hair_style = atoi(row[32]);
|
||||||
|
entry.face = atoi(row[33]);
|
||||||
|
entry.beard = atoi(row[34]);
|
||||||
|
entry.drakkin_heritage = atoi(row[35]);
|
||||||
|
entry.drakkin_tattoo = atoi(row[36]);
|
||||||
|
entry.drakkin_details = atoi(row[37]);
|
||||||
|
entry.wc_1 = atoi(row[38]);
|
||||||
|
entry.wc_2 = atoi(row[39]);
|
||||||
|
entry.wc_3 = atoi(row[40]);
|
||||||
|
entry.wc_4 = atoi(row[41]);
|
||||||
|
entry.wc_5 = atoi(row[42]);
|
||||||
|
entry.wc_6 = atoi(row[43]);
|
||||||
|
entry.wc_7 = atoi(row[44]);
|
||||||
|
entry.wc_8 = atoi(row[45]);
|
||||||
|
entry.wc_9 = atoi(row[46]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_CORPSES_REPOSITORY_H
|
||||||
455
common/repositories/base/base_character_currency_repository.h
Normal file
455
common/repositories/base/base_character_currency_repository.h
Normal file
@ -0,0 +1,455 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_CURRENCY_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_CURRENCY_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterCurrencyRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterCurrency {
|
||||||
|
int id;
|
||||||
|
int platinum;
|
||||||
|
int gold;
|
||||||
|
int silver;
|
||||||
|
int copper;
|
||||||
|
int platinum_bank;
|
||||||
|
int gold_bank;
|
||||||
|
int silver_bank;
|
||||||
|
int copper_bank;
|
||||||
|
int platinum_cursor;
|
||||||
|
int gold_cursor;
|
||||||
|
int silver_cursor;
|
||||||
|
int copper_cursor;
|
||||||
|
int radiant_crystals;
|
||||||
|
int career_radiant_crystals;
|
||||||
|
int ebon_crystals;
|
||||||
|
int career_ebon_crystals;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"platinum",
|
||||||
|
"gold",
|
||||||
|
"silver",
|
||||||
|
"copper",
|
||||||
|
"platinum_bank",
|
||||||
|
"gold_bank",
|
||||||
|
"silver_bank",
|
||||||
|
"copper_bank",
|
||||||
|
"platinum_cursor",
|
||||||
|
"gold_cursor",
|
||||||
|
"silver_cursor",
|
||||||
|
"copper_cursor",
|
||||||
|
"radiant_crystals",
|
||||||
|
"career_radiant_crystals",
|
||||||
|
"ebon_crystals",
|
||||||
|
"career_ebon_crystals",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_currency");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterCurrency NewEntity()
|
||||||
|
{
|
||||||
|
CharacterCurrency entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.platinum = 0;
|
||||||
|
entry.gold = 0;
|
||||||
|
entry.silver = 0;
|
||||||
|
entry.copper = 0;
|
||||||
|
entry.platinum_bank = 0;
|
||||||
|
entry.gold_bank = 0;
|
||||||
|
entry.silver_bank = 0;
|
||||||
|
entry.copper_bank = 0;
|
||||||
|
entry.platinum_cursor = 0;
|
||||||
|
entry.gold_cursor = 0;
|
||||||
|
entry.silver_cursor = 0;
|
||||||
|
entry.copper_cursor = 0;
|
||||||
|
entry.radiant_crystals = 0;
|
||||||
|
entry.career_radiant_crystals = 0;
|
||||||
|
entry.ebon_crystals = 0;
|
||||||
|
entry.career_ebon_crystals = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterCurrency GetCharacterCurrencyEntry(
|
||||||
|
const std::vector<CharacterCurrency> &character_currencys,
|
||||||
|
int character_currency_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_currency : character_currencys) {
|
||||||
|
if (character_currency.id == character_currency_id) {
|
||||||
|
return character_currency;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterCurrency FindOne(
|
||||||
|
int character_currency_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_currency_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterCurrency entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.platinum = atoi(row[1]);
|
||||||
|
entry.gold = atoi(row[2]);
|
||||||
|
entry.silver = atoi(row[3]);
|
||||||
|
entry.copper = atoi(row[4]);
|
||||||
|
entry.platinum_bank = atoi(row[5]);
|
||||||
|
entry.gold_bank = atoi(row[6]);
|
||||||
|
entry.silver_bank = atoi(row[7]);
|
||||||
|
entry.copper_bank = atoi(row[8]);
|
||||||
|
entry.platinum_cursor = atoi(row[9]);
|
||||||
|
entry.gold_cursor = atoi(row[10]);
|
||||||
|
entry.silver_cursor = atoi(row[11]);
|
||||||
|
entry.copper_cursor = atoi(row[12]);
|
||||||
|
entry.radiant_crystals = atoi(row[13]);
|
||||||
|
entry.career_radiant_crystals = atoi(row[14]);
|
||||||
|
entry.ebon_crystals = atoi(row[15]);
|
||||||
|
entry.career_ebon_crystals = atoi(row[16]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_currency_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_currency_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterCurrency character_currency_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(character_currency_entry.id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_currency_entry.platinum));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_currency_entry.gold));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(character_currency_entry.silver));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(character_currency_entry.copper));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(character_currency_entry.platinum_bank));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(character_currency_entry.gold_bank));
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(character_currency_entry.silver_bank));
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(character_currency_entry.copper_bank));
|
||||||
|
update_values.push_back(columns[9] + " = " + std::to_string(character_currency_entry.platinum_cursor));
|
||||||
|
update_values.push_back(columns[10] + " = " + std::to_string(character_currency_entry.gold_cursor));
|
||||||
|
update_values.push_back(columns[11] + " = " + std::to_string(character_currency_entry.silver_cursor));
|
||||||
|
update_values.push_back(columns[12] + " = " + std::to_string(character_currency_entry.copper_cursor));
|
||||||
|
update_values.push_back(columns[13] + " = " + std::to_string(character_currency_entry.radiant_crystals));
|
||||||
|
update_values.push_back(columns[14] + " = " + std::to_string(character_currency_entry.career_radiant_crystals));
|
||||||
|
update_values.push_back(columns[15] + " = " + std::to_string(character_currency_entry.ebon_crystals));
|
||||||
|
update_values.push_back(columns[16] + " = " + std::to_string(character_currency_entry.career_ebon_crystals));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_currency_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterCurrency InsertOne(
|
||||||
|
CharacterCurrency character_currency_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.platinum));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.gold));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.silver));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.copper));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.platinum_bank));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.gold_bank));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.silver_bank));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.copper_bank));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.platinum_cursor));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.gold_cursor));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.silver_cursor));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.copper_cursor));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.radiant_crystals));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.career_radiant_crystals));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.ebon_crystals));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.career_ebon_crystals));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_currency_entry.id = results.LastInsertedID();
|
||||||
|
return character_currency_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_currency_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_currency_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterCurrency> character_currency_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_currency_entry: character_currency_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.platinum));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.gold));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.silver));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.copper));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.platinum_bank));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.gold_bank));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.silver_bank));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.copper_bank));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.platinum_cursor));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.gold_cursor));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.silver_cursor));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.copper_cursor));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.radiant_crystals));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.career_radiant_crystals));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.ebon_crystals));
|
||||||
|
insert_values.push_back(std::to_string(character_currency_entry.career_ebon_crystals));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterCurrency> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterCurrency> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterCurrency entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.platinum = atoi(row[1]);
|
||||||
|
entry.gold = atoi(row[2]);
|
||||||
|
entry.silver = atoi(row[3]);
|
||||||
|
entry.copper = atoi(row[4]);
|
||||||
|
entry.platinum_bank = atoi(row[5]);
|
||||||
|
entry.gold_bank = atoi(row[6]);
|
||||||
|
entry.silver_bank = atoi(row[7]);
|
||||||
|
entry.copper_bank = atoi(row[8]);
|
||||||
|
entry.platinum_cursor = atoi(row[9]);
|
||||||
|
entry.gold_cursor = atoi(row[10]);
|
||||||
|
entry.silver_cursor = atoi(row[11]);
|
||||||
|
entry.copper_cursor = atoi(row[12]);
|
||||||
|
entry.radiant_crystals = atoi(row[13]);
|
||||||
|
entry.career_radiant_crystals = atoi(row[14]);
|
||||||
|
entry.ebon_crystals = atoi(row[15]);
|
||||||
|
entry.career_ebon_crystals = atoi(row[16]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterCurrency> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterCurrency> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterCurrency entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.platinum = atoi(row[1]);
|
||||||
|
entry.gold = atoi(row[2]);
|
||||||
|
entry.silver = atoi(row[3]);
|
||||||
|
entry.copper = atoi(row[4]);
|
||||||
|
entry.platinum_bank = atoi(row[5]);
|
||||||
|
entry.gold_bank = atoi(row[6]);
|
||||||
|
entry.silver_bank = atoi(row[7]);
|
||||||
|
entry.copper_bank = atoi(row[8]);
|
||||||
|
entry.platinum_cursor = atoi(row[9]);
|
||||||
|
entry.gold_cursor = atoi(row[10]);
|
||||||
|
entry.silver_cursor = atoi(row[11]);
|
||||||
|
entry.copper_cursor = atoi(row[12]);
|
||||||
|
entry.radiant_crystals = atoi(row[13]);
|
||||||
|
entry.career_radiant_crystals = atoi(row[14]);
|
||||||
|
entry.ebon_crystals = atoi(row[15]);
|
||||||
|
entry.career_ebon_crystals = atoi(row[16]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_CURRENCY_REPOSITORY_H
|
||||||
1217
common/repositories/base/base_character_data_repository.h
Normal file
1217
common/repositories/base/base_character_data_repository.h
Normal file
File diff suppressed because it is too large
Load Diff
329
common/repositories/base/base_character_disciplines_repository.h
Normal file
329
common/repositories/base/base_character_disciplines_repository.h
Normal file
@ -0,0 +1,329 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_DISCIPLINES_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_DISCIPLINES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterDisciplinesRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterDisciplines {
|
||||||
|
int id;
|
||||||
|
int slot_id;
|
||||||
|
int disc_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"slot_id",
|
||||||
|
"disc_id",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_disciplines");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterDisciplines NewEntity()
|
||||||
|
{
|
||||||
|
CharacterDisciplines entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.slot_id = 0;
|
||||||
|
entry.disc_id = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterDisciplines GetCharacterDisciplinesEntry(
|
||||||
|
const std::vector<CharacterDisciplines> &character_discipliness,
|
||||||
|
int character_disciplines_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_disciplines : character_discipliness) {
|
||||||
|
if (character_disciplines.id == character_disciplines_id) {
|
||||||
|
return character_disciplines;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterDisciplines FindOne(
|
||||||
|
int character_disciplines_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_disciplines_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterDisciplines entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot_id = atoi(row[1]);
|
||||||
|
entry.disc_id = atoi(row[2]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_disciplines_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_disciplines_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterDisciplines character_disciplines_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(character_disciplines_entry.id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_disciplines_entry.slot_id));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_disciplines_entry.disc_id));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_disciplines_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterDisciplines InsertOne(
|
||||||
|
CharacterDisciplines character_disciplines_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_disciplines_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(character_disciplines_entry.slot_id));
|
||||||
|
insert_values.push_back(std::to_string(character_disciplines_entry.disc_id));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_disciplines_entry.id = results.LastInsertedID();
|
||||||
|
return character_disciplines_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_disciplines_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_disciplines_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterDisciplines> character_disciplines_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_disciplines_entry: character_disciplines_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_disciplines_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(character_disciplines_entry.slot_id));
|
||||||
|
insert_values.push_back(std::to_string(character_disciplines_entry.disc_id));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterDisciplines> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterDisciplines> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterDisciplines entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot_id = atoi(row[1]);
|
||||||
|
entry.disc_id = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterDisciplines> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterDisciplines> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterDisciplines entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot_id = atoi(row[1]);
|
||||||
|
entry.disc_id = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_DISCIPLINES_REPOSITORY_H
|
||||||
@ -0,0 +1,320 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_INSPECT_MESSAGES_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_INSPECT_MESSAGES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterInspectMessagesRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterInspectMessages {
|
||||||
|
int id;
|
||||||
|
std::string inspect_message;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"inspect_message",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_inspect_messages");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterInspectMessages NewEntity()
|
||||||
|
{
|
||||||
|
CharacterInspectMessages entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.inspect_message = "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterInspectMessages GetCharacterInspectMessagesEntry(
|
||||||
|
const std::vector<CharacterInspectMessages> &character_inspect_messagess,
|
||||||
|
int character_inspect_messages_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_inspect_messages : character_inspect_messagess) {
|
||||||
|
if (character_inspect_messages.id == character_inspect_messages_id) {
|
||||||
|
return character_inspect_messages;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterInspectMessages FindOne(
|
||||||
|
int character_inspect_messages_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_inspect_messages_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterInspectMessages entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.inspect_message = row[1] ? row[1] : "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_inspect_messages_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_inspect_messages_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterInspectMessages character_inspect_messages_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(character_inspect_messages_entry.id));
|
||||||
|
update_values.push_back(columns[1] + " = '" + EscapeString(character_inspect_messages_entry.inspect_message) + "'");
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_inspect_messages_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterInspectMessages InsertOne(
|
||||||
|
CharacterInspectMessages character_inspect_messages_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_inspect_messages_entry.id));
|
||||||
|
insert_values.push_back("'" + EscapeString(character_inspect_messages_entry.inspect_message) + "'");
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_inspect_messages_entry.id = results.LastInsertedID();
|
||||||
|
return character_inspect_messages_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_inspect_messages_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_inspect_messages_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterInspectMessages> character_inspect_messages_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_inspect_messages_entry: character_inspect_messages_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_inspect_messages_entry.id));
|
||||||
|
insert_values.push_back("'" + EscapeString(character_inspect_messages_entry.inspect_message) + "'");
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterInspectMessages> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterInspectMessages> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterInspectMessages entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.inspect_message = row[1] ? row[1] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterInspectMessages> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterInspectMessages> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterInspectMessages entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.inspect_message = row[1] ? row[1] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_INSPECT_MESSAGES_REPOSITORY_H
|
||||||
329
common/repositories/base/base_character_item_recast_repository.h
Normal file
329
common/repositories/base/base_character_item_recast_repository.h
Normal file
@ -0,0 +1,329 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_ITEM_RECAST_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_ITEM_RECAST_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterItemRecastRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterItemRecast {
|
||||||
|
int id;
|
||||||
|
int recast_type;
|
||||||
|
int timestamp;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"recast_type",
|
||||||
|
"timestamp",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_item_recast");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterItemRecast NewEntity()
|
||||||
|
{
|
||||||
|
CharacterItemRecast entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.recast_type = 0;
|
||||||
|
entry.timestamp = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterItemRecast GetCharacterItemRecastEntry(
|
||||||
|
const std::vector<CharacterItemRecast> &character_item_recasts,
|
||||||
|
int character_item_recast_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_item_recast : character_item_recasts) {
|
||||||
|
if (character_item_recast.id == character_item_recast_id) {
|
||||||
|
return character_item_recast;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterItemRecast FindOne(
|
||||||
|
int character_item_recast_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_item_recast_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterItemRecast entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.recast_type = atoi(row[1]);
|
||||||
|
entry.timestamp = atoi(row[2]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_item_recast_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_item_recast_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterItemRecast character_item_recast_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(character_item_recast_entry.id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_item_recast_entry.recast_type));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_item_recast_entry.timestamp));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_item_recast_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterItemRecast InsertOne(
|
||||||
|
CharacterItemRecast character_item_recast_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_item_recast_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(character_item_recast_entry.recast_type));
|
||||||
|
insert_values.push_back(std::to_string(character_item_recast_entry.timestamp));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_item_recast_entry.id = results.LastInsertedID();
|
||||||
|
return character_item_recast_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_item_recast_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_item_recast_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterItemRecast> character_item_recast_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_item_recast_entry: character_item_recast_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_item_recast_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(character_item_recast_entry.recast_type));
|
||||||
|
insert_values.push_back(std::to_string(character_item_recast_entry.timestamp));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterItemRecast> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterItemRecast> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterItemRecast entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.recast_type = atoi(row[1]);
|
||||||
|
entry.timestamp = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterItemRecast> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterItemRecast> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterItemRecast entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.recast_type = atoi(row[1]);
|
||||||
|
entry.timestamp = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_ITEM_RECAST_REPOSITORY_H
|
||||||
326
common/repositories/base/base_character_languages_repository.h
Normal file
326
common/repositories/base/base_character_languages_repository.h
Normal file
@ -0,0 +1,326 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_LANGUAGES_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_LANGUAGES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterLanguagesRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterLanguages {
|
||||||
|
int id;
|
||||||
|
int lang_id;
|
||||||
|
int value;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"lang_id",
|
||||||
|
"value",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_languages");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterLanguages NewEntity()
|
||||||
|
{
|
||||||
|
CharacterLanguages entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.lang_id = 0;
|
||||||
|
entry.value = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterLanguages GetCharacterLanguagesEntry(
|
||||||
|
const std::vector<CharacterLanguages> &character_languagess,
|
||||||
|
int character_languages_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_languages : character_languagess) {
|
||||||
|
if (character_languages.id == character_languages_id) {
|
||||||
|
return character_languages;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterLanguages FindOne(
|
||||||
|
int character_languages_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_languages_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterLanguages entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.lang_id = atoi(row[1]);
|
||||||
|
entry.value = atoi(row[2]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_languages_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_languages_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterLanguages character_languages_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_languages_entry.lang_id));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_languages_entry.value));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_languages_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterLanguages InsertOne(
|
||||||
|
CharacterLanguages character_languages_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_languages_entry.lang_id));
|
||||||
|
insert_values.push_back(std::to_string(character_languages_entry.value));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_languages_entry.id = results.LastInsertedID();
|
||||||
|
return character_languages_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_languages_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_languages_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterLanguages> character_languages_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_languages_entry: character_languages_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_languages_entry.lang_id));
|
||||||
|
insert_values.push_back(std::to_string(character_languages_entry.value));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterLanguages> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterLanguages> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterLanguages entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.lang_id = atoi(row[1]);
|
||||||
|
entry.value = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterLanguages> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterLanguages> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterLanguages entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.lang_id = atoi(row[1]);
|
||||||
|
entry.value = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_LANGUAGES_REPOSITORY_H
|
||||||
@ -0,0 +1,329 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_LEADERSHIP_ABILITIES_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_LEADERSHIP_ABILITIES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterLeadershipAbilitiesRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterLeadershipAbilities {
|
||||||
|
int id;
|
||||||
|
int slot;
|
||||||
|
int rank;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"slot",
|
||||||
|
"rank",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_leadership_abilities");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterLeadershipAbilities NewEntity()
|
||||||
|
{
|
||||||
|
CharacterLeadershipAbilities entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.slot = 0;
|
||||||
|
entry.rank = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterLeadershipAbilities GetCharacterLeadershipAbilitiesEntry(
|
||||||
|
const std::vector<CharacterLeadershipAbilities> &character_leadership_abilitiess,
|
||||||
|
int character_leadership_abilities_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_leadership_abilities : character_leadership_abilitiess) {
|
||||||
|
if (character_leadership_abilities.id == character_leadership_abilities_id) {
|
||||||
|
return character_leadership_abilities;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterLeadershipAbilities FindOne(
|
||||||
|
int character_leadership_abilities_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_leadership_abilities_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterLeadershipAbilities entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot = atoi(row[1]);
|
||||||
|
entry.rank = atoi(row[2]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_leadership_abilities_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_leadership_abilities_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterLeadershipAbilities character_leadership_abilities_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(character_leadership_abilities_entry.id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_leadership_abilities_entry.slot));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_leadership_abilities_entry.rank));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_leadership_abilities_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterLeadershipAbilities InsertOne(
|
||||||
|
CharacterLeadershipAbilities character_leadership_abilities_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_leadership_abilities_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(character_leadership_abilities_entry.slot));
|
||||||
|
insert_values.push_back(std::to_string(character_leadership_abilities_entry.rank));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_leadership_abilities_entry.id = results.LastInsertedID();
|
||||||
|
return character_leadership_abilities_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_leadership_abilities_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_leadership_abilities_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterLeadershipAbilities> character_leadership_abilities_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_leadership_abilities_entry: character_leadership_abilities_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_leadership_abilities_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(character_leadership_abilities_entry.slot));
|
||||||
|
insert_values.push_back(std::to_string(character_leadership_abilities_entry.rank));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterLeadershipAbilities> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterLeadershipAbilities> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterLeadershipAbilities entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot = atoi(row[1]);
|
||||||
|
entry.rank = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterLeadershipAbilities> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterLeadershipAbilities> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterLeadershipAbilities entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot = atoi(row[1]);
|
||||||
|
entry.rank = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_LEADERSHIP_ABILITIES_REPOSITORY_H
|
||||||
362
common/repositories/base/base_character_material_repository.h
Normal file
362
common/repositories/base/base_character_material_repository.h
Normal file
@ -0,0 +1,362 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_MATERIAL_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_MATERIAL_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterMaterialRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterMaterial {
|
||||||
|
int id;
|
||||||
|
int slot;
|
||||||
|
int blue;
|
||||||
|
int green;
|
||||||
|
int red;
|
||||||
|
int use_tint;
|
||||||
|
int color;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"slot",
|
||||||
|
"blue",
|
||||||
|
"green",
|
||||||
|
"red",
|
||||||
|
"use_tint",
|
||||||
|
"color",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_material");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterMaterial NewEntity()
|
||||||
|
{
|
||||||
|
CharacterMaterial entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.slot = 0;
|
||||||
|
entry.blue = 0;
|
||||||
|
entry.green = 0;
|
||||||
|
entry.red = 0;
|
||||||
|
entry.use_tint = 0;
|
||||||
|
entry.color = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterMaterial GetCharacterMaterialEntry(
|
||||||
|
const std::vector<CharacterMaterial> &character_materials,
|
||||||
|
int character_material_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_material : character_materials) {
|
||||||
|
if (character_material.id == character_material_id) {
|
||||||
|
return character_material;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterMaterial FindOne(
|
||||||
|
int character_material_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_material_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterMaterial entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot = atoi(row[1]);
|
||||||
|
entry.blue = atoi(row[2]);
|
||||||
|
entry.green = atoi(row[3]);
|
||||||
|
entry.red = atoi(row[4]);
|
||||||
|
entry.use_tint = atoi(row[5]);
|
||||||
|
entry.color = atoi(row[6]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_material_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_material_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterMaterial character_material_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_material_entry.slot));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_material_entry.blue));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(character_material_entry.green));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(character_material_entry.red));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(character_material_entry.use_tint));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(character_material_entry.color));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_material_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterMaterial InsertOne(
|
||||||
|
CharacterMaterial character_material_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_material_entry.slot));
|
||||||
|
insert_values.push_back(std::to_string(character_material_entry.blue));
|
||||||
|
insert_values.push_back(std::to_string(character_material_entry.green));
|
||||||
|
insert_values.push_back(std::to_string(character_material_entry.red));
|
||||||
|
insert_values.push_back(std::to_string(character_material_entry.use_tint));
|
||||||
|
insert_values.push_back(std::to_string(character_material_entry.color));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_material_entry.id = results.LastInsertedID();
|
||||||
|
return character_material_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_material_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_material_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterMaterial> character_material_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_material_entry: character_material_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_material_entry.slot));
|
||||||
|
insert_values.push_back(std::to_string(character_material_entry.blue));
|
||||||
|
insert_values.push_back(std::to_string(character_material_entry.green));
|
||||||
|
insert_values.push_back(std::to_string(character_material_entry.red));
|
||||||
|
insert_values.push_back(std::to_string(character_material_entry.use_tint));
|
||||||
|
insert_values.push_back(std::to_string(character_material_entry.color));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterMaterial> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterMaterial> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterMaterial entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot = atoi(row[1]);
|
||||||
|
entry.blue = atoi(row[2]);
|
||||||
|
entry.green = atoi(row[3]);
|
||||||
|
entry.red = atoi(row[4]);
|
||||||
|
entry.use_tint = atoi(row[5]);
|
||||||
|
entry.color = atoi(row[6]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterMaterial> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterMaterial> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterMaterial entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot = atoi(row[1]);
|
||||||
|
entry.blue = atoi(row[2]);
|
||||||
|
entry.green = atoi(row[3]);
|
||||||
|
entry.red = atoi(row[4]);
|
||||||
|
entry.use_tint = atoi(row[5]);
|
||||||
|
entry.color = atoi(row[6]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_MATERIAL_REPOSITORY_H
|
||||||
@ -0,0 +1,329 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_MEMMED_SPELLS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_MEMMED_SPELLS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterMemmedSpellsRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterMemmedSpells {
|
||||||
|
int id;
|
||||||
|
int slot_id;
|
||||||
|
int spell_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"slot_id",
|
||||||
|
"spell_id",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_memmed_spells");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterMemmedSpells NewEntity()
|
||||||
|
{
|
||||||
|
CharacterMemmedSpells entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.slot_id = 0;
|
||||||
|
entry.spell_id = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterMemmedSpells GetCharacterMemmedSpellsEntry(
|
||||||
|
const std::vector<CharacterMemmedSpells> &character_memmed_spellss,
|
||||||
|
int character_memmed_spells_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_memmed_spells : character_memmed_spellss) {
|
||||||
|
if (character_memmed_spells.id == character_memmed_spells_id) {
|
||||||
|
return character_memmed_spells;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterMemmedSpells FindOne(
|
||||||
|
int character_memmed_spells_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_memmed_spells_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterMemmedSpells entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot_id = atoi(row[1]);
|
||||||
|
entry.spell_id = atoi(row[2]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_memmed_spells_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_memmed_spells_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterMemmedSpells character_memmed_spells_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(character_memmed_spells_entry.id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_memmed_spells_entry.slot_id));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_memmed_spells_entry.spell_id));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_memmed_spells_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterMemmedSpells InsertOne(
|
||||||
|
CharacterMemmedSpells character_memmed_spells_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_memmed_spells_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(character_memmed_spells_entry.slot_id));
|
||||||
|
insert_values.push_back(std::to_string(character_memmed_spells_entry.spell_id));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_memmed_spells_entry.id = results.LastInsertedID();
|
||||||
|
return character_memmed_spells_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_memmed_spells_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_memmed_spells_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterMemmedSpells> character_memmed_spells_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_memmed_spells_entry: character_memmed_spells_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_memmed_spells_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(character_memmed_spells_entry.slot_id));
|
||||||
|
insert_values.push_back(std::to_string(character_memmed_spells_entry.spell_id));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterMemmedSpells> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterMemmedSpells> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterMemmedSpells entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot_id = atoi(row[1]);
|
||||||
|
entry.spell_id = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterMemmedSpells> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterMemmedSpells> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterMemmedSpells entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot_id = atoi(row[1]);
|
||||||
|
entry.spell_id = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_MEMMED_SPELLS_REPOSITORY_H
|
||||||
401
common/repositories/base/base_character_pet_buffs_repository.h
Normal file
401
common/repositories/base/base_character_pet_buffs_repository.h
Normal file
@ -0,0 +1,401 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_PET_BUFFS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_PET_BUFFS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterPetBuffsRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterPetBuffs {
|
||||||
|
int char_id;
|
||||||
|
int pet;
|
||||||
|
int slot;
|
||||||
|
int spell_id;
|
||||||
|
int caster_level;
|
||||||
|
std::string castername;
|
||||||
|
int ticsremaining;
|
||||||
|
int counters;
|
||||||
|
int numhits;
|
||||||
|
int rune;
|
||||||
|
int instrument_mod;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("char_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"char_id",
|
||||||
|
"pet",
|
||||||
|
"slot",
|
||||||
|
"spell_id",
|
||||||
|
"caster_level",
|
||||||
|
"castername",
|
||||||
|
"ticsremaining",
|
||||||
|
"counters",
|
||||||
|
"numhits",
|
||||||
|
"rune",
|
||||||
|
"instrument_mod",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_pet_buffs");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterPetBuffs NewEntity()
|
||||||
|
{
|
||||||
|
CharacterPetBuffs entry{};
|
||||||
|
|
||||||
|
entry.char_id = 0;
|
||||||
|
entry.pet = 0;
|
||||||
|
entry.slot = 0;
|
||||||
|
entry.spell_id = 0;
|
||||||
|
entry.caster_level = 0;
|
||||||
|
entry.castername = "";
|
||||||
|
entry.ticsremaining = 0;
|
||||||
|
entry.counters = 0;
|
||||||
|
entry.numhits = 0;
|
||||||
|
entry.rune = 0;
|
||||||
|
entry.instrument_mod = 10;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterPetBuffs GetCharacterPetBuffsEntry(
|
||||||
|
const std::vector<CharacterPetBuffs> &character_pet_buffss,
|
||||||
|
int character_pet_buffs_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_pet_buffs : character_pet_buffss) {
|
||||||
|
if (character_pet_buffs.char_id == character_pet_buffs_id) {
|
||||||
|
return character_pet_buffs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterPetBuffs FindOne(
|
||||||
|
int character_pet_buffs_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_pet_buffs_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterPetBuffs entry{};
|
||||||
|
|
||||||
|
entry.char_id = atoi(row[0]);
|
||||||
|
entry.pet = atoi(row[1]);
|
||||||
|
entry.slot = atoi(row[2]);
|
||||||
|
entry.spell_id = atoi(row[3]);
|
||||||
|
entry.caster_level = atoi(row[4]);
|
||||||
|
entry.castername = row[5] ? row[5] : "";
|
||||||
|
entry.ticsremaining = atoi(row[6]);
|
||||||
|
entry.counters = atoi(row[7]);
|
||||||
|
entry.numhits = atoi(row[8]);
|
||||||
|
entry.rune = atoi(row[9]);
|
||||||
|
entry.instrument_mod = atoi(row[10]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_pet_buffs_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_pet_buffs_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterPetBuffs character_pet_buffs_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(character_pet_buffs_entry.char_id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_pet_buffs_entry.pet));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_pet_buffs_entry.slot));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(character_pet_buffs_entry.spell_id));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(character_pet_buffs_entry.caster_level));
|
||||||
|
update_values.push_back(columns[5] + " = '" + EscapeString(character_pet_buffs_entry.castername) + "'");
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(character_pet_buffs_entry.ticsremaining));
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(character_pet_buffs_entry.counters));
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(character_pet_buffs_entry.numhits));
|
||||||
|
update_values.push_back(columns[9] + " = " + std::to_string(character_pet_buffs_entry.rune));
|
||||||
|
update_values.push_back(columns[10] + " = " + std::to_string(character_pet_buffs_entry.instrument_mod));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_pet_buffs_entry.char_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterPetBuffs InsertOne(
|
||||||
|
CharacterPetBuffs character_pet_buffs_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_pet_buffs_entry.char_id));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_buffs_entry.pet));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_buffs_entry.slot));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_buffs_entry.spell_id));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_buffs_entry.caster_level));
|
||||||
|
insert_values.push_back("'" + EscapeString(character_pet_buffs_entry.castername) + "'");
|
||||||
|
insert_values.push_back(std::to_string(character_pet_buffs_entry.ticsremaining));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_buffs_entry.counters));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_buffs_entry.numhits));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_buffs_entry.rune));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_buffs_entry.instrument_mod));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_pet_buffs_entry.char_id = results.LastInsertedID();
|
||||||
|
return character_pet_buffs_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_pet_buffs_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_pet_buffs_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterPetBuffs> character_pet_buffs_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_pet_buffs_entry: character_pet_buffs_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_pet_buffs_entry.char_id));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_buffs_entry.pet));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_buffs_entry.slot));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_buffs_entry.spell_id));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_buffs_entry.caster_level));
|
||||||
|
insert_values.push_back("'" + EscapeString(character_pet_buffs_entry.castername) + "'");
|
||||||
|
insert_values.push_back(std::to_string(character_pet_buffs_entry.ticsremaining));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_buffs_entry.counters));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_buffs_entry.numhits));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_buffs_entry.rune));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_buffs_entry.instrument_mod));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterPetBuffs> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterPetBuffs> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterPetBuffs entry{};
|
||||||
|
|
||||||
|
entry.char_id = atoi(row[0]);
|
||||||
|
entry.pet = atoi(row[1]);
|
||||||
|
entry.slot = atoi(row[2]);
|
||||||
|
entry.spell_id = atoi(row[3]);
|
||||||
|
entry.caster_level = atoi(row[4]);
|
||||||
|
entry.castername = row[5] ? row[5] : "";
|
||||||
|
entry.ticsremaining = atoi(row[6]);
|
||||||
|
entry.counters = atoi(row[7]);
|
||||||
|
entry.numhits = atoi(row[8]);
|
||||||
|
entry.rune = atoi(row[9]);
|
||||||
|
entry.instrument_mod = atoi(row[10]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterPetBuffs> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterPetBuffs> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterPetBuffs entry{};
|
||||||
|
|
||||||
|
entry.char_id = atoi(row[0]);
|
||||||
|
entry.pet = atoi(row[1]);
|
||||||
|
entry.slot = atoi(row[2]);
|
||||||
|
entry.spell_id = atoi(row[3]);
|
||||||
|
entry.caster_level = atoi(row[4]);
|
||||||
|
entry.castername = row[5] ? row[5] : "";
|
||||||
|
entry.ticsremaining = atoi(row[6]);
|
||||||
|
entry.counters = atoi(row[7]);
|
||||||
|
entry.numhits = atoi(row[8]);
|
||||||
|
entry.rune = atoi(row[9]);
|
||||||
|
entry.instrument_mod = atoi(row[10]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_PET_BUFFS_REPOSITORY_H
|
||||||
374
common/repositories/base/base_character_pet_info_repository.h
Normal file
374
common/repositories/base/base_character_pet_info_repository.h
Normal file
@ -0,0 +1,374 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_PET_INFO_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_PET_INFO_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterPetInfoRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterPetInfo {
|
||||||
|
int char_id;
|
||||||
|
int pet;
|
||||||
|
std::string petname;
|
||||||
|
int petpower;
|
||||||
|
int spell_id;
|
||||||
|
int hp;
|
||||||
|
int mana;
|
||||||
|
float size;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("char_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"char_id",
|
||||||
|
"pet",
|
||||||
|
"petname",
|
||||||
|
"petpower",
|
||||||
|
"spell_id",
|
||||||
|
"hp",
|
||||||
|
"mana",
|
||||||
|
"size",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_pet_info");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterPetInfo NewEntity()
|
||||||
|
{
|
||||||
|
CharacterPetInfo entry{};
|
||||||
|
|
||||||
|
entry.char_id = 0;
|
||||||
|
entry.pet = 0;
|
||||||
|
entry.petname = "";
|
||||||
|
entry.petpower = 0;
|
||||||
|
entry.spell_id = 0;
|
||||||
|
entry.hp = 0;
|
||||||
|
entry.mana = 0;
|
||||||
|
entry.size = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterPetInfo GetCharacterPetInfoEntry(
|
||||||
|
const std::vector<CharacterPetInfo> &character_pet_infos,
|
||||||
|
int character_pet_info_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_pet_info : character_pet_infos) {
|
||||||
|
if (character_pet_info.char_id == character_pet_info_id) {
|
||||||
|
return character_pet_info;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterPetInfo FindOne(
|
||||||
|
int character_pet_info_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_pet_info_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterPetInfo entry{};
|
||||||
|
|
||||||
|
entry.char_id = atoi(row[0]);
|
||||||
|
entry.pet = atoi(row[1]);
|
||||||
|
entry.petname = row[2] ? row[2] : "";
|
||||||
|
entry.petpower = atoi(row[3]);
|
||||||
|
entry.spell_id = atoi(row[4]);
|
||||||
|
entry.hp = atoi(row[5]);
|
||||||
|
entry.mana = atoi(row[6]);
|
||||||
|
entry.size = static_cast<float>(atof(row[7]));
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_pet_info_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_pet_info_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterPetInfo character_pet_info_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(character_pet_info_entry.char_id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_pet_info_entry.pet));
|
||||||
|
update_values.push_back(columns[2] + " = '" + EscapeString(character_pet_info_entry.petname) + "'");
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(character_pet_info_entry.petpower));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(character_pet_info_entry.spell_id));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(character_pet_info_entry.hp));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(character_pet_info_entry.mana));
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(character_pet_info_entry.size));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_pet_info_entry.char_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterPetInfo InsertOne(
|
||||||
|
CharacterPetInfo character_pet_info_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_pet_info_entry.char_id));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_info_entry.pet));
|
||||||
|
insert_values.push_back("'" + EscapeString(character_pet_info_entry.petname) + "'");
|
||||||
|
insert_values.push_back(std::to_string(character_pet_info_entry.petpower));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_info_entry.spell_id));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_info_entry.hp));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_info_entry.mana));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_info_entry.size));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_pet_info_entry.char_id = results.LastInsertedID();
|
||||||
|
return character_pet_info_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_pet_info_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_pet_info_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterPetInfo> character_pet_info_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_pet_info_entry: character_pet_info_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_pet_info_entry.char_id));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_info_entry.pet));
|
||||||
|
insert_values.push_back("'" + EscapeString(character_pet_info_entry.petname) + "'");
|
||||||
|
insert_values.push_back(std::to_string(character_pet_info_entry.petpower));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_info_entry.spell_id));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_info_entry.hp));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_info_entry.mana));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_info_entry.size));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterPetInfo> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterPetInfo> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterPetInfo entry{};
|
||||||
|
|
||||||
|
entry.char_id = atoi(row[0]);
|
||||||
|
entry.pet = atoi(row[1]);
|
||||||
|
entry.petname = row[2] ? row[2] : "";
|
||||||
|
entry.petpower = atoi(row[3]);
|
||||||
|
entry.spell_id = atoi(row[4]);
|
||||||
|
entry.hp = atoi(row[5]);
|
||||||
|
entry.mana = atoi(row[6]);
|
||||||
|
entry.size = static_cast<float>(atof(row[7]));
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterPetInfo> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterPetInfo> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterPetInfo entry{};
|
||||||
|
|
||||||
|
entry.char_id = atoi(row[0]);
|
||||||
|
entry.pet = atoi(row[1]);
|
||||||
|
entry.petname = row[2] ? row[2] : "";
|
||||||
|
entry.petpower = atoi(row[3]);
|
||||||
|
entry.spell_id = atoi(row[4]);
|
||||||
|
entry.hp = atoi(row[5]);
|
||||||
|
entry.mana = atoi(row[6]);
|
||||||
|
entry.size = static_cast<float>(atof(row[7]));
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_PET_INFO_REPOSITORY_H
|
||||||
@ -0,0 +1,338 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_PET_INVENTORY_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_PET_INVENTORY_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterPetInventoryRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterPetInventory {
|
||||||
|
int char_id;
|
||||||
|
int pet;
|
||||||
|
int slot;
|
||||||
|
int item_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("char_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"char_id",
|
||||||
|
"pet",
|
||||||
|
"slot",
|
||||||
|
"item_id",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_pet_inventory");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterPetInventory NewEntity()
|
||||||
|
{
|
||||||
|
CharacterPetInventory entry{};
|
||||||
|
|
||||||
|
entry.char_id = 0;
|
||||||
|
entry.pet = 0;
|
||||||
|
entry.slot = 0;
|
||||||
|
entry.item_id = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterPetInventory GetCharacterPetInventoryEntry(
|
||||||
|
const std::vector<CharacterPetInventory> &character_pet_inventorys,
|
||||||
|
int character_pet_inventory_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_pet_inventory : character_pet_inventorys) {
|
||||||
|
if (character_pet_inventory.char_id == character_pet_inventory_id) {
|
||||||
|
return character_pet_inventory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterPetInventory FindOne(
|
||||||
|
int character_pet_inventory_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_pet_inventory_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterPetInventory entry{};
|
||||||
|
|
||||||
|
entry.char_id = atoi(row[0]);
|
||||||
|
entry.pet = atoi(row[1]);
|
||||||
|
entry.slot = atoi(row[2]);
|
||||||
|
entry.item_id = atoi(row[3]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_pet_inventory_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_pet_inventory_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterPetInventory character_pet_inventory_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(character_pet_inventory_entry.char_id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_pet_inventory_entry.pet));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_pet_inventory_entry.slot));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(character_pet_inventory_entry.item_id));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_pet_inventory_entry.char_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterPetInventory InsertOne(
|
||||||
|
CharacterPetInventory character_pet_inventory_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_pet_inventory_entry.char_id));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_inventory_entry.pet));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_inventory_entry.slot));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_inventory_entry.item_id));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_pet_inventory_entry.char_id = results.LastInsertedID();
|
||||||
|
return character_pet_inventory_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_pet_inventory_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_pet_inventory_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterPetInventory> character_pet_inventory_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_pet_inventory_entry: character_pet_inventory_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_pet_inventory_entry.char_id));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_inventory_entry.pet));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_inventory_entry.slot));
|
||||||
|
insert_values.push_back(std::to_string(character_pet_inventory_entry.item_id));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterPetInventory> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterPetInventory> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterPetInventory entry{};
|
||||||
|
|
||||||
|
entry.char_id = atoi(row[0]);
|
||||||
|
entry.pet = atoi(row[1]);
|
||||||
|
entry.slot = atoi(row[2]);
|
||||||
|
entry.item_id = atoi(row[3]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterPetInventory> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterPetInventory> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterPetInventory entry{};
|
||||||
|
|
||||||
|
entry.char_id = atoi(row[0]);
|
||||||
|
entry.pet = atoi(row[1]);
|
||||||
|
entry.slot = atoi(row[2]);
|
||||||
|
entry.item_id = atoi(row[3]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_PET_INVENTORY_REPOSITORY_H
|
||||||
338
common/repositories/base/base_character_potionbelt_repository.h
Normal file
338
common/repositories/base/base_character_potionbelt_repository.h
Normal file
@ -0,0 +1,338 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_POTIONBELT_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_POTIONBELT_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterPotionbeltRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterPotionbelt {
|
||||||
|
int id;
|
||||||
|
int potion_id;
|
||||||
|
int item_id;
|
||||||
|
int icon;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"potion_id",
|
||||||
|
"item_id",
|
||||||
|
"icon",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_potionbelt");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterPotionbelt NewEntity()
|
||||||
|
{
|
||||||
|
CharacterPotionbelt entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.potion_id = 0;
|
||||||
|
entry.item_id = 0;
|
||||||
|
entry.icon = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterPotionbelt GetCharacterPotionbeltEntry(
|
||||||
|
const std::vector<CharacterPotionbelt> &character_potionbelts,
|
||||||
|
int character_potionbelt_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_potionbelt : character_potionbelts) {
|
||||||
|
if (character_potionbelt.id == character_potionbelt_id) {
|
||||||
|
return character_potionbelt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterPotionbelt FindOne(
|
||||||
|
int character_potionbelt_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_potionbelt_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterPotionbelt entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.potion_id = atoi(row[1]);
|
||||||
|
entry.item_id = atoi(row[2]);
|
||||||
|
entry.icon = atoi(row[3]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_potionbelt_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_potionbelt_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterPotionbelt character_potionbelt_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(character_potionbelt_entry.id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_potionbelt_entry.potion_id));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_potionbelt_entry.item_id));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(character_potionbelt_entry.icon));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_potionbelt_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterPotionbelt InsertOne(
|
||||||
|
CharacterPotionbelt character_potionbelt_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_potionbelt_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(character_potionbelt_entry.potion_id));
|
||||||
|
insert_values.push_back(std::to_string(character_potionbelt_entry.item_id));
|
||||||
|
insert_values.push_back(std::to_string(character_potionbelt_entry.icon));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_potionbelt_entry.id = results.LastInsertedID();
|
||||||
|
return character_potionbelt_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_potionbelt_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_potionbelt_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterPotionbelt> character_potionbelt_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_potionbelt_entry: character_potionbelt_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_potionbelt_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(character_potionbelt_entry.potion_id));
|
||||||
|
insert_values.push_back(std::to_string(character_potionbelt_entry.item_id));
|
||||||
|
insert_values.push_back(std::to_string(character_potionbelt_entry.icon));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterPotionbelt> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterPotionbelt> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterPotionbelt entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.potion_id = atoi(row[1]);
|
||||||
|
entry.item_id = atoi(row[2]);
|
||||||
|
entry.icon = atoi(row[3]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterPotionbelt> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterPotionbelt> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterPotionbelt entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.potion_id = atoi(row[1]);
|
||||||
|
entry.item_id = atoi(row[2]);
|
||||||
|
entry.icon = atoi(row[3]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_POTIONBELT_REPOSITORY_H
|
||||||
326
common/repositories/base/base_character_skills_repository.h
Normal file
326
common/repositories/base/base_character_skills_repository.h
Normal file
@ -0,0 +1,326 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_SKILLS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_SKILLS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterSkillsRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterSkills {
|
||||||
|
int id;
|
||||||
|
int skill_id;
|
||||||
|
int value;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"skill_id",
|
||||||
|
"value",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_skills");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterSkills NewEntity()
|
||||||
|
{
|
||||||
|
CharacterSkills entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.skill_id = 0;
|
||||||
|
entry.value = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterSkills GetCharacterSkillsEntry(
|
||||||
|
const std::vector<CharacterSkills> &character_skillss,
|
||||||
|
int character_skills_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_skills : character_skillss) {
|
||||||
|
if (character_skills.id == character_skills_id) {
|
||||||
|
return character_skills;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterSkills FindOne(
|
||||||
|
int character_skills_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_skills_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterSkills entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.skill_id = atoi(row[1]);
|
||||||
|
entry.value = atoi(row[2]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_skills_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_skills_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterSkills character_skills_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_skills_entry.skill_id));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_skills_entry.value));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_skills_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterSkills InsertOne(
|
||||||
|
CharacterSkills character_skills_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_skills_entry.skill_id));
|
||||||
|
insert_values.push_back(std::to_string(character_skills_entry.value));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_skills_entry.id = results.LastInsertedID();
|
||||||
|
return character_skills_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_skills_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_skills_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterSkills> character_skills_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_skills_entry: character_skills_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_skills_entry.skill_id));
|
||||||
|
insert_values.push_back(std::to_string(character_skills_entry.value));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterSkills> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterSkills> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterSkills entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.skill_id = atoi(row[1]);
|
||||||
|
entry.value = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterSkills> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterSkills> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterSkills entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.skill_id = atoi(row[1]);
|
||||||
|
entry.value = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_SKILLS_REPOSITORY_H
|
||||||
326
common/repositories/base/base_character_spells_repository.h
Normal file
326
common/repositories/base/base_character_spells_repository.h
Normal file
@ -0,0 +1,326 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_SPELLS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_SPELLS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterSpellsRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterSpells {
|
||||||
|
int id;
|
||||||
|
int slot_id;
|
||||||
|
int spell_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"slot_id",
|
||||||
|
"spell_id",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_spells");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterSpells NewEntity()
|
||||||
|
{
|
||||||
|
CharacterSpells entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.slot_id = 0;
|
||||||
|
entry.spell_id = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterSpells GetCharacterSpellsEntry(
|
||||||
|
const std::vector<CharacterSpells> &character_spellss,
|
||||||
|
int character_spells_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_spells : character_spellss) {
|
||||||
|
if (character_spells.id == character_spells_id) {
|
||||||
|
return character_spells;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterSpells FindOne(
|
||||||
|
int character_spells_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_spells_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterSpells entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot_id = atoi(row[1]);
|
||||||
|
entry.spell_id = atoi(row[2]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_spells_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_spells_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterSpells character_spells_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_spells_entry.slot_id));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_spells_entry.spell_id));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_spells_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterSpells InsertOne(
|
||||||
|
CharacterSpells character_spells_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_spells_entry.slot_id));
|
||||||
|
insert_values.push_back(std::to_string(character_spells_entry.spell_id));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_spells_entry.id = results.LastInsertedID();
|
||||||
|
return character_spells_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_spells_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_spells_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterSpells> character_spells_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_spells_entry: character_spells_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_spells_entry.slot_id));
|
||||||
|
insert_values.push_back(std::to_string(character_spells_entry.spell_id));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterSpells> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterSpells> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterSpells entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot_id = atoi(row[1]);
|
||||||
|
entry.spell_id = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterSpells> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterSpells> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterSpells entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.slot_id = atoi(row[1]);
|
||||||
|
entry.spell_id = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_SPELLS_REPOSITORY_H
|
||||||
347
common/repositories/base/base_character_tasks_repository.h
Normal file
347
common/repositories/base/base_character_tasks_repository.h
Normal file
@ -0,0 +1,347 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CHARACTER_TASKS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CHARACTER_TASKS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCharacterTasksRepository {
|
||||||
|
public:
|
||||||
|
struct CharacterTasks {
|
||||||
|
int charid;
|
||||||
|
int taskid;
|
||||||
|
int slot;
|
||||||
|
int type;
|
||||||
|
int acceptedtime;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("charid");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"charid",
|
||||||
|
"taskid",
|
||||||
|
"slot",
|
||||||
|
"type",
|
||||||
|
"acceptedtime",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("character_tasks");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterTasks NewEntity()
|
||||||
|
{
|
||||||
|
CharacterTasks entry{};
|
||||||
|
|
||||||
|
entry.charid = 0;
|
||||||
|
entry.taskid = 0;
|
||||||
|
entry.slot = 0;
|
||||||
|
entry.type = 0;
|
||||||
|
entry.acceptedtime = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterTasks GetCharacterTasksEntry(
|
||||||
|
const std::vector<CharacterTasks> &character_taskss,
|
||||||
|
int character_tasks_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &character_tasks : character_taskss) {
|
||||||
|
if (character_tasks.charid == character_tasks_id) {
|
||||||
|
return character_tasks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterTasks FindOne(
|
||||||
|
int character_tasks_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
character_tasks_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CharacterTasks entry{};
|
||||||
|
|
||||||
|
entry.charid = atoi(row[0]);
|
||||||
|
entry.taskid = atoi(row[1]);
|
||||||
|
entry.slot = atoi(row[2]);
|
||||||
|
entry.type = atoi(row[3]);
|
||||||
|
entry.acceptedtime = atoi(row[4]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int character_tasks_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_tasks_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CharacterTasks character_tasks_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(character_tasks_entry.charid));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(character_tasks_entry.taskid));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(character_tasks_entry.slot));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(character_tasks_entry.type));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(character_tasks_entry.acceptedtime));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
character_tasks_entry.charid
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CharacterTasks InsertOne(
|
||||||
|
CharacterTasks character_tasks_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_tasks_entry.charid));
|
||||||
|
insert_values.push_back(std::to_string(character_tasks_entry.taskid));
|
||||||
|
insert_values.push_back(std::to_string(character_tasks_entry.slot));
|
||||||
|
insert_values.push_back(std::to_string(character_tasks_entry.type));
|
||||||
|
insert_values.push_back(std::to_string(character_tasks_entry.acceptedtime));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
character_tasks_entry.charid = results.LastInsertedID();
|
||||||
|
return character_tasks_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
character_tasks_entry = NewEntity();
|
||||||
|
|
||||||
|
return character_tasks_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CharacterTasks> character_tasks_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &character_tasks_entry: character_tasks_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(character_tasks_entry.charid));
|
||||||
|
insert_values.push_back(std::to_string(character_tasks_entry.taskid));
|
||||||
|
insert_values.push_back(std::to_string(character_tasks_entry.slot));
|
||||||
|
insert_values.push_back(std::to_string(character_tasks_entry.type));
|
||||||
|
insert_values.push_back(std::to_string(character_tasks_entry.acceptedtime));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterTasks> All()
|
||||||
|
{
|
||||||
|
std::vector<CharacterTasks> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterTasks entry{};
|
||||||
|
|
||||||
|
entry.charid = atoi(row[0]);
|
||||||
|
entry.taskid = atoi(row[1]);
|
||||||
|
entry.slot = atoi(row[2]);
|
||||||
|
entry.type = atoi(row[3]);
|
||||||
|
entry.acceptedtime = atoi(row[4]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CharacterTasks> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CharacterTasks> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CharacterTasks entry{};
|
||||||
|
|
||||||
|
entry.charid = atoi(row[0]);
|
||||||
|
entry.taskid = atoi(row[1]);
|
||||||
|
entry.slot = atoi(row[2]);
|
||||||
|
entry.type = atoi(row[3]);
|
||||||
|
entry.acceptedtime = atoi(row[4]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CHARACTER_TASKS_REPOSITORY_H
|
||||||
338
common/repositories/base/base_completed_tasks_repository.h
Normal file
338
common/repositories/base/base_completed_tasks_repository.h
Normal file
@ -0,0 +1,338 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_COMPLETED_TASKS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_COMPLETED_TASKS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseCompletedTasksRepository {
|
||||||
|
public:
|
||||||
|
struct CompletedTasks {
|
||||||
|
int charid;
|
||||||
|
int completedtime;
|
||||||
|
int taskid;
|
||||||
|
int activityid;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("charid");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"charid",
|
||||||
|
"completedtime",
|
||||||
|
"taskid",
|
||||||
|
"activityid",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("completed_tasks");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CompletedTasks NewEntity()
|
||||||
|
{
|
||||||
|
CompletedTasks entry{};
|
||||||
|
|
||||||
|
entry.charid = 0;
|
||||||
|
entry.completedtime = 0;
|
||||||
|
entry.taskid = 0;
|
||||||
|
entry.activityid = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CompletedTasks GetCompletedTasksEntry(
|
||||||
|
const std::vector<CompletedTasks> &completed_taskss,
|
||||||
|
int completed_tasks_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &completed_tasks : completed_taskss) {
|
||||||
|
if (completed_tasks.charid == completed_tasks_id) {
|
||||||
|
return completed_tasks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CompletedTasks FindOne(
|
||||||
|
int completed_tasks_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
completed_tasks_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
CompletedTasks entry{};
|
||||||
|
|
||||||
|
entry.charid = atoi(row[0]);
|
||||||
|
entry.completedtime = atoi(row[1]);
|
||||||
|
entry.taskid = atoi(row[2]);
|
||||||
|
entry.activityid = atoi(row[3]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int completed_tasks_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
completed_tasks_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
CompletedTasks completed_tasks_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(completed_tasks_entry.charid));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(completed_tasks_entry.completedtime));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(completed_tasks_entry.taskid));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(completed_tasks_entry.activityid));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
completed_tasks_entry.charid
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CompletedTasks InsertOne(
|
||||||
|
CompletedTasks completed_tasks_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(completed_tasks_entry.charid));
|
||||||
|
insert_values.push_back(std::to_string(completed_tasks_entry.completedtime));
|
||||||
|
insert_values.push_back(std::to_string(completed_tasks_entry.taskid));
|
||||||
|
insert_values.push_back(std::to_string(completed_tasks_entry.activityid));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
completed_tasks_entry.charid = results.LastInsertedID();
|
||||||
|
return completed_tasks_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
completed_tasks_entry = NewEntity();
|
||||||
|
|
||||||
|
return completed_tasks_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<CompletedTasks> completed_tasks_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &completed_tasks_entry: completed_tasks_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(completed_tasks_entry.charid));
|
||||||
|
insert_values.push_back(std::to_string(completed_tasks_entry.completedtime));
|
||||||
|
insert_values.push_back(std::to_string(completed_tasks_entry.taskid));
|
||||||
|
insert_values.push_back(std::to_string(completed_tasks_entry.activityid));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CompletedTasks> All()
|
||||||
|
{
|
||||||
|
std::vector<CompletedTasks> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CompletedTasks entry{};
|
||||||
|
|
||||||
|
entry.charid = atoi(row[0]);
|
||||||
|
entry.completedtime = atoi(row[1]);
|
||||||
|
entry.taskid = atoi(row[2]);
|
||||||
|
entry.activityid = atoi(row[3]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<CompletedTasks> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<CompletedTasks> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
CompletedTasks entry{};
|
||||||
|
|
||||||
|
entry.charid = atoi(row[0]);
|
||||||
|
entry.completedtime = atoi(row[1]);
|
||||||
|
entry.taskid = atoi(row[2]);
|
||||||
|
entry.activityid = atoi(row[3]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_COMPLETED_TASKS_REPOSITORY_H
|
||||||
335
common/repositories/base/base_content_flags_repository.h
Normal file
335
common/repositories/base/base_content_flags_repository.h
Normal file
@ -0,0 +1,335 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_CONTENT_FLAGS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_CONTENT_FLAGS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseContentFlagsRepository {
|
||||||
|
public:
|
||||||
|
struct ContentFlags {
|
||||||
|
int id;
|
||||||
|
std::string flag_name;
|
||||||
|
int enabled;
|
||||||
|
std::string notes;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"flag_name",
|
||||||
|
"enabled",
|
||||||
|
"notes",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("content_flags");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ContentFlags NewEntity()
|
||||||
|
{
|
||||||
|
ContentFlags entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.flag_name = "";
|
||||||
|
entry.enabled = 0;
|
||||||
|
entry.notes = "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ContentFlags GetContentFlagsEntry(
|
||||||
|
const std::vector<ContentFlags> &content_flagss,
|
||||||
|
int content_flags_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &content_flags : content_flagss) {
|
||||||
|
if (content_flags.id == content_flags_id) {
|
||||||
|
return content_flags;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static ContentFlags FindOne(
|
||||||
|
int content_flags_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
content_flags_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
ContentFlags entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.flag_name = row[1] ? row[1] : "";
|
||||||
|
entry.enabled = atoi(row[2]);
|
||||||
|
entry.notes = row[3] ? row[3] : "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int content_flags_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
content_flags_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
ContentFlags content_flags_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[1] + " = '" + EscapeString(content_flags_entry.flag_name) + "'");
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(content_flags_entry.enabled));
|
||||||
|
update_values.push_back(columns[3] + " = '" + EscapeString(content_flags_entry.notes) + "'");
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
content_flags_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ContentFlags InsertOne(
|
||||||
|
ContentFlags content_flags_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back("'" + EscapeString(content_flags_entry.flag_name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(content_flags_entry.enabled));
|
||||||
|
insert_values.push_back("'" + EscapeString(content_flags_entry.notes) + "'");
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
content_flags_entry.id = results.LastInsertedID();
|
||||||
|
return content_flags_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
content_flags_entry = NewEntity();
|
||||||
|
|
||||||
|
return content_flags_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<ContentFlags> content_flags_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &content_flags_entry: content_flags_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back("'" + EscapeString(content_flags_entry.flag_name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(content_flags_entry.enabled));
|
||||||
|
insert_values.push_back("'" + EscapeString(content_flags_entry.notes) + "'");
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<ContentFlags> All()
|
||||||
|
{
|
||||||
|
std::vector<ContentFlags> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
ContentFlags entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.flag_name = row[1] ? row[1] : "";
|
||||||
|
entry.enabled = atoi(row[2]);
|
||||||
|
entry.notes = row[3] ? row[3] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<ContentFlags> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<ContentFlags> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
ContentFlags entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.flag_name = row[1] ? row[1] : "";
|
||||||
|
entry.enabled = atoi(row[2]);
|
||||||
|
entry.notes = row[3] ? row[3] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_CONTENT_FLAGS_REPOSITORY_H
|
||||||
335
common/repositories/base/base_data_buckets_repository.h
Normal file
335
common/repositories/base/base_data_buckets_repository.h
Normal file
@ -0,0 +1,335 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_DATA_BUCKETS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_DATA_BUCKETS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseDataBucketsRepository {
|
||||||
|
public:
|
||||||
|
struct DataBuckets {
|
||||||
|
int id;
|
||||||
|
std::string key;
|
||||||
|
std::string value;
|
||||||
|
int expires;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"key",
|
||||||
|
"value",
|
||||||
|
"expires",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("data_buckets");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static DataBuckets NewEntity()
|
||||||
|
{
|
||||||
|
DataBuckets entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.key = "";
|
||||||
|
entry.value = "";
|
||||||
|
entry.expires = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static DataBuckets GetDataBucketsEntry(
|
||||||
|
const std::vector<DataBuckets> &data_bucketss,
|
||||||
|
int data_buckets_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &data_buckets : data_bucketss) {
|
||||||
|
if (data_buckets.id == data_buckets_id) {
|
||||||
|
return data_buckets;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static DataBuckets FindOne(
|
||||||
|
int data_buckets_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
data_buckets_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
DataBuckets entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.key = row[1] ? row[1] : "";
|
||||||
|
entry.value = row[2] ? row[2] : "";
|
||||||
|
entry.expires = atoi(row[3]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int data_buckets_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
data_buckets_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
DataBuckets data_buckets_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[1] + " = '" + EscapeString(data_buckets_entry.key) + "'");
|
||||||
|
update_values.push_back(columns[2] + " = '" + EscapeString(data_buckets_entry.value) + "'");
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(data_buckets_entry.expires));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
data_buckets_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static DataBuckets InsertOne(
|
||||||
|
DataBuckets data_buckets_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back("'" + EscapeString(data_buckets_entry.key) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(data_buckets_entry.value) + "'");
|
||||||
|
insert_values.push_back(std::to_string(data_buckets_entry.expires));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
data_buckets_entry.id = results.LastInsertedID();
|
||||||
|
return data_buckets_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
data_buckets_entry = NewEntity();
|
||||||
|
|
||||||
|
return data_buckets_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<DataBuckets> data_buckets_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &data_buckets_entry: data_buckets_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back("'" + EscapeString(data_buckets_entry.key) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(data_buckets_entry.value) + "'");
|
||||||
|
insert_values.push_back(std::to_string(data_buckets_entry.expires));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<DataBuckets> All()
|
||||||
|
{
|
||||||
|
std::vector<DataBuckets> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
DataBuckets entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.key = row[1] ? row[1] : "";
|
||||||
|
entry.value = row[2] ? row[2] : "";
|
||||||
|
entry.expires = atoi(row[3]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<DataBuckets> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<DataBuckets> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
DataBuckets entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.key = row[1] ? row[1] : "";
|
||||||
|
entry.value = row[2] ? row[2] : "";
|
||||||
|
entry.expires = atoi(row[3]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_DATA_BUCKETS_REPOSITORY_H
|
||||||
329
common/repositories/base/base_db_str_repository.h
Normal file
329
common/repositories/base/base_db_str_repository.h
Normal file
@ -0,0 +1,329 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_DB_STR_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_DB_STR_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseDbStrRepository {
|
||||||
|
public:
|
||||||
|
struct DbStr {
|
||||||
|
int id;
|
||||||
|
int type;
|
||||||
|
std::string value;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"type",
|
||||||
|
"value",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("db_str");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static DbStr NewEntity()
|
||||||
|
{
|
||||||
|
DbStr entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.type = 0;
|
||||||
|
entry.value = "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static DbStr GetDbStrEntry(
|
||||||
|
const std::vector<DbStr> &db_strs,
|
||||||
|
int db_str_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &db_str : db_strs) {
|
||||||
|
if (db_str.id == db_str_id) {
|
||||||
|
return db_str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static DbStr FindOne(
|
||||||
|
int db_str_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
db_str_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
DbStr entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.type = atoi(row[1]);
|
||||||
|
entry.value = row[2] ? row[2] : "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int db_str_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
db_str_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
DbStr db_str_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(db_str_entry.id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(db_str_entry.type));
|
||||||
|
update_values.push_back(columns[2] + " = '" + EscapeString(db_str_entry.value) + "'");
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
db_str_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static DbStr InsertOne(
|
||||||
|
DbStr db_str_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(db_str_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(db_str_entry.type));
|
||||||
|
insert_values.push_back("'" + EscapeString(db_str_entry.value) + "'");
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
db_str_entry.id = results.LastInsertedID();
|
||||||
|
return db_str_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
db_str_entry = NewEntity();
|
||||||
|
|
||||||
|
return db_str_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<DbStr> db_str_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &db_str_entry: db_str_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(db_str_entry.id));
|
||||||
|
insert_values.push_back(std::to_string(db_str_entry.type));
|
||||||
|
insert_values.push_back("'" + EscapeString(db_str_entry.value) + "'");
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<DbStr> All()
|
||||||
|
{
|
||||||
|
std::vector<DbStr> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
DbStr entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.type = atoi(row[1]);
|
||||||
|
entry.value = row[2] ? row[2] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<DbStr> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<DbStr> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
DbStr entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.type = atoi(row[1]);
|
||||||
|
entry.value = row[2] ? row[2] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_DB_STR_REPOSITORY_H
|
||||||
338
common/repositories/base/base_discovered_items_repository.h
Normal file
338
common/repositories/base/base_discovered_items_repository.h
Normal file
@ -0,0 +1,338 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_DISCOVERED_ITEMS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_DISCOVERED_ITEMS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseDiscoveredItemsRepository {
|
||||||
|
public:
|
||||||
|
struct DiscoveredItems {
|
||||||
|
int item_id;
|
||||||
|
std::string char_name;
|
||||||
|
int discovered_date;
|
||||||
|
int account_status;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("item_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"item_id",
|
||||||
|
"char_name",
|
||||||
|
"discovered_date",
|
||||||
|
"account_status",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("discovered_items");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static DiscoveredItems NewEntity()
|
||||||
|
{
|
||||||
|
DiscoveredItems entry{};
|
||||||
|
|
||||||
|
entry.item_id = 0;
|
||||||
|
entry.char_name = "";
|
||||||
|
entry.discovered_date = 0;
|
||||||
|
entry.account_status = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static DiscoveredItems GetDiscoveredItemsEntry(
|
||||||
|
const std::vector<DiscoveredItems> &discovered_itemss,
|
||||||
|
int discovered_items_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &discovered_items : discovered_itemss) {
|
||||||
|
if (discovered_items.item_id == discovered_items_id) {
|
||||||
|
return discovered_items;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static DiscoveredItems FindOne(
|
||||||
|
int discovered_items_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
discovered_items_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
DiscoveredItems entry{};
|
||||||
|
|
||||||
|
entry.item_id = atoi(row[0]);
|
||||||
|
entry.char_name = row[1] ? row[1] : "";
|
||||||
|
entry.discovered_date = atoi(row[2]);
|
||||||
|
entry.account_status = atoi(row[3]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int discovered_items_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
discovered_items_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
DiscoveredItems discovered_items_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(discovered_items_entry.item_id));
|
||||||
|
update_values.push_back(columns[1] + " = '" + EscapeString(discovered_items_entry.char_name) + "'");
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(discovered_items_entry.discovered_date));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(discovered_items_entry.account_status));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
discovered_items_entry.item_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static DiscoveredItems InsertOne(
|
||||||
|
DiscoveredItems discovered_items_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(discovered_items_entry.item_id));
|
||||||
|
insert_values.push_back("'" + EscapeString(discovered_items_entry.char_name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(discovered_items_entry.discovered_date));
|
||||||
|
insert_values.push_back(std::to_string(discovered_items_entry.account_status));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
discovered_items_entry.item_id = results.LastInsertedID();
|
||||||
|
return discovered_items_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
discovered_items_entry = NewEntity();
|
||||||
|
|
||||||
|
return discovered_items_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<DiscoveredItems> discovered_items_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &discovered_items_entry: discovered_items_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(discovered_items_entry.item_id));
|
||||||
|
insert_values.push_back("'" + EscapeString(discovered_items_entry.char_name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(discovered_items_entry.discovered_date));
|
||||||
|
insert_values.push_back(std::to_string(discovered_items_entry.account_status));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<DiscoveredItems> All()
|
||||||
|
{
|
||||||
|
std::vector<DiscoveredItems> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
DiscoveredItems entry{};
|
||||||
|
|
||||||
|
entry.item_id = atoi(row[0]);
|
||||||
|
entry.char_name = row[1] ? row[1] : "";
|
||||||
|
entry.discovered_date = atoi(row[2]);
|
||||||
|
entry.account_status = atoi(row[3]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<DiscoveredItems> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<DiscoveredItems> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
DiscoveredItems entry{};
|
||||||
|
|
||||||
|
entry.item_id = atoi(row[0]);
|
||||||
|
entry.char_name = row[1] ? row[1] : "";
|
||||||
|
entry.discovered_date = atoi(row[2]);
|
||||||
|
entry.account_status = atoi(row[3]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_DISCOVERED_ITEMS_REPOSITORY_H
|
||||||
614
common/repositories/base/base_doors_repository.h
Normal file
614
common/repositories/base/base_doors_repository.h
Normal file
@ -0,0 +1,614 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_DOORS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_DOORS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseDoorsRepository {
|
||||||
|
public:
|
||||||
|
struct Doors {
|
||||||
|
int id;
|
||||||
|
int doorid;
|
||||||
|
std::string zone;
|
||||||
|
int version;
|
||||||
|
std::string name;
|
||||||
|
float pos_y;
|
||||||
|
float pos_x;
|
||||||
|
float pos_z;
|
||||||
|
float heading;
|
||||||
|
int opentype;
|
||||||
|
int guild;
|
||||||
|
int lockpick;
|
||||||
|
int keyitem;
|
||||||
|
int nokeyring;
|
||||||
|
int triggerdoor;
|
||||||
|
int triggertype;
|
||||||
|
int disable_timer;
|
||||||
|
int doorisopen;
|
||||||
|
int door_param;
|
||||||
|
std::string dest_zone;
|
||||||
|
int dest_instance;
|
||||||
|
float dest_x;
|
||||||
|
float dest_y;
|
||||||
|
float dest_z;
|
||||||
|
float dest_heading;
|
||||||
|
int invert_state;
|
||||||
|
int incline;
|
||||||
|
int size;
|
||||||
|
float buffer;
|
||||||
|
int client_version_mask;
|
||||||
|
int is_ldon_door;
|
||||||
|
int min_expansion;
|
||||||
|
int max_expansion;
|
||||||
|
std::string content_flags;
|
||||||
|
std::string content_flags_disabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"doorid",
|
||||||
|
"zone",
|
||||||
|
"version",
|
||||||
|
"name",
|
||||||
|
"pos_y",
|
||||||
|
"pos_x",
|
||||||
|
"pos_z",
|
||||||
|
"heading",
|
||||||
|
"opentype",
|
||||||
|
"guild",
|
||||||
|
"lockpick",
|
||||||
|
"keyitem",
|
||||||
|
"nokeyring",
|
||||||
|
"triggerdoor",
|
||||||
|
"triggertype",
|
||||||
|
"disable_timer",
|
||||||
|
"doorisopen",
|
||||||
|
"door_param",
|
||||||
|
"dest_zone",
|
||||||
|
"dest_instance",
|
||||||
|
"dest_x",
|
||||||
|
"dest_y",
|
||||||
|
"dest_z",
|
||||||
|
"dest_heading",
|
||||||
|
"invert_state",
|
||||||
|
"incline",
|
||||||
|
"size",
|
||||||
|
"buffer",
|
||||||
|
"client_version_mask",
|
||||||
|
"is_ldon_door",
|
||||||
|
"min_expansion",
|
||||||
|
"max_expansion",
|
||||||
|
"content_flags",
|
||||||
|
"content_flags_disabled",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("doors");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Doors NewEntity()
|
||||||
|
{
|
||||||
|
Doors entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.doorid = 0;
|
||||||
|
entry.zone = "";
|
||||||
|
entry.version = 0;
|
||||||
|
entry.name = "";
|
||||||
|
entry.pos_y = 0;
|
||||||
|
entry.pos_x = 0;
|
||||||
|
entry.pos_z = 0;
|
||||||
|
entry.heading = 0;
|
||||||
|
entry.opentype = 0;
|
||||||
|
entry.guild = 0;
|
||||||
|
entry.lockpick = 0;
|
||||||
|
entry.keyitem = 0;
|
||||||
|
entry.nokeyring = 0;
|
||||||
|
entry.triggerdoor = 0;
|
||||||
|
entry.triggertype = 0;
|
||||||
|
entry.disable_timer = 0;
|
||||||
|
entry.doorisopen = 0;
|
||||||
|
entry.door_param = 0;
|
||||||
|
entry.dest_zone = "NONE";
|
||||||
|
entry.dest_instance = 0;
|
||||||
|
entry.dest_x = 0;
|
||||||
|
entry.dest_y = 0;
|
||||||
|
entry.dest_z = 0;
|
||||||
|
entry.dest_heading = 0;
|
||||||
|
entry.invert_state = 0;
|
||||||
|
entry.incline = 0;
|
||||||
|
entry.size = 100;
|
||||||
|
entry.buffer = 0;
|
||||||
|
entry.client_version_mask = 4294967295;
|
||||||
|
entry.is_ldon_door = 0;
|
||||||
|
entry.min_expansion = 0;
|
||||||
|
entry.max_expansion = 0;
|
||||||
|
entry.content_flags = "";
|
||||||
|
entry.content_flags_disabled = "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Doors GetDoorsEntry(
|
||||||
|
const std::vector<Doors> &doorss,
|
||||||
|
int doors_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &doors : doorss) {
|
||||||
|
if (doors.id == doors_id) {
|
||||||
|
return doors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Doors FindOne(
|
||||||
|
int doors_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
doors_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
Doors entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.doorid = atoi(row[1]);
|
||||||
|
entry.zone = row[2] ? row[2] : "";
|
||||||
|
entry.version = atoi(row[3]);
|
||||||
|
entry.name = row[4] ? row[4] : "";
|
||||||
|
entry.pos_y = static_cast<float>(atof(row[5]));
|
||||||
|
entry.pos_x = static_cast<float>(atof(row[6]));
|
||||||
|
entry.pos_z = static_cast<float>(atof(row[7]));
|
||||||
|
entry.heading = static_cast<float>(atof(row[8]));
|
||||||
|
entry.opentype = atoi(row[9]);
|
||||||
|
entry.guild = atoi(row[10]);
|
||||||
|
entry.lockpick = atoi(row[11]);
|
||||||
|
entry.keyitem = atoi(row[12]);
|
||||||
|
entry.nokeyring = atoi(row[13]);
|
||||||
|
entry.triggerdoor = atoi(row[14]);
|
||||||
|
entry.triggertype = atoi(row[15]);
|
||||||
|
entry.disable_timer = atoi(row[16]);
|
||||||
|
entry.doorisopen = atoi(row[17]);
|
||||||
|
entry.door_param = atoi(row[18]);
|
||||||
|
entry.dest_zone = row[19] ? row[19] : "";
|
||||||
|
entry.dest_instance = atoi(row[20]);
|
||||||
|
entry.dest_x = static_cast<float>(atof(row[21]));
|
||||||
|
entry.dest_y = static_cast<float>(atof(row[22]));
|
||||||
|
entry.dest_z = static_cast<float>(atof(row[23]));
|
||||||
|
entry.dest_heading = static_cast<float>(atof(row[24]));
|
||||||
|
entry.invert_state = atoi(row[25]);
|
||||||
|
entry.incline = atoi(row[26]);
|
||||||
|
entry.size = atoi(row[27]);
|
||||||
|
entry.buffer = static_cast<float>(atof(row[28]));
|
||||||
|
entry.client_version_mask = atoi(row[29]);
|
||||||
|
entry.is_ldon_door = atoi(row[30]);
|
||||||
|
entry.min_expansion = atoi(row[31]);
|
||||||
|
entry.max_expansion = atoi(row[32]);
|
||||||
|
entry.content_flags = row[33] ? row[33] : "";
|
||||||
|
entry.content_flags_disabled = row[34] ? row[34] : "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int doors_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
doors_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Doors doors_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(doors_entry.doorid));
|
||||||
|
update_values.push_back(columns[2] + " = '" + EscapeString(doors_entry.zone) + "'");
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(doors_entry.version));
|
||||||
|
update_values.push_back(columns[4] + " = '" + EscapeString(doors_entry.name) + "'");
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(doors_entry.pos_y));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(doors_entry.pos_x));
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(doors_entry.pos_z));
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(doors_entry.heading));
|
||||||
|
update_values.push_back(columns[9] + " = " + std::to_string(doors_entry.opentype));
|
||||||
|
update_values.push_back(columns[10] + " = " + std::to_string(doors_entry.guild));
|
||||||
|
update_values.push_back(columns[11] + " = " + std::to_string(doors_entry.lockpick));
|
||||||
|
update_values.push_back(columns[12] + " = " + std::to_string(doors_entry.keyitem));
|
||||||
|
update_values.push_back(columns[13] + " = " + std::to_string(doors_entry.nokeyring));
|
||||||
|
update_values.push_back(columns[14] + " = " + std::to_string(doors_entry.triggerdoor));
|
||||||
|
update_values.push_back(columns[15] + " = " + std::to_string(doors_entry.triggertype));
|
||||||
|
update_values.push_back(columns[16] + " = " + std::to_string(doors_entry.disable_timer));
|
||||||
|
update_values.push_back(columns[17] + " = " + std::to_string(doors_entry.doorisopen));
|
||||||
|
update_values.push_back(columns[18] + " = " + std::to_string(doors_entry.door_param));
|
||||||
|
update_values.push_back(columns[19] + " = '" + EscapeString(doors_entry.dest_zone) + "'");
|
||||||
|
update_values.push_back(columns[20] + " = " + std::to_string(doors_entry.dest_instance));
|
||||||
|
update_values.push_back(columns[21] + " = " + std::to_string(doors_entry.dest_x));
|
||||||
|
update_values.push_back(columns[22] + " = " + std::to_string(doors_entry.dest_y));
|
||||||
|
update_values.push_back(columns[23] + " = " + std::to_string(doors_entry.dest_z));
|
||||||
|
update_values.push_back(columns[24] + " = " + std::to_string(doors_entry.dest_heading));
|
||||||
|
update_values.push_back(columns[25] + " = " + std::to_string(doors_entry.invert_state));
|
||||||
|
update_values.push_back(columns[26] + " = " + std::to_string(doors_entry.incline));
|
||||||
|
update_values.push_back(columns[27] + " = " + std::to_string(doors_entry.size));
|
||||||
|
update_values.push_back(columns[28] + " = " + std::to_string(doors_entry.buffer));
|
||||||
|
update_values.push_back(columns[29] + " = " + std::to_string(doors_entry.client_version_mask));
|
||||||
|
update_values.push_back(columns[30] + " = " + std::to_string(doors_entry.is_ldon_door));
|
||||||
|
update_values.push_back(columns[31] + " = " + std::to_string(doors_entry.min_expansion));
|
||||||
|
update_values.push_back(columns[32] + " = " + std::to_string(doors_entry.max_expansion));
|
||||||
|
update_values.push_back(columns[33] + " = '" + EscapeString(doors_entry.content_flags) + "'");
|
||||||
|
update_values.push_back(columns[34] + " = '" + EscapeString(doors_entry.content_flags_disabled) + "'");
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
doors_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Doors InsertOne(
|
||||||
|
Doors doors_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.doorid));
|
||||||
|
insert_values.push_back("'" + EscapeString(doors_entry.zone) + "'");
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.version));
|
||||||
|
insert_values.push_back("'" + EscapeString(doors_entry.name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.pos_y));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.pos_x));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.pos_z));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.heading));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.opentype));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.guild));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.lockpick));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.keyitem));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.nokeyring));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.triggerdoor));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.triggertype));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.disable_timer));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.doorisopen));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.door_param));
|
||||||
|
insert_values.push_back("'" + EscapeString(doors_entry.dest_zone) + "'");
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.dest_instance));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.dest_x));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.dest_y));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.dest_z));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.dest_heading));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.invert_state));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.incline));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.size));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.buffer));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.client_version_mask));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.is_ldon_door));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.min_expansion));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.max_expansion));
|
||||||
|
insert_values.push_back("'" + EscapeString(doors_entry.content_flags) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(doors_entry.content_flags_disabled) + "'");
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
doors_entry.id = results.LastInsertedID();
|
||||||
|
return doors_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
doors_entry = NewEntity();
|
||||||
|
|
||||||
|
return doors_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<Doors> doors_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &doors_entry: doors_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.doorid));
|
||||||
|
insert_values.push_back("'" + EscapeString(doors_entry.zone) + "'");
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.version));
|
||||||
|
insert_values.push_back("'" + EscapeString(doors_entry.name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.pos_y));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.pos_x));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.pos_z));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.heading));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.opentype));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.guild));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.lockpick));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.keyitem));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.nokeyring));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.triggerdoor));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.triggertype));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.disable_timer));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.doorisopen));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.door_param));
|
||||||
|
insert_values.push_back("'" + EscapeString(doors_entry.dest_zone) + "'");
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.dest_instance));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.dest_x));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.dest_y));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.dest_z));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.dest_heading));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.invert_state));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.incline));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.size));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.buffer));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.client_version_mask));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.is_ldon_door));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.min_expansion));
|
||||||
|
insert_values.push_back(std::to_string(doors_entry.max_expansion));
|
||||||
|
insert_values.push_back("'" + EscapeString(doors_entry.content_flags) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(doors_entry.content_flags_disabled) + "'");
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Doors> All()
|
||||||
|
{
|
||||||
|
std::vector<Doors> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Doors entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.doorid = atoi(row[1]);
|
||||||
|
entry.zone = row[2] ? row[2] : "";
|
||||||
|
entry.version = atoi(row[3]);
|
||||||
|
entry.name = row[4] ? row[4] : "";
|
||||||
|
entry.pos_y = static_cast<float>(atof(row[5]));
|
||||||
|
entry.pos_x = static_cast<float>(atof(row[6]));
|
||||||
|
entry.pos_z = static_cast<float>(atof(row[7]));
|
||||||
|
entry.heading = static_cast<float>(atof(row[8]));
|
||||||
|
entry.opentype = atoi(row[9]);
|
||||||
|
entry.guild = atoi(row[10]);
|
||||||
|
entry.lockpick = atoi(row[11]);
|
||||||
|
entry.keyitem = atoi(row[12]);
|
||||||
|
entry.nokeyring = atoi(row[13]);
|
||||||
|
entry.triggerdoor = atoi(row[14]);
|
||||||
|
entry.triggertype = atoi(row[15]);
|
||||||
|
entry.disable_timer = atoi(row[16]);
|
||||||
|
entry.doorisopen = atoi(row[17]);
|
||||||
|
entry.door_param = atoi(row[18]);
|
||||||
|
entry.dest_zone = row[19] ? row[19] : "";
|
||||||
|
entry.dest_instance = atoi(row[20]);
|
||||||
|
entry.dest_x = static_cast<float>(atof(row[21]));
|
||||||
|
entry.dest_y = static_cast<float>(atof(row[22]));
|
||||||
|
entry.dest_z = static_cast<float>(atof(row[23]));
|
||||||
|
entry.dest_heading = static_cast<float>(atof(row[24]));
|
||||||
|
entry.invert_state = atoi(row[25]);
|
||||||
|
entry.incline = atoi(row[26]);
|
||||||
|
entry.size = atoi(row[27]);
|
||||||
|
entry.buffer = static_cast<float>(atof(row[28]));
|
||||||
|
entry.client_version_mask = atoi(row[29]);
|
||||||
|
entry.is_ldon_door = atoi(row[30]);
|
||||||
|
entry.min_expansion = atoi(row[31]);
|
||||||
|
entry.max_expansion = atoi(row[32]);
|
||||||
|
entry.content_flags = row[33] ? row[33] : "";
|
||||||
|
entry.content_flags_disabled = row[34] ? row[34] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Doors> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<Doors> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Doors entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.doorid = atoi(row[1]);
|
||||||
|
entry.zone = row[2] ? row[2] : "";
|
||||||
|
entry.version = atoi(row[3]);
|
||||||
|
entry.name = row[4] ? row[4] : "";
|
||||||
|
entry.pos_y = static_cast<float>(atof(row[5]));
|
||||||
|
entry.pos_x = static_cast<float>(atof(row[6]));
|
||||||
|
entry.pos_z = static_cast<float>(atof(row[7]));
|
||||||
|
entry.heading = static_cast<float>(atof(row[8]));
|
||||||
|
entry.opentype = atoi(row[9]);
|
||||||
|
entry.guild = atoi(row[10]);
|
||||||
|
entry.lockpick = atoi(row[11]);
|
||||||
|
entry.keyitem = atoi(row[12]);
|
||||||
|
entry.nokeyring = atoi(row[13]);
|
||||||
|
entry.triggerdoor = atoi(row[14]);
|
||||||
|
entry.triggertype = atoi(row[15]);
|
||||||
|
entry.disable_timer = atoi(row[16]);
|
||||||
|
entry.doorisopen = atoi(row[17]);
|
||||||
|
entry.door_param = atoi(row[18]);
|
||||||
|
entry.dest_zone = row[19] ? row[19] : "";
|
||||||
|
entry.dest_instance = atoi(row[20]);
|
||||||
|
entry.dest_x = static_cast<float>(atof(row[21]));
|
||||||
|
entry.dest_y = static_cast<float>(atof(row[22]));
|
||||||
|
entry.dest_z = static_cast<float>(atof(row[23]));
|
||||||
|
entry.dest_heading = static_cast<float>(atof(row[24]));
|
||||||
|
entry.invert_state = atoi(row[25]);
|
||||||
|
entry.incline = atoi(row[26]);
|
||||||
|
entry.size = atoi(row[27]);
|
||||||
|
entry.buffer = static_cast<float>(atof(row[28]));
|
||||||
|
entry.client_version_mask = atoi(row[29]);
|
||||||
|
entry.is_ldon_door = atoi(row[30]);
|
||||||
|
entry.min_expansion = atoi(row[31]);
|
||||||
|
entry.max_expansion = atoi(row[32]);
|
||||||
|
entry.content_flags = row[33] ? row[33] : "";
|
||||||
|
entry.content_flags_disabled = row[34] ? row[34] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_DOORS_REPOSITORY_H
|
||||||
389
common/repositories/base/base_eventlog_repository.h
Normal file
389
common/repositories/base/base_eventlog_repository.h
Normal file
@ -0,0 +1,389 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_EVENTLOG_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_EVENTLOG_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseEventlogRepository {
|
||||||
|
public:
|
||||||
|
struct Eventlog {
|
||||||
|
int id;
|
||||||
|
std::string accountname;
|
||||||
|
int accountid;
|
||||||
|
int status;
|
||||||
|
std::string charname;
|
||||||
|
std::string target;
|
||||||
|
std::string time;
|
||||||
|
std::string descriptiontype;
|
||||||
|
std::string description;
|
||||||
|
int event_nid;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"accountname",
|
||||||
|
"accountid",
|
||||||
|
"status",
|
||||||
|
"charname",
|
||||||
|
"target",
|
||||||
|
"time",
|
||||||
|
"descriptiontype",
|
||||||
|
"description",
|
||||||
|
"event_nid",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("eventlog");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eventlog NewEntity()
|
||||||
|
{
|
||||||
|
Eventlog entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.accountname = "";
|
||||||
|
entry.accountid = 0;
|
||||||
|
entry.status = 0;
|
||||||
|
entry.charname = "";
|
||||||
|
entry.target = "None";
|
||||||
|
entry.time = current_timestamp();
|
||||||
|
entry.descriptiontype = "";
|
||||||
|
entry.description = "";
|
||||||
|
entry.event_nid = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eventlog GetEventlogEntry(
|
||||||
|
const std::vector<Eventlog> &eventlogs,
|
||||||
|
int eventlog_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &eventlog : eventlogs) {
|
||||||
|
if (eventlog.id == eventlog_id) {
|
||||||
|
return eventlog;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eventlog FindOne(
|
||||||
|
int eventlog_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
eventlog_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
Eventlog entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.accountname = row[1] ? row[1] : "";
|
||||||
|
entry.accountid = atoi(row[2]);
|
||||||
|
entry.status = atoi(row[3]);
|
||||||
|
entry.charname = row[4] ? row[4] : "";
|
||||||
|
entry.target = row[5] ? row[5] : "";
|
||||||
|
entry.time = row[6] ? row[6] : "";
|
||||||
|
entry.descriptiontype = row[7] ? row[7] : "";
|
||||||
|
entry.description = row[8] ? row[8] : "";
|
||||||
|
entry.event_nid = atoi(row[9]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int eventlog_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
eventlog_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Eventlog eventlog_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[1] + " = '" + EscapeString(eventlog_entry.accountname) + "'");
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(eventlog_entry.accountid));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(eventlog_entry.status));
|
||||||
|
update_values.push_back(columns[4] + " = '" + EscapeString(eventlog_entry.charname) + "'");
|
||||||
|
update_values.push_back(columns[5] + " = '" + EscapeString(eventlog_entry.target) + "'");
|
||||||
|
update_values.push_back(columns[6] + " = '" + EscapeString(eventlog_entry.time) + "'");
|
||||||
|
update_values.push_back(columns[7] + " = '" + EscapeString(eventlog_entry.descriptiontype) + "'");
|
||||||
|
update_values.push_back(columns[8] + " = '" + EscapeString(eventlog_entry.description) + "'");
|
||||||
|
update_values.push_back(columns[9] + " = " + std::to_string(eventlog_entry.event_nid));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
eventlog_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eventlog InsertOne(
|
||||||
|
Eventlog eventlog_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back("'" + EscapeString(eventlog_entry.accountname) + "'");
|
||||||
|
insert_values.push_back(std::to_string(eventlog_entry.accountid));
|
||||||
|
insert_values.push_back(std::to_string(eventlog_entry.status));
|
||||||
|
insert_values.push_back("'" + EscapeString(eventlog_entry.charname) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(eventlog_entry.target) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(eventlog_entry.time) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(eventlog_entry.descriptiontype) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(eventlog_entry.description) + "'");
|
||||||
|
insert_values.push_back(std::to_string(eventlog_entry.event_nid));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
eventlog_entry.id = results.LastInsertedID();
|
||||||
|
return eventlog_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
eventlog_entry = NewEntity();
|
||||||
|
|
||||||
|
return eventlog_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<Eventlog> eventlog_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &eventlog_entry: eventlog_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back("'" + EscapeString(eventlog_entry.accountname) + "'");
|
||||||
|
insert_values.push_back(std::to_string(eventlog_entry.accountid));
|
||||||
|
insert_values.push_back(std::to_string(eventlog_entry.status));
|
||||||
|
insert_values.push_back("'" + EscapeString(eventlog_entry.charname) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(eventlog_entry.target) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(eventlog_entry.time) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(eventlog_entry.descriptiontype) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(eventlog_entry.description) + "'");
|
||||||
|
insert_values.push_back(std::to_string(eventlog_entry.event_nid));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Eventlog> All()
|
||||||
|
{
|
||||||
|
std::vector<Eventlog> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Eventlog entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.accountname = row[1] ? row[1] : "";
|
||||||
|
entry.accountid = atoi(row[2]);
|
||||||
|
entry.status = atoi(row[3]);
|
||||||
|
entry.charname = row[4] ? row[4] : "";
|
||||||
|
entry.target = row[5] ? row[5] : "";
|
||||||
|
entry.time = row[6] ? row[6] : "";
|
||||||
|
entry.descriptiontype = row[7] ? row[7] : "";
|
||||||
|
entry.description = row[8] ? row[8] : "";
|
||||||
|
entry.event_nid = atoi(row[9]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Eventlog> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<Eventlog> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Eventlog entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.accountname = row[1] ? row[1] : "";
|
||||||
|
entry.accountid = atoi(row[2]);
|
||||||
|
entry.status = atoi(row[3]);
|
||||||
|
entry.charname = row[4] ? row[4] : "";
|
||||||
|
entry.target = row[5] ? row[5] : "";
|
||||||
|
entry.time = row[6] ? row[6] : "";
|
||||||
|
entry.descriptiontype = row[7] ? row[7] : "";
|
||||||
|
entry.description = row[8] ? row[8] : "";
|
||||||
|
entry.event_nid = atoi(row[9]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_EVENTLOG_REPOSITORY_H
|
||||||
356
common/repositories/base/base_faction_base_data_repository.h
Normal file
356
common/repositories/base/base_faction_base_data_repository.h
Normal file
@ -0,0 +1,356 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_FACTION_BASE_DATA_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_FACTION_BASE_DATA_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseFactionBaseDataRepository {
|
||||||
|
public:
|
||||||
|
struct FactionBaseData {
|
||||||
|
int client_faction_id;
|
||||||
|
int min;
|
||||||
|
int max;
|
||||||
|
int unk_hero1;
|
||||||
|
int unk_hero2;
|
||||||
|
int unk_hero3;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("client_faction_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"client_faction_id",
|
||||||
|
"min",
|
||||||
|
"max",
|
||||||
|
"unk_hero1",
|
||||||
|
"unk_hero2",
|
||||||
|
"unk_hero3",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("faction_base_data");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static FactionBaseData NewEntity()
|
||||||
|
{
|
||||||
|
FactionBaseData entry{};
|
||||||
|
|
||||||
|
entry.client_faction_id = 0;
|
||||||
|
entry.min = -2000;
|
||||||
|
entry.max = 2000;
|
||||||
|
entry.unk_hero1 = 0;
|
||||||
|
entry.unk_hero2 = 0;
|
||||||
|
entry.unk_hero3 = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FactionBaseData GetFactionBaseDataEntry(
|
||||||
|
const std::vector<FactionBaseData> &faction_base_datas,
|
||||||
|
int faction_base_data_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &faction_base_data : faction_base_datas) {
|
||||||
|
if (faction_base_data.client_faction_id == faction_base_data_id) {
|
||||||
|
return faction_base_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static FactionBaseData FindOne(
|
||||||
|
int faction_base_data_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
faction_base_data_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
FactionBaseData entry{};
|
||||||
|
|
||||||
|
entry.client_faction_id = atoi(row[0]);
|
||||||
|
entry.min = atoi(row[1]);
|
||||||
|
entry.max = atoi(row[2]);
|
||||||
|
entry.unk_hero1 = atoi(row[3]);
|
||||||
|
entry.unk_hero2 = atoi(row[4]);
|
||||||
|
entry.unk_hero3 = atoi(row[5]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int faction_base_data_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
faction_base_data_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
FactionBaseData faction_base_data_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(faction_base_data_entry.client_faction_id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(faction_base_data_entry.min));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(faction_base_data_entry.max));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(faction_base_data_entry.unk_hero1));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(faction_base_data_entry.unk_hero2));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(faction_base_data_entry.unk_hero3));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
faction_base_data_entry.client_faction_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static FactionBaseData InsertOne(
|
||||||
|
FactionBaseData faction_base_data_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(faction_base_data_entry.client_faction_id));
|
||||||
|
insert_values.push_back(std::to_string(faction_base_data_entry.min));
|
||||||
|
insert_values.push_back(std::to_string(faction_base_data_entry.max));
|
||||||
|
insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero1));
|
||||||
|
insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero2));
|
||||||
|
insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero3));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
faction_base_data_entry.client_faction_id = results.LastInsertedID();
|
||||||
|
return faction_base_data_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
faction_base_data_entry = NewEntity();
|
||||||
|
|
||||||
|
return faction_base_data_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<FactionBaseData> faction_base_data_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &faction_base_data_entry: faction_base_data_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(faction_base_data_entry.client_faction_id));
|
||||||
|
insert_values.push_back(std::to_string(faction_base_data_entry.min));
|
||||||
|
insert_values.push_back(std::to_string(faction_base_data_entry.max));
|
||||||
|
insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero1));
|
||||||
|
insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero2));
|
||||||
|
insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero3));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<FactionBaseData> All()
|
||||||
|
{
|
||||||
|
std::vector<FactionBaseData> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
FactionBaseData entry{};
|
||||||
|
|
||||||
|
entry.client_faction_id = atoi(row[0]);
|
||||||
|
entry.min = atoi(row[1]);
|
||||||
|
entry.max = atoi(row[2]);
|
||||||
|
entry.unk_hero1 = atoi(row[3]);
|
||||||
|
entry.unk_hero2 = atoi(row[4]);
|
||||||
|
entry.unk_hero3 = atoi(row[5]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<FactionBaseData> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<FactionBaseData> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
FactionBaseData entry{};
|
||||||
|
|
||||||
|
entry.client_faction_id = atoi(row[0]);
|
||||||
|
entry.min = atoi(row[1]);
|
||||||
|
entry.max = atoi(row[2]);
|
||||||
|
entry.unk_hero1 = atoi(row[3]);
|
||||||
|
entry.unk_hero2 = atoi(row[4]);
|
||||||
|
entry.unk_hero3 = atoi(row[5]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_FACTION_BASE_DATA_REPOSITORY_H
|
||||||
335
common/repositories/base/base_faction_list_mod_repository.h
Normal file
335
common/repositories/base/base_faction_list_mod_repository.h
Normal file
@ -0,0 +1,335 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_FACTION_LIST_MOD_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_FACTION_LIST_MOD_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseFactionListModRepository {
|
||||||
|
public:
|
||||||
|
struct FactionListMod {
|
||||||
|
int id;
|
||||||
|
int faction_id;
|
||||||
|
int mod;
|
||||||
|
std::string mod_name;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"faction_id",
|
||||||
|
"mod",
|
||||||
|
"mod_name",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("faction_list_mod");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static FactionListMod NewEntity()
|
||||||
|
{
|
||||||
|
FactionListMod entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.faction_id = 0;
|
||||||
|
entry.mod = 0;
|
||||||
|
entry.mod_name = "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FactionListMod GetFactionListModEntry(
|
||||||
|
const std::vector<FactionListMod> &faction_list_mods,
|
||||||
|
int faction_list_mod_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &faction_list_mod : faction_list_mods) {
|
||||||
|
if (faction_list_mod.id == faction_list_mod_id) {
|
||||||
|
return faction_list_mod;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static FactionListMod FindOne(
|
||||||
|
int faction_list_mod_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
faction_list_mod_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
FactionListMod entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.faction_id = atoi(row[1]);
|
||||||
|
entry.mod = atoi(row[2]);
|
||||||
|
entry.mod_name = row[3] ? row[3] : "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int faction_list_mod_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
faction_list_mod_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
FactionListMod faction_list_mod_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(faction_list_mod_entry.faction_id));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(faction_list_mod_entry.mod));
|
||||||
|
update_values.push_back(columns[3] + " = '" + EscapeString(faction_list_mod_entry.mod_name) + "'");
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
faction_list_mod_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static FactionListMod InsertOne(
|
||||||
|
FactionListMod faction_list_mod_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(faction_list_mod_entry.faction_id));
|
||||||
|
insert_values.push_back(std::to_string(faction_list_mod_entry.mod));
|
||||||
|
insert_values.push_back("'" + EscapeString(faction_list_mod_entry.mod_name) + "'");
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
faction_list_mod_entry.id = results.LastInsertedID();
|
||||||
|
return faction_list_mod_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
faction_list_mod_entry = NewEntity();
|
||||||
|
|
||||||
|
return faction_list_mod_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<FactionListMod> faction_list_mod_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &faction_list_mod_entry: faction_list_mod_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(faction_list_mod_entry.faction_id));
|
||||||
|
insert_values.push_back(std::to_string(faction_list_mod_entry.mod));
|
||||||
|
insert_values.push_back("'" + EscapeString(faction_list_mod_entry.mod_name) + "'");
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<FactionListMod> All()
|
||||||
|
{
|
||||||
|
std::vector<FactionListMod> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
FactionListMod entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.faction_id = atoi(row[1]);
|
||||||
|
entry.mod = atoi(row[2]);
|
||||||
|
entry.mod_name = row[3] ? row[3] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<FactionListMod> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<FactionListMod> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
FactionListMod entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.faction_id = atoi(row[1]);
|
||||||
|
entry.mod = atoi(row[2]);
|
||||||
|
entry.mod_name = row[3] ? row[3] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_FACTION_LIST_MOD_REPOSITORY_H
|
||||||
329
common/repositories/base/base_faction_list_repository.h
Normal file
329
common/repositories/base/base_faction_list_repository.h
Normal file
@ -0,0 +1,329 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_FACTION_LIST_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_FACTION_LIST_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseFactionListRepository {
|
||||||
|
public:
|
||||||
|
struct FactionList {
|
||||||
|
int id;
|
||||||
|
std::string name;
|
||||||
|
int base;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"base",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("faction_list");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static FactionList NewEntity()
|
||||||
|
{
|
||||||
|
FactionList entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.name = "";
|
||||||
|
entry.base = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FactionList GetFactionListEntry(
|
||||||
|
const std::vector<FactionList> &faction_lists,
|
||||||
|
int faction_list_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &faction_list : faction_lists) {
|
||||||
|
if (faction_list.id == faction_list_id) {
|
||||||
|
return faction_list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static FactionList FindOne(
|
||||||
|
int faction_list_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
faction_list_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
FactionList entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.name = row[1] ? row[1] : "";
|
||||||
|
entry.base = atoi(row[2]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int faction_list_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
faction_list_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
FactionList faction_list_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(faction_list_entry.id));
|
||||||
|
update_values.push_back(columns[1] + " = '" + EscapeString(faction_list_entry.name) + "'");
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(faction_list_entry.base));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
faction_list_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static FactionList InsertOne(
|
||||||
|
FactionList faction_list_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(faction_list_entry.id));
|
||||||
|
insert_values.push_back("'" + EscapeString(faction_list_entry.name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(faction_list_entry.base));
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
faction_list_entry.id = results.LastInsertedID();
|
||||||
|
return faction_list_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
faction_list_entry = NewEntity();
|
||||||
|
|
||||||
|
return faction_list_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<FactionList> faction_list_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &faction_list_entry: faction_list_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(faction_list_entry.id));
|
||||||
|
insert_values.push_back("'" + EscapeString(faction_list_entry.name) + "'");
|
||||||
|
insert_values.push_back(std::to_string(faction_list_entry.base));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<FactionList> All()
|
||||||
|
{
|
||||||
|
std::vector<FactionList> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
FactionList entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.name = row[1] ? row[1] : "";
|
||||||
|
entry.base = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<FactionList> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<FactionList> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
FactionList entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.name = row[1] ? row[1] : "";
|
||||||
|
entry.base = atoi(row[2]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_FACTION_LIST_REPOSITORY_H
|
||||||
338
common/repositories/base/base_faction_values_repository.h
Normal file
338
common/repositories/base/base_faction_values_repository.h
Normal file
@ -0,0 +1,338 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_FACTION_VALUES_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_FACTION_VALUES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseFactionValuesRepository {
|
||||||
|
public:
|
||||||
|
struct FactionValues {
|
||||||
|
int char_id;
|
||||||
|
int faction_id;
|
||||||
|
int current_value;
|
||||||
|
int temp;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("char_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"char_id",
|
||||||
|
"faction_id",
|
||||||
|
"current_value",
|
||||||
|
"temp",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("faction_values");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static FactionValues NewEntity()
|
||||||
|
{
|
||||||
|
FactionValues entry{};
|
||||||
|
|
||||||
|
entry.char_id = 0;
|
||||||
|
entry.faction_id = 0;
|
||||||
|
entry.current_value = 0;
|
||||||
|
entry.temp = 0;
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FactionValues GetFactionValuesEntry(
|
||||||
|
const std::vector<FactionValues> &faction_valuess,
|
||||||
|
int faction_values_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &faction_values : faction_valuess) {
|
||||||
|
if (faction_values.char_id == faction_values_id) {
|
||||||
|
return faction_values;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static FactionValues FindOne(
|
||||||
|
int faction_values_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
faction_values_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
FactionValues entry{};
|
||||||
|
|
||||||
|
entry.char_id = atoi(row[0]);
|
||||||
|
entry.faction_id = atoi(row[1]);
|
||||||
|
entry.current_value = atoi(row[2]);
|
||||||
|
entry.temp = atoi(row[3]);
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int faction_values_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
faction_values_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
FactionValues faction_values_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(faction_values_entry.char_id));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(faction_values_entry.faction_id));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(faction_values_entry.current_value));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(faction_values_entry.temp));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
faction_values_entry.char_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static FactionValues InsertOne(
|
||||||
|
FactionValues faction_values_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(faction_values_entry.char_id));
|
||||||
|
insert_values.push_back(std::to_string(faction_values_entry.faction_id));
|
||||||
|
insert_values.push_back(std::to_string(faction_values_entry.current_value));
|
||||||
|
insert_values.push_back(std::to_string(faction_values_entry.temp));
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
faction_values_entry.char_id = results.LastInsertedID();
|
||||||
|
return faction_values_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
faction_values_entry = NewEntity();
|
||||||
|
|
||||||
|
return faction_values_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<FactionValues> faction_values_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &faction_values_entry: faction_values_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(faction_values_entry.char_id));
|
||||||
|
insert_values.push_back(std::to_string(faction_values_entry.faction_id));
|
||||||
|
insert_values.push_back(std::to_string(faction_values_entry.current_value));
|
||||||
|
insert_values.push_back(std::to_string(faction_values_entry.temp));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<FactionValues> All()
|
||||||
|
{
|
||||||
|
std::vector<FactionValues> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
FactionValues entry{};
|
||||||
|
|
||||||
|
entry.char_id = atoi(row[0]);
|
||||||
|
entry.faction_id = atoi(row[1]);
|
||||||
|
entry.current_value = atoi(row[2]);
|
||||||
|
entry.temp = atoi(row[3]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<FactionValues> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<FactionValues> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
FactionValues entry{};
|
||||||
|
|
||||||
|
entry.char_id = atoi(row[0]);
|
||||||
|
entry.faction_id = atoi(row[1]);
|
||||||
|
entry.current_value = atoi(row[2]);
|
||||||
|
entry.temp = atoi(row[3]);
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_FACTION_VALUES_REPOSITORY_H
|
||||||
398
common/repositories/base/base_fishing_repository.h
Normal file
398
common/repositories/base/base_fishing_repository.h
Normal file
@ -0,0 +1,398 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_FISHING_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_FISHING_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseFishingRepository {
|
||||||
|
public:
|
||||||
|
struct Fishing {
|
||||||
|
int id;
|
||||||
|
int zoneid;
|
||||||
|
int Itemid;
|
||||||
|
int skill_level;
|
||||||
|
int chance;
|
||||||
|
int npc_id;
|
||||||
|
int npc_chance;
|
||||||
|
int min_expansion;
|
||||||
|
int max_expansion;
|
||||||
|
std::string content_flags;
|
||||||
|
std::string content_flags_disabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"zoneid",
|
||||||
|
"Itemid",
|
||||||
|
"skill_level",
|
||||||
|
"chance",
|
||||||
|
"npc_id",
|
||||||
|
"npc_chance",
|
||||||
|
"min_expansion",
|
||||||
|
"max_expansion",
|
||||||
|
"content_flags",
|
||||||
|
"content_flags_disabled",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("fishing");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Fishing NewEntity()
|
||||||
|
{
|
||||||
|
Fishing entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.zoneid = 0;
|
||||||
|
entry.Itemid = 0;
|
||||||
|
entry.skill_level = 0;
|
||||||
|
entry.chance = 0;
|
||||||
|
entry.npc_id = 0;
|
||||||
|
entry.npc_chance = 0;
|
||||||
|
entry.min_expansion = 0;
|
||||||
|
entry.max_expansion = 0;
|
||||||
|
entry.content_flags = "";
|
||||||
|
entry.content_flags_disabled = "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Fishing GetFishingEntry(
|
||||||
|
const std::vector<Fishing> &fishings,
|
||||||
|
int fishing_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &fishing : fishings) {
|
||||||
|
if (fishing.id == fishing_id) {
|
||||||
|
return fishing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Fishing FindOne(
|
||||||
|
int fishing_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
fishing_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
Fishing entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.zoneid = atoi(row[1]);
|
||||||
|
entry.Itemid = atoi(row[2]);
|
||||||
|
entry.skill_level = atoi(row[3]);
|
||||||
|
entry.chance = atoi(row[4]);
|
||||||
|
entry.npc_id = atoi(row[5]);
|
||||||
|
entry.npc_chance = atoi(row[6]);
|
||||||
|
entry.min_expansion = atoi(row[7]);
|
||||||
|
entry.max_expansion = atoi(row[8]);
|
||||||
|
entry.content_flags = row[9] ? row[9] : "";
|
||||||
|
entry.content_flags_disabled = row[10] ? row[10] : "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int fishing_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
fishing_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Fishing fishing_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(fishing_entry.zoneid));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(fishing_entry.Itemid));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(fishing_entry.skill_level));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(fishing_entry.chance));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(fishing_entry.npc_id));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(fishing_entry.npc_chance));
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(fishing_entry.min_expansion));
|
||||||
|
update_values.push_back(columns[8] + " = " + std::to_string(fishing_entry.max_expansion));
|
||||||
|
update_values.push_back(columns[9] + " = '" + EscapeString(fishing_entry.content_flags) + "'");
|
||||||
|
update_values.push_back(columns[10] + " = '" + EscapeString(fishing_entry.content_flags_disabled) + "'");
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
fishing_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Fishing InsertOne(
|
||||||
|
Fishing fishing_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(fishing_entry.zoneid));
|
||||||
|
insert_values.push_back(std::to_string(fishing_entry.Itemid));
|
||||||
|
insert_values.push_back(std::to_string(fishing_entry.skill_level));
|
||||||
|
insert_values.push_back(std::to_string(fishing_entry.chance));
|
||||||
|
insert_values.push_back(std::to_string(fishing_entry.npc_id));
|
||||||
|
insert_values.push_back(std::to_string(fishing_entry.npc_chance));
|
||||||
|
insert_values.push_back(std::to_string(fishing_entry.min_expansion));
|
||||||
|
insert_values.push_back(std::to_string(fishing_entry.max_expansion));
|
||||||
|
insert_values.push_back("'" + EscapeString(fishing_entry.content_flags) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(fishing_entry.content_flags_disabled) + "'");
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
fishing_entry.id = results.LastInsertedID();
|
||||||
|
return fishing_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
fishing_entry = NewEntity();
|
||||||
|
|
||||||
|
return fishing_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<Fishing> fishing_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &fishing_entry: fishing_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(fishing_entry.zoneid));
|
||||||
|
insert_values.push_back(std::to_string(fishing_entry.Itemid));
|
||||||
|
insert_values.push_back(std::to_string(fishing_entry.skill_level));
|
||||||
|
insert_values.push_back(std::to_string(fishing_entry.chance));
|
||||||
|
insert_values.push_back(std::to_string(fishing_entry.npc_id));
|
||||||
|
insert_values.push_back(std::to_string(fishing_entry.npc_chance));
|
||||||
|
insert_values.push_back(std::to_string(fishing_entry.min_expansion));
|
||||||
|
insert_values.push_back(std::to_string(fishing_entry.max_expansion));
|
||||||
|
insert_values.push_back("'" + EscapeString(fishing_entry.content_flags) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(fishing_entry.content_flags_disabled) + "'");
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Fishing> All()
|
||||||
|
{
|
||||||
|
std::vector<Fishing> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Fishing entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.zoneid = atoi(row[1]);
|
||||||
|
entry.Itemid = atoi(row[2]);
|
||||||
|
entry.skill_level = atoi(row[3]);
|
||||||
|
entry.chance = atoi(row[4]);
|
||||||
|
entry.npc_id = atoi(row[5]);
|
||||||
|
entry.npc_chance = atoi(row[6]);
|
||||||
|
entry.min_expansion = atoi(row[7]);
|
||||||
|
entry.max_expansion = atoi(row[8]);
|
||||||
|
entry.content_flags = row[9] ? row[9] : "";
|
||||||
|
entry.content_flags_disabled = row[10] ? row[10] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Fishing> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<Fishing> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Fishing entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.zoneid = atoi(row[1]);
|
||||||
|
entry.Itemid = atoi(row[2]);
|
||||||
|
entry.skill_level = atoi(row[3]);
|
||||||
|
entry.chance = atoi(row[4]);
|
||||||
|
entry.npc_id = atoi(row[5]);
|
||||||
|
entry.npc_chance = atoi(row[6]);
|
||||||
|
entry.min_expansion = atoi(row[7]);
|
||||||
|
entry.max_expansion = atoi(row[8]);
|
||||||
|
entry.content_flags = row[9] ? row[9] : "";
|
||||||
|
entry.content_flags_disabled = row[10] ? row[10] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_FISHING_REPOSITORY_H
|
||||||
380
common/repositories/base/base_forage_repository.h
Normal file
380
common/repositories/base/base_forage_repository.h
Normal file
@ -0,0 +1,380 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_FORAGE_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_FORAGE_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseForageRepository {
|
||||||
|
public:
|
||||||
|
struct Forage {
|
||||||
|
int id;
|
||||||
|
int zoneid;
|
||||||
|
int Itemid;
|
||||||
|
int level;
|
||||||
|
int chance;
|
||||||
|
int min_expansion;
|
||||||
|
int max_expansion;
|
||||||
|
std::string content_flags;
|
||||||
|
std::string content_flags_disabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"zoneid",
|
||||||
|
"Itemid",
|
||||||
|
"level",
|
||||||
|
"chance",
|
||||||
|
"min_expansion",
|
||||||
|
"max_expansion",
|
||||||
|
"content_flags",
|
||||||
|
"content_flags_disabled",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("forage");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Forage NewEntity()
|
||||||
|
{
|
||||||
|
Forage entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.zoneid = 0;
|
||||||
|
entry.Itemid = 0;
|
||||||
|
entry.level = 0;
|
||||||
|
entry.chance = 0;
|
||||||
|
entry.min_expansion = 0;
|
||||||
|
entry.max_expansion = 0;
|
||||||
|
entry.content_flags = "";
|
||||||
|
entry.content_flags_disabled = "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Forage GetForageEntry(
|
||||||
|
const std::vector<Forage> &forages,
|
||||||
|
int forage_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &forage : forages) {
|
||||||
|
if (forage.id == forage_id) {
|
||||||
|
return forage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Forage FindOne(
|
||||||
|
int forage_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
forage_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
Forage entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.zoneid = atoi(row[1]);
|
||||||
|
entry.Itemid = atoi(row[2]);
|
||||||
|
entry.level = atoi(row[3]);
|
||||||
|
entry.chance = atoi(row[4]);
|
||||||
|
entry.min_expansion = atoi(row[5]);
|
||||||
|
entry.max_expansion = atoi(row[6]);
|
||||||
|
entry.content_flags = row[7] ? row[7] : "";
|
||||||
|
entry.content_flags_disabled = row[8] ? row[8] : "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int forage_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
forage_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Forage forage_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(forage_entry.zoneid));
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(forage_entry.Itemid));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(forage_entry.level));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(forage_entry.chance));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(forage_entry.min_expansion));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(forage_entry.max_expansion));
|
||||||
|
update_values.push_back(columns[7] + " = '" + EscapeString(forage_entry.content_flags) + "'");
|
||||||
|
update_values.push_back(columns[8] + " = '" + EscapeString(forage_entry.content_flags_disabled) + "'");
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
forage_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Forage InsertOne(
|
||||||
|
Forage forage_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(forage_entry.zoneid));
|
||||||
|
insert_values.push_back(std::to_string(forage_entry.Itemid));
|
||||||
|
insert_values.push_back(std::to_string(forage_entry.level));
|
||||||
|
insert_values.push_back(std::to_string(forage_entry.chance));
|
||||||
|
insert_values.push_back(std::to_string(forage_entry.min_expansion));
|
||||||
|
insert_values.push_back(std::to_string(forage_entry.max_expansion));
|
||||||
|
insert_values.push_back("'" + EscapeString(forage_entry.content_flags) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(forage_entry.content_flags_disabled) + "'");
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
forage_entry.id = results.LastInsertedID();
|
||||||
|
return forage_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
forage_entry = NewEntity();
|
||||||
|
|
||||||
|
return forage_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<Forage> forage_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &forage_entry: forage_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(forage_entry.zoneid));
|
||||||
|
insert_values.push_back(std::to_string(forage_entry.Itemid));
|
||||||
|
insert_values.push_back(std::to_string(forage_entry.level));
|
||||||
|
insert_values.push_back(std::to_string(forage_entry.chance));
|
||||||
|
insert_values.push_back(std::to_string(forage_entry.min_expansion));
|
||||||
|
insert_values.push_back(std::to_string(forage_entry.max_expansion));
|
||||||
|
insert_values.push_back("'" + EscapeString(forage_entry.content_flags) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(forage_entry.content_flags_disabled) + "'");
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Forage> All()
|
||||||
|
{
|
||||||
|
std::vector<Forage> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Forage entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.zoneid = atoi(row[1]);
|
||||||
|
entry.Itemid = atoi(row[2]);
|
||||||
|
entry.level = atoi(row[3]);
|
||||||
|
entry.chance = atoi(row[4]);
|
||||||
|
entry.min_expansion = atoi(row[5]);
|
||||||
|
entry.max_expansion = atoi(row[6]);
|
||||||
|
entry.content_flags = row[7] ? row[7] : "";
|
||||||
|
entry.content_flags_disabled = row[8] ? row[8] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Forage> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<Forage> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Forage entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.zoneid = atoi(row[1]);
|
||||||
|
entry.Itemid = atoi(row[2]);
|
||||||
|
entry.level = atoi(row[3]);
|
||||||
|
entry.chance = atoi(row[4]);
|
||||||
|
entry.min_expansion = atoi(row[5]);
|
||||||
|
entry.max_expansion = atoi(row[6]);
|
||||||
|
entry.content_flags = row[7] ? row[7] : "";
|
||||||
|
entry.content_flags_disabled = row[8] ? row[8] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_FORAGE_REPOSITORY_H
|
||||||
329
common/repositories/base/base_friends_repository.h
Normal file
329
common/repositories/base/base_friends_repository.h
Normal file
@ -0,0 +1,329 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_FRIENDS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_FRIENDS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseFriendsRepository {
|
||||||
|
public:
|
||||||
|
struct Friends {
|
||||||
|
int charid;
|
||||||
|
int type;
|
||||||
|
std::string name;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("charid");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"charid",
|
||||||
|
"type",
|
||||||
|
"name",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("friends");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Friends NewEntity()
|
||||||
|
{
|
||||||
|
Friends entry{};
|
||||||
|
|
||||||
|
entry.charid = 0;
|
||||||
|
entry.type = 1;
|
||||||
|
entry.name = "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Friends GetFriendsEntry(
|
||||||
|
const std::vector<Friends> &friendss,
|
||||||
|
int friends_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &friends : friendss) {
|
||||||
|
if (friends.charid == friends_id) {
|
||||||
|
return friends;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Friends FindOne(
|
||||||
|
int friends_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
friends_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
Friends entry{};
|
||||||
|
|
||||||
|
entry.charid = atoi(row[0]);
|
||||||
|
entry.type = atoi(row[1]);
|
||||||
|
entry.name = row[2] ? row[2] : "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int friends_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
friends_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Friends friends_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[0] + " = " + std::to_string(friends_entry.charid));
|
||||||
|
update_values.push_back(columns[1] + " = " + std::to_string(friends_entry.type));
|
||||||
|
update_values.push_back(columns[2] + " = '" + EscapeString(friends_entry.name) + "'");
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
friends_entry.charid
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Friends InsertOne(
|
||||||
|
Friends friends_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(friends_entry.charid));
|
||||||
|
insert_values.push_back(std::to_string(friends_entry.type));
|
||||||
|
insert_values.push_back("'" + EscapeString(friends_entry.name) + "'");
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
friends_entry.charid = results.LastInsertedID();
|
||||||
|
return friends_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
friends_entry = NewEntity();
|
||||||
|
|
||||||
|
return friends_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<Friends> friends_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &friends_entry: friends_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back(std::to_string(friends_entry.charid));
|
||||||
|
insert_values.push_back(std::to_string(friends_entry.type));
|
||||||
|
insert_values.push_back("'" + EscapeString(friends_entry.name) + "'");
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Friends> All()
|
||||||
|
{
|
||||||
|
std::vector<Friends> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Friends entry{};
|
||||||
|
|
||||||
|
entry.charid = atoi(row[0]);
|
||||||
|
entry.type = atoi(row[1]);
|
||||||
|
entry.name = row[2] ? row[2] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Friends> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<Friends> all_entries;
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Friends entry{};
|
||||||
|
|
||||||
|
entry.charid = atoi(row[0]);
|
||||||
|
entry.type = atoi(row[1]);
|
||||||
|
entry.name = row[2] ? row[2] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = database.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_FRIENDS_REPOSITORY_H
|
||||||
452
common/repositories/base/base_global_loot_repository.h
Normal file
452
common/repositories/base/base_global_loot_repository.h
Normal file
@ -0,0 +1,452 @@
|
|||||||
|
/**
|
||||||
|
* EQEmulator: Everquest Server Emulator
|
||||||
|
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
|
* are required to give you total support for your newly bought product;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to
|
||||||
|
* the repository extending the base. Any modifications to base repositories are to
|
||||||
|
* be made by the generator only
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_GLOBAL_LOOT_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_GLOBAL_LOOT_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../string_util.h"
|
||||||
|
|
||||||
|
class BaseGlobalLootRepository {
|
||||||
|
public:
|
||||||
|
struct GlobalLoot {
|
||||||
|
int id;
|
||||||
|
std::string description;
|
||||||
|
int loottable_id;
|
||||||
|
int enabled;
|
||||||
|
int min_level;
|
||||||
|
int max_level;
|
||||||
|
int rare;
|
||||||
|
int raid;
|
||||||
|
std::string race;
|
||||||
|
std::string class;
|
||||||
|
std::string bodytype;
|
||||||
|
std::string zone;
|
||||||
|
int hot_zone;
|
||||||
|
int min_expansion;
|
||||||
|
int max_expansion;
|
||||||
|
std::string content_flags;
|
||||||
|
std::string content_flags_disabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"description",
|
||||||
|
"loottable_id",
|
||||||
|
"enabled",
|
||||||
|
"min_level",
|
||||||
|
"max_level",
|
||||||
|
"rare",
|
||||||
|
"raid",
|
||||||
|
"race",
|
||||||
|
"class",
|
||||||
|
"bodytype",
|
||||||
|
"zone",
|
||||||
|
"hot_zone",
|
||||||
|
"min_expansion",
|
||||||
|
"max_expansion",
|
||||||
|
"content_flags",
|
||||||
|
"content_flags_disabled",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string InsertColumnsRaw()
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_columns;
|
||||||
|
|
||||||
|
for (auto &column : Columns()) {
|
||||||
|
if (column == PrimaryKey()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
insert_columns.push_back(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(implode(", ", insert_columns));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("global_loot");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
ColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
InsertColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GlobalLoot NewEntity()
|
||||||
|
{
|
||||||
|
GlobalLoot entry{};
|
||||||
|
|
||||||
|
entry.id = 0;
|
||||||
|
entry.description = "";
|
||||||
|
entry.loottable_id = 0;
|
||||||
|
entry.enabled = 1;
|
||||||
|
entry.min_level = 0;
|
||||||
|
entry.max_level = 0;
|
||||||
|
entry.rare = 0;
|
||||||
|
entry.raid = 0;
|
||||||
|
entry.race = "";
|
||||||
|
entry.class = "";
|
||||||
|
entry.bodytype = "";
|
||||||
|
entry.zone = "";
|
||||||
|
entry.hot_zone = 0;
|
||||||
|
entry.min_expansion = 0;
|
||||||
|
entry.max_expansion = 0;
|
||||||
|
entry.content_flags = "";
|
||||||
|
entry.content_flags_disabled = "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GlobalLoot GetGlobalLootEntry(
|
||||||
|
const std::vector<GlobalLoot> &global_loots,
|
||||||
|
int global_loot_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &global_loot : global_loots) {
|
||||||
|
if (global_loot.id == global_loot_id) {
|
||||||
|
return global_loot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static GlobalLoot FindOne(
|
||||||
|
int global_loot_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE id = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
global_loot_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
GlobalLoot entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.description = row[1] ? row[1] : "";
|
||||||
|
entry.loottable_id = atoi(row[2]);
|
||||||
|
entry.enabled = atoi(row[3]);
|
||||||
|
entry.min_level = atoi(row[4]);
|
||||||
|
entry.max_level = atoi(row[5]);
|
||||||
|
entry.rare = atoi(row[6]);
|
||||||
|
entry.raid = atoi(row[7]);
|
||||||
|
entry.race = row[8] ? row[8] : "";
|
||||||
|
entry.class = row[9] ? row[9] : "";
|
||||||
|
entry.bodytype = row[10] ? row[10] : "";
|
||||||
|
entry.zone = row[11] ? row[11] : "";
|
||||||
|
entry.hot_zone = atoi(row[12]);
|
||||||
|
entry.min_expansion = atoi(row[13]);
|
||||||
|
entry.max_expansion = atoi(row[14]);
|
||||||
|
entry.content_flags = row[15] ? row[15] : "";
|
||||||
|
entry.content_flags_disabled = row[16] ? row[16] : "";
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
int global_loot_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
global_loot_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
GlobalLoot global_loot_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> update_values;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
update_values.push_back(columns[1] + " = '" + EscapeString(global_loot_entry.description) + "'");
|
||||||
|
update_values.push_back(columns[2] + " = " + std::to_string(global_loot_entry.loottable_id));
|
||||||
|
update_values.push_back(columns[3] + " = " + std::to_string(global_loot_entry.enabled));
|
||||||
|
update_values.push_back(columns[4] + " = " + std::to_string(global_loot_entry.min_level));
|
||||||
|
update_values.push_back(columns[5] + " = " + std::to_string(global_loot_entry.max_level));
|
||||||
|
update_values.push_back(columns[6] + " = " + std::to_string(global_loot_entry.rare));
|
||||||
|
update_values.push_back(columns[7] + " = " + std::to_string(global_loot_entry.raid));
|
||||||
|
update_values.push_back(columns[8] + " = '" + EscapeString(global_loot_entry.race) + "'");
|
||||||
|
update_values.push_back(columns[9] + " = '" + EscapeString(global_loot_entry.class) + "'");
|
||||||
|
update_values.push_back(columns[10] + " = '" + EscapeString(global_loot_entry.bodytype) + "'");
|
||||||
|
update_values.push_back(columns[11] + " = '" + EscapeString(global_loot_entry.zone) + "'");
|
||||||
|
update_values.push_back(columns[12] + " = " + std::to_string(global_loot_entry.hot_zone));
|
||||||
|
update_values.push_back(columns[13] + " = " + std::to_string(global_loot_entry.min_expansion));
|
||||||
|
update_values.push_back(columns[14] + " = " + std::to_string(global_loot_entry.max_expansion));
|
||||||
|
update_values.push_back(columns[15] + " = '" + EscapeString(global_loot_entry.content_flags) + "'");
|
||||||
|
update_values.push_back(columns[16] + " = '" + EscapeString(global_loot_entry.content_flags_disabled) + "'");
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
implode(", ", update_values),
|
||||||
|
PrimaryKey(),
|
||||||
|
global_loot_entry.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GlobalLoot InsertOne(
|
||||||
|
GlobalLoot global_loot_entry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back("'" + EscapeString(global_loot_entry.description) + "'");
|
||||||
|
insert_values.push_back(std::to_string(global_loot_entry.loottable_id));
|
||||||
|
insert_values.push_back(std::to_string(global_loot_entry.enabled));
|
||||||
|
insert_values.push_back(std::to_string(global_loot_entry.min_level));
|
||||||
|
insert_values.push_back(std::to_string(global_loot_entry.max_level));
|
||||||
|
insert_values.push_back(std::to_string(global_loot_entry.rare));
|
||||||
|
insert_values.push_back(std::to_string(global_loot_entry.raid));
|
||||||
|
insert_values.push_back("'" + EscapeString(global_loot_entry.race) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(global_loot_entry.class) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(global_loot_entry.bodytype) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(global_loot_entry.zone) + "'");
|
||||||
|
insert_values.push_back(std::to_string(global_loot_entry.hot_zone));
|
||||||
|
insert_values.push_back(std::to_string(global_loot_entry.min_expansion));
|
||||||
|
insert_values.push_back(std::to_string(global_loot_entry.max_expansion));
|
||||||
|
insert_values.push_back("'" + EscapeString(global_loot_entry.content_flags) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(global_loot_entry.content_flags_disabled) + "'");
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_values)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
global_loot_entry.id = results.LastInsertedID();
|
||||||
|
return global_loot_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
global_loot_entry = NewEntity();
|
||||||
|
|
||||||
|
return global_loot_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
std::vector<GlobalLoot> global_loot_entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &global_loot_entry: global_loot_entries) {
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
insert_values.push_back("'" + EscapeString(global_loot_entry.description) + "'");
|
||||||
|
insert_values.push_back(std::to_string(global_loot_entry.loottable_id));
|
||||||
|
insert_values.push_back(std::to_string(global_loot_entry.enabled));
|
||||||
|
insert_values.push_back(std::to_string(global_loot_entry.min_level));
|
||||||
|
insert_values.push_back(std::to_string(global_loot_entry.max_level));
|
||||||
|
insert_values.push_back(std::to_string(global_loot_entry.rare));
|
||||||
|
insert_values.push_back(std::to_string(global_loot_entry.raid));
|
||||||
|
insert_values.push_back("'" + EscapeString(global_loot_entry.race) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(global_loot_entry.class) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(global_loot_entry.bodytype) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(global_loot_entry.zone) + "'");
|
||||||
|
insert_values.push_back(std::to_string(global_loot_entry.hot_zone));
|
||||||
|
insert_values.push_back(std::to_string(global_loot_entry.min_expansion));
|
||||||
|
insert_values.push_back(std::to_string(global_loot_entry.max_expansion));
|
||||||
|
insert_values.push_back("'" + EscapeString(global_loot_entry.content_flags) + "'");
|
||||||
|
insert_values.push_back("'" + EscapeString(global_loot_entry.content_flags_disabled) + "'");
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> insert_values;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<GlobalLoot> All()
|
||||||
|
{
|
||||||
|
std::vector<GlobalLoot> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
GlobalLoot entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.description = row[1] ? row[1] : "";
|
||||||
|
entry.loottable_id = atoi(row[2]);
|
||||||
|
entry.enabled = atoi(row[3]);
|
||||||
|
entry.min_level = atoi(row[4]);
|
||||||
|
entry.max_level = atoi(row[5]);
|
||||||
|
entry.rare = atoi(row[6]);
|
||||||
|
entry.raid = atoi(row[7]);
|
||||||
|
entry.race = row[8] ? row[8] : "";
|
||||||
|
entry.class = row[9] ? row[9] : "";
|
||||||
|
entry.bodytype = row[10] ? row[10] : "";
|
||||||
|
entry.zone = row[11] ? row[11] : "";
|
||||||
|
entry.hot_zone = atoi(row[12]);
|
||||||
|
entry.min_expansion = atoi(row[13]);
|
||||||
|
entry.max_expansion = atoi(row[14]);
|
||||||
|
entry.content_flags = row[15] ? row[15] : "";
|
||||||
|
entry.content_flags_disabled = row[16] ? row[16] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<GlobalLoot> GetWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
std::vector<GlobalLoot> all_entries;
|
||||||
|
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
GlobalLoot entry{};
|
||||||
|
|
||||||
|
entry.id = atoi(row[0]);
|
||||||
|
entry.description = row[1] ? row[1] : "";
|
||||||
|
entry.loottable_id = atoi(row[2]);
|
||||||
|
entry.enabled = atoi(row[3]);
|
||||||
|
entry.min_level = atoi(row[4]);
|
||||||
|
entry.max_level = atoi(row[5]);
|
||||||
|
entry.rare = atoi(row[6]);
|
||||||
|
entry.raid = atoi(row[7]);
|
||||||
|
entry.race = row[8] ? row[8] : "";
|
||||||
|
entry.class = row[9] ? row[9] : "";
|
||||||
|
entry.bodytype = row[10] ? row[10] : "";
|
||||||
|
entry.zone = row[11] ? row[11] : "";
|
||||||
|
entry.hot_zone = atoi(row[12]);
|
||||||
|
entry.min_expansion = atoi(row[13]);
|
||||||
|
entry.max_expansion = atoi(row[14]);
|
||||||
|
entry.content_flags = row[15] ? row[15] : "";
|
||||||
|
entry.content_flags_disabled = row[16] ? row[16] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(std::string where_filter)
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate()
|
||||||
|
{
|
||||||
|
auto results = content_db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_GLOBAL_LOOT_REPOSITORY_H
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user