diff --git a/common/repositories/base/base_character_expedition_lockouts_repository.h b/common/repositories/base/base_character_expedition_lockouts_repository.h new file mode 100644 index 000000000..f2e3ec874 --- /dev/null +++ b/common/repositories/base/base_character_expedition_lockouts_repository.h @@ -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_EXPEDITION_LOCKOUTS_REPOSITORY_H +#define EQEMU_BASE_CHARACTER_EXPEDITION_LOCKOUTS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseCharacterExpeditionLockoutsRepository { +public: + struct CharacterExpeditionLockouts { + int id; + int character_id; + std::string expedition_name; + std::string event_name; + std::string expire_time; + int duration; + std::string from_expedition_uuid; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "character_id", + "expedition_name", + "event_name", + "expire_time", + "duration", + "from_expedition_uuid", + }; + } + + static std::string ColumnsRaw() + { + return std::string(implode(", ", Columns())); + } + + static std::string InsertColumnsRaw() + { + std::vector 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_expedition_lockouts"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static CharacterExpeditionLockouts NewEntity() + { + CharacterExpeditionLockouts entry{}; + + entry.id = 0; + entry.character_id = 0; + entry.expedition_name = ""; + entry.event_name = ""; + entry.expire_time = current_timestamp(); + entry.duration = 0; + entry.from_expedition_uuid = ""; + + return entry; + } + + static CharacterExpeditionLockouts GetCharacterExpeditionLockoutsEntry( + const std::vector &character_expedition_lockoutss, + int character_expedition_lockouts_id + ) + { + for (auto &character_expedition_lockouts : character_expedition_lockoutss) { + if (character_expedition_lockouts.id == character_expedition_lockouts_id) { + return character_expedition_lockouts; + } + } + + return NewEntity(); + } + + static CharacterExpeditionLockouts FindOne( + int character_expedition_lockouts_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + character_expedition_lockouts_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + CharacterExpeditionLockouts entry{}; + + entry.id = atoi(row[0]); + entry.character_id = atoi(row[1]); + entry.expedition_name = row[2] ? row[2] : ""; + entry.event_name = row[3] ? row[3] : ""; + entry.expire_time = row[4] ? row[4] : ""; + entry.duration = atoi(row[5]); + entry.from_expedition_uuid = row[6] ? row[6] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int character_expedition_lockouts_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + character_expedition_lockouts_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + CharacterExpeditionLockouts character_expedition_lockouts_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(character_expedition_lockouts_entry.character_id)); + update_values.push_back(columns[2] + " = '" + EscapeString(character_expedition_lockouts_entry.expedition_name) + "'"); + update_values.push_back(columns[3] + " = '" + EscapeString(character_expedition_lockouts_entry.event_name) + "'"); + update_values.push_back(columns[4] + " = '" + EscapeString(character_expedition_lockouts_entry.expire_time) + "'"); + update_values.push_back(columns[5] + " = " + std::to_string(character_expedition_lockouts_entry.duration)); + update_values.push_back(columns[6] + " = '" + EscapeString(character_expedition_lockouts_entry.from_expedition_uuid) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + character_expedition_lockouts_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterExpeditionLockouts InsertOne( + CharacterExpeditionLockouts character_expedition_lockouts_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(character_expedition_lockouts_entry.character_id)); + insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.expedition_name) + "'"); + insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.event_name) + "'"); + insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.expire_time) + "'"); + insert_values.push_back(std::to_string(character_expedition_lockouts_entry.duration)); + insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.from_expedition_uuid) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + character_expedition_lockouts_entry.id = results.LastInsertedID(); + return character_expedition_lockouts_entry; + } + + character_expedition_lockouts_entry = NewEntity(); + + return character_expedition_lockouts_entry; + } + + static int InsertMany( + std::vector character_expedition_lockouts_entries + ) + { + std::vector insert_chunks; + + for (auto &character_expedition_lockouts_entry: character_expedition_lockouts_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(character_expedition_lockouts_entry.character_id)); + insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.expedition_name) + "'"); + insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.event_name) + "'"); + insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.expire_time) + "'"); + insert_values.push_back(std::to_string(character_expedition_lockouts_entry.duration)); + insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.from_expedition_uuid) + "'"); + + insert_chunks.push_back("(" + implode(",", insert_values) + ")"); + } + + std::vector insert_values; + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES {}", + BaseInsert(), + implode(",", insert_chunks) + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static std::vector All() + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{}", + BaseSelect() + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterExpeditionLockouts entry{}; + + entry.id = atoi(row[0]); + entry.character_id = atoi(row[1]); + entry.expedition_name = row[2] ? row[2] : ""; + entry.event_name = row[3] ? row[3] : ""; + entry.expire_time = row[4] ? row[4] : ""; + entry.duration = atoi(row[5]); + entry.from_expedition_uuid = row[6] ? row[6] : ""; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static std::vector GetWhere(std::string where_filter) + { + std::vector 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) { + CharacterExpeditionLockouts entry{}; + + entry.id = atoi(row[0]); + entry.character_id = atoi(row[1]); + entry.expedition_name = row[2] ? row[2] : ""; + entry.event_name = row[3] ? row[3] : ""; + entry.expire_time = row[4] ? row[4] : ""; + entry.duration = atoi(row[5]); + entry.from_expedition_uuid = row[6] ? 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_EXPEDITION_LOCKOUTS_REPOSITORY_H diff --git a/common/repositories/base/base_character_pet_info_repository.h b/common/repositories/base/base_character_pet_info_repository.h index b4d795745..5432109ea 100644 --- a/common/repositories/base/base_character_pet_info_repository.h +++ b/common/repositories/base/base_character_pet_info_repository.h @@ -43,6 +43,7 @@ public: int hp; int mana; float size; + int taunting; }; static std::string PrimaryKey() @@ -61,6 +62,7 @@ public: "hp", "mana", "size", + "taunting", }; } @@ -119,6 +121,7 @@ public: entry.hp = 0; entry.mana = 0; entry.size = 0; + entry.taunting = 1; return entry; } @@ -161,6 +164,7 @@ public: entry.hp = atoi(row[5]); entry.mana = atoi(row[6]); entry.size = static_cast(atof(row[7])); + entry.taunting = atoi(row[8]); return entry; } @@ -200,6 +204,7 @@ public: 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)); + update_values.push_back(columns[8] + " = " + std::to_string(character_pet_info_entry.taunting)); auto results = database.QueryDatabase( fmt::format( @@ -228,6 +233,7 @@ public: 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_values.push_back(std::to_string(character_pet_info_entry.taunting)); auto results = database.QueryDatabase( fmt::format( @@ -264,6 +270,7 @@ public: 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_values.push_back(std::to_string(character_pet_info_entry.taunting)); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } @@ -305,6 +312,7 @@ public: entry.hp = atoi(row[5]); entry.mana = atoi(row[6]); entry.size = static_cast(atof(row[7])); + entry.taunting = atoi(row[8]); all_entries.push_back(entry); } @@ -337,6 +345,7 @@ public: entry.hp = atoi(row[5]); entry.mana = atoi(row[6]); entry.size = static_cast(atof(row[7])); + entry.taunting = atoi(row[8]); all_entries.push_back(entry); } diff --git a/common/repositories/base/base_damageshieldtypes_repository.h b/common/repositories/base/base_damageshieldtypes_repository.h new file mode 100644 index 000000000..bce2af3b6 --- /dev/null +++ b/common/repositories/base/base_damageshieldtypes_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_DAMAGESHIELDTYPES_REPOSITORY_H +#define EQEMU_BASE_DAMAGESHIELDTYPES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseDamageshieldtypesRepository { +public: + struct Damageshieldtypes { + int spellid; + int type; + }; + + static std::string PrimaryKey() + { + return std::string("spellid"); + } + + static std::vector Columns() + { + return { + "spellid", + "type", + }; + } + + static std::string ColumnsRaw() + { + return std::string(implode(", ", Columns())); + } + + static std::string InsertColumnsRaw() + { + std::vector 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("damageshieldtypes"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Damageshieldtypes NewEntity() + { + Damageshieldtypes entry{}; + + entry.spellid = 0; + entry.type = 0; + + return entry; + } + + static Damageshieldtypes GetDamageshieldtypesEntry( + const std::vector &damageshieldtypess, + int damageshieldtypes_id + ) + { + for (auto &damageshieldtypes : damageshieldtypess) { + if (damageshieldtypes.spellid == damageshieldtypes_id) { + return damageshieldtypes; + } + } + + return NewEntity(); + } + + static Damageshieldtypes FindOne( + int damageshieldtypes_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + damageshieldtypes_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Damageshieldtypes entry{}; + + entry.spellid = atoi(row[0]); + entry.type = atoi(row[1]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int damageshieldtypes_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + damageshieldtypes_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Damageshieldtypes damageshieldtypes_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[0] + " = " + std::to_string(damageshieldtypes_entry.spellid)); + update_values.push_back(columns[1] + " = " + std::to_string(damageshieldtypes_entry.type)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + damageshieldtypes_entry.spellid + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Damageshieldtypes InsertOne( + Damageshieldtypes damageshieldtypes_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(damageshieldtypes_entry.spellid)); + insert_values.push_back(std::to_string(damageshieldtypes_entry.type)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + damageshieldtypes_entry.spellid = results.LastInsertedID(); + return damageshieldtypes_entry; + } + + damageshieldtypes_entry = NewEntity(); + + return damageshieldtypes_entry; + } + + static int InsertMany( + std::vector damageshieldtypes_entries + ) + { + std::vector insert_chunks; + + for (auto &damageshieldtypes_entry: damageshieldtypes_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(damageshieldtypes_entry.spellid)); + insert_values.push_back(std::to_string(damageshieldtypes_entry.type)); + + insert_chunks.push_back("(" + implode(",", insert_values) + ")"); + } + + std::vector insert_values; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES {}", + BaseInsert(), + implode(",", insert_chunks) + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static std::vector All() + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{}", + BaseSelect() + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Damageshieldtypes entry{}; + + entry.spellid = atoi(row[0]); + entry.type = atoi(row[1]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static std::vector GetWhere(std::string where_filter) + { + std::vector 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) { + Damageshieldtypes entry{}; + + entry.spellid = atoi(row[0]); + entry.type = 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_DAMAGESHIELDTYPES_REPOSITORY_H diff --git a/common/repositories/base/base_dynamic_zones_repository.h b/common/repositories/base/base_dynamic_zones_repository.h new file mode 100644 index 000000000..fff2033c8 --- /dev/null +++ b/common/repositories/base/base_dynamic_zones_repository.h @@ -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_DYNAMIC_ZONES_REPOSITORY_H +#define EQEMU_BASE_DYNAMIC_ZONES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseDynamicZonesRepository { +public: + struct DynamicZones { + int id; + int instance_id; + int type; + int compass_zone_id; + float compass_x; + float compass_y; + float compass_z; + int safe_return_zone_id; + float safe_return_x; + float safe_return_y; + float safe_return_z; + float safe_return_heading; + float zone_in_x; + float zone_in_y; + float zone_in_z; + float zone_in_heading; + int has_zone_in; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "instance_id", + "type", + "compass_zone_id", + "compass_x", + "compass_y", + "compass_z", + "safe_return_zone_id", + "safe_return_x", + "safe_return_y", + "safe_return_z", + "safe_return_heading", + "zone_in_x", + "zone_in_y", + "zone_in_z", + "zone_in_heading", + "has_zone_in", + }; + } + + static std::string ColumnsRaw() + { + return std::string(implode(", ", Columns())); + } + + static std::string InsertColumnsRaw() + { + std::vector 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("dynamic_zones"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static DynamicZones NewEntity() + { + DynamicZones entry{}; + + entry.id = 0; + entry.instance_id = 0; + entry.type = 0; + entry.compass_zone_id = 0; + entry.compass_x = 0; + entry.compass_y = 0; + entry.compass_z = 0; + entry.safe_return_zone_id = 0; + entry.safe_return_x = 0; + entry.safe_return_y = 0; + entry.safe_return_z = 0; + entry.safe_return_heading = 0; + entry.zone_in_x = 0; + entry.zone_in_y = 0; + entry.zone_in_z = 0; + entry.zone_in_heading = 0; + entry.has_zone_in = 0; + + return entry; + } + + static DynamicZones GetDynamicZonesEntry( + const std::vector &dynamic_zoness, + int dynamic_zones_id + ) + { + for (auto &dynamic_zones : dynamic_zoness) { + if (dynamic_zones.id == dynamic_zones_id) { + return dynamic_zones; + } + } + + return NewEntity(); + } + + static DynamicZones FindOne( + int dynamic_zones_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + dynamic_zones_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + DynamicZones entry{}; + + entry.id = atoi(row[0]); + entry.instance_id = atoi(row[1]); + entry.type = atoi(row[2]); + entry.compass_zone_id = atoi(row[3]); + entry.compass_x = static_cast(atof(row[4])); + entry.compass_y = static_cast(atof(row[5])); + entry.compass_z = static_cast(atof(row[6])); + entry.safe_return_zone_id = atoi(row[7]); + entry.safe_return_x = static_cast(atof(row[8])); + entry.safe_return_y = static_cast(atof(row[9])); + entry.safe_return_z = static_cast(atof(row[10])); + entry.safe_return_heading = static_cast(atof(row[11])); + entry.zone_in_x = static_cast(atof(row[12])); + entry.zone_in_y = static_cast(atof(row[13])); + entry.zone_in_z = static_cast(atof(row[14])); + entry.zone_in_heading = static_cast(atof(row[15])); + entry.has_zone_in = atoi(row[16]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int dynamic_zones_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + dynamic_zones_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + DynamicZones dynamic_zones_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(dynamic_zones_entry.instance_id)); + update_values.push_back(columns[2] + " = " + std::to_string(dynamic_zones_entry.type)); + update_values.push_back(columns[3] + " = " + std::to_string(dynamic_zones_entry.compass_zone_id)); + update_values.push_back(columns[4] + " = " + std::to_string(dynamic_zones_entry.compass_x)); + update_values.push_back(columns[5] + " = " + std::to_string(dynamic_zones_entry.compass_y)); + update_values.push_back(columns[6] + " = " + std::to_string(dynamic_zones_entry.compass_z)); + update_values.push_back(columns[7] + " = " + std::to_string(dynamic_zones_entry.safe_return_zone_id)); + update_values.push_back(columns[8] + " = " + std::to_string(dynamic_zones_entry.safe_return_x)); + update_values.push_back(columns[9] + " = " + std::to_string(dynamic_zones_entry.safe_return_y)); + update_values.push_back(columns[10] + " = " + std::to_string(dynamic_zones_entry.safe_return_z)); + update_values.push_back(columns[11] + " = " + std::to_string(dynamic_zones_entry.safe_return_heading)); + update_values.push_back(columns[12] + " = " + std::to_string(dynamic_zones_entry.zone_in_x)); + update_values.push_back(columns[13] + " = " + std::to_string(dynamic_zones_entry.zone_in_y)); + update_values.push_back(columns[14] + " = " + std::to_string(dynamic_zones_entry.zone_in_z)); + update_values.push_back(columns[15] + " = " + std::to_string(dynamic_zones_entry.zone_in_heading)); + update_values.push_back(columns[16] + " = " + std::to_string(dynamic_zones_entry.has_zone_in)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + dynamic_zones_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static DynamicZones InsertOne( + DynamicZones dynamic_zones_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(dynamic_zones_entry.instance_id)); + insert_values.push_back(std::to_string(dynamic_zones_entry.type)); + insert_values.push_back(std::to_string(dynamic_zones_entry.compass_zone_id)); + insert_values.push_back(std::to_string(dynamic_zones_entry.compass_x)); + insert_values.push_back(std::to_string(dynamic_zones_entry.compass_y)); + insert_values.push_back(std::to_string(dynamic_zones_entry.compass_z)); + insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_zone_id)); + insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_x)); + insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_y)); + insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_z)); + insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_heading)); + insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_x)); + insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_y)); + insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_z)); + insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_heading)); + insert_values.push_back(std::to_string(dynamic_zones_entry.has_zone_in)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + dynamic_zones_entry.id = results.LastInsertedID(); + return dynamic_zones_entry; + } + + dynamic_zones_entry = NewEntity(); + + return dynamic_zones_entry; + } + + static int InsertMany( + std::vector dynamic_zones_entries + ) + { + std::vector insert_chunks; + + for (auto &dynamic_zones_entry: dynamic_zones_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(dynamic_zones_entry.instance_id)); + insert_values.push_back(std::to_string(dynamic_zones_entry.type)); + insert_values.push_back(std::to_string(dynamic_zones_entry.compass_zone_id)); + insert_values.push_back(std::to_string(dynamic_zones_entry.compass_x)); + insert_values.push_back(std::to_string(dynamic_zones_entry.compass_y)); + insert_values.push_back(std::to_string(dynamic_zones_entry.compass_z)); + insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_zone_id)); + insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_x)); + insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_y)); + insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_z)); + insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_heading)); + insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_x)); + insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_y)); + insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_z)); + insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_heading)); + insert_values.push_back(std::to_string(dynamic_zones_entry.has_zone_in)); + + insert_chunks.push_back("(" + implode(",", insert_values) + ")"); + } + + std::vector insert_values; + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES {}", + BaseInsert(), + implode(",", insert_chunks) + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static std::vector All() + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{}", + BaseSelect() + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + DynamicZones entry{}; + + entry.id = atoi(row[0]); + entry.instance_id = atoi(row[1]); + entry.type = atoi(row[2]); + entry.compass_zone_id = atoi(row[3]); + entry.compass_x = static_cast(atof(row[4])); + entry.compass_y = static_cast(atof(row[5])); + entry.compass_z = static_cast(atof(row[6])); + entry.safe_return_zone_id = atoi(row[7]); + entry.safe_return_x = static_cast(atof(row[8])); + entry.safe_return_y = static_cast(atof(row[9])); + entry.safe_return_z = static_cast(atof(row[10])); + entry.safe_return_heading = static_cast(atof(row[11])); + entry.zone_in_x = static_cast(atof(row[12])); + entry.zone_in_y = static_cast(atof(row[13])); + entry.zone_in_z = static_cast(atof(row[14])); + entry.zone_in_heading = static_cast(atof(row[15])); + entry.has_zone_in = atoi(row[16]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static std::vector GetWhere(std::string where_filter) + { + std::vector 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) { + DynamicZones entry{}; + + entry.id = atoi(row[0]); + entry.instance_id = atoi(row[1]); + entry.type = atoi(row[2]); + entry.compass_zone_id = atoi(row[3]); + entry.compass_x = static_cast(atof(row[4])); + entry.compass_y = static_cast(atof(row[5])); + entry.compass_z = static_cast(atof(row[6])); + entry.safe_return_zone_id = atoi(row[7]); + entry.safe_return_x = static_cast(atof(row[8])); + entry.safe_return_y = static_cast(atof(row[9])); + entry.safe_return_z = static_cast(atof(row[10])); + entry.safe_return_heading = static_cast(atof(row[11])); + entry.zone_in_x = static_cast(atof(row[12])); + entry.zone_in_y = static_cast(atof(row[13])); + entry.zone_in_z = static_cast(atof(row[14])); + entry.zone_in_heading = static_cast(atof(row[15])); + entry.has_zone_in = 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_DYNAMIC_ZONES_REPOSITORY_H diff --git a/common/repositories/base/base_expedition_lockouts_repository.h b/common/repositories/base/base_expedition_lockouts_repository.h new file mode 100644 index 000000000..a6cdf691d --- /dev/null +++ b/common/repositories/base/base_expedition_lockouts_repository.h @@ -0,0 +1,353 @@ +/** + * 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_EXPEDITION_LOCKOUTS_REPOSITORY_H +#define EQEMU_BASE_EXPEDITION_LOCKOUTS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseExpeditionLockoutsRepository { +public: + struct ExpeditionLockouts { + int id; + int expedition_id; + std::string event_name; + std::string expire_time; + int duration; + std::string from_expedition_uuid; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "expedition_id", + "event_name", + "expire_time", + "duration", + "from_expedition_uuid", + }; + } + + static std::string ColumnsRaw() + { + return std::string(implode(", ", Columns())); + } + + static std::string InsertColumnsRaw() + { + std::vector 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("expedition_lockouts"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static ExpeditionLockouts NewEntity() + { + ExpeditionLockouts entry{}; + + entry.id = 0; + entry.expedition_id = 0; + entry.event_name = ""; + entry.expire_time = current_timestamp(); + entry.duration = 0; + entry.from_expedition_uuid = ""; + + return entry; + } + + static ExpeditionLockouts GetExpeditionLockoutsEntry( + const std::vector &expedition_lockoutss, + int expedition_lockouts_id + ) + { + for (auto &expedition_lockouts : expedition_lockoutss) { + if (expedition_lockouts.id == expedition_lockouts_id) { + return expedition_lockouts; + } + } + + return NewEntity(); + } + + static ExpeditionLockouts FindOne( + int expedition_lockouts_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + expedition_lockouts_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + ExpeditionLockouts entry{}; + + entry.id = atoi(row[0]); + entry.expedition_id = atoi(row[1]); + entry.event_name = row[2] ? row[2] : ""; + entry.expire_time = row[3] ? row[3] : ""; + entry.duration = atoi(row[4]); + entry.from_expedition_uuid = row[5] ? row[5] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int expedition_lockouts_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + expedition_lockouts_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + ExpeditionLockouts expedition_lockouts_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(expedition_lockouts_entry.expedition_id)); + update_values.push_back(columns[2] + " = '" + EscapeString(expedition_lockouts_entry.event_name) + "'"); + update_values.push_back(columns[3] + " = '" + EscapeString(expedition_lockouts_entry.expire_time) + "'"); + update_values.push_back(columns[4] + " = " + std::to_string(expedition_lockouts_entry.duration)); + update_values.push_back(columns[5] + " = '" + EscapeString(expedition_lockouts_entry.from_expedition_uuid) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + expedition_lockouts_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static ExpeditionLockouts InsertOne( + ExpeditionLockouts expedition_lockouts_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(expedition_lockouts_entry.expedition_id)); + insert_values.push_back("'" + EscapeString(expedition_lockouts_entry.event_name) + "'"); + insert_values.push_back("'" + EscapeString(expedition_lockouts_entry.expire_time) + "'"); + insert_values.push_back(std::to_string(expedition_lockouts_entry.duration)); + insert_values.push_back("'" + EscapeString(expedition_lockouts_entry.from_expedition_uuid) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + expedition_lockouts_entry.id = results.LastInsertedID(); + return expedition_lockouts_entry; + } + + expedition_lockouts_entry = NewEntity(); + + return expedition_lockouts_entry; + } + + static int InsertMany( + std::vector expedition_lockouts_entries + ) + { + std::vector insert_chunks; + + for (auto &expedition_lockouts_entry: expedition_lockouts_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(expedition_lockouts_entry.expedition_id)); + insert_values.push_back("'" + EscapeString(expedition_lockouts_entry.event_name) + "'"); + insert_values.push_back("'" + EscapeString(expedition_lockouts_entry.expire_time) + "'"); + insert_values.push_back(std::to_string(expedition_lockouts_entry.duration)); + insert_values.push_back("'" + EscapeString(expedition_lockouts_entry.from_expedition_uuid) + "'"); + + insert_chunks.push_back("(" + implode(",", insert_values) + ")"); + } + + std::vector insert_values; + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES {}", + BaseInsert(), + implode(",", insert_chunks) + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static std::vector All() + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{}", + BaseSelect() + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + ExpeditionLockouts entry{}; + + entry.id = atoi(row[0]); + entry.expedition_id = atoi(row[1]); + entry.event_name = row[2] ? row[2] : ""; + entry.expire_time = row[3] ? row[3] : ""; + entry.duration = atoi(row[4]); + entry.from_expedition_uuid = row[5] ? row[5] : ""; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static std::vector GetWhere(std::string where_filter) + { + std::vector 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) { + ExpeditionLockouts entry{}; + + entry.id = atoi(row[0]); + entry.expedition_id = atoi(row[1]); + entry.event_name = row[2] ? row[2] : ""; + entry.expire_time = row[3] ? row[3] : ""; + entry.duration = atoi(row[4]); + entry.from_expedition_uuid = 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_EXPEDITION_LOCKOUTS_REPOSITORY_H diff --git a/common/repositories/base/base_expedition_members_repository.h b/common/repositories/base/base_expedition_members_repository.h new file mode 100644 index 000000000..e3a9d79e1 --- /dev/null +++ b/common/repositories/base/base_expedition_members_repository.h @@ -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_EXPEDITION_MEMBERS_REPOSITORY_H +#define EQEMU_BASE_EXPEDITION_MEMBERS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseExpeditionMembersRepository { +public: + struct ExpeditionMembers { + int id; + int expedition_id; + int character_id; + int is_current_member; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "expedition_id", + "character_id", + "is_current_member", + }; + } + + static std::string ColumnsRaw() + { + return std::string(implode(", ", Columns())); + } + + static std::string InsertColumnsRaw() + { + std::vector 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("expedition_members"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static ExpeditionMembers NewEntity() + { + ExpeditionMembers entry{}; + + entry.id = 0; + entry.expedition_id = 0; + entry.character_id = 0; + entry.is_current_member = 1; + + return entry; + } + + static ExpeditionMembers GetExpeditionMembersEntry( + const std::vector &expedition_memberss, + int expedition_members_id + ) + { + for (auto &expedition_members : expedition_memberss) { + if (expedition_members.id == expedition_members_id) { + return expedition_members; + } + } + + return NewEntity(); + } + + static ExpeditionMembers FindOne( + int expedition_members_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + expedition_members_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + ExpeditionMembers entry{}; + + entry.id = atoi(row[0]); + entry.expedition_id = atoi(row[1]); + entry.character_id = atoi(row[2]); + entry.is_current_member = atoi(row[3]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int expedition_members_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + expedition_members_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + ExpeditionMembers expedition_members_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(expedition_members_entry.expedition_id)); + update_values.push_back(columns[2] + " = " + std::to_string(expedition_members_entry.character_id)); + update_values.push_back(columns[3] + " = " + std::to_string(expedition_members_entry.is_current_member)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + expedition_members_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static ExpeditionMembers InsertOne( + ExpeditionMembers expedition_members_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(expedition_members_entry.expedition_id)); + insert_values.push_back(std::to_string(expedition_members_entry.character_id)); + insert_values.push_back(std::to_string(expedition_members_entry.is_current_member)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + expedition_members_entry.id = results.LastInsertedID(); + return expedition_members_entry; + } + + expedition_members_entry = NewEntity(); + + return expedition_members_entry; + } + + static int InsertMany( + std::vector expedition_members_entries + ) + { + std::vector insert_chunks; + + for (auto &expedition_members_entry: expedition_members_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(expedition_members_entry.expedition_id)); + insert_values.push_back(std::to_string(expedition_members_entry.character_id)); + insert_values.push_back(std::to_string(expedition_members_entry.is_current_member)); + + insert_chunks.push_back("(" + implode(",", insert_values) + ")"); + } + + std::vector insert_values; + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES {}", + BaseInsert(), + implode(",", insert_chunks) + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static std::vector All() + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{}", + BaseSelect() + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + ExpeditionMembers entry{}; + + entry.id = atoi(row[0]); + entry.expedition_id = atoi(row[1]); + entry.character_id = atoi(row[2]); + entry.is_current_member = atoi(row[3]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static std::vector GetWhere(std::string where_filter) + { + std::vector 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) { + ExpeditionMembers entry{}; + + entry.id = atoi(row[0]); + entry.expedition_id = atoi(row[1]); + entry.character_id = atoi(row[2]); + entry.is_current_member = 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_EXPEDITION_MEMBERS_REPOSITORY_H diff --git a/common/repositories/base/base_expeditions_repository.h b/common/repositories/base/base_expeditions_repository.h new file mode 100644 index 000000000..bd97c5c50 --- /dev/null +++ b/common/repositories/base/base_expeditions_repository.h @@ -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_EXPEDITIONS_REPOSITORY_H +#define EQEMU_BASE_EXPEDITIONS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseExpeditionsRepository { +public: + struct Expeditions { + int id; + std::string uuid; + int dynamic_zone_id; + std::string expedition_name; + int leader_id; + int min_players; + int max_players; + int add_replay_on_join; + int is_locked; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "uuid", + "dynamic_zone_id", + "expedition_name", + "leader_id", + "min_players", + "max_players", + "add_replay_on_join", + "is_locked", + }; + } + + static std::string ColumnsRaw() + { + return std::string(implode(", ", Columns())); + } + + static std::string InsertColumnsRaw() + { + std::vector 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("expeditions"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Expeditions NewEntity() + { + Expeditions entry{}; + + entry.id = 0; + entry.uuid = ""; + entry.dynamic_zone_id = 0; + entry.expedition_name = ""; + entry.leader_id = 0; + entry.min_players = 0; + entry.max_players = 0; + entry.add_replay_on_join = 1; + entry.is_locked = 0; + + return entry; + } + + static Expeditions GetExpeditionsEntry( + const std::vector &expeditionss, + int expeditions_id + ) + { + for (auto &expeditions : expeditionss) { + if (expeditions.id == expeditions_id) { + return expeditions; + } + } + + return NewEntity(); + } + + static Expeditions FindOne( + int expeditions_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + expeditions_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Expeditions entry{}; + + entry.id = atoi(row[0]); + entry.uuid = row[1] ? row[1] : ""; + entry.dynamic_zone_id = atoi(row[2]); + entry.expedition_name = row[3] ? row[3] : ""; + entry.leader_id = atoi(row[4]); + entry.min_players = atoi(row[5]); + entry.max_players = atoi(row[6]); + entry.add_replay_on_join = atoi(row[7]); + entry.is_locked = atoi(row[8]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int expeditions_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + expeditions_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Expeditions expeditions_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(expeditions_entry.uuid) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(expeditions_entry.dynamic_zone_id)); + update_values.push_back(columns[3] + " = '" + EscapeString(expeditions_entry.expedition_name) + "'"); + update_values.push_back(columns[4] + " = " + std::to_string(expeditions_entry.leader_id)); + update_values.push_back(columns[5] + " = " + std::to_string(expeditions_entry.min_players)); + update_values.push_back(columns[6] + " = " + std::to_string(expeditions_entry.max_players)); + update_values.push_back(columns[7] + " = " + std::to_string(expeditions_entry.add_replay_on_join)); + update_values.push_back(columns[8] + " = " + std::to_string(expeditions_entry.is_locked)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + expeditions_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Expeditions InsertOne( + Expeditions expeditions_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(expeditions_entry.uuid) + "'"); + insert_values.push_back(std::to_string(expeditions_entry.dynamic_zone_id)); + insert_values.push_back("'" + EscapeString(expeditions_entry.expedition_name) + "'"); + insert_values.push_back(std::to_string(expeditions_entry.leader_id)); + insert_values.push_back(std::to_string(expeditions_entry.min_players)); + insert_values.push_back(std::to_string(expeditions_entry.max_players)); + insert_values.push_back(std::to_string(expeditions_entry.add_replay_on_join)); + insert_values.push_back(std::to_string(expeditions_entry.is_locked)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + expeditions_entry.id = results.LastInsertedID(); + return expeditions_entry; + } + + expeditions_entry = NewEntity(); + + return expeditions_entry; + } + + static int InsertMany( + std::vector expeditions_entries + ) + { + std::vector insert_chunks; + + for (auto &expeditions_entry: expeditions_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(expeditions_entry.uuid) + "'"); + insert_values.push_back(std::to_string(expeditions_entry.dynamic_zone_id)); + insert_values.push_back("'" + EscapeString(expeditions_entry.expedition_name) + "'"); + insert_values.push_back(std::to_string(expeditions_entry.leader_id)); + insert_values.push_back(std::to_string(expeditions_entry.min_players)); + insert_values.push_back(std::to_string(expeditions_entry.max_players)); + insert_values.push_back(std::to_string(expeditions_entry.add_replay_on_join)); + insert_values.push_back(std::to_string(expeditions_entry.is_locked)); + + insert_chunks.push_back("(" + implode(",", insert_values) + ")"); + } + + std::vector insert_values; + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES {}", + BaseInsert(), + implode(",", insert_chunks) + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static std::vector All() + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{}", + BaseSelect() + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Expeditions entry{}; + + entry.id = atoi(row[0]); + entry.uuid = row[1] ? row[1] : ""; + entry.dynamic_zone_id = atoi(row[2]); + entry.expedition_name = row[3] ? row[3] : ""; + entry.leader_id = atoi(row[4]); + entry.min_players = atoi(row[5]); + entry.max_players = atoi(row[6]); + entry.add_replay_on_join = atoi(row[7]); + entry.is_locked = atoi(row[8]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static std::vector GetWhere(std::string where_filter) + { + std::vector 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) { + Expeditions entry{}; + + entry.id = atoi(row[0]); + entry.uuid = row[1] ? row[1] : ""; + entry.dynamic_zone_id = atoi(row[2]); + entry.expedition_name = row[3] ? row[3] : ""; + entry.leader_id = atoi(row[4]); + entry.min_players = atoi(row[5]); + entry.max_players = atoi(row[6]); + entry.add_replay_on_join = atoi(row[7]); + entry.is_locked = 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_EXPEDITIONS_REPOSITORY_H diff --git a/common/repositories/base/base_zone_repository.h b/common/repositories/base/base_zone_repository.h index 83c18086a..c20279198 100644 --- a/common/repositories/base/base_zone_repository.h +++ b/common/repositories/base/base_zone_repository.h @@ -125,6 +125,7 @@ public: int max_expansion; std::string content_flags; std::string content_flags_disabled; + int underworld_teleport_index; }; static std::string PrimaryKey() @@ -225,6 +226,7 @@ public: "max_expansion", "content_flags", "content_flags_disabled", + "underworld_teleport_index", }; } @@ -365,6 +367,7 @@ public: entry.max_expansion = 0; entry.content_flags = ""; entry.content_flags_disabled = ""; + entry.underworld_teleport_index = 0; return entry; } @@ -489,6 +492,7 @@ public: entry.max_expansion = atoi(row[87]); entry.content_flags = row[88] ? row[88] : ""; entry.content_flags_disabled = row[89] ? row[89] : ""; + entry.underworld_teleport_index = atoi(row[90]); return entry; } @@ -609,6 +613,7 @@ public: update_values.push_back(columns[87] + " = " + std::to_string(zone_entry.max_expansion)); update_values.push_back(columns[88] + " = '" + EscapeString(zone_entry.content_flags) + "'"); update_values.push_back(columns[89] + " = '" + EscapeString(zone_entry.content_flags_disabled) + "'"); + update_values.push_back(columns[90] + " = " + std::to_string(zone_entry.underworld_teleport_index)); auto results = content_db.QueryDatabase( fmt::format( @@ -718,6 +723,7 @@ public: insert_values.push_back(std::to_string(zone_entry.max_expansion)); insert_values.push_back("'" + EscapeString(zone_entry.content_flags) + "'"); insert_values.push_back("'" + EscapeString(zone_entry.content_flags_disabled) + "'"); + insert_values.push_back(std::to_string(zone_entry.underworld_teleport_index)); auto results = content_db.QueryDatabase( fmt::format( @@ -835,6 +841,7 @@ public: insert_values.push_back(std::to_string(zone_entry.max_expansion)); insert_values.push_back("'" + EscapeString(zone_entry.content_flags) + "'"); insert_values.push_back("'" + EscapeString(zone_entry.content_flags_disabled) + "'"); + insert_values.push_back(std::to_string(zone_entry.underworld_teleport_index)); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } @@ -958,6 +965,7 @@ public: entry.max_expansion = atoi(row[87]); entry.content_flags = row[88] ? row[88] : ""; entry.content_flags_disabled = row[89] ? row[89] : ""; + entry.underworld_teleport_index = atoi(row[90]); all_entries.push_back(entry); } @@ -1072,6 +1080,7 @@ public: entry.max_expansion = atoi(row[87]); entry.content_flags = row[88] ? row[88] : ""; entry.content_flags_disabled = row[89] ? row[89] : ""; + entry.underworld_teleport_index = atoi(row[90]); all_entries.push_back(entry); } diff --git a/common/repositories/character_expedition_lockouts_repository.h b/common/repositories/character_expedition_lockouts_repository.h new file mode 100644 index 000000000..47ffaf7ee --- /dev/null +++ b/common/repositories/character_expedition_lockouts_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_CHARACTER_EXPEDITION_LOCKOUTS_REPOSITORY_H +#define EQEMU_CHARACTER_EXPEDITION_LOCKOUTS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_expedition_lockouts_repository.h" + +class CharacterExpeditionLockoutsRepository: public BaseCharacterExpeditionLockoutsRepository { +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 + * + * CharacterExpeditionLockoutsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterExpeditionLockoutsRepository::GetWhereNeverExpires() + * CharacterExpeditionLockoutsRepository::GetWhereXAndY() + * CharacterExpeditionLockoutsRepository::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_CHARACTER_EXPEDITION_LOCKOUTS_REPOSITORY_H diff --git a/common/repositories/damageshieldtypes_repository.h b/common/repositories/damageshieldtypes_repository.h new file mode 100644 index 000000000..3bb4b4fd2 --- /dev/null +++ b/common/repositories/damageshieldtypes_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_DAMAGESHIELDTYPES_REPOSITORY_H +#define EQEMU_DAMAGESHIELDTYPES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_damageshieldtypes_repository.h" + +class DamageshieldtypesRepository: public BaseDamageshieldtypesRepository { +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 + * + * DamageshieldtypesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * DamageshieldtypesRepository::GetWhereNeverExpires() + * DamageshieldtypesRepository::GetWhereXAndY() + * DamageshieldtypesRepository::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_DAMAGESHIELDTYPES_REPOSITORY_H diff --git a/common/repositories/dynamic_zones_repository.h b/common/repositories/dynamic_zones_repository.h new file mode 100644 index 000000000..03435457c --- /dev/null +++ b/common/repositories/dynamic_zones_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_DYNAMIC_ZONES_REPOSITORY_H +#define EQEMU_DYNAMIC_ZONES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_dynamic_zones_repository.h" + +class DynamicZonesRepository: public BaseDynamicZonesRepository { +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 + * + * DynamicZonesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * DynamicZonesRepository::GetWhereNeverExpires() + * DynamicZonesRepository::GetWhereXAndY() + * DynamicZonesRepository::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_DYNAMIC_ZONES_REPOSITORY_H diff --git a/common/repositories/expedition_lockouts_repository.h b/common/repositories/expedition_lockouts_repository.h new file mode 100644 index 000000000..0f33c4209 --- /dev/null +++ b/common/repositories/expedition_lockouts_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_EXPEDITION_LOCKOUTS_REPOSITORY_H +#define EQEMU_EXPEDITION_LOCKOUTS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_expedition_lockouts_repository.h" + +class ExpeditionLockoutsRepository: public BaseExpeditionLockoutsRepository { +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 + * + * ExpeditionLockoutsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * ExpeditionLockoutsRepository::GetWhereNeverExpires() + * ExpeditionLockoutsRepository::GetWhereXAndY() + * ExpeditionLockoutsRepository::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_EXPEDITION_LOCKOUTS_REPOSITORY_H diff --git a/common/repositories/expedition_members_repository.h b/common/repositories/expedition_members_repository.h new file mode 100644 index 000000000..87304a99b --- /dev/null +++ b/common/repositories/expedition_members_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_EXPEDITION_MEMBERS_REPOSITORY_H +#define EQEMU_EXPEDITION_MEMBERS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_expedition_members_repository.h" + +class ExpeditionMembersRepository: public BaseExpeditionMembersRepository { +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 + * + * ExpeditionMembersRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * ExpeditionMembersRepository::GetWhereNeverExpires() + * ExpeditionMembersRepository::GetWhereXAndY() + * ExpeditionMembersRepository::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_EXPEDITION_MEMBERS_REPOSITORY_H diff --git a/common/repositories/expeditions_repository.h b/common/repositories/expeditions_repository.h new file mode 100644 index 000000000..a570ab588 --- /dev/null +++ b/common/repositories/expeditions_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_EXPEDITIONS_REPOSITORY_H +#define EQEMU_EXPEDITIONS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_expeditions_repository.h" + +class ExpeditionsRepository: public BaseExpeditionsRepository { +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 + * + * ExpeditionsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * ExpeditionsRepository::GetWhereNeverExpires() + * ExpeditionsRepository::GetWhereXAndY() + * ExpeditionsRepository::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_EXPEDITIONS_REPOSITORY_H