diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index cfa404825..4cd537c79 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -110,14 +110,343 @@ SET(common_sources util/uuid.cpp) SET(repositories - repositories/character_recipe_list_repository.h + + # 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_banned_ips_repository.h + repositories/base/base_base_data_repository.h + repositories/base/base_blocked_spells_repository.h + repositories/base/base_books_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_character_tribute_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_chatchannels_repository.h + repositories/base/base_command_settings_repository.h + repositories/base/base_completed_tasks_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_horses_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_launcher_repository.h + repositories/base/base_launcher_zones_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/banned_ips_repository.h + repositories/base_data_repository.h + repositories/blocked_spells_repository.h + repositories/books_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/character_tribute_repository.h + repositories/char_create_combinations_repository.h + repositories/char_create_point_allocations_repository.h + repositories/char_recipe_list_repository.h + repositories/chatchannels_repository.h + repositories/command_settings_repository.h + repositories/completed_tasks_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/spawngroup_repository.h - repositories/tradeskill_recipe_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/horses_repository.h repositories/instance_list_repository.h - repositories/zone_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/launcher_repository.h + repositories/launcher_zones_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 any.h diff --git a/common/content/world_content_service.cpp b/common/content/world_content_service.cpp index 350208774..e636d8854 100644 --- a/common/content/world_content_service.cpp +++ b/common/content/world_content_service.cpp @@ -20,6 +20,11 @@ #include "world_content_service.h" +WorldContentService::WorldContentService() +{ + SetCurrentExpansion(0); +} + int WorldContentService::GetCurrentExpansion() const { return current_expansion; diff --git a/common/content/world_content_service.h b/common/content/world_content_service.h index d6d6723a9..9faa6847e 100644 --- a/common/content/world_content_service.h +++ b/common/content/world_content_service.h @@ -93,6 +93,8 @@ namespace Expansion { class WorldContentService { public: + WorldContentService(); + int GetCurrentExpansion() const; void SetCurrentExpansion(int current_expansion); diff --git a/common/repositories/aa_ability_repository.h b/common/repositories/aa_ability_repository.h new file mode 100644 index 000000000..c8d096e8e --- /dev/null +++ b/common/repositories/aa_ability_repository.h @@ -0,0 +1,68 @@ +/** + * 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 on Apr 5, 2020 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) + * + * 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 diff --git a/common/repositories/aa_rank_effects_repository.h b/common/repositories/aa_rank_effects_repository.h new file mode 100644 index 000000000..df283fb1f --- /dev/null +++ b/common/repositories/aa_rank_effects_repository.h @@ -0,0 +1,68 @@ +/** + * 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 on Apr 5, 2020 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) + * + * 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 diff --git a/common/repositories/aa_rank_prereqs_repository.h b/common/repositories/aa_rank_prereqs_repository.h new file mode 100644 index 000000000..dafb1c4d8 --- /dev/null +++ b/common/repositories/aa_rank_prereqs_repository.h @@ -0,0 +1,68 @@ +/** + * 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 on Apr 5, 2020 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) + * + * 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 diff --git a/common/repositories/aa_ranks_repository.h b/common/repositories/aa_ranks_repository.h new file mode 100644 index 000000000..b62e4e840 --- /dev/null +++ b/common/repositories/aa_ranks_repository.h @@ -0,0 +1,68 @@ +/** + * 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 on Apr 5, 2020 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) + * + * 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 diff --git a/common/repositories/account_flags_repository.h b/common/repositories/account_flags_repository.h new file mode 100644 index 000000000..9ebe84abb --- /dev/null +++ b/common/repositories/account_flags_repository.h @@ -0,0 +1,68 @@ +/** + * 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 on Apr 5, 2020 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) + * + * 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 diff --git a/common/repositories/account_ip_repository.h b/common/repositories/account_ip_repository.h new file mode 100644 index 000000000..d33cb609d --- /dev/null +++ b/common/repositories/account_ip_repository.h @@ -0,0 +1,68 @@ +/** + * 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 on Apr 5, 2020 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) + * + * 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 diff --git a/common/repositories/account_repository.h b/common/repositories/account_repository.h index 6d8b51a9e..32d49c92d 100644 --- a/common/repositories/account_repository.h +++ b/common/repositories/account_repository.h @@ -23,371 +23,45 @@ #include "../database.h" #include "../string_util.h" +#include "base/base_account_repository.h" -class AccountRepository { +class AccountRepository: public 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"); - } + /** + * This file was auto generated on Apr 5, 2020 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) + * + * 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 + */ - static std::vector 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 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("{{TABLE_NAME}}"); - } - - 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 = 0; - entry.suspend_reason = 0; - - return entry; - } - - static Account GetAccountEntry( - const std::vector &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]; - entry.charname = row[2]; - entry.sharedplat = atoi(row[3]); - entry.password = row[4]; - entry.status = atoi(row[5]); - entry.ls_id = 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]; - entry.hideme = atoi(row[12]); - entry.rulesflag = atoi(row[13]); - entry.suspendeduntil = row[14]; - entry.time_creation = atoi(row[15]); - entry.expansion = atoi(row[16]); - entry.ban_reason = row[17]; - entry.suspend_reason = 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 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 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 = InstanceListRepository::NewEntity(); - - return account_entry; - } - - static int InsertMany( - std::vector account_entries - ) - { - std::vector insert_chunks; - - for (auto &account_entry: account_entries) { - std::vector 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 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) { - Account entry{}; - - entry.id = atoi(row[0]); - entry.name = row[1]; - entry.charname = row[2]; - entry.sharedplat = atoi(row[3]); - entry.password = row[4]; - entry.status = atoi(row[5]); - entry.ls_id = 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]; - entry.hideme = atoi(row[12]); - entry.rulesflag = atoi(row[13]); - entry.suspendeduntil = row[14]; - entry.time_creation = atoi(row[15]); - entry.expansion = atoi(row[16]); - entry.ban_reason = row[17]; - entry.suspend_reason = row[18]; - - all_entries.push_back(entry); - } - - return all_entries; - } + // Custom extended repository methods here }; diff --git a/common/repositories/account_rewards_repository.h b/common/repositories/account_rewards_repository.h new file mode 100644 index 000000000..77cad4076 --- /dev/null +++ b/common/repositories/account_rewards_repository.h @@ -0,0 +1,68 @@ +/** + * 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 on Apr 5, 2020 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) + * + * 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 diff --git a/common/repositories/adventure_details_repository.h b/common/repositories/adventure_details_repository.h new file mode 100644 index 000000000..909a3e7ae --- /dev/null +++ b/common/repositories/adventure_details_repository.h @@ -0,0 +1,68 @@ +/** + * 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 on Apr 5, 2020 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) + * + * 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 diff --git a/common/repositories/adventure_members_repository.h b/common/repositories/adventure_members_repository.h new file mode 100644 index 000000000..3cdedac90 --- /dev/null +++ b/common/repositories/adventure_members_repository.h @@ -0,0 +1,68 @@ +/** + * 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 on Apr 5, 2020 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) + * + * 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 diff --git a/common/repositories/adventure_stats_repository.h b/common/repositories/adventure_stats_repository.h new file mode 100644 index 000000000..8ff138849 --- /dev/null +++ b/common/repositories/adventure_stats_repository.h @@ -0,0 +1,68 @@ +/** + * 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 on Apr 5, 2020 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) + * + * 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 diff --git a/common/repositories/adventure_template_entry_flavor_repository.h b/common/repositories/adventure_template_entry_flavor_repository.h new file mode 100644 index 000000000..183d50780 --- /dev/null +++ b/common/repositories/adventure_template_entry_flavor_repository.h @@ -0,0 +1,68 @@ +/** + * 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 on Apr 5, 2020 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) + * + * 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 diff --git a/common/repositories/adventure_template_entry_repository.h b/common/repositories/adventure_template_entry_repository.h new file mode 100644 index 000000000..68e6008fc --- /dev/null +++ b/common/repositories/adventure_template_entry_repository.h @@ -0,0 +1,68 @@ +/** + * 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 on Apr 5, 2020 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) + * + * 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 diff --git a/common/repositories/adventure_template_repository.h b/common/repositories/adventure_template_repository.h new file mode 100644 index 000000000..a3e9c9a99 --- /dev/null +++ b/common/repositories/adventure_template_repository.h @@ -0,0 +1,68 @@ +/** + * 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 on Apr 5, 2020 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) + * + * 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 diff --git a/common/repositories/alternate_currency_repository.h b/common/repositories/alternate_currency_repository.h new file mode 100644 index 000000000..732f1e6f8 --- /dev/null +++ b/common/repositories/alternate_currency_repository.h @@ -0,0 +1,68 @@ +/** + * 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 on Apr 5, 2020 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) + * + * 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 diff --git a/common/repositories/auras_repository.h b/common/repositories/auras_repository.h new file mode 100644 index 000000000..5948195db --- /dev/null +++ b/common/repositories/auras_repository.h @@ -0,0 +1,68 @@ +/** + * 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 on Apr 5, 2020 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) + * + * 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 diff --git a/common/repositories/banned_ips_repository.h b/common/repositories/banned_ips_repository.h new file mode 100644 index 000000000..4610a6575 --- /dev/null +++ b/common/repositories/banned_ips_repository.h @@ -0,0 +1,68 @@ +/** + * 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_BANNED_IPS_REPOSITORY_H +#define EQEMU_BANNED_IPS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_banned_ips_repository.h" + +class BannedIpsRepository: public BaseBannedIpsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * BannedIpsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * BannedIpsRepository::GetWhereNeverExpires() + * BannedIpsRepository::GetWhereXAndY() + * BannedIpsRepository::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_BANNED_IPS_REPOSITORY_H diff --git a/common/repositories/base/base_aa_ability_repository.h b/common/repositories/base/base_aa_ability_repository.h new file mode 100644 index 000000000..3fbc3eeee --- /dev/null +++ b/common/repositories/base/base_aa_ability_repository.h @@ -0,0 +1,414 @@ +/** + * 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 on Apr 5, 2020 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; + int8 grant_only; + int first_rank_id; + int8 enabled; + int8 reset_on_death; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector 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 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 &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 update_values; + + auto columns = Columns(); + + 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 insert_values; + + 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 aa_ability_entries + ) + { + std::vector insert_chunks; + + for (auto &aa_ability_entry: aa_ability_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_AA_ABILITY_REPOSITORY_H diff --git a/common/repositories/base/base_aa_rank_effects_repository.h b/common/repositories/base/base_aa_rank_effects_repository.h new file mode 100644 index 000000000..8744febbe --- /dev/null +++ b/common/repositories/base/base_aa_rank_effects_repository.h @@ -0,0 +1,330 @@ +/** + * 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 on Apr 5, 2020 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("slot"); + } + + static std::vector Columns() + { + return { + "rank_id", + "slot", + "effect_id", + "base1", + "base2", + }; + } + + 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("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 &aa_rank_effectss, + int aa_rank_effects_id + ) + { + for (auto &aa_rank_effects : aa_rank_effectss) { + if (aa_rank_effects.slot == 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 update_values; + + auto columns = Columns(); + + 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.slot + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static AaRankEffects InsertOne( + AaRankEffects aa_rank_effects_entry + ) + { + std::vector insert_values; + + 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.id = results.LastInsertedID(); + return aa_rank_effects_entry; + } + + aa_rank_effects_entry = NewEntity(); + + return aa_rank_effects_entry; + } + + static int InsertMany( + std::vector aa_rank_effects_entries + ) + { + std::vector insert_chunks; + + for (auto &aa_rank_effects_entry: aa_rank_effects_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_AA_RANK_EFFECTS_REPOSITORY_H diff --git a/common/repositories/base/base_aa_rank_prereqs_repository.h b/common/repositories/base/base_aa_rank_prereqs_repository.h new file mode 100644 index 000000000..194917b34 --- /dev/null +++ b/common/repositories/base/base_aa_rank_prereqs_repository.h @@ -0,0 +1,312 @@ +/** + * 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 on Apr 5, 2020 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("aa_id"); + } + + static std::vector Columns() + { + return { + "rank_id", + "aa_id", + "points", + }; + } + + 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("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 &aa_rank_prereqss, + int aa_rank_prereqs_id + ) + { + for (auto &aa_rank_prereqs : aa_rank_prereqss) { + if (aa_rank_prereqs.aa_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 update_values; + + auto columns = Columns(); + + 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.aa_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static AaRankPrereqs InsertOne( + AaRankPrereqs aa_rank_prereqs_entry + ) + { + std::vector insert_values; + + 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.id = results.LastInsertedID(); + return aa_rank_prereqs_entry; + } + + aa_rank_prereqs_entry = NewEntity(); + + return aa_rank_prereqs_entry; + } + + static int InsertMany( + std::vector aa_rank_prereqs_entries + ) + { + std::vector insert_chunks; + + for (auto &aa_rank_prereqs_entry: aa_rank_prereqs_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(aa_rank_prereqs_entry.points)); + + 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_AA_RANK_PREREQS_REPOSITORY_H diff --git a/common/repositories/base/base_aa_ranks_repository.h b/common/repositories/base/base_aa_ranks_repository.h new file mode 100644 index 000000000..d8a7624d5 --- /dev/null +++ b/common/repositories/base/base_aa_ranks_repository.h @@ -0,0 +1,405 @@ +/** + * 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 on Apr 5, 2020 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 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 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 &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 update_values; + + auto columns = Columns(); + + 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 insert_values; + + 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 aa_ranks_entries + ) + { + std::vector insert_chunks; + + for (auto &aa_ranks_entry: aa_ranks_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_AA_RANKS_REPOSITORY_H diff --git a/common/repositories/base/base_account_flags_repository.h b/common/repositories/base/base_account_flags_repository.h new file mode 100644 index 000000000..36a4f7f7c --- /dev/null +++ b/common/repositories/base/base_account_flags_repository.h @@ -0,0 +1,312 @@ +/** + * 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 on Apr 5, 2020 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_flag"); + } + + static std::vector Columns() + { + return { + "p_accid", + "p_flag", + "p_value", + }; + } + + 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("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 &account_flagss, + int account_flags_id + ) + { + for (auto &account_flags : account_flagss) { + if (account_flags.p_flag == 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 update_values; + + auto columns = Columns(); + + 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_flag + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static AccountFlags InsertOne( + AccountFlags account_flags_entry + ) + { + std::vector insert_values; + + 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.id = results.LastInsertedID(); + return account_flags_entry; + } + + account_flags_entry = NewEntity(); + + return account_flags_entry; + } + + static int InsertMany( + std::vector account_flags_entries + ) + { + std::vector insert_chunks; + + for (auto &account_flags_entry: account_flags_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(account_flags_entry.p_value) + "'"); + + 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_ACCOUNT_FLAGS_REPOSITORY_H diff --git a/common/repositories/base/base_account_ip_repository.h b/common/repositories/base/base_account_ip_repository.h new file mode 100644 index 000000000..c85b90c81 --- /dev/null +++ b/common/repositories/base/base_account_ip_repository.h @@ -0,0 +1,321 @@ +/** + * 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 on Apr 5, 2020 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("ip"); + } + + static std::vector Columns() + { + return { + "accid", + "ip", + "count", + "lastused", + }; + } + + 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("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 &account_ips, + int account_ip_id + ) + { + for (auto &account_ip : account_ips) { + if (account_ip.ip == 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 update_values; + + auto columns = Columns(); + + 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.ip + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static AccountIp InsertOne( + AccountIp account_ip_entry + ) + { + std::vector insert_values; + + 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.id = results.LastInsertedID(); + return account_ip_entry; + } + + account_ip_entry = NewEntity(); + + return account_ip_entry; + } + + static int InsertMany( + std::vector account_ip_entries + ) + { + std::vector insert_chunks; + + for (auto &account_ip_entry: account_ip_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_ACCOUNT_IP_REPOSITORY_H diff --git a/common/repositories/base/base_account_repository.h b/common/repositories/base/base_account_repository.h new file mode 100644 index 000000000..3434a9c9f --- /dev/null +++ b/common/repositories/base/base_account_repository.h @@ -0,0 +1,459 @@ +/** + * 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 on Apr 5, 2020 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; + int8 gmspeed; + int8 revoked; + int karma; + std::string minilogin_ip; + int8 hideme; + int8 rulesflag; + std::string suspendeduntil; + int time_creation; + int8 expansion; + std::string ban_reason; + std::string suspend_reason; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector 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 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 &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 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 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_entries + ) + { + std::vector insert_chunks; + + for (auto &account_entry: account_entries) { + std::vector 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_ACCOUNT_REPOSITORY_H diff --git a/common/repositories/base/base_account_rewards_repository.h b/common/repositories/base/base_account_rewards_repository.h new file mode 100644 index 000000000..06120dffb --- /dev/null +++ b/common/repositories/base/base_account_rewards_repository.h @@ -0,0 +1,312 @@ +/** + * 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 on Apr 5, 2020 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("reward_id"); + } + + static std::vector Columns() + { + return { + "account_id", + "reward_id", + "amount", + }; + } + + 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("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 &account_rewardss, + int account_rewards_id + ) + { + for (auto &account_rewards : account_rewardss) { + if (account_rewards.reward_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 update_values; + + auto columns = Columns(); + + 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.reward_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static AccountRewards InsertOne( + AccountRewards account_rewards_entry + ) + { + std::vector insert_values; + + 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.id = results.LastInsertedID(); + return account_rewards_entry; + } + + account_rewards_entry = NewEntity(); + + return account_rewards_entry; + } + + static int InsertMany( + std::vector account_rewards_entries + ) + { + std::vector insert_chunks; + + for (auto &account_rewards_entry: account_rewards_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(account_rewards_entry.amount)); + + 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_ACCOUNT_REWARDS_REPOSITORY_H diff --git a/common/repositories/base/base_adventure_details_repository.h b/common/repositories/base/base_adventure_details_repository.h new file mode 100644 index 000000000..d5ffbecc0 --- /dev/null +++ b/common/repositories/base/base_adventure_details_repository.h @@ -0,0 +1,369 @@ +/** + * 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 on Apr 5, 2020 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; + int16 adventure_id; + int instance_id; + int16 count; + int16 assassinate_count; + int8 status; + int time_created; + int time_zoned; + int time_completed; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector 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 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 &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 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 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 adventure_details_entries + ) + { + std::vector insert_chunks; + + for (auto &adventure_details_entry: adventure_details_entries) { + std::vector 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_ADVENTURE_DETAILS_REPOSITORY_H diff --git a/common/repositories/base/base_adventure_members_repository.h b/common/repositories/base/base_adventure_members_repository.h new file mode 100644 index 000000000..0636da1ec --- /dev/null +++ b/common/repositories/base/base_adventure_members_repository.h @@ -0,0 +1,306 @@ +/** + * 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 on Apr 5, 2020 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 Columns() + { + return { + "id", + "charid", + }; + } + + 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("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 &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 update_values; + + auto columns = Columns(); + + update_values.push_back(columns[0] + " = " + std::to_string(adventure_members_entry.id)); + + 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 insert_values; + + insert_values.push_back(std::to_string(adventure_members_entry.id)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + adventure_members_entry.id = results.LastInsertedID(); + return adventure_members_entry; + } + + adventure_members_entry = NewEntity(); + + return adventure_members_entry; + } + + static int InsertMany( + std::vector adventure_members_entries + ) + { + std::vector insert_chunks; + + for (auto &adventure_members_entry: adventure_members_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(adventure_members_entry.id)); + + 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) { + AdventureMembers entry{}; + + entry.id = atoi(row[0]); + entry.charid = 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 = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_ADVENTURE_MEMBERS_REPOSITORY_H diff --git a/common/repositories/base/base_adventure_stats_repository.h b/common/repositories/base/base_adventure_stats_repository.h new file mode 100644 index 000000000..fbd571bc9 --- /dev/null +++ b/common/repositories/base/base_adventure_stats_repository.h @@ -0,0 +1,387 @@ +/** + * 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 on Apr 5, 2020 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 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 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 &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 update_values; + + auto columns = Columns(); + + 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 insert_values; + + 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.id = results.LastInsertedID(); + return adventure_stats_entry; + } + + adventure_stats_entry = NewEntity(); + + return adventure_stats_entry; + } + + static int InsertMany( + std::vector adventure_stats_entries + ) + { + std::vector insert_chunks; + + for (auto &adventure_stats_entry: adventure_stats_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_ADVENTURE_STATS_REPOSITORY_H diff --git a/common/repositories/base/base_adventure_template_entry_flavor_repository.h b/common/repositories/base/base_adventure_template_entry_flavor_repository.h new file mode 100644 index 000000000..0aec523ed --- /dev/null +++ b/common/repositories/base/base_adventure_template_entry_flavor_repository.h @@ -0,0 +1,306 @@ +/** + * 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 on Apr 5, 2020 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 Columns() + { + return { + "id", + "text", + }; + } + + 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("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 &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 update_values; + + auto columns = Columns(); + + 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 insert_values; + + 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 adventure_template_entry_flavor_entries + ) + { + std::vector insert_chunks; + + for (auto &adventure_template_entry_flavor_entry: adventure_template_entry_flavor_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(adventure_template_entry_flavor_entry.text) + "'"); + + 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) { + AdventureTemplateEntryFlavor entry{}; + + entry.id = atoi(row[0]); + entry.text = row[1] ? 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_ADVENTURE_TEMPLATE_ENTRY_FLAVOR_REPOSITORY_H diff --git a/common/repositories/base/base_adventure_template_entry_repository.h b/common/repositories/base/base_adventure_template_entry_repository.h new file mode 100644 index 000000000..64799c3bf --- /dev/null +++ b/common/repositories/base/base_adventure_template_entry_repository.h @@ -0,0 +1,306 @@ +/** + * 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 on Apr 5, 2020 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("template_id"); + } + + static std::vector Columns() + { + return { + "id", + "template_id", + }; + } + + 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("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 &adventure_template_entrys, + int adventure_template_entry_id + ) + { + for (auto &adventure_template_entry : adventure_template_entrys) { + if (adventure_template_entry.template_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 update_values; + + auto columns = Columns(); + + + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + adventure_template_entry_entry.template_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static AdventureTemplateEntry InsertOne( + AdventureTemplateEntry adventure_template_entry_entry + ) + { + std::vector insert_values; + + + + 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 adventure_template_entry_entries + ) + { + std::vector insert_chunks; + + for (auto &adventure_template_entry_entry: adventure_template_entry_entries) { + std::vector insert_values; + + + + 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) { + AdventureTemplateEntry entry{}; + + entry.id = atoi(row[0]); + entry.template_id = 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_ADVENTURE_TEMPLATE_ENTRY_REPOSITORY_H diff --git a/common/repositories/base/base_adventure_template_repository.h b/common/repositories/base/base_adventure_template_repository.h new file mode 100644 index 000000000..d93f46bf4 --- /dev/null +++ b/common/repositories/base/base_adventure_template_repository.h @@ -0,0 +1,585 @@ +/** + * 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 on Apr 5, 2020 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; + int8 zone_version; + int8 is_hard; + int8 is_raid; + int8 min_level; + int8 max_level; + int8 type; + int type_data; + int16 type_count; + float assa_x; + float assa_y; + float assa_z; + float assa_h; + std::string text; + int duration; + int zone_in_time; + int16 win_points; + int16 lose_points; + int8 theme; + int16 zone_in_zone_id; + float zone_in_x; + float zone_in_y; + int16 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 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 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 &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 = atof(row[10]); + entry.assa_y = atof(row[11]); + entry.assa_z = atof(row[12]); + entry.assa_h = 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 = atof(row[21]); + entry.zone_in_y = atof(row[22]); + entry.zone_in_object_id = atoi(row[23]); + entry.dest_x = atof(row[24]); + entry.dest_y = atof(row[25]); + entry.dest_z = atof(row[26]); + entry.dest_h = atof(row[27]); + entry.graveyard_zone_id = atoi(row[28]); + entry.graveyard_x = atof(row[29]); + entry.graveyard_y = atof(row[30]); + entry.graveyard_z = atof(row[31]); + entry.graveyard_radius = 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 update_values; + + auto columns = Columns(); + + 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 insert_values; + + 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 adventure_template_entries + ) + { + std::vector insert_chunks; + + for (auto &adventure_template_entry: adventure_template_entries) { + std::vector insert_values; + + 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 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) { + 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 = atof(row[10]); + entry.assa_y = atof(row[11]); + entry.assa_z = atof(row[12]); + entry.assa_h = 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 = atof(row[21]); + entry.zone_in_y = atof(row[22]); + entry.zone_in_object_id = atoi(row[23]); + entry.dest_x = atof(row[24]); + entry.dest_y = atof(row[25]); + entry.dest_z = atof(row[26]); + entry.dest_h = atof(row[27]); + entry.graveyard_zone_id = atoi(row[28]); + entry.graveyard_x = atof(row[29]); + entry.graveyard_y = atof(row[30]); + entry.graveyard_z = atof(row[31]); + entry.graveyard_radius = atof(row[32]); + + 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) { + 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 = atof(row[10]); + entry.assa_y = atof(row[11]); + entry.assa_z = atof(row[12]); + entry.assa_h = 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 = atof(row[21]); + entry.zone_in_y = atof(row[22]); + entry.zone_in_object_id = atoi(row[23]); + entry.dest_x = atof(row[24]); + entry.dest_y = atof(row[25]); + entry.dest_z = atof(row[26]); + entry.dest_h = atof(row[27]); + entry.graveyard_zone_id = atoi(row[28]); + entry.graveyard_x = atof(row[29]); + entry.graveyard_y = atof(row[30]); + entry.graveyard_z = atof(row[31]); + entry.graveyard_radius = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_ADVENTURE_TEMPLATE_REPOSITORY_H diff --git a/common/repositories/base/base_alternate_currency_repository.h b/common/repositories/base/base_alternate_currency_repository.h new file mode 100644 index 000000000..07fc1e489 --- /dev/null +++ b/common/repositories/base/base_alternate_currency_repository.h @@ -0,0 +1,306 @@ +/** + * 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 on Apr 5, 2020 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 Columns() + { + return { + "id", + "item_id", + }; + } + + 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("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 &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 update_values; + + auto columns = Columns(); + + 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 insert_values; + + 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 alternate_currency_entries + ) + { + std::vector insert_chunks; + + for (auto &alternate_currency_entry: alternate_currency_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(alternate_currency_entry.item_id)); + + 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) { + AlternateCurrency entry{}; + + entry.id = atoi(row[0]); + entry.item_id = 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_ALTERNATE_CURRENCY_REPOSITORY_H diff --git a/common/repositories/base/base_auras_repository.h b/common/repositories/base/base_auras_repository.h new file mode 100644 index 000000000..a12523bbd --- /dev/null +++ b/common/repositories/base/base_auras_repository.h @@ -0,0 +1,387 @@ +/** + * 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 on Apr 5, 2020 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 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 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 &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 update_values; + + auto columns = Columns(); + + 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 insert_values; + + 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.id = results.LastInsertedID(); + return auras_entry; + } + + auras_entry = NewEntity(); + + return auras_entry; + } + + static int InsertMany( + std::vector auras_entries + ) + { + std::vector insert_chunks; + + for (auto &auras_entry: auras_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_AURAS_REPOSITORY_H diff --git a/common/repositories/base/base_banned_ips_repository.h b/common/repositories/base/base_banned_ips_repository.h new file mode 100644 index 000000000..9c0178b09 --- /dev/null +++ b/common/repositories/base/base_banned_ips_repository.h @@ -0,0 +1,306 @@ +/** + * 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 on Apr 5, 2020 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_BANNED_IPS_REPOSITORY_H +#define EQEMU_BASE_BANNED_IPS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseBannedIpsRepository { +public: + struct BannedIps { + std::string ip_address; + std::string notes; + }; + + static std::string PrimaryKey() + { + return std::string("ip_address"); + } + + static std::vector Columns() + { + return { + "ip_address", + "notes", + }; + } + + 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("banned_ips"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static BannedIps NewEntity() + { + BannedIps entry{}; + + entry.ip_address = ""; + entry.notes = ""; + + return entry; + } + + static BannedIps GetBannedIpsEntry( + const std::vector &banned_ipss, + int banned_ips_id + ) + { + for (auto &banned_ips : banned_ipss) { + if (banned_ips.ip_address == banned_ips_id) { + return banned_ips; + } + } + + return NewEntity(); + } + + static BannedIps FindOne( + int banned_ips_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + banned_ips_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + BannedIps entry{}; + + entry.ip_address = row[0] ? row[0] : ""; + entry.notes = row[1] ? row[1] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int banned_ips_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + banned_ips_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + BannedIps banned_ips_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(banned_ips_entry.notes) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + banned_ips_entry.ip_address + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static BannedIps InsertOne( + BannedIps banned_ips_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(banned_ips_entry.notes) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + banned_ips_entry.id = results.LastInsertedID(); + return banned_ips_entry; + } + + banned_ips_entry = NewEntity(); + + return banned_ips_entry; + } + + static int InsertMany( + std::vector banned_ips_entries + ) + { + std::vector insert_chunks; + + for (auto &banned_ips_entry: banned_ips_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(banned_ips_entry.notes) + "'"); + + 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) { + BannedIps entry{}; + + entry.ip_address = row[0] ? row[0] : ""; + entry.notes = row[1] ? row[1] : ""; + + 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) { + BannedIps entry{}; + + entry.ip_address = row[0] ? row[0] : ""; + entry.notes = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_BANNED_IPS_REPOSITORY_H diff --git a/common/repositories/base/base_base_data_repository.h b/common/repositories/base/base_base_data_repository.h new file mode 100644 index 000000000..0cc222895 --- /dev/null +++ b/common/repositories/base/base_base_data_repository.h @@ -0,0 +1,375 @@ +/** + * 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 on Apr 5, 2020 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("class"); + } + + static std::vector 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 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 &base_datas, + int base_data_id + ) + { + for (auto &base_data : base_datas) { + if (base_data.class == 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 = atof(row[2]); + entry.mana = atof(row[3]); + entry.end = atof(row[4]); + entry.unk1 = atof(row[5]); + entry.unk2 = atof(row[6]); + entry.hp_fac = atof(row[7]); + entry.mana_fac = atof(row[8]); + entry.end_fac = 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 update_values; + + auto columns = Columns(); + + 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.class + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static BaseData InsertOne( + BaseData base_data_entry + ) + { + std::vector insert_values; + + 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.id = results.LastInsertedID(); + return base_data_entry; + } + + base_data_entry = NewEntity(); + + return base_data_entry; + } + + static int InsertMany( + std::vector base_data_entries + ) + { + std::vector insert_chunks; + + for (auto &base_data_entry: base_data_entries) { + std::vector insert_values; + + 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 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) { + BaseData entry{}; + + entry.level = atoi(row[0]); + entry.class = atoi(row[1]); + entry.hp = atof(row[2]); + entry.mana = atof(row[3]); + entry.end = atof(row[4]); + entry.unk1 = atof(row[5]); + entry.unk2 = atof(row[6]); + entry.hp_fac = atof(row[7]); + entry.mana_fac = atof(row[8]); + entry.end_fac = atof(row[9]); + + 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) { + BaseData entry{}; + + entry.level = atoi(row[0]); + entry.class = atoi(row[1]); + entry.hp = atof(row[2]); + entry.mana = atof(row[3]); + entry.end = atof(row[4]); + entry.unk1 = atof(row[5]); + entry.unk2 = atof(row[6]); + entry.hp_fac = atof(row[7]); + entry.mana_fac = atof(row[8]); + entry.end_fac = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_BASE_DATA_REPOSITORY_H diff --git a/common/repositories/base/base_blocked_spells_repository.h b/common/repositories/base/base_blocked_spells_repository.h new file mode 100644 index 000000000..753fe131d --- /dev/null +++ b/common/repositories/base/base_blocked_spells_repository.h @@ -0,0 +1,396 @@ +/** + * 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 on Apr 5, 2020 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; + int8 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 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 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 &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 = atof(row[4]); + entry.y = atof(row[5]); + entry.z = atof(row[6]); + entry.x_diff = atof(row[7]); + entry.y_diff = atof(row[8]); + entry.z_diff = 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 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 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 blocked_spells_entries + ) + { + std::vector insert_chunks; + + for (auto &blocked_spells_entry: blocked_spells_entries) { + std::vector 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 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) { + BlockedSpells entry{}; + + entry.id = atoi(row[0]); + entry.spellid = atoi(row[1]); + entry.type = atoi(row[2]); + entry.zoneid = atoi(row[3]); + entry.x = atof(row[4]); + entry.y = atof(row[5]); + entry.z = atof(row[6]); + entry.x_diff = atof(row[7]); + entry.y_diff = atof(row[8]); + entry.z_diff = 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 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) { + BlockedSpells entry{}; + + entry.id = atoi(row[0]); + entry.spellid = atoi(row[1]); + entry.type = atoi(row[2]); + entry.zoneid = atoi(row[3]); + entry.x = atof(row[4]); + entry.y = atof(row[5]); + entry.z = atof(row[6]); + entry.x_diff = atof(row[7]); + entry.y_diff = atof(row[8]); + entry.z_diff = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_BLOCKED_SPELLS_REPOSITORY_H diff --git a/common/repositories/base/base_books_repository.h b/common/repositories/base/base_books_repository.h new file mode 100644 index 000000000..c8453c680 --- /dev/null +++ b/common/repositories/base/base_books_repository.h @@ -0,0 +1,315 @@ +/** + * 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 on Apr 5, 2020 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_BOOKS_REPOSITORY_H +#define EQEMU_BASE_BOOKS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseBooksRepository { +public: + struct Books { + std::string name; + std::string txtfile; + int language; + }; + + static std::string PrimaryKey() + { + return std::string("name"); + } + + static std::vector Columns() + { + return { + "name", + "txtfile", + "language", + }; + } + + 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("books"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Books NewEntity() + { + Books entry{}; + + entry.name = ""; + entry.txtfile = ""; + entry.language = 0; + + return entry; + } + + static Books GetBooksEntry( + const std::vector &bookss, + int books_id + ) + { + for (auto &books : bookss) { + if (books.name == books_id) { + return books; + } + } + + return NewEntity(); + } + + static Books FindOne( + int books_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + books_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Books entry{}; + + entry.name = row[0] ? row[0] : ""; + entry.txtfile = row[1] ? row[1] : ""; + entry.language = atoi(row[2]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int books_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + books_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Books books_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(books_entry.txtfile) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(books_entry.language)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + books_entry.name + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Books InsertOne( + Books books_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(books_entry.txtfile) + "'"); + insert_values.push_back(std::to_string(books_entry.language)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + books_entry.id = results.LastInsertedID(); + return books_entry; + } + + books_entry = NewEntity(); + + return books_entry; + } + + static int InsertMany( + std::vector books_entries + ) + { + std::vector insert_chunks; + + for (auto &books_entry: books_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(books_entry.txtfile) + "'"); + insert_values.push_back(std::to_string(books_entry.language)); + + 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) { + Books entry{}; + + entry.name = row[0] ? row[0] : ""; + entry.txtfile = row[1] ? row[1] : ""; + entry.language = atoi(row[2]); + + 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) { + Books entry{}; + + entry.name = row[0] ? row[0] : ""; + entry.txtfile = row[1] ? row[1] : ""; + entry.language = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_BOOKS_REPOSITORY_H diff --git a/common/repositories/base/base_bug_reports_repository.h b/common/repositories/base/base_bug_reports_repository.h new file mode 100644 index 000000000..5ec89a015 --- /dev/null +++ b/common/repositories/base/base_bug_reports_repository.h @@ -0,0 +1,576 @@ +/** + * 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 on Apr 5, 2020 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; + int8 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; + int8 _can_duplicate; + int8 _crash_bug; + int8 _target_info; + int8 _character_flags; + int8 _unknown_value; + std::string bug_report; + std::string system_info; + std::string report_datetime; + int8 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 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 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 &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 = atof(row[12]); + entry.pos_y = atof(row[13]); + entry.pos_z = 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 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 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 bug_reports_entries + ) + { + std::vector insert_chunks; + + for (auto &bug_reports_entry: bug_reports_entries) { + std::vector 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 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) { + 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 = atof(row[12]); + entry.pos_y = atof(row[13]); + entry.pos_z = 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 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) { + 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 = atof(row[12]); + entry.pos_y = atof(row[13]); + entry.pos_z = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_BUG_REPORTS_REPOSITORY_H diff --git a/common/repositories/base/base_bugs_repository.h b/common/repositories/base/base_bugs_repository.h new file mode 100644 index 000000000..08d378271 --- /dev/null +++ b/common/repositories/base/base_bugs_repository.h @@ -0,0 +1,405 @@ +/** + * 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 on Apr 5, 2020 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; + int8 flag; + std::string target; + std::string bug; + std::string date; + int8 status; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector 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 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 &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 = atof(row[4]); + entry.y = atof(row[5]); + entry.z = 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 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 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_entries + ) + { + std::vector insert_chunks; + + for (auto &bugs_entry: bugs_entries) { + std::vector 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 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) { + 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 = atof(row[4]); + entry.y = atof(row[5]); + entry.z = 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 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) { + 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 = atof(row[4]); + entry.y = atof(row[5]); + entry.z = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_BUGS_REPOSITORY_H diff --git a/common/repositories/base/base_buyer_repository.h b/common/repositories/base/base_buyer_repository.h new file mode 100644 index 000000000..2752abe23 --- /dev/null +++ b/common/repositories/base/base_buyer_repository.h @@ -0,0 +1,339 @@ +/** + * 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 on Apr 5, 2020 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("buyslot"); + } + + static std::vector Columns() + { + return { + "charid", + "buyslot", + "itemid", + "itemname", + "quantity", + "price", + }; + } + + 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("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 &buyers, + int buyer_id + ) + { + for (auto &buyer : buyers) { + if (buyer.buyslot == 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 update_values; + + auto columns = Columns(); + + 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.buyslot + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Buyer InsertOne( + Buyer buyer_entry + ) + { + std::vector insert_values; + + 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.id = results.LastInsertedID(); + return buyer_entry; + } + + buyer_entry = NewEntity(); + + return buyer_entry; + } + + static int InsertMany( + std::vector buyer_entries + ) + { + std::vector insert_chunks; + + for (auto &buyer_entry: buyer_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_BUYER_REPOSITORY_H diff --git a/common/repositories/base/base_char_create_combinations_repository.h b/common/repositories/base/base_char_create_combinations_repository.h new file mode 100644 index 000000000..d333c7d63 --- /dev/null +++ b/common/repositories/base/base_char_create_combinations_repository.h @@ -0,0 +1,360 @@ +/** + * 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 on Apr 5, 2020 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; + int8 min_expansion; + int8 max_expansion; + std::string content_flags; + }; + + static std::string PrimaryKey() + { + return std::string("start_zone"); + } + + static std::vector Columns() + { + return { + "allocation_id", + "race", + "class", + "deity", + "start_zone", + "expansions_req", + "min_expansion", + "max_expansion", + "content_flags", + }; + } + + 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("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; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; + + return entry; + } + + static CharCreateCombinations GetCharCreateCombinationsEntry( + const std::vector &char_create_combinationss, + int char_create_combinations_id + ) + { + for (auto &char_create_combinations : char_create_combinationss) { + if (char_create_combinations.start_zone == 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]); + entry.min_expansion = atoi(row[6]); + entry.max_expansion = atoi(row[7]); + entry.content_flags = row[8] ? row[8] : ""; + + 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 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[5] + " = " + std::to_string(char_create_combinations_entry.expansions_req)); + update_values.push_back(columns[6] + " = " + std::to_string(char_create_combinations_entry.min_expansion)); + update_values.push_back(columns[7] + " = " + std::to_string(char_create_combinations_entry.max_expansion)); + update_values.push_back(columns[8] + " = '" + EscapeString(char_create_combinations_entry.content_flags) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + char_create_combinations_entry.start_zone + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharCreateCombinations InsertOne( + CharCreateCombinations char_create_combinations_entry + ) + { + std::vector 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.expansions_req)); + insert_values.push_back(std::to_string(char_create_combinations_entry.min_expansion)); + insert_values.push_back(std::to_string(char_create_combinations_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(char_create_combinations_entry.content_flags) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + char_create_combinations_entry.id = results.LastInsertedID(); + return char_create_combinations_entry; + } + + char_create_combinations_entry = NewEntity(); + + return char_create_combinations_entry; + } + + static int InsertMany( + std::vector char_create_combinations_entries + ) + { + std::vector insert_chunks; + + for (auto &char_create_combinations_entry: char_create_combinations_entries) { + std::vector 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.expansions_req)); + insert_values.push_back(std::to_string(char_create_combinations_entry.min_expansion)); + insert_values.push_back(std::to_string(char_create_combinations_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(char_create_combinations_entry.content_flags) + "'"); + + 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) { + 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]); + entry.min_expansion = atoi(row[6]); + entry.max_expansion = atoi(row[7]); + entry.content_flags = row[8] ? row[8] : ""; + + 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) { + 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]); + entry.min_expansion = atoi(row[6]); + entry.max_expansion = atoi(row[7]); + entry.content_flags = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHAR_CREATE_COMBINATIONS_REPOSITORY_H diff --git a/common/repositories/base/base_char_create_point_allocations_repository.h b/common/repositories/base/base_char_create_point_allocations_repository.h new file mode 100644 index 000000000..6b97292d1 --- /dev/null +++ b/common/repositories/base/base_char_create_point_allocations_repository.h @@ -0,0 +1,423 @@ +/** + * 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 on Apr 5, 2020 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 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 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 &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 update_values; + + auto columns = Columns(); + + 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 insert_values; + + 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 char_create_point_allocations_entries + ) + { + std::vector insert_chunks; + + for (auto &char_create_point_allocations_entry: char_create_point_allocations_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHAR_CREATE_POINT_ALLOCATIONS_REPOSITORY_H diff --git a/common/repositories/base/base_char_recipe_list_repository.h b/common/repositories/base/base_char_recipe_list_repository.h new file mode 100644 index 000000000..5ad9aa85a --- /dev/null +++ b/common/repositories/base/base_char_recipe_list_repository.h @@ -0,0 +1,312 @@ +/** + * 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 on Apr 5, 2020 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("recipe_id"); + } + + static std::vector Columns() + { + return { + "char_id", + "recipe_id", + "madecount", + }; + } + + 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("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 &char_recipe_lists, + int char_recipe_list_id + ) + { + for (auto &char_recipe_list : char_recipe_lists) { + if (char_recipe_list.recipe_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 update_values; + + auto columns = Columns(); + + 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.recipe_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharRecipeList InsertOne( + CharRecipeList char_recipe_list_entry + ) + { + std::vector insert_values; + + 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.id = results.LastInsertedID(); + return char_recipe_list_entry; + } + + char_recipe_list_entry = NewEntity(); + + return char_recipe_list_entry; + } + + static int InsertMany( + std::vector char_recipe_list_entries + ) + { + std::vector insert_chunks; + + for (auto &char_recipe_list_entry: char_recipe_list_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(char_recipe_list_entry.madecount)); + + 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHAR_RECIPE_LIST_REPOSITORY_H diff --git a/common/repositories/base/base_character_activities_repository.h b/common/repositories/base/base_character_activities_repository.h new file mode 100644 index 000000000..f535c7d41 --- /dev/null +++ b/common/repositories/base/base_character_activities_repository.h @@ -0,0 +1,327 @@ +/** + * 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 on Apr 5, 2020 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; + int8 completed; + }; + + static std::string PrimaryKey() + { + return std::string("activityid"); + } + + static std::vector Columns() + { + return { + "charid", + "taskid", + "activityid", + "donecount", + "completed", + }; + } + + 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_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 &character_activitiess, + int character_activities_id + ) + { + for (auto &character_activities : character_activitiess) { + if (character_activities.activityid == 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 update_values; + + auto columns = Columns(); + + 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.activityid + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterActivities InsertOne( + CharacterActivities character_activities_entry + ) + { + std::vector insert_values; + + 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.id = results.LastInsertedID(); + return character_activities_entry; + } + + character_activities_entry = NewEntity(); + + return character_activities_entry; + } + + static int InsertMany( + std::vector character_activities_entries + ) + { + std::vector insert_chunks; + + for (auto &character_activities_entry: character_activities_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_ACTIVITIES_REPOSITORY_H diff --git a/common/repositories/base/base_character_alt_currency_repository.h b/common/repositories/base/base_character_alt_currency_repository.h new file mode 100644 index 000000000..0542f3f87 --- /dev/null +++ b/common/repositories/base/base_character_alt_currency_repository.h @@ -0,0 +1,312 @@ +/** + * 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 on Apr 5, 2020 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("currency_id"); + } + + static std::vector Columns() + { + return { + "char_id", + "currency_id", + "amount", + }; + } + + 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_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 &character_alt_currencys, + int character_alt_currency_id + ) + { + for (auto &character_alt_currency : character_alt_currencys) { + if (character_alt_currency.currency_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 update_values; + + auto columns = Columns(); + + 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.currency_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterAltCurrency InsertOne( + CharacterAltCurrency character_alt_currency_entry + ) + { + std::vector insert_values; + + 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.id = results.LastInsertedID(); + return character_alt_currency_entry; + } + + character_alt_currency_entry = NewEntity(); + + return character_alt_currency_entry; + } + + static int InsertMany( + std::vector character_alt_currency_entries + ) + { + std::vector insert_chunks; + + for (auto &character_alt_currency_entry: character_alt_currency_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(character_alt_currency_entry.amount)); + + 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_ALT_CURRENCY_REPOSITORY_H diff --git a/common/repositories/base/base_character_alternate_abilities_repository.h b/common/repositories/base/base_character_alternate_abilities_repository.h new file mode 100644 index 000000000..0974e5d0c --- /dev/null +++ b/common/repositories/base/base_character_alternate_abilities_repository.h @@ -0,0 +1,321 @@ +/** + * 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 on Apr 5, 2020 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; + int16 aa_id; + int16 aa_value; + int16 charges; + }; + + static std::string PrimaryKey() + { + return std::string("aa_id"); + } + + static std::vector Columns() + { + return { + "id", + "aa_id", + "aa_value", + "charges", + }; + } + + 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_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 &character_alternate_abilitiess, + int character_alternate_abilities_id + ) + { + for (auto &character_alternate_abilities : character_alternate_abilitiess) { + if (character_alternate_abilities.aa_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 update_values; + + auto columns = Columns(); + + 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.aa_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterAlternateAbilities InsertOne( + CharacterAlternateAbilities character_alternate_abilities_entry + ) + { + std::vector insert_values; + + 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 character_alternate_abilities_entries + ) + { + std::vector insert_chunks; + + for (auto &character_alternate_abilities_entry: character_alternate_abilities_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_ALTERNATE_ABILITIES_REPOSITORY_H diff --git a/common/repositories/base/base_character_auras_repository.h b/common/repositories/base/base_character_auras_repository.h new file mode 100644 index 000000000..41514e158 --- /dev/null +++ b/common/repositories/base/base_character_auras_repository.h @@ -0,0 +1,312 @@ +/** + * 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 on Apr 5, 2020 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; + int8 slot; + int spell_id; + }; + + static std::string PrimaryKey() + { + return std::string("slot"); + } + + static std::vector Columns() + { + return { + "id", + "slot", + "spell_id", + }; + } + + 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_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 &character_aurass, + int character_auras_id + ) + { + for (auto &character_auras : character_aurass) { + if (character_auras.slot == 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 update_values; + + auto columns = Columns(); + + 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.slot + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterAuras InsertOne( + CharacterAuras character_auras_entry + ) + { + std::vector insert_values; + + 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 character_auras_entries + ) + { + std::vector insert_chunks; + + for (auto &character_auras_entry: character_auras_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(character_auras_entry.spell_id)); + + 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_AURAS_REPOSITORY_H diff --git a/common/repositories/base/base_character_bandolier_repository.h b/common/repositories/base/base_character_bandolier_repository.h new file mode 100644 index 000000000..0b9ef5ccc --- /dev/null +++ b/common/repositories/base/base_character_bandolier_repository.h @@ -0,0 +1,336 @@ +/** + * 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 on Apr 5, 2020 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; + int8 bandolier_id; + int8 bandolier_slot; + int item_id; + int icon; + std::string bandolier_name; + }; + + static std::string PrimaryKey() + { + return std::string("bandolier_slot"); + } + + static std::vector 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 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 &character_bandoliers, + int character_bandolier_id + ) + { + for (auto &character_bandolier : character_bandoliers) { + if (character_bandolier.bandolier_slot == 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 update_values; + + auto columns = Columns(); + + 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.bandolier_slot + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterBandolier InsertOne( + CharacterBandolier character_bandolier_entry + ) + { + std::vector insert_values; + + 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 character_bandolier_entries + ) + { + std::vector insert_chunks; + + for (auto &character_bandolier_entry: character_bandolier_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_BANDOLIER_REPOSITORY_H diff --git a/common/repositories/base/base_character_bind_repository.h b/common/repositories/base/base_character_bind_repository.h new file mode 100644 index 000000000..a68ab33b9 --- /dev/null +++ b/common/repositories/base/base_character_bind_repository.h @@ -0,0 +1,357 @@ +/** + * 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 on Apr 5, 2020 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; + int16 zone_id; + int instance_id; + float x; + float y; + float z; + float heading; + }; + + static std::string PrimaryKey() + { + return std::string("slot"); + } + + static std::vector 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 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 &character_binds, + int character_bind_id + ) + { + for (auto &character_bind : character_binds) { + if (character_bind.slot == 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 = atof(row[4]); + entry.y = atof(row[5]); + entry.z = atof(row[6]); + entry.heading = 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 update_values; + + auto columns = Columns(); + + 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.slot + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterBind InsertOne( + CharacterBind character_bind_entry + ) + { + std::vector insert_values; + + 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 character_bind_entries + ) + { + std::vector insert_chunks; + + for (auto &character_bind_entry: character_bind_entries) { + std::vector insert_values; + + 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 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) { + 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 = atof(row[4]); + entry.y = atof(row[5]); + entry.z = atof(row[6]); + entry.heading = atof(row[7]); + + 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) { + 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 = atof(row[4]); + entry.y = atof(row[5]); + entry.z = atof(row[6]); + entry.heading = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_BIND_REPOSITORY_H diff --git a/common/repositories/base/base_character_buffs_repository.h b/common/repositories/base/base_character_buffs_repository.h new file mode 100644 index 000000000..57b35a5c4 --- /dev/null +++ b/common/repositories/base/base_character_buffs_repository.h @@ -0,0 +1,438 @@ +/** + * 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 on Apr 5, 2020 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; + int8 slot_id; + int16 spell_id; + int8 caster_level; + std::string caster_name; + int ticsremaining; + int counters; + int numhits; + int melee_rune; + int magic_rune; + int8 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("slot_id"); + } + + static std::vector 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 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 &character_buffss, + int character_buffs_id + ) + { + for (auto &character_buffs : character_buffss) { + if (character_buffs.slot_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 update_values; + + auto columns = Columns(); + + 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.slot_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterBuffs InsertOne( + CharacterBuffs character_buffs_entry + ) + { + std::vector insert_values; + + 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.id = results.LastInsertedID(); + return character_buffs_entry; + } + + character_buffs_entry = NewEntity(); + + return character_buffs_entry; + } + + static int InsertMany( + std::vector character_buffs_entries + ) + { + std::vector insert_chunks; + + for (auto &character_buffs_entry: character_buffs_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_BUFFS_REPOSITORY_H diff --git a/common/repositories/base/base_character_corpse_items_repository.h b/common/repositories/base/base_character_corpse_items_repository.h new file mode 100644 index 000000000..b0b258389 --- /dev/null +++ b/common/repositories/base/base_character_corpse_items_repository.h @@ -0,0 +1,384 @@ +/** + * 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 on Apr 5, 2020 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; + int16 attuned; + }; + + static std::string PrimaryKey() + { + return std::string("equip_slot"); + } + + static std::vector 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 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 &character_corpse_itemss, + int character_corpse_items_id + ) + { + for (auto &character_corpse_items : character_corpse_itemss) { + if (character_corpse_items.equip_slot == 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 update_values; + + auto columns = Columns(); + + 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.equip_slot + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterCorpseItems InsertOne( + CharacterCorpseItems character_corpse_items_entry + ) + { + std::vector insert_values; + + 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.id = results.LastInsertedID(); + return character_corpse_items_entry; + } + + character_corpse_items_entry = NewEntity(); + + return character_corpse_items_entry; + } + + static int InsertMany( + std::vector character_corpse_items_entries + ) + { + std::vector insert_chunks; + + for (auto &character_corpse_items_entry: character_corpse_items_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_CORPSE_ITEMS_REPOSITORY_H diff --git a/common/repositories/base/base_character_corpses_repository.h b/common/repositories/base/base_character_corpses_repository.h new file mode 100644 index 000000000..2af2feac1 --- /dev/null +++ b/common/repositories/base/base_character_corpses_repository.h @@ -0,0 +1,711 @@ +/** + * 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 on Apr 5, 2020 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; + int16 zone_id; + int16 instance_id; + float x; + float y; + float z; + float heading; + std::string time_of_death; + int guild_consent_id; + int8 is_rezzed; + int8 is_buried; + int8 was_at_graveyard; + int8 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 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 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 &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 = atof(row[5]); + entry.y = atof(row[6]); + entry.z = atof(row[7]); + entry.heading = 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 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 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 character_corpses_entries + ) + { + std::vector insert_chunks; + + for (auto &character_corpses_entry: character_corpses_entries) { + std::vector 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 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) { + 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 = atof(row[5]); + entry.y = atof(row[6]); + entry.z = atof(row[7]); + entry.heading = 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 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) { + 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 = atof(row[5]); + entry.y = atof(row[6]); + entry.z = atof(row[7]); + entry.heading = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_CORPSES_REPOSITORY_H diff --git a/common/repositories/base/base_character_currency_repository.h b/common/repositories/base/base_character_currency_repository.h new file mode 100644 index 000000000..d38deb4db --- /dev/null +++ b/common/repositories/base/base_character_currency_repository.h @@ -0,0 +1,441 @@ +/** + * 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 on Apr 5, 2020 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 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 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 &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 update_values; + + auto columns = Columns(); + + 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 insert_values; + + 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 character_currency_entries + ) + { + std::vector insert_chunks; + + for (auto &character_currency_entry: character_currency_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_CURRENCY_REPOSITORY_H diff --git a/common/repositories/base/base_character_data_repository.h b/common/repositories/base/base_character_data_repository.h new file mode 100644 index 000000000..24133e729 --- /dev/null +++ b/common/repositories/base/base_character_data_repository.h @@ -0,0 +1,1206 @@ +/** + * 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 on Apr 5, 2020 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_DATA_REPOSITORY_H +#define EQEMU_BASE_CHARACTER_DATA_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseCharacterDataRepository { +public: + struct CharacterData { + int id; + int account_id; + std::string name; + std::string last_name; + std::string title; + std::string suffix; + int zone_id; + int zone_instance; + float y; + float x; + float z; + float heading; + int8 gender; + int16 race; + int8 class; + int level; + int deity; + int birthday; + int last_login; + int time_played; + int8 level2; + int8 anon; + int8 gm; + int face; + int8 hair_color; + int8 hair_style; + int8 beard; + int8 beard_color; + int8 eye_color_1; + int8 eye_color_2; + int drakkin_heritage; + int drakkin_tattoo; + int drakkin_details; + int8 ability_time_seconds; + int8 ability_number; + int8 ability_time_minutes; + int8 ability_time_hours; + int exp; + int aa_points_spent; + int aa_exp; + int aa_points; + int group_leadership_exp; + int raid_leadership_exp; + int group_leadership_points; + int raid_leadership_points; + int points; + int cur_hp; + int mana; + int endurance; + int intoxication; + int str; + int sta; + int cha; + int dex; + int int; + int agi; + int wis; + int zone_change_count; + int toxicity; + int hunger_level; + int thirst_level; + int ability_up; + int ldon_points_guk; + int ldon_points_mir; + int ldon_points_mmc; + int ldon_points_ruj; + int ldon_points_tak; + int ldon_points_available; + int tribute_time_remaining; + int career_tribute_points; + int tribute_points; + int tribute_active; + int8 pvp_status; + int pvp_kills; + int pvp_deaths; + int pvp_current_points; + int pvp_career_points; + int pvp_best_kill_streak; + int pvp_worst_death_streak; + int pvp_current_kill_streak; + int pvp2; + int pvp_type; + int show_helm; + int8 group_auto_consent; + int8 raid_auto_consent; + int8 guild_auto_consent; + int8 leadership_exp_on; + int RestTimer; + int air_remaining; + int autosplit_enabled; + int8 lfp; + int8 lfg; + std::string mailkey; + int8 xtargets; + int8 firstlogon; + int e_aa_effects; + int e_percent_to_aa; + int e_expended_aa_spent; + int aa_points_spent_old; + int aa_points_old; + int e_last_invsnapshot; + std::string deleted_at; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "account_id", + "name", + "last_name", + "title", + "suffix", + "zone_id", + "zone_instance", + "y", + "x", + "z", + "heading", + "gender", + "race", + "class", + "level", + "deity", + "birthday", + "last_login", + "time_played", + "level2", + "anon", + "gm", + "face", + "hair_color", + "hair_style", + "beard", + "beard_color", + "eye_color_1", + "eye_color_2", + "drakkin_heritage", + "drakkin_tattoo", + "drakkin_details", + "ability_time_seconds", + "ability_number", + "ability_time_minutes", + "ability_time_hours", + "exp", + "aa_points_spent", + "aa_exp", + "aa_points", + "group_leadership_exp", + "raid_leadership_exp", + "group_leadership_points", + "raid_leadership_points", + "points", + "cur_hp", + "mana", + "endurance", + "intoxication", + "str", + "sta", + "cha", + "dex", + "int", + "agi", + "wis", + "zone_change_count", + "toxicity", + "hunger_level", + "thirst_level", + "ability_up", + "ldon_points_guk", + "ldon_points_mir", + "ldon_points_mmc", + "ldon_points_ruj", + "ldon_points_tak", + "ldon_points_available", + "tribute_time_remaining", + "career_tribute_points", + "tribute_points", + "tribute_active", + "pvp_status", + "pvp_kills", + "pvp_deaths", + "pvp_current_points", + "pvp_career_points", + "pvp_best_kill_streak", + "pvp_worst_death_streak", + "pvp_current_kill_streak", + "pvp2", + "pvp_type", + "show_helm", + "group_auto_consent", + "raid_auto_consent", + "guild_auto_consent", + "leadership_exp_on", + "RestTimer", + "air_remaining", + "autosplit_enabled", + "lfp", + "lfg", + "mailkey", + "xtargets", + "firstlogon", + "e_aa_effects", + "e_percent_to_aa", + "e_expended_aa_spent", + "aa_points_spent_old", + "aa_points_old", + "e_last_invsnapshot", + "deleted_at", + }; + } + + 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_data"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static CharacterData NewEntity() + { + CharacterData entry{}; + + entry.id = 0; + entry.account_id = 0; + entry.name = ""; + entry.last_name = ""; + entry.title = ""; + entry.suffix = ""; + entry.zone_id = 0; + entry.zone_instance = 0; + entry.y = 0; + entry.x = 0; + entry.z = 0; + entry.heading = 0; + entry.gender = 0; + entry.race = 0; + entry.class = 0; + entry.level = 0; + entry.deity = 0; + entry.birthday = 0; + entry.last_login = 0; + entry.time_played = 0; + entry.level2 = 0; + entry.anon = 0; + entry.gm = 0; + entry.face = 0; + entry.hair_color = 0; + entry.hair_style = 0; + entry.beard = 0; + entry.beard_color = 0; + entry.eye_color_1 = 0; + entry.eye_color_2 = 0; + entry.drakkin_heritage = 0; + entry.drakkin_tattoo = 0; + entry.drakkin_details = 0; + entry.ability_time_seconds = 0; + entry.ability_number = 0; + entry.ability_time_minutes = 0; + entry.ability_time_hours = 0; + entry.exp = 0; + entry.aa_points_spent = 0; + entry.aa_exp = 0; + entry.aa_points = 0; + entry.group_leadership_exp = 0; + entry.raid_leadership_exp = 0; + entry.group_leadership_points = 0; + entry.raid_leadership_points = 0; + entry.points = 0; + entry.cur_hp = 0; + entry.mana = 0; + entry.endurance = 0; + entry.intoxication = 0; + entry.str = 0; + entry.sta = 0; + entry.cha = 0; + entry.dex = 0; + entry.int = 0; + entry.agi = 0; + entry.wis = 0; + entry.zone_change_count = 0; + entry.toxicity = 0; + entry.hunger_level = 0; + entry.thirst_level = 0; + entry.ability_up = 0; + entry.ldon_points_guk = 0; + entry.ldon_points_mir = 0; + entry.ldon_points_mmc = 0; + entry.ldon_points_ruj = 0; + entry.ldon_points_tak = 0; + entry.ldon_points_available = 0; + entry.tribute_time_remaining = 0; + entry.career_tribute_points = 0; + entry.tribute_points = 0; + entry.tribute_active = 0; + entry.pvp_status = 0; + entry.pvp_kills = 0; + entry.pvp_deaths = 0; + entry.pvp_current_points = 0; + entry.pvp_career_points = 0; + entry.pvp_best_kill_streak = 0; + entry.pvp_worst_death_streak = 0; + entry.pvp_current_kill_streak = 0; + entry.pvp2 = 0; + entry.pvp_type = 0; + entry.show_helm = 0; + entry.group_auto_consent = 0; + entry.raid_auto_consent = 0; + entry.guild_auto_consent = 0; + entry.leadership_exp_on = 0; + entry.RestTimer = 0; + entry.air_remaining = 0; + entry.autosplit_enabled = 0; + entry.lfp = 0; + entry.lfg = 0; + entry.mailkey = ""; + entry.xtargets = 5; + entry.firstlogon = 0; + entry.e_aa_effects = 0; + entry.e_percent_to_aa = 0; + entry.e_expended_aa_spent = 0; + entry.aa_points_spent_old = 0; + entry.aa_points_old = 0; + entry.e_last_invsnapshot = 0; + entry.deleted_at = 0; + + return entry; + } + + static CharacterData GetCharacterDataEntry( + const std::vector &character_datas, + int character_data_id + ) + { + for (auto &character_data : character_datas) { + if (character_data.id == character_data_id) { + return character_data; + } + } + + return NewEntity(); + } + + static CharacterData FindOne( + int character_data_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + character_data_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + CharacterData entry{}; + + entry.id = atoi(row[0]); + entry.account_id = atoi(row[1]); + entry.name = row[2] ? row[2] : ""; + entry.last_name = row[3] ? row[3] : ""; + entry.title = row[4] ? row[4] : ""; + entry.suffix = row[5] ? row[5] : ""; + entry.zone_id = atoi(row[6]); + entry.zone_instance = atoi(row[7]); + entry.y = atof(row[8]); + entry.x = atof(row[9]); + entry.z = atof(row[10]); + entry.heading = atof(row[11]); + entry.gender = atoi(row[12]); + entry.race = atoi(row[13]); + entry.class = atoi(row[14]); + entry.level = atoi(row[15]); + entry.deity = atoi(row[16]); + entry.birthday = atoi(row[17]); + entry.last_login = atoi(row[18]); + entry.time_played = atoi(row[19]); + entry.level2 = atoi(row[20]); + entry.anon = atoi(row[21]); + entry.gm = atoi(row[22]); + entry.face = atoi(row[23]); + entry.hair_color = atoi(row[24]); + entry.hair_style = atoi(row[25]); + entry.beard = atoi(row[26]); + entry.beard_color = atoi(row[27]); + entry.eye_color_1 = atoi(row[28]); + entry.eye_color_2 = atoi(row[29]); + entry.drakkin_heritage = atoi(row[30]); + entry.drakkin_tattoo = atoi(row[31]); + entry.drakkin_details = atoi(row[32]); + entry.ability_time_seconds = atoi(row[33]); + entry.ability_number = atoi(row[34]); + entry.ability_time_minutes = atoi(row[35]); + entry.ability_time_hours = atoi(row[36]); + entry.exp = atoi(row[37]); + entry.aa_points_spent = atoi(row[38]); + entry.aa_exp = atoi(row[39]); + entry.aa_points = atoi(row[40]); + entry.group_leadership_exp = atoi(row[41]); + entry.raid_leadership_exp = atoi(row[42]); + entry.group_leadership_points = atoi(row[43]); + entry.raid_leadership_points = atoi(row[44]); + entry.points = atoi(row[45]); + entry.cur_hp = atoi(row[46]); + entry.mana = atoi(row[47]); + entry.endurance = atoi(row[48]); + entry.intoxication = atoi(row[49]); + entry.str = atoi(row[50]); + entry.sta = atoi(row[51]); + entry.cha = atoi(row[52]); + entry.dex = atoi(row[53]); + entry.int = atoi(row[54]); + entry.agi = atoi(row[55]); + entry.wis = atoi(row[56]); + entry.zone_change_count = atoi(row[57]); + entry.toxicity = atoi(row[58]); + entry.hunger_level = atoi(row[59]); + entry.thirst_level = atoi(row[60]); + entry.ability_up = atoi(row[61]); + entry.ldon_points_guk = atoi(row[62]); + entry.ldon_points_mir = atoi(row[63]); + entry.ldon_points_mmc = atoi(row[64]); + entry.ldon_points_ruj = atoi(row[65]); + entry.ldon_points_tak = atoi(row[66]); + entry.ldon_points_available = atoi(row[67]); + entry.tribute_time_remaining = atoi(row[68]); + entry.career_tribute_points = atoi(row[69]); + entry.tribute_points = atoi(row[70]); + entry.tribute_active = atoi(row[71]); + entry.pvp_status = atoi(row[72]); + entry.pvp_kills = atoi(row[73]); + entry.pvp_deaths = atoi(row[74]); + entry.pvp_current_points = atoi(row[75]); + entry.pvp_career_points = atoi(row[76]); + entry.pvp_best_kill_streak = atoi(row[77]); + entry.pvp_worst_death_streak = atoi(row[78]); + entry.pvp_current_kill_streak = atoi(row[79]); + entry.pvp2 = atoi(row[80]); + entry.pvp_type = atoi(row[81]); + entry.show_helm = atoi(row[82]); + entry.group_auto_consent = atoi(row[83]); + entry.raid_auto_consent = atoi(row[84]); + entry.guild_auto_consent = atoi(row[85]); + entry.leadership_exp_on = atoi(row[86]); + entry.RestTimer = atoi(row[87]); + entry.air_remaining = atoi(row[88]); + entry.autosplit_enabled = atoi(row[89]); + entry.lfp = atoi(row[90]); + entry.lfg = atoi(row[91]); + entry.mailkey = row[92] ? row[92] : ""; + entry.xtargets = atoi(row[93]); + entry.firstlogon = atoi(row[94]); + entry.e_aa_effects = atoi(row[95]); + entry.e_percent_to_aa = atoi(row[96]); + entry.e_expended_aa_spent = atoi(row[97]); + entry.aa_points_spent_old = atoi(row[98]); + entry.aa_points_old = atoi(row[99]); + entry.e_last_invsnapshot = atoi(row[100]); + entry.deleted_at = row[101] ? row[101] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int character_data_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + character_data_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + CharacterData character_data_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(character_data_entry.account_id)); + update_values.push_back(columns[2] + " = '" + EscapeString(character_data_entry.name) + "'"); + update_values.push_back(columns[3] + " = '" + EscapeString(character_data_entry.last_name) + "'"); + update_values.push_back(columns[4] + " = '" + EscapeString(character_data_entry.title) + "'"); + update_values.push_back(columns[5] + " = '" + EscapeString(character_data_entry.suffix) + "'"); + update_values.push_back(columns[6] + " = " + std::to_string(character_data_entry.zone_id)); + update_values.push_back(columns[7] + " = " + std::to_string(character_data_entry.zone_instance)); + update_values.push_back(columns[8] + " = " + std::to_string(character_data_entry.y)); + update_values.push_back(columns[9] + " = " + std::to_string(character_data_entry.x)); + update_values.push_back(columns[10] + " = " + std::to_string(character_data_entry.z)); + update_values.push_back(columns[11] + " = " + std::to_string(character_data_entry.heading)); + update_values.push_back(columns[12] + " = " + std::to_string(character_data_entry.gender)); + update_values.push_back(columns[13] + " = " + std::to_string(character_data_entry.race)); + update_values.push_back(columns[14] + " = " + std::to_string(character_data_entry.class)); + update_values.push_back(columns[15] + " = " + std::to_string(character_data_entry.level)); + update_values.push_back(columns[16] + " = " + std::to_string(character_data_entry.deity)); + update_values.push_back(columns[17] + " = " + std::to_string(character_data_entry.birthday)); + update_values.push_back(columns[18] + " = " + std::to_string(character_data_entry.last_login)); + update_values.push_back(columns[19] + " = " + std::to_string(character_data_entry.time_played)); + update_values.push_back(columns[20] + " = " + std::to_string(character_data_entry.level2)); + update_values.push_back(columns[21] + " = " + std::to_string(character_data_entry.anon)); + update_values.push_back(columns[22] + " = " + std::to_string(character_data_entry.gm)); + update_values.push_back(columns[23] + " = " + std::to_string(character_data_entry.face)); + update_values.push_back(columns[24] + " = " + std::to_string(character_data_entry.hair_color)); + update_values.push_back(columns[25] + " = " + std::to_string(character_data_entry.hair_style)); + update_values.push_back(columns[26] + " = " + std::to_string(character_data_entry.beard)); + update_values.push_back(columns[27] + " = " + std::to_string(character_data_entry.beard_color)); + update_values.push_back(columns[28] + " = " + std::to_string(character_data_entry.eye_color_1)); + update_values.push_back(columns[29] + " = " + std::to_string(character_data_entry.eye_color_2)); + update_values.push_back(columns[30] + " = " + std::to_string(character_data_entry.drakkin_heritage)); + update_values.push_back(columns[31] + " = " + std::to_string(character_data_entry.drakkin_tattoo)); + update_values.push_back(columns[32] + " = " + std::to_string(character_data_entry.drakkin_details)); + update_values.push_back(columns[33] + " = " + std::to_string(character_data_entry.ability_time_seconds)); + update_values.push_back(columns[34] + " = " + std::to_string(character_data_entry.ability_number)); + update_values.push_back(columns[35] + " = " + std::to_string(character_data_entry.ability_time_minutes)); + update_values.push_back(columns[36] + " = " + std::to_string(character_data_entry.ability_time_hours)); + update_values.push_back(columns[37] + " = " + std::to_string(character_data_entry.exp)); + update_values.push_back(columns[38] + " = " + std::to_string(character_data_entry.aa_points_spent)); + update_values.push_back(columns[39] + " = " + std::to_string(character_data_entry.aa_exp)); + update_values.push_back(columns[40] + " = " + std::to_string(character_data_entry.aa_points)); + update_values.push_back(columns[41] + " = " + std::to_string(character_data_entry.group_leadership_exp)); + update_values.push_back(columns[42] + " = " + std::to_string(character_data_entry.raid_leadership_exp)); + update_values.push_back(columns[43] + " = " + std::to_string(character_data_entry.group_leadership_points)); + update_values.push_back(columns[44] + " = " + std::to_string(character_data_entry.raid_leadership_points)); + update_values.push_back(columns[45] + " = " + std::to_string(character_data_entry.points)); + update_values.push_back(columns[46] + " = " + std::to_string(character_data_entry.cur_hp)); + update_values.push_back(columns[47] + " = " + std::to_string(character_data_entry.mana)); + update_values.push_back(columns[48] + " = " + std::to_string(character_data_entry.endurance)); + update_values.push_back(columns[49] + " = " + std::to_string(character_data_entry.intoxication)); + update_values.push_back(columns[50] + " = " + std::to_string(character_data_entry.str)); + update_values.push_back(columns[51] + " = " + std::to_string(character_data_entry.sta)); + update_values.push_back(columns[52] + " = " + std::to_string(character_data_entry.cha)); + update_values.push_back(columns[53] + " = " + std::to_string(character_data_entry.dex)); + update_values.push_back(columns[54] + " = " + std::to_string(character_data_entry.int)); + update_values.push_back(columns[55] + " = " + std::to_string(character_data_entry.agi)); + update_values.push_back(columns[56] + " = " + std::to_string(character_data_entry.wis)); + update_values.push_back(columns[57] + " = " + std::to_string(character_data_entry.zone_change_count)); + update_values.push_back(columns[58] + " = " + std::to_string(character_data_entry.toxicity)); + update_values.push_back(columns[59] + " = " + std::to_string(character_data_entry.hunger_level)); + update_values.push_back(columns[60] + " = " + std::to_string(character_data_entry.thirst_level)); + update_values.push_back(columns[61] + " = " + std::to_string(character_data_entry.ability_up)); + update_values.push_back(columns[62] + " = " + std::to_string(character_data_entry.ldon_points_guk)); + update_values.push_back(columns[63] + " = " + std::to_string(character_data_entry.ldon_points_mir)); + update_values.push_back(columns[64] + " = " + std::to_string(character_data_entry.ldon_points_mmc)); + update_values.push_back(columns[65] + " = " + std::to_string(character_data_entry.ldon_points_ruj)); + update_values.push_back(columns[66] + " = " + std::to_string(character_data_entry.ldon_points_tak)); + update_values.push_back(columns[67] + " = " + std::to_string(character_data_entry.ldon_points_available)); + update_values.push_back(columns[68] + " = " + std::to_string(character_data_entry.tribute_time_remaining)); + update_values.push_back(columns[69] + " = " + std::to_string(character_data_entry.career_tribute_points)); + update_values.push_back(columns[70] + " = " + std::to_string(character_data_entry.tribute_points)); + update_values.push_back(columns[71] + " = " + std::to_string(character_data_entry.tribute_active)); + update_values.push_back(columns[72] + " = " + std::to_string(character_data_entry.pvp_status)); + update_values.push_back(columns[73] + " = " + std::to_string(character_data_entry.pvp_kills)); + update_values.push_back(columns[74] + " = " + std::to_string(character_data_entry.pvp_deaths)); + update_values.push_back(columns[75] + " = " + std::to_string(character_data_entry.pvp_current_points)); + update_values.push_back(columns[76] + " = " + std::to_string(character_data_entry.pvp_career_points)); + update_values.push_back(columns[77] + " = " + std::to_string(character_data_entry.pvp_best_kill_streak)); + update_values.push_back(columns[78] + " = " + std::to_string(character_data_entry.pvp_worst_death_streak)); + update_values.push_back(columns[79] + " = " + std::to_string(character_data_entry.pvp_current_kill_streak)); + update_values.push_back(columns[80] + " = " + std::to_string(character_data_entry.pvp2)); + update_values.push_back(columns[81] + " = " + std::to_string(character_data_entry.pvp_type)); + update_values.push_back(columns[82] + " = " + std::to_string(character_data_entry.show_helm)); + update_values.push_back(columns[83] + " = " + std::to_string(character_data_entry.group_auto_consent)); + update_values.push_back(columns[84] + " = " + std::to_string(character_data_entry.raid_auto_consent)); + update_values.push_back(columns[85] + " = " + std::to_string(character_data_entry.guild_auto_consent)); + update_values.push_back(columns[86] + " = " + std::to_string(character_data_entry.leadership_exp_on)); + update_values.push_back(columns[87] + " = " + std::to_string(character_data_entry.RestTimer)); + update_values.push_back(columns[88] + " = " + std::to_string(character_data_entry.air_remaining)); + update_values.push_back(columns[89] + " = " + std::to_string(character_data_entry.autosplit_enabled)); + update_values.push_back(columns[90] + " = " + std::to_string(character_data_entry.lfp)); + update_values.push_back(columns[91] + " = " + std::to_string(character_data_entry.lfg)); + update_values.push_back(columns[92] + " = '" + EscapeString(character_data_entry.mailkey) + "'"); + update_values.push_back(columns[93] + " = " + std::to_string(character_data_entry.xtargets)); + update_values.push_back(columns[94] + " = " + std::to_string(character_data_entry.firstlogon)); + update_values.push_back(columns[95] + " = " + std::to_string(character_data_entry.e_aa_effects)); + update_values.push_back(columns[96] + " = " + std::to_string(character_data_entry.e_percent_to_aa)); + update_values.push_back(columns[97] + " = " + std::to_string(character_data_entry.e_expended_aa_spent)); + update_values.push_back(columns[98] + " = " + std::to_string(character_data_entry.aa_points_spent_old)); + update_values.push_back(columns[99] + " = " + std::to_string(character_data_entry.aa_points_old)); + update_values.push_back(columns[100] + " = " + std::to_string(character_data_entry.e_last_invsnapshot)); + update_values.push_back(columns[101] + " = '" + EscapeString(character_data_entry.deleted_at) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + character_data_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterData InsertOne( + CharacterData character_data_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(character_data_entry.account_id)); + insert_values.push_back("'" + EscapeString(character_data_entry.name) + "'"); + insert_values.push_back("'" + EscapeString(character_data_entry.last_name) + "'"); + insert_values.push_back("'" + EscapeString(character_data_entry.title) + "'"); + insert_values.push_back("'" + EscapeString(character_data_entry.suffix) + "'"); + insert_values.push_back(std::to_string(character_data_entry.zone_id)); + insert_values.push_back(std::to_string(character_data_entry.zone_instance)); + insert_values.push_back(std::to_string(character_data_entry.y)); + insert_values.push_back(std::to_string(character_data_entry.x)); + insert_values.push_back(std::to_string(character_data_entry.z)); + insert_values.push_back(std::to_string(character_data_entry.heading)); + insert_values.push_back(std::to_string(character_data_entry.gender)); + insert_values.push_back(std::to_string(character_data_entry.race)); + insert_values.push_back(std::to_string(character_data_entry.class)); + insert_values.push_back(std::to_string(character_data_entry.level)); + insert_values.push_back(std::to_string(character_data_entry.deity)); + insert_values.push_back(std::to_string(character_data_entry.birthday)); + insert_values.push_back(std::to_string(character_data_entry.last_login)); + insert_values.push_back(std::to_string(character_data_entry.time_played)); + insert_values.push_back(std::to_string(character_data_entry.level2)); + insert_values.push_back(std::to_string(character_data_entry.anon)); + insert_values.push_back(std::to_string(character_data_entry.gm)); + insert_values.push_back(std::to_string(character_data_entry.face)); + insert_values.push_back(std::to_string(character_data_entry.hair_color)); + insert_values.push_back(std::to_string(character_data_entry.hair_style)); + insert_values.push_back(std::to_string(character_data_entry.beard)); + insert_values.push_back(std::to_string(character_data_entry.beard_color)); + insert_values.push_back(std::to_string(character_data_entry.eye_color_1)); + insert_values.push_back(std::to_string(character_data_entry.eye_color_2)); + insert_values.push_back(std::to_string(character_data_entry.drakkin_heritage)); + insert_values.push_back(std::to_string(character_data_entry.drakkin_tattoo)); + insert_values.push_back(std::to_string(character_data_entry.drakkin_details)); + insert_values.push_back(std::to_string(character_data_entry.ability_time_seconds)); + insert_values.push_back(std::to_string(character_data_entry.ability_number)); + insert_values.push_back(std::to_string(character_data_entry.ability_time_minutes)); + insert_values.push_back(std::to_string(character_data_entry.ability_time_hours)); + insert_values.push_back(std::to_string(character_data_entry.exp)); + insert_values.push_back(std::to_string(character_data_entry.aa_points_spent)); + insert_values.push_back(std::to_string(character_data_entry.aa_exp)); + insert_values.push_back(std::to_string(character_data_entry.aa_points)); + insert_values.push_back(std::to_string(character_data_entry.group_leadership_exp)); + insert_values.push_back(std::to_string(character_data_entry.raid_leadership_exp)); + insert_values.push_back(std::to_string(character_data_entry.group_leadership_points)); + insert_values.push_back(std::to_string(character_data_entry.raid_leadership_points)); + insert_values.push_back(std::to_string(character_data_entry.points)); + insert_values.push_back(std::to_string(character_data_entry.cur_hp)); + insert_values.push_back(std::to_string(character_data_entry.mana)); + insert_values.push_back(std::to_string(character_data_entry.endurance)); + insert_values.push_back(std::to_string(character_data_entry.intoxication)); + insert_values.push_back(std::to_string(character_data_entry.str)); + insert_values.push_back(std::to_string(character_data_entry.sta)); + insert_values.push_back(std::to_string(character_data_entry.cha)); + insert_values.push_back(std::to_string(character_data_entry.dex)); + insert_values.push_back(std::to_string(character_data_entry.int)); + insert_values.push_back(std::to_string(character_data_entry.agi)); + insert_values.push_back(std::to_string(character_data_entry.wis)); + insert_values.push_back(std::to_string(character_data_entry.zone_change_count)); + insert_values.push_back(std::to_string(character_data_entry.toxicity)); + insert_values.push_back(std::to_string(character_data_entry.hunger_level)); + insert_values.push_back(std::to_string(character_data_entry.thirst_level)); + insert_values.push_back(std::to_string(character_data_entry.ability_up)); + insert_values.push_back(std::to_string(character_data_entry.ldon_points_guk)); + insert_values.push_back(std::to_string(character_data_entry.ldon_points_mir)); + insert_values.push_back(std::to_string(character_data_entry.ldon_points_mmc)); + insert_values.push_back(std::to_string(character_data_entry.ldon_points_ruj)); + insert_values.push_back(std::to_string(character_data_entry.ldon_points_tak)); + insert_values.push_back(std::to_string(character_data_entry.ldon_points_available)); + insert_values.push_back(std::to_string(character_data_entry.tribute_time_remaining)); + insert_values.push_back(std::to_string(character_data_entry.career_tribute_points)); + insert_values.push_back(std::to_string(character_data_entry.tribute_points)); + insert_values.push_back(std::to_string(character_data_entry.tribute_active)); + insert_values.push_back(std::to_string(character_data_entry.pvp_status)); + insert_values.push_back(std::to_string(character_data_entry.pvp_kills)); + insert_values.push_back(std::to_string(character_data_entry.pvp_deaths)); + insert_values.push_back(std::to_string(character_data_entry.pvp_current_points)); + insert_values.push_back(std::to_string(character_data_entry.pvp_career_points)); + insert_values.push_back(std::to_string(character_data_entry.pvp_best_kill_streak)); + insert_values.push_back(std::to_string(character_data_entry.pvp_worst_death_streak)); + insert_values.push_back(std::to_string(character_data_entry.pvp_current_kill_streak)); + insert_values.push_back(std::to_string(character_data_entry.pvp2)); + insert_values.push_back(std::to_string(character_data_entry.pvp_type)); + insert_values.push_back(std::to_string(character_data_entry.show_helm)); + insert_values.push_back(std::to_string(character_data_entry.group_auto_consent)); + insert_values.push_back(std::to_string(character_data_entry.raid_auto_consent)); + insert_values.push_back(std::to_string(character_data_entry.guild_auto_consent)); + insert_values.push_back(std::to_string(character_data_entry.leadership_exp_on)); + insert_values.push_back(std::to_string(character_data_entry.RestTimer)); + insert_values.push_back(std::to_string(character_data_entry.air_remaining)); + insert_values.push_back(std::to_string(character_data_entry.autosplit_enabled)); + insert_values.push_back(std::to_string(character_data_entry.lfp)); + insert_values.push_back(std::to_string(character_data_entry.lfg)); + insert_values.push_back("'" + EscapeString(character_data_entry.mailkey) + "'"); + insert_values.push_back(std::to_string(character_data_entry.xtargets)); + insert_values.push_back(std::to_string(character_data_entry.firstlogon)); + insert_values.push_back(std::to_string(character_data_entry.e_aa_effects)); + insert_values.push_back(std::to_string(character_data_entry.e_percent_to_aa)); + insert_values.push_back(std::to_string(character_data_entry.e_expended_aa_spent)); + insert_values.push_back(std::to_string(character_data_entry.aa_points_spent_old)); + insert_values.push_back(std::to_string(character_data_entry.aa_points_old)); + insert_values.push_back(std::to_string(character_data_entry.e_last_invsnapshot)); + insert_values.push_back("'" + EscapeString(character_data_entry.deleted_at) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + character_data_entry.id = results.LastInsertedID(); + return character_data_entry; + } + + character_data_entry = NewEntity(); + + return character_data_entry; + } + + static int InsertMany( + std::vector character_data_entries + ) + { + std::vector insert_chunks; + + for (auto &character_data_entry: character_data_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(character_data_entry.account_id)); + insert_values.push_back("'" + EscapeString(character_data_entry.name) + "'"); + insert_values.push_back("'" + EscapeString(character_data_entry.last_name) + "'"); + insert_values.push_back("'" + EscapeString(character_data_entry.title) + "'"); + insert_values.push_back("'" + EscapeString(character_data_entry.suffix) + "'"); + insert_values.push_back(std::to_string(character_data_entry.zone_id)); + insert_values.push_back(std::to_string(character_data_entry.zone_instance)); + insert_values.push_back(std::to_string(character_data_entry.y)); + insert_values.push_back(std::to_string(character_data_entry.x)); + insert_values.push_back(std::to_string(character_data_entry.z)); + insert_values.push_back(std::to_string(character_data_entry.heading)); + insert_values.push_back(std::to_string(character_data_entry.gender)); + insert_values.push_back(std::to_string(character_data_entry.race)); + insert_values.push_back(std::to_string(character_data_entry.class)); + insert_values.push_back(std::to_string(character_data_entry.level)); + insert_values.push_back(std::to_string(character_data_entry.deity)); + insert_values.push_back(std::to_string(character_data_entry.birthday)); + insert_values.push_back(std::to_string(character_data_entry.last_login)); + insert_values.push_back(std::to_string(character_data_entry.time_played)); + insert_values.push_back(std::to_string(character_data_entry.level2)); + insert_values.push_back(std::to_string(character_data_entry.anon)); + insert_values.push_back(std::to_string(character_data_entry.gm)); + insert_values.push_back(std::to_string(character_data_entry.face)); + insert_values.push_back(std::to_string(character_data_entry.hair_color)); + insert_values.push_back(std::to_string(character_data_entry.hair_style)); + insert_values.push_back(std::to_string(character_data_entry.beard)); + insert_values.push_back(std::to_string(character_data_entry.beard_color)); + insert_values.push_back(std::to_string(character_data_entry.eye_color_1)); + insert_values.push_back(std::to_string(character_data_entry.eye_color_2)); + insert_values.push_back(std::to_string(character_data_entry.drakkin_heritage)); + insert_values.push_back(std::to_string(character_data_entry.drakkin_tattoo)); + insert_values.push_back(std::to_string(character_data_entry.drakkin_details)); + insert_values.push_back(std::to_string(character_data_entry.ability_time_seconds)); + insert_values.push_back(std::to_string(character_data_entry.ability_number)); + insert_values.push_back(std::to_string(character_data_entry.ability_time_minutes)); + insert_values.push_back(std::to_string(character_data_entry.ability_time_hours)); + insert_values.push_back(std::to_string(character_data_entry.exp)); + insert_values.push_back(std::to_string(character_data_entry.aa_points_spent)); + insert_values.push_back(std::to_string(character_data_entry.aa_exp)); + insert_values.push_back(std::to_string(character_data_entry.aa_points)); + insert_values.push_back(std::to_string(character_data_entry.group_leadership_exp)); + insert_values.push_back(std::to_string(character_data_entry.raid_leadership_exp)); + insert_values.push_back(std::to_string(character_data_entry.group_leadership_points)); + insert_values.push_back(std::to_string(character_data_entry.raid_leadership_points)); + insert_values.push_back(std::to_string(character_data_entry.points)); + insert_values.push_back(std::to_string(character_data_entry.cur_hp)); + insert_values.push_back(std::to_string(character_data_entry.mana)); + insert_values.push_back(std::to_string(character_data_entry.endurance)); + insert_values.push_back(std::to_string(character_data_entry.intoxication)); + insert_values.push_back(std::to_string(character_data_entry.str)); + insert_values.push_back(std::to_string(character_data_entry.sta)); + insert_values.push_back(std::to_string(character_data_entry.cha)); + insert_values.push_back(std::to_string(character_data_entry.dex)); + insert_values.push_back(std::to_string(character_data_entry.int)); + insert_values.push_back(std::to_string(character_data_entry.agi)); + insert_values.push_back(std::to_string(character_data_entry.wis)); + insert_values.push_back(std::to_string(character_data_entry.zone_change_count)); + insert_values.push_back(std::to_string(character_data_entry.toxicity)); + insert_values.push_back(std::to_string(character_data_entry.hunger_level)); + insert_values.push_back(std::to_string(character_data_entry.thirst_level)); + insert_values.push_back(std::to_string(character_data_entry.ability_up)); + insert_values.push_back(std::to_string(character_data_entry.ldon_points_guk)); + insert_values.push_back(std::to_string(character_data_entry.ldon_points_mir)); + insert_values.push_back(std::to_string(character_data_entry.ldon_points_mmc)); + insert_values.push_back(std::to_string(character_data_entry.ldon_points_ruj)); + insert_values.push_back(std::to_string(character_data_entry.ldon_points_tak)); + insert_values.push_back(std::to_string(character_data_entry.ldon_points_available)); + insert_values.push_back(std::to_string(character_data_entry.tribute_time_remaining)); + insert_values.push_back(std::to_string(character_data_entry.career_tribute_points)); + insert_values.push_back(std::to_string(character_data_entry.tribute_points)); + insert_values.push_back(std::to_string(character_data_entry.tribute_active)); + insert_values.push_back(std::to_string(character_data_entry.pvp_status)); + insert_values.push_back(std::to_string(character_data_entry.pvp_kills)); + insert_values.push_back(std::to_string(character_data_entry.pvp_deaths)); + insert_values.push_back(std::to_string(character_data_entry.pvp_current_points)); + insert_values.push_back(std::to_string(character_data_entry.pvp_career_points)); + insert_values.push_back(std::to_string(character_data_entry.pvp_best_kill_streak)); + insert_values.push_back(std::to_string(character_data_entry.pvp_worst_death_streak)); + insert_values.push_back(std::to_string(character_data_entry.pvp_current_kill_streak)); + insert_values.push_back(std::to_string(character_data_entry.pvp2)); + insert_values.push_back(std::to_string(character_data_entry.pvp_type)); + insert_values.push_back(std::to_string(character_data_entry.show_helm)); + insert_values.push_back(std::to_string(character_data_entry.group_auto_consent)); + insert_values.push_back(std::to_string(character_data_entry.raid_auto_consent)); + insert_values.push_back(std::to_string(character_data_entry.guild_auto_consent)); + insert_values.push_back(std::to_string(character_data_entry.leadership_exp_on)); + insert_values.push_back(std::to_string(character_data_entry.RestTimer)); + insert_values.push_back(std::to_string(character_data_entry.air_remaining)); + insert_values.push_back(std::to_string(character_data_entry.autosplit_enabled)); + insert_values.push_back(std::to_string(character_data_entry.lfp)); + insert_values.push_back(std::to_string(character_data_entry.lfg)); + insert_values.push_back("'" + EscapeString(character_data_entry.mailkey) + "'"); + insert_values.push_back(std::to_string(character_data_entry.xtargets)); + insert_values.push_back(std::to_string(character_data_entry.firstlogon)); + insert_values.push_back(std::to_string(character_data_entry.e_aa_effects)); + insert_values.push_back(std::to_string(character_data_entry.e_percent_to_aa)); + insert_values.push_back(std::to_string(character_data_entry.e_expended_aa_spent)); + insert_values.push_back(std::to_string(character_data_entry.aa_points_spent_old)); + insert_values.push_back(std::to_string(character_data_entry.aa_points_old)); + insert_values.push_back(std::to_string(character_data_entry.e_last_invsnapshot)); + insert_values.push_back("'" + EscapeString(character_data_entry.deleted_at) + "'"); + + 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) { + CharacterData entry{}; + + entry.id = atoi(row[0]); + entry.account_id = atoi(row[1]); + entry.name = row[2] ? row[2] : ""; + entry.last_name = row[3] ? row[3] : ""; + entry.title = row[4] ? row[4] : ""; + entry.suffix = row[5] ? row[5] : ""; + entry.zone_id = atoi(row[6]); + entry.zone_instance = atoi(row[7]); + entry.y = atof(row[8]); + entry.x = atof(row[9]); + entry.z = atof(row[10]); + entry.heading = atof(row[11]); + entry.gender = atoi(row[12]); + entry.race = atoi(row[13]); + entry.class = atoi(row[14]); + entry.level = atoi(row[15]); + entry.deity = atoi(row[16]); + entry.birthday = atoi(row[17]); + entry.last_login = atoi(row[18]); + entry.time_played = atoi(row[19]); + entry.level2 = atoi(row[20]); + entry.anon = atoi(row[21]); + entry.gm = atoi(row[22]); + entry.face = atoi(row[23]); + entry.hair_color = atoi(row[24]); + entry.hair_style = atoi(row[25]); + entry.beard = atoi(row[26]); + entry.beard_color = atoi(row[27]); + entry.eye_color_1 = atoi(row[28]); + entry.eye_color_2 = atoi(row[29]); + entry.drakkin_heritage = atoi(row[30]); + entry.drakkin_tattoo = atoi(row[31]); + entry.drakkin_details = atoi(row[32]); + entry.ability_time_seconds = atoi(row[33]); + entry.ability_number = atoi(row[34]); + entry.ability_time_minutes = atoi(row[35]); + entry.ability_time_hours = atoi(row[36]); + entry.exp = atoi(row[37]); + entry.aa_points_spent = atoi(row[38]); + entry.aa_exp = atoi(row[39]); + entry.aa_points = atoi(row[40]); + entry.group_leadership_exp = atoi(row[41]); + entry.raid_leadership_exp = atoi(row[42]); + entry.group_leadership_points = atoi(row[43]); + entry.raid_leadership_points = atoi(row[44]); + entry.points = atoi(row[45]); + entry.cur_hp = atoi(row[46]); + entry.mana = atoi(row[47]); + entry.endurance = atoi(row[48]); + entry.intoxication = atoi(row[49]); + entry.str = atoi(row[50]); + entry.sta = atoi(row[51]); + entry.cha = atoi(row[52]); + entry.dex = atoi(row[53]); + entry.int = atoi(row[54]); + entry.agi = atoi(row[55]); + entry.wis = atoi(row[56]); + entry.zone_change_count = atoi(row[57]); + entry.toxicity = atoi(row[58]); + entry.hunger_level = atoi(row[59]); + entry.thirst_level = atoi(row[60]); + entry.ability_up = atoi(row[61]); + entry.ldon_points_guk = atoi(row[62]); + entry.ldon_points_mir = atoi(row[63]); + entry.ldon_points_mmc = atoi(row[64]); + entry.ldon_points_ruj = atoi(row[65]); + entry.ldon_points_tak = atoi(row[66]); + entry.ldon_points_available = atoi(row[67]); + entry.tribute_time_remaining = atoi(row[68]); + entry.career_tribute_points = atoi(row[69]); + entry.tribute_points = atoi(row[70]); + entry.tribute_active = atoi(row[71]); + entry.pvp_status = atoi(row[72]); + entry.pvp_kills = atoi(row[73]); + entry.pvp_deaths = atoi(row[74]); + entry.pvp_current_points = atoi(row[75]); + entry.pvp_career_points = atoi(row[76]); + entry.pvp_best_kill_streak = atoi(row[77]); + entry.pvp_worst_death_streak = atoi(row[78]); + entry.pvp_current_kill_streak = atoi(row[79]); + entry.pvp2 = atoi(row[80]); + entry.pvp_type = atoi(row[81]); + entry.show_helm = atoi(row[82]); + entry.group_auto_consent = atoi(row[83]); + entry.raid_auto_consent = atoi(row[84]); + entry.guild_auto_consent = atoi(row[85]); + entry.leadership_exp_on = atoi(row[86]); + entry.RestTimer = atoi(row[87]); + entry.air_remaining = atoi(row[88]); + entry.autosplit_enabled = atoi(row[89]); + entry.lfp = atoi(row[90]); + entry.lfg = atoi(row[91]); + entry.mailkey = row[92] ? row[92] : ""; + entry.xtargets = atoi(row[93]); + entry.firstlogon = atoi(row[94]); + entry.e_aa_effects = atoi(row[95]); + entry.e_percent_to_aa = atoi(row[96]); + entry.e_expended_aa_spent = atoi(row[97]); + entry.aa_points_spent_old = atoi(row[98]); + entry.aa_points_old = atoi(row[99]); + entry.e_last_invsnapshot = atoi(row[100]); + entry.deleted_at = row[101] ? row[101] : ""; + + 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) { + CharacterData entry{}; + + entry.id = atoi(row[0]); + entry.account_id = atoi(row[1]); + entry.name = row[2] ? row[2] : ""; + entry.last_name = row[3] ? row[3] : ""; + entry.title = row[4] ? row[4] : ""; + entry.suffix = row[5] ? row[5] : ""; + entry.zone_id = atoi(row[6]); + entry.zone_instance = atoi(row[7]); + entry.y = atof(row[8]); + entry.x = atof(row[9]); + entry.z = atof(row[10]); + entry.heading = atof(row[11]); + entry.gender = atoi(row[12]); + entry.race = atoi(row[13]); + entry.class = atoi(row[14]); + entry.level = atoi(row[15]); + entry.deity = atoi(row[16]); + entry.birthday = atoi(row[17]); + entry.last_login = atoi(row[18]); + entry.time_played = atoi(row[19]); + entry.level2 = atoi(row[20]); + entry.anon = atoi(row[21]); + entry.gm = atoi(row[22]); + entry.face = atoi(row[23]); + entry.hair_color = atoi(row[24]); + entry.hair_style = atoi(row[25]); + entry.beard = atoi(row[26]); + entry.beard_color = atoi(row[27]); + entry.eye_color_1 = atoi(row[28]); + entry.eye_color_2 = atoi(row[29]); + entry.drakkin_heritage = atoi(row[30]); + entry.drakkin_tattoo = atoi(row[31]); + entry.drakkin_details = atoi(row[32]); + entry.ability_time_seconds = atoi(row[33]); + entry.ability_number = atoi(row[34]); + entry.ability_time_minutes = atoi(row[35]); + entry.ability_time_hours = atoi(row[36]); + entry.exp = atoi(row[37]); + entry.aa_points_spent = atoi(row[38]); + entry.aa_exp = atoi(row[39]); + entry.aa_points = atoi(row[40]); + entry.group_leadership_exp = atoi(row[41]); + entry.raid_leadership_exp = atoi(row[42]); + entry.group_leadership_points = atoi(row[43]); + entry.raid_leadership_points = atoi(row[44]); + entry.points = atoi(row[45]); + entry.cur_hp = atoi(row[46]); + entry.mana = atoi(row[47]); + entry.endurance = atoi(row[48]); + entry.intoxication = atoi(row[49]); + entry.str = atoi(row[50]); + entry.sta = atoi(row[51]); + entry.cha = atoi(row[52]); + entry.dex = atoi(row[53]); + entry.int = atoi(row[54]); + entry.agi = atoi(row[55]); + entry.wis = atoi(row[56]); + entry.zone_change_count = atoi(row[57]); + entry.toxicity = atoi(row[58]); + entry.hunger_level = atoi(row[59]); + entry.thirst_level = atoi(row[60]); + entry.ability_up = atoi(row[61]); + entry.ldon_points_guk = atoi(row[62]); + entry.ldon_points_mir = atoi(row[63]); + entry.ldon_points_mmc = atoi(row[64]); + entry.ldon_points_ruj = atoi(row[65]); + entry.ldon_points_tak = atoi(row[66]); + entry.ldon_points_available = atoi(row[67]); + entry.tribute_time_remaining = atoi(row[68]); + entry.career_tribute_points = atoi(row[69]); + entry.tribute_points = atoi(row[70]); + entry.tribute_active = atoi(row[71]); + entry.pvp_status = atoi(row[72]); + entry.pvp_kills = atoi(row[73]); + entry.pvp_deaths = atoi(row[74]); + entry.pvp_current_points = atoi(row[75]); + entry.pvp_career_points = atoi(row[76]); + entry.pvp_best_kill_streak = atoi(row[77]); + entry.pvp_worst_death_streak = atoi(row[78]); + entry.pvp_current_kill_streak = atoi(row[79]); + entry.pvp2 = atoi(row[80]); + entry.pvp_type = atoi(row[81]); + entry.show_helm = atoi(row[82]); + entry.group_auto_consent = atoi(row[83]); + entry.raid_auto_consent = atoi(row[84]); + entry.guild_auto_consent = atoi(row[85]); + entry.leadership_exp_on = atoi(row[86]); + entry.RestTimer = atoi(row[87]); + entry.air_remaining = atoi(row[88]); + entry.autosplit_enabled = atoi(row[89]); + entry.lfp = atoi(row[90]); + entry.lfg = atoi(row[91]); + entry.mailkey = row[92] ? row[92] : ""; + entry.xtargets = atoi(row[93]); + entry.firstlogon = atoi(row[94]); + entry.e_aa_effects = atoi(row[95]); + entry.e_percent_to_aa = atoi(row[96]); + entry.e_expended_aa_spent = atoi(row[97]); + entry.aa_points_spent_old = atoi(row[98]); + entry.aa_points_old = atoi(row[99]); + entry.e_last_invsnapshot = atoi(row[100]); + entry.deleted_at = row[101] ? row[101] : ""; + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_DATA_REPOSITORY_H diff --git a/common/repositories/base/base_character_disciplines_repository.h b/common/repositories/base/base_character_disciplines_repository.h new file mode 100644 index 000000000..3109327d1 --- /dev/null +++ b/common/repositories/base/base_character_disciplines_repository.h @@ -0,0 +1,312 @@ +/** + * 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 on Apr 5, 2020 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; + int16 slot_id; + int16 disc_id; + }; + + static std::string PrimaryKey() + { + return std::string("slot_id"); + } + + static std::vector Columns() + { + return { + "id", + "slot_id", + "disc_id", + }; + } + + 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_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 &character_discipliness, + int character_disciplines_id + ) + { + for (auto &character_disciplines : character_discipliness) { + if (character_disciplines.slot_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 update_values; + + auto columns = Columns(); + + 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.slot_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterDisciplines InsertOne( + CharacterDisciplines character_disciplines_entry + ) + { + std::vector insert_values; + + 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 character_disciplines_entries + ) + { + std::vector insert_chunks; + + for (auto &character_disciplines_entry: character_disciplines_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(character_disciplines_entry.disc_id)); + + 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_DISCIPLINES_REPOSITORY_H diff --git a/common/repositories/base/base_character_inspect_messages_repository.h b/common/repositories/base/base_character_inspect_messages_repository.h new file mode 100644 index 000000000..bc5ef873c --- /dev/null +++ b/common/repositories/base/base_character_inspect_messages_repository.h @@ -0,0 +1,306 @@ +/** + * 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 on Apr 5, 2020 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 Columns() + { + return { + "id", + "inspect_message", + }; + } + + 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_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 &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 update_values; + + auto columns = Columns(); + + 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 insert_values; + + 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 character_inspect_messages_entries + ) + { + std::vector insert_chunks; + + for (auto &character_inspect_messages_entry: character_inspect_messages_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(character_inspect_messages_entry.inspect_message) + "'"); + + 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_INSPECT_MESSAGES_REPOSITORY_H diff --git a/common/repositories/base/base_character_item_recast_repository.h b/common/repositories/base/base_character_item_recast_repository.h new file mode 100644 index 000000000..67ac8919c --- /dev/null +++ b/common/repositories/base/base_character_item_recast_repository.h @@ -0,0 +1,312 @@ +/** + * 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 on Apr 5, 2020 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; + int16 recast_type; + int timestamp; + }; + + static std::string PrimaryKey() + { + return std::string("recast_type"); + } + + static std::vector Columns() + { + return { + "id", + "recast_type", + "timestamp", + }; + } + + 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_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 &character_item_recasts, + int character_item_recast_id + ) + { + for (auto &character_item_recast : character_item_recasts) { + if (character_item_recast.recast_type == 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 update_values; + + auto columns = Columns(); + + 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.recast_type + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterItemRecast InsertOne( + CharacterItemRecast character_item_recast_entry + ) + { + std::vector insert_values; + + 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 character_item_recast_entries + ) + { + std::vector insert_chunks; + + for (auto &character_item_recast_entry: character_item_recast_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(character_item_recast_entry.timestamp)); + + 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_ITEM_RECAST_REPOSITORY_H diff --git a/common/repositories/base/base_character_languages_repository.h b/common/repositories/base/base_character_languages_repository.h new file mode 100644 index 000000000..9589fb5c9 --- /dev/null +++ b/common/repositories/base/base_character_languages_repository.h @@ -0,0 +1,312 @@ +/** + * 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 on Apr 5, 2020 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; + int16 lang_id; + int16 value; + }; + + static std::string PrimaryKey() + { + return std::string("lang_id"); + } + + static std::vector Columns() + { + return { + "id", + "lang_id", + "value", + }; + } + + 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_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 &character_languagess, + int character_languages_id + ) + { + for (auto &character_languages : character_languagess) { + if (character_languages.lang_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 update_values; + + auto columns = Columns(); + + 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.lang_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterLanguages InsertOne( + CharacterLanguages character_languages_entry + ) + { + std::vector insert_values; + + 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 character_languages_entries + ) + { + std::vector insert_chunks; + + for (auto &character_languages_entry: character_languages_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(character_languages_entry.value)); + + 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_LANGUAGES_REPOSITORY_H diff --git a/common/repositories/base/base_character_leadership_abilities_repository.h b/common/repositories/base/base_character_leadership_abilities_repository.h new file mode 100644 index 000000000..aa63e3a6c --- /dev/null +++ b/common/repositories/base/base_character_leadership_abilities_repository.h @@ -0,0 +1,312 @@ +/** + * 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 on Apr 5, 2020 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; + int16 slot; + int16 rank; + }; + + static std::string PrimaryKey() + { + return std::string("slot"); + } + + static std::vector Columns() + { + return { + "id", + "slot", + "rank", + }; + } + + 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_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 &character_leadership_abilitiess, + int character_leadership_abilities_id + ) + { + for (auto &character_leadership_abilities : character_leadership_abilitiess) { + if (character_leadership_abilities.slot == 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 update_values; + + auto columns = Columns(); + + 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.slot + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterLeadershipAbilities InsertOne( + CharacterLeadershipAbilities character_leadership_abilities_entry + ) + { + std::vector insert_values; + + 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 character_leadership_abilities_entries + ) + { + std::vector insert_chunks; + + for (auto &character_leadership_abilities_entry: character_leadership_abilities_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(character_leadership_abilities_entry.rank)); + + 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_LEADERSHIP_ABILITIES_REPOSITORY_H diff --git a/common/repositories/base/base_character_material_repository.h b/common/repositories/base/base_character_material_repository.h new file mode 100644 index 000000000..7a94e1b16 --- /dev/null +++ b/common/repositories/base/base_character_material_repository.h @@ -0,0 +1,348 @@ +/** + * 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 on Apr 5, 2020 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; + int8 slot; + int8 blue; + int8 green; + int8 red; + int8 use_tint; + int color; + }; + + static std::string PrimaryKey() + { + return std::string("slot"); + } + + static std::vector 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 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 &character_materials, + int character_material_id + ) + { + for (auto &character_material : character_materials) { + if (character_material.slot == 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 update_values; + + auto columns = Columns(); + + 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.slot + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterMaterial InsertOne( + CharacterMaterial character_material_entry + ) + { + std::vector insert_values; + + 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 character_material_entries + ) + { + std::vector insert_chunks; + + for (auto &character_material_entry: character_material_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_MATERIAL_REPOSITORY_H diff --git a/common/repositories/base/base_character_memmed_spells_repository.h b/common/repositories/base/base_character_memmed_spells_repository.h new file mode 100644 index 000000000..eb224025b --- /dev/null +++ b/common/repositories/base/base_character_memmed_spells_repository.h @@ -0,0 +1,312 @@ +/** + * 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 on Apr 5, 2020 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; + int16 slot_id; + int16 spell_id; + }; + + static std::string PrimaryKey() + { + return std::string("slot_id"); + } + + static std::vector Columns() + { + return { + "id", + "slot_id", + "spell_id", + }; + } + + 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_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 &character_memmed_spellss, + int character_memmed_spells_id + ) + { + for (auto &character_memmed_spells : character_memmed_spellss) { + if (character_memmed_spells.slot_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 update_values; + + auto columns = Columns(); + + 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.slot_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterMemmedSpells InsertOne( + CharacterMemmedSpells character_memmed_spells_entry + ) + { + std::vector insert_values; + + 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 character_memmed_spells_entries + ) + { + std::vector insert_chunks; + + for (auto &character_memmed_spells_entry: character_memmed_spells_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(character_memmed_spells_entry.spell_id)); + + 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_MEMMED_SPELLS_REPOSITORY_H diff --git a/common/repositories/base/base_character_pet_buffs_repository.h b/common/repositories/base/base_character_pet_buffs_repository.h new file mode 100644 index 000000000..1cd7b3f8a --- /dev/null +++ b/common/repositories/base/base_character_pet_buffs_repository.h @@ -0,0 +1,381 @@ +/** + * 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 on Apr 5, 2020 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; + int8 caster_level; + std::string castername; + int ticsremaining; + int counters; + int numhits; + int rune; + int8 instrument_mod; + }; + + static std::string PrimaryKey() + { + return std::string("slot"); + } + + static std::vector 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 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 &character_pet_buffss, + int character_pet_buffs_id + ) + { + for (auto &character_pet_buffs : character_pet_buffss) { + if (character_pet_buffs.slot == 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 update_values; + + auto columns = Columns(); + + 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.slot + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterPetBuffs InsertOne( + CharacterPetBuffs character_pet_buffs_entry + ) + { + std::vector insert_values; + + 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.id = results.LastInsertedID(); + return character_pet_buffs_entry; + } + + character_pet_buffs_entry = NewEntity(); + + return character_pet_buffs_entry; + } + + static int InsertMany( + std::vector character_pet_buffs_entries + ) + { + std::vector insert_chunks; + + for (auto &character_pet_buffs_entry: character_pet_buffs_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_PET_BUFFS_REPOSITORY_H diff --git a/common/repositories/base/base_character_pet_info_repository.h b/common/repositories/base/base_character_pet_info_repository.h new file mode 100644 index 000000000..fd5c64fd6 --- /dev/null +++ b/common/repositories/base/base_character_pet_info_repository.h @@ -0,0 +1,357 @@ +/** + * 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 on Apr 5, 2020 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("pet"); + } + + static std::vector 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 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 &character_pet_infos, + int character_pet_info_id + ) + { + for (auto &character_pet_info : character_pet_infos) { + if (character_pet_info.pet == 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 = 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 update_values; + + auto columns = Columns(); + + 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.pet + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterPetInfo InsertOne( + CharacterPetInfo character_pet_info_entry + ) + { + std::vector insert_values; + + 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.id = results.LastInsertedID(); + return character_pet_info_entry; + } + + character_pet_info_entry = NewEntity(); + + return character_pet_info_entry; + } + + static int InsertMany( + std::vector character_pet_info_entries + ) + { + std::vector insert_chunks; + + for (auto &character_pet_info_entry: character_pet_info_entries) { + std::vector insert_values; + + 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 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) { + 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 = atof(row[7]); + + 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) { + 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 = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_PET_INFO_REPOSITORY_H diff --git a/common/repositories/base/base_character_pet_inventory_repository.h b/common/repositories/base/base_character_pet_inventory_repository.h new file mode 100644 index 000000000..f2a79f898 --- /dev/null +++ b/common/repositories/base/base_character_pet_inventory_repository.h @@ -0,0 +1,318 @@ +/** + * 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 on Apr 5, 2020 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("slot"); + } + + static std::vector Columns() + { + return { + "char_id", + "pet", + "slot", + "item_id", + }; + } + + 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_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 &character_pet_inventorys, + int character_pet_inventory_id + ) + { + for (auto &character_pet_inventory : character_pet_inventorys) { + if (character_pet_inventory.slot == 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 update_values; + + auto columns = Columns(); + + 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.slot + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterPetInventory InsertOne( + CharacterPetInventory character_pet_inventory_entry + ) + { + std::vector insert_values; + + 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.id = results.LastInsertedID(); + return character_pet_inventory_entry; + } + + character_pet_inventory_entry = NewEntity(); + + return character_pet_inventory_entry; + } + + static int InsertMany( + std::vector character_pet_inventory_entries + ) + { + std::vector insert_chunks; + + for (auto &character_pet_inventory_entry: character_pet_inventory_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(character_pet_inventory_entry.item_id)); + + 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_PET_INVENTORY_REPOSITORY_H diff --git a/common/repositories/base/base_character_potionbelt_repository.h b/common/repositories/base/base_character_potionbelt_repository.h new file mode 100644 index 000000000..9c017a009 --- /dev/null +++ b/common/repositories/base/base_character_potionbelt_repository.h @@ -0,0 +1,321 @@ +/** + * 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 on Apr 5, 2020 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; + int8 potion_id; + int item_id; + int icon; + }; + + static std::string PrimaryKey() + { + return std::string("potion_id"); + } + + static std::vector Columns() + { + return { + "id", + "potion_id", + "item_id", + "icon", + }; + } + + 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_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 &character_potionbelts, + int character_potionbelt_id + ) + { + for (auto &character_potionbelt : character_potionbelts) { + if (character_potionbelt.potion_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 update_values; + + auto columns = Columns(); + + 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.potion_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterPotionbelt InsertOne( + CharacterPotionbelt character_potionbelt_entry + ) + { + std::vector insert_values; + + 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 character_potionbelt_entries + ) + { + std::vector insert_chunks; + + for (auto &character_potionbelt_entry: character_potionbelt_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_POTIONBELT_REPOSITORY_H diff --git a/common/repositories/base/base_character_skills_repository.h b/common/repositories/base/base_character_skills_repository.h new file mode 100644 index 000000000..4298c7e5e --- /dev/null +++ b/common/repositories/base/base_character_skills_repository.h @@ -0,0 +1,312 @@ +/** + * 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 on Apr 5, 2020 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; + int16 skill_id; + int16 value; + }; + + static std::string PrimaryKey() + { + return std::string("skill_id"); + } + + static std::vector Columns() + { + return { + "id", + "skill_id", + "value", + }; + } + + 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_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 &character_skillss, + int character_skills_id + ) + { + for (auto &character_skills : character_skillss) { + if (character_skills.skill_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 update_values; + + auto columns = Columns(); + + 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.skill_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterSkills InsertOne( + CharacterSkills character_skills_entry + ) + { + std::vector insert_values; + + 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 character_skills_entries + ) + { + std::vector insert_chunks; + + for (auto &character_skills_entry: character_skills_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(character_skills_entry.value)); + + 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_SKILLS_REPOSITORY_H diff --git a/common/repositories/base/base_character_spells_repository.h b/common/repositories/base/base_character_spells_repository.h new file mode 100644 index 000000000..0e9a8c182 --- /dev/null +++ b/common/repositories/base/base_character_spells_repository.h @@ -0,0 +1,312 @@ +/** + * 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 on Apr 5, 2020 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; + int16 slot_id; + int16 spell_id; + }; + + static std::string PrimaryKey() + { + return std::string("slot_id"); + } + + static std::vector Columns() + { + return { + "id", + "slot_id", + "spell_id", + }; + } + + 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_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 &character_spellss, + int character_spells_id + ) + { + for (auto &character_spells : character_spellss) { + if (character_spells.slot_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 update_values; + + auto columns = Columns(); + + 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.slot_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterSpells InsertOne( + CharacterSpells character_spells_entry + ) + { + std::vector insert_values; + + 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 character_spells_entries + ) + { + std::vector insert_chunks; + + for (auto &character_spells_entry: character_spells_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(character_spells_entry.spell_id)); + + 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_SPELLS_REPOSITORY_H diff --git a/common/repositories/base/base_character_tasks_repository.h b/common/repositories/base/base_character_tasks_repository.h new file mode 100644 index 000000000..362a81e37 --- /dev/null +++ b/common/repositories/base/base_character_tasks_repository.h @@ -0,0 +1,330 @@ +/** + * 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 on Apr 5, 2020 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; + int8 type; + int acceptedtime; + }; + + static std::string PrimaryKey() + { + return std::string("taskid"); + } + + static std::vector Columns() + { + return { + "charid", + "taskid", + "slot", + "type", + "acceptedtime", + }; + } + + 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_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 &character_taskss, + int character_tasks_id + ) + { + for (auto &character_tasks : character_taskss) { + if (character_tasks.taskid == 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 update_values; + + auto columns = Columns(); + + 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.taskid + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterTasks InsertOne( + CharacterTasks character_tasks_entry + ) + { + std::vector insert_values; + + 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.id = results.LastInsertedID(); + return character_tasks_entry; + } + + character_tasks_entry = NewEntity(); + + return character_tasks_entry; + } + + static int InsertMany( + std::vector character_tasks_entries + ) + { + std::vector insert_chunks; + + for (auto &character_tasks_entry: character_tasks_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_TASKS_REPOSITORY_H diff --git a/common/repositories/base/base_character_tribute_repository.h b/common/repositories/base/base_character_tribute_repository.h new file mode 100644 index 000000000..8c3d318c8 --- /dev/null +++ b/common/repositories/base/base_character_tribute_repository.h @@ -0,0 +1,318 @@ +/** + * 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 on Apr 5, 2020 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_TRIBUTE_REPOSITORY_H +#define EQEMU_BASE_CHARACTER_TRIBUTE_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseCharacterTributeRepository { +public: + struct CharacterTribute { + int id; + int8 tier; + int tribute; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "tier", + "tribute", + }; + } + + 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_tribute"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static CharacterTribute NewEntity() + { + CharacterTribute entry{}; + + entry.id = 0; + entry.tier = 0; + entry.tribute = 0; + + return entry; + } + + static CharacterTribute GetCharacterTributeEntry( + const std::vector &character_tributes, + int character_tribute_id + ) + { + for (auto &character_tribute : character_tributes) { + if (character_tribute.id == character_tribute_id) { + return character_tribute; + } + } + + return NewEntity(); + } + + static CharacterTribute FindOne( + int character_tribute_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + character_tribute_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + CharacterTribute entry{}; + + entry.id = atoi(row[0]); + entry.tier = atoi(row[1]); + entry.tribute = atoi(row[2]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int character_tribute_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + character_tribute_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + CharacterTribute character_tribute_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[0] + " = " + std::to_string(character_tribute_entry.id)); + update_values.push_back(columns[1] + " = " + std::to_string(character_tribute_entry.tier)); + update_values.push_back(columns[2] + " = " + std::to_string(character_tribute_entry.tribute)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + character_tribute_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterTribute InsertOne( + CharacterTribute character_tribute_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(character_tribute_entry.id)); + insert_values.push_back(std::to_string(character_tribute_entry.tier)); + insert_values.push_back(std::to_string(character_tribute_entry.tribute)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + character_tribute_entry.id = results.LastInsertedID(); + return character_tribute_entry; + } + + character_tribute_entry = NewEntity(); + + return character_tribute_entry; + } + + static int InsertMany( + std::vector character_tribute_entries + ) + { + std::vector insert_chunks; + + for (auto &character_tribute_entry: character_tribute_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(character_tribute_entry.id)); + insert_values.push_back(std::to_string(character_tribute_entry.tier)); + insert_values.push_back(std::to_string(character_tribute_entry.tribute)); + + 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) { + CharacterTribute entry{}; + + entry.id = atoi(row[0]); + entry.tier = atoi(row[1]); + entry.tribute = atoi(row[2]); + + 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) { + CharacterTribute entry{}; + + entry.id = atoi(row[0]); + entry.tier = atoi(row[1]); + entry.tribute = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_TRIBUTE_REPOSITORY_H diff --git a/common/repositories/base/base_chatchannels_repository.h b/common/repositories/base/base_chatchannels_repository.h new file mode 100644 index 000000000..680e6a4bb --- /dev/null +++ b/common/repositories/base/base_chatchannels_repository.h @@ -0,0 +1,324 @@ +/** + * 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 on Apr 5, 2020 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_CHATCHANNELS_REPOSITORY_H +#define EQEMU_BASE_CHATCHANNELS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseChatchannelsRepository { +public: + struct Chatchannels { + std::string name; + std::string owner; + std::string password; + int minstatus; + }; + + static std::string PrimaryKey() + { + return std::string("name"); + } + + static std::vector Columns() + { + return { + "name", + "owner", + "password", + "minstatus", + }; + } + + 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("chatchannels"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Chatchannels NewEntity() + { + Chatchannels entry{}; + + entry.name = ""; + entry.owner = ""; + entry.password = ""; + entry.minstatus = 0; + + return entry; + } + + static Chatchannels GetChatchannelsEntry( + const std::vector &chatchannelss, + int chatchannels_id + ) + { + for (auto &chatchannels : chatchannelss) { + if (chatchannels.name == chatchannels_id) { + return chatchannels; + } + } + + return NewEntity(); + } + + static Chatchannels FindOne( + int chatchannels_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + chatchannels_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Chatchannels entry{}; + + entry.name = row[0] ? row[0] : ""; + entry.owner = row[1] ? row[1] : ""; + entry.password = row[2] ? row[2] : ""; + entry.minstatus = atoi(row[3]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int chatchannels_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + chatchannels_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Chatchannels chatchannels_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(chatchannels_entry.owner) + "'"); + update_values.push_back(columns[2] + " = '" + EscapeString(chatchannels_entry.password) + "'"); + update_values.push_back(columns[3] + " = " + std::to_string(chatchannels_entry.minstatus)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + chatchannels_entry.name + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Chatchannels InsertOne( + Chatchannels chatchannels_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(chatchannels_entry.owner) + "'"); + insert_values.push_back("'" + EscapeString(chatchannels_entry.password) + "'"); + insert_values.push_back(std::to_string(chatchannels_entry.minstatus)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + chatchannels_entry.id = results.LastInsertedID(); + return chatchannels_entry; + } + + chatchannels_entry = NewEntity(); + + return chatchannels_entry; + } + + static int InsertMany( + std::vector chatchannels_entries + ) + { + std::vector insert_chunks; + + for (auto &chatchannels_entry: chatchannels_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(chatchannels_entry.owner) + "'"); + insert_values.push_back("'" + EscapeString(chatchannels_entry.password) + "'"); + insert_values.push_back(std::to_string(chatchannels_entry.minstatus)); + + 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) { + Chatchannels entry{}; + + entry.name = row[0] ? row[0] : ""; + entry.owner = row[1] ? row[1] : ""; + entry.password = row[2] ? row[2] : ""; + entry.minstatus = 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) { + Chatchannels entry{}; + + entry.name = row[0] ? row[0] : ""; + entry.owner = row[1] ? row[1] : ""; + entry.password = row[2] ? row[2] : ""; + entry.minstatus = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHATCHANNELS_REPOSITORY_H diff --git a/common/repositories/base/base_command_settings_repository.h b/common/repositories/base/base_command_settings_repository.h new file mode 100644 index 000000000..98233bdd7 --- /dev/null +++ b/common/repositories/base/base_command_settings_repository.h @@ -0,0 +1,315 @@ +/** + * 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 on Apr 5, 2020 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_COMMAND_SETTINGS_REPOSITORY_H +#define EQEMU_BASE_COMMAND_SETTINGS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseCommandSettingsRepository { +public: + struct CommandSettings { + std::string command; + int access; + std::string aliases; + }; + + static std::string PrimaryKey() + { + return std::string("command"); + } + + static std::vector Columns() + { + return { + "command", + "access", + "aliases", + }; + } + + 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("command_settings"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static CommandSettings NewEntity() + { + CommandSettings entry{}; + + entry.command = ""; + entry.access = 0; + entry.aliases = ""; + + return entry; + } + + static CommandSettings GetCommandSettingsEntry( + const std::vector &command_settingss, + int command_settings_id + ) + { + for (auto &command_settings : command_settingss) { + if (command_settings.command == command_settings_id) { + return command_settings; + } + } + + return NewEntity(); + } + + static CommandSettings FindOne( + int command_settings_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + command_settings_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + CommandSettings entry{}; + + entry.command = row[0] ? row[0] : ""; + entry.access = atoi(row[1]); + entry.aliases = row[2] ? row[2] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int command_settings_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + command_settings_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + CommandSettings command_settings_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(command_settings_entry.access)); + update_values.push_back(columns[2] + " = '" + EscapeString(command_settings_entry.aliases) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + command_settings_entry.command + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CommandSettings InsertOne( + CommandSettings command_settings_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(command_settings_entry.access)); + insert_values.push_back("'" + EscapeString(command_settings_entry.aliases) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + command_settings_entry.id = results.LastInsertedID(); + return command_settings_entry; + } + + command_settings_entry = NewEntity(); + + return command_settings_entry; + } + + static int InsertMany( + std::vector command_settings_entries + ) + { + std::vector insert_chunks; + + for (auto &command_settings_entry: command_settings_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(command_settings_entry.access)); + insert_values.push_back("'" + EscapeString(command_settings_entry.aliases) + "'"); + + 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) { + CommandSettings entry{}; + + entry.command = row[0] ? row[0] : ""; + entry.access = atoi(row[1]); + entry.aliases = row[2] ? row[2] : ""; + + 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) { + CommandSettings entry{}; + + entry.command = row[0] ? row[0] : ""; + entry.access = atoi(row[1]); + entry.aliases = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_COMMAND_SETTINGS_REPOSITORY_H diff --git a/common/repositories/base/base_completed_tasks_repository.h b/common/repositories/base/base_completed_tasks_repository.h new file mode 100644 index 000000000..5b2ddfd07 --- /dev/null +++ b/common/repositories/base/base_completed_tasks_repository.h @@ -0,0 +1,318 @@ +/** + * 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 on Apr 5, 2020 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("activityid"); + } + + static std::vector Columns() + { + return { + "charid", + "completedtime", + "taskid", + "activityid", + }; + } + + 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("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 &completed_taskss, + int completed_tasks_id + ) + { + for (auto &completed_tasks : completed_taskss) { + if (completed_tasks.activityid == 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 update_values; + + auto columns = Columns(); + + + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + completed_tasks_entry.activityid + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CompletedTasks InsertOne( + CompletedTasks completed_tasks_entry + ) + { + std::vector insert_values; + + + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + completed_tasks_entry.id = results.LastInsertedID(); + return completed_tasks_entry; + } + + completed_tasks_entry = NewEntity(); + + return completed_tasks_entry; + } + + static int InsertMany( + std::vector completed_tasks_entries + ) + { + std::vector insert_chunks; + + for (auto &completed_tasks_entry: completed_tasks_entries) { + std::vector insert_values; + + + + 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_COMPLETED_TASKS_REPOSITORY_H diff --git a/common/repositories/base/base_data_buckets_repository.h b/common/repositories/base/base_data_buckets_repository.h new file mode 100644 index 000000000..a3704fb90 --- /dev/null +++ b/common/repositories/base/base_data_buckets_repository.h @@ -0,0 +1,324 @@ +/** + * 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 on Apr 5, 2020 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 Columns() + { + return { + "id", + "key", + "value", + "expires", + }; + } + + 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("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 &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 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 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 data_buckets_entries + ) + { + std::vector insert_chunks; + + for (auto &data_buckets_entry: data_buckets_entries) { + std::vector 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_DATA_BUCKETS_REPOSITORY_H diff --git a/common/repositories/base/base_db_str_repository.h b/common/repositories/base/base_db_str_repository.h new file mode 100644 index 000000000..9268f9647 --- /dev/null +++ b/common/repositories/base/base_db_str_repository.h @@ -0,0 +1,312 @@ +/** + * 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 on Apr 5, 2020 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("type"); + } + + static std::vector Columns() + { + return { + "id", + "type", + "value", + }; + } + + 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("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 &db_strs, + int db_str_id + ) + { + for (auto &db_str : db_strs) { + if (db_str.type == 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 update_values; + + auto columns = Columns(); + + 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.type + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static DbStr InsertOne( + DbStr db_str_entry + ) + { + std::vector insert_values; + + 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 db_str_entries + ) + { + std::vector insert_chunks; + + for (auto &db_str_entry: db_str_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(db_str_entry.value) + "'"); + + 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_DB_STR_REPOSITORY_H diff --git a/common/repositories/base/base_discovered_items_repository.h b/common/repositories/base/base_discovered_items_repository.h new file mode 100644 index 000000000..2c7d88ddb --- /dev/null +++ b/common/repositories/base/base_discovered_items_repository.h @@ -0,0 +1,324 @@ +/** + * 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 on Apr 5, 2020 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 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 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 &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 update_values; + + auto columns = Columns(); + + 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 insert_values; + + 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.id = results.LastInsertedID(); + return discovered_items_entry; + } + + discovered_items_entry = NewEntity(); + + return discovered_items_entry; + } + + static int InsertMany( + std::vector discovered_items_entries + ) + { + std::vector insert_chunks; + + for (auto &discovered_items_entry: discovered_items_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_DISCOVERED_ITEMS_REPOSITORY_H diff --git a/common/repositories/base/base_doors_repository.h b/common/repositories/base/base_doors_repository.h new file mode 100644 index 000000000..885c931b9 --- /dev/null +++ b/common/repositories/base/base_doors_repository.h @@ -0,0 +1,594 @@ +/** + * 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 on Apr 5, 2020 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; + int16 doorid; + std::string zone; + int16 version; + std::string name; + float pos_y; + float pos_x; + float pos_z; + float heading; + int16 opentype; + int16 guild; + int16 lockpick; + int keyitem; + int8 nokeyring; + int16 triggerdoor; + int16 triggertype; + int8 disable_timer; + int16 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; + int16 size; + float buffer; + int client_version_mask; + int16 is_ldon_door; + int8 min_expansion; + int8 max_expansion; + std::string content_flags; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector 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", + }; + } + + 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("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 = ""; + + return entry; + } + + static Doors GetDoorsEntry( + const std::vector &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 = atof(row[5]); + entry.pos_x = atof(row[6]); + entry.pos_z = atof(row[7]); + entry.heading = 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 = atof(row[21]); + entry.dest_y = atof(row[22]); + entry.dest_z = atof(row[23]); + entry.dest_heading = atof(row[24]); + entry.invert_state = atoi(row[25]); + entry.incline = atoi(row[26]); + entry.size = atoi(row[27]); + entry.buffer = 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] : ""; + + 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 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) + "'"); + + 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 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) + "'"); + + 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_entries + ) + { + std::vector insert_chunks; + + for (auto &doors_entry: doors_entries) { + std::vector 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_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) { + 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 = atof(row[5]); + entry.pos_x = atof(row[6]); + entry.pos_z = atof(row[7]); + entry.heading = 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 = atof(row[21]); + entry.dest_y = atof(row[22]); + entry.dest_z = atof(row[23]); + entry.dest_heading = atof(row[24]); + entry.invert_state = atoi(row[25]); + entry.incline = atoi(row[26]); + entry.size = atoi(row[27]); + entry.buffer = 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] : ""; + + 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) { + 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 = atof(row[5]); + entry.pos_x = atof(row[6]); + entry.pos_z = atof(row[7]); + entry.heading = 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 = atof(row[21]); + entry.dest_y = atof(row[22]); + entry.dest_z = atof(row[23]); + entry.dest_heading = atof(row[24]); + entry.invert_state = atoi(row[25]); + entry.incline = atoi(row[26]); + entry.size = atoi(row[27]); + entry.buffer = 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] : ""; + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_DOORS_REPOSITORY_H diff --git a/common/repositories/base/base_eventlog_repository.h b/common/repositories/base/base_eventlog_repository.h new file mode 100644 index 000000000..069a56667 --- /dev/null +++ b/common/repositories/base/base_eventlog_repository.h @@ -0,0 +1,378 @@ +/** + * 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 on Apr 5, 2020 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 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 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 &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 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 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_entries + ) + { + std::vector insert_chunks; + + for (auto &eventlog_entry: eventlog_entries) { + std::vector 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_EVENTLOG_REPOSITORY_H diff --git a/common/repositories/base/base_faction_base_data_repository.h b/common/repositories/base/base_faction_base_data_repository.h new file mode 100644 index 000000000..b32fdff98 --- /dev/null +++ b/common/repositories/base/base_faction_base_data_repository.h @@ -0,0 +1,342 @@ +/** + * 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 on Apr 5, 2020 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 { + int16 client_faction_id; + int16 min; + int16 max; + int16 unk_hero1; + int16 unk_hero2; + int16 unk_hero3; + }; + + static std::string PrimaryKey() + { + return std::string("client_faction_id"); + } + + static std::vector 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 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 &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 update_values; + + auto columns = Columns(); + + 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 insert_values; + + 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.id = results.LastInsertedID(); + return faction_base_data_entry; + } + + faction_base_data_entry = NewEntity(); + + return faction_base_data_entry; + } + + static int InsertMany( + std::vector faction_base_data_entries + ) + { + std::vector insert_chunks; + + for (auto &faction_base_data_entry: faction_base_data_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_FACTION_BASE_DATA_REPOSITORY_H diff --git a/common/repositories/base/base_faction_list_mod_repository.h b/common/repositories/base/base_faction_list_mod_repository.h new file mode 100644 index 000000000..8cff9e393 --- /dev/null +++ b/common/repositories/base/base_faction_list_mod_repository.h @@ -0,0 +1,324 @@ +/** + * 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 on Apr 5, 2020 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; + int16 mod; + std::string mod_name; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "faction_id", + "mod", + "mod_name", + }; + } + + 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("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 &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 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 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 faction_list_mod_entries + ) + { + std::vector insert_chunks; + + for (auto &faction_list_mod_entry: faction_list_mod_entries) { + std::vector 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_FACTION_LIST_MOD_REPOSITORY_H diff --git a/common/repositories/base/base_faction_list_repository.h b/common/repositories/base/base_faction_list_repository.h new file mode 100644 index 000000000..c6f191421 --- /dev/null +++ b/common/repositories/base/base_faction_list_repository.h @@ -0,0 +1,315 @@ +/** + * 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 on Apr 5, 2020 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; + int16 base; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "name", + "base", + }; + } + + 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("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 &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 update_values; + + auto columns = Columns(); + + 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 insert_values; + + 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 faction_list_entries + ) + { + std::vector insert_chunks; + + for (auto &faction_list_entry: faction_list_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_FACTION_LIST_REPOSITORY_H diff --git a/common/repositories/base/base_faction_values_repository.h b/common/repositories/base/base_faction_values_repository.h new file mode 100644 index 000000000..3d2f3da69 --- /dev/null +++ b/common/repositories/base/base_faction_values_repository.h @@ -0,0 +1,321 @@ +/** + * 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 on Apr 5, 2020 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; + int16 current_value; + int8 temp; + }; + + static std::string PrimaryKey() + { + return std::string("faction_id"); + } + + static std::vector Columns() + { + return { + "char_id", + "faction_id", + "current_value", + "temp", + }; + } + + 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("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 &faction_valuess, + int faction_values_id + ) + { + for (auto &faction_values : faction_valuess) { + if (faction_values.faction_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 update_values; + + auto columns = Columns(); + + 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.faction_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static FactionValues InsertOne( + FactionValues faction_values_entry + ) + { + std::vector insert_values; + + 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.id = results.LastInsertedID(); + return faction_values_entry; + } + + faction_values_entry = NewEntity(); + + return faction_values_entry; + } + + static int InsertMany( + std::vector faction_values_entries + ) + { + std::vector insert_chunks; + + for (auto &faction_values_entry: faction_values_entries) { + std::vector insert_values; + + 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 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_FACTION_VALUES_REPOSITORY_H diff --git a/common/repositories/base/base_fishing_repository.h b/common/repositories/base/base_fishing_repository.h new file mode 100644 index 000000000..7e164bc12 --- /dev/null +++ b/common/repositories/base/base_fishing_repository.h @@ -0,0 +1,378 @@ +/** + * 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 on Apr 5, 2020 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; + int16 skill_level; + int16 chance; + int npc_id; + int npc_chance; + int8 min_expansion; + int8 max_expansion; + std::string content_flags; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "zoneid", + "Itemid", + "skill_level", + "chance", + "npc_id", + "npc_chance", + "min_expansion", + "max_expansion", + "content_flags", + }; + } + + 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("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 = ""; + + return entry; + } + + static Fishing GetFishingEntry( + const std::vector &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] : ""; + + 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 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) + "'"); + + 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 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) + "'"); + + 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_entries + ) + { + std::vector insert_chunks; + + for (auto &fishing_entry: fishing_entries) { + std::vector 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_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) { + 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] : ""; + + 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) { + 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] : ""; + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_FISHING_REPOSITORY_H diff --git a/common/repositories/base/base_forage_repository.h b/common/repositories/base/base_forage_repository.h new file mode 100644 index 000000000..9b5fbd371 --- /dev/null +++ b/common/repositories/base/base_forage_repository.h @@ -0,0 +1,360 @@ +/** + * 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 on Apr 5, 2020 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; + int16 level; + int16 chance; + int8 min_expansion; + int8 max_expansion; + std::string content_flags; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "zoneid", + "Itemid", + "level", + "chance", + "min_expansion", + "max_expansion", + "content_flags", + }; + } + + 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("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 = ""; + + return entry; + } + + static Forage GetForageEntry( + const std::vector &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] : ""; + + 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 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) + "'"); + + 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 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) + "'"); + + 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_entries + ) + { + std::vector insert_chunks; + + for (auto &forage_entry: forage_entries) { + std::vector 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_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) { + 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] : ""; + + 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) { + 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] : ""; + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_FORAGE_REPOSITORY_H diff --git a/common/repositories/base/base_friends_repository.h b/common/repositories/base/base_friends_repository.h new file mode 100644 index 000000000..67220e475 --- /dev/null +++ b/common/repositories/base/base_friends_repository.h @@ -0,0 +1,312 @@ +/** + * 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 on Apr 5, 2020 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; + int8 type; + std::string name; + }; + + static std::string PrimaryKey() + { + return std::string("name"); + } + + static std::vector Columns() + { + return { + "charid", + "type", + "name", + }; + } + + 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("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 &friendss, + int friends_id + ) + { + for (auto &friends : friendss) { + if (friends.name == 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 update_values; + + auto columns = Columns(); + + + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + friends_entry.name + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Friends InsertOne( + Friends friends_entry + ) + { + std::vector insert_values; + + + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + friends_entry.id = results.LastInsertedID(); + return friends_entry; + } + + friends_entry = NewEntity(); + + return friends_entry; + } + + static int InsertMany( + std::vector friends_entries + ) + { + std::vector insert_chunks; + + for (auto &friends_entry: friends_entries) { + std::vector insert_values; + + + + 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) { + 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 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) { + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_FRIENDS_REPOSITORY_H diff --git a/common/repositories/base/base_global_loot_repository.h b/common/repositories/base/base_global_loot_repository.h new file mode 100644 index 000000000..4528434c7 --- /dev/null +++ b/common/repositories/base/base_global_loot_repository.h @@ -0,0 +1,432 @@ +/** + * 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 on Apr 5, 2020 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; + int8 enabled; + int min_level; + int max_level; + int8 rare; + int8 raid; + std::string race; + std::string class; + std::string bodytype; + std::string zone; + int8 hot_zone; + int8 min_expansion; + int8 max_expansion; + std::string content_flags; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector 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", + }; + } + + 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("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 = ""; + + return entry; + } + + static GlobalLoot GetGlobalLootEntry( + const std::vector &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] : ""; + + 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 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) + "'"); + + 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 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) + "'"); + + 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 global_loot_entries + ) + { + std::vector insert_chunks; + + for (auto &global_loot_entry: global_loot_entries) { + std::vector 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_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) { + 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] : ""; + + 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) { + 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] : ""; + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_GLOBAL_LOOT_REPOSITORY_H diff --git a/common/repositories/base/base_gm_ips_repository.h b/common/repositories/base/base_gm_ips_repository.h new file mode 100644 index 000000000..6d80f5bd5 --- /dev/null +++ b/common/repositories/base/base_gm_ips_repository.h @@ -0,0 +1,312 @@ +/** + * 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 on Apr 5, 2020 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_GM_IPS_REPOSITORY_H +#define EQEMU_BASE_GM_IPS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseGmIpsRepository { +public: + struct GmIps { + std::string name; + int account_id; + std::string ip_address; + }; + + static std::string PrimaryKey() + { + return std::string("ip_address"); + } + + static std::vector Columns() + { + return { + "name", + "account_id", + "ip_address", + }; + } + + 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("gm_ips"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static GmIps NewEntity() + { + GmIps entry{}; + + entry.name = ""; + entry.account_id = 0; + entry.ip_address = ""; + + return entry; + } + + static GmIps GetGmIpsEntry( + const std::vector &gm_ipss, + int gm_ips_id + ) + { + for (auto &gm_ips : gm_ipss) { + if (gm_ips.ip_address == gm_ips_id) { + return gm_ips; + } + } + + return NewEntity(); + } + + static GmIps FindOne( + int gm_ips_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + gm_ips_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + GmIps entry{}; + + entry.name = row[0] ? row[0] : ""; + entry.account_id = atoi(row[1]); + entry.ip_address = row[2] ? row[2] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int gm_ips_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + gm_ips_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + GmIps gm_ips_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[0] + " = '" + EscapeString(gm_ips_entry.name) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + gm_ips_entry.ip_address + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static GmIps InsertOne( + GmIps gm_ips_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(gm_ips_entry.name) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + gm_ips_entry.id = results.LastInsertedID(); + return gm_ips_entry; + } + + gm_ips_entry = NewEntity(); + + return gm_ips_entry; + } + + static int InsertMany( + std::vector gm_ips_entries + ) + { + std::vector insert_chunks; + + for (auto &gm_ips_entry: gm_ips_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(gm_ips_entry.name) + "'"); + + 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) { + GmIps entry{}; + + entry.name = row[0] ? row[0] : ""; + entry.account_id = atoi(row[1]); + entry.ip_address = row[2] ? row[2] : ""; + + 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) { + GmIps entry{}; + + entry.name = row[0] ? row[0] : ""; + entry.account_id = atoi(row[1]); + entry.ip_address = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_GM_IPS_REPOSITORY_H diff --git a/common/repositories/base/base_goallists_repository.h b/common/repositories/base/base_goallists_repository.h new file mode 100644 index 000000000..3b9dfb808 --- /dev/null +++ b/common/repositories/base/base_goallists_repository.h @@ -0,0 +1,306 @@ +/** + * 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 on Apr 5, 2020 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_GOALLISTS_REPOSITORY_H +#define EQEMU_BASE_GOALLISTS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseGoallistsRepository { +public: + struct Goallists { + int listid; + int entry; + }; + + static std::string PrimaryKey() + { + return std::string("entry"); + } + + static std::vector Columns() + { + return { + "listid", + "entry", + }; + } + + 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("goallists"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Goallists NewEntity() + { + Goallists entry{}; + + entry.listid = 0; + entry.entry = 0; + + return entry; + } + + static Goallists GetGoallistsEntry( + const std::vector &goallistss, + int goallists_id + ) + { + for (auto &goallists : goallistss) { + if (goallists.entry == goallists_id) { + return goallists; + } + } + + return NewEntity(); + } + + static Goallists FindOne( + int goallists_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + goallists_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Goallists entry{}; + + entry.listid = atoi(row[0]); + entry.entry = atoi(row[1]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int goallists_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + goallists_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Goallists goallists_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + goallists_entry.entry + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Goallists InsertOne( + Goallists goallists_entry + ) + { + std::vector insert_values; + + + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + goallists_entry.id = results.LastInsertedID(); + return goallists_entry; + } + + goallists_entry = NewEntity(); + + return goallists_entry; + } + + static int InsertMany( + std::vector goallists_entries + ) + { + std::vector insert_chunks; + + for (auto &goallists_entry: goallists_entries) { + std::vector insert_values; + + + + 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) { + Goallists entry{}; + + entry.listid = atoi(row[0]); + entry.entry = 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) { + Goallists entry{}; + + entry.listid = atoi(row[0]); + entry.entry = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_GOALLISTS_REPOSITORY_H diff --git a/common/repositories/base/base_graveyard_repository.h b/common/repositories/base/base_graveyard_repository.h new file mode 100644 index 000000000..7019a7d40 --- /dev/null +++ b/common/repositories/base/base_graveyard_repository.h @@ -0,0 +1,342 @@ +/** + * 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 on Apr 5, 2020 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_GRAVEYARD_REPOSITORY_H +#define EQEMU_BASE_GRAVEYARD_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseGraveyardRepository { +public: + struct Graveyard { + int id; + int zone_id; + float x; + float y; + float z; + float heading; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "zone_id", + "x", + "y", + "z", + "heading", + }; + } + + 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("graveyard"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Graveyard NewEntity() + { + Graveyard entry{}; + + entry.id = 0; + entry.zone_id = 0; + entry.x = 0; + entry.y = 0; + entry.z = 0; + entry.heading = 0; + + return entry; + } + + static Graveyard GetGraveyardEntry( + const std::vector &graveyards, + int graveyard_id + ) + { + for (auto &graveyard : graveyards) { + if (graveyard.id == graveyard_id) { + return graveyard; + } + } + + return NewEntity(); + } + + static Graveyard FindOne( + int graveyard_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + graveyard_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Graveyard entry{}; + + entry.id = atoi(row[0]); + entry.zone_id = atoi(row[1]); + entry.x = atof(row[2]); + entry.y = atof(row[3]); + entry.z = atof(row[4]); + entry.heading = atof(row[5]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int graveyard_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + graveyard_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Graveyard graveyard_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(graveyard_entry.zone_id)); + update_values.push_back(columns[2] + " = " + std::to_string(graveyard_entry.x)); + update_values.push_back(columns[3] + " = " + std::to_string(graveyard_entry.y)); + update_values.push_back(columns[4] + " = " + std::to_string(graveyard_entry.z)); + update_values.push_back(columns[5] + " = " + std::to_string(graveyard_entry.heading)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + graveyard_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Graveyard InsertOne( + Graveyard graveyard_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(graveyard_entry.zone_id)); + insert_values.push_back(std::to_string(graveyard_entry.x)); + insert_values.push_back(std::to_string(graveyard_entry.y)); + insert_values.push_back(std::to_string(graveyard_entry.z)); + insert_values.push_back(std::to_string(graveyard_entry.heading)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + graveyard_entry.id = results.LastInsertedID(); + return graveyard_entry; + } + + graveyard_entry = NewEntity(); + + return graveyard_entry; + } + + static int InsertMany( + std::vector graveyard_entries + ) + { + std::vector insert_chunks; + + for (auto &graveyard_entry: graveyard_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(graveyard_entry.zone_id)); + insert_values.push_back(std::to_string(graveyard_entry.x)); + insert_values.push_back(std::to_string(graveyard_entry.y)); + insert_values.push_back(std::to_string(graveyard_entry.z)); + insert_values.push_back(std::to_string(graveyard_entry.heading)); + + 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) { + Graveyard entry{}; + + entry.id = atoi(row[0]); + entry.zone_id = atoi(row[1]); + entry.x = atof(row[2]); + entry.y = atof(row[3]); + entry.z = atof(row[4]); + entry.heading = atof(row[5]); + + 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) { + Graveyard entry{}; + + entry.id = atoi(row[0]); + entry.zone_id = atoi(row[1]); + entry.x = atof(row[2]); + entry.y = atof(row[3]); + entry.z = atof(row[4]); + entry.heading = atof(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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_GRAVEYARD_REPOSITORY_H diff --git a/common/repositories/base/base_grid_entries_repository.h b/common/repositories/base/base_grid_entries_repository.h new file mode 100644 index 000000000..6b0f3fcd2 --- /dev/null +++ b/common/repositories/base/base_grid_entries_repository.h @@ -0,0 +1,363 @@ +/** + * 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 on Apr 5, 2020 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_GRID_ENTRIES_REPOSITORY_H +#define EQEMU_BASE_GRID_ENTRIES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseGridEntriesRepository { +public: + struct GridEntries { + int gridid; + int zoneid; + int number; + float x; + float y; + float z; + float heading; + int pause; + int8 centerpoint; + }; + + static std::string PrimaryKey() + { + return std::string("number"); + } + + static std::vector Columns() + { + return { + "gridid", + "zoneid", + "number", + "x", + "y", + "z", + "heading", + "pause", + "centerpoint", + }; + } + + 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("grid_entries"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static GridEntries NewEntity() + { + GridEntries entry{}; + + entry.gridid = 0; + entry.zoneid = 0; + entry.number = 0; + entry.x = 0; + entry.y = 0; + entry.z = 0; + entry.heading = 0; + entry.pause = 0; + entry.centerpoint = 0; + + return entry; + } + + static GridEntries GetGridEntriesEntry( + const std::vector &grid_entriess, + int grid_entries_id + ) + { + for (auto &grid_entries : grid_entriess) { + if (grid_entries.number == grid_entries_id) { + return grid_entries; + } + } + + return NewEntity(); + } + + static GridEntries FindOne( + int grid_entries_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + grid_entries_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + GridEntries entry{}; + + entry.gridid = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.number = atoi(row[2]); + entry.x = atof(row[3]); + entry.y = atof(row[4]); + entry.z = atof(row[5]); + entry.heading = atof(row[6]); + entry.pause = atoi(row[7]); + entry.centerpoint = atoi(row[8]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int grid_entries_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + grid_entries_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + GridEntries grid_entries_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[3] + " = " + std::to_string(grid_entries_entry.x)); + update_values.push_back(columns[4] + " = " + std::to_string(grid_entries_entry.y)); + update_values.push_back(columns[5] + " = " + std::to_string(grid_entries_entry.z)); + update_values.push_back(columns[6] + " = " + std::to_string(grid_entries_entry.heading)); + update_values.push_back(columns[7] + " = " + std::to_string(grid_entries_entry.pause)); + update_values.push_back(columns[8] + " = " + std::to_string(grid_entries_entry.centerpoint)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + grid_entries_entry.number + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static GridEntries InsertOne( + GridEntries grid_entries_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(grid_entries_entry.x)); + insert_values.push_back(std::to_string(grid_entries_entry.y)); + insert_values.push_back(std::to_string(grid_entries_entry.z)); + insert_values.push_back(std::to_string(grid_entries_entry.heading)); + insert_values.push_back(std::to_string(grid_entries_entry.pause)); + insert_values.push_back(std::to_string(grid_entries_entry.centerpoint)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + grid_entries_entry.id = results.LastInsertedID(); + return grid_entries_entry; + } + + grid_entries_entry = NewEntity(); + + return grid_entries_entry; + } + + static int InsertMany( + std::vector grid_entries_entries + ) + { + std::vector insert_chunks; + + for (auto &grid_entries_entry: grid_entries_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(grid_entries_entry.x)); + insert_values.push_back(std::to_string(grid_entries_entry.y)); + insert_values.push_back(std::to_string(grid_entries_entry.z)); + insert_values.push_back(std::to_string(grid_entries_entry.heading)); + insert_values.push_back(std::to_string(grid_entries_entry.pause)); + insert_values.push_back(std::to_string(grid_entries_entry.centerpoint)); + + 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) { + GridEntries entry{}; + + entry.gridid = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.number = atoi(row[2]); + entry.x = atof(row[3]); + entry.y = atof(row[4]); + entry.z = atof(row[5]); + entry.heading = atof(row[6]); + entry.pause = atoi(row[7]); + entry.centerpoint = 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 = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + GridEntries entry{}; + + entry.gridid = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.number = atoi(row[2]); + entry.x = atof(row[3]); + entry.y = atof(row[4]); + entry.z = atof(row[5]); + entry.heading = atof(row[6]); + entry.pause = atoi(row[7]); + entry.centerpoint = atoi(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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_GRID_ENTRIES_REPOSITORY_H diff --git a/common/repositories/base/base_grid_repository.h b/common/repositories/base/base_grid_repository.h new file mode 100644 index 000000000..0fedf47a5 --- /dev/null +++ b/common/repositories/base/base_grid_repository.h @@ -0,0 +1,321 @@ +/** + * 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 on Apr 5, 2020 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_GRID_REPOSITORY_H +#define EQEMU_BASE_GRID_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseGridRepository { +public: + struct Grid { + int id; + int zoneid; + int type; + int type2; + }; + + static std::string PrimaryKey() + { + return std::string("zoneid"); + } + + static std::vector Columns() + { + return { + "id", + "zoneid", + "type", + "type2", + }; + } + + 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("grid"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Grid NewEntity() + { + Grid entry{}; + + entry.id = 0; + entry.zoneid = 0; + entry.type = 0; + entry.type2 = 0; + + return entry; + } + + static Grid GetGridEntry( + const std::vector &grids, + int grid_id + ) + { + for (auto &grid : grids) { + if (grid.zoneid == grid_id) { + return grid; + } + } + + return NewEntity(); + } + + static Grid FindOne( + int grid_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + grid_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Grid entry{}; + + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.type = atoi(row[2]); + entry.type2 = atoi(row[3]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int grid_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + grid_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Grid grid_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = " + std::to_string(grid_entry.type)); + update_values.push_back(columns[3] + " = " + std::to_string(grid_entry.type2)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + grid_entry.zoneid + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Grid InsertOne( + Grid grid_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(grid_entry.type)); + insert_values.push_back(std::to_string(grid_entry.type2)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + grid_entry.id = results.LastInsertedID(); + return grid_entry; + } + + grid_entry = NewEntity(); + + return grid_entry; + } + + static int InsertMany( + std::vector grid_entries + ) + { + std::vector insert_chunks; + + for (auto &grid_entry: grid_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(grid_entry.type)); + insert_values.push_back(std::to_string(grid_entry.type2)); + + 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) { + Grid entry{}; + + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.type = atoi(row[2]); + entry.type2 = 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 = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Grid entry{}; + + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.type = atoi(row[2]); + entry.type2 = atoi(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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_GRID_REPOSITORY_H diff --git a/common/repositories/base/base_ground_spawns_repository.h b/common/repositories/base/base_ground_spawns_repository.h new file mode 100644 index 000000000..4ff76b0c8 --- /dev/null +++ b/common/repositories/base/base_ground_spawns_repository.h @@ -0,0 +1,441 @@ +/** + * 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 on Apr 5, 2020 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_GROUND_SPAWNS_REPOSITORY_H +#define EQEMU_BASE_GROUND_SPAWNS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseGroundSpawnsRepository { +public: + struct GroundSpawns { + int id; + int zoneid; + int16 version; + float max_x; + float max_y; + float max_z; + float min_x; + float min_y; + float heading; + std::string name; + int item; + int max_allowed; + std::string comment; + int respawn_timer; + int8 min_expansion; + int8 max_expansion; + std::string content_flags; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "zoneid", + "version", + "max_x", + "max_y", + "max_z", + "min_x", + "min_y", + "heading", + "name", + "item", + "max_allowed", + "comment", + "respawn_timer", + "min_expansion", + "max_expansion", + "content_flags", + }; + } + + 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("ground_spawns"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static GroundSpawns NewEntity() + { + GroundSpawns entry{}; + + entry.id = 0; + entry.zoneid = 0; + entry.version = 0; + entry.max_x = 2000; + entry.max_y = 2000; + entry.max_z = 10000; + entry.min_x = -2000; + entry.min_y = -2000; + entry.heading = 0; + entry.name = ""; + entry.item = 0; + entry.max_allowed = 1; + entry.comment = ""; + entry.respawn_timer = 300; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; + + return entry; + } + + static GroundSpawns GetGroundSpawnsEntry( + const std::vector &ground_spawnss, + int ground_spawns_id + ) + { + for (auto &ground_spawns : ground_spawnss) { + if (ground_spawns.id == ground_spawns_id) { + return ground_spawns; + } + } + + return NewEntity(); + } + + static GroundSpawns FindOne( + int ground_spawns_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + ground_spawns_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + GroundSpawns entry{}; + + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.version = atoi(row[2]); + entry.max_x = atof(row[3]); + entry.max_y = atof(row[4]); + entry.max_z = atof(row[5]); + entry.min_x = atof(row[6]); + entry.min_y = atof(row[7]); + entry.heading = atof(row[8]); + entry.name = row[9] ? row[9] : ""; + entry.item = atoi(row[10]); + entry.max_allowed = atoi(row[11]); + entry.comment = row[12] ? row[12] : ""; + entry.respawn_timer = atoi(row[13]); + entry.min_expansion = atoi(row[14]); + entry.max_expansion = atoi(row[15]); + entry.content_flags = row[16] ? row[16] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int ground_spawns_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + ground_spawns_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + GroundSpawns ground_spawns_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(ground_spawns_entry.zoneid)); + update_values.push_back(columns[2] + " = " + std::to_string(ground_spawns_entry.version)); + update_values.push_back(columns[3] + " = " + std::to_string(ground_spawns_entry.max_x)); + update_values.push_back(columns[4] + " = " + std::to_string(ground_spawns_entry.max_y)); + update_values.push_back(columns[5] + " = " + std::to_string(ground_spawns_entry.max_z)); + update_values.push_back(columns[6] + " = " + std::to_string(ground_spawns_entry.min_x)); + update_values.push_back(columns[7] + " = " + std::to_string(ground_spawns_entry.min_y)); + update_values.push_back(columns[8] + " = " + std::to_string(ground_spawns_entry.heading)); + update_values.push_back(columns[9] + " = '" + EscapeString(ground_spawns_entry.name) + "'"); + update_values.push_back(columns[10] + " = " + std::to_string(ground_spawns_entry.item)); + update_values.push_back(columns[11] + " = " + std::to_string(ground_spawns_entry.max_allowed)); + update_values.push_back(columns[12] + " = '" + EscapeString(ground_spawns_entry.comment) + "'"); + update_values.push_back(columns[13] + " = " + std::to_string(ground_spawns_entry.respawn_timer)); + update_values.push_back(columns[14] + " = " + std::to_string(ground_spawns_entry.min_expansion)); + update_values.push_back(columns[15] + " = " + std::to_string(ground_spawns_entry.max_expansion)); + update_values.push_back(columns[16] + " = '" + EscapeString(ground_spawns_entry.content_flags) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + ground_spawns_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static GroundSpawns InsertOne( + GroundSpawns ground_spawns_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(ground_spawns_entry.zoneid)); + insert_values.push_back(std::to_string(ground_spawns_entry.version)); + insert_values.push_back(std::to_string(ground_spawns_entry.max_x)); + insert_values.push_back(std::to_string(ground_spawns_entry.max_y)); + insert_values.push_back(std::to_string(ground_spawns_entry.max_z)); + insert_values.push_back(std::to_string(ground_spawns_entry.min_x)); + insert_values.push_back(std::to_string(ground_spawns_entry.min_y)); + insert_values.push_back(std::to_string(ground_spawns_entry.heading)); + insert_values.push_back("'" + EscapeString(ground_spawns_entry.name) + "'"); + insert_values.push_back(std::to_string(ground_spawns_entry.item)); + insert_values.push_back(std::to_string(ground_spawns_entry.max_allowed)); + insert_values.push_back("'" + EscapeString(ground_spawns_entry.comment) + "'"); + insert_values.push_back(std::to_string(ground_spawns_entry.respawn_timer)); + insert_values.push_back(std::to_string(ground_spawns_entry.min_expansion)); + insert_values.push_back(std::to_string(ground_spawns_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(ground_spawns_entry.content_flags) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + ground_spawns_entry.id = results.LastInsertedID(); + return ground_spawns_entry; + } + + ground_spawns_entry = NewEntity(); + + return ground_spawns_entry; + } + + static int InsertMany( + std::vector ground_spawns_entries + ) + { + std::vector insert_chunks; + + for (auto &ground_spawns_entry: ground_spawns_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(ground_spawns_entry.zoneid)); + insert_values.push_back(std::to_string(ground_spawns_entry.version)); + insert_values.push_back(std::to_string(ground_spawns_entry.max_x)); + insert_values.push_back(std::to_string(ground_spawns_entry.max_y)); + insert_values.push_back(std::to_string(ground_spawns_entry.max_z)); + insert_values.push_back(std::to_string(ground_spawns_entry.min_x)); + insert_values.push_back(std::to_string(ground_spawns_entry.min_y)); + insert_values.push_back(std::to_string(ground_spawns_entry.heading)); + insert_values.push_back("'" + EscapeString(ground_spawns_entry.name) + "'"); + insert_values.push_back(std::to_string(ground_spawns_entry.item)); + insert_values.push_back(std::to_string(ground_spawns_entry.max_allowed)); + insert_values.push_back("'" + EscapeString(ground_spawns_entry.comment) + "'"); + insert_values.push_back(std::to_string(ground_spawns_entry.respawn_timer)); + insert_values.push_back(std::to_string(ground_spawns_entry.min_expansion)); + insert_values.push_back(std::to_string(ground_spawns_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(ground_spawns_entry.content_flags) + "'"); + + 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) { + GroundSpawns entry{}; + + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.version = atoi(row[2]); + entry.max_x = atof(row[3]); + entry.max_y = atof(row[4]); + entry.max_z = atof(row[5]); + entry.min_x = atof(row[6]); + entry.min_y = atof(row[7]); + entry.heading = atof(row[8]); + entry.name = row[9] ? row[9] : ""; + entry.item = atoi(row[10]); + entry.max_allowed = atoi(row[11]); + entry.comment = row[12] ? row[12] : ""; + entry.respawn_timer = atoi(row[13]); + entry.min_expansion = atoi(row[14]); + entry.max_expansion = atoi(row[15]); + entry.content_flags = row[16] ? row[16] : ""; + + 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) { + GroundSpawns entry{}; + + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.version = atoi(row[2]); + entry.max_x = atof(row[3]); + entry.max_y = atof(row[4]); + entry.max_z = atof(row[5]); + entry.min_x = atof(row[6]); + entry.min_y = atof(row[7]); + entry.heading = atof(row[8]); + entry.name = row[9] ? row[9] : ""; + entry.item = atoi(row[10]); + entry.max_allowed = atoi(row[11]); + entry.comment = row[12] ? row[12] : ""; + entry.respawn_timer = atoi(row[13]); + entry.min_expansion = atoi(row[14]); + entry.max_expansion = atoi(row[15]); + entry.content_flags = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_GROUND_SPAWNS_REPOSITORY_H diff --git a/common/repositories/base/base_group_id_repository.h b/common/repositories/base/base_group_id_repository.h new file mode 100644 index 000000000..c9446a5d1 --- /dev/null +++ b/common/repositories/base/base_group_id_repository.h @@ -0,0 +1,318 @@ +/** + * 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 on Apr 5, 2020 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_GROUP_ID_REPOSITORY_H +#define EQEMU_BASE_GROUP_ID_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseGroupIdRepository { +public: + struct GroupId { + int groupid; + int charid; + std::string name; + int8 ismerc; + }; + + static std::string PrimaryKey() + { + return std::string("ismerc"); + } + + static std::vector Columns() + { + return { + "groupid", + "charid", + "name", + "ismerc", + }; + } + + 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("group_id"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static GroupId NewEntity() + { + GroupId entry{}; + + entry.groupid = 0; + entry.charid = 0; + entry.name = ""; + entry.ismerc = 0; + + return entry; + } + + static GroupId GetGroupIdEntry( + const std::vector &group_ids, + int group_id_id + ) + { + for (auto &group_id : group_ids) { + if (group_id.ismerc == group_id_id) { + return group_id; + } + } + + return NewEntity(); + } + + static GroupId FindOne( + int group_id_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + group_id_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + GroupId entry{}; + + entry.groupid = atoi(row[0]); + entry.charid = atoi(row[1]); + entry.name = row[2] ? row[2] : ""; + entry.ismerc = atoi(row[3]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int group_id_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + group_id_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + GroupId group_id_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = '" + EscapeString(group_id_entry.name) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + group_id_entry.ismerc + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static GroupId InsertOne( + GroupId group_id_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(group_id_entry.name) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + group_id_entry.id = results.LastInsertedID(); + return group_id_entry; + } + + group_id_entry = NewEntity(); + + return group_id_entry; + } + + static int InsertMany( + std::vector group_id_entries + ) + { + std::vector insert_chunks; + + for (auto &group_id_entry: group_id_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(group_id_entry.name) + "'"); + + 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) { + GroupId entry{}; + + entry.groupid = atoi(row[0]); + entry.charid = atoi(row[1]); + entry.name = row[2] ? row[2] : ""; + entry.ismerc = 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) { + GroupId entry{}; + + entry.groupid = atoi(row[0]); + entry.charid = atoi(row[1]); + entry.name = row[2] ? row[2] : ""; + entry.ismerc = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_GROUP_ID_REPOSITORY_H diff --git a/common/repositories/base/base_group_leaders_repository.h b/common/repositories/base/base_group_leaders_repository.h new file mode 100644 index 000000000..7670f4db9 --- /dev/null +++ b/common/repositories/base/base_group_leaders_repository.h @@ -0,0 +1,369 @@ +/** + * 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 on Apr 5, 2020 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_GROUP_LEADERS_REPOSITORY_H +#define EQEMU_BASE_GROUP_LEADERS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseGroupLeadersRepository { +public: + struct GroupLeaders { + int gid; + std::string leadername; + std::string marknpc; + std::string leadershipaa; + std::string maintank; + std::string assist; + std::string puller; + std::string mentoree; + int mentor_percent; + }; + + static std::string PrimaryKey() + { + return std::string("gid"); + } + + static std::vector Columns() + { + return { + "gid", + "leadername", + "marknpc", + "leadershipaa", + "maintank", + "assist", + "puller", + "mentoree", + "mentor_percent", + }; + } + + 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("group_leaders"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static GroupLeaders NewEntity() + { + GroupLeaders entry{}; + + entry.gid = 0; + entry.leadername = ""; + entry.marknpc = ""; + entry.leadershipaa = 0; + entry.maintank = ""; + entry.assist = ""; + entry.puller = ""; + entry.mentoree = ""; + entry.mentor_percent = 0; + + return entry; + } + + static GroupLeaders GetGroupLeadersEntry( + const std::vector &group_leaderss, + int group_leaders_id + ) + { + for (auto &group_leaders : group_leaderss) { + if (group_leaders.gid == group_leaders_id) { + return group_leaders; + } + } + + return NewEntity(); + } + + static GroupLeaders FindOne( + int group_leaders_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + group_leaders_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + GroupLeaders entry{}; + + entry.gid = atoi(row[0]); + entry.leadername = row[1] ? row[1] : ""; + entry.marknpc = row[2] ? row[2] : ""; + entry.leadershipaa = row[3] ? row[3] : ""; + entry.maintank = row[4] ? row[4] : ""; + entry.assist = row[5] ? row[5] : ""; + entry.puller = row[6] ? row[6] : ""; + entry.mentoree = row[7] ? row[7] : ""; + entry.mentor_percent = atoi(row[8]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int group_leaders_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + group_leaders_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + GroupLeaders group_leaders_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(group_leaders_entry.leadername) + "'"); + update_values.push_back(columns[2] + " = '" + EscapeString(group_leaders_entry.marknpc) + "'"); + update_values.push_back(columns[3] + " = '" + EscapeString(group_leaders_entry.leadershipaa) + "'"); + update_values.push_back(columns[4] + " = '" + EscapeString(group_leaders_entry.maintank) + "'"); + update_values.push_back(columns[5] + " = '" + EscapeString(group_leaders_entry.assist) + "'"); + update_values.push_back(columns[6] + " = '" + EscapeString(group_leaders_entry.puller) + "'"); + update_values.push_back(columns[7] + " = '" + EscapeString(group_leaders_entry.mentoree) + "'"); + update_values.push_back(columns[8] + " = " + std::to_string(group_leaders_entry.mentor_percent)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + group_leaders_entry.gid + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static GroupLeaders InsertOne( + GroupLeaders group_leaders_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(group_leaders_entry.leadername) + "'"); + insert_values.push_back("'" + EscapeString(group_leaders_entry.marknpc) + "'"); + insert_values.push_back("'" + EscapeString(group_leaders_entry.leadershipaa) + "'"); + insert_values.push_back("'" + EscapeString(group_leaders_entry.maintank) + "'"); + insert_values.push_back("'" + EscapeString(group_leaders_entry.assist) + "'"); + insert_values.push_back("'" + EscapeString(group_leaders_entry.puller) + "'"); + insert_values.push_back("'" + EscapeString(group_leaders_entry.mentoree) + "'"); + insert_values.push_back(std::to_string(group_leaders_entry.mentor_percent)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + group_leaders_entry.id = results.LastInsertedID(); + return group_leaders_entry; + } + + group_leaders_entry = NewEntity(); + + return group_leaders_entry; + } + + static int InsertMany( + std::vector group_leaders_entries + ) + { + std::vector insert_chunks; + + for (auto &group_leaders_entry: group_leaders_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(group_leaders_entry.leadername) + "'"); + insert_values.push_back("'" + EscapeString(group_leaders_entry.marknpc) + "'"); + insert_values.push_back("'" + EscapeString(group_leaders_entry.leadershipaa) + "'"); + insert_values.push_back("'" + EscapeString(group_leaders_entry.maintank) + "'"); + insert_values.push_back("'" + EscapeString(group_leaders_entry.assist) + "'"); + insert_values.push_back("'" + EscapeString(group_leaders_entry.puller) + "'"); + insert_values.push_back("'" + EscapeString(group_leaders_entry.mentoree) + "'"); + insert_values.push_back(std::to_string(group_leaders_entry.mentor_percent)); + + 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) { + GroupLeaders entry{}; + + entry.gid = atoi(row[0]); + entry.leadername = row[1] ? row[1] : ""; + entry.marknpc = row[2] ? row[2] : ""; + entry.leadershipaa = row[3] ? row[3] : ""; + entry.maintank = row[4] ? row[4] : ""; + entry.assist = row[5] ? row[5] : ""; + entry.puller = row[6] ? row[6] : ""; + entry.mentoree = row[7] ? row[7] : ""; + entry.mentor_percent = 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) { + GroupLeaders entry{}; + + entry.gid = atoi(row[0]); + entry.leadername = row[1] ? row[1] : ""; + entry.marknpc = row[2] ? row[2] : ""; + entry.leadershipaa = row[3] ? row[3] : ""; + entry.maintank = row[4] ? row[4] : ""; + entry.assist = row[5] ? row[5] : ""; + entry.puller = row[6] ? row[6] : ""; + entry.mentoree = row[7] ? row[7] : ""; + entry.mentor_percent = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_GROUP_LEADERS_REPOSITORY_H diff --git a/common/repositories/base/base_guild_members_repository.h b/common/repositories/base/base_guild_members_repository.h new file mode 100644 index 000000000..56d462a93 --- /dev/null +++ b/common/repositories/base/base_guild_members_repository.h @@ -0,0 +1,369 @@ +/** + * 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 on Apr 5, 2020 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_GUILD_MEMBERS_REPOSITORY_H +#define EQEMU_BASE_GUILD_MEMBERS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseGuildMembersRepository { +public: + struct GuildMembers { + int char_id; + int guild_id; + int8 rank; + int8 tribute_enable; + int total_tribute; + int last_tribute; + int8 banker; + std::string public_note; + int8 alt; + }; + + static std::string PrimaryKey() + { + return std::string("char_id"); + } + + static std::vector Columns() + { + return { + "char_id", + "guild_id", + "rank", + "tribute_enable", + "total_tribute", + "last_tribute", + "banker", + "public_note", + "alt", + }; + } + + 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("guild_members"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static GuildMembers NewEntity() + { + GuildMembers entry{}; + + entry.char_id = 0; + entry.guild_id = 0; + entry.rank = 0; + entry.tribute_enable = 0; + entry.total_tribute = 0; + entry.last_tribute = 0; + entry.banker = 0; + entry.public_note = ""; + entry.alt = 0; + + return entry; + } + + static GuildMembers GetGuildMembersEntry( + const std::vector &guild_memberss, + int guild_members_id + ) + { + for (auto &guild_members : guild_memberss) { + if (guild_members.char_id == guild_members_id) { + return guild_members; + } + } + + return NewEntity(); + } + + static GuildMembers FindOne( + int guild_members_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + guild_members_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + GuildMembers entry{}; + + entry.char_id = atoi(row[0]); + entry.guild_id = atoi(row[1]); + entry.rank = atoi(row[2]); + entry.tribute_enable = atoi(row[3]); + entry.total_tribute = atoi(row[4]); + entry.last_tribute = atoi(row[5]); + entry.banker = atoi(row[6]); + entry.public_note = row[7] ? row[7] : ""; + entry.alt = atoi(row[8]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int guild_members_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + guild_members_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + GuildMembers guild_members_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(guild_members_entry.guild_id)); + update_values.push_back(columns[2] + " = " + std::to_string(guild_members_entry.rank)); + update_values.push_back(columns[3] + " = " + std::to_string(guild_members_entry.tribute_enable)); + update_values.push_back(columns[4] + " = " + std::to_string(guild_members_entry.total_tribute)); + update_values.push_back(columns[5] + " = " + std::to_string(guild_members_entry.last_tribute)); + update_values.push_back(columns[6] + " = " + std::to_string(guild_members_entry.banker)); + update_values.push_back(columns[7] + " = '" + EscapeString(guild_members_entry.public_note) + "'"); + update_values.push_back(columns[8] + " = " + std::to_string(guild_members_entry.alt)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + guild_members_entry.char_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static GuildMembers InsertOne( + GuildMembers guild_members_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(guild_members_entry.guild_id)); + insert_values.push_back(std::to_string(guild_members_entry.rank)); + insert_values.push_back(std::to_string(guild_members_entry.tribute_enable)); + insert_values.push_back(std::to_string(guild_members_entry.total_tribute)); + insert_values.push_back(std::to_string(guild_members_entry.last_tribute)); + insert_values.push_back(std::to_string(guild_members_entry.banker)); + insert_values.push_back("'" + EscapeString(guild_members_entry.public_note) + "'"); + insert_values.push_back(std::to_string(guild_members_entry.alt)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + guild_members_entry.id = results.LastInsertedID(); + return guild_members_entry; + } + + guild_members_entry = NewEntity(); + + return guild_members_entry; + } + + static int InsertMany( + std::vector guild_members_entries + ) + { + std::vector insert_chunks; + + for (auto &guild_members_entry: guild_members_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(guild_members_entry.guild_id)); + insert_values.push_back(std::to_string(guild_members_entry.rank)); + insert_values.push_back(std::to_string(guild_members_entry.tribute_enable)); + insert_values.push_back(std::to_string(guild_members_entry.total_tribute)); + insert_values.push_back(std::to_string(guild_members_entry.last_tribute)); + insert_values.push_back(std::to_string(guild_members_entry.banker)); + insert_values.push_back("'" + EscapeString(guild_members_entry.public_note) + "'"); + insert_values.push_back(std::to_string(guild_members_entry.alt)); + + 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) { + GuildMembers entry{}; + + entry.char_id = atoi(row[0]); + entry.guild_id = atoi(row[1]); + entry.rank = atoi(row[2]); + entry.tribute_enable = atoi(row[3]); + entry.total_tribute = atoi(row[4]); + entry.last_tribute = atoi(row[5]); + entry.banker = atoi(row[6]); + entry.public_note = row[7] ? row[7] : ""; + entry.alt = 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) { + GuildMembers entry{}; + + entry.char_id = atoi(row[0]); + entry.guild_id = atoi(row[1]); + entry.rank = atoi(row[2]); + entry.tribute_enable = atoi(row[3]); + entry.total_tribute = atoi(row[4]); + entry.last_tribute = atoi(row[5]); + entry.banker = atoi(row[6]); + entry.public_note = row[7] ? row[7] : ""; + entry.alt = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_GUILD_MEMBERS_REPOSITORY_H diff --git a/common/repositories/base/base_guild_ranks_repository.h b/common/repositories/base/base_guild_ranks_repository.h new file mode 100644 index 000000000..b7c606f23 --- /dev/null +++ b/common/repositories/base/base_guild_ranks_repository.h @@ -0,0 +1,384 @@ +/** + * 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 on Apr 5, 2020 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_GUILD_RANKS_REPOSITORY_H +#define EQEMU_BASE_GUILD_RANKS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseGuildRanksRepository { +public: + struct GuildRanks { + int guild_id; + int8 rank; + std::string title; + int8 can_hear; + int8 can_speak; + int8 can_invite; + int8 can_remove; + int8 can_promote; + int8 can_demote; + int8 can_motd; + int8 can_warpeace; + }; + + static std::string PrimaryKey() + { + return std::string("rank"); + } + + static std::vector Columns() + { + return { + "guild_id", + "rank", + "title", + "can_hear", + "can_speak", + "can_invite", + "can_remove", + "can_promote", + "can_demote", + "can_motd", + "can_warpeace", + }; + } + + 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("guild_ranks"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static GuildRanks NewEntity() + { + GuildRanks entry{}; + + entry.guild_id = 0; + entry.rank = 0; + entry.title = ""; + entry.can_hear = 0; + entry.can_speak = 0; + entry.can_invite = 0; + entry.can_remove = 0; + entry.can_promote = 0; + entry.can_demote = 0; + entry.can_motd = 0; + entry.can_warpeace = 0; + + return entry; + } + + static GuildRanks GetGuildRanksEntry( + const std::vector &guild_rankss, + int guild_ranks_id + ) + { + for (auto &guild_ranks : guild_rankss) { + if (guild_ranks.rank == guild_ranks_id) { + return guild_ranks; + } + } + + return NewEntity(); + } + + static GuildRanks FindOne( + int guild_ranks_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + guild_ranks_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + GuildRanks entry{}; + + entry.guild_id = atoi(row[0]); + entry.rank = atoi(row[1]); + entry.title = row[2] ? row[2] : ""; + entry.can_hear = atoi(row[3]); + entry.can_speak = atoi(row[4]); + entry.can_invite = atoi(row[5]); + entry.can_remove = atoi(row[6]); + entry.can_promote = atoi(row[7]); + entry.can_demote = atoi(row[8]); + entry.can_motd = atoi(row[9]); + entry.can_warpeace = atoi(row[10]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int guild_ranks_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + guild_ranks_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + GuildRanks guild_ranks_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = '" + EscapeString(guild_ranks_entry.title) + "'"); + update_values.push_back(columns[3] + " = " + std::to_string(guild_ranks_entry.can_hear)); + update_values.push_back(columns[4] + " = " + std::to_string(guild_ranks_entry.can_speak)); + update_values.push_back(columns[5] + " = " + std::to_string(guild_ranks_entry.can_invite)); + update_values.push_back(columns[6] + " = " + std::to_string(guild_ranks_entry.can_remove)); + update_values.push_back(columns[7] + " = " + std::to_string(guild_ranks_entry.can_promote)); + update_values.push_back(columns[8] + " = " + std::to_string(guild_ranks_entry.can_demote)); + update_values.push_back(columns[9] + " = " + std::to_string(guild_ranks_entry.can_motd)); + update_values.push_back(columns[10] + " = " + std::to_string(guild_ranks_entry.can_warpeace)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + guild_ranks_entry.rank + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static GuildRanks InsertOne( + GuildRanks guild_ranks_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(guild_ranks_entry.title) + "'"); + insert_values.push_back(std::to_string(guild_ranks_entry.can_hear)); + insert_values.push_back(std::to_string(guild_ranks_entry.can_speak)); + insert_values.push_back(std::to_string(guild_ranks_entry.can_invite)); + insert_values.push_back(std::to_string(guild_ranks_entry.can_remove)); + insert_values.push_back(std::to_string(guild_ranks_entry.can_promote)); + insert_values.push_back(std::to_string(guild_ranks_entry.can_demote)); + insert_values.push_back(std::to_string(guild_ranks_entry.can_motd)); + insert_values.push_back(std::to_string(guild_ranks_entry.can_warpeace)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + guild_ranks_entry.id = results.LastInsertedID(); + return guild_ranks_entry; + } + + guild_ranks_entry = NewEntity(); + + return guild_ranks_entry; + } + + static int InsertMany( + std::vector guild_ranks_entries + ) + { + std::vector insert_chunks; + + for (auto &guild_ranks_entry: guild_ranks_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(guild_ranks_entry.title) + "'"); + insert_values.push_back(std::to_string(guild_ranks_entry.can_hear)); + insert_values.push_back(std::to_string(guild_ranks_entry.can_speak)); + insert_values.push_back(std::to_string(guild_ranks_entry.can_invite)); + insert_values.push_back(std::to_string(guild_ranks_entry.can_remove)); + insert_values.push_back(std::to_string(guild_ranks_entry.can_promote)); + insert_values.push_back(std::to_string(guild_ranks_entry.can_demote)); + insert_values.push_back(std::to_string(guild_ranks_entry.can_motd)); + insert_values.push_back(std::to_string(guild_ranks_entry.can_warpeace)); + + 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) { + GuildRanks entry{}; + + entry.guild_id = atoi(row[0]); + entry.rank = atoi(row[1]); + entry.title = row[2] ? row[2] : ""; + entry.can_hear = atoi(row[3]); + entry.can_speak = atoi(row[4]); + entry.can_invite = atoi(row[5]); + entry.can_remove = atoi(row[6]); + entry.can_promote = atoi(row[7]); + entry.can_demote = atoi(row[8]); + entry.can_motd = atoi(row[9]); + entry.can_warpeace = atoi(row[10]); + + 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) { + GuildRanks entry{}; + + entry.guild_id = atoi(row[0]); + entry.rank = atoi(row[1]); + entry.title = row[2] ? row[2] : ""; + entry.can_hear = atoi(row[3]); + entry.can_speak = atoi(row[4]); + entry.can_invite = atoi(row[5]); + entry.can_remove = atoi(row[6]); + entry.can_promote = atoi(row[7]); + entry.can_demote = atoi(row[8]); + entry.can_motd = atoi(row[9]); + entry.can_warpeace = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_GUILD_RANKS_REPOSITORY_H diff --git a/common/repositories/base/base_guild_relations_repository.h b/common/repositories/base/base_guild_relations_repository.h new file mode 100644 index 000000000..b0ac5c179 --- /dev/null +++ b/common/repositories/base/base_guild_relations_repository.h @@ -0,0 +1,312 @@ +/** + * 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 on Apr 5, 2020 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_GUILD_RELATIONS_REPOSITORY_H +#define EQEMU_BASE_GUILD_RELATIONS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseGuildRelationsRepository { +public: + struct GuildRelations { + int guild1; + int guild2; + int8 relation; + }; + + static std::string PrimaryKey() + { + return std::string("guild2"); + } + + static std::vector Columns() + { + return { + "guild1", + "guild2", + "relation", + }; + } + + 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("guild_relations"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static GuildRelations NewEntity() + { + GuildRelations entry{}; + + entry.guild1 = 0; + entry.guild2 = 0; + entry.relation = 0; + + return entry; + } + + static GuildRelations GetGuildRelationsEntry( + const std::vector &guild_relationss, + int guild_relations_id + ) + { + for (auto &guild_relations : guild_relationss) { + if (guild_relations.guild2 == guild_relations_id) { + return guild_relations; + } + } + + return NewEntity(); + } + + static GuildRelations FindOne( + int guild_relations_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + guild_relations_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + GuildRelations entry{}; + + entry.guild1 = atoi(row[0]); + entry.guild2 = atoi(row[1]); + entry.relation = atoi(row[2]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int guild_relations_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + guild_relations_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + GuildRelations guild_relations_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = " + std::to_string(guild_relations_entry.relation)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + guild_relations_entry.guild2 + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static GuildRelations InsertOne( + GuildRelations guild_relations_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(guild_relations_entry.relation)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + guild_relations_entry.id = results.LastInsertedID(); + return guild_relations_entry; + } + + guild_relations_entry = NewEntity(); + + return guild_relations_entry; + } + + static int InsertMany( + std::vector guild_relations_entries + ) + { + std::vector insert_chunks; + + for (auto &guild_relations_entry: guild_relations_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(guild_relations_entry.relation)); + + 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) { + GuildRelations entry{}; + + entry.guild1 = atoi(row[0]); + entry.guild2 = atoi(row[1]); + entry.relation = atoi(row[2]); + + 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) { + GuildRelations entry{}; + + entry.guild1 = atoi(row[0]); + entry.guild2 = atoi(row[1]); + entry.relation = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_GUILD_RELATIONS_REPOSITORY_H diff --git a/common/repositories/base/base_guilds_repository.h b/common/repositories/base/base_guilds_repository.h new file mode 100644 index 000000000..557804686 --- /dev/null +++ b/common/repositories/base/base_guilds_repository.h @@ -0,0 +1,369 @@ +/** + * 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 on Apr 5, 2020 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_GUILDS_REPOSITORY_H +#define EQEMU_BASE_GUILDS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseGuildsRepository { +public: + struct Guilds { + int id; + std::string name; + int leader; + int16 minstatus; + std::string motd; + int tribute; + std::string motd_setter; + std::string channel; + std::string url; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "name", + "leader", + "minstatus", + "motd", + "tribute", + "motd_setter", + "channel", + "url", + }; + } + + 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("guilds"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Guilds NewEntity() + { + Guilds entry{}; + + entry.id = 0; + entry.name = ""; + entry.leader = 0; + entry.minstatus = 0; + entry.motd = ""; + entry.tribute = 0; + entry.motd_setter = ""; + entry.channel = ""; + entry.url = ""; + + return entry; + } + + static Guilds GetGuildsEntry( + const std::vector &guildss, + int guilds_id + ) + { + for (auto &guilds : guildss) { + if (guilds.id == guilds_id) { + return guilds; + } + } + + return NewEntity(); + } + + static Guilds FindOne( + int guilds_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + guilds_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Guilds entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.leader = atoi(row[2]); + entry.minstatus = atoi(row[3]); + entry.motd = row[4] ? row[4] : ""; + entry.tribute = atoi(row[5]); + entry.motd_setter = row[6] ? row[6] : ""; + entry.channel = row[7] ? row[7] : ""; + entry.url = row[8] ? row[8] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int guilds_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + guilds_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Guilds guilds_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(guilds_entry.name) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(guilds_entry.leader)); + update_values.push_back(columns[3] + " = " + std::to_string(guilds_entry.minstatus)); + update_values.push_back(columns[4] + " = '" + EscapeString(guilds_entry.motd) + "'"); + update_values.push_back(columns[5] + " = " + std::to_string(guilds_entry.tribute)); + update_values.push_back(columns[6] + " = '" + EscapeString(guilds_entry.motd_setter) + "'"); + update_values.push_back(columns[7] + " = '" + EscapeString(guilds_entry.channel) + "'"); + update_values.push_back(columns[8] + " = '" + EscapeString(guilds_entry.url) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + guilds_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Guilds InsertOne( + Guilds guilds_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(guilds_entry.name) + "'"); + insert_values.push_back(std::to_string(guilds_entry.leader)); + insert_values.push_back(std::to_string(guilds_entry.minstatus)); + insert_values.push_back("'" + EscapeString(guilds_entry.motd) + "'"); + insert_values.push_back(std::to_string(guilds_entry.tribute)); + insert_values.push_back("'" + EscapeString(guilds_entry.motd_setter) + "'"); + insert_values.push_back("'" + EscapeString(guilds_entry.channel) + "'"); + insert_values.push_back("'" + EscapeString(guilds_entry.url) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + guilds_entry.id = results.LastInsertedID(); + return guilds_entry; + } + + guilds_entry = NewEntity(); + + return guilds_entry; + } + + static int InsertMany( + std::vector guilds_entries + ) + { + std::vector insert_chunks; + + for (auto &guilds_entry: guilds_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(guilds_entry.name) + "'"); + insert_values.push_back(std::to_string(guilds_entry.leader)); + insert_values.push_back(std::to_string(guilds_entry.minstatus)); + insert_values.push_back("'" + EscapeString(guilds_entry.motd) + "'"); + insert_values.push_back(std::to_string(guilds_entry.tribute)); + insert_values.push_back("'" + EscapeString(guilds_entry.motd_setter) + "'"); + insert_values.push_back("'" + EscapeString(guilds_entry.channel) + "'"); + insert_values.push_back("'" + EscapeString(guilds_entry.url) + "'"); + + 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) { + Guilds entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.leader = atoi(row[2]); + entry.minstatus = atoi(row[3]); + entry.motd = row[4] ? row[4] : ""; + entry.tribute = atoi(row[5]); + entry.motd_setter = row[6] ? row[6] : ""; + entry.channel = row[7] ? row[7] : ""; + entry.url = row[8] ? 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) { + Guilds entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.leader = atoi(row[2]); + entry.minstatus = atoi(row[3]); + entry.motd = row[4] ? row[4] : ""; + entry.tribute = atoi(row[5]); + entry.motd_setter = row[6] ? row[6] : ""; + entry.channel = row[7] ? row[7] : ""; + entry.url = row[8] ? 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_GUILDS_REPOSITORY_H diff --git a/common/repositories/base/base_hackers_repository.h b/common/repositories/base/base_hackers_repository.h new file mode 100644 index 000000000..8b869cfb3 --- /dev/null +++ b/common/repositories/base/base_hackers_repository.h @@ -0,0 +1,342 @@ +/** + * 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 on Apr 5, 2020 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_HACKERS_REPOSITORY_H +#define EQEMU_BASE_HACKERS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseHackersRepository { +public: + struct Hackers { + int id; + std::string account; + std::string name; + std::string hacked; + std::string zone; + std::string date; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "account", + "name", + "hacked", + "zone", + "date", + }; + } + + 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("hackers"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Hackers NewEntity() + { + Hackers entry{}; + + entry.id = 0; + entry.account = ""; + entry.name = ""; + entry.hacked = ""; + entry.zone = ""; + entry.date = current_timestamp(); + + return entry; + } + + static Hackers GetHackersEntry( + const std::vector &hackerss, + int hackers_id + ) + { + for (auto &hackers : hackerss) { + if (hackers.id == hackers_id) { + return hackers; + } + } + + return NewEntity(); + } + + static Hackers FindOne( + int hackers_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + hackers_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Hackers entry{}; + + entry.id = atoi(row[0]); + entry.account = row[1] ? row[1] : ""; + entry.name = row[2] ? row[2] : ""; + entry.hacked = row[3] ? row[3] : ""; + entry.zone = row[4] ? row[4] : ""; + entry.date = row[5] ? row[5] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int hackers_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + hackers_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Hackers hackers_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(hackers_entry.account) + "'"); + update_values.push_back(columns[2] + " = '" + EscapeString(hackers_entry.name) + "'"); + update_values.push_back(columns[3] + " = '" + EscapeString(hackers_entry.hacked) + "'"); + update_values.push_back(columns[4] + " = '" + EscapeString(hackers_entry.zone) + "'"); + update_values.push_back(columns[5] + " = '" + EscapeString(hackers_entry.date) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + hackers_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Hackers InsertOne( + Hackers hackers_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(hackers_entry.account) + "'"); + insert_values.push_back("'" + EscapeString(hackers_entry.name) + "'"); + insert_values.push_back("'" + EscapeString(hackers_entry.hacked) + "'"); + insert_values.push_back("'" + EscapeString(hackers_entry.zone) + "'"); + insert_values.push_back("'" + EscapeString(hackers_entry.date) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + hackers_entry.id = results.LastInsertedID(); + return hackers_entry; + } + + hackers_entry = NewEntity(); + + return hackers_entry; + } + + static int InsertMany( + std::vector hackers_entries + ) + { + std::vector insert_chunks; + + for (auto &hackers_entry: hackers_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(hackers_entry.account) + "'"); + insert_values.push_back("'" + EscapeString(hackers_entry.name) + "'"); + insert_values.push_back("'" + EscapeString(hackers_entry.hacked) + "'"); + insert_values.push_back("'" + EscapeString(hackers_entry.zone) + "'"); + insert_values.push_back("'" + EscapeString(hackers_entry.date) + "'"); + + 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) { + Hackers entry{}; + + entry.id = atoi(row[0]); + entry.account = row[1] ? row[1] : ""; + entry.name = row[2] ? row[2] : ""; + entry.hacked = row[3] ? row[3] : ""; + entry.zone = row[4] ? row[4] : ""; + entry.date = 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) { + Hackers entry{}; + + entry.id = atoi(row[0]); + entry.account = row[1] ? row[1] : ""; + entry.name = row[2] ? row[2] : ""; + entry.hacked = row[3] ? row[3] : ""; + entry.zone = row[4] ? row[4] : ""; + entry.date = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_HACKERS_REPOSITORY_H diff --git a/common/repositories/base/base_horses_repository.h b/common/repositories/base/base_horses_repository.h new file mode 100644 index 000000000..cb365018d --- /dev/null +++ b/common/repositories/base/base_horses_repository.h @@ -0,0 +1,342 @@ +/** + * 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 on Apr 5, 2020 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_HORSES_REPOSITORY_H +#define EQEMU_BASE_HORSES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseHorsesRepository { +public: + struct Horses { + std::string filename; + int16 race; + int8 gender; + int8 texture; + float mountspeed; + std::string notes; + }; + + static std::string PrimaryKey() + { + return std::string("filename"); + } + + static std::vector Columns() + { + return { + "filename", + "race", + "gender", + "texture", + "mountspeed", + "notes", + }; + } + + 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("horses"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Horses NewEntity() + { + Horses entry{}; + + entry.filename = ""; + entry.race = 216; + entry.gender = 0; + entry.texture = 0; + entry.mountspeed = 0.75; + entry.notes = "Notes"; + + return entry; + } + + static Horses GetHorsesEntry( + const std::vector &horsess, + int horses_id + ) + { + for (auto &horses : horsess) { + if (horses.filename == horses_id) { + return horses; + } + } + + return NewEntity(); + } + + static Horses FindOne( + int horses_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + horses_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Horses entry{}; + + entry.filename = row[0] ? row[0] : ""; + entry.race = atoi(row[1]); + entry.gender = atoi(row[2]); + entry.texture = atoi(row[3]); + entry.mountspeed = atof(row[4]); + entry.notes = row[5] ? row[5] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int horses_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + horses_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Horses horses_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(horses_entry.race)); + update_values.push_back(columns[2] + " = " + std::to_string(horses_entry.gender)); + update_values.push_back(columns[3] + " = " + std::to_string(horses_entry.texture)); + update_values.push_back(columns[4] + " = " + std::to_string(horses_entry.mountspeed)); + update_values.push_back(columns[5] + " = '" + EscapeString(horses_entry.notes) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + horses_entry.filename + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Horses InsertOne( + Horses horses_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(horses_entry.race)); + insert_values.push_back(std::to_string(horses_entry.gender)); + insert_values.push_back(std::to_string(horses_entry.texture)); + insert_values.push_back(std::to_string(horses_entry.mountspeed)); + insert_values.push_back("'" + EscapeString(horses_entry.notes) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + horses_entry.id = results.LastInsertedID(); + return horses_entry; + } + + horses_entry = NewEntity(); + + return horses_entry; + } + + static int InsertMany( + std::vector horses_entries + ) + { + std::vector insert_chunks; + + for (auto &horses_entry: horses_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(horses_entry.race)); + insert_values.push_back(std::to_string(horses_entry.gender)); + insert_values.push_back(std::to_string(horses_entry.texture)); + insert_values.push_back(std::to_string(horses_entry.mountspeed)); + insert_values.push_back("'" + EscapeString(horses_entry.notes) + "'"); + + 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) { + Horses entry{}; + + entry.filename = row[0] ? row[0] : ""; + entry.race = atoi(row[1]); + entry.gender = atoi(row[2]); + entry.texture = atoi(row[3]); + entry.mountspeed = atof(row[4]); + entry.notes = 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 = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Horses entry{}; + + entry.filename = row[0] ? row[0] : ""; + entry.race = atoi(row[1]); + entry.gender = atoi(row[2]); + entry.texture = atoi(row[3]); + entry.mountspeed = atof(row[4]); + entry.notes = row[5] ? 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_HORSES_REPOSITORY_H diff --git a/common/repositories/base/base_instance_list_player_repository.h b/common/repositories/base/base_instance_list_player_repository.h new file mode 100644 index 000000000..bc7a255c3 --- /dev/null +++ b/common/repositories/base/base_instance_list_player_repository.h @@ -0,0 +1,306 @@ +/** + * 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 on Apr 5, 2020 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_INSTANCE_LIST_PLAYER_REPOSITORY_H +#define EQEMU_BASE_INSTANCE_LIST_PLAYER_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseInstanceListPlayerRepository { +public: + struct InstanceListPlayer { + int id; + int charid; + }; + + static std::string PrimaryKey() + { + return std::string("charid"); + } + + static std::vector Columns() + { + return { + "id", + "charid", + }; + } + + 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("instance_list_player"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static InstanceListPlayer NewEntity() + { + InstanceListPlayer entry{}; + + entry.id = 0; + entry.charid = 0; + + return entry; + } + + static InstanceListPlayer GetInstanceListPlayerEntry( + const std::vector &instance_list_players, + int instance_list_player_id + ) + { + for (auto &instance_list_player : instance_list_players) { + if (instance_list_player.charid == instance_list_player_id) { + return instance_list_player; + } + } + + return NewEntity(); + } + + static InstanceListPlayer FindOne( + int instance_list_player_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + instance_list_player_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + InstanceListPlayer entry{}; + + entry.id = atoi(row[0]); + entry.charid = atoi(row[1]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int instance_list_player_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + instance_list_player_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + InstanceListPlayer instance_list_player_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + instance_list_player_entry.charid + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static InstanceListPlayer InsertOne( + InstanceListPlayer instance_list_player_entry + ) + { + std::vector insert_values; + + + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + instance_list_player_entry.id = results.LastInsertedID(); + return instance_list_player_entry; + } + + instance_list_player_entry = NewEntity(); + + return instance_list_player_entry; + } + + static int InsertMany( + std::vector instance_list_player_entries + ) + { + std::vector insert_chunks; + + for (auto &instance_list_player_entry: instance_list_player_entries) { + std::vector insert_values; + + + + 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) { + InstanceListPlayer entry{}; + + entry.id = atoi(row[0]); + entry.charid = 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 = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + InstanceListPlayer 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_INSTANCE_LIST_PLAYER_REPOSITORY_H diff --git a/common/repositories/base/base_instance_list_repository.h b/common/repositories/base/base_instance_list_repository.h new file mode 100644 index 000000000..d27d6aa27 --- /dev/null +++ b/common/repositories/base/base_instance_list_repository.h @@ -0,0 +1,351 @@ +/** + * 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 on Apr 5, 2020 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_INSTANCE_LIST_REPOSITORY_H +#define EQEMU_BASE_INSTANCE_LIST_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseInstanceListRepository { +public: + struct InstanceList { + int id; + int zone; + int8 version; + int8 is_global; + int start_time; + int duration; + int8 never_expires; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "zone", + "version", + "is_global", + "start_time", + "duration", + "never_expires", + }; + } + + 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("instance_list"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static InstanceList NewEntity() + { + InstanceList entry{}; + + entry.id = 0; + entry.zone = 0; + entry.version = 0; + entry.is_global = 0; + entry.start_time = 0; + entry.duration = 0; + entry.never_expires = 0; + + return entry; + } + + static InstanceList GetInstanceListEntry( + const std::vector &instance_lists, + int instance_list_id + ) + { + for (auto &instance_list : instance_lists) { + if (instance_list.id == instance_list_id) { + return instance_list; + } + } + + return NewEntity(); + } + + static InstanceList FindOne( + int instance_list_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + instance_list_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + InstanceList entry{}; + + entry.id = atoi(row[0]); + entry.zone = atoi(row[1]); + entry.version = atoi(row[2]); + entry.is_global = atoi(row[3]); + entry.start_time = atoi(row[4]); + entry.duration = atoi(row[5]); + entry.never_expires = atoi(row[6]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int instance_list_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + instance_list_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + InstanceList instance_list_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(instance_list_entry.zone)); + update_values.push_back(columns[2] + " = " + std::to_string(instance_list_entry.version)); + update_values.push_back(columns[3] + " = " + std::to_string(instance_list_entry.is_global)); + update_values.push_back(columns[4] + " = " + std::to_string(instance_list_entry.start_time)); + update_values.push_back(columns[5] + " = " + std::to_string(instance_list_entry.duration)); + update_values.push_back(columns[6] + " = " + std::to_string(instance_list_entry.never_expires)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + instance_list_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static InstanceList InsertOne( + InstanceList instance_list_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(instance_list_entry.zone)); + insert_values.push_back(std::to_string(instance_list_entry.version)); + insert_values.push_back(std::to_string(instance_list_entry.is_global)); + insert_values.push_back(std::to_string(instance_list_entry.start_time)); + insert_values.push_back(std::to_string(instance_list_entry.duration)); + insert_values.push_back(std::to_string(instance_list_entry.never_expires)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + instance_list_entry.id = results.LastInsertedID(); + return instance_list_entry; + } + + instance_list_entry = NewEntity(); + + return instance_list_entry; + } + + static int InsertMany( + std::vector instance_list_entries + ) + { + std::vector insert_chunks; + + for (auto &instance_list_entry: instance_list_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(instance_list_entry.zone)); + insert_values.push_back(std::to_string(instance_list_entry.version)); + insert_values.push_back(std::to_string(instance_list_entry.is_global)); + insert_values.push_back(std::to_string(instance_list_entry.start_time)); + insert_values.push_back(std::to_string(instance_list_entry.duration)); + insert_values.push_back(std::to_string(instance_list_entry.never_expires)); + + 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) { + InstanceList entry{}; + + entry.id = atoi(row[0]); + entry.zone = atoi(row[1]); + entry.version = atoi(row[2]); + entry.is_global = atoi(row[3]); + entry.start_time = atoi(row[4]); + entry.duration = atoi(row[5]); + entry.never_expires = atoi(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) { + InstanceList entry{}; + + entry.id = atoi(row[0]); + entry.zone = atoi(row[1]); + entry.version = atoi(row[2]); + entry.is_global = atoi(row[3]); + entry.start_time = atoi(row[4]); + entry.duration = atoi(row[5]); + entry.never_expires = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_INSTANCE_LIST_REPOSITORY_H diff --git a/common/repositories/base/base_inventory_repository.h b/common/repositories/base/base_inventory_repository.h new file mode 100644 index 000000000..c389918f7 --- /dev/null +++ b/common/repositories/base/base_inventory_repository.h @@ -0,0 +1,429 @@ +/** + * 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 on Apr 5, 2020 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_INVENTORY_REPOSITORY_H +#define EQEMU_BASE_INVENTORY_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseInventoryRepository { +public: + struct Inventory { + int charid; + int slotid; + int itemid; + int16 charges; + int color; + int augslot1; + int augslot2; + int augslot3; + int augslot4; + int augslot5; + int augslot6; + int8 instnodrop; + std::string custom_data; + int ornamenticon; + int ornamentidfile; + int ornament_hero_model; + }; + + static std::string PrimaryKey() + { + return std::string("slotid"); + } + + static std::vector Columns() + { + return { + "charid", + "slotid", + "itemid", + "charges", + "color", + "augslot1", + "augslot2", + "augslot3", + "augslot4", + "augslot5", + "augslot6", + "instnodrop", + "custom_data", + "ornamenticon", + "ornamentidfile", + "ornament_hero_model", + }; + } + + 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("inventory"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Inventory NewEntity() + { + Inventory entry{}; + + entry.charid = 0; + entry.slotid = 0; + entry.itemid = 0; + entry.charges = 0; + entry.color = 0; + entry.augslot1 = 0; + entry.augslot2 = 0; + entry.augslot3 = 0; + entry.augslot4 = 0; + entry.augslot5 = 0; + entry.augslot6 = 0; + entry.instnodrop = 0; + entry.custom_data = ""; + entry.ornamenticon = 0; + entry.ornamentidfile = 0; + entry.ornament_hero_model = 0; + + return entry; + } + + static Inventory GetInventoryEntry( + const std::vector &inventorys, + int inventory_id + ) + { + for (auto &inventory : inventorys) { + if (inventory.slotid == inventory_id) { + return inventory; + } + } + + return NewEntity(); + } + + static Inventory FindOne( + int inventory_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + inventory_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Inventory entry{}; + + entry.charid = atoi(row[0]); + entry.slotid = atoi(row[1]); + entry.itemid = atoi(row[2]); + entry.charges = atoi(row[3]); + entry.color = atoi(row[4]); + entry.augslot1 = atoi(row[5]); + entry.augslot2 = atoi(row[6]); + entry.augslot3 = atoi(row[7]); + entry.augslot4 = atoi(row[8]); + entry.augslot5 = atoi(row[9]); + entry.augslot6 = atoi(row[10]); + entry.instnodrop = atoi(row[11]); + entry.custom_data = row[12] ? row[12] : ""; + entry.ornamenticon = atoi(row[13]); + entry.ornamentidfile = atoi(row[14]); + entry.ornament_hero_model = atoi(row[15]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int inventory_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + inventory_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Inventory inventory_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = " + std::to_string(inventory_entry.itemid)); + update_values.push_back(columns[3] + " = " + std::to_string(inventory_entry.charges)); + update_values.push_back(columns[4] + " = " + std::to_string(inventory_entry.color)); + update_values.push_back(columns[5] + " = " + std::to_string(inventory_entry.augslot1)); + update_values.push_back(columns[6] + " = " + std::to_string(inventory_entry.augslot2)); + update_values.push_back(columns[7] + " = " + std::to_string(inventory_entry.augslot3)); + update_values.push_back(columns[8] + " = " + std::to_string(inventory_entry.augslot4)); + update_values.push_back(columns[9] + " = " + std::to_string(inventory_entry.augslot5)); + update_values.push_back(columns[10] + " = " + std::to_string(inventory_entry.augslot6)); + update_values.push_back(columns[11] + " = " + std::to_string(inventory_entry.instnodrop)); + update_values.push_back(columns[12] + " = '" + EscapeString(inventory_entry.custom_data) + "'"); + update_values.push_back(columns[13] + " = " + std::to_string(inventory_entry.ornamenticon)); + update_values.push_back(columns[14] + " = " + std::to_string(inventory_entry.ornamentidfile)); + update_values.push_back(columns[15] + " = " + std::to_string(inventory_entry.ornament_hero_model)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + inventory_entry.slotid + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Inventory InsertOne( + Inventory inventory_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(inventory_entry.itemid)); + insert_values.push_back(std::to_string(inventory_entry.charges)); + insert_values.push_back(std::to_string(inventory_entry.color)); + insert_values.push_back(std::to_string(inventory_entry.augslot1)); + insert_values.push_back(std::to_string(inventory_entry.augslot2)); + insert_values.push_back(std::to_string(inventory_entry.augslot3)); + insert_values.push_back(std::to_string(inventory_entry.augslot4)); + insert_values.push_back(std::to_string(inventory_entry.augslot5)); + insert_values.push_back(std::to_string(inventory_entry.augslot6)); + insert_values.push_back(std::to_string(inventory_entry.instnodrop)); + insert_values.push_back("'" + EscapeString(inventory_entry.custom_data) + "'"); + insert_values.push_back(std::to_string(inventory_entry.ornamenticon)); + insert_values.push_back(std::to_string(inventory_entry.ornamentidfile)); + insert_values.push_back(std::to_string(inventory_entry.ornament_hero_model)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + inventory_entry.id = results.LastInsertedID(); + return inventory_entry; + } + + inventory_entry = NewEntity(); + + return inventory_entry; + } + + static int InsertMany( + std::vector inventory_entries + ) + { + std::vector insert_chunks; + + for (auto &inventory_entry: inventory_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(inventory_entry.itemid)); + insert_values.push_back(std::to_string(inventory_entry.charges)); + insert_values.push_back(std::to_string(inventory_entry.color)); + insert_values.push_back(std::to_string(inventory_entry.augslot1)); + insert_values.push_back(std::to_string(inventory_entry.augslot2)); + insert_values.push_back(std::to_string(inventory_entry.augslot3)); + insert_values.push_back(std::to_string(inventory_entry.augslot4)); + insert_values.push_back(std::to_string(inventory_entry.augslot5)); + insert_values.push_back(std::to_string(inventory_entry.augslot6)); + insert_values.push_back(std::to_string(inventory_entry.instnodrop)); + insert_values.push_back("'" + EscapeString(inventory_entry.custom_data) + "'"); + insert_values.push_back(std::to_string(inventory_entry.ornamenticon)); + insert_values.push_back(std::to_string(inventory_entry.ornamentidfile)); + insert_values.push_back(std::to_string(inventory_entry.ornament_hero_model)); + + 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) { + Inventory entry{}; + + entry.charid = atoi(row[0]); + entry.slotid = atoi(row[1]); + entry.itemid = atoi(row[2]); + entry.charges = atoi(row[3]); + entry.color = atoi(row[4]); + entry.augslot1 = atoi(row[5]); + entry.augslot2 = atoi(row[6]); + entry.augslot3 = atoi(row[7]); + entry.augslot4 = atoi(row[8]); + entry.augslot5 = atoi(row[9]); + entry.augslot6 = atoi(row[10]); + entry.instnodrop = atoi(row[11]); + entry.custom_data = row[12] ? row[12] : ""; + entry.ornamenticon = atoi(row[13]); + entry.ornamentidfile = atoi(row[14]); + entry.ornament_hero_model = atoi(row[15]); + + 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) { + Inventory entry{}; + + entry.charid = atoi(row[0]); + entry.slotid = atoi(row[1]); + entry.itemid = atoi(row[2]); + entry.charges = atoi(row[3]); + entry.color = atoi(row[4]); + entry.augslot1 = atoi(row[5]); + entry.augslot2 = atoi(row[6]); + entry.augslot3 = atoi(row[7]); + entry.augslot4 = atoi(row[8]); + entry.augslot5 = atoi(row[9]); + entry.augslot6 = atoi(row[10]); + entry.instnodrop = atoi(row[11]); + entry.custom_data = row[12] ? row[12] : ""; + entry.ornamenticon = atoi(row[13]); + entry.ornamentidfile = atoi(row[14]); + entry.ornament_hero_model = atoi(row[15]); + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_INVENTORY_REPOSITORY_H diff --git a/common/repositories/base/base_inventory_snapshots_repository.h b/common/repositories/base/base_inventory_snapshots_repository.h new file mode 100644 index 000000000..f05b88811 --- /dev/null +++ b/common/repositories/base/base_inventory_snapshots_repository.h @@ -0,0 +1,435 @@ +/** + * 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 on Apr 5, 2020 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_INVENTORY_SNAPSHOTS_REPOSITORY_H +#define EQEMU_BASE_INVENTORY_SNAPSHOTS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseInventorySnapshotsRepository { +public: + struct InventorySnapshots { + int time_index; + int charid; + int slotid; + int itemid; + int16 charges; + int color; + int augslot1; + int augslot2; + int augslot3; + int augslot4; + int augslot5; + int augslot6; + int8 instnodrop; + std::string custom_data; + int ornamenticon; + int ornamentidfile; + int ornament_hero_model; + }; + + static std::string PrimaryKey() + { + return std::string("slotid"); + } + + static std::vector Columns() + { + return { + "time_index", + "charid", + "slotid", + "itemid", + "charges", + "color", + "augslot1", + "augslot2", + "augslot3", + "augslot4", + "augslot5", + "augslot6", + "instnodrop", + "custom_data", + "ornamenticon", + "ornamentidfile", + "ornament_hero_model", + }; + } + + 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("inventory_snapshots"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static InventorySnapshots NewEntity() + { + InventorySnapshots entry{}; + + entry.time_index = 0; + entry.charid = 0; + entry.slotid = 0; + entry.itemid = 0; + entry.charges = 0; + entry.color = 0; + entry.augslot1 = 0; + entry.augslot2 = 0; + entry.augslot3 = 0; + entry.augslot4 = 0; + entry.augslot5 = 0; + entry.augslot6 = 0; + entry.instnodrop = 0; + entry.custom_data = ""; + entry.ornamenticon = 0; + entry.ornamentidfile = 0; + entry.ornament_hero_model = 0; + + return entry; + } + + static InventorySnapshots GetInventorySnapshotsEntry( + const std::vector &inventory_snapshotss, + int inventory_snapshots_id + ) + { + for (auto &inventory_snapshots : inventory_snapshotss) { + if (inventory_snapshots.slotid == inventory_snapshots_id) { + return inventory_snapshots; + } + } + + return NewEntity(); + } + + static InventorySnapshots FindOne( + int inventory_snapshots_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + inventory_snapshots_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + InventorySnapshots entry{}; + + entry.time_index = atoi(row[0]); + entry.charid = atoi(row[1]); + entry.slotid = atoi(row[2]); + entry.itemid = atoi(row[3]); + entry.charges = atoi(row[4]); + entry.color = atoi(row[5]); + entry.augslot1 = atoi(row[6]); + entry.augslot2 = atoi(row[7]); + entry.augslot3 = atoi(row[8]); + entry.augslot4 = atoi(row[9]); + entry.augslot5 = atoi(row[10]); + entry.augslot6 = atoi(row[11]); + entry.instnodrop = atoi(row[12]); + entry.custom_data = row[13] ? row[13] : ""; + entry.ornamenticon = atoi(row[14]); + entry.ornamentidfile = atoi(row[15]); + entry.ornament_hero_model = atoi(row[16]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int inventory_snapshots_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + inventory_snapshots_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + InventorySnapshots inventory_snapshots_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[3] + " = " + std::to_string(inventory_snapshots_entry.itemid)); + update_values.push_back(columns[4] + " = " + std::to_string(inventory_snapshots_entry.charges)); + update_values.push_back(columns[5] + " = " + std::to_string(inventory_snapshots_entry.color)); + update_values.push_back(columns[6] + " = " + std::to_string(inventory_snapshots_entry.augslot1)); + update_values.push_back(columns[7] + " = " + std::to_string(inventory_snapshots_entry.augslot2)); + update_values.push_back(columns[8] + " = " + std::to_string(inventory_snapshots_entry.augslot3)); + update_values.push_back(columns[9] + " = " + std::to_string(inventory_snapshots_entry.augslot4)); + update_values.push_back(columns[10] + " = " + std::to_string(inventory_snapshots_entry.augslot5)); + update_values.push_back(columns[11] + " = " + std::to_string(inventory_snapshots_entry.augslot6)); + update_values.push_back(columns[12] + " = " + std::to_string(inventory_snapshots_entry.instnodrop)); + update_values.push_back(columns[13] + " = '" + EscapeString(inventory_snapshots_entry.custom_data) + "'"); + update_values.push_back(columns[14] + " = " + std::to_string(inventory_snapshots_entry.ornamenticon)); + update_values.push_back(columns[15] + " = " + std::to_string(inventory_snapshots_entry.ornamentidfile)); + update_values.push_back(columns[16] + " = " + std::to_string(inventory_snapshots_entry.ornament_hero_model)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + inventory_snapshots_entry.slotid + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static InventorySnapshots InsertOne( + InventorySnapshots inventory_snapshots_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(inventory_snapshots_entry.itemid)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.charges)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.color)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot1)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot2)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot3)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot4)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot5)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot6)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.instnodrop)); + insert_values.push_back("'" + EscapeString(inventory_snapshots_entry.custom_data) + "'"); + insert_values.push_back(std::to_string(inventory_snapshots_entry.ornamenticon)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.ornamentidfile)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.ornament_hero_model)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + inventory_snapshots_entry.id = results.LastInsertedID(); + return inventory_snapshots_entry; + } + + inventory_snapshots_entry = NewEntity(); + + return inventory_snapshots_entry; + } + + static int InsertMany( + std::vector inventory_snapshots_entries + ) + { + std::vector insert_chunks; + + for (auto &inventory_snapshots_entry: inventory_snapshots_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(inventory_snapshots_entry.itemid)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.charges)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.color)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot1)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot2)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot3)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot4)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot5)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot6)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.instnodrop)); + insert_values.push_back("'" + EscapeString(inventory_snapshots_entry.custom_data) + "'"); + insert_values.push_back(std::to_string(inventory_snapshots_entry.ornamenticon)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.ornamentidfile)); + insert_values.push_back(std::to_string(inventory_snapshots_entry.ornament_hero_model)); + + 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) { + InventorySnapshots entry{}; + + entry.time_index = atoi(row[0]); + entry.charid = atoi(row[1]); + entry.slotid = atoi(row[2]); + entry.itemid = atoi(row[3]); + entry.charges = atoi(row[4]); + entry.color = atoi(row[5]); + entry.augslot1 = atoi(row[6]); + entry.augslot2 = atoi(row[7]); + entry.augslot3 = atoi(row[8]); + entry.augslot4 = atoi(row[9]); + entry.augslot5 = atoi(row[10]); + entry.augslot6 = atoi(row[11]); + entry.instnodrop = atoi(row[12]); + entry.custom_data = row[13] ? row[13] : ""; + entry.ornamenticon = atoi(row[14]); + entry.ornamentidfile = atoi(row[15]); + entry.ornament_hero_model = 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) { + InventorySnapshots entry{}; + + entry.time_index = atoi(row[0]); + entry.charid = atoi(row[1]); + entry.slotid = atoi(row[2]); + entry.itemid = atoi(row[3]); + entry.charges = atoi(row[4]); + entry.color = atoi(row[5]); + entry.augslot1 = atoi(row[6]); + entry.augslot2 = atoi(row[7]); + entry.augslot3 = atoi(row[8]); + entry.augslot4 = atoi(row[9]); + entry.augslot5 = atoi(row[10]); + entry.augslot6 = atoi(row[11]); + entry.instnodrop = atoi(row[12]); + entry.custom_data = row[13] ? row[13] : ""; + entry.ornamenticon = atoi(row[14]); + entry.ornamentidfile = atoi(row[15]); + entry.ornament_hero_model = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_INVENTORY_SNAPSHOTS_REPOSITORY_H diff --git a/common/repositories/base/base_ip_exemptions_repository.h b/common/repositories/base/base_ip_exemptions_repository.h new file mode 100644 index 000000000..9a2bcb45c --- /dev/null +++ b/common/repositories/base/base_ip_exemptions_repository.h @@ -0,0 +1,315 @@ +/** + * 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 on Apr 5, 2020 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_IP_EXEMPTIONS_REPOSITORY_H +#define EQEMU_BASE_IP_EXEMPTIONS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseIpExemptionsRepository { +public: + struct IpExemptions { + int exemption_id; + std::string exemption_ip; + int exemption_amount; + }; + + static std::string PrimaryKey() + { + return std::string("exemption_id"); + } + + static std::vector Columns() + { + return { + "exemption_id", + "exemption_ip", + "exemption_amount", + }; + } + + 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("ip_exemptions"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static IpExemptions NewEntity() + { + IpExemptions entry{}; + + entry.exemption_id = 0; + entry.exemption_ip = ""; + entry.exemption_amount = 0; + + return entry; + } + + static IpExemptions GetIpExemptionsEntry( + const std::vector &ip_exemptionss, + int ip_exemptions_id + ) + { + for (auto &ip_exemptions : ip_exemptionss) { + if (ip_exemptions.exemption_id == ip_exemptions_id) { + return ip_exemptions; + } + } + + return NewEntity(); + } + + static IpExemptions FindOne( + int ip_exemptions_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + ip_exemptions_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + IpExemptions entry{}; + + entry.exemption_id = atoi(row[0]); + entry.exemption_ip = row[1] ? row[1] : ""; + entry.exemption_amount = atoi(row[2]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int ip_exemptions_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + ip_exemptions_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + IpExemptions ip_exemptions_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(ip_exemptions_entry.exemption_ip) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(ip_exemptions_entry.exemption_amount)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + ip_exemptions_entry.exemption_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static IpExemptions InsertOne( + IpExemptions ip_exemptions_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(ip_exemptions_entry.exemption_ip) + "'"); + insert_values.push_back(std::to_string(ip_exemptions_entry.exemption_amount)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + ip_exemptions_entry.id = results.LastInsertedID(); + return ip_exemptions_entry; + } + + ip_exemptions_entry = NewEntity(); + + return ip_exemptions_entry; + } + + static int InsertMany( + std::vector ip_exemptions_entries + ) + { + std::vector insert_chunks; + + for (auto &ip_exemptions_entry: ip_exemptions_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(ip_exemptions_entry.exemption_ip) + "'"); + insert_values.push_back(std::to_string(ip_exemptions_entry.exemption_amount)); + + 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) { + IpExemptions entry{}; + + entry.exemption_id = atoi(row[0]); + entry.exemption_ip = row[1] ? row[1] : ""; + entry.exemption_amount = atoi(row[2]); + + 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) { + IpExemptions entry{}; + + entry.exemption_id = atoi(row[0]); + entry.exemption_ip = row[1] ? row[1] : ""; + entry.exemption_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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_IP_EXEMPTIONS_REPOSITORY_H diff --git a/common/repositories/base/base_item_tick_repository.h b/common/repositories/base/base_item_tick_repository.h new file mode 100644 index 000000000..b22039a37 --- /dev/null +++ b/common/repositories/base/base_item_tick_repository.h @@ -0,0 +1,342 @@ +/** + * 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 on Apr 5, 2020 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_ITEM_TICK_REPOSITORY_H +#define EQEMU_BASE_ITEM_TICK_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseItemTickRepository { +public: + struct ItemTick { + int it_itemid; + int it_chance; + int it_level; + int it_id; + std::string it_qglobal; + int8 it_bagslot; + }; + + static std::string PrimaryKey() + { + return std::string("it_id"); + } + + static std::vector Columns() + { + return { + "it_itemid", + "it_chance", + "it_level", + "it_id", + "it_qglobal", + "it_bagslot", + }; + } + + 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("item_tick"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static ItemTick NewEntity() + { + ItemTick entry{}; + + entry.it_itemid = 0; + entry.it_chance = 0; + entry.it_level = 0; + entry.it_id = 0; + entry.it_qglobal = ""; + entry.it_bagslot = 0; + + return entry; + } + + static ItemTick GetItemTickEntry( + const std::vector &item_ticks, + int item_tick_id + ) + { + for (auto &item_tick : item_ticks) { + if (item_tick.it_id == item_tick_id) { + return item_tick; + } + } + + return NewEntity(); + } + + static ItemTick FindOne( + int item_tick_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + item_tick_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + ItemTick entry{}; + + entry.it_itemid = atoi(row[0]); + entry.it_chance = atoi(row[1]); + entry.it_level = atoi(row[2]); + entry.it_id = atoi(row[3]); + entry.it_qglobal = row[4] ? row[4] : ""; + entry.it_bagslot = atoi(row[5]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int item_tick_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + item_tick_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + ItemTick item_tick_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[0] + " = " + std::to_string(item_tick_entry.it_itemid)); + update_values.push_back(columns[1] + " = " + std::to_string(item_tick_entry.it_chance)); + update_values.push_back(columns[2] + " = " + std::to_string(item_tick_entry.it_level)); + update_values.push_back(columns[4] + " = '" + EscapeString(item_tick_entry.it_qglobal) + "'"); + update_values.push_back(columns[5] + " = " + std::to_string(item_tick_entry.it_bagslot)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + item_tick_entry.it_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static ItemTick InsertOne( + ItemTick item_tick_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(item_tick_entry.it_itemid)); + insert_values.push_back(std::to_string(item_tick_entry.it_chance)); + insert_values.push_back(std::to_string(item_tick_entry.it_level)); + insert_values.push_back("'" + EscapeString(item_tick_entry.it_qglobal) + "'"); + insert_values.push_back(std::to_string(item_tick_entry.it_bagslot)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + item_tick_entry.id = results.LastInsertedID(); + return item_tick_entry; + } + + item_tick_entry = NewEntity(); + + return item_tick_entry; + } + + static int InsertMany( + std::vector item_tick_entries + ) + { + std::vector insert_chunks; + + for (auto &item_tick_entry: item_tick_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(item_tick_entry.it_itemid)); + insert_values.push_back(std::to_string(item_tick_entry.it_chance)); + insert_values.push_back(std::to_string(item_tick_entry.it_level)); + insert_values.push_back("'" + EscapeString(item_tick_entry.it_qglobal) + "'"); + insert_values.push_back(std::to_string(item_tick_entry.it_bagslot)); + + 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) { + ItemTick entry{}; + + entry.it_itemid = atoi(row[0]); + entry.it_chance = atoi(row[1]); + entry.it_level = atoi(row[2]); + entry.it_id = atoi(row[3]); + entry.it_qglobal = row[4] ? row[4] : ""; + entry.it_bagslot = atoi(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) { + ItemTick entry{}; + + entry.it_itemid = atoi(row[0]); + entry.it_chance = atoi(row[1]); + entry.it_level = atoi(row[2]); + entry.it_id = atoi(row[3]); + entry.it_qglobal = row[4] ? row[4] : ""; + entry.it_bagslot = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_ITEM_TICK_REPOSITORY_H diff --git a/common/repositories/base/base_items_repository.h b/common/repositories/base/base_items_repository.h new file mode 100644 index 000000000..69a053c2c --- /dev/null +++ b/common/repositories/base/base_items_repository.h @@ -0,0 +1,2853 @@ +/** + * 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 on Apr 5, 2020 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_ITEMS_REPOSITORY_H +#define EQEMU_BASE_ITEMS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseItemsRepository { +public: + struct Items { + int id; + int16 minstatus; + std::string Name; + int aagi; + int ac; + int accuracy; + int acha; + int adex; + int aint; + int8 artifactflag; + int asta; + int astr; + int attack; + int augrestrict; + int8 augslot1type; + int8 augslot1visible; + int8 augslot2type; + int8 augslot2visible; + int8 augslot3type; + int8 augslot3visible; + int8 augslot4type; + int8 augslot4visible; + int8 augslot5type; + int8 augslot5visible; + int8 augslot6type; + int8 augslot6visible; + int augtype; + int avoidance; + int awis; + int bagsize; + int bagslots; + int bagtype; + int bagwr; + int banedmgamt; + int banedmgraceamt; + int banedmgbody; + int banedmgrace; + int bardtype; + int bardvalue; + int book; + int casttime; + int casttime_; + std::string charmfile; + std::string charmfileid; + int classes; + int color; + std::string combateffects; + int extradmgskill; + int extradmgamt; + int price; + int cr; + int damage; + int damageshield; + int deity; + int delay; + int augdistiller; + int dotshielding; + int dr; + int clicktype; + int clicklevel2; + int elemdmgtype; + int elemdmgamt; + int endur; + int factionamt1; + int factionamt2; + int factionamt3; + int factionamt4; + int factionmod1; + int factionmod2; + int factionmod3; + int factionmod4; + std::string filename; + int focuseffect; + int fr; + int fvnodrop; + int haste; + int clicklevel; + int hp; + int regen; + int icon; + std::string idfile; + int itemclass; + int itemtype; + int ldonprice; + int ldontheme; + int ldonsold; + int light; + std::string lore; + int loregroup; + int magic; + int mana; + int manaregen; + int enduranceregen; + int material; + int herosforgemodel; + int maxcharges; + int mr; + int nodrop; + int norent; + int8 pendingloreflag; + int pr; + int procrate; + int races; + int range; + int reclevel; + int recskill; + int reqlevel; + float sellrate; + int shielding; + int size; + int skillmodtype; + int skillmodvalue; + int slots; + int clickeffect; + int spellshield; + int strikethrough; + int stunresist; + int8 summonedflag; + int tradeskills; + int favor; + int weight; + int UNK012; + int UNK013; + int benefitflag; + int UNK054; + int UNK059; + int booktype; + int recastdelay; + int recasttype; + int guildfavor; + int UNK123; + int UNK124; + int attuneable; + int nopet; + std::string updated; + std::string comment; + int UNK127; + int pointtype; + int potionbelt; + int potionbeltslots; + int stacksize; + int notransfer; + int stackable; + std::string UNK134; + int UNK137; + int proceffect; + int proctype; + int proclevel2; + int proclevel; + int UNK142; + int worneffect; + int worntype; + int wornlevel2; + int wornlevel; + int UNK147; + int focustype; + int focuslevel2; + int focuslevel; + int UNK152; + int scrolleffect; + int scrolltype; + int scrolllevel2; + int scrolllevel; + int UNK157; + std::string serialized; + std::string verified; + std::string serialization; + std::string source; + int UNK033; + std::string lorefile; + int UNK014; + int svcorruption; + int skillmodmax; + int UNK060; + int augslot1unk2; + int augslot2unk2; + int augslot3unk2; + int augslot4unk2; + int augslot5unk2; + int augslot6unk2; + int UNK120; + int UNK121; + int questitemflag; + std::string UNK132; + int clickunk5; + std::string clickunk6; + int clickunk7; + int procunk1; + int procunk2; + int procunk3; + int procunk4; + std::string procunk6; + int procunk7; + int wornunk1; + int wornunk2; + int wornunk3; + int wornunk4; + int wornunk5; + std::string wornunk6; + int wornunk7; + int focusunk1; + int focusunk2; + int focusunk3; + int focusunk4; + int focusunk5; + std::string focusunk6; + int focusunk7; + int scrollunk1; + int scrollunk2; + int scrollunk3; + int scrollunk4; + int scrollunk5; + std::string scrollunk6; + int scrollunk7; + int UNK193; + int purity; + int evoitem; + int evoid; + int evolvinglevel; + int evomax; + std::string clickname; + std::string procname; + std::string wornname; + std::string focusname; + std::string scrollname; + int16 dsmitigation; + int16 heroic_str; + int16 heroic_int; + int16 heroic_wis; + int16 heroic_agi; + int16 heroic_dex; + int16 heroic_sta; + int16 heroic_cha; + int16 heroic_pr; + int16 heroic_dr; + int16 heroic_fr; + int16 heroic_cr; + int16 heroic_mr; + int16 heroic_svcorrup; + int16 healamt; + int16 spelldmg; + int16 clairvoyance; + int16 backstabdmg; + std::string created; + int16 elitematerial; + int16 ldonsellbackrate; + int16 scriptfileid; + int16 expendablearrow; + int16 powersourcecapacity; + int16 bardeffect; + int16 bardeffecttype; + int16 bardlevel2; + int16 bardlevel; + int16 bardunk1; + int16 bardunk2; + int16 bardunk3; + int16 bardunk4; + int16 bardunk5; + std::string bardname; + int16 bardunk7; + int16 UNK214; + int UNK219; + int UNK220; + int UNK221; + int heirloom; + int UNK223; + int UNK224; + int UNK225; + int UNK226; + int UNK227; + int UNK228; + int UNK229; + int UNK230; + int UNK231; + int UNK232; + int UNK233; + int UNK234; + int placeable; + int UNK236; + int UNK237; + int UNK238; + int UNK239; + int UNK240; + int UNK241; + int epicitem; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "minstatus", + "Name", + "aagi", + "ac", + "accuracy", + "acha", + "adex", + "aint", + "artifactflag", + "asta", + "astr", + "attack", + "augrestrict", + "augslot1type", + "augslot1visible", + "augslot2type", + "augslot2visible", + "augslot3type", + "augslot3visible", + "augslot4type", + "augslot4visible", + "augslot5type", + "augslot5visible", + "augslot6type", + "augslot6visible", + "augtype", + "avoidance", + "awis", + "bagsize", + "bagslots", + "bagtype", + "bagwr", + "banedmgamt", + "banedmgraceamt", + "banedmgbody", + "banedmgrace", + "bardtype", + "bardvalue", + "book", + "casttime", + "casttime_", + "charmfile", + "charmfileid", + "classes", + "color", + "combateffects", + "extradmgskill", + "extradmgamt", + "price", + "cr", + "damage", + "damageshield", + "deity", + "delay", + "augdistiller", + "dotshielding", + "dr", + "clicktype", + "clicklevel2", + "elemdmgtype", + "elemdmgamt", + "endur", + "factionamt1", + "factionamt2", + "factionamt3", + "factionamt4", + "factionmod1", + "factionmod2", + "factionmod3", + "factionmod4", + "filename", + "focuseffect", + "fr", + "fvnodrop", + "haste", + "clicklevel", + "hp", + "regen", + "icon", + "idfile", + "itemclass", + "itemtype", + "ldonprice", + "ldontheme", + "ldonsold", + "light", + "lore", + "loregroup", + "magic", + "mana", + "manaregen", + "enduranceregen", + "material", + "herosforgemodel", + "maxcharges", + "mr", + "nodrop", + "norent", + "pendingloreflag", + "pr", + "procrate", + "races", + "range", + "reclevel", + "recskill", + "reqlevel", + "sellrate", + "shielding", + "size", + "skillmodtype", + "skillmodvalue", + "slots", + "clickeffect", + "spellshield", + "strikethrough", + "stunresist", + "summonedflag", + "tradeskills", + "favor", + "weight", + "UNK012", + "UNK013", + "benefitflag", + "UNK054", + "UNK059", + "booktype", + "recastdelay", + "recasttype", + "guildfavor", + "UNK123", + "UNK124", + "attuneable", + "nopet", + "updated", + "comment", + "UNK127", + "pointtype", + "potionbelt", + "potionbeltslots", + "stacksize", + "notransfer", + "stackable", + "UNK134", + "UNK137", + "proceffect", + "proctype", + "proclevel2", + "proclevel", + "UNK142", + "worneffect", + "worntype", + "wornlevel2", + "wornlevel", + "UNK147", + "focustype", + "focuslevel2", + "focuslevel", + "UNK152", + "scrolleffect", + "scrolltype", + "scrolllevel2", + "scrolllevel", + "UNK157", + "serialized", + "verified", + "serialization", + "source", + "UNK033", + "lorefile", + "UNK014", + "svcorruption", + "skillmodmax", + "UNK060", + "augslot1unk2", + "augslot2unk2", + "augslot3unk2", + "augslot4unk2", + "augslot5unk2", + "augslot6unk2", + "UNK120", + "UNK121", + "questitemflag", + "UNK132", + "clickunk5", + "clickunk6", + "clickunk7", + "procunk1", + "procunk2", + "procunk3", + "procunk4", + "procunk6", + "procunk7", + "wornunk1", + "wornunk2", + "wornunk3", + "wornunk4", + "wornunk5", + "wornunk6", + "wornunk7", + "focusunk1", + "focusunk2", + "focusunk3", + "focusunk4", + "focusunk5", + "focusunk6", + "focusunk7", + "scrollunk1", + "scrollunk2", + "scrollunk3", + "scrollunk4", + "scrollunk5", + "scrollunk6", + "scrollunk7", + "UNK193", + "purity", + "evoitem", + "evoid", + "evolvinglevel", + "evomax", + "clickname", + "procname", + "wornname", + "focusname", + "scrollname", + "dsmitigation", + "heroic_str", + "heroic_int", + "heroic_wis", + "heroic_agi", + "heroic_dex", + "heroic_sta", + "heroic_cha", + "heroic_pr", + "heroic_dr", + "heroic_fr", + "heroic_cr", + "heroic_mr", + "heroic_svcorrup", + "healamt", + "spelldmg", + "clairvoyance", + "backstabdmg", + "created", + "elitematerial", + "ldonsellbackrate", + "scriptfileid", + "expendablearrow", + "powersourcecapacity", + "bardeffect", + "bardeffecttype", + "bardlevel2", + "bardlevel", + "bardunk1", + "bardunk2", + "bardunk3", + "bardunk4", + "bardunk5", + "bardname", + "bardunk7", + "UNK214", + "UNK219", + "UNK220", + "UNK221", + "heirloom", + "UNK223", + "UNK224", + "UNK225", + "UNK226", + "UNK227", + "UNK228", + "UNK229", + "UNK230", + "UNK231", + "UNK232", + "UNK233", + "UNK234", + "placeable", + "UNK236", + "UNK237", + "UNK238", + "UNK239", + "UNK240", + "UNK241", + "epicitem", + }; + } + + 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("items"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Items NewEntity() + { + Items entry{}; + + entry.id = 0; + entry.minstatus = 0; + entry.Name = ""; + entry.aagi = 0; + entry.ac = 0; + entry.accuracy = 0; + entry.acha = 0; + entry.adex = 0; + entry.aint = 0; + entry.artifactflag = 0; + entry.asta = 0; + entry.astr = 0; + entry.attack = 0; + entry.augrestrict = 0; + entry.augslot1type = 0; + entry.augslot1visible = 0; + entry.augslot2type = 0; + entry.augslot2visible = 0; + entry.augslot3type = 0; + entry.augslot3visible = 0; + entry.augslot4type = 0; + entry.augslot4visible = 0; + entry.augslot5type = 0; + entry.augslot5visible = 0; + entry.augslot6type = 0; + entry.augslot6visible = 0; + entry.augtype = 0; + entry.avoidance = 0; + entry.awis = 0; + entry.bagsize = 0; + entry.bagslots = 0; + entry.bagtype = 0; + entry.bagwr = 0; + entry.banedmgamt = 0; + entry.banedmgraceamt = 0; + entry.banedmgbody = 0; + entry.banedmgrace = 0; + entry.bardtype = 0; + entry.bardvalue = 0; + entry.book = 0; + entry.casttime = 0; + entry.casttime_ = 0; + entry.charmfile = ""; + entry.charmfileid = ""; + entry.classes = 0; + entry.color = 0; + entry.combateffects = ""; + entry.extradmgskill = 0; + entry.extradmgamt = 0; + entry.price = 0; + entry.cr = 0; + entry.damage = 0; + entry.damageshield = 0; + entry.deity = 0; + entry.delay = 0; + entry.augdistiller = 0; + entry.dotshielding = 0; + entry.dr = 0; + entry.clicktype = 0; + entry.clicklevel2 = 0; + entry.elemdmgtype = 0; + entry.elemdmgamt = 0; + entry.endur = 0; + entry.factionamt1 = 0; + entry.factionamt2 = 0; + entry.factionamt3 = 0; + entry.factionamt4 = 0; + entry.factionmod1 = 0; + entry.factionmod2 = 0; + entry.factionmod3 = 0; + entry.factionmod4 = 0; + entry.filename = ""; + entry.focuseffect = 0; + entry.fr = 0; + entry.fvnodrop = 0; + entry.haste = 0; + entry.clicklevel = 0; + entry.hp = 0; + entry.regen = 0; + entry.icon = 0; + entry.idfile = ""; + entry.itemclass = 0; + entry.itemtype = 0; + entry.ldonprice = 0; + entry.ldontheme = 0; + entry.ldonsold = 0; + entry.light = 0; + entry.lore = ""; + entry.loregroup = 0; + entry.magic = 0; + entry.mana = 0; + entry.manaregen = 0; + entry.enduranceregen = 0; + entry.material = 0; + entry.herosforgemodel = 0; + entry.maxcharges = 0; + entry.mr = 0; + entry.nodrop = 0; + entry.norent = 0; + entry.pendingloreflag = 0; + entry.pr = 0; + entry.procrate = 0; + entry.races = 0; + entry.range = 0; + entry.reclevel = 0; + entry.recskill = 0; + entry.reqlevel = 0; + entry.sellrate = 0; + entry.shielding = 0; + entry.size = 0; + entry.skillmodtype = 0; + entry.skillmodvalue = 0; + entry.slots = 0; + entry.clickeffect = 0; + entry.spellshield = 0; + entry.strikethrough = 0; + entry.stunresist = 0; + entry.summonedflag = 0; + entry.tradeskills = 0; + entry.favor = 0; + entry.weight = 0; + entry.UNK012 = 0; + entry.UNK013 = 0; + entry.benefitflag = 0; + entry.UNK054 = 0; + entry.UNK059 = 0; + entry.booktype = 0; + entry.recastdelay = 0; + entry.recasttype = 0; + entry.guildfavor = 0; + entry.UNK123 = 0; + entry.UNK124 = 0; + entry.attuneable = 0; + entry.nopet = 0; + entry.updated = "0000-00-00 00:00:00"; + entry.comment = ""; + entry.UNK127 = 0; + entry.pointtype = 0; + entry.potionbelt = 0; + entry.potionbeltslots = 0; + entry.stacksize = 0; + entry.notransfer = 0; + entry.stackable = 0; + entry.UNK134 = ""; + entry.UNK137 = 0; + entry.proceffect = 0; + entry.proctype = 0; + entry.proclevel2 = 0; + entry.proclevel = 0; + entry.UNK142 = 0; + entry.worneffect = 0; + entry.worntype = 0; + entry.wornlevel2 = 0; + entry.wornlevel = 0; + entry.UNK147 = 0; + entry.focustype = 0; + entry.focuslevel2 = 0; + entry.focuslevel = 0; + entry.UNK152 = 0; + entry.scrolleffect = 0; + entry.scrolltype = 0; + entry.scrolllevel2 = 0; + entry.scrolllevel = 0; + entry.UNK157 = 0; + entry.serialized = 0; + entry.verified = 0; + entry.serialization = ""; + entry.source = ""; + entry.UNK033 = 0; + entry.lorefile = ""; + entry.UNK014 = 0; + entry.svcorruption = 0; + entry.skillmodmax = 0; + entry.UNK060 = 0; + entry.augslot1unk2 = 0; + entry.augslot2unk2 = 0; + entry.augslot3unk2 = 0; + entry.augslot4unk2 = 0; + entry.augslot5unk2 = 0; + entry.augslot6unk2 = 0; + entry.UNK120 = 0; + entry.UNK121 = 0; + entry.questitemflag = 0; + entry.UNK132 = ""; + entry.clickunk5 = 0; + entry.clickunk6 = ""; + entry.clickunk7 = 0; + entry.procunk1 = 0; + entry.procunk2 = 0; + entry.procunk3 = 0; + entry.procunk4 = 0; + entry.procunk6 = ""; + entry.procunk7 = 0; + entry.wornunk1 = 0; + entry.wornunk2 = 0; + entry.wornunk3 = 0; + entry.wornunk4 = 0; + entry.wornunk5 = 0; + entry.wornunk6 = ""; + entry.wornunk7 = 0; + entry.focusunk1 = 0; + entry.focusunk2 = 0; + entry.focusunk3 = 0; + entry.focusunk4 = 0; + entry.focusunk5 = 0; + entry.focusunk6 = ""; + entry.focusunk7 = 0; + entry.scrollunk1 = 0; + entry.scrollunk2 = 0; + entry.scrollunk3 = 0; + entry.scrollunk4 = 0; + entry.scrollunk5 = 0; + entry.scrollunk6 = ""; + entry.scrollunk7 = 0; + entry.UNK193 = 0; + entry.purity = 0; + entry.evoitem = 0; + entry.evoid = 0; + entry.evolvinglevel = 0; + entry.evomax = 0; + entry.clickname = ""; + entry.procname = ""; + entry.wornname = ""; + entry.focusname = ""; + entry.scrollname = ""; + entry.dsmitigation = 0; + entry.heroic_str = 0; + entry.heroic_int = 0; + entry.heroic_wis = 0; + entry.heroic_agi = 0; + entry.heroic_dex = 0; + entry.heroic_sta = 0; + entry.heroic_cha = 0; + entry.heroic_pr = 0; + entry.heroic_dr = 0; + entry.heroic_fr = 0; + entry.heroic_cr = 0; + entry.heroic_mr = 0; + entry.heroic_svcorrup = 0; + entry.healamt = 0; + entry.spelldmg = 0; + entry.clairvoyance = 0; + entry.backstabdmg = 0; + entry.created = ""; + entry.elitematerial = 0; + entry.ldonsellbackrate = 0; + entry.scriptfileid = 0; + entry.expendablearrow = 0; + entry.powersourcecapacity = 0; + entry.bardeffect = 0; + entry.bardeffecttype = 0; + entry.bardlevel2 = 0; + entry.bardlevel = 0; + entry.bardunk1 = 0; + entry.bardunk2 = 0; + entry.bardunk3 = 0; + entry.bardunk4 = 0; + entry.bardunk5 = 0; + entry.bardname = ""; + entry.bardunk7 = 0; + entry.UNK214 = 0; + entry.UNK219 = 0; + entry.UNK220 = 0; + entry.UNK221 = 0; + entry.heirloom = 0; + entry.UNK223 = 0; + entry.UNK224 = 0; + entry.UNK225 = 0; + entry.UNK226 = 0; + entry.UNK227 = 0; + entry.UNK228 = 0; + entry.UNK229 = 0; + entry.UNK230 = 0; + entry.UNK231 = 0; + entry.UNK232 = 0; + entry.UNK233 = 0; + entry.UNK234 = 0; + entry.placeable = 0; + entry.UNK236 = 0; + entry.UNK237 = 0; + entry.UNK238 = 0; + entry.UNK239 = 0; + entry.UNK240 = 0; + entry.UNK241 = 0; + entry.epicitem = 0; + + return entry; + } + + static Items GetItemsEntry( + const std::vector &itemss, + int items_id + ) + { + for (auto &items : itemss) { + if (items.id == items_id) { + return items; + } + } + + return NewEntity(); + } + + static Items FindOne( + int items_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + items_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Items entry{}; + + entry.id = atoi(row[0]); + entry.minstatus = atoi(row[1]); + entry.Name = row[2] ? row[2] : ""; + entry.aagi = atoi(row[3]); + entry.ac = atoi(row[4]); + entry.accuracy = atoi(row[5]); + entry.acha = atoi(row[6]); + entry.adex = atoi(row[7]); + entry.aint = atoi(row[8]); + entry.artifactflag = atoi(row[9]); + entry.asta = atoi(row[10]); + entry.astr = atoi(row[11]); + entry.attack = atoi(row[12]); + entry.augrestrict = atoi(row[13]); + entry.augslot1type = atoi(row[14]); + entry.augslot1visible = atoi(row[15]); + entry.augslot2type = atoi(row[16]); + entry.augslot2visible = atoi(row[17]); + entry.augslot3type = atoi(row[18]); + entry.augslot3visible = atoi(row[19]); + entry.augslot4type = atoi(row[20]); + entry.augslot4visible = atoi(row[21]); + entry.augslot5type = atoi(row[22]); + entry.augslot5visible = atoi(row[23]); + entry.augslot6type = atoi(row[24]); + entry.augslot6visible = atoi(row[25]); + entry.augtype = atoi(row[26]); + entry.avoidance = atoi(row[27]); + entry.awis = atoi(row[28]); + entry.bagsize = atoi(row[29]); + entry.bagslots = atoi(row[30]); + entry.bagtype = atoi(row[31]); + entry.bagwr = atoi(row[32]); + entry.banedmgamt = atoi(row[33]); + entry.banedmgraceamt = atoi(row[34]); + entry.banedmgbody = atoi(row[35]); + entry.banedmgrace = atoi(row[36]); + entry.bardtype = atoi(row[37]); + entry.bardvalue = atoi(row[38]); + entry.book = atoi(row[39]); + entry.casttime = atoi(row[40]); + entry.casttime_ = atoi(row[41]); + entry.charmfile = row[42] ? row[42] : ""; + entry.charmfileid = row[43] ? row[43] : ""; + entry.classes = atoi(row[44]); + entry.color = atoi(row[45]); + entry.combateffects = row[46] ? row[46] : ""; + entry.extradmgskill = atoi(row[47]); + entry.extradmgamt = atoi(row[48]); + entry.price = atoi(row[49]); + entry.cr = atoi(row[50]); + entry.damage = atoi(row[51]); + entry.damageshield = atoi(row[52]); + entry.deity = atoi(row[53]); + entry.delay = atoi(row[54]); + entry.augdistiller = atoi(row[55]); + entry.dotshielding = atoi(row[56]); + entry.dr = atoi(row[57]); + entry.clicktype = atoi(row[58]); + entry.clicklevel2 = atoi(row[59]); + entry.elemdmgtype = atoi(row[60]); + entry.elemdmgamt = atoi(row[61]); + entry.endur = atoi(row[62]); + entry.factionamt1 = atoi(row[63]); + entry.factionamt2 = atoi(row[64]); + entry.factionamt3 = atoi(row[65]); + entry.factionamt4 = atoi(row[66]); + entry.factionmod1 = atoi(row[67]); + entry.factionmod2 = atoi(row[68]); + entry.factionmod3 = atoi(row[69]); + entry.factionmod4 = atoi(row[70]); + entry.filename = row[71] ? row[71] : ""; + entry.focuseffect = atoi(row[72]); + entry.fr = atoi(row[73]); + entry.fvnodrop = atoi(row[74]); + entry.haste = atoi(row[75]); + entry.clicklevel = atoi(row[76]); + entry.hp = atoi(row[77]); + entry.regen = atoi(row[78]); + entry.icon = atoi(row[79]); + entry.idfile = row[80] ? row[80] : ""; + entry.itemclass = atoi(row[81]); + entry.itemtype = atoi(row[82]); + entry.ldonprice = atoi(row[83]); + entry.ldontheme = atoi(row[84]); + entry.ldonsold = atoi(row[85]); + entry.light = atoi(row[86]); + entry.lore = row[87] ? row[87] : ""; + entry.loregroup = atoi(row[88]); + entry.magic = atoi(row[89]); + entry.mana = atoi(row[90]); + entry.manaregen = atoi(row[91]); + entry.enduranceregen = atoi(row[92]); + entry.material = atoi(row[93]); + entry.herosforgemodel = atoi(row[94]); + entry.maxcharges = atoi(row[95]); + entry.mr = atoi(row[96]); + entry.nodrop = atoi(row[97]); + entry.norent = atoi(row[98]); + entry.pendingloreflag = atoi(row[99]); + entry.pr = atoi(row[100]); + entry.procrate = atoi(row[101]); + entry.races = atoi(row[102]); + entry.range = atoi(row[103]); + entry.reclevel = atoi(row[104]); + entry.recskill = atoi(row[105]); + entry.reqlevel = atoi(row[106]); + entry.sellrate = atof(row[107]); + entry.shielding = atoi(row[108]); + entry.size = atoi(row[109]); + entry.skillmodtype = atoi(row[110]); + entry.skillmodvalue = atoi(row[111]); + entry.slots = atoi(row[112]); + entry.clickeffect = atoi(row[113]); + entry.spellshield = atoi(row[114]); + entry.strikethrough = atoi(row[115]); + entry.stunresist = atoi(row[116]); + entry.summonedflag = atoi(row[117]); + entry.tradeskills = atoi(row[118]); + entry.favor = atoi(row[119]); + entry.weight = atoi(row[120]); + entry.UNK012 = atoi(row[121]); + entry.UNK013 = atoi(row[122]); + entry.benefitflag = atoi(row[123]); + entry.UNK054 = atoi(row[124]); + entry.UNK059 = atoi(row[125]); + entry.booktype = atoi(row[126]); + entry.recastdelay = atoi(row[127]); + entry.recasttype = atoi(row[128]); + entry.guildfavor = atoi(row[129]); + entry.UNK123 = atoi(row[130]); + entry.UNK124 = atoi(row[131]); + entry.attuneable = atoi(row[132]); + entry.nopet = atoi(row[133]); + entry.updated = row[134] ? row[134] : ""; + entry.comment = row[135] ? row[135] : ""; + entry.UNK127 = atoi(row[136]); + entry.pointtype = atoi(row[137]); + entry.potionbelt = atoi(row[138]); + entry.potionbeltslots = atoi(row[139]); + entry.stacksize = atoi(row[140]); + entry.notransfer = atoi(row[141]); + entry.stackable = atoi(row[142]); + entry.UNK134 = row[143] ? row[143] : ""; + entry.UNK137 = atoi(row[144]); + entry.proceffect = atoi(row[145]); + entry.proctype = atoi(row[146]); + entry.proclevel2 = atoi(row[147]); + entry.proclevel = atoi(row[148]); + entry.UNK142 = atoi(row[149]); + entry.worneffect = atoi(row[150]); + entry.worntype = atoi(row[151]); + entry.wornlevel2 = atoi(row[152]); + entry.wornlevel = atoi(row[153]); + entry.UNK147 = atoi(row[154]); + entry.focustype = atoi(row[155]); + entry.focuslevel2 = atoi(row[156]); + entry.focuslevel = atoi(row[157]); + entry.UNK152 = atoi(row[158]); + entry.scrolleffect = atoi(row[159]); + entry.scrolltype = atoi(row[160]); + entry.scrolllevel2 = atoi(row[161]); + entry.scrolllevel = atoi(row[162]); + entry.UNK157 = atoi(row[163]); + entry.serialized = row[164] ? row[164] : ""; + entry.verified = row[165] ? row[165] : ""; + entry.serialization = row[166] ? row[166] : ""; + entry.source = row[167] ? row[167] : ""; + entry.UNK033 = atoi(row[168]); + entry.lorefile = row[169] ? row[169] : ""; + entry.UNK014 = atoi(row[170]); + entry.svcorruption = atoi(row[171]); + entry.skillmodmax = atoi(row[172]); + entry.UNK060 = atoi(row[173]); + entry.augslot1unk2 = atoi(row[174]); + entry.augslot2unk2 = atoi(row[175]); + entry.augslot3unk2 = atoi(row[176]); + entry.augslot4unk2 = atoi(row[177]); + entry.augslot5unk2 = atoi(row[178]); + entry.augslot6unk2 = atoi(row[179]); + entry.UNK120 = atoi(row[180]); + entry.UNK121 = atoi(row[181]); + entry.questitemflag = atoi(row[182]); + entry.UNK132 = row[183] ? row[183] : ""; + entry.clickunk5 = atoi(row[184]); + entry.clickunk6 = row[185] ? row[185] : ""; + entry.clickunk7 = atoi(row[186]); + entry.procunk1 = atoi(row[187]); + entry.procunk2 = atoi(row[188]); + entry.procunk3 = atoi(row[189]); + entry.procunk4 = atoi(row[190]); + entry.procunk6 = row[191] ? row[191] : ""; + entry.procunk7 = atoi(row[192]); + entry.wornunk1 = atoi(row[193]); + entry.wornunk2 = atoi(row[194]); + entry.wornunk3 = atoi(row[195]); + entry.wornunk4 = atoi(row[196]); + entry.wornunk5 = atoi(row[197]); + entry.wornunk6 = row[198] ? row[198] : ""; + entry.wornunk7 = atoi(row[199]); + entry.focusunk1 = atoi(row[200]); + entry.focusunk2 = atoi(row[201]); + entry.focusunk3 = atoi(row[202]); + entry.focusunk4 = atoi(row[203]); + entry.focusunk5 = atoi(row[204]); + entry.focusunk6 = row[205] ? row[205] : ""; + entry.focusunk7 = atoi(row[206]); + entry.scrollunk1 = atoi(row[207]); + entry.scrollunk2 = atoi(row[208]); + entry.scrollunk3 = atoi(row[209]); + entry.scrollunk4 = atoi(row[210]); + entry.scrollunk5 = atoi(row[211]); + entry.scrollunk6 = row[212] ? row[212] : ""; + entry.scrollunk7 = atoi(row[213]); + entry.UNK193 = atoi(row[214]); + entry.purity = atoi(row[215]); + entry.evoitem = atoi(row[216]); + entry.evoid = atoi(row[217]); + entry.evolvinglevel = atoi(row[218]); + entry.evomax = atoi(row[219]); + entry.clickname = row[220] ? row[220] : ""; + entry.procname = row[221] ? row[221] : ""; + entry.wornname = row[222] ? row[222] : ""; + entry.focusname = row[223] ? row[223] : ""; + entry.scrollname = row[224] ? row[224] : ""; + entry.dsmitigation = atoi(row[225]); + entry.heroic_str = atoi(row[226]); + entry.heroic_int = atoi(row[227]); + entry.heroic_wis = atoi(row[228]); + entry.heroic_agi = atoi(row[229]); + entry.heroic_dex = atoi(row[230]); + entry.heroic_sta = atoi(row[231]); + entry.heroic_cha = atoi(row[232]); + entry.heroic_pr = atoi(row[233]); + entry.heroic_dr = atoi(row[234]); + entry.heroic_fr = atoi(row[235]); + entry.heroic_cr = atoi(row[236]); + entry.heroic_mr = atoi(row[237]); + entry.heroic_svcorrup = atoi(row[238]); + entry.healamt = atoi(row[239]); + entry.spelldmg = atoi(row[240]); + entry.clairvoyance = atoi(row[241]); + entry.backstabdmg = atoi(row[242]); + entry.created = row[243] ? row[243] : ""; + entry.elitematerial = atoi(row[244]); + entry.ldonsellbackrate = atoi(row[245]); + entry.scriptfileid = atoi(row[246]); + entry.expendablearrow = atoi(row[247]); + entry.powersourcecapacity = atoi(row[248]); + entry.bardeffect = atoi(row[249]); + entry.bardeffecttype = atoi(row[250]); + entry.bardlevel2 = atoi(row[251]); + entry.bardlevel = atoi(row[252]); + entry.bardunk1 = atoi(row[253]); + entry.bardunk2 = atoi(row[254]); + entry.bardunk3 = atoi(row[255]); + entry.bardunk4 = atoi(row[256]); + entry.bardunk5 = atoi(row[257]); + entry.bardname = row[258] ? row[258] : ""; + entry.bardunk7 = atoi(row[259]); + entry.UNK214 = atoi(row[260]); + entry.UNK219 = atoi(row[261]); + entry.UNK220 = atoi(row[262]); + entry.UNK221 = atoi(row[263]); + entry.heirloom = atoi(row[264]); + entry.UNK223 = atoi(row[265]); + entry.UNK224 = atoi(row[266]); + entry.UNK225 = atoi(row[267]); + entry.UNK226 = atoi(row[268]); + entry.UNK227 = atoi(row[269]); + entry.UNK228 = atoi(row[270]); + entry.UNK229 = atoi(row[271]); + entry.UNK230 = atoi(row[272]); + entry.UNK231 = atoi(row[273]); + entry.UNK232 = atoi(row[274]); + entry.UNK233 = atoi(row[275]); + entry.UNK234 = atoi(row[276]); + entry.placeable = atoi(row[277]); + entry.UNK236 = atoi(row[278]); + entry.UNK237 = atoi(row[279]); + entry.UNK238 = atoi(row[280]); + entry.UNK239 = atoi(row[281]); + entry.UNK240 = atoi(row[282]); + entry.UNK241 = atoi(row[283]); + entry.epicitem = atoi(row[284]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int items_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + items_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Items items_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(items_entry.minstatus)); + update_values.push_back(columns[2] + " = '" + EscapeString(items_entry.Name) + "'"); + update_values.push_back(columns[3] + " = " + std::to_string(items_entry.aagi)); + update_values.push_back(columns[4] + " = " + std::to_string(items_entry.ac)); + update_values.push_back(columns[5] + " = " + std::to_string(items_entry.accuracy)); + update_values.push_back(columns[6] + " = " + std::to_string(items_entry.acha)); + update_values.push_back(columns[7] + " = " + std::to_string(items_entry.adex)); + update_values.push_back(columns[8] + " = " + std::to_string(items_entry.aint)); + update_values.push_back(columns[9] + " = " + std::to_string(items_entry.artifactflag)); + update_values.push_back(columns[10] + " = " + std::to_string(items_entry.asta)); + update_values.push_back(columns[11] + " = " + std::to_string(items_entry.astr)); + update_values.push_back(columns[12] + " = " + std::to_string(items_entry.attack)); + update_values.push_back(columns[13] + " = " + std::to_string(items_entry.augrestrict)); + update_values.push_back(columns[14] + " = " + std::to_string(items_entry.augslot1type)); + update_values.push_back(columns[15] + " = " + std::to_string(items_entry.augslot1visible)); + update_values.push_back(columns[16] + " = " + std::to_string(items_entry.augslot2type)); + update_values.push_back(columns[17] + " = " + std::to_string(items_entry.augslot2visible)); + update_values.push_back(columns[18] + " = " + std::to_string(items_entry.augslot3type)); + update_values.push_back(columns[19] + " = " + std::to_string(items_entry.augslot3visible)); + update_values.push_back(columns[20] + " = " + std::to_string(items_entry.augslot4type)); + update_values.push_back(columns[21] + " = " + std::to_string(items_entry.augslot4visible)); + update_values.push_back(columns[22] + " = " + std::to_string(items_entry.augslot5type)); + update_values.push_back(columns[23] + " = " + std::to_string(items_entry.augslot5visible)); + update_values.push_back(columns[24] + " = " + std::to_string(items_entry.augslot6type)); + update_values.push_back(columns[25] + " = " + std::to_string(items_entry.augslot6visible)); + update_values.push_back(columns[26] + " = " + std::to_string(items_entry.augtype)); + update_values.push_back(columns[27] + " = " + std::to_string(items_entry.avoidance)); + update_values.push_back(columns[28] + " = " + std::to_string(items_entry.awis)); + update_values.push_back(columns[29] + " = " + std::to_string(items_entry.bagsize)); + update_values.push_back(columns[30] + " = " + std::to_string(items_entry.bagslots)); + update_values.push_back(columns[31] + " = " + std::to_string(items_entry.bagtype)); + update_values.push_back(columns[32] + " = " + std::to_string(items_entry.bagwr)); + update_values.push_back(columns[33] + " = " + std::to_string(items_entry.banedmgamt)); + update_values.push_back(columns[34] + " = " + std::to_string(items_entry.banedmgraceamt)); + update_values.push_back(columns[35] + " = " + std::to_string(items_entry.banedmgbody)); + update_values.push_back(columns[36] + " = " + std::to_string(items_entry.banedmgrace)); + update_values.push_back(columns[37] + " = " + std::to_string(items_entry.bardtype)); + update_values.push_back(columns[38] + " = " + std::to_string(items_entry.bardvalue)); + update_values.push_back(columns[39] + " = " + std::to_string(items_entry.book)); + update_values.push_back(columns[40] + " = " + std::to_string(items_entry.casttime)); + update_values.push_back(columns[41] + " = " + std::to_string(items_entry.casttime_)); + update_values.push_back(columns[42] + " = '" + EscapeString(items_entry.charmfile) + "'"); + update_values.push_back(columns[43] + " = '" + EscapeString(items_entry.charmfileid) + "'"); + update_values.push_back(columns[44] + " = " + std::to_string(items_entry.classes)); + update_values.push_back(columns[45] + " = " + std::to_string(items_entry.color)); + update_values.push_back(columns[46] + " = '" + EscapeString(items_entry.combateffects) + "'"); + update_values.push_back(columns[47] + " = " + std::to_string(items_entry.extradmgskill)); + update_values.push_back(columns[48] + " = " + std::to_string(items_entry.extradmgamt)); + update_values.push_back(columns[49] + " = " + std::to_string(items_entry.price)); + update_values.push_back(columns[50] + " = " + std::to_string(items_entry.cr)); + update_values.push_back(columns[51] + " = " + std::to_string(items_entry.damage)); + update_values.push_back(columns[52] + " = " + std::to_string(items_entry.damageshield)); + update_values.push_back(columns[53] + " = " + std::to_string(items_entry.deity)); + update_values.push_back(columns[54] + " = " + std::to_string(items_entry.delay)); + update_values.push_back(columns[55] + " = " + std::to_string(items_entry.augdistiller)); + update_values.push_back(columns[56] + " = " + std::to_string(items_entry.dotshielding)); + update_values.push_back(columns[57] + " = " + std::to_string(items_entry.dr)); + update_values.push_back(columns[58] + " = " + std::to_string(items_entry.clicktype)); + update_values.push_back(columns[59] + " = " + std::to_string(items_entry.clicklevel2)); + update_values.push_back(columns[60] + " = " + std::to_string(items_entry.elemdmgtype)); + update_values.push_back(columns[61] + " = " + std::to_string(items_entry.elemdmgamt)); + update_values.push_back(columns[62] + " = " + std::to_string(items_entry.endur)); + update_values.push_back(columns[63] + " = " + std::to_string(items_entry.factionamt1)); + update_values.push_back(columns[64] + " = " + std::to_string(items_entry.factionamt2)); + update_values.push_back(columns[65] + " = " + std::to_string(items_entry.factionamt3)); + update_values.push_back(columns[66] + " = " + std::to_string(items_entry.factionamt4)); + update_values.push_back(columns[67] + " = " + std::to_string(items_entry.factionmod1)); + update_values.push_back(columns[68] + " = " + std::to_string(items_entry.factionmod2)); + update_values.push_back(columns[69] + " = " + std::to_string(items_entry.factionmod3)); + update_values.push_back(columns[70] + " = " + std::to_string(items_entry.factionmod4)); + update_values.push_back(columns[71] + " = '" + EscapeString(items_entry.filename) + "'"); + update_values.push_back(columns[72] + " = " + std::to_string(items_entry.focuseffect)); + update_values.push_back(columns[73] + " = " + std::to_string(items_entry.fr)); + update_values.push_back(columns[74] + " = " + std::to_string(items_entry.fvnodrop)); + update_values.push_back(columns[75] + " = " + std::to_string(items_entry.haste)); + update_values.push_back(columns[76] + " = " + std::to_string(items_entry.clicklevel)); + update_values.push_back(columns[77] + " = " + std::to_string(items_entry.hp)); + update_values.push_back(columns[78] + " = " + std::to_string(items_entry.regen)); + update_values.push_back(columns[79] + " = " + std::to_string(items_entry.icon)); + update_values.push_back(columns[80] + " = '" + EscapeString(items_entry.idfile) + "'"); + update_values.push_back(columns[81] + " = " + std::to_string(items_entry.itemclass)); + update_values.push_back(columns[82] + " = " + std::to_string(items_entry.itemtype)); + update_values.push_back(columns[83] + " = " + std::to_string(items_entry.ldonprice)); + update_values.push_back(columns[84] + " = " + std::to_string(items_entry.ldontheme)); + update_values.push_back(columns[85] + " = " + std::to_string(items_entry.ldonsold)); + update_values.push_back(columns[86] + " = " + std::to_string(items_entry.light)); + update_values.push_back(columns[87] + " = '" + EscapeString(items_entry.lore) + "'"); + update_values.push_back(columns[88] + " = " + std::to_string(items_entry.loregroup)); + update_values.push_back(columns[89] + " = " + std::to_string(items_entry.magic)); + update_values.push_back(columns[90] + " = " + std::to_string(items_entry.mana)); + update_values.push_back(columns[91] + " = " + std::to_string(items_entry.manaregen)); + update_values.push_back(columns[92] + " = " + std::to_string(items_entry.enduranceregen)); + update_values.push_back(columns[93] + " = " + std::to_string(items_entry.material)); + update_values.push_back(columns[94] + " = " + std::to_string(items_entry.herosforgemodel)); + update_values.push_back(columns[95] + " = " + std::to_string(items_entry.maxcharges)); + update_values.push_back(columns[96] + " = " + std::to_string(items_entry.mr)); + update_values.push_back(columns[97] + " = " + std::to_string(items_entry.nodrop)); + update_values.push_back(columns[98] + " = " + std::to_string(items_entry.norent)); + update_values.push_back(columns[99] + " = " + std::to_string(items_entry.pendingloreflag)); + update_values.push_back(columns[100] + " = " + std::to_string(items_entry.pr)); + update_values.push_back(columns[101] + " = " + std::to_string(items_entry.procrate)); + update_values.push_back(columns[102] + " = " + std::to_string(items_entry.races)); + update_values.push_back(columns[103] + " = " + std::to_string(items_entry.range)); + update_values.push_back(columns[104] + " = " + std::to_string(items_entry.reclevel)); + update_values.push_back(columns[105] + " = " + std::to_string(items_entry.recskill)); + update_values.push_back(columns[106] + " = " + std::to_string(items_entry.reqlevel)); + update_values.push_back(columns[107] + " = " + std::to_string(items_entry.sellrate)); + update_values.push_back(columns[108] + " = " + std::to_string(items_entry.shielding)); + update_values.push_back(columns[109] + " = " + std::to_string(items_entry.size)); + update_values.push_back(columns[110] + " = " + std::to_string(items_entry.skillmodtype)); + update_values.push_back(columns[111] + " = " + std::to_string(items_entry.skillmodvalue)); + update_values.push_back(columns[112] + " = " + std::to_string(items_entry.slots)); + update_values.push_back(columns[113] + " = " + std::to_string(items_entry.clickeffect)); + update_values.push_back(columns[114] + " = " + std::to_string(items_entry.spellshield)); + update_values.push_back(columns[115] + " = " + std::to_string(items_entry.strikethrough)); + update_values.push_back(columns[116] + " = " + std::to_string(items_entry.stunresist)); + update_values.push_back(columns[117] + " = " + std::to_string(items_entry.summonedflag)); + update_values.push_back(columns[118] + " = " + std::to_string(items_entry.tradeskills)); + update_values.push_back(columns[119] + " = " + std::to_string(items_entry.favor)); + update_values.push_back(columns[120] + " = " + std::to_string(items_entry.weight)); + update_values.push_back(columns[121] + " = " + std::to_string(items_entry.UNK012)); + update_values.push_back(columns[122] + " = " + std::to_string(items_entry.UNK013)); + update_values.push_back(columns[123] + " = " + std::to_string(items_entry.benefitflag)); + update_values.push_back(columns[124] + " = " + std::to_string(items_entry.UNK054)); + update_values.push_back(columns[125] + " = " + std::to_string(items_entry.UNK059)); + update_values.push_back(columns[126] + " = " + std::to_string(items_entry.booktype)); + update_values.push_back(columns[127] + " = " + std::to_string(items_entry.recastdelay)); + update_values.push_back(columns[128] + " = " + std::to_string(items_entry.recasttype)); + update_values.push_back(columns[129] + " = " + std::to_string(items_entry.guildfavor)); + update_values.push_back(columns[130] + " = " + std::to_string(items_entry.UNK123)); + update_values.push_back(columns[131] + " = " + std::to_string(items_entry.UNK124)); + update_values.push_back(columns[132] + " = " + std::to_string(items_entry.attuneable)); + update_values.push_back(columns[133] + " = " + std::to_string(items_entry.nopet)); + update_values.push_back(columns[134] + " = '" + EscapeString(items_entry.updated) + "'"); + update_values.push_back(columns[135] + " = '" + EscapeString(items_entry.comment) + "'"); + update_values.push_back(columns[136] + " = " + std::to_string(items_entry.UNK127)); + update_values.push_back(columns[137] + " = " + std::to_string(items_entry.pointtype)); + update_values.push_back(columns[138] + " = " + std::to_string(items_entry.potionbelt)); + update_values.push_back(columns[139] + " = " + std::to_string(items_entry.potionbeltslots)); + update_values.push_back(columns[140] + " = " + std::to_string(items_entry.stacksize)); + update_values.push_back(columns[141] + " = " + std::to_string(items_entry.notransfer)); + update_values.push_back(columns[142] + " = " + std::to_string(items_entry.stackable)); + update_values.push_back(columns[143] + " = '" + EscapeString(items_entry.UNK134) + "'"); + update_values.push_back(columns[144] + " = " + std::to_string(items_entry.UNK137)); + update_values.push_back(columns[145] + " = " + std::to_string(items_entry.proceffect)); + update_values.push_back(columns[146] + " = " + std::to_string(items_entry.proctype)); + update_values.push_back(columns[147] + " = " + std::to_string(items_entry.proclevel2)); + update_values.push_back(columns[148] + " = " + std::to_string(items_entry.proclevel)); + update_values.push_back(columns[149] + " = " + std::to_string(items_entry.UNK142)); + update_values.push_back(columns[150] + " = " + std::to_string(items_entry.worneffect)); + update_values.push_back(columns[151] + " = " + std::to_string(items_entry.worntype)); + update_values.push_back(columns[152] + " = " + std::to_string(items_entry.wornlevel2)); + update_values.push_back(columns[153] + " = " + std::to_string(items_entry.wornlevel)); + update_values.push_back(columns[154] + " = " + std::to_string(items_entry.UNK147)); + update_values.push_back(columns[155] + " = " + std::to_string(items_entry.focustype)); + update_values.push_back(columns[156] + " = " + std::to_string(items_entry.focuslevel2)); + update_values.push_back(columns[157] + " = " + std::to_string(items_entry.focuslevel)); + update_values.push_back(columns[158] + " = " + std::to_string(items_entry.UNK152)); + update_values.push_back(columns[159] + " = " + std::to_string(items_entry.scrolleffect)); + update_values.push_back(columns[160] + " = " + std::to_string(items_entry.scrolltype)); + update_values.push_back(columns[161] + " = " + std::to_string(items_entry.scrolllevel2)); + update_values.push_back(columns[162] + " = " + std::to_string(items_entry.scrolllevel)); + update_values.push_back(columns[163] + " = " + std::to_string(items_entry.UNK157)); + update_values.push_back(columns[164] + " = '" + EscapeString(items_entry.serialized) + "'"); + update_values.push_back(columns[165] + " = '" + EscapeString(items_entry.verified) + "'"); + update_values.push_back(columns[166] + " = '" + EscapeString(items_entry.serialization) + "'"); + update_values.push_back(columns[167] + " = '" + EscapeString(items_entry.source) + "'"); + update_values.push_back(columns[168] + " = " + std::to_string(items_entry.UNK033)); + update_values.push_back(columns[169] + " = '" + EscapeString(items_entry.lorefile) + "'"); + update_values.push_back(columns[170] + " = " + std::to_string(items_entry.UNK014)); + update_values.push_back(columns[171] + " = " + std::to_string(items_entry.svcorruption)); + update_values.push_back(columns[172] + " = " + std::to_string(items_entry.skillmodmax)); + update_values.push_back(columns[173] + " = " + std::to_string(items_entry.UNK060)); + update_values.push_back(columns[174] + " = " + std::to_string(items_entry.augslot1unk2)); + update_values.push_back(columns[175] + " = " + std::to_string(items_entry.augslot2unk2)); + update_values.push_back(columns[176] + " = " + std::to_string(items_entry.augslot3unk2)); + update_values.push_back(columns[177] + " = " + std::to_string(items_entry.augslot4unk2)); + update_values.push_back(columns[178] + " = " + std::to_string(items_entry.augslot5unk2)); + update_values.push_back(columns[179] + " = " + std::to_string(items_entry.augslot6unk2)); + update_values.push_back(columns[180] + " = " + std::to_string(items_entry.UNK120)); + update_values.push_back(columns[181] + " = " + std::to_string(items_entry.UNK121)); + update_values.push_back(columns[182] + " = " + std::to_string(items_entry.questitemflag)); + update_values.push_back(columns[183] + " = '" + EscapeString(items_entry.UNK132) + "'"); + update_values.push_back(columns[184] + " = " + std::to_string(items_entry.clickunk5)); + update_values.push_back(columns[185] + " = '" + EscapeString(items_entry.clickunk6) + "'"); + update_values.push_back(columns[186] + " = " + std::to_string(items_entry.clickunk7)); + update_values.push_back(columns[187] + " = " + std::to_string(items_entry.procunk1)); + update_values.push_back(columns[188] + " = " + std::to_string(items_entry.procunk2)); + update_values.push_back(columns[189] + " = " + std::to_string(items_entry.procunk3)); + update_values.push_back(columns[190] + " = " + std::to_string(items_entry.procunk4)); + update_values.push_back(columns[191] + " = '" + EscapeString(items_entry.procunk6) + "'"); + update_values.push_back(columns[192] + " = " + std::to_string(items_entry.procunk7)); + update_values.push_back(columns[193] + " = " + std::to_string(items_entry.wornunk1)); + update_values.push_back(columns[194] + " = " + std::to_string(items_entry.wornunk2)); + update_values.push_back(columns[195] + " = " + std::to_string(items_entry.wornunk3)); + update_values.push_back(columns[196] + " = " + std::to_string(items_entry.wornunk4)); + update_values.push_back(columns[197] + " = " + std::to_string(items_entry.wornunk5)); + update_values.push_back(columns[198] + " = '" + EscapeString(items_entry.wornunk6) + "'"); + update_values.push_back(columns[199] + " = " + std::to_string(items_entry.wornunk7)); + update_values.push_back(columns[200] + " = " + std::to_string(items_entry.focusunk1)); + update_values.push_back(columns[201] + " = " + std::to_string(items_entry.focusunk2)); + update_values.push_back(columns[202] + " = " + std::to_string(items_entry.focusunk3)); + update_values.push_back(columns[203] + " = " + std::to_string(items_entry.focusunk4)); + update_values.push_back(columns[204] + " = " + std::to_string(items_entry.focusunk5)); + update_values.push_back(columns[205] + " = '" + EscapeString(items_entry.focusunk6) + "'"); + update_values.push_back(columns[206] + " = " + std::to_string(items_entry.focusunk7)); + update_values.push_back(columns[207] + " = " + std::to_string(items_entry.scrollunk1)); + update_values.push_back(columns[208] + " = " + std::to_string(items_entry.scrollunk2)); + update_values.push_back(columns[209] + " = " + std::to_string(items_entry.scrollunk3)); + update_values.push_back(columns[210] + " = " + std::to_string(items_entry.scrollunk4)); + update_values.push_back(columns[211] + " = " + std::to_string(items_entry.scrollunk5)); + update_values.push_back(columns[212] + " = '" + EscapeString(items_entry.scrollunk6) + "'"); + update_values.push_back(columns[213] + " = " + std::to_string(items_entry.scrollunk7)); + update_values.push_back(columns[214] + " = " + std::to_string(items_entry.UNK193)); + update_values.push_back(columns[215] + " = " + std::to_string(items_entry.purity)); + update_values.push_back(columns[216] + " = " + std::to_string(items_entry.evoitem)); + update_values.push_back(columns[217] + " = " + std::to_string(items_entry.evoid)); + update_values.push_back(columns[218] + " = " + std::to_string(items_entry.evolvinglevel)); + update_values.push_back(columns[219] + " = " + std::to_string(items_entry.evomax)); + update_values.push_back(columns[220] + " = '" + EscapeString(items_entry.clickname) + "'"); + update_values.push_back(columns[221] + " = '" + EscapeString(items_entry.procname) + "'"); + update_values.push_back(columns[222] + " = '" + EscapeString(items_entry.wornname) + "'"); + update_values.push_back(columns[223] + " = '" + EscapeString(items_entry.focusname) + "'"); + update_values.push_back(columns[224] + " = '" + EscapeString(items_entry.scrollname) + "'"); + update_values.push_back(columns[225] + " = " + std::to_string(items_entry.dsmitigation)); + update_values.push_back(columns[226] + " = " + std::to_string(items_entry.heroic_str)); + update_values.push_back(columns[227] + " = " + std::to_string(items_entry.heroic_int)); + update_values.push_back(columns[228] + " = " + std::to_string(items_entry.heroic_wis)); + update_values.push_back(columns[229] + " = " + std::to_string(items_entry.heroic_agi)); + update_values.push_back(columns[230] + " = " + std::to_string(items_entry.heroic_dex)); + update_values.push_back(columns[231] + " = " + std::to_string(items_entry.heroic_sta)); + update_values.push_back(columns[232] + " = " + std::to_string(items_entry.heroic_cha)); + update_values.push_back(columns[233] + " = " + std::to_string(items_entry.heroic_pr)); + update_values.push_back(columns[234] + " = " + std::to_string(items_entry.heroic_dr)); + update_values.push_back(columns[235] + " = " + std::to_string(items_entry.heroic_fr)); + update_values.push_back(columns[236] + " = " + std::to_string(items_entry.heroic_cr)); + update_values.push_back(columns[237] + " = " + std::to_string(items_entry.heroic_mr)); + update_values.push_back(columns[238] + " = " + std::to_string(items_entry.heroic_svcorrup)); + update_values.push_back(columns[239] + " = " + std::to_string(items_entry.healamt)); + update_values.push_back(columns[240] + " = " + std::to_string(items_entry.spelldmg)); + update_values.push_back(columns[241] + " = " + std::to_string(items_entry.clairvoyance)); + update_values.push_back(columns[242] + " = " + std::to_string(items_entry.backstabdmg)); + update_values.push_back(columns[243] + " = '" + EscapeString(items_entry.created) + "'"); + update_values.push_back(columns[244] + " = " + std::to_string(items_entry.elitematerial)); + update_values.push_back(columns[245] + " = " + std::to_string(items_entry.ldonsellbackrate)); + update_values.push_back(columns[246] + " = " + std::to_string(items_entry.scriptfileid)); + update_values.push_back(columns[247] + " = " + std::to_string(items_entry.expendablearrow)); + update_values.push_back(columns[248] + " = " + std::to_string(items_entry.powersourcecapacity)); + update_values.push_back(columns[249] + " = " + std::to_string(items_entry.bardeffect)); + update_values.push_back(columns[250] + " = " + std::to_string(items_entry.bardeffecttype)); + update_values.push_back(columns[251] + " = " + std::to_string(items_entry.bardlevel2)); + update_values.push_back(columns[252] + " = " + std::to_string(items_entry.bardlevel)); + update_values.push_back(columns[253] + " = " + std::to_string(items_entry.bardunk1)); + update_values.push_back(columns[254] + " = " + std::to_string(items_entry.bardunk2)); + update_values.push_back(columns[255] + " = " + std::to_string(items_entry.bardunk3)); + update_values.push_back(columns[256] + " = " + std::to_string(items_entry.bardunk4)); + update_values.push_back(columns[257] + " = " + std::to_string(items_entry.bardunk5)); + update_values.push_back(columns[258] + " = '" + EscapeString(items_entry.bardname) + "'"); + update_values.push_back(columns[259] + " = " + std::to_string(items_entry.bardunk7)); + update_values.push_back(columns[260] + " = " + std::to_string(items_entry.UNK214)); + update_values.push_back(columns[261] + " = " + std::to_string(items_entry.UNK219)); + update_values.push_back(columns[262] + " = " + std::to_string(items_entry.UNK220)); + update_values.push_back(columns[263] + " = " + std::to_string(items_entry.UNK221)); + update_values.push_back(columns[264] + " = " + std::to_string(items_entry.heirloom)); + update_values.push_back(columns[265] + " = " + std::to_string(items_entry.UNK223)); + update_values.push_back(columns[266] + " = " + std::to_string(items_entry.UNK224)); + update_values.push_back(columns[267] + " = " + std::to_string(items_entry.UNK225)); + update_values.push_back(columns[268] + " = " + std::to_string(items_entry.UNK226)); + update_values.push_back(columns[269] + " = " + std::to_string(items_entry.UNK227)); + update_values.push_back(columns[270] + " = " + std::to_string(items_entry.UNK228)); + update_values.push_back(columns[271] + " = " + std::to_string(items_entry.UNK229)); + update_values.push_back(columns[272] + " = " + std::to_string(items_entry.UNK230)); + update_values.push_back(columns[273] + " = " + std::to_string(items_entry.UNK231)); + update_values.push_back(columns[274] + " = " + std::to_string(items_entry.UNK232)); + update_values.push_back(columns[275] + " = " + std::to_string(items_entry.UNK233)); + update_values.push_back(columns[276] + " = " + std::to_string(items_entry.UNK234)); + update_values.push_back(columns[277] + " = " + std::to_string(items_entry.placeable)); + update_values.push_back(columns[278] + " = " + std::to_string(items_entry.UNK236)); + update_values.push_back(columns[279] + " = " + std::to_string(items_entry.UNK237)); + update_values.push_back(columns[280] + " = " + std::to_string(items_entry.UNK238)); + update_values.push_back(columns[281] + " = " + std::to_string(items_entry.UNK239)); + update_values.push_back(columns[282] + " = " + std::to_string(items_entry.UNK240)); + update_values.push_back(columns[283] + " = " + std::to_string(items_entry.UNK241)); + update_values.push_back(columns[284] + " = " + std::to_string(items_entry.epicitem)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + items_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Items InsertOne( + Items items_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(items_entry.minstatus)); + insert_values.push_back("'" + EscapeString(items_entry.Name) + "'"); + insert_values.push_back(std::to_string(items_entry.aagi)); + insert_values.push_back(std::to_string(items_entry.ac)); + insert_values.push_back(std::to_string(items_entry.accuracy)); + insert_values.push_back(std::to_string(items_entry.acha)); + insert_values.push_back(std::to_string(items_entry.adex)); + insert_values.push_back(std::to_string(items_entry.aint)); + insert_values.push_back(std::to_string(items_entry.artifactflag)); + insert_values.push_back(std::to_string(items_entry.asta)); + insert_values.push_back(std::to_string(items_entry.astr)); + insert_values.push_back(std::to_string(items_entry.attack)); + insert_values.push_back(std::to_string(items_entry.augrestrict)); + insert_values.push_back(std::to_string(items_entry.augslot1type)); + insert_values.push_back(std::to_string(items_entry.augslot1visible)); + insert_values.push_back(std::to_string(items_entry.augslot2type)); + insert_values.push_back(std::to_string(items_entry.augslot2visible)); + insert_values.push_back(std::to_string(items_entry.augslot3type)); + insert_values.push_back(std::to_string(items_entry.augslot3visible)); + insert_values.push_back(std::to_string(items_entry.augslot4type)); + insert_values.push_back(std::to_string(items_entry.augslot4visible)); + insert_values.push_back(std::to_string(items_entry.augslot5type)); + insert_values.push_back(std::to_string(items_entry.augslot5visible)); + insert_values.push_back(std::to_string(items_entry.augslot6type)); + insert_values.push_back(std::to_string(items_entry.augslot6visible)); + insert_values.push_back(std::to_string(items_entry.augtype)); + insert_values.push_back(std::to_string(items_entry.avoidance)); + insert_values.push_back(std::to_string(items_entry.awis)); + insert_values.push_back(std::to_string(items_entry.bagsize)); + insert_values.push_back(std::to_string(items_entry.bagslots)); + insert_values.push_back(std::to_string(items_entry.bagtype)); + insert_values.push_back(std::to_string(items_entry.bagwr)); + insert_values.push_back(std::to_string(items_entry.banedmgamt)); + insert_values.push_back(std::to_string(items_entry.banedmgraceamt)); + insert_values.push_back(std::to_string(items_entry.banedmgbody)); + insert_values.push_back(std::to_string(items_entry.banedmgrace)); + insert_values.push_back(std::to_string(items_entry.bardtype)); + insert_values.push_back(std::to_string(items_entry.bardvalue)); + insert_values.push_back(std::to_string(items_entry.book)); + insert_values.push_back(std::to_string(items_entry.casttime)); + insert_values.push_back(std::to_string(items_entry.casttime_)); + insert_values.push_back("'" + EscapeString(items_entry.charmfile) + "'"); + insert_values.push_back("'" + EscapeString(items_entry.charmfileid) + "'"); + insert_values.push_back(std::to_string(items_entry.classes)); + insert_values.push_back(std::to_string(items_entry.color)); + insert_values.push_back("'" + EscapeString(items_entry.combateffects) + "'"); + insert_values.push_back(std::to_string(items_entry.extradmgskill)); + insert_values.push_back(std::to_string(items_entry.extradmgamt)); + insert_values.push_back(std::to_string(items_entry.price)); + insert_values.push_back(std::to_string(items_entry.cr)); + insert_values.push_back(std::to_string(items_entry.damage)); + insert_values.push_back(std::to_string(items_entry.damageshield)); + insert_values.push_back(std::to_string(items_entry.deity)); + insert_values.push_back(std::to_string(items_entry.delay)); + insert_values.push_back(std::to_string(items_entry.augdistiller)); + insert_values.push_back(std::to_string(items_entry.dotshielding)); + insert_values.push_back(std::to_string(items_entry.dr)); + insert_values.push_back(std::to_string(items_entry.clicktype)); + insert_values.push_back(std::to_string(items_entry.clicklevel2)); + insert_values.push_back(std::to_string(items_entry.elemdmgtype)); + insert_values.push_back(std::to_string(items_entry.elemdmgamt)); + insert_values.push_back(std::to_string(items_entry.endur)); + insert_values.push_back(std::to_string(items_entry.factionamt1)); + insert_values.push_back(std::to_string(items_entry.factionamt2)); + insert_values.push_back(std::to_string(items_entry.factionamt3)); + insert_values.push_back(std::to_string(items_entry.factionamt4)); + insert_values.push_back(std::to_string(items_entry.factionmod1)); + insert_values.push_back(std::to_string(items_entry.factionmod2)); + insert_values.push_back(std::to_string(items_entry.factionmod3)); + insert_values.push_back(std::to_string(items_entry.factionmod4)); + insert_values.push_back("'" + EscapeString(items_entry.filename) + "'"); + insert_values.push_back(std::to_string(items_entry.focuseffect)); + insert_values.push_back(std::to_string(items_entry.fr)); + insert_values.push_back(std::to_string(items_entry.fvnodrop)); + insert_values.push_back(std::to_string(items_entry.haste)); + insert_values.push_back(std::to_string(items_entry.clicklevel)); + insert_values.push_back(std::to_string(items_entry.hp)); + insert_values.push_back(std::to_string(items_entry.regen)); + insert_values.push_back(std::to_string(items_entry.icon)); + insert_values.push_back("'" + EscapeString(items_entry.idfile) + "'"); + insert_values.push_back(std::to_string(items_entry.itemclass)); + insert_values.push_back(std::to_string(items_entry.itemtype)); + insert_values.push_back(std::to_string(items_entry.ldonprice)); + insert_values.push_back(std::to_string(items_entry.ldontheme)); + insert_values.push_back(std::to_string(items_entry.ldonsold)); + insert_values.push_back(std::to_string(items_entry.light)); + insert_values.push_back("'" + EscapeString(items_entry.lore) + "'"); + insert_values.push_back(std::to_string(items_entry.loregroup)); + insert_values.push_back(std::to_string(items_entry.magic)); + insert_values.push_back(std::to_string(items_entry.mana)); + insert_values.push_back(std::to_string(items_entry.manaregen)); + insert_values.push_back(std::to_string(items_entry.enduranceregen)); + insert_values.push_back(std::to_string(items_entry.material)); + insert_values.push_back(std::to_string(items_entry.herosforgemodel)); + insert_values.push_back(std::to_string(items_entry.maxcharges)); + insert_values.push_back(std::to_string(items_entry.mr)); + insert_values.push_back(std::to_string(items_entry.nodrop)); + insert_values.push_back(std::to_string(items_entry.norent)); + insert_values.push_back(std::to_string(items_entry.pendingloreflag)); + insert_values.push_back(std::to_string(items_entry.pr)); + insert_values.push_back(std::to_string(items_entry.procrate)); + insert_values.push_back(std::to_string(items_entry.races)); + insert_values.push_back(std::to_string(items_entry.range)); + insert_values.push_back(std::to_string(items_entry.reclevel)); + insert_values.push_back(std::to_string(items_entry.recskill)); + insert_values.push_back(std::to_string(items_entry.reqlevel)); + insert_values.push_back(std::to_string(items_entry.sellrate)); + insert_values.push_back(std::to_string(items_entry.shielding)); + insert_values.push_back(std::to_string(items_entry.size)); + insert_values.push_back(std::to_string(items_entry.skillmodtype)); + insert_values.push_back(std::to_string(items_entry.skillmodvalue)); + insert_values.push_back(std::to_string(items_entry.slots)); + insert_values.push_back(std::to_string(items_entry.clickeffect)); + insert_values.push_back(std::to_string(items_entry.spellshield)); + insert_values.push_back(std::to_string(items_entry.strikethrough)); + insert_values.push_back(std::to_string(items_entry.stunresist)); + insert_values.push_back(std::to_string(items_entry.summonedflag)); + insert_values.push_back(std::to_string(items_entry.tradeskills)); + insert_values.push_back(std::to_string(items_entry.favor)); + insert_values.push_back(std::to_string(items_entry.weight)); + insert_values.push_back(std::to_string(items_entry.UNK012)); + insert_values.push_back(std::to_string(items_entry.UNK013)); + insert_values.push_back(std::to_string(items_entry.benefitflag)); + insert_values.push_back(std::to_string(items_entry.UNK054)); + insert_values.push_back(std::to_string(items_entry.UNK059)); + insert_values.push_back(std::to_string(items_entry.booktype)); + insert_values.push_back(std::to_string(items_entry.recastdelay)); + insert_values.push_back(std::to_string(items_entry.recasttype)); + insert_values.push_back(std::to_string(items_entry.guildfavor)); + insert_values.push_back(std::to_string(items_entry.UNK123)); + insert_values.push_back(std::to_string(items_entry.UNK124)); + insert_values.push_back(std::to_string(items_entry.attuneable)); + insert_values.push_back(std::to_string(items_entry.nopet)); + insert_values.push_back("'" + EscapeString(items_entry.updated) + "'"); + insert_values.push_back("'" + EscapeString(items_entry.comment) + "'"); + insert_values.push_back(std::to_string(items_entry.UNK127)); + insert_values.push_back(std::to_string(items_entry.pointtype)); + insert_values.push_back(std::to_string(items_entry.potionbelt)); + insert_values.push_back(std::to_string(items_entry.potionbeltslots)); + insert_values.push_back(std::to_string(items_entry.stacksize)); + insert_values.push_back(std::to_string(items_entry.notransfer)); + insert_values.push_back(std::to_string(items_entry.stackable)); + insert_values.push_back("'" + EscapeString(items_entry.UNK134) + "'"); + insert_values.push_back(std::to_string(items_entry.UNK137)); + insert_values.push_back(std::to_string(items_entry.proceffect)); + insert_values.push_back(std::to_string(items_entry.proctype)); + insert_values.push_back(std::to_string(items_entry.proclevel2)); + insert_values.push_back(std::to_string(items_entry.proclevel)); + insert_values.push_back(std::to_string(items_entry.UNK142)); + insert_values.push_back(std::to_string(items_entry.worneffect)); + insert_values.push_back(std::to_string(items_entry.worntype)); + insert_values.push_back(std::to_string(items_entry.wornlevel2)); + insert_values.push_back(std::to_string(items_entry.wornlevel)); + insert_values.push_back(std::to_string(items_entry.UNK147)); + insert_values.push_back(std::to_string(items_entry.focustype)); + insert_values.push_back(std::to_string(items_entry.focuslevel2)); + insert_values.push_back(std::to_string(items_entry.focuslevel)); + insert_values.push_back(std::to_string(items_entry.UNK152)); + insert_values.push_back(std::to_string(items_entry.scrolleffect)); + insert_values.push_back(std::to_string(items_entry.scrolltype)); + insert_values.push_back(std::to_string(items_entry.scrolllevel2)); + insert_values.push_back(std::to_string(items_entry.scrolllevel)); + insert_values.push_back(std::to_string(items_entry.UNK157)); + insert_values.push_back("'" + EscapeString(items_entry.serialized) + "'"); + insert_values.push_back("'" + EscapeString(items_entry.verified) + "'"); + insert_values.push_back("'" + EscapeString(items_entry.serialization) + "'"); + insert_values.push_back("'" + EscapeString(items_entry.source) + "'"); + insert_values.push_back(std::to_string(items_entry.UNK033)); + insert_values.push_back("'" + EscapeString(items_entry.lorefile) + "'"); + insert_values.push_back(std::to_string(items_entry.UNK014)); + insert_values.push_back(std::to_string(items_entry.svcorruption)); + insert_values.push_back(std::to_string(items_entry.skillmodmax)); + insert_values.push_back(std::to_string(items_entry.UNK060)); + insert_values.push_back(std::to_string(items_entry.augslot1unk2)); + insert_values.push_back(std::to_string(items_entry.augslot2unk2)); + insert_values.push_back(std::to_string(items_entry.augslot3unk2)); + insert_values.push_back(std::to_string(items_entry.augslot4unk2)); + insert_values.push_back(std::to_string(items_entry.augslot5unk2)); + insert_values.push_back(std::to_string(items_entry.augslot6unk2)); + insert_values.push_back(std::to_string(items_entry.UNK120)); + insert_values.push_back(std::to_string(items_entry.UNK121)); + insert_values.push_back(std::to_string(items_entry.questitemflag)); + insert_values.push_back("'" + EscapeString(items_entry.UNK132) + "'"); + insert_values.push_back(std::to_string(items_entry.clickunk5)); + insert_values.push_back("'" + EscapeString(items_entry.clickunk6) + "'"); + insert_values.push_back(std::to_string(items_entry.clickunk7)); + insert_values.push_back(std::to_string(items_entry.procunk1)); + insert_values.push_back(std::to_string(items_entry.procunk2)); + insert_values.push_back(std::to_string(items_entry.procunk3)); + insert_values.push_back(std::to_string(items_entry.procunk4)); + insert_values.push_back("'" + EscapeString(items_entry.procunk6) + "'"); + insert_values.push_back(std::to_string(items_entry.procunk7)); + insert_values.push_back(std::to_string(items_entry.wornunk1)); + insert_values.push_back(std::to_string(items_entry.wornunk2)); + insert_values.push_back(std::to_string(items_entry.wornunk3)); + insert_values.push_back(std::to_string(items_entry.wornunk4)); + insert_values.push_back(std::to_string(items_entry.wornunk5)); + insert_values.push_back("'" + EscapeString(items_entry.wornunk6) + "'"); + insert_values.push_back(std::to_string(items_entry.wornunk7)); + insert_values.push_back(std::to_string(items_entry.focusunk1)); + insert_values.push_back(std::to_string(items_entry.focusunk2)); + insert_values.push_back(std::to_string(items_entry.focusunk3)); + insert_values.push_back(std::to_string(items_entry.focusunk4)); + insert_values.push_back(std::to_string(items_entry.focusunk5)); + insert_values.push_back("'" + EscapeString(items_entry.focusunk6) + "'"); + insert_values.push_back(std::to_string(items_entry.focusunk7)); + insert_values.push_back(std::to_string(items_entry.scrollunk1)); + insert_values.push_back(std::to_string(items_entry.scrollunk2)); + insert_values.push_back(std::to_string(items_entry.scrollunk3)); + insert_values.push_back(std::to_string(items_entry.scrollunk4)); + insert_values.push_back(std::to_string(items_entry.scrollunk5)); + insert_values.push_back("'" + EscapeString(items_entry.scrollunk6) + "'"); + insert_values.push_back(std::to_string(items_entry.scrollunk7)); + insert_values.push_back(std::to_string(items_entry.UNK193)); + insert_values.push_back(std::to_string(items_entry.purity)); + insert_values.push_back(std::to_string(items_entry.evoitem)); + insert_values.push_back(std::to_string(items_entry.evoid)); + insert_values.push_back(std::to_string(items_entry.evolvinglevel)); + insert_values.push_back(std::to_string(items_entry.evomax)); + insert_values.push_back("'" + EscapeString(items_entry.clickname) + "'"); + insert_values.push_back("'" + EscapeString(items_entry.procname) + "'"); + insert_values.push_back("'" + EscapeString(items_entry.wornname) + "'"); + insert_values.push_back("'" + EscapeString(items_entry.focusname) + "'"); + insert_values.push_back("'" + EscapeString(items_entry.scrollname) + "'"); + insert_values.push_back(std::to_string(items_entry.dsmitigation)); + insert_values.push_back(std::to_string(items_entry.heroic_str)); + insert_values.push_back(std::to_string(items_entry.heroic_int)); + insert_values.push_back(std::to_string(items_entry.heroic_wis)); + insert_values.push_back(std::to_string(items_entry.heroic_agi)); + insert_values.push_back(std::to_string(items_entry.heroic_dex)); + insert_values.push_back(std::to_string(items_entry.heroic_sta)); + insert_values.push_back(std::to_string(items_entry.heroic_cha)); + insert_values.push_back(std::to_string(items_entry.heroic_pr)); + insert_values.push_back(std::to_string(items_entry.heroic_dr)); + insert_values.push_back(std::to_string(items_entry.heroic_fr)); + insert_values.push_back(std::to_string(items_entry.heroic_cr)); + insert_values.push_back(std::to_string(items_entry.heroic_mr)); + insert_values.push_back(std::to_string(items_entry.heroic_svcorrup)); + insert_values.push_back(std::to_string(items_entry.healamt)); + insert_values.push_back(std::to_string(items_entry.spelldmg)); + insert_values.push_back(std::to_string(items_entry.clairvoyance)); + insert_values.push_back(std::to_string(items_entry.backstabdmg)); + insert_values.push_back("'" + EscapeString(items_entry.created) + "'"); + insert_values.push_back(std::to_string(items_entry.elitematerial)); + insert_values.push_back(std::to_string(items_entry.ldonsellbackrate)); + insert_values.push_back(std::to_string(items_entry.scriptfileid)); + insert_values.push_back(std::to_string(items_entry.expendablearrow)); + insert_values.push_back(std::to_string(items_entry.powersourcecapacity)); + insert_values.push_back(std::to_string(items_entry.bardeffect)); + insert_values.push_back(std::to_string(items_entry.bardeffecttype)); + insert_values.push_back(std::to_string(items_entry.bardlevel2)); + insert_values.push_back(std::to_string(items_entry.bardlevel)); + insert_values.push_back(std::to_string(items_entry.bardunk1)); + insert_values.push_back(std::to_string(items_entry.bardunk2)); + insert_values.push_back(std::to_string(items_entry.bardunk3)); + insert_values.push_back(std::to_string(items_entry.bardunk4)); + insert_values.push_back(std::to_string(items_entry.bardunk5)); + insert_values.push_back("'" + EscapeString(items_entry.bardname) + "'"); + insert_values.push_back(std::to_string(items_entry.bardunk7)); + insert_values.push_back(std::to_string(items_entry.UNK214)); + insert_values.push_back(std::to_string(items_entry.UNK219)); + insert_values.push_back(std::to_string(items_entry.UNK220)); + insert_values.push_back(std::to_string(items_entry.UNK221)); + insert_values.push_back(std::to_string(items_entry.heirloom)); + insert_values.push_back(std::to_string(items_entry.UNK223)); + insert_values.push_back(std::to_string(items_entry.UNK224)); + insert_values.push_back(std::to_string(items_entry.UNK225)); + insert_values.push_back(std::to_string(items_entry.UNK226)); + insert_values.push_back(std::to_string(items_entry.UNK227)); + insert_values.push_back(std::to_string(items_entry.UNK228)); + insert_values.push_back(std::to_string(items_entry.UNK229)); + insert_values.push_back(std::to_string(items_entry.UNK230)); + insert_values.push_back(std::to_string(items_entry.UNK231)); + insert_values.push_back(std::to_string(items_entry.UNK232)); + insert_values.push_back(std::to_string(items_entry.UNK233)); + insert_values.push_back(std::to_string(items_entry.UNK234)); + insert_values.push_back(std::to_string(items_entry.placeable)); + insert_values.push_back(std::to_string(items_entry.UNK236)); + insert_values.push_back(std::to_string(items_entry.UNK237)); + insert_values.push_back(std::to_string(items_entry.UNK238)); + insert_values.push_back(std::to_string(items_entry.UNK239)); + insert_values.push_back(std::to_string(items_entry.UNK240)); + insert_values.push_back(std::to_string(items_entry.UNK241)); + insert_values.push_back(std::to_string(items_entry.epicitem)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + items_entry.id = results.LastInsertedID(); + return items_entry; + } + + items_entry = NewEntity(); + + return items_entry; + } + + static int InsertMany( + std::vector items_entries + ) + { + std::vector insert_chunks; + + for (auto &items_entry: items_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(items_entry.minstatus)); + insert_values.push_back("'" + EscapeString(items_entry.Name) + "'"); + insert_values.push_back(std::to_string(items_entry.aagi)); + insert_values.push_back(std::to_string(items_entry.ac)); + insert_values.push_back(std::to_string(items_entry.accuracy)); + insert_values.push_back(std::to_string(items_entry.acha)); + insert_values.push_back(std::to_string(items_entry.adex)); + insert_values.push_back(std::to_string(items_entry.aint)); + insert_values.push_back(std::to_string(items_entry.artifactflag)); + insert_values.push_back(std::to_string(items_entry.asta)); + insert_values.push_back(std::to_string(items_entry.astr)); + insert_values.push_back(std::to_string(items_entry.attack)); + insert_values.push_back(std::to_string(items_entry.augrestrict)); + insert_values.push_back(std::to_string(items_entry.augslot1type)); + insert_values.push_back(std::to_string(items_entry.augslot1visible)); + insert_values.push_back(std::to_string(items_entry.augslot2type)); + insert_values.push_back(std::to_string(items_entry.augslot2visible)); + insert_values.push_back(std::to_string(items_entry.augslot3type)); + insert_values.push_back(std::to_string(items_entry.augslot3visible)); + insert_values.push_back(std::to_string(items_entry.augslot4type)); + insert_values.push_back(std::to_string(items_entry.augslot4visible)); + insert_values.push_back(std::to_string(items_entry.augslot5type)); + insert_values.push_back(std::to_string(items_entry.augslot5visible)); + insert_values.push_back(std::to_string(items_entry.augslot6type)); + insert_values.push_back(std::to_string(items_entry.augslot6visible)); + insert_values.push_back(std::to_string(items_entry.augtype)); + insert_values.push_back(std::to_string(items_entry.avoidance)); + insert_values.push_back(std::to_string(items_entry.awis)); + insert_values.push_back(std::to_string(items_entry.bagsize)); + insert_values.push_back(std::to_string(items_entry.bagslots)); + insert_values.push_back(std::to_string(items_entry.bagtype)); + insert_values.push_back(std::to_string(items_entry.bagwr)); + insert_values.push_back(std::to_string(items_entry.banedmgamt)); + insert_values.push_back(std::to_string(items_entry.banedmgraceamt)); + insert_values.push_back(std::to_string(items_entry.banedmgbody)); + insert_values.push_back(std::to_string(items_entry.banedmgrace)); + insert_values.push_back(std::to_string(items_entry.bardtype)); + insert_values.push_back(std::to_string(items_entry.bardvalue)); + insert_values.push_back(std::to_string(items_entry.book)); + insert_values.push_back(std::to_string(items_entry.casttime)); + insert_values.push_back(std::to_string(items_entry.casttime_)); + insert_values.push_back("'" + EscapeString(items_entry.charmfile) + "'"); + insert_values.push_back("'" + EscapeString(items_entry.charmfileid) + "'"); + insert_values.push_back(std::to_string(items_entry.classes)); + insert_values.push_back(std::to_string(items_entry.color)); + insert_values.push_back("'" + EscapeString(items_entry.combateffects) + "'"); + insert_values.push_back(std::to_string(items_entry.extradmgskill)); + insert_values.push_back(std::to_string(items_entry.extradmgamt)); + insert_values.push_back(std::to_string(items_entry.price)); + insert_values.push_back(std::to_string(items_entry.cr)); + insert_values.push_back(std::to_string(items_entry.damage)); + insert_values.push_back(std::to_string(items_entry.damageshield)); + insert_values.push_back(std::to_string(items_entry.deity)); + insert_values.push_back(std::to_string(items_entry.delay)); + insert_values.push_back(std::to_string(items_entry.augdistiller)); + insert_values.push_back(std::to_string(items_entry.dotshielding)); + insert_values.push_back(std::to_string(items_entry.dr)); + insert_values.push_back(std::to_string(items_entry.clicktype)); + insert_values.push_back(std::to_string(items_entry.clicklevel2)); + insert_values.push_back(std::to_string(items_entry.elemdmgtype)); + insert_values.push_back(std::to_string(items_entry.elemdmgamt)); + insert_values.push_back(std::to_string(items_entry.endur)); + insert_values.push_back(std::to_string(items_entry.factionamt1)); + insert_values.push_back(std::to_string(items_entry.factionamt2)); + insert_values.push_back(std::to_string(items_entry.factionamt3)); + insert_values.push_back(std::to_string(items_entry.factionamt4)); + insert_values.push_back(std::to_string(items_entry.factionmod1)); + insert_values.push_back(std::to_string(items_entry.factionmod2)); + insert_values.push_back(std::to_string(items_entry.factionmod3)); + insert_values.push_back(std::to_string(items_entry.factionmod4)); + insert_values.push_back("'" + EscapeString(items_entry.filename) + "'"); + insert_values.push_back(std::to_string(items_entry.focuseffect)); + insert_values.push_back(std::to_string(items_entry.fr)); + insert_values.push_back(std::to_string(items_entry.fvnodrop)); + insert_values.push_back(std::to_string(items_entry.haste)); + insert_values.push_back(std::to_string(items_entry.clicklevel)); + insert_values.push_back(std::to_string(items_entry.hp)); + insert_values.push_back(std::to_string(items_entry.regen)); + insert_values.push_back(std::to_string(items_entry.icon)); + insert_values.push_back("'" + EscapeString(items_entry.idfile) + "'"); + insert_values.push_back(std::to_string(items_entry.itemclass)); + insert_values.push_back(std::to_string(items_entry.itemtype)); + insert_values.push_back(std::to_string(items_entry.ldonprice)); + insert_values.push_back(std::to_string(items_entry.ldontheme)); + insert_values.push_back(std::to_string(items_entry.ldonsold)); + insert_values.push_back(std::to_string(items_entry.light)); + insert_values.push_back("'" + EscapeString(items_entry.lore) + "'"); + insert_values.push_back(std::to_string(items_entry.loregroup)); + insert_values.push_back(std::to_string(items_entry.magic)); + insert_values.push_back(std::to_string(items_entry.mana)); + insert_values.push_back(std::to_string(items_entry.manaregen)); + insert_values.push_back(std::to_string(items_entry.enduranceregen)); + insert_values.push_back(std::to_string(items_entry.material)); + insert_values.push_back(std::to_string(items_entry.herosforgemodel)); + insert_values.push_back(std::to_string(items_entry.maxcharges)); + insert_values.push_back(std::to_string(items_entry.mr)); + insert_values.push_back(std::to_string(items_entry.nodrop)); + insert_values.push_back(std::to_string(items_entry.norent)); + insert_values.push_back(std::to_string(items_entry.pendingloreflag)); + insert_values.push_back(std::to_string(items_entry.pr)); + insert_values.push_back(std::to_string(items_entry.procrate)); + insert_values.push_back(std::to_string(items_entry.races)); + insert_values.push_back(std::to_string(items_entry.range)); + insert_values.push_back(std::to_string(items_entry.reclevel)); + insert_values.push_back(std::to_string(items_entry.recskill)); + insert_values.push_back(std::to_string(items_entry.reqlevel)); + insert_values.push_back(std::to_string(items_entry.sellrate)); + insert_values.push_back(std::to_string(items_entry.shielding)); + insert_values.push_back(std::to_string(items_entry.size)); + insert_values.push_back(std::to_string(items_entry.skillmodtype)); + insert_values.push_back(std::to_string(items_entry.skillmodvalue)); + insert_values.push_back(std::to_string(items_entry.slots)); + insert_values.push_back(std::to_string(items_entry.clickeffect)); + insert_values.push_back(std::to_string(items_entry.spellshield)); + insert_values.push_back(std::to_string(items_entry.strikethrough)); + insert_values.push_back(std::to_string(items_entry.stunresist)); + insert_values.push_back(std::to_string(items_entry.summonedflag)); + insert_values.push_back(std::to_string(items_entry.tradeskills)); + insert_values.push_back(std::to_string(items_entry.favor)); + insert_values.push_back(std::to_string(items_entry.weight)); + insert_values.push_back(std::to_string(items_entry.UNK012)); + insert_values.push_back(std::to_string(items_entry.UNK013)); + insert_values.push_back(std::to_string(items_entry.benefitflag)); + insert_values.push_back(std::to_string(items_entry.UNK054)); + insert_values.push_back(std::to_string(items_entry.UNK059)); + insert_values.push_back(std::to_string(items_entry.booktype)); + insert_values.push_back(std::to_string(items_entry.recastdelay)); + insert_values.push_back(std::to_string(items_entry.recasttype)); + insert_values.push_back(std::to_string(items_entry.guildfavor)); + insert_values.push_back(std::to_string(items_entry.UNK123)); + insert_values.push_back(std::to_string(items_entry.UNK124)); + insert_values.push_back(std::to_string(items_entry.attuneable)); + insert_values.push_back(std::to_string(items_entry.nopet)); + insert_values.push_back("'" + EscapeString(items_entry.updated) + "'"); + insert_values.push_back("'" + EscapeString(items_entry.comment) + "'"); + insert_values.push_back(std::to_string(items_entry.UNK127)); + insert_values.push_back(std::to_string(items_entry.pointtype)); + insert_values.push_back(std::to_string(items_entry.potionbelt)); + insert_values.push_back(std::to_string(items_entry.potionbeltslots)); + insert_values.push_back(std::to_string(items_entry.stacksize)); + insert_values.push_back(std::to_string(items_entry.notransfer)); + insert_values.push_back(std::to_string(items_entry.stackable)); + insert_values.push_back("'" + EscapeString(items_entry.UNK134) + "'"); + insert_values.push_back(std::to_string(items_entry.UNK137)); + insert_values.push_back(std::to_string(items_entry.proceffect)); + insert_values.push_back(std::to_string(items_entry.proctype)); + insert_values.push_back(std::to_string(items_entry.proclevel2)); + insert_values.push_back(std::to_string(items_entry.proclevel)); + insert_values.push_back(std::to_string(items_entry.UNK142)); + insert_values.push_back(std::to_string(items_entry.worneffect)); + insert_values.push_back(std::to_string(items_entry.worntype)); + insert_values.push_back(std::to_string(items_entry.wornlevel2)); + insert_values.push_back(std::to_string(items_entry.wornlevel)); + insert_values.push_back(std::to_string(items_entry.UNK147)); + insert_values.push_back(std::to_string(items_entry.focustype)); + insert_values.push_back(std::to_string(items_entry.focuslevel2)); + insert_values.push_back(std::to_string(items_entry.focuslevel)); + insert_values.push_back(std::to_string(items_entry.UNK152)); + insert_values.push_back(std::to_string(items_entry.scrolleffect)); + insert_values.push_back(std::to_string(items_entry.scrolltype)); + insert_values.push_back(std::to_string(items_entry.scrolllevel2)); + insert_values.push_back(std::to_string(items_entry.scrolllevel)); + insert_values.push_back(std::to_string(items_entry.UNK157)); + insert_values.push_back("'" + EscapeString(items_entry.serialized) + "'"); + insert_values.push_back("'" + EscapeString(items_entry.verified) + "'"); + insert_values.push_back("'" + EscapeString(items_entry.serialization) + "'"); + insert_values.push_back("'" + EscapeString(items_entry.source) + "'"); + insert_values.push_back(std::to_string(items_entry.UNK033)); + insert_values.push_back("'" + EscapeString(items_entry.lorefile) + "'"); + insert_values.push_back(std::to_string(items_entry.UNK014)); + insert_values.push_back(std::to_string(items_entry.svcorruption)); + insert_values.push_back(std::to_string(items_entry.skillmodmax)); + insert_values.push_back(std::to_string(items_entry.UNK060)); + insert_values.push_back(std::to_string(items_entry.augslot1unk2)); + insert_values.push_back(std::to_string(items_entry.augslot2unk2)); + insert_values.push_back(std::to_string(items_entry.augslot3unk2)); + insert_values.push_back(std::to_string(items_entry.augslot4unk2)); + insert_values.push_back(std::to_string(items_entry.augslot5unk2)); + insert_values.push_back(std::to_string(items_entry.augslot6unk2)); + insert_values.push_back(std::to_string(items_entry.UNK120)); + insert_values.push_back(std::to_string(items_entry.UNK121)); + insert_values.push_back(std::to_string(items_entry.questitemflag)); + insert_values.push_back("'" + EscapeString(items_entry.UNK132) + "'"); + insert_values.push_back(std::to_string(items_entry.clickunk5)); + insert_values.push_back("'" + EscapeString(items_entry.clickunk6) + "'"); + insert_values.push_back(std::to_string(items_entry.clickunk7)); + insert_values.push_back(std::to_string(items_entry.procunk1)); + insert_values.push_back(std::to_string(items_entry.procunk2)); + insert_values.push_back(std::to_string(items_entry.procunk3)); + insert_values.push_back(std::to_string(items_entry.procunk4)); + insert_values.push_back("'" + EscapeString(items_entry.procunk6) + "'"); + insert_values.push_back(std::to_string(items_entry.procunk7)); + insert_values.push_back(std::to_string(items_entry.wornunk1)); + insert_values.push_back(std::to_string(items_entry.wornunk2)); + insert_values.push_back(std::to_string(items_entry.wornunk3)); + insert_values.push_back(std::to_string(items_entry.wornunk4)); + insert_values.push_back(std::to_string(items_entry.wornunk5)); + insert_values.push_back("'" + EscapeString(items_entry.wornunk6) + "'"); + insert_values.push_back(std::to_string(items_entry.wornunk7)); + insert_values.push_back(std::to_string(items_entry.focusunk1)); + insert_values.push_back(std::to_string(items_entry.focusunk2)); + insert_values.push_back(std::to_string(items_entry.focusunk3)); + insert_values.push_back(std::to_string(items_entry.focusunk4)); + insert_values.push_back(std::to_string(items_entry.focusunk5)); + insert_values.push_back("'" + EscapeString(items_entry.focusunk6) + "'"); + insert_values.push_back(std::to_string(items_entry.focusunk7)); + insert_values.push_back(std::to_string(items_entry.scrollunk1)); + insert_values.push_back(std::to_string(items_entry.scrollunk2)); + insert_values.push_back(std::to_string(items_entry.scrollunk3)); + insert_values.push_back(std::to_string(items_entry.scrollunk4)); + insert_values.push_back(std::to_string(items_entry.scrollunk5)); + insert_values.push_back("'" + EscapeString(items_entry.scrollunk6) + "'"); + insert_values.push_back(std::to_string(items_entry.scrollunk7)); + insert_values.push_back(std::to_string(items_entry.UNK193)); + insert_values.push_back(std::to_string(items_entry.purity)); + insert_values.push_back(std::to_string(items_entry.evoitem)); + insert_values.push_back(std::to_string(items_entry.evoid)); + insert_values.push_back(std::to_string(items_entry.evolvinglevel)); + insert_values.push_back(std::to_string(items_entry.evomax)); + insert_values.push_back("'" + EscapeString(items_entry.clickname) + "'"); + insert_values.push_back("'" + EscapeString(items_entry.procname) + "'"); + insert_values.push_back("'" + EscapeString(items_entry.wornname) + "'"); + insert_values.push_back("'" + EscapeString(items_entry.focusname) + "'"); + insert_values.push_back("'" + EscapeString(items_entry.scrollname) + "'"); + insert_values.push_back(std::to_string(items_entry.dsmitigation)); + insert_values.push_back(std::to_string(items_entry.heroic_str)); + insert_values.push_back(std::to_string(items_entry.heroic_int)); + insert_values.push_back(std::to_string(items_entry.heroic_wis)); + insert_values.push_back(std::to_string(items_entry.heroic_agi)); + insert_values.push_back(std::to_string(items_entry.heroic_dex)); + insert_values.push_back(std::to_string(items_entry.heroic_sta)); + insert_values.push_back(std::to_string(items_entry.heroic_cha)); + insert_values.push_back(std::to_string(items_entry.heroic_pr)); + insert_values.push_back(std::to_string(items_entry.heroic_dr)); + insert_values.push_back(std::to_string(items_entry.heroic_fr)); + insert_values.push_back(std::to_string(items_entry.heroic_cr)); + insert_values.push_back(std::to_string(items_entry.heroic_mr)); + insert_values.push_back(std::to_string(items_entry.heroic_svcorrup)); + insert_values.push_back(std::to_string(items_entry.healamt)); + insert_values.push_back(std::to_string(items_entry.spelldmg)); + insert_values.push_back(std::to_string(items_entry.clairvoyance)); + insert_values.push_back(std::to_string(items_entry.backstabdmg)); + insert_values.push_back("'" + EscapeString(items_entry.created) + "'"); + insert_values.push_back(std::to_string(items_entry.elitematerial)); + insert_values.push_back(std::to_string(items_entry.ldonsellbackrate)); + insert_values.push_back(std::to_string(items_entry.scriptfileid)); + insert_values.push_back(std::to_string(items_entry.expendablearrow)); + insert_values.push_back(std::to_string(items_entry.powersourcecapacity)); + insert_values.push_back(std::to_string(items_entry.bardeffect)); + insert_values.push_back(std::to_string(items_entry.bardeffecttype)); + insert_values.push_back(std::to_string(items_entry.bardlevel2)); + insert_values.push_back(std::to_string(items_entry.bardlevel)); + insert_values.push_back(std::to_string(items_entry.bardunk1)); + insert_values.push_back(std::to_string(items_entry.bardunk2)); + insert_values.push_back(std::to_string(items_entry.bardunk3)); + insert_values.push_back(std::to_string(items_entry.bardunk4)); + insert_values.push_back(std::to_string(items_entry.bardunk5)); + insert_values.push_back("'" + EscapeString(items_entry.bardname) + "'"); + insert_values.push_back(std::to_string(items_entry.bardunk7)); + insert_values.push_back(std::to_string(items_entry.UNK214)); + insert_values.push_back(std::to_string(items_entry.UNK219)); + insert_values.push_back(std::to_string(items_entry.UNK220)); + insert_values.push_back(std::to_string(items_entry.UNK221)); + insert_values.push_back(std::to_string(items_entry.heirloom)); + insert_values.push_back(std::to_string(items_entry.UNK223)); + insert_values.push_back(std::to_string(items_entry.UNK224)); + insert_values.push_back(std::to_string(items_entry.UNK225)); + insert_values.push_back(std::to_string(items_entry.UNK226)); + insert_values.push_back(std::to_string(items_entry.UNK227)); + insert_values.push_back(std::to_string(items_entry.UNK228)); + insert_values.push_back(std::to_string(items_entry.UNK229)); + insert_values.push_back(std::to_string(items_entry.UNK230)); + insert_values.push_back(std::to_string(items_entry.UNK231)); + insert_values.push_back(std::to_string(items_entry.UNK232)); + insert_values.push_back(std::to_string(items_entry.UNK233)); + insert_values.push_back(std::to_string(items_entry.UNK234)); + insert_values.push_back(std::to_string(items_entry.placeable)); + insert_values.push_back(std::to_string(items_entry.UNK236)); + insert_values.push_back(std::to_string(items_entry.UNK237)); + insert_values.push_back(std::to_string(items_entry.UNK238)); + insert_values.push_back(std::to_string(items_entry.UNK239)); + insert_values.push_back(std::to_string(items_entry.UNK240)); + insert_values.push_back(std::to_string(items_entry.UNK241)); + insert_values.push_back(std::to_string(items_entry.epicitem)); + + 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) { + Items entry{}; + + entry.id = atoi(row[0]); + entry.minstatus = atoi(row[1]); + entry.Name = row[2] ? row[2] : ""; + entry.aagi = atoi(row[3]); + entry.ac = atoi(row[4]); + entry.accuracy = atoi(row[5]); + entry.acha = atoi(row[6]); + entry.adex = atoi(row[7]); + entry.aint = atoi(row[8]); + entry.artifactflag = atoi(row[9]); + entry.asta = atoi(row[10]); + entry.astr = atoi(row[11]); + entry.attack = atoi(row[12]); + entry.augrestrict = atoi(row[13]); + entry.augslot1type = atoi(row[14]); + entry.augslot1visible = atoi(row[15]); + entry.augslot2type = atoi(row[16]); + entry.augslot2visible = atoi(row[17]); + entry.augslot3type = atoi(row[18]); + entry.augslot3visible = atoi(row[19]); + entry.augslot4type = atoi(row[20]); + entry.augslot4visible = atoi(row[21]); + entry.augslot5type = atoi(row[22]); + entry.augslot5visible = atoi(row[23]); + entry.augslot6type = atoi(row[24]); + entry.augslot6visible = atoi(row[25]); + entry.augtype = atoi(row[26]); + entry.avoidance = atoi(row[27]); + entry.awis = atoi(row[28]); + entry.bagsize = atoi(row[29]); + entry.bagslots = atoi(row[30]); + entry.bagtype = atoi(row[31]); + entry.bagwr = atoi(row[32]); + entry.banedmgamt = atoi(row[33]); + entry.banedmgraceamt = atoi(row[34]); + entry.banedmgbody = atoi(row[35]); + entry.banedmgrace = atoi(row[36]); + entry.bardtype = atoi(row[37]); + entry.bardvalue = atoi(row[38]); + entry.book = atoi(row[39]); + entry.casttime = atoi(row[40]); + entry.casttime_ = atoi(row[41]); + entry.charmfile = row[42] ? row[42] : ""; + entry.charmfileid = row[43] ? row[43] : ""; + entry.classes = atoi(row[44]); + entry.color = atoi(row[45]); + entry.combateffects = row[46] ? row[46] : ""; + entry.extradmgskill = atoi(row[47]); + entry.extradmgamt = atoi(row[48]); + entry.price = atoi(row[49]); + entry.cr = atoi(row[50]); + entry.damage = atoi(row[51]); + entry.damageshield = atoi(row[52]); + entry.deity = atoi(row[53]); + entry.delay = atoi(row[54]); + entry.augdistiller = atoi(row[55]); + entry.dotshielding = atoi(row[56]); + entry.dr = atoi(row[57]); + entry.clicktype = atoi(row[58]); + entry.clicklevel2 = atoi(row[59]); + entry.elemdmgtype = atoi(row[60]); + entry.elemdmgamt = atoi(row[61]); + entry.endur = atoi(row[62]); + entry.factionamt1 = atoi(row[63]); + entry.factionamt2 = atoi(row[64]); + entry.factionamt3 = atoi(row[65]); + entry.factionamt4 = atoi(row[66]); + entry.factionmod1 = atoi(row[67]); + entry.factionmod2 = atoi(row[68]); + entry.factionmod3 = atoi(row[69]); + entry.factionmod4 = atoi(row[70]); + entry.filename = row[71] ? row[71] : ""; + entry.focuseffect = atoi(row[72]); + entry.fr = atoi(row[73]); + entry.fvnodrop = atoi(row[74]); + entry.haste = atoi(row[75]); + entry.clicklevel = atoi(row[76]); + entry.hp = atoi(row[77]); + entry.regen = atoi(row[78]); + entry.icon = atoi(row[79]); + entry.idfile = row[80] ? row[80] : ""; + entry.itemclass = atoi(row[81]); + entry.itemtype = atoi(row[82]); + entry.ldonprice = atoi(row[83]); + entry.ldontheme = atoi(row[84]); + entry.ldonsold = atoi(row[85]); + entry.light = atoi(row[86]); + entry.lore = row[87] ? row[87] : ""; + entry.loregroup = atoi(row[88]); + entry.magic = atoi(row[89]); + entry.mana = atoi(row[90]); + entry.manaregen = atoi(row[91]); + entry.enduranceregen = atoi(row[92]); + entry.material = atoi(row[93]); + entry.herosforgemodel = atoi(row[94]); + entry.maxcharges = atoi(row[95]); + entry.mr = atoi(row[96]); + entry.nodrop = atoi(row[97]); + entry.norent = atoi(row[98]); + entry.pendingloreflag = atoi(row[99]); + entry.pr = atoi(row[100]); + entry.procrate = atoi(row[101]); + entry.races = atoi(row[102]); + entry.range = atoi(row[103]); + entry.reclevel = atoi(row[104]); + entry.recskill = atoi(row[105]); + entry.reqlevel = atoi(row[106]); + entry.sellrate = atof(row[107]); + entry.shielding = atoi(row[108]); + entry.size = atoi(row[109]); + entry.skillmodtype = atoi(row[110]); + entry.skillmodvalue = atoi(row[111]); + entry.slots = atoi(row[112]); + entry.clickeffect = atoi(row[113]); + entry.spellshield = atoi(row[114]); + entry.strikethrough = atoi(row[115]); + entry.stunresist = atoi(row[116]); + entry.summonedflag = atoi(row[117]); + entry.tradeskills = atoi(row[118]); + entry.favor = atoi(row[119]); + entry.weight = atoi(row[120]); + entry.UNK012 = atoi(row[121]); + entry.UNK013 = atoi(row[122]); + entry.benefitflag = atoi(row[123]); + entry.UNK054 = atoi(row[124]); + entry.UNK059 = atoi(row[125]); + entry.booktype = atoi(row[126]); + entry.recastdelay = atoi(row[127]); + entry.recasttype = atoi(row[128]); + entry.guildfavor = atoi(row[129]); + entry.UNK123 = atoi(row[130]); + entry.UNK124 = atoi(row[131]); + entry.attuneable = atoi(row[132]); + entry.nopet = atoi(row[133]); + entry.updated = row[134] ? row[134] : ""; + entry.comment = row[135] ? row[135] : ""; + entry.UNK127 = atoi(row[136]); + entry.pointtype = atoi(row[137]); + entry.potionbelt = atoi(row[138]); + entry.potionbeltslots = atoi(row[139]); + entry.stacksize = atoi(row[140]); + entry.notransfer = atoi(row[141]); + entry.stackable = atoi(row[142]); + entry.UNK134 = row[143] ? row[143] : ""; + entry.UNK137 = atoi(row[144]); + entry.proceffect = atoi(row[145]); + entry.proctype = atoi(row[146]); + entry.proclevel2 = atoi(row[147]); + entry.proclevel = atoi(row[148]); + entry.UNK142 = atoi(row[149]); + entry.worneffect = atoi(row[150]); + entry.worntype = atoi(row[151]); + entry.wornlevel2 = atoi(row[152]); + entry.wornlevel = atoi(row[153]); + entry.UNK147 = atoi(row[154]); + entry.focustype = atoi(row[155]); + entry.focuslevel2 = atoi(row[156]); + entry.focuslevel = atoi(row[157]); + entry.UNK152 = atoi(row[158]); + entry.scrolleffect = atoi(row[159]); + entry.scrolltype = atoi(row[160]); + entry.scrolllevel2 = atoi(row[161]); + entry.scrolllevel = atoi(row[162]); + entry.UNK157 = atoi(row[163]); + entry.serialized = row[164] ? row[164] : ""; + entry.verified = row[165] ? row[165] : ""; + entry.serialization = row[166] ? row[166] : ""; + entry.source = row[167] ? row[167] : ""; + entry.UNK033 = atoi(row[168]); + entry.lorefile = row[169] ? row[169] : ""; + entry.UNK014 = atoi(row[170]); + entry.svcorruption = atoi(row[171]); + entry.skillmodmax = atoi(row[172]); + entry.UNK060 = atoi(row[173]); + entry.augslot1unk2 = atoi(row[174]); + entry.augslot2unk2 = atoi(row[175]); + entry.augslot3unk2 = atoi(row[176]); + entry.augslot4unk2 = atoi(row[177]); + entry.augslot5unk2 = atoi(row[178]); + entry.augslot6unk2 = atoi(row[179]); + entry.UNK120 = atoi(row[180]); + entry.UNK121 = atoi(row[181]); + entry.questitemflag = atoi(row[182]); + entry.UNK132 = row[183] ? row[183] : ""; + entry.clickunk5 = atoi(row[184]); + entry.clickunk6 = row[185] ? row[185] : ""; + entry.clickunk7 = atoi(row[186]); + entry.procunk1 = atoi(row[187]); + entry.procunk2 = atoi(row[188]); + entry.procunk3 = atoi(row[189]); + entry.procunk4 = atoi(row[190]); + entry.procunk6 = row[191] ? row[191] : ""; + entry.procunk7 = atoi(row[192]); + entry.wornunk1 = atoi(row[193]); + entry.wornunk2 = atoi(row[194]); + entry.wornunk3 = atoi(row[195]); + entry.wornunk4 = atoi(row[196]); + entry.wornunk5 = atoi(row[197]); + entry.wornunk6 = row[198] ? row[198] : ""; + entry.wornunk7 = atoi(row[199]); + entry.focusunk1 = atoi(row[200]); + entry.focusunk2 = atoi(row[201]); + entry.focusunk3 = atoi(row[202]); + entry.focusunk4 = atoi(row[203]); + entry.focusunk5 = atoi(row[204]); + entry.focusunk6 = row[205] ? row[205] : ""; + entry.focusunk7 = atoi(row[206]); + entry.scrollunk1 = atoi(row[207]); + entry.scrollunk2 = atoi(row[208]); + entry.scrollunk3 = atoi(row[209]); + entry.scrollunk4 = atoi(row[210]); + entry.scrollunk5 = atoi(row[211]); + entry.scrollunk6 = row[212] ? row[212] : ""; + entry.scrollunk7 = atoi(row[213]); + entry.UNK193 = atoi(row[214]); + entry.purity = atoi(row[215]); + entry.evoitem = atoi(row[216]); + entry.evoid = atoi(row[217]); + entry.evolvinglevel = atoi(row[218]); + entry.evomax = atoi(row[219]); + entry.clickname = row[220] ? row[220] : ""; + entry.procname = row[221] ? row[221] : ""; + entry.wornname = row[222] ? row[222] : ""; + entry.focusname = row[223] ? row[223] : ""; + entry.scrollname = row[224] ? row[224] : ""; + entry.dsmitigation = atoi(row[225]); + entry.heroic_str = atoi(row[226]); + entry.heroic_int = atoi(row[227]); + entry.heroic_wis = atoi(row[228]); + entry.heroic_agi = atoi(row[229]); + entry.heroic_dex = atoi(row[230]); + entry.heroic_sta = atoi(row[231]); + entry.heroic_cha = atoi(row[232]); + entry.heroic_pr = atoi(row[233]); + entry.heroic_dr = atoi(row[234]); + entry.heroic_fr = atoi(row[235]); + entry.heroic_cr = atoi(row[236]); + entry.heroic_mr = atoi(row[237]); + entry.heroic_svcorrup = atoi(row[238]); + entry.healamt = atoi(row[239]); + entry.spelldmg = atoi(row[240]); + entry.clairvoyance = atoi(row[241]); + entry.backstabdmg = atoi(row[242]); + entry.created = row[243] ? row[243] : ""; + entry.elitematerial = atoi(row[244]); + entry.ldonsellbackrate = atoi(row[245]); + entry.scriptfileid = atoi(row[246]); + entry.expendablearrow = atoi(row[247]); + entry.powersourcecapacity = atoi(row[248]); + entry.bardeffect = atoi(row[249]); + entry.bardeffecttype = atoi(row[250]); + entry.bardlevel2 = atoi(row[251]); + entry.bardlevel = atoi(row[252]); + entry.bardunk1 = atoi(row[253]); + entry.bardunk2 = atoi(row[254]); + entry.bardunk3 = atoi(row[255]); + entry.bardunk4 = atoi(row[256]); + entry.bardunk5 = atoi(row[257]); + entry.bardname = row[258] ? row[258] : ""; + entry.bardunk7 = atoi(row[259]); + entry.UNK214 = atoi(row[260]); + entry.UNK219 = atoi(row[261]); + entry.UNK220 = atoi(row[262]); + entry.UNK221 = atoi(row[263]); + entry.heirloom = atoi(row[264]); + entry.UNK223 = atoi(row[265]); + entry.UNK224 = atoi(row[266]); + entry.UNK225 = atoi(row[267]); + entry.UNK226 = atoi(row[268]); + entry.UNK227 = atoi(row[269]); + entry.UNK228 = atoi(row[270]); + entry.UNK229 = atoi(row[271]); + entry.UNK230 = atoi(row[272]); + entry.UNK231 = atoi(row[273]); + entry.UNK232 = atoi(row[274]); + entry.UNK233 = atoi(row[275]); + entry.UNK234 = atoi(row[276]); + entry.placeable = atoi(row[277]); + entry.UNK236 = atoi(row[278]); + entry.UNK237 = atoi(row[279]); + entry.UNK238 = atoi(row[280]); + entry.UNK239 = atoi(row[281]); + entry.UNK240 = atoi(row[282]); + entry.UNK241 = atoi(row[283]); + entry.epicitem = atoi(row[284]); + + 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) { + Items entry{}; + + entry.id = atoi(row[0]); + entry.minstatus = atoi(row[1]); + entry.Name = row[2] ? row[2] : ""; + entry.aagi = atoi(row[3]); + entry.ac = atoi(row[4]); + entry.accuracy = atoi(row[5]); + entry.acha = atoi(row[6]); + entry.adex = atoi(row[7]); + entry.aint = atoi(row[8]); + entry.artifactflag = atoi(row[9]); + entry.asta = atoi(row[10]); + entry.astr = atoi(row[11]); + entry.attack = atoi(row[12]); + entry.augrestrict = atoi(row[13]); + entry.augslot1type = atoi(row[14]); + entry.augslot1visible = atoi(row[15]); + entry.augslot2type = atoi(row[16]); + entry.augslot2visible = atoi(row[17]); + entry.augslot3type = atoi(row[18]); + entry.augslot3visible = atoi(row[19]); + entry.augslot4type = atoi(row[20]); + entry.augslot4visible = atoi(row[21]); + entry.augslot5type = atoi(row[22]); + entry.augslot5visible = atoi(row[23]); + entry.augslot6type = atoi(row[24]); + entry.augslot6visible = atoi(row[25]); + entry.augtype = atoi(row[26]); + entry.avoidance = atoi(row[27]); + entry.awis = atoi(row[28]); + entry.bagsize = atoi(row[29]); + entry.bagslots = atoi(row[30]); + entry.bagtype = atoi(row[31]); + entry.bagwr = atoi(row[32]); + entry.banedmgamt = atoi(row[33]); + entry.banedmgraceamt = atoi(row[34]); + entry.banedmgbody = atoi(row[35]); + entry.banedmgrace = atoi(row[36]); + entry.bardtype = atoi(row[37]); + entry.bardvalue = atoi(row[38]); + entry.book = atoi(row[39]); + entry.casttime = atoi(row[40]); + entry.casttime_ = atoi(row[41]); + entry.charmfile = row[42] ? row[42] : ""; + entry.charmfileid = row[43] ? row[43] : ""; + entry.classes = atoi(row[44]); + entry.color = atoi(row[45]); + entry.combateffects = row[46] ? row[46] : ""; + entry.extradmgskill = atoi(row[47]); + entry.extradmgamt = atoi(row[48]); + entry.price = atoi(row[49]); + entry.cr = atoi(row[50]); + entry.damage = atoi(row[51]); + entry.damageshield = atoi(row[52]); + entry.deity = atoi(row[53]); + entry.delay = atoi(row[54]); + entry.augdistiller = atoi(row[55]); + entry.dotshielding = atoi(row[56]); + entry.dr = atoi(row[57]); + entry.clicktype = atoi(row[58]); + entry.clicklevel2 = atoi(row[59]); + entry.elemdmgtype = atoi(row[60]); + entry.elemdmgamt = atoi(row[61]); + entry.endur = atoi(row[62]); + entry.factionamt1 = atoi(row[63]); + entry.factionamt2 = atoi(row[64]); + entry.factionamt3 = atoi(row[65]); + entry.factionamt4 = atoi(row[66]); + entry.factionmod1 = atoi(row[67]); + entry.factionmod2 = atoi(row[68]); + entry.factionmod3 = atoi(row[69]); + entry.factionmod4 = atoi(row[70]); + entry.filename = row[71] ? row[71] : ""; + entry.focuseffect = atoi(row[72]); + entry.fr = atoi(row[73]); + entry.fvnodrop = atoi(row[74]); + entry.haste = atoi(row[75]); + entry.clicklevel = atoi(row[76]); + entry.hp = atoi(row[77]); + entry.regen = atoi(row[78]); + entry.icon = atoi(row[79]); + entry.idfile = row[80] ? row[80] : ""; + entry.itemclass = atoi(row[81]); + entry.itemtype = atoi(row[82]); + entry.ldonprice = atoi(row[83]); + entry.ldontheme = atoi(row[84]); + entry.ldonsold = atoi(row[85]); + entry.light = atoi(row[86]); + entry.lore = row[87] ? row[87] : ""; + entry.loregroup = atoi(row[88]); + entry.magic = atoi(row[89]); + entry.mana = atoi(row[90]); + entry.manaregen = atoi(row[91]); + entry.enduranceregen = atoi(row[92]); + entry.material = atoi(row[93]); + entry.herosforgemodel = atoi(row[94]); + entry.maxcharges = atoi(row[95]); + entry.mr = atoi(row[96]); + entry.nodrop = atoi(row[97]); + entry.norent = atoi(row[98]); + entry.pendingloreflag = atoi(row[99]); + entry.pr = atoi(row[100]); + entry.procrate = atoi(row[101]); + entry.races = atoi(row[102]); + entry.range = atoi(row[103]); + entry.reclevel = atoi(row[104]); + entry.recskill = atoi(row[105]); + entry.reqlevel = atoi(row[106]); + entry.sellrate = atof(row[107]); + entry.shielding = atoi(row[108]); + entry.size = atoi(row[109]); + entry.skillmodtype = atoi(row[110]); + entry.skillmodvalue = atoi(row[111]); + entry.slots = atoi(row[112]); + entry.clickeffect = atoi(row[113]); + entry.spellshield = atoi(row[114]); + entry.strikethrough = atoi(row[115]); + entry.stunresist = atoi(row[116]); + entry.summonedflag = atoi(row[117]); + entry.tradeskills = atoi(row[118]); + entry.favor = atoi(row[119]); + entry.weight = atoi(row[120]); + entry.UNK012 = atoi(row[121]); + entry.UNK013 = atoi(row[122]); + entry.benefitflag = atoi(row[123]); + entry.UNK054 = atoi(row[124]); + entry.UNK059 = atoi(row[125]); + entry.booktype = atoi(row[126]); + entry.recastdelay = atoi(row[127]); + entry.recasttype = atoi(row[128]); + entry.guildfavor = atoi(row[129]); + entry.UNK123 = atoi(row[130]); + entry.UNK124 = atoi(row[131]); + entry.attuneable = atoi(row[132]); + entry.nopet = atoi(row[133]); + entry.updated = row[134] ? row[134] : ""; + entry.comment = row[135] ? row[135] : ""; + entry.UNK127 = atoi(row[136]); + entry.pointtype = atoi(row[137]); + entry.potionbelt = atoi(row[138]); + entry.potionbeltslots = atoi(row[139]); + entry.stacksize = atoi(row[140]); + entry.notransfer = atoi(row[141]); + entry.stackable = atoi(row[142]); + entry.UNK134 = row[143] ? row[143] : ""; + entry.UNK137 = atoi(row[144]); + entry.proceffect = atoi(row[145]); + entry.proctype = atoi(row[146]); + entry.proclevel2 = atoi(row[147]); + entry.proclevel = atoi(row[148]); + entry.UNK142 = atoi(row[149]); + entry.worneffect = atoi(row[150]); + entry.worntype = atoi(row[151]); + entry.wornlevel2 = atoi(row[152]); + entry.wornlevel = atoi(row[153]); + entry.UNK147 = atoi(row[154]); + entry.focustype = atoi(row[155]); + entry.focuslevel2 = atoi(row[156]); + entry.focuslevel = atoi(row[157]); + entry.UNK152 = atoi(row[158]); + entry.scrolleffect = atoi(row[159]); + entry.scrolltype = atoi(row[160]); + entry.scrolllevel2 = atoi(row[161]); + entry.scrolllevel = atoi(row[162]); + entry.UNK157 = atoi(row[163]); + entry.serialized = row[164] ? row[164] : ""; + entry.verified = row[165] ? row[165] : ""; + entry.serialization = row[166] ? row[166] : ""; + entry.source = row[167] ? row[167] : ""; + entry.UNK033 = atoi(row[168]); + entry.lorefile = row[169] ? row[169] : ""; + entry.UNK014 = atoi(row[170]); + entry.svcorruption = atoi(row[171]); + entry.skillmodmax = atoi(row[172]); + entry.UNK060 = atoi(row[173]); + entry.augslot1unk2 = atoi(row[174]); + entry.augslot2unk2 = atoi(row[175]); + entry.augslot3unk2 = atoi(row[176]); + entry.augslot4unk2 = atoi(row[177]); + entry.augslot5unk2 = atoi(row[178]); + entry.augslot6unk2 = atoi(row[179]); + entry.UNK120 = atoi(row[180]); + entry.UNK121 = atoi(row[181]); + entry.questitemflag = atoi(row[182]); + entry.UNK132 = row[183] ? row[183] : ""; + entry.clickunk5 = atoi(row[184]); + entry.clickunk6 = row[185] ? row[185] : ""; + entry.clickunk7 = atoi(row[186]); + entry.procunk1 = atoi(row[187]); + entry.procunk2 = atoi(row[188]); + entry.procunk3 = atoi(row[189]); + entry.procunk4 = atoi(row[190]); + entry.procunk6 = row[191] ? row[191] : ""; + entry.procunk7 = atoi(row[192]); + entry.wornunk1 = atoi(row[193]); + entry.wornunk2 = atoi(row[194]); + entry.wornunk3 = atoi(row[195]); + entry.wornunk4 = atoi(row[196]); + entry.wornunk5 = atoi(row[197]); + entry.wornunk6 = row[198] ? row[198] : ""; + entry.wornunk7 = atoi(row[199]); + entry.focusunk1 = atoi(row[200]); + entry.focusunk2 = atoi(row[201]); + entry.focusunk3 = atoi(row[202]); + entry.focusunk4 = atoi(row[203]); + entry.focusunk5 = atoi(row[204]); + entry.focusunk6 = row[205] ? row[205] : ""; + entry.focusunk7 = atoi(row[206]); + entry.scrollunk1 = atoi(row[207]); + entry.scrollunk2 = atoi(row[208]); + entry.scrollunk3 = atoi(row[209]); + entry.scrollunk4 = atoi(row[210]); + entry.scrollunk5 = atoi(row[211]); + entry.scrollunk6 = row[212] ? row[212] : ""; + entry.scrollunk7 = atoi(row[213]); + entry.UNK193 = atoi(row[214]); + entry.purity = atoi(row[215]); + entry.evoitem = atoi(row[216]); + entry.evoid = atoi(row[217]); + entry.evolvinglevel = atoi(row[218]); + entry.evomax = atoi(row[219]); + entry.clickname = row[220] ? row[220] : ""; + entry.procname = row[221] ? row[221] : ""; + entry.wornname = row[222] ? row[222] : ""; + entry.focusname = row[223] ? row[223] : ""; + entry.scrollname = row[224] ? row[224] : ""; + entry.dsmitigation = atoi(row[225]); + entry.heroic_str = atoi(row[226]); + entry.heroic_int = atoi(row[227]); + entry.heroic_wis = atoi(row[228]); + entry.heroic_agi = atoi(row[229]); + entry.heroic_dex = atoi(row[230]); + entry.heroic_sta = atoi(row[231]); + entry.heroic_cha = atoi(row[232]); + entry.heroic_pr = atoi(row[233]); + entry.heroic_dr = atoi(row[234]); + entry.heroic_fr = atoi(row[235]); + entry.heroic_cr = atoi(row[236]); + entry.heroic_mr = atoi(row[237]); + entry.heroic_svcorrup = atoi(row[238]); + entry.healamt = atoi(row[239]); + entry.spelldmg = atoi(row[240]); + entry.clairvoyance = atoi(row[241]); + entry.backstabdmg = atoi(row[242]); + entry.created = row[243] ? row[243] : ""; + entry.elitematerial = atoi(row[244]); + entry.ldonsellbackrate = atoi(row[245]); + entry.scriptfileid = atoi(row[246]); + entry.expendablearrow = atoi(row[247]); + entry.powersourcecapacity = atoi(row[248]); + entry.bardeffect = atoi(row[249]); + entry.bardeffecttype = atoi(row[250]); + entry.bardlevel2 = atoi(row[251]); + entry.bardlevel = atoi(row[252]); + entry.bardunk1 = atoi(row[253]); + entry.bardunk2 = atoi(row[254]); + entry.bardunk3 = atoi(row[255]); + entry.bardunk4 = atoi(row[256]); + entry.bardunk5 = atoi(row[257]); + entry.bardname = row[258] ? row[258] : ""; + entry.bardunk7 = atoi(row[259]); + entry.UNK214 = atoi(row[260]); + entry.UNK219 = atoi(row[261]); + entry.UNK220 = atoi(row[262]); + entry.UNK221 = atoi(row[263]); + entry.heirloom = atoi(row[264]); + entry.UNK223 = atoi(row[265]); + entry.UNK224 = atoi(row[266]); + entry.UNK225 = atoi(row[267]); + entry.UNK226 = atoi(row[268]); + entry.UNK227 = atoi(row[269]); + entry.UNK228 = atoi(row[270]); + entry.UNK229 = atoi(row[271]); + entry.UNK230 = atoi(row[272]); + entry.UNK231 = atoi(row[273]); + entry.UNK232 = atoi(row[274]); + entry.UNK233 = atoi(row[275]); + entry.UNK234 = atoi(row[276]); + entry.placeable = atoi(row[277]); + entry.UNK236 = atoi(row[278]); + entry.UNK237 = atoi(row[279]); + entry.UNK238 = atoi(row[280]); + entry.UNK239 = atoi(row[281]); + entry.UNK240 = atoi(row[282]); + entry.UNK241 = atoi(row[283]); + entry.epicitem = atoi(row[284]); + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_ITEMS_REPOSITORY_H diff --git a/common/repositories/base/base_launcher_repository.h b/common/repositories/base/base_launcher_repository.h new file mode 100644 index 000000000..04d148afc --- /dev/null +++ b/common/repositories/base/base_launcher_repository.h @@ -0,0 +1,306 @@ +/** + * 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 on Apr 5, 2020 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_LAUNCHER_REPOSITORY_H +#define EQEMU_BASE_LAUNCHER_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseLauncherRepository { +public: + struct Launcher { + std::string name; + int8 dynamics; + }; + + static std::string PrimaryKey() + { + return std::string("name"); + } + + static std::vector Columns() + { + return { + "name", + "dynamics", + }; + } + + 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("launcher"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Launcher NewEntity() + { + Launcher entry{}; + + entry.name = ""; + entry.dynamics = 0; + + return entry; + } + + static Launcher GetLauncherEntry( + const std::vector &launchers, + int launcher_id + ) + { + for (auto &launcher : launchers) { + if (launcher.name == launcher_id) { + return launcher; + } + } + + return NewEntity(); + } + + static Launcher FindOne( + int launcher_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + launcher_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Launcher entry{}; + + entry.name = row[0] ? row[0] : ""; + entry.dynamics = atoi(row[1]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int launcher_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + launcher_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Launcher launcher_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(launcher_entry.dynamics)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + launcher_entry.name + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Launcher InsertOne( + Launcher launcher_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(launcher_entry.dynamics)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + launcher_entry.id = results.LastInsertedID(); + return launcher_entry; + } + + launcher_entry = NewEntity(); + + return launcher_entry; + } + + static int InsertMany( + std::vector launcher_entries + ) + { + std::vector insert_chunks; + + for (auto &launcher_entry: launcher_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(launcher_entry.dynamics)); + + 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) { + Launcher entry{}; + + entry.name = row[0] ? row[0] : ""; + entry.dynamics = 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 = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Launcher entry{}; + + entry.name = row[0] ? row[0] : ""; + entry.dynamics = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_LAUNCHER_REPOSITORY_H diff --git a/common/repositories/base/base_launcher_zones_repository.h b/common/repositories/base/base_launcher_zones_repository.h new file mode 100644 index 000000000..ba2fe82b3 --- /dev/null +++ b/common/repositories/base/base_launcher_zones_repository.h @@ -0,0 +1,312 @@ +/** + * 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 on Apr 5, 2020 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_LAUNCHER_ZONES_REPOSITORY_H +#define EQEMU_BASE_LAUNCHER_ZONES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseLauncherZonesRepository { +public: + struct LauncherZones { + std::string launcher; + std::string zone; + int port; + }; + + static std::string PrimaryKey() + { + return std::string("zone"); + } + + static std::vector Columns() + { + return { + "launcher", + "zone", + "port", + }; + } + + 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("launcher_zones"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static LauncherZones NewEntity() + { + LauncherZones entry{}; + + entry.launcher = ""; + entry.zone = ""; + entry.port = 0; + + return entry; + } + + static LauncherZones GetLauncherZonesEntry( + const std::vector &launcher_zoness, + int launcher_zones_id + ) + { + for (auto &launcher_zones : launcher_zoness) { + if (launcher_zones.zone == launcher_zones_id) { + return launcher_zones; + } + } + + return NewEntity(); + } + + static LauncherZones FindOne( + int launcher_zones_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + launcher_zones_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + LauncherZones entry{}; + + entry.launcher = row[0] ? row[0] : ""; + entry.zone = row[1] ? row[1] : ""; + entry.port = atoi(row[2]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int launcher_zones_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + launcher_zones_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + LauncherZones launcher_zones_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = " + std::to_string(launcher_zones_entry.port)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + launcher_zones_entry.zone + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static LauncherZones InsertOne( + LauncherZones launcher_zones_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(launcher_zones_entry.port)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + launcher_zones_entry.id = results.LastInsertedID(); + return launcher_zones_entry; + } + + launcher_zones_entry = NewEntity(); + + return launcher_zones_entry; + } + + static int InsertMany( + std::vector launcher_zones_entries + ) + { + std::vector insert_chunks; + + for (auto &launcher_zones_entry: launcher_zones_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(launcher_zones_entry.port)); + + 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) { + LauncherZones entry{}; + + entry.launcher = row[0] ? row[0] : ""; + entry.zone = row[1] ? row[1] : ""; + entry.port = atoi(row[2]); + + 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) { + LauncherZones entry{}; + + entry.launcher = row[0] ? row[0] : ""; + entry.zone = row[1] ? row[1] : ""; + entry.port = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_LAUNCHER_ZONES_REPOSITORY_H diff --git a/common/repositories/base/base_ldon_trap_entries_repository.h b/common/repositories/base/base_ldon_trap_entries_repository.h new file mode 100644 index 000000000..aa6d7cc7a --- /dev/null +++ b/common/repositories/base/base_ldon_trap_entries_repository.h @@ -0,0 +1,306 @@ +/** + * 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 on Apr 5, 2020 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_LDON_TRAP_ENTRIES_REPOSITORY_H +#define EQEMU_BASE_LDON_TRAP_ENTRIES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseLdonTrapEntriesRepository { +public: + struct LdonTrapEntries { + int id; + int trap_id; + }; + + static std::string PrimaryKey() + { + return std::string("trap_id"); + } + + static std::vector Columns() + { + return { + "id", + "trap_id", + }; + } + + 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("ldon_trap_entries"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static LdonTrapEntries NewEntity() + { + LdonTrapEntries entry{}; + + entry.id = 0; + entry.trap_id = 0; + + return entry; + } + + static LdonTrapEntries GetLdonTrapEntriesEntry( + const std::vector &ldon_trap_entriess, + int ldon_trap_entries_id + ) + { + for (auto &ldon_trap_entries : ldon_trap_entriess) { + if (ldon_trap_entries.trap_id == ldon_trap_entries_id) { + return ldon_trap_entries; + } + } + + return NewEntity(); + } + + static LdonTrapEntries FindOne( + int ldon_trap_entries_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + ldon_trap_entries_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + LdonTrapEntries entry{}; + + entry.id = atoi(row[0]); + entry.trap_id = atoi(row[1]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int ldon_trap_entries_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + ldon_trap_entries_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + LdonTrapEntries ldon_trap_entries_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + ldon_trap_entries_entry.trap_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static LdonTrapEntries InsertOne( + LdonTrapEntries ldon_trap_entries_entry + ) + { + std::vector insert_values; + + + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + ldon_trap_entries_entry.id = results.LastInsertedID(); + return ldon_trap_entries_entry; + } + + ldon_trap_entries_entry = NewEntity(); + + return ldon_trap_entries_entry; + } + + static int InsertMany( + std::vector ldon_trap_entries_entries + ) + { + std::vector insert_chunks; + + for (auto &ldon_trap_entries_entry: ldon_trap_entries_entries) { + std::vector insert_values; + + + + 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) { + LdonTrapEntries entry{}; + + entry.id = atoi(row[0]); + entry.trap_id = 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) { + LdonTrapEntries entry{}; + + entry.id = atoi(row[0]); + entry.trap_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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_LDON_TRAP_ENTRIES_REPOSITORY_H diff --git a/common/repositories/base/base_ldon_trap_templates_repository.h b/common/repositories/base/base_ldon_trap_templates_repository.h new file mode 100644 index 000000000..3d75990cf --- /dev/null +++ b/common/repositories/base/base_ldon_trap_templates_repository.h @@ -0,0 +1,333 @@ +/** + * 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 on Apr 5, 2020 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_LDON_TRAP_TEMPLATES_REPOSITORY_H +#define EQEMU_BASE_LDON_TRAP_TEMPLATES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseLdonTrapTemplatesRepository { +public: + struct LdonTrapTemplates { + int id; + int8 type; + int16 spell_id; + int16 skill; + int8 locked; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "type", + "spell_id", + "skill", + "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("ldon_trap_templates"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static LdonTrapTemplates NewEntity() + { + LdonTrapTemplates entry{}; + + entry.id = 0; + entry.type = 1; + entry.spell_id = 0; + entry.skill = 0; + entry.locked = 0; + + return entry; + } + + static LdonTrapTemplates GetLdonTrapTemplatesEntry( + const std::vector &ldon_trap_templatess, + int ldon_trap_templates_id + ) + { + for (auto &ldon_trap_templates : ldon_trap_templatess) { + if (ldon_trap_templates.id == ldon_trap_templates_id) { + return ldon_trap_templates; + } + } + + return NewEntity(); + } + + static LdonTrapTemplates FindOne( + int ldon_trap_templates_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + ldon_trap_templates_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + LdonTrapTemplates entry{}; + + entry.id = atoi(row[0]); + entry.type = atoi(row[1]); + entry.spell_id = atoi(row[2]); + entry.skill = atoi(row[3]); + entry.locked = atoi(row[4]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int ldon_trap_templates_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + ldon_trap_templates_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + LdonTrapTemplates ldon_trap_templates_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(ldon_trap_templates_entry.type)); + update_values.push_back(columns[2] + " = " + std::to_string(ldon_trap_templates_entry.spell_id)); + update_values.push_back(columns[3] + " = " + std::to_string(ldon_trap_templates_entry.skill)); + update_values.push_back(columns[4] + " = " + std::to_string(ldon_trap_templates_entry.locked)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + ldon_trap_templates_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static LdonTrapTemplates InsertOne( + LdonTrapTemplates ldon_trap_templates_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(ldon_trap_templates_entry.type)); + insert_values.push_back(std::to_string(ldon_trap_templates_entry.spell_id)); + insert_values.push_back(std::to_string(ldon_trap_templates_entry.skill)); + insert_values.push_back(std::to_string(ldon_trap_templates_entry.locked)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + ldon_trap_templates_entry.id = results.LastInsertedID(); + return ldon_trap_templates_entry; + } + + ldon_trap_templates_entry = NewEntity(); + + return ldon_trap_templates_entry; + } + + static int InsertMany( + std::vector ldon_trap_templates_entries + ) + { + std::vector insert_chunks; + + for (auto &ldon_trap_templates_entry: ldon_trap_templates_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(ldon_trap_templates_entry.type)); + insert_values.push_back(std::to_string(ldon_trap_templates_entry.spell_id)); + insert_values.push_back(std::to_string(ldon_trap_templates_entry.skill)); + insert_values.push_back(std::to_string(ldon_trap_templates_entry.locked)); + + 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) { + LdonTrapTemplates entry{}; + + entry.id = atoi(row[0]); + entry.type = atoi(row[1]); + entry.spell_id = atoi(row[2]); + entry.skill = atoi(row[3]); + entry.locked = atoi(row[4]); + + 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) { + LdonTrapTemplates entry{}; + + entry.id = atoi(row[0]); + entry.type = atoi(row[1]); + entry.spell_id = atoi(row[2]); + entry.skill = atoi(row[3]); + entry.locked = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_LDON_TRAP_TEMPLATES_REPOSITORY_H diff --git a/common/repositories/base/base_level_exp_mods_repository.h b/common/repositories/base/base_level_exp_mods_repository.h new file mode 100644 index 000000000..d3c1b5249 --- /dev/null +++ b/common/repositories/base/base_level_exp_mods_repository.h @@ -0,0 +1,315 @@ +/** + * 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 on Apr 5, 2020 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_LEVEL_EXP_MODS_REPOSITORY_H +#define EQEMU_BASE_LEVEL_EXP_MODS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseLevelExpModsRepository { +public: + struct LevelExpMods { + int level; + float exp_mod; + float aa_exp_mod; + }; + + static std::string PrimaryKey() + { + return std::string("level"); + } + + static std::vector Columns() + { + return { + "level", + "exp_mod", + "aa_exp_mod", + }; + } + + 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("level_exp_mods"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static LevelExpMods NewEntity() + { + LevelExpMods entry{}; + + entry.level = 0; + entry.exp_mod = 0; + entry.aa_exp_mod = 0; + + return entry; + } + + static LevelExpMods GetLevelExpModsEntry( + const std::vector &level_exp_modss, + int level_exp_mods_id + ) + { + for (auto &level_exp_mods : level_exp_modss) { + if (level_exp_mods.level == level_exp_mods_id) { + return level_exp_mods; + } + } + + return NewEntity(); + } + + static LevelExpMods FindOne( + int level_exp_mods_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + level_exp_mods_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + LevelExpMods entry{}; + + entry.level = atoi(row[0]); + entry.exp_mod = atof(row[1]); + entry.aa_exp_mod = atof(row[2]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int level_exp_mods_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + level_exp_mods_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + LevelExpMods level_exp_mods_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(level_exp_mods_entry.exp_mod)); + update_values.push_back(columns[2] + " = " + std::to_string(level_exp_mods_entry.aa_exp_mod)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + level_exp_mods_entry.level + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static LevelExpMods InsertOne( + LevelExpMods level_exp_mods_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(level_exp_mods_entry.exp_mod)); + insert_values.push_back(std::to_string(level_exp_mods_entry.aa_exp_mod)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + level_exp_mods_entry.id = results.LastInsertedID(); + return level_exp_mods_entry; + } + + level_exp_mods_entry = NewEntity(); + + return level_exp_mods_entry; + } + + static int InsertMany( + std::vector level_exp_mods_entries + ) + { + std::vector insert_chunks; + + for (auto &level_exp_mods_entry: level_exp_mods_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(level_exp_mods_entry.exp_mod)); + insert_values.push_back(std::to_string(level_exp_mods_entry.aa_exp_mod)); + + 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) { + LevelExpMods entry{}; + + entry.level = atoi(row[0]); + entry.exp_mod = atof(row[1]); + entry.aa_exp_mod = atof(row[2]); + + 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) { + LevelExpMods entry{}; + + entry.level = atoi(row[0]); + entry.exp_mod = atof(row[1]); + entry.aa_exp_mod = atof(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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_LEVEL_EXP_MODS_REPOSITORY_H diff --git a/common/repositories/base/base_lfguild_repository.h b/common/repositories/base/base_lfguild_repository.h new file mode 100644 index 000000000..9930dc35c --- /dev/null +++ b/common/repositories/base/base_lfguild_repository.h @@ -0,0 +1,366 @@ +/** + * 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 on Apr 5, 2020 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_LFGUILD_REPOSITORY_H +#define EQEMU_BASE_LFGUILD_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseLfguildRepository { +public: + struct Lfguild { + int8 type; + std::string name; + std::string comment; + int8 fromlevel; + int8 tolevel; + int classes; + int aacount; + int timezone; + int timeposted; + }; + + static std::string PrimaryKey() + { + return std::string("name"); + } + + static std::vector Columns() + { + return { + "type", + "name", + "comment", + "fromlevel", + "tolevel", + "classes", + "aacount", + "timezone", + "timeposted", + }; + } + + 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("lfguild"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Lfguild NewEntity() + { + Lfguild entry{}; + + entry.type = 0; + entry.name = ""; + entry.comment = ""; + entry.fromlevel = 0; + entry.tolevel = 0; + entry.classes = 0; + entry.aacount = 0; + entry.timezone = 0; + entry.timeposted = 0; + + return entry; + } + + static Lfguild GetLfguildEntry( + const std::vector &lfguilds, + int lfguild_id + ) + { + for (auto &lfguild : lfguilds) { + if (lfguild.name == lfguild_id) { + return lfguild; + } + } + + return NewEntity(); + } + + static Lfguild FindOne( + int lfguild_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + lfguild_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Lfguild entry{}; + + entry.type = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.comment = row[2] ? row[2] : ""; + entry.fromlevel = atoi(row[3]); + entry.tolevel = atoi(row[4]); + entry.classes = atoi(row[5]); + entry.aacount = atoi(row[6]); + entry.timezone = atoi(row[7]); + entry.timeposted = atoi(row[8]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int lfguild_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + lfguild_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Lfguild lfguild_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = '" + EscapeString(lfguild_entry.comment) + "'"); + update_values.push_back(columns[3] + " = " + std::to_string(lfguild_entry.fromlevel)); + update_values.push_back(columns[4] + " = " + std::to_string(lfguild_entry.tolevel)); + update_values.push_back(columns[5] + " = " + std::to_string(lfguild_entry.classes)); + update_values.push_back(columns[6] + " = " + std::to_string(lfguild_entry.aacount)); + update_values.push_back(columns[7] + " = " + std::to_string(lfguild_entry.timezone)); + update_values.push_back(columns[8] + " = " + std::to_string(lfguild_entry.timeposted)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + lfguild_entry.name + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Lfguild InsertOne( + Lfguild lfguild_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(lfguild_entry.comment) + "'"); + insert_values.push_back(std::to_string(lfguild_entry.fromlevel)); + insert_values.push_back(std::to_string(lfguild_entry.tolevel)); + insert_values.push_back(std::to_string(lfguild_entry.classes)); + insert_values.push_back(std::to_string(lfguild_entry.aacount)); + insert_values.push_back(std::to_string(lfguild_entry.timezone)); + insert_values.push_back(std::to_string(lfguild_entry.timeposted)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + lfguild_entry.id = results.LastInsertedID(); + return lfguild_entry; + } + + lfguild_entry = NewEntity(); + + return lfguild_entry; + } + + static int InsertMany( + std::vector lfguild_entries + ) + { + std::vector insert_chunks; + + for (auto &lfguild_entry: lfguild_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(lfguild_entry.comment) + "'"); + insert_values.push_back(std::to_string(lfguild_entry.fromlevel)); + insert_values.push_back(std::to_string(lfguild_entry.tolevel)); + insert_values.push_back(std::to_string(lfguild_entry.classes)); + insert_values.push_back(std::to_string(lfguild_entry.aacount)); + insert_values.push_back(std::to_string(lfguild_entry.timezone)); + insert_values.push_back(std::to_string(lfguild_entry.timeposted)); + + 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) { + Lfguild entry{}; + + entry.type = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.comment = row[2] ? row[2] : ""; + entry.fromlevel = atoi(row[3]); + entry.tolevel = atoi(row[4]); + entry.classes = atoi(row[5]); + entry.aacount = atoi(row[6]); + entry.timezone = atoi(row[7]); + entry.timeposted = 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) { + Lfguild entry{}; + + entry.type = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.comment = row[2] ? row[2] : ""; + entry.fromlevel = atoi(row[3]); + entry.tolevel = atoi(row[4]); + entry.classes = atoi(row[5]); + entry.aacount = atoi(row[6]); + entry.timezone = atoi(row[7]); + entry.timeposted = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_LFGUILD_REPOSITORY_H diff --git a/common/repositories/base/base_login_accounts_repository.h b/common/repositories/base/base_login_accounts_repository.h new file mode 100644 index 000000000..8ef4d63c1 --- /dev/null +++ b/common/repositories/base/base_login_accounts_repository.h @@ -0,0 +1,369 @@ +/** + * 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 on Apr 5, 2020 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_LOGIN_ACCOUNTS_REPOSITORY_H +#define EQEMU_BASE_LOGIN_ACCOUNTS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseLoginAccountsRepository { +public: + struct LoginAccounts { + int id; + std::string account_name; + std::string account_password; + std::string account_email; + std::string source_loginserver; + std::string last_ip_address; + std::string last_login_date; + std::string created_at; + std::string updated_at; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "account_name", + "account_password", + "account_email", + "source_loginserver", + "last_ip_address", + "last_login_date", + "created_at", + "updated_at", + }; + } + + 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("login_accounts"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static LoginAccounts NewEntity() + { + LoginAccounts entry{}; + + entry.id = 0; + entry.account_name = ""; + entry.account_password = ""; + entry.account_email = ""; + entry.source_loginserver = ""; + entry.last_ip_address = ""; + entry.last_login_date = 0; + entry.created_at = 0; + entry.updated_at = current_timestamp(); + + return entry; + } + + static LoginAccounts GetLoginAccountsEntry( + const std::vector &login_accountss, + int login_accounts_id + ) + { + for (auto &login_accounts : login_accountss) { + if (login_accounts.id == login_accounts_id) { + return login_accounts; + } + } + + return NewEntity(); + } + + static LoginAccounts FindOne( + int login_accounts_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + login_accounts_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + LoginAccounts entry{}; + + entry.id = atoi(row[0]); + entry.account_name = row[1] ? row[1] : ""; + entry.account_password = row[2] ? row[2] : ""; + entry.account_email = row[3] ? row[3] : ""; + entry.source_loginserver = row[4] ? row[4] : ""; + entry.last_ip_address = row[5] ? row[5] : ""; + entry.last_login_date = row[6] ? row[6] : ""; + entry.created_at = row[7] ? row[7] : ""; + entry.updated_at = row[8] ? row[8] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int login_accounts_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + login_accounts_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + LoginAccounts login_accounts_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(login_accounts_entry.account_name) + "'"); + update_values.push_back(columns[2] + " = '" + EscapeString(login_accounts_entry.account_password) + "'"); + update_values.push_back(columns[3] + " = '" + EscapeString(login_accounts_entry.account_email) + "'"); + update_values.push_back(columns[4] + " = '" + EscapeString(login_accounts_entry.source_loginserver) + "'"); + update_values.push_back(columns[5] + " = '" + EscapeString(login_accounts_entry.last_ip_address) + "'"); + update_values.push_back(columns[6] + " = '" + EscapeString(login_accounts_entry.last_login_date) + "'"); + update_values.push_back(columns[7] + " = '" + EscapeString(login_accounts_entry.created_at) + "'"); + update_values.push_back(columns[8] + " = '" + EscapeString(login_accounts_entry.updated_at) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + login_accounts_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static LoginAccounts InsertOne( + LoginAccounts login_accounts_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(login_accounts_entry.account_name) + "'"); + insert_values.push_back("'" + EscapeString(login_accounts_entry.account_password) + "'"); + insert_values.push_back("'" + EscapeString(login_accounts_entry.account_email) + "'"); + insert_values.push_back("'" + EscapeString(login_accounts_entry.source_loginserver) + "'"); + insert_values.push_back("'" + EscapeString(login_accounts_entry.last_ip_address) + "'"); + insert_values.push_back("'" + EscapeString(login_accounts_entry.last_login_date) + "'"); + insert_values.push_back("'" + EscapeString(login_accounts_entry.created_at) + "'"); + insert_values.push_back("'" + EscapeString(login_accounts_entry.updated_at) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + login_accounts_entry.id = results.LastInsertedID(); + return login_accounts_entry; + } + + login_accounts_entry = NewEntity(); + + return login_accounts_entry; + } + + static int InsertMany( + std::vector login_accounts_entries + ) + { + std::vector insert_chunks; + + for (auto &login_accounts_entry: login_accounts_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(login_accounts_entry.account_name) + "'"); + insert_values.push_back("'" + EscapeString(login_accounts_entry.account_password) + "'"); + insert_values.push_back("'" + EscapeString(login_accounts_entry.account_email) + "'"); + insert_values.push_back("'" + EscapeString(login_accounts_entry.source_loginserver) + "'"); + insert_values.push_back("'" + EscapeString(login_accounts_entry.last_ip_address) + "'"); + insert_values.push_back("'" + EscapeString(login_accounts_entry.last_login_date) + "'"); + insert_values.push_back("'" + EscapeString(login_accounts_entry.created_at) + "'"); + insert_values.push_back("'" + EscapeString(login_accounts_entry.updated_at) + "'"); + + 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) { + LoginAccounts entry{}; + + entry.id = atoi(row[0]); + entry.account_name = row[1] ? row[1] : ""; + entry.account_password = row[2] ? row[2] : ""; + entry.account_email = row[3] ? row[3] : ""; + entry.source_loginserver = row[4] ? row[4] : ""; + entry.last_ip_address = row[5] ? row[5] : ""; + entry.last_login_date = row[6] ? row[6] : ""; + entry.created_at = row[7] ? row[7] : ""; + entry.updated_at = row[8] ? 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) { + LoginAccounts entry{}; + + entry.id = atoi(row[0]); + entry.account_name = row[1] ? row[1] : ""; + entry.account_password = row[2] ? row[2] : ""; + entry.account_email = row[3] ? row[3] : ""; + entry.source_loginserver = row[4] ? row[4] : ""; + entry.last_ip_address = row[5] ? row[5] : ""; + entry.last_login_date = row[6] ? row[6] : ""; + entry.created_at = row[7] ? row[7] : ""; + entry.updated_at = row[8] ? 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_LOGIN_ACCOUNTS_REPOSITORY_H diff --git a/common/repositories/base/base_login_api_tokens_repository.h b/common/repositories/base/base_login_api_tokens_repository.h new file mode 100644 index 000000000..94b995aba --- /dev/null +++ b/common/repositories/base/base_login_api_tokens_repository.h @@ -0,0 +1,342 @@ +/** + * 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 on Apr 5, 2020 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_LOGIN_API_TOKENS_REPOSITORY_H +#define EQEMU_BASE_LOGIN_API_TOKENS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseLoginApiTokensRepository { +public: + struct LoginApiTokens { + int id; + std::string token; + int can_write; + int can_read; + std::string created_at; + std::string updated_at; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "token", + "can_write", + "can_read", + "created_at", + "updated_at", + }; + } + + 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("login_api_tokens"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static LoginApiTokens NewEntity() + { + LoginApiTokens entry{}; + + entry.id = 0; + entry.token = ""; + entry.can_write = 0; + entry.can_read = 0; + entry.created_at = 0; + entry.updated_at = current_timestamp(); + + return entry; + } + + static LoginApiTokens GetLoginApiTokensEntry( + const std::vector &login_api_tokenss, + int login_api_tokens_id + ) + { + for (auto &login_api_tokens : login_api_tokenss) { + if (login_api_tokens.id == login_api_tokens_id) { + return login_api_tokens; + } + } + + return NewEntity(); + } + + static LoginApiTokens FindOne( + int login_api_tokens_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + login_api_tokens_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + LoginApiTokens entry{}; + + entry.id = atoi(row[0]); + entry.token = row[1] ? row[1] : ""; + entry.can_write = atoi(row[2]); + entry.can_read = atoi(row[3]); + entry.created_at = row[4] ? row[4] : ""; + entry.updated_at = row[5] ? row[5] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int login_api_tokens_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + login_api_tokens_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + LoginApiTokens login_api_tokens_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(login_api_tokens_entry.token) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(login_api_tokens_entry.can_write)); + update_values.push_back(columns[3] + " = " + std::to_string(login_api_tokens_entry.can_read)); + update_values.push_back(columns[4] + " = '" + EscapeString(login_api_tokens_entry.created_at) + "'"); + update_values.push_back(columns[5] + " = '" + EscapeString(login_api_tokens_entry.updated_at) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + login_api_tokens_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static LoginApiTokens InsertOne( + LoginApiTokens login_api_tokens_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(login_api_tokens_entry.token) + "'"); + insert_values.push_back(std::to_string(login_api_tokens_entry.can_write)); + insert_values.push_back(std::to_string(login_api_tokens_entry.can_read)); + insert_values.push_back("'" + EscapeString(login_api_tokens_entry.created_at) + "'"); + insert_values.push_back("'" + EscapeString(login_api_tokens_entry.updated_at) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + login_api_tokens_entry.id = results.LastInsertedID(); + return login_api_tokens_entry; + } + + login_api_tokens_entry = NewEntity(); + + return login_api_tokens_entry; + } + + static int InsertMany( + std::vector login_api_tokens_entries + ) + { + std::vector insert_chunks; + + for (auto &login_api_tokens_entry: login_api_tokens_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(login_api_tokens_entry.token) + "'"); + insert_values.push_back(std::to_string(login_api_tokens_entry.can_write)); + insert_values.push_back(std::to_string(login_api_tokens_entry.can_read)); + insert_values.push_back("'" + EscapeString(login_api_tokens_entry.created_at) + "'"); + insert_values.push_back("'" + EscapeString(login_api_tokens_entry.updated_at) + "'"); + + 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) { + LoginApiTokens entry{}; + + entry.id = atoi(row[0]); + entry.token = row[1] ? row[1] : ""; + entry.can_write = atoi(row[2]); + entry.can_read = atoi(row[3]); + entry.created_at = row[4] ? row[4] : ""; + entry.updated_at = 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) { + LoginApiTokens entry{}; + + entry.id = atoi(row[0]); + entry.token = row[1] ? row[1] : ""; + entry.can_write = atoi(row[2]); + entry.can_read = atoi(row[3]); + entry.created_at = row[4] ? row[4] : ""; + entry.updated_at = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_LOGIN_API_TOKENS_REPOSITORY_H diff --git a/common/repositories/base/base_login_server_admins_repository.h b/common/repositories/base/base_login_server_admins_repository.h new file mode 100644 index 000000000..1d637ab00 --- /dev/null +++ b/common/repositories/base/base_login_server_admins_repository.h @@ -0,0 +1,360 @@ +/** + * 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 on Apr 5, 2020 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_LOGIN_SERVER_ADMINS_REPOSITORY_H +#define EQEMU_BASE_LOGIN_SERVER_ADMINS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseLoginServerAdminsRepository { +public: + struct LoginServerAdmins { + int id; + std::string account_name; + std::string account_password; + std::string first_name; + std::string last_name; + std::string email; + std::string registration_date; + std::string registration_ip_address; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "account_name", + "account_password", + "first_name", + "last_name", + "email", + "registration_date", + "registration_ip_address", + }; + } + + 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("login_server_admins"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static LoginServerAdmins NewEntity() + { + LoginServerAdmins entry{}; + + entry.id = 0; + entry.account_name = ""; + entry.account_password = ""; + entry.first_name = ""; + entry.last_name = ""; + entry.email = ""; + entry.registration_date = 0; + entry.registration_ip_address = ""; + + return entry; + } + + static LoginServerAdmins GetLoginServerAdminsEntry( + const std::vector &login_server_adminss, + int login_server_admins_id + ) + { + for (auto &login_server_admins : login_server_adminss) { + if (login_server_admins.id == login_server_admins_id) { + return login_server_admins; + } + } + + return NewEntity(); + } + + static LoginServerAdmins FindOne( + int login_server_admins_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + login_server_admins_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + LoginServerAdmins entry{}; + + entry.id = atoi(row[0]); + entry.account_name = row[1] ? row[1] : ""; + entry.account_password = row[2] ? row[2] : ""; + entry.first_name = row[3] ? row[3] : ""; + entry.last_name = row[4] ? row[4] : ""; + entry.email = row[5] ? row[5] : ""; + entry.registration_date = row[6] ? row[6] : ""; + entry.registration_ip_address = row[7] ? row[7] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int login_server_admins_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + login_server_admins_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + LoginServerAdmins login_server_admins_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(login_server_admins_entry.account_name) + "'"); + update_values.push_back(columns[2] + " = '" + EscapeString(login_server_admins_entry.account_password) + "'"); + update_values.push_back(columns[3] + " = '" + EscapeString(login_server_admins_entry.first_name) + "'"); + update_values.push_back(columns[4] + " = '" + EscapeString(login_server_admins_entry.last_name) + "'"); + update_values.push_back(columns[5] + " = '" + EscapeString(login_server_admins_entry.email) + "'"); + update_values.push_back(columns[6] + " = '" + EscapeString(login_server_admins_entry.registration_date) + "'"); + update_values.push_back(columns[7] + " = '" + EscapeString(login_server_admins_entry.registration_ip_address) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + login_server_admins_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static LoginServerAdmins InsertOne( + LoginServerAdmins login_server_admins_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(login_server_admins_entry.account_name) + "'"); + insert_values.push_back("'" + EscapeString(login_server_admins_entry.account_password) + "'"); + insert_values.push_back("'" + EscapeString(login_server_admins_entry.first_name) + "'"); + insert_values.push_back("'" + EscapeString(login_server_admins_entry.last_name) + "'"); + insert_values.push_back("'" + EscapeString(login_server_admins_entry.email) + "'"); + insert_values.push_back("'" + EscapeString(login_server_admins_entry.registration_date) + "'"); + insert_values.push_back("'" + EscapeString(login_server_admins_entry.registration_ip_address) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + login_server_admins_entry.id = results.LastInsertedID(); + return login_server_admins_entry; + } + + login_server_admins_entry = NewEntity(); + + return login_server_admins_entry; + } + + static int InsertMany( + std::vector login_server_admins_entries + ) + { + std::vector insert_chunks; + + for (auto &login_server_admins_entry: login_server_admins_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(login_server_admins_entry.account_name) + "'"); + insert_values.push_back("'" + EscapeString(login_server_admins_entry.account_password) + "'"); + insert_values.push_back("'" + EscapeString(login_server_admins_entry.first_name) + "'"); + insert_values.push_back("'" + EscapeString(login_server_admins_entry.last_name) + "'"); + insert_values.push_back("'" + EscapeString(login_server_admins_entry.email) + "'"); + insert_values.push_back("'" + EscapeString(login_server_admins_entry.registration_date) + "'"); + insert_values.push_back("'" + EscapeString(login_server_admins_entry.registration_ip_address) + "'"); + + 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) { + LoginServerAdmins entry{}; + + entry.id = atoi(row[0]); + entry.account_name = row[1] ? row[1] : ""; + entry.account_password = row[2] ? row[2] : ""; + entry.first_name = row[3] ? row[3] : ""; + entry.last_name = row[4] ? row[4] : ""; + entry.email = row[5] ? row[5] : ""; + entry.registration_date = row[6] ? row[6] : ""; + entry.registration_ip_address = row[7] ? row[7] : ""; + + 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) { + LoginServerAdmins entry{}; + + entry.id = atoi(row[0]); + entry.account_name = row[1] ? row[1] : ""; + entry.account_password = row[2] ? row[2] : ""; + entry.first_name = row[3] ? row[3] : ""; + entry.last_name = row[4] ? row[4] : ""; + entry.email = row[5] ? row[5] : ""; + entry.registration_date = row[6] ? row[6] : ""; + entry.registration_ip_address = row[7] ? 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_LOGIN_SERVER_ADMINS_REPOSITORY_H diff --git a/common/repositories/base/base_login_server_list_types_repository.h b/common/repositories/base/base_login_server_list_types_repository.h new file mode 100644 index 000000000..5becb3e65 --- /dev/null +++ b/common/repositories/base/base_login_server_list_types_repository.h @@ -0,0 +1,306 @@ +/** + * 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 on Apr 5, 2020 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_LOGIN_SERVER_LIST_TYPES_REPOSITORY_H +#define EQEMU_BASE_LOGIN_SERVER_LIST_TYPES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseLoginServerListTypesRepository { +public: + struct LoginServerListTypes { + int id; + std::string description; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "description", + }; + } + + 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("login_server_list_types"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static LoginServerListTypes NewEntity() + { + LoginServerListTypes entry{}; + + entry.id = 0; + entry.description = ""; + + return entry; + } + + static LoginServerListTypes GetLoginServerListTypesEntry( + const std::vector &login_server_list_typess, + int login_server_list_types_id + ) + { + for (auto &login_server_list_types : login_server_list_typess) { + if (login_server_list_types.id == login_server_list_types_id) { + return login_server_list_types; + } + } + + return NewEntity(); + } + + static LoginServerListTypes FindOne( + int login_server_list_types_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + login_server_list_types_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + LoginServerListTypes entry{}; + + entry.id = atoi(row[0]); + entry.description = row[1] ? row[1] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int login_server_list_types_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + login_server_list_types_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + LoginServerListTypes login_server_list_types_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(login_server_list_types_entry.description) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + login_server_list_types_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static LoginServerListTypes InsertOne( + LoginServerListTypes login_server_list_types_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(login_server_list_types_entry.description) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + login_server_list_types_entry.id = results.LastInsertedID(); + return login_server_list_types_entry; + } + + login_server_list_types_entry = NewEntity(); + + return login_server_list_types_entry; + } + + static int InsertMany( + std::vector login_server_list_types_entries + ) + { + std::vector insert_chunks; + + for (auto &login_server_list_types_entry: login_server_list_types_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(login_server_list_types_entry.description) + "'"); + + 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) { + LoginServerListTypes entry{}; + + entry.id = atoi(row[0]); + entry.description = row[1] ? row[1] : ""; + + 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) { + LoginServerListTypes entry{}; + + entry.id = atoi(row[0]); + entry.description = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_LOGIN_SERVER_LIST_TYPES_REPOSITORY_H diff --git a/common/repositories/base/base_login_world_servers_repository.h b/common/repositories/base/base_login_world_servers_repository.h new file mode 100644 index 000000000..517db98f3 --- /dev/null +++ b/common/repositories/base/base_login_world_servers_repository.h @@ -0,0 +1,378 @@ +/** + * 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 on Apr 5, 2020 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_LOGIN_WORLD_SERVERS_REPOSITORY_H +#define EQEMU_BASE_LOGIN_WORLD_SERVERS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseLoginWorldServersRepository { +public: + struct LoginWorldServers { + int id; + std::string long_name; + std::string short_name; + std::string tag_description; + int login_server_list_type_id; + std::string last_login_date; + std::string last_ip_address; + int login_server_admin_id; + int is_server_trusted; + std::string note; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "long_name", + "short_name", + "tag_description", + "login_server_list_type_id", + "last_login_date", + "last_ip_address", + "login_server_admin_id", + "is_server_trusted", + "note", + }; + } + + 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("login_world_servers"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static LoginWorldServers NewEntity() + { + LoginWorldServers entry{}; + + entry.id = 0; + entry.long_name = ""; + entry.short_name = ""; + entry.tag_description = ""; + entry.login_server_list_type_id = 0; + entry.last_login_date = 0; + entry.last_ip_address = ""; + entry.login_server_admin_id = 0; + entry.is_server_trusted = 0; + entry.note = ""; + + return entry; + } + + static LoginWorldServers GetLoginWorldServersEntry( + const std::vector &login_world_serverss, + int login_world_servers_id + ) + { + for (auto &login_world_servers : login_world_serverss) { + if (login_world_servers.id == login_world_servers_id) { + return login_world_servers; + } + } + + return NewEntity(); + } + + static LoginWorldServers FindOne( + int login_world_servers_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + login_world_servers_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + LoginWorldServers entry{}; + + entry.id = atoi(row[0]); + entry.long_name = row[1] ? row[1] : ""; + entry.short_name = row[2] ? row[2] : ""; + entry.tag_description = row[3] ? row[3] : ""; + entry.login_server_list_type_id = atoi(row[4]); + entry.last_login_date = row[5] ? row[5] : ""; + entry.last_ip_address = row[6] ? row[6] : ""; + entry.login_server_admin_id = atoi(row[7]); + entry.is_server_trusted = atoi(row[8]); + entry.note = row[9] ? row[9] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int login_world_servers_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + login_world_servers_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + LoginWorldServers login_world_servers_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(login_world_servers_entry.long_name) + "'"); + update_values.push_back(columns[2] + " = '" + EscapeString(login_world_servers_entry.short_name) + "'"); + update_values.push_back(columns[3] + " = '" + EscapeString(login_world_servers_entry.tag_description) + "'"); + update_values.push_back(columns[4] + " = " + std::to_string(login_world_servers_entry.login_server_list_type_id)); + update_values.push_back(columns[5] + " = '" + EscapeString(login_world_servers_entry.last_login_date) + "'"); + update_values.push_back(columns[6] + " = '" + EscapeString(login_world_servers_entry.last_ip_address) + "'"); + update_values.push_back(columns[7] + " = " + std::to_string(login_world_servers_entry.login_server_admin_id)); + update_values.push_back(columns[8] + " = " + std::to_string(login_world_servers_entry.is_server_trusted)); + update_values.push_back(columns[9] + " = '" + EscapeString(login_world_servers_entry.note) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + login_world_servers_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static LoginWorldServers InsertOne( + LoginWorldServers login_world_servers_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(login_world_servers_entry.long_name) + "'"); + insert_values.push_back("'" + EscapeString(login_world_servers_entry.short_name) + "'"); + insert_values.push_back("'" + EscapeString(login_world_servers_entry.tag_description) + "'"); + insert_values.push_back(std::to_string(login_world_servers_entry.login_server_list_type_id)); + insert_values.push_back("'" + EscapeString(login_world_servers_entry.last_login_date) + "'"); + insert_values.push_back("'" + EscapeString(login_world_servers_entry.last_ip_address) + "'"); + insert_values.push_back(std::to_string(login_world_servers_entry.login_server_admin_id)); + insert_values.push_back(std::to_string(login_world_servers_entry.is_server_trusted)); + insert_values.push_back("'" + EscapeString(login_world_servers_entry.note) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + login_world_servers_entry.id = results.LastInsertedID(); + return login_world_servers_entry; + } + + login_world_servers_entry = NewEntity(); + + return login_world_servers_entry; + } + + static int InsertMany( + std::vector login_world_servers_entries + ) + { + std::vector insert_chunks; + + for (auto &login_world_servers_entry: login_world_servers_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(login_world_servers_entry.long_name) + "'"); + insert_values.push_back("'" + EscapeString(login_world_servers_entry.short_name) + "'"); + insert_values.push_back("'" + EscapeString(login_world_servers_entry.tag_description) + "'"); + insert_values.push_back(std::to_string(login_world_servers_entry.login_server_list_type_id)); + insert_values.push_back("'" + EscapeString(login_world_servers_entry.last_login_date) + "'"); + insert_values.push_back("'" + EscapeString(login_world_servers_entry.last_ip_address) + "'"); + insert_values.push_back(std::to_string(login_world_servers_entry.login_server_admin_id)); + insert_values.push_back(std::to_string(login_world_servers_entry.is_server_trusted)); + insert_values.push_back("'" + EscapeString(login_world_servers_entry.note) + "'"); + + 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) { + LoginWorldServers entry{}; + + entry.id = atoi(row[0]); + entry.long_name = row[1] ? row[1] : ""; + entry.short_name = row[2] ? row[2] : ""; + entry.tag_description = row[3] ? row[3] : ""; + entry.login_server_list_type_id = atoi(row[4]); + entry.last_login_date = row[5] ? row[5] : ""; + entry.last_ip_address = row[6] ? row[6] : ""; + entry.login_server_admin_id = atoi(row[7]); + entry.is_server_trusted = atoi(row[8]); + entry.note = row[9] ? row[9] : ""; + + 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) { + LoginWorldServers entry{}; + + entry.id = atoi(row[0]); + entry.long_name = row[1] ? row[1] : ""; + entry.short_name = row[2] ? row[2] : ""; + entry.tag_description = row[3] ? row[3] : ""; + entry.login_server_list_type_id = atoi(row[4]); + entry.last_login_date = row[5] ? row[5] : ""; + entry.last_ip_address = row[6] ? row[6] : ""; + entry.login_server_admin_id = atoi(row[7]); + entry.is_server_trusted = atoi(row[8]); + entry.note = row[9] ? 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_LOGIN_WORLD_SERVERS_REPOSITORY_H diff --git a/common/repositories/base/base_logsys_categories_repository.h b/common/repositories/base/base_logsys_categories_repository.h new file mode 100644 index 000000000..dff017855 --- /dev/null +++ b/common/repositories/base/base_logsys_categories_repository.h @@ -0,0 +1,333 @@ +/** + * 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 on Apr 5, 2020 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_LOGSYS_CATEGORIES_REPOSITORY_H +#define EQEMU_BASE_LOGSYS_CATEGORIES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseLogsysCategoriesRepository { +public: + struct LogsysCategories { + int log_category_id; + std::string log_category_description; + int16 log_to_console; + int16 log_to_file; + int16 log_to_gmsay; + }; + + static std::string PrimaryKey() + { + return std::string("log_category_id"); + } + + static std::vector Columns() + { + return { + "log_category_id", + "log_category_description", + "log_to_console", + "log_to_file", + "log_to_gmsay", + }; + } + + 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("logsys_categories"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static LogsysCategories NewEntity() + { + LogsysCategories entry{}; + + entry.log_category_id = 0; + entry.log_category_description = ""; + entry.log_to_console = 0; + entry.log_to_file = 0; + entry.log_to_gmsay = 0; + + return entry; + } + + static LogsysCategories GetLogsysCategoriesEntry( + const std::vector &logsys_categoriess, + int logsys_categories_id + ) + { + for (auto &logsys_categories : logsys_categoriess) { + if (logsys_categories.log_category_id == logsys_categories_id) { + return logsys_categories; + } + } + + return NewEntity(); + } + + static LogsysCategories FindOne( + int logsys_categories_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + logsys_categories_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + LogsysCategories entry{}; + + entry.log_category_id = atoi(row[0]); + entry.log_category_description = row[1] ? row[1] : ""; + entry.log_to_console = atoi(row[2]); + entry.log_to_file = atoi(row[3]); + entry.log_to_gmsay = atoi(row[4]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int logsys_categories_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + logsys_categories_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + LogsysCategories logsys_categories_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(logsys_categories_entry.log_category_description) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(logsys_categories_entry.log_to_console)); + update_values.push_back(columns[3] + " = " + std::to_string(logsys_categories_entry.log_to_file)); + update_values.push_back(columns[4] + " = " + std::to_string(logsys_categories_entry.log_to_gmsay)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + logsys_categories_entry.log_category_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static LogsysCategories InsertOne( + LogsysCategories logsys_categories_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(logsys_categories_entry.log_category_description) + "'"); + insert_values.push_back(std::to_string(logsys_categories_entry.log_to_console)); + insert_values.push_back(std::to_string(logsys_categories_entry.log_to_file)); + insert_values.push_back(std::to_string(logsys_categories_entry.log_to_gmsay)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + logsys_categories_entry.id = results.LastInsertedID(); + return logsys_categories_entry; + } + + logsys_categories_entry = NewEntity(); + + return logsys_categories_entry; + } + + static int InsertMany( + std::vector logsys_categories_entries + ) + { + std::vector insert_chunks; + + for (auto &logsys_categories_entry: logsys_categories_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(logsys_categories_entry.log_category_description) + "'"); + insert_values.push_back(std::to_string(logsys_categories_entry.log_to_console)); + insert_values.push_back(std::to_string(logsys_categories_entry.log_to_file)); + insert_values.push_back(std::to_string(logsys_categories_entry.log_to_gmsay)); + + 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) { + LogsysCategories entry{}; + + entry.log_category_id = atoi(row[0]); + entry.log_category_description = row[1] ? row[1] : ""; + entry.log_to_console = atoi(row[2]); + entry.log_to_file = atoi(row[3]); + entry.log_to_gmsay = atoi(row[4]); + + 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) { + LogsysCategories entry{}; + + entry.log_category_id = atoi(row[0]); + entry.log_category_description = row[1] ? row[1] : ""; + entry.log_to_console = atoi(row[2]); + entry.log_to_file = atoi(row[3]); + entry.log_to_gmsay = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_LOGSYS_CATEGORIES_REPOSITORY_H diff --git a/common/repositories/base/base_lootdrop_entries_repository.h b/common/repositories/base/base_lootdrop_entries_repository.h new file mode 100644 index 000000000..67ab318d6 --- /dev/null +++ b/common/repositories/base/base_lootdrop_entries_repository.h @@ -0,0 +1,366 @@ +/** + * 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 on Apr 5, 2020 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_LOOTDROP_ENTRIES_REPOSITORY_H +#define EQEMU_BASE_LOOTDROP_ENTRIES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseLootdropEntriesRepository { +public: + struct LootdropEntries { + int lootdrop_id; + int item_id; + int16 item_charges; + int8 equip_item; + float chance; + float disabled_chance; + int8 minlevel; + int8 maxlevel; + int8 multiplier; + }; + + static std::string PrimaryKey() + { + return std::string("item_id"); + } + + static std::vector Columns() + { + return { + "lootdrop_id", + "item_id", + "item_charges", + "equip_item", + "chance", + "disabled_chance", + "minlevel", + "maxlevel", + "multiplier", + }; + } + + 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("lootdrop_entries"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static LootdropEntries NewEntity() + { + LootdropEntries entry{}; + + entry.lootdrop_id = 0; + entry.item_id = 0; + entry.item_charges = 1; + entry.equip_item = 0; + entry.chance = 1; + entry.disabled_chance = 0; + entry.minlevel = 0; + entry.maxlevel = 127; + entry.multiplier = 1; + + return entry; + } + + static LootdropEntries GetLootdropEntriesEntry( + const std::vector &lootdrop_entriess, + int lootdrop_entries_id + ) + { + for (auto &lootdrop_entries : lootdrop_entriess) { + if (lootdrop_entries.item_id == lootdrop_entries_id) { + return lootdrop_entries; + } + } + + return NewEntity(); + } + + static LootdropEntries FindOne( + int lootdrop_entries_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + lootdrop_entries_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + LootdropEntries entry{}; + + entry.lootdrop_id = atoi(row[0]); + entry.item_id = atoi(row[1]); + entry.item_charges = atoi(row[2]); + entry.equip_item = atoi(row[3]); + entry.chance = atof(row[4]); + entry.disabled_chance = atof(row[5]); + entry.minlevel = atoi(row[6]); + entry.maxlevel = atoi(row[7]); + entry.multiplier = atoi(row[8]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int lootdrop_entries_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + lootdrop_entries_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + LootdropEntries lootdrop_entries_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = " + std::to_string(lootdrop_entries_entry.item_charges)); + update_values.push_back(columns[3] + " = " + std::to_string(lootdrop_entries_entry.equip_item)); + update_values.push_back(columns[4] + " = " + std::to_string(lootdrop_entries_entry.chance)); + update_values.push_back(columns[5] + " = " + std::to_string(lootdrop_entries_entry.disabled_chance)); + update_values.push_back(columns[6] + " = " + std::to_string(lootdrop_entries_entry.minlevel)); + update_values.push_back(columns[7] + " = " + std::to_string(lootdrop_entries_entry.maxlevel)); + update_values.push_back(columns[8] + " = " + std::to_string(lootdrop_entries_entry.multiplier)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + lootdrop_entries_entry.item_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static LootdropEntries InsertOne( + LootdropEntries lootdrop_entries_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(lootdrop_entries_entry.item_charges)); + insert_values.push_back(std::to_string(lootdrop_entries_entry.equip_item)); + insert_values.push_back(std::to_string(lootdrop_entries_entry.chance)); + insert_values.push_back(std::to_string(lootdrop_entries_entry.disabled_chance)); + insert_values.push_back(std::to_string(lootdrop_entries_entry.minlevel)); + insert_values.push_back(std::to_string(lootdrop_entries_entry.maxlevel)); + insert_values.push_back(std::to_string(lootdrop_entries_entry.multiplier)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + lootdrop_entries_entry.id = results.LastInsertedID(); + return lootdrop_entries_entry; + } + + lootdrop_entries_entry = NewEntity(); + + return lootdrop_entries_entry; + } + + static int InsertMany( + std::vector lootdrop_entries_entries + ) + { + std::vector insert_chunks; + + for (auto &lootdrop_entries_entry: lootdrop_entries_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(lootdrop_entries_entry.item_charges)); + insert_values.push_back(std::to_string(lootdrop_entries_entry.equip_item)); + insert_values.push_back(std::to_string(lootdrop_entries_entry.chance)); + insert_values.push_back(std::to_string(lootdrop_entries_entry.disabled_chance)); + insert_values.push_back(std::to_string(lootdrop_entries_entry.minlevel)); + insert_values.push_back(std::to_string(lootdrop_entries_entry.maxlevel)); + insert_values.push_back(std::to_string(lootdrop_entries_entry.multiplier)); + + 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) { + LootdropEntries entry{}; + + entry.lootdrop_id = atoi(row[0]); + entry.item_id = atoi(row[1]); + entry.item_charges = atoi(row[2]); + entry.equip_item = atoi(row[3]); + entry.chance = atof(row[4]); + entry.disabled_chance = atof(row[5]); + entry.minlevel = atoi(row[6]); + entry.maxlevel = atoi(row[7]); + entry.multiplier = 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 = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + LootdropEntries entry{}; + + entry.lootdrop_id = atoi(row[0]); + entry.item_id = atoi(row[1]); + entry.item_charges = atoi(row[2]); + entry.equip_item = atoi(row[3]); + entry.chance = atof(row[4]); + entry.disabled_chance = atof(row[5]); + entry.minlevel = atoi(row[6]); + entry.maxlevel = atoi(row[7]); + entry.multiplier = atoi(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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_LOOTDROP_ENTRIES_REPOSITORY_H diff --git a/common/repositories/base/base_lootdrop_repository.h b/common/repositories/base/base_lootdrop_repository.h new file mode 100644 index 000000000..3ee90b6da --- /dev/null +++ b/common/repositories/base/base_lootdrop_repository.h @@ -0,0 +1,333 @@ +/** + * 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 on Apr 5, 2020 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_LOOTDROP_REPOSITORY_H +#define EQEMU_BASE_LOOTDROP_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseLootdropRepository { +public: + struct Lootdrop { + int id; + std::string name; + int8 min_expansion; + int8 max_expansion; + std::string content_flags; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "name", + "min_expansion", + "max_expansion", + "content_flags", + }; + } + + 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("lootdrop"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Lootdrop NewEntity() + { + Lootdrop entry{}; + + entry.id = 0; + entry.name = ""; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; + + return entry; + } + + static Lootdrop GetLootdropEntry( + const std::vector &lootdrops, + int lootdrop_id + ) + { + for (auto &lootdrop : lootdrops) { + if (lootdrop.id == lootdrop_id) { + return lootdrop; + } + } + + return NewEntity(); + } + + static Lootdrop FindOne( + int lootdrop_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + lootdrop_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Lootdrop entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.min_expansion = atoi(row[2]); + entry.max_expansion = atoi(row[3]); + entry.content_flags = row[4] ? row[4] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int lootdrop_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + lootdrop_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Lootdrop lootdrop_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(lootdrop_entry.name) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(lootdrop_entry.min_expansion)); + update_values.push_back(columns[3] + " = " + std::to_string(lootdrop_entry.max_expansion)); + update_values.push_back(columns[4] + " = '" + EscapeString(lootdrop_entry.content_flags) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + lootdrop_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Lootdrop InsertOne( + Lootdrop lootdrop_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(lootdrop_entry.name) + "'"); + insert_values.push_back(std::to_string(lootdrop_entry.min_expansion)); + insert_values.push_back(std::to_string(lootdrop_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(lootdrop_entry.content_flags) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + lootdrop_entry.id = results.LastInsertedID(); + return lootdrop_entry; + } + + lootdrop_entry = NewEntity(); + + return lootdrop_entry; + } + + static int InsertMany( + std::vector lootdrop_entries + ) + { + std::vector insert_chunks; + + for (auto &lootdrop_entry: lootdrop_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(lootdrop_entry.name) + "'"); + insert_values.push_back(std::to_string(lootdrop_entry.min_expansion)); + insert_values.push_back(std::to_string(lootdrop_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(lootdrop_entry.content_flags) + "'"); + + 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) { + Lootdrop entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.min_expansion = atoi(row[2]); + entry.max_expansion = atoi(row[3]); + entry.content_flags = row[4] ? row[4] : ""; + + 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) { + Lootdrop entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.min_expansion = atoi(row[2]); + entry.max_expansion = atoi(row[3]); + entry.content_flags = row[4] ? 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_LOOTDROP_REPOSITORY_H diff --git a/common/repositories/base/base_loottable_entries_repository.h b/common/repositories/base/base_loottable_entries_repository.h new file mode 100644 index 000000000..fc4542934 --- /dev/null +++ b/common/repositories/base/base_loottable_entries_repository.h @@ -0,0 +1,339 @@ +/** + * 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 on Apr 5, 2020 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_LOOTTABLE_ENTRIES_REPOSITORY_H +#define EQEMU_BASE_LOOTTABLE_ENTRIES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseLoottableEntriesRepository { +public: + struct LoottableEntries { + int loottable_id; + int lootdrop_id; + int8 multiplier; + int8 droplimit; + int8 mindrop; + float probability; + }; + + static std::string PrimaryKey() + { + return std::string("lootdrop_id"); + } + + static std::vector Columns() + { + return { + "loottable_id", + "lootdrop_id", + "multiplier", + "droplimit", + "mindrop", + "probability", + }; + } + + 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("loottable_entries"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static LoottableEntries NewEntity() + { + LoottableEntries entry{}; + + entry.loottable_id = 0; + entry.lootdrop_id = 0; + entry.multiplier = 1; + entry.droplimit = 0; + entry.mindrop = 0; + entry.probability = 100; + + return entry; + } + + static LoottableEntries GetLoottableEntriesEntry( + const std::vector &loottable_entriess, + int loottable_entries_id + ) + { + for (auto &loottable_entries : loottable_entriess) { + if (loottable_entries.lootdrop_id == loottable_entries_id) { + return loottable_entries; + } + } + + return NewEntity(); + } + + static LoottableEntries FindOne( + int loottable_entries_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + loottable_entries_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + LoottableEntries entry{}; + + entry.loottable_id = atoi(row[0]); + entry.lootdrop_id = atoi(row[1]); + entry.multiplier = atoi(row[2]); + entry.droplimit = atoi(row[3]); + entry.mindrop = atoi(row[4]); + entry.probability = atof(row[5]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int loottable_entries_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + loottable_entries_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + LoottableEntries loottable_entries_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = " + std::to_string(loottable_entries_entry.multiplier)); + update_values.push_back(columns[3] + " = " + std::to_string(loottable_entries_entry.droplimit)); + update_values.push_back(columns[4] + " = " + std::to_string(loottable_entries_entry.mindrop)); + update_values.push_back(columns[5] + " = " + std::to_string(loottable_entries_entry.probability)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + loottable_entries_entry.lootdrop_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static LoottableEntries InsertOne( + LoottableEntries loottable_entries_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(loottable_entries_entry.multiplier)); + insert_values.push_back(std::to_string(loottable_entries_entry.droplimit)); + insert_values.push_back(std::to_string(loottable_entries_entry.mindrop)); + insert_values.push_back(std::to_string(loottable_entries_entry.probability)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + loottable_entries_entry.id = results.LastInsertedID(); + return loottable_entries_entry; + } + + loottable_entries_entry = NewEntity(); + + return loottable_entries_entry; + } + + static int InsertMany( + std::vector loottable_entries_entries + ) + { + std::vector insert_chunks; + + for (auto &loottable_entries_entry: loottable_entries_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(loottable_entries_entry.multiplier)); + insert_values.push_back(std::to_string(loottable_entries_entry.droplimit)); + insert_values.push_back(std::to_string(loottable_entries_entry.mindrop)); + insert_values.push_back(std::to_string(loottable_entries_entry.probability)); + + 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) { + LoottableEntries entry{}; + + entry.loottable_id = atoi(row[0]); + entry.lootdrop_id = atoi(row[1]); + entry.multiplier = atoi(row[2]); + entry.droplimit = atoi(row[3]); + entry.mindrop = atoi(row[4]); + entry.probability = atof(row[5]); + + 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) { + LoottableEntries entry{}; + + entry.loottable_id = atoi(row[0]); + entry.lootdrop_id = atoi(row[1]); + entry.multiplier = atoi(row[2]); + entry.droplimit = atoi(row[3]); + entry.mindrop = atoi(row[4]); + entry.probability = atof(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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_LOOTTABLE_ENTRIES_REPOSITORY_H diff --git a/common/repositories/base/base_loottable_repository.h b/common/repositories/base/base_loottable_repository.h new file mode 100644 index 000000000..f04f18f69 --- /dev/null +++ b/common/repositories/base/base_loottable_repository.h @@ -0,0 +1,369 @@ +/** + * 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 on Apr 5, 2020 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_LOOTTABLE_REPOSITORY_H +#define EQEMU_BASE_LOOTTABLE_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseLoottableRepository { +public: + struct Loottable { + int id; + std::string name; + int mincash; + int maxcash; + int avgcoin; + int8 done; + int8 min_expansion; + int8 max_expansion; + std::string content_flags; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "name", + "mincash", + "maxcash", + "avgcoin", + "done", + "min_expansion", + "max_expansion", + "content_flags", + }; + } + + 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("loottable"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Loottable NewEntity() + { + Loottable entry{}; + + entry.id = 0; + entry.name = ""; + entry.mincash = 0; + entry.maxcash = 0; + entry.avgcoin = 0; + entry.done = 0; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; + + return entry; + } + + static Loottable GetLoottableEntry( + const std::vector &loottables, + int loottable_id + ) + { + for (auto &loottable : loottables) { + if (loottable.id == loottable_id) { + return loottable; + } + } + + return NewEntity(); + } + + static Loottable FindOne( + int loottable_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + loottable_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Loottable entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.mincash = atoi(row[2]); + entry.maxcash = atoi(row[3]); + entry.avgcoin = atoi(row[4]); + entry.done = atoi(row[5]); + entry.min_expansion = atoi(row[6]); + entry.max_expansion = atoi(row[7]); + entry.content_flags = row[8] ? row[8] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int loottable_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + loottable_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Loottable loottable_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(loottable_entry.name) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(loottable_entry.mincash)); + update_values.push_back(columns[3] + " = " + std::to_string(loottable_entry.maxcash)); + update_values.push_back(columns[4] + " = " + std::to_string(loottable_entry.avgcoin)); + update_values.push_back(columns[5] + " = " + std::to_string(loottable_entry.done)); + update_values.push_back(columns[6] + " = " + std::to_string(loottable_entry.min_expansion)); + update_values.push_back(columns[7] + " = " + std::to_string(loottable_entry.max_expansion)); + update_values.push_back(columns[8] + " = '" + EscapeString(loottable_entry.content_flags) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + loottable_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Loottable InsertOne( + Loottable loottable_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(loottable_entry.name) + "'"); + insert_values.push_back(std::to_string(loottable_entry.mincash)); + insert_values.push_back(std::to_string(loottable_entry.maxcash)); + insert_values.push_back(std::to_string(loottable_entry.avgcoin)); + insert_values.push_back(std::to_string(loottable_entry.done)); + insert_values.push_back(std::to_string(loottable_entry.min_expansion)); + insert_values.push_back(std::to_string(loottable_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(loottable_entry.content_flags) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + loottable_entry.id = results.LastInsertedID(); + return loottable_entry; + } + + loottable_entry = NewEntity(); + + return loottable_entry; + } + + static int InsertMany( + std::vector loottable_entries + ) + { + std::vector insert_chunks; + + for (auto &loottable_entry: loottable_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(loottable_entry.name) + "'"); + insert_values.push_back(std::to_string(loottable_entry.mincash)); + insert_values.push_back(std::to_string(loottable_entry.maxcash)); + insert_values.push_back(std::to_string(loottable_entry.avgcoin)); + insert_values.push_back(std::to_string(loottable_entry.done)); + insert_values.push_back(std::to_string(loottable_entry.min_expansion)); + insert_values.push_back(std::to_string(loottable_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(loottable_entry.content_flags) + "'"); + + 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) { + Loottable entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.mincash = atoi(row[2]); + entry.maxcash = atoi(row[3]); + entry.avgcoin = atoi(row[4]); + entry.done = atoi(row[5]); + entry.min_expansion = atoi(row[6]); + entry.max_expansion = atoi(row[7]); + entry.content_flags = row[8] ? row[8] : ""; + + 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) { + Loottable entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.mincash = atoi(row[2]); + entry.maxcash = atoi(row[3]); + entry.avgcoin = atoi(row[4]); + entry.done = atoi(row[5]); + entry.min_expansion = atoi(row[6]); + entry.max_expansion = atoi(row[7]); + entry.content_flags = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_LOOTTABLE_REPOSITORY_H diff --git a/common/repositories/base/base_mail_repository.h b/common/repositories/base/base_mail_repository.h new file mode 100644 index 000000000..e8f362c34 --- /dev/null +++ b/common/repositories/base/base_mail_repository.h @@ -0,0 +1,360 @@ +/** + * 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 on Apr 5, 2020 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_MAIL_REPOSITORY_H +#define EQEMU_BASE_MAIL_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseMailRepository { +public: + struct Mail { + int msgid; + int charid; + int timestamp; + std::string from; + std::string subject; + std::string body; + std::string to; + int8 status; + }; + + static std::string PrimaryKey() + { + return std::string("msgid"); + } + + static std::vector Columns() + { + return { + "msgid", + "charid", + "timestamp", + "from", + "subject", + "body", + "to", + "status", + }; + } + + 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("mail"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Mail NewEntity() + { + Mail entry{}; + + entry.msgid = 0; + entry.charid = 0; + entry.timestamp = 0; + entry.from = ""; + entry.subject = ""; + entry.body = ""; + entry.to = ""; + entry.status = 0; + + return entry; + } + + static Mail GetMailEntry( + const std::vector &mails, + int mail_id + ) + { + for (auto &mail : mails) { + if (mail.msgid == mail_id) { + return mail; + } + } + + return NewEntity(); + } + + static Mail FindOne( + int mail_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + mail_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Mail entry{}; + + entry.msgid = atoi(row[0]); + entry.charid = atoi(row[1]); + entry.timestamp = atoi(row[2]); + entry.from = row[3] ? row[3] : ""; + entry.subject = row[4] ? row[4] : ""; + entry.body = row[5] ? row[5] : ""; + entry.to = row[6] ? row[6] : ""; + entry.status = atoi(row[7]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int mail_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + mail_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Mail mail_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(mail_entry.charid)); + update_values.push_back(columns[2] + " = " + std::to_string(mail_entry.timestamp)); + update_values.push_back(columns[3] + " = '" + EscapeString(mail_entry.from) + "'"); + update_values.push_back(columns[4] + " = '" + EscapeString(mail_entry.subject) + "'"); + update_values.push_back(columns[5] + " = '" + EscapeString(mail_entry.body) + "'"); + update_values.push_back(columns[6] + " = '" + EscapeString(mail_entry.to) + "'"); + update_values.push_back(columns[7] + " = " + std::to_string(mail_entry.status)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + mail_entry.msgid + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Mail InsertOne( + Mail mail_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(mail_entry.charid)); + insert_values.push_back(std::to_string(mail_entry.timestamp)); + insert_values.push_back("'" + EscapeString(mail_entry.from) + "'"); + insert_values.push_back("'" + EscapeString(mail_entry.subject) + "'"); + insert_values.push_back("'" + EscapeString(mail_entry.body) + "'"); + insert_values.push_back("'" + EscapeString(mail_entry.to) + "'"); + insert_values.push_back(std::to_string(mail_entry.status)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + mail_entry.id = results.LastInsertedID(); + return mail_entry; + } + + mail_entry = NewEntity(); + + return mail_entry; + } + + static int InsertMany( + std::vector mail_entries + ) + { + std::vector insert_chunks; + + for (auto &mail_entry: mail_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(mail_entry.charid)); + insert_values.push_back(std::to_string(mail_entry.timestamp)); + insert_values.push_back("'" + EscapeString(mail_entry.from) + "'"); + insert_values.push_back("'" + EscapeString(mail_entry.subject) + "'"); + insert_values.push_back("'" + EscapeString(mail_entry.body) + "'"); + insert_values.push_back("'" + EscapeString(mail_entry.to) + "'"); + insert_values.push_back(std::to_string(mail_entry.status)); + + 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) { + Mail entry{}; + + entry.msgid = atoi(row[0]); + entry.charid = atoi(row[1]); + entry.timestamp = atoi(row[2]); + entry.from = row[3] ? row[3] : ""; + entry.subject = row[4] ? row[4] : ""; + entry.body = row[5] ? row[5] : ""; + entry.to = row[6] ? row[6] : ""; + entry.status = atoi(row[7]); + + 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) { + Mail entry{}; + + entry.msgid = atoi(row[0]); + entry.charid = atoi(row[1]); + entry.timestamp = atoi(row[2]); + entry.from = row[3] ? row[3] : ""; + entry.subject = row[4] ? row[4] : ""; + entry.body = row[5] ? row[5] : ""; + entry.to = row[6] ? row[6] : ""; + entry.status = atoi(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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_MAIL_REPOSITORY_H diff --git a/common/repositories/base/base_merchantlist_repository.h b/common/repositories/base/base_merchantlist_repository.h new file mode 100644 index 000000000..d4dd17828 --- /dev/null +++ b/common/repositories/base/base_merchantlist_repository.h @@ -0,0 +1,384 @@ +/** + * 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 on Apr 5, 2020 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_MERCHANTLIST_REPOSITORY_H +#define EQEMU_BASE_MERCHANTLIST_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseMerchantlistRepository { +public: + struct Merchantlist { + int merchantid; + int slot; + int item; + int16 faction_required; + int8 level_required; + int16 alt_currency_cost; + int classes_required; + int probability; + int8 min_expansion; + int8 max_expansion; + std::string content_flags; + }; + + static std::string PrimaryKey() + { + return std::string("slot"); + } + + static std::vector Columns() + { + return { + "merchantid", + "slot", + "item", + "faction_required", + "level_required", + "alt_currency_cost", + "classes_required", + "probability", + "min_expansion", + "max_expansion", + "content_flags", + }; + } + + 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("merchantlist"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Merchantlist NewEntity() + { + Merchantlist entry{}; + + entry.merchantid = 0; + entry.slot = 0; + entry.item = 0; + entry.faction_required = -100; + entry.level_required = 0; + entry.alt_currency_cost = 0; + entry.classes_required = 65535; + entry.probability = 100; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; + + return entry; + } + + static Merchantlist GetMerchantlistEntry( + const std::vector &merchantlists, + int merchantlist_id + ) + { + for (auto &merchantlist : merchantlists) { + if (merchantlist.slot == merchantlist_id) { + return merchantlist; + } + } + + return NewEntity(); + } + + static Merchantlist FindOne( + int merchantlist_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + merchantlist_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Merchantlist entry{}; + + entry.merchantid = atoi(row[0]); + entry.slot = atoi(row[1]); + entry.item = atoi(row[2]); + entry.faction_required = atoi(row[3]); + entry.level_required = atoi(row[4]); + entry.alt_currency_cost = atoi(row[5]); + entry.classes_required = atoi(row[6]); + entry.probability = atoi(row[7]); + entry.min_expansion = atoi(row[8]); + entry.max_expansion = atoi(row[9]); + entry.content_flags = row[10] ? row[10] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int merchantlist_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + merchantlist_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Merchantlist merchantlist_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = " + std::to_string(merchantlist_entry.item)); + update_values.push_back(columns[3] + " = " + std::to_string(merchantlist_entry.faction_required)); + update_values.push_back(columns[4] + " = " + std::to_string(merchantlist_entry.level_required)); + update_values.push_back(columns[5] + " = " + std::to_string(merchantlist_entry.alt_currency_cost)); + update_values.push_back(columns[6] + " = " + std::to_string(merchantlist_entry.classes_required)); + update_values.push_back(columns[7] + " = " + std::to_string(merchantlist_entry.probability)); + update_values.push_back(columns[8] + " = " + std::to_string(merchantlist_entry.min_expansion)); + update_values.push_back(columns[9] + " = " + std::to_string(merchantlist_entry.max_expansion)); + update_values.push_back(columns[10] + " = '" + EscapeString(merchantlist_entry.content_flags) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + merchantlist_entry.slot + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Merchantlist InsertOne( + Merchantlist merchantlist_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(merchantlist_entry.item)); + insert_values.push_back(std::to_string(merchantlist_entry.faction_required)); + insert_values.push_back(std::to_string(merchantlist_entry.level_required)); + insert_values.push_back(std::to_string(merchantlist_entry.alt_currency_cost)); + insert_values.push_back(std::to_string(merchantlist_entry.classes_required)); + insert_values.push_back(std::to_string(merchantlist_entry.probability)); + insert_values.push_back(std::to_string(merchantlist_entry.min_expansion)); + insert_values.push_back(std::to_string(merchantlist_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(merchantlist_entry.content_flags) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + merchantlist_entry.id = results.LastInsertedID(); + return merchantlist_entry; + } + + merchantlist_entry = NewEntity(); + + return merchantlist_entry; + } + + static int InsertMany( + std::vector merchantlist_entries + ) + { + std::vector insert_chunks; + + for (auto &merchantlist_entry: merchantlist_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(merchantlist_entry.item)); + insert_values.push_back(std::to_string(merchantlist_entry.faction_required)); + insert_values.push_back(std::to_string(merchantlist_entry.level_required)); + insert_values.push_back(std::to_string(merchantlist_entry.alt_currency_cost)); + insert_values.push_back(std::to_string(merchantlist_entry.classes_required)); + insert_values.push_back(std::to_string(merchantlist_entry.probability)); + insert_values.push_back(std::to_string(merchantlist_entry.min_expansion)); + insert_values.push_back(std::to_string(merchantlist_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(merchantlist_entry.content_flags) + "'"); + + 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) { + Merchantlist entry{}; + + entry.merchantid = atoi(row[0]); + entry.slot = atoi(row[1]); + entry.item = atoi(row[2]); + entry.faction_required = atoi(row[3]); + entry.level_required = atoi(row[4]); + entry.alt_currency_cost = atoi(row[5]); + entry.classes_required = atoi(row[6]); + entry.probability = atoi(row[7]); + entry.min_expansion = atoi(row[8]); + entry.max_expansion = atoi(row[9]); + entry.content_flags = row[10] ? row[10] : ""; + + 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) { + Merchantlist entry{}; + + entry.merchantid = atoi(row[0]); + entry.slot = atoi(row[1]); + entry.item = atoi(row[2]); + entry.faction_required = atoi(row[3]); + entry.level_required = atoi(row[4]); + entry.alt_currency_cost = atoi(row[5]); + entry.classes_required = atoi(row[6]); + entry.probability = atoi(row[7]); + entry.min_expansion = atoi(row[8]); + entry.max_expansion = atoi(row[9]); + entry.content_flags = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_MERCHANTLIST_REPOSITORY_H diff --git a/common/repositories/base/base_merchantlist_temp_repository.h b/common/repositories/base/base_merchantlist_temp_repository.h new file mode 100644 index 000000000..0c5d06010 --- /dev/null +++ b/common/repositories/base/base_merchantlist_temp_repository.h @@ -0,0 +1,321 @@ +/** + * 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 on Apr 5, 2020 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_MERCHANTLIST_TEMP_REPOSITORY_H +#define EQEMU_BASE_MERCHANTLIST_TEMP_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseMerchantlistTempRepository { +public: + struct MerchantlistTemp { + int npcid; + int8 slot; + int itemid; + int charges; + }; + + static std::string PrimaryKey() + { + return std::string("slot"); + } + + static std::vector Columns() + { + return { + "npcid", + "slot", + "itemid", + "charges", + }; + } + + 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("merchantlist_temp"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static MerchantlistTemp NewEntity() + { + MerchantlistTemp entry{}; + + entry.npcid = 0; + entry.slot = 0; + entry.itemid = 0; + entry.charges = 1; + + return entry; + } + + static MerchantlistTemp GetMerchantlistTempEntry( + const std::vector &merchantlist_temps, + int merchantlist_temp_id + ) + { + for (auto &merchantlist_temp : merchantlist_temps) { + if (merchantlist_temp.slot == merchantlist_temp_id) { + return merchantlist_temp; + } + } + + return NewEntity(); + } + + static MerchantlistTemp FindOne( + int merchantlist_temp_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + merchantlist_temp_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + MerchantlistTemp entry{}; + + entry.npcid = atoi(row[0]); + entry.slot = atoi(row[1]); + entry.itemid = atoi(row[2]); + entry.charges = atoi(row[3]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int merchantlist_temp_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + merchantlist_temp_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + MerchantlistTemp merchantlist_temp_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = " + std::to_string(merchantlist_temp_entry.itemid)); + update_values.push_back(columns[3] + " = " + std::to_string(merchantlist_temp_entry.charges)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + merchantlist_temp_entry.slot + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static MerchantlistTemp InsertOne( + MerchantlistTemp merchantlist_temp_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(merchantlist_temp_entry.itemid)); + insert_values.push_back(std::to_string(merchantlist_temp_entry.charges)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + merchantlist_temp_entry.id = results.LastInsertedID(); + return merchantlist_temp_entry; + } + + merchantlist_temp_entry = NewEntity(); + + return merchantlist_temp_entry; + } + + static int InsertMany( + std::vector merchantlist_temp_entries + ) + { + std::vector insert_chunks; + + for (auto &merchantlist_temp_entry: merchantlist_temp_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(merchantlist_temp_entry.itemid)); + insert_values.push_back(std::to_string(merchantlist_temp_entry.charges)); + + 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) { + MerchantlistTemp entry{}; + + entry.npcid = atoi(row[0]); + entry.slot = atoi(row[1]); + entry.itemid = atoi(row[2]); + entry.charges = 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) { + MerchantlistTemp entry{}; + + entry.npcid = atoi(row[0]); + entry.slot = atoi(row[1]); + entry.itemid = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_MERCHANTLIST_TEMP_REPOSITORY_H diff --git a/common/repositories/base/base_name_filter_repository.h b/common/repositories/base/base_name_filter_repository.h new file mode 100644 index 000000000..a79fc338c --- /dev/null +++ b/common/repositories/base/base_name_filter_repository.h @@ -0,0 +1,306 @@ +/** + * 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 on Apr 5, 2020 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_NAME_FILTER_REPOSITORY_H +#define EQEMU_BASE_NAME_FILTER_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseNameFilterRepository { +public: + struct NameFilter { + int id; + std::string name; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "name", + }; + } + + 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("name_filter"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static NameFilter NewEntity() + { + NameFilter entry{}; + + entry.id = 0; + entry.name = ""; + + return entry; + } + + static NameFilter GetNameFilterEntry( + const std::vector &name_filters, + int name_filter_id + ) + { + for (auto &name_filter : name_filters) { + if (name_filter.id == name_filter_id) { + return name_filter; + } + } + + return NewEntity(); + } + + static NameFilter FindOne( + int name_filter_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + name_filter_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + NameFilter entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int name_filter_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + name_filter_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + NameFilter name_filter_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(name_filter_entry.name) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + name_filter_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static NameFilter InsertOne( + NameFilter name_filter_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(name_filter_entry.name) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + name_filter_entry.id = results.LastInsertedID(); + return name_filter_entry; + } + + name_filter_entry = NewEntity(); + + return name_filter_entry; + } + + static int InsertMany( + std::vector name_filter_entries + ) + { + std::vector insert_chunks; + + for (auto &name_filter_entry: name_filter_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(name_filter_entry.name) + "'"); + + 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) { + NameFilter entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + + 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) { + NameFilter entry{}; + + entry.id = atoi(row[0]); + entry.name = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_NAME_FILTER_REPOSITORY_H diff --git a/common/repositories/base/base_npc_emotes_repository.h b/common/repositories/base/base_npc_emotes_repository.h new file mode 100644 index 000000000..bb6567e8c --- /dev/null +++ b/common/repositories/base/base_npc_emotes_repository.h @@ -0,0 +1,333 @@ +/** + * 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 on Apr 5, 2020 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_NPC_EMOTES_REPOSITORY_H +#define EQEMU_BASE_NPC_EMOTES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseNpcEmotesRepository { +public: + struct NpcEmotes { + int id; + int emoteid; + int8 event_; + int8 type; + std::string text; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "emoteid", + "event_", + "type", + "text", + }; + } + + 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("npc_emotes"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static NpcEmotes NewEntity() + { + NpcEmotes entry{}; + + entry.id = 0; + entry.emoteid = 0; + entry.event_ = 0; + entry.type = 0; + entry.text = ""; + + return entry; + } + + static NpcEmotes GetNpcEmotesEntry( + const std::vector &npc_emotess, + int npc_emotes_id + ) + { + for (auto &npc_emotes : npc_emotess) { + if (npc_emotes.id == npc_emotes_id) { + return npc_emotes; + } + } + + return NewEntity(); + } + + static NpcEmotes FindOne( + int npc_emotes_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + npc_emotes_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + NpcEmotes entry{}; + + entry.id = atoi(row[0]); + entry.emoteid = atoi(row[1]); + entry.event_ = atoi(row[2]); + entry.type = atoi(row[3]); + entry.text = row[4] ? row[4] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int npc_emotes_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + npc_emotes_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + NpcEmotes npc_emotes_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(npc_emotes_entry.emoteid)); + update_values.push_back(columns[2] + " = " + std::to_string(npc_emotes_entry.event_)); + update_values.push_back(columns[3] + " = " + std::to_string(npc_emotes_entry.type)); + update_values.push_back(columns[4] + " = '" + EscapeString(npc_emotes_entry.text) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + npc_emotes_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static NpcEmotes InsertOne( + NpcEmotes npc_emotes_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(npc_emotes_entry.emoteid)); + insert_values.push_back(std::to_string(npc_emotes_entry.event_)); + insert_values.push_back(std::to_string(npc_emotes_entry.type)); + insert_values.push_back("'" + EscapeString(npc_emotes_entry.text) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + npc_emotes_entry.id = results.LastInsertedID(); + return npc_emotes_entry; + } + + npc_emotes_entry = NewEntity(); + + return npc_emotes_entry; + } + + static int InsertMany( + std::vector npc_emotes_entries + ) + { + std::vector insert_chunks; + + for (auto &npc_emotes_entry: npc_emotes_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(npc_emotes_entry.emoteid)); + insert_values.push_back(std::to_string(npc_emotes_entry.event_)); + insert_values.push_back(std::to_string(npc_emotes_entry.type)); + insert_values.push_back("'" + EscapeString(npc_emotes_entry.text) + "'"); + + 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) { + NpcEmotes entry{}; + + entry.id = atoi(row[0]); + entry.emoteid = atoi(row[1]); + entry.event_ = atoi(row[2]); + entry.type = atoi(row[3]); + entry.text = row[4] ? row[4] : ""; + + 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) { + NpcEmotes entry{}; + + entry.id = atoi(row[0]); + entry.emoteid = atoi(row[1]); + entry.event_ = atoi(row[2]); + entry.type = atoi(row[3]); + entry.text = row[4] ? 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_NPC_EMOTES_REPOSITORY_H diff --git a/common/repositories/base/base_npc_faction_entries_repository.h b/common/repositories/base/base_npc_faction_entries_repository.h new file mode 100644 index 000000000..64d07c6a9 --- /dev/null +++ b/common/repositories/base/base_npc_faction_entries_repository.h @@ -0,0 +1,330 @@ +/** + * 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 on Apr 5, 2020 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_NPC_FACTION_ENTRIES_REPOSITORY_H +#define EQEMU_BASE_NPC_FACTION_ENTRIES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseNpcFactionEntriesRepository { +public: + struct NpcFactionEntries { + int npc_faction_id; + int faction_id; + int value; + int8 npc_value; + int8 temp; + }; + + static std::string PrimaryKey() + { + return std::string("faction_id"); + } + + static std::vector Columns() + { + return { + "npc_faction_id", + "faction_id", + "value", + "npc_value", + "temp", + }; + } + + 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("npc_faction_entries"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static NpcFactionEntries NewEntity() + { + NpcFactionEntries entry{}; + + entry.npc_faction_id = 0; + entry.faction_id = 0; + entry.value = 0; + entry.npc_value = 0; + entry.temp = 0; + + return entry; + } + + static NpcFactionEntries GetNpcFactionEntriesEntry( + const std::vector &npc_faction_entriess, + int npc_faction_entries_id + ) + { + for (auto &npc_faction_entries : npc_faction_entriess) { + if (npc_faction_entries.faction_id == npc_faction_entries_id) { + return npc_faction_entries; + } + } + + return NewEntity(); + } + + static NpcFactionEntries FindOne( + int npc_faction_entries_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + npc_faction_entries_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + NpcFactionEntries entry{}; + + entry.npc_faction_id = atoi(row[0]); + entry.faction_id = atoi(row[1]); + entry.value = atoi(row[2]); + entry.npc_value = atoi(row[3]); + entry.temp = atoi(row[4]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int npc_faction_entries_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + npc_faction_entries_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + NpcFactionEntries npc_faction_entries_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = " + std::to_string(npc_faction_entries_entry.value)); + update_values.push_back(columns[3] + " = " + std::to_string(npc_faction_entries_entry.npc_value)); + update_values.push_back(columns[4] + " = " + std::to_string(npc_faction_entries_entry.temp)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + npc_faction_entries_entry.faction_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static NpcFactionEntries InsertOne( + NpcFactionEntries npc_faction_entries_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(npc_faction_entries_entry.value)); + insert_values.push_back(std::to_string(npc_faction_entries_entry.npc_value)); + insert_values.push_back(std::to_string(npc_faction_entries_entry.temp)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + npc_faction_entries_entry.id = results.LastInsertedID(); + return npc_faction_entries_entry; + } + + npc_faction_entries_entry = NewEntity(); + + return npc_faction_entries_entry; + } + + static int InsertMany( + std::vector npc_faction_entries_entries + ) + { + std::vector insert_chunks; + + for (auto &npc_faction_entries_entry: npc_faction_entries_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(npc_faction_entries_entry.value)); + insert_values.push_back(std::to_string(npc_faction_entries_entry.npc_value)); + insert_values.push_back(std::to_string(npc_faction_entries_entry.temp)); + + 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) { + NpcFactionEntries entry{}; + + entry.npc_faction_id = atoi(row[0]); + entry.faction_id = atoi(row[1]); + entry.value = atoi(row[2]); + entry.npc_value = atoi(row[3]); + entry.temp = atoi(row[4]); + + 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) { + NpcFactionEntries entry{}; + + entry.npc_faction_id = atoi(row[0]); + entry.faction_id = atoi(row[1]); + entry.value = atoi(row[2]); + entry.npc_value = atoi(row[3]); + entry.temp = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_NPC_FACTION_ENTRIES_REPOSITORY_H diff --git a/common/repositories/base/base_npc_faction_repository.h b/common/repositories/base/base_npc_faction_repository.h new file mode 100644 index 000000000..dc5f89300 --- /dev/null +++ b/common/repositories/base/base_npc_faction_repository.h @@ -0,0 +1,324 @@ +/** + * 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 on Apr 5, 2020 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_NPC_FACTION_REPOSITORY_H +#define EQEMU_BASE_NPC_FACTION_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseNpcFactionRepository { +public: + struct NpcFaction { + int id; + std::string name; + int primaryfaction; + int8 ignore_primary_assist; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "name", + "primaryfaction", + "ignore_primary_assist", + }; + } + + 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("npc_faction"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static NpcFaction NewEntity() + { + NpcFaction entry{}; + + entry.id = 0; + entry.name = ""; + entry.primaryfaction = 0; + entry.ignore_primary_assist = 0; + + return entry; + } + + static NpcFaction GetNpcFactionEntry( + const std::vector &npc_factions, + int npc_faction_id + ) + { + for (auto &npc_faction : npc_factions) { + if (npc_faction.id == npc_faction_id) { + return npc_faction; + } + } + + return NewEntity(); + } + + static NpcFaction FindOne( + int npc_faction_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + npc_faction_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + NpcFaction entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.primaryfaction = atoi(row[2]); + entry.ignore_primary_assist = atoi(row[3]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int npc_faction_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + npc_faction_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + NpcFaction npc_faction_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(npc_faction_entry.name) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(npc_faction_entry.primaryfaction)); + update_values.push_back(columns[3] + " = " + std::to_string(npc_faction_entry.ignore_primary_assist)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + npc_faction_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static NpcFaction InsertOne( + NpcFaction npc_faction_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(npc_faction_entry.name) + "'"); + insert_values.push_back(std::to_string(npc_faction_entry.primaryfaction)); + insert_values.push_back(std::to_string(npc_faction_entry.ignore_primary_assist)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + npc_faction_entry.id = results.LastInsertedID(); + return npc_faction_entry; + } + + npc_faction_entry = NewEntity(); + + return npc_faction_entry; + } + + static int InsertMany( + std::vector npc_faction_entries + ) + { + std::vector insert_chunks; + + for (auto &npc_faction_entry: npc_faction_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(npc_faction_entry.name) + "'"); + insert_values.push_back(std::to_string(npc_faction_entry.primaryfaction)); + insert_values.push_back(std::to_string(npc_faction_entry.ignore_primary_assist)); + + 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) { + NpcFaction entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.primaryfaction = atoi(row[2]); + entry.ignore_primary_assist = 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 = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + NpcFaction entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.primaryfaction = atoi(row[2]); + entry.ignore_primary_assist = atoi(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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_NPC_FACTION_REPOSITORY_H diff --git a/common/repositories/base/base_npc_scale_global_base_repository.h b/common/repositories/base/base_npc_scale_global_base_repository.h new file mode 100644 index 000000000..543fa6261 --- /dev/null +++ b/common/repositories/base/base_npc_scale_global_base_repository.h @@ -0,0 +1,537 @@ +/** + * 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 on Apr 5, 2020 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_NPC_SCALE_GLOBAL_BASE_REPOSITORY_H +#define EQEMU_BASE_NPC_SCALE_GLOBAL_BASE_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseNpcScaleGlobalBaseRepository { +public: + struct NpcScaleGlobalBase { + int type; + int level; + int ac; + int hp; + int accuracy; + int slow_mitigation; + int attack; + int strength; + int stamina; + int dexterity; + int agility; + int intelligence; + int wisdom; + int charisma; + int magic_resist; + int cold_resist; + int fire_resist; + int poison_resist; + int disease_resist; + int corruption_resist; + int physical_resist; + int min_dmg; + int max_dmg; + int hp_regen_rate; + int attack_delay; + int spell_scale; + int heal_scale; + std::string special_abilities; + }; + + static std::string PrimaryKey() + { + return std::string("level"); + } + + static std::vector Columns() + { + return { + "type", + "level", + "ac", + "hp", + "accuracy", + "slow_mitigation", + "attack", + "strength", + "stamina", + "dexterity", + "agility", + "intelligence", + "wisdom", + "charisma", + "magic_resist", + "cold_resist", + "fire_resist", + "poison_resist", + "disease_resist", + "corruption_resist", + "physical_resist", + "min_dmg", + "max_dmg", + "hp_regen_rate", + "attack_delay", + "spell_scale", + "heal_scale", + "special_abilities", + }; + } + + 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("npc_scale_global_base"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static NpcScaleGlobalBase NewEntity() + { + NpcScaleGlobalBase entry{}; + + entry.type = 0; + entry.level = 0; + entry.ac = 0; + entry.hp = 0; + entry.accuracy = 0; + entry.slow_mitigation = 0; + entry.attack = 0; + entry.strength = 0; + entry.stamina = 0; + entry.dexterity = 0; + entry.agility = 0; + entry.intelligence = 0; + entry.wisdom = 0; + entry.charisma = 0; + entry.magic_resist = 0; + entry.cold_resist = 0; + entry.fire_resist = 0; + entry.poison_resist = 0; + entry.disease_resist = 0; + entry.corruption_resist = 0; + entry.physical_resist = 0; + entry.min_dmg = 0; + entry.max_dmg = 0; + entry.hp_regen_rate = 0; + entry.attack_delay = 0; + entry.spell_scale = 100; + entry.heal_scale = 100; + entry.special_abilities = ""; + + return entry; + } + + static NpcScaleGlobalBase GetNpcScaleGlobalBaseEntry( + const std::vector &npc_scale_global_bases, + int npc_scale_global_base_id + ) + { + for (auto &npc_scale_global_base : npc_scale_global_bases) { + if (npc_scale_global_base.level == npc_scale_global_base_id) { + return npc_scale_global_base; + } + } + + return NewEntity(); + } + + static NpcScaleGlobalBase FindOne( + int npc_scale_global_base_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + npc_scale_global_base_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + NpcScaleGlobalBase entry{}; + + entry.type = atoi(row[0]); + entry.level = atoi(row[1]); + entry.ac = atoi(row[2]); + entry.hp = atoi(row[3]); + entry.accuracy = atoi(row[4]); + entry.slow_mitigation = atoi(row[5]); + entry.attack = atoi(row[6]); + entry.strength = atoi(row[7]); + entry.stamina = atoi(row[8]); + entry.dexterity = atoi(row[9]); + entry.agility = atoi(row[10]); + entry.intelligence = atoi(row[11]); + entry.wisdom = atoi(row[12]); + entry.charisma = atoi(row[13]); + entry.magic_resist = atoi(row[14]); + entry.cold_resist = atoi(row[15]); + entry.fire_resist = atoi(row[16]); + entry.poison_resist = atoi(row[17]); + entry.disease_resist = atoi(row[18]); + entry.corruption_resist = atoi(row[19]); + entry.physical_resist = atoi(row[20]); + entry.min_dmg = atoi(row[21]); + entry.max_dmg = atoi(row[22]); + entry.hp_regen_rate = atoi(row[23]); + entry.attack_delay = atoi(row[24]); + entry.spell_scale = atoi(row[25]); + entry.heal_scale = atoi(row[26]); + entry.special_abilities = row[27] ? row[27] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int npc_scale_global_base_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + npc_scale_global_base_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + NpcScaleGlobalBase npc_scale_global_base_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = " + std::to_string(npc_scale_global_base_entry.ac)); + update_values.push_back(columns[3] + " = " + std::to_string(npc_scale_global_base_entry.hp)); + update_values.push_back(columns[4] + " = " + std::to_string(npc_scale_global_base_entry.accuracy)); + update_values.push_back(columns[5] + " = " + std::to_string(npc_scale_global_base_entry.slow_mitigation)); + update_values.push_back(columns[6] + " = " + std::to_string(npc_scale_global_base_entry.attack)); + update_values.push_back(columns[7] + " = " + std::to_string(npc_scale_global_base_entry.strength)); + update_values.push_back(columns[8] + " = " + std::to_string(npc_scale_global_base_entry.stamina)); + update_values.push_back(columns[9] + " = " + std::to_string(npc_scale_global_base_entry.dexterity)); + update_values.push_back(columns[10] + " = " + std::to_string(npc_scale_global_base_entry.agility)); + update_values.push_back(columns[11] + " = " + std::to_string(npc_scale_global_base_entry.intelligence)); + update_values.push_back(columns[12] + " = " + std::to_string(npc_scale_global_base_entry.wisdom)); + update_values.push_back(columns[13] + " = " + std::to_string(npc_scale_global_base_entry.charisma)); + update_values.push_back(columns[14] + " = " + std::to_string(npc_scale_global_base_entry.magic_resist)); + update_values.push_back(columns[15] + " = " + std::to_string(npc_scale_global_base_entry.cold_resist)); + update_values.push_back(columns[16] + " = " + std::to_string(npc_scale_global_base_entry.fire_resist)); + update_values.push_back(columns[17] + " = " + std::to_string(npc_scale_global_base_entry.poison_resist)); + update_values.push_back(columns[18] + " = " + std::to_string(npc_scale_global_base_entry.disease_resist)); + update_values.push_back(columns[19] + " = " + std::to_string(npc_scale_global_base_entry.corruption_resist)); + update_values.push_back(columns[20] + " = " + std::to_string(npc_scale_global_base_entry.physical_resist)); + update_values.push_back(columns[21] + " = " + std::to_string(npc_scale_global_base_entry.min_dmg)); + update_values.push_back(columns[22] + " = " + std::to_string(npc_scale_global_base_entry.max_dmg)); + update_values.push_back(columns[23] + " = " + std::to_string(npc_scale_global_base_entry.hp_regen_rate)); + update_values.push_back(columns[24] + " = " + std::to_string(npc_scale_global_base_entry.attack_delay)); + update_values.push_back(columns[25] + " = " + std::to_string(npc_scale_global_base_entry.spell_scale)); + update_values.push_back(columns[26] + " = " + std::to_string(npc_scale_global_base_entry.heal_scale)); + update_values.push_back(columns[27] + " = '" + EscapeString(npc_scale_global_base_entry.special_abilities) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + npc_scale_global_base_entry.level + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static NpcScaleGlobalBase InsertOne( + NpcScaleGlobalBase npc_scale_global_base_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(npc_scale_global_base_entry.ac)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.hp)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.accuracy)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.slow_mitigation)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.attack)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.strength)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.stamina)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.dexterity)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.agility)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.intelligence)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.wisdom)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.charisma)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.magic_resist)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.cold_resist)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.fire_resist)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.poison_resist)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.disease_resist)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.corruption_resist)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.physical_resist)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.min_dmg)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.max_dmg)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.hp_regen_rate)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.attack_delay)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.spell_scale)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.heal_scale)); + insert_values.push_back("'" + EscapeString(npc_scale_global_base_entry.special_abilities) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + npc_scale_global_base_entry.id = results.LastInsertedID(); + return npc_scale_global_base_entry; + } + + npc_scale_global_base_entry = NewEntity(); + + return npc_scale_global_base_entry; + } + + static int InsertMany( + std::vector npc_scale_global_base_entries + ) + { + std::vector insert_chunks; + + for (auto &npc_scale_global_base_entry: npc_scale_global_base_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(npc_scale_global_base_entry.ac)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.hp)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.accuracy)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.slow_mitigation)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.attack)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.strength)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.stamina)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.dexterity)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.agility)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.intelligence)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.wisdom)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.charisma)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.magic_resist)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.cold_resist)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.fire_resist)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.poison_resist)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.disease_resist)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.corruption_resist)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.physical_resist)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.min_dmg)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.max_dmg)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.hp_regen_rate)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.attack_delay)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.spell_scale)); + insert_values.push_back(std::to_string(npc_scale_global_base_entry.heal_scale)); + insert_values.push_back("'" + EscapeString(npc_scale_global_base_entry.special_abilities) + "'"); + + 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) { + NpcScaleGlobalBase entry{}; + + entry.type = atoi(row[0]); + entry.level = atoi(row[1]); + entry.ac = atoi(row[2]); + entry.hp = atoi(row[3]); + entry.accuracy = atoi(row[4]); + entry.slow_mitigation = atoi(row[5]); + entry.attack = atoi(row[6]); + entry.strength = atoi(row[7]); + entry.stamina = atoi(row[8]); + entry.dexterity = atoi(row[9]); + entry.agility = atoi(row[10]); + entry.intelligence = atoi(row[11]); + entry.wisdom = atoi(row[12]); + entry.charisma = atoi(row[13]); + entry.magic_resist = atoi(row[14]); + entry.cold_resist = atoi(row[15]); + entry.fire_resist = atoi(row[16]); + entry.poison_resist = atoi(row[17]); + entry.disease_resist = atoi(row[18]); + entry.corruption_resist = atoi(row[19]); + entry.physical_resist = atoi(row[20]); + entry.min_dmg = atoi(row[21]); + entry.max_dmg = atoi(row[22]); + entry.hp_regen_rate = atoi(row[23]); + entry.attack_delay = atoi(row[24]); + entry.spell_scale = atoi(row[25]); + entry.heal_scale = atoi(row[26]); + entry.special_abilities = row[27] ? row[27] : ""; + + 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) { + NpcScaleGlobalBase entry{}; + + entry.type = atoi(row[0]); + entry.level = atoi(row[1]); + entry.ac = atoi(row[2]); + entry.hp = atoi(row[3]); + entry.accuracy = atoi(row[4]); + entry.slow_mitigation = atoi(row[5]); + entry.attack = atoi(row[6]); + entry.strength = atoi(row[7]); + entry.stamina = atoi(row[8]); + entry.dexterity = atoi(row[9]); + entry.agility = atoi(row[10]); + entry.intelligence = atoi(row[11]); + entry.wisdom = atoi(row[12]); + entry.charisma = atoi(row[13]); + entry.magic_resist = atoi(row[14]); + entry.cold_resist = atoi(row[15]); + entry.fire_resist = atoi(row[16]); + entry.poison_resist = atoi(row[17]); + entry.disease_resist = atoi(row[18]); + entry.corruption_resist = atoi(row[19]); + entry.physical_resist = atoi(row[20]); + entry.min_dmg = atoi(row[21]); + entry.max_dmg = atoi(row[22]); + entry.hp_regen_rate = atoi(row[23]); + entry.attack_delay = atoi(row[24]); + entry.spell_scale = atoi(row[25]); + entry.heal_scale = atoi(row[26]); + entry.special_abilities = row[27] ? row[27] : ""; + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_NPC_SCALE_GLOBAL_BASE_REPOSITORY_H diff --git a/common/repositories/base/base_npc_spells_effects_entries_repository.h b/common/repositories/base/base_npc_spells_effects_entries_repository.h new file mode 100644 index 000000000..e4631037c --- /dev/null +++ b/common/repositories/base/base_npc_spells_effects_entries_repository.h @@ -0,0 +1,360 @@ +/** + * 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 on Apr 5, 2020 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_NPC_SPELLS_EFFECTS_ENTRIES_REPOSITORY_H +#define EQEMU_BASE_NPC_SPELLS_EFFECTS_ENTRIES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseNpcSpellsEffectsEntriesRepository { +public: + struct NpcSpellsEffectsEntries { + int id; + int npc_spells_effects_id; + int16 spell_effect_id; + int8 minlevel; + int8 maxlevel; + int se_base; + int se_limit; + int se_max; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "npc_spells_effects_id", + "spell_effect_id", + "minlevel", + "maxlevel", + "se_base", + "se_limit", + "se_max", + }; + } + + 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("npc_spells_effects_entries"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static NpcSpellsEffectsEntries NewEntity() + { + NpcSpellsEffectsEntries entry{}; + + entry.id = 0; + entry.npc_spells_effects_id = 0; + entry.spell_effect_id = 0; + entry.minlevel = 0; + entry.maxlevel = 255; + entry.se_base = 0; + entry.se_limit = 0; + entry.se_max = 0; + + return entry; + } + + static NpcSpellsEffectsEntries GetNpcSpellsEffectsEntriesEntry( + const std::vector &npc_spells_effects_entriess, + int npc_spells_effects_entries_id + ) + { + for (auto &npc_spells_effects_entries : npc_spells_effects_entriess) { + if (npc_spells_effects_entries.id == npc_spells_effects_entries_id) { + return npc_spells_effects_entries; + } + } + + return NewEntity(); + } + + static NpcSpellsEffectsEntries FindOne( + int npc_spells_effects_entries_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + npc_spells_effects_entries_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + NpcSpellsEffectsEntries entry{}; + + entry.id = atoi(row[0]); + entry.npc_spells_effects_id = atoi(row[1]); + entry.spell_effect_id = atoi(row[2]); + entry.minlevel = atoi(row[3]); + entry.maxlevel = atoi(row[4]); + entry.se_base = atoi(row[5]); + entry.se_limit = atoi(row[6]); + entry.se_max = atoi(row[7]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int npc_spells_effects_entries_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + npc_spells_effects_entries_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + NpcSpellsEffectsEntries npc_spells_effects_entries_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(npc_spells_effects_entries_entry.npc_spells_effects_id)); + update_values.push_back(columns[2] + " = " + std::to_string(npc_spells_effects_entries_entry.spell_effect_id)); + update_values.push_back(columns[3] + " = " + std::to_string(npc_spells_effects_entries_entry.minlevel)); + update_values.push_back(columns[4] + " = " + std::to_string(npc_spells_effects_entries_entry.maxlevel)); + update_values.push_back(columns[5] + " = " + std::to_string(npc_spells_effects_entries_entry.se_base)); + update_values.push_back(columns[6] + " = " + std::to_string(npc_spells_effects_entries_entry.se_limit)); + update_values.push_back(columns[7] + " = " + std::to_string(npc_spells_effects_entries_entry.se_max)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + npc_spells_effects_entries_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static NpcSpellsEffectsEntries InsertOne( + NpcSpellsEffectsEntries npc_spells_effects_entries_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.npc_spells_effects_id)); + insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.spell_effect_id)); + insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.minlevel)); + insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.maxlevel)); + insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.se_base)); + insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.se_limit)); + insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.se_max)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + npc_spells_effects_entries_entry.id = results.LastInsertedID(); + return npc_spells_effects_entries_entry; + } + + npc_spells_effects_entries_entry = NewEntity(); + + return npc_spells_effects_entries_entry; + } + + static int InsertMany( + std::vector npc_spells_effects_entries_entries + ) + { + std::vector insert_chunks; + + for (auto &npc_spells_effects_entries_entry: npc_spells_effects_entries_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.npc_spells_effects_id)); + insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.spell_effect_id)); + insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.minlevel)); + insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.maxlevel)); + insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.se_base)); + insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.se_limit)); + insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.se_max)); + + 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) { + NpcSpellsEffectsEntries entry{}; + + entry.id = atoi(row[0]); + entry.npc_spells_effects_id = atoi(row[1]); + entry.spell_effect_id = atoi(row[2]); + entry.minlevel = atoi(row[3]); + entry.maxlevel = atoi(row[4]); + entry.se_base = atoi(row[5]); + entry.se_limit = atoi(row[6]); + entry.se_max = atoi(row[7]); + + 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) { + NpcSpellsEffectsEntries entry{}; + + entry.id = atoi(row[0]); + entry.npc_spells_effects_id = atoi(row[1]); + entry.spell_effect_id = atoi(row[2]); + entry.minlevel = atoi(row[3]); + entry.maxlevel = atoi(row[4]); + entry.se_base = atoi(row[5]); + entry.se_limit = atoi(row[6]); + entry.se_max = atoi(row[7]); + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_NPC_SPELLS_EFFECTS_ENTRIES_REPOSITORY_H diff --git a/common/repositories/base/base_npc_spells_effects_repository.h b/common/repositories/base/base_npc_spells_effects_repository.h new file mode 100644 index 000000000..831d5b6c9 --- /dev/null +++ b/common/repositories/base/base_npc_spells_effects_repository.h @@ -0,0 +1,315 @@ +/** + * 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 on Apr 5, 2020 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_NPC_SPELLS_EFFECTS_REPOSITORY_H +#define EQEMU_BASE_NPC_SPELLS_EFFECTS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseNpcSpellsEffectsRepository { +public: + struct NpcSpellsEffects { + int id; + std::string name; + int parent_list; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "name", + "parent_list", + }; + } + + 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("npc_spells_effects"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static NpcSpellsEffects NewEntity() + { + NpcSpellsEffects entry{}; + + entry.id = 0; + entry.name = ""; + entry.parent_list = 0; + + return entry; + } + + static NpcSpellsEffects GetNpcSpellsEffectsEntry( + const std::vector &npc_spells_effectss, + int npc_spells_effects_id + ) + { + for (auto &npc_spells_effects : npc_spells_effectss) { + if (npc_spells_effects.id == npc_spells_effects_id) { + return npc_spells_effects; + } + } + + return NewEntity(); + } + + static NpcSpellsEffects FindOne( + int npc_spells_effects_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + npc_spells_effects_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + NpcSpellsEffects entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.parent_list = atoi(row[2]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int npc_spells_effects_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + npc_spells_effects_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + NpcSpellsEffects npc_spells_effects_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(npc_spells_effects_entry.name) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(npc_spells_effects_entry.parent_list)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + npc_spells_effects_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static NpcSpellsEffects InsertOne( + NpcSpellsEffects npc_spells_effects_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(npc_spells_effects_entry.name) + "'"); + insert_values.push_back(std::to_string(npc_spells_effects_entry.parent_list)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + npc_spells_effects_entry.id = results.LastInsertedID(); + return npc_spells_effects_entry; + } + + npc_spells_effects_entry = NewEntity(); + + return npc_spells_effects_entry; + } + + static int InsertMany( + std::vector npc_spells_effects_entries + ) + { + std::vector insert_chunks; + + for (auto &npc_spells_effects_entry: npc_spells_effects_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(npc_spells_effects_entry.name) + "'"); + insert_values.push_back(std::to_string(npc_spells_effects_entry.parent_list)); + + 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) { + NpcSpellsEffects entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.parent_list = atoi(row[2]); + + 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) { + NpcSpellsEffects entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.parent_list = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_NPC_SPELLS_EFFECTS_REPOSITORY_H diff --git a/common/repositories/base/base_npc_spells_entries_repository.h b/common/repositories/base/base_npc_spells_entries_repository.h new file mode 100644 index 000000000..85bdbc383 --- /dev/null +++ b/common/repositories/base/base_npc_spells_entries_repository.h @@ -0,0 +1,396 @@ +/** + * 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 on Apr 5, 2020 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_NPC_SPELLS_ENTRIES_REPOSITORY_H +#define EQEMU_BASE_NPC_SPELLS_ENTRIES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseNpcSpellsEntriesRepository { +public: + struct NpcSpellsEntries { + int id; + int npc_spells_id; + int16 spellid; + int type; + int8 minlevel; + int8 maxlevel; + int16 manacost; + int recast_delay; + int16 priority; + int resist_adjust; + int16 min_hp; + int16 max_hp; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "npc_spells_id", + "spellid", + "type", + "minlevel", + "maxlevel", + "manacost", + "recast_delay", + "priority", + "resist_adjust", + "min_hp", + "max_hp", + }; + } + + 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("npc_spells_entries"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static NpcSpellsEntries NewEntity() + { + NpcSpellsEntries entry{}; + + entry.id = 0; + entry.npc_spells_id = 0; + entry.spellid = 0; + entry.type = 0; + entry.minlevel = 0; + entry.maxlevel = 255; + entry.manacost = -1; + entry.recast_delay = -1; + entry.priority = 0; + entry.resist_adjust = 0; + entry.min_hp = 0; + entry.max_hp = 0; + + return entry; + } + + static NpcSpellsEntries GetNpcSpellsEntriesEntry( + const std::vector &npc_spells_entriess, + int npc_spells_entries_id + ) + { + for (auto &npc_spells_entries : npc_spells_entriess) { + if (npc_spells_entries.id == npc_spells_entries_id) { + return npc_spells_entries; + } + } + + return NewEntity(); + } + + static NpcSpellsEntries FindOne( + int npc_spells_entries_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + npc_spells_entries_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + NpcSpellsEntries entry{}; + + entry.id = atoi(row[0]); + entry.npc_spells_id = atoi(row[1]); + entry.spellid = atoi(row[2]); + entry.type = atoi(row[3]); + entry.minlevel = atoi(row[4]); + entry.maxlevel = atoi(row[5]); + entry.manacost = atoi(row[6]); + entry.recast_delay = atoi(row[7]); + entry.priority = atoi(row[8]); + entry.resist_adjust = atoi(row[9]); + entry.min_hp = atoi(row[10]); + entry.max_hp = atoi(row[11]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int npc_spells_entries_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + npc_spells_entries_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + NpcSpellsEntries npc_spells_entries_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(npc_spells_entries_entry.npc_spells_id)); + update_values.push_back(columns[2] + " = " + std::to_string(npc_spells_entries_entry.spellid)); + update_values.push_back(columns[3] + " = " + std::to_string(npc_spells_entries_entry.type)); + update_values.push_back(columns[4] + " = " + std::to_string(npc_spells_entries_entry.minlevel)); + update_values.push_back(columns[5] + " = " + std::to_string(npc_spells_entries_entry.maxlevel)); + update_values.push_back(columns[6] + " = " + std::to_string(npc_spells_entries_entry.manacost)); + update_values.push_back(columns[7] + " = " + std::to_string(npc_spells_entries_entry.recast_delay)); + update_values.push_back(columns[8] + " = " + std::to_string(npc_spells_entries_entry.priority)); + update_values.push_back(columns[9] + " = " + std::to_string(npc_spells_entries_entry.resist_adjust)); + update_values.push_back(columns[10] + " = " + std::to_string(npc_spells_entries_entry.min_hp)); + update_values.push_back(columns[11] + " = " + std::to_string(npc_spells_entries_entry.max_hp)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + npc_spells_entries_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static NpcSpellsEntries InsertOne( + NpcSpellsEntries npc_spells_entries_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(npc_spells_entries_entry.npc_spells_id)); + insert_values.push_back(std::to_string(npc_spells_entries_entry.spellid)); + insert_values.push_back(std::to_string(npc_spells_entries_entry.type)); + insert_values.push_back(std::to_string(npc_spells_entries_entry.minlevel)); + insert_values.push_back(std::to_string(npc_spells_entries_entry.maxlevel)); + insert_values.push_back(std::to_string(npc_spells_entries_entry.manacost)); + insert_values.push_back(std::to_string(npc_spells_entries_entry.recast_delay)); + insert_values.push_back(std::to_string(npc_spells_entries_entry.priority)); + insert_values.push_back(std::to_string(npc_spells_entries_entry.resist_adjust)); + insert_values.push_back(std::to_string(npc_spells_entries_entry.min_hp)); + insert_values.push_back(std::to_string(npc_spells_entries_entry.max_hp)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + npc_spells_entries_entry.id = results.LastInsertedID(); + return npc_spells_entries_entry; + } + + npc_spells_entries_entry = NewEntity(); + + return npc_spells_entries_entry; + } + + static int InsertMany( + std::vector npc_spells_entries_entries + ) + { + std::vector insert_chunks; + + for (auto &npc_spells_entries_entry: npc_spells_entries_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(npc_spells_entries_entry.npc_spells_id)); + insert_values.push_back(std::to_string(npc_spells_entries_entry.spellid)); + insert_values.push_back(std::to_string(npc_spells_entries_entry.type)); + insert_values.push_back(std::to_string(npc_spells_entries_entry.minlevel)); + insert_values.push_back(std::to_string(npc_spells_entries_entry.maxlevel)); + insert_values.push_back(std::to_string(npc_spells_entries_entry.manacost)); + insert_values.push_back(std::to_string(npc_spells_entries_entry.recast_delay)); + insert_values.push_back(std::to_string(npc_spells_entries_entry.priority)); + insert_values.push_back(std::to_string(npc_spells_entries_entry.resist_adjust)); + insert_values.push_back(std::to_string(npc_spells_entries_entry.min_hp)); + insert_values.push_back(std::to_string(npc_spells_entries_entry.max_hp)); + + 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) { + NpcSpellsEntries entry{}; + + entry.id = atoi(row[0]); + entry.npc_spells_id = atoi(row[1]); + entry.spellid = atoi(row[2]); + entry.type = atoi(row[3]); + entry.minlevel = atoi(row[4]); + entry.maxlevel = atoi(row[5]); + entry.manacost = atoi(row[6]); + entry.recast_delay = atoi(row[7]); + entry.priority = atoi(row[8]); + entry.resist_adjust = atoi(row[9]); + entry.min_hp = atoi(row[10]); + entry.max_hp = atoi(row[11]); + + 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) { + NpcSpellsEntries entry{}; + + entry.id = atoi(row[0]); + entry.npc_spells_id = atoi(row[1]); + entry.spellid = atoi(row[2]); + entry.type = atoi(row[3]); + entry.minlevel = atoi(row[4]); + entry.maxlevel = atoi(row[5]); + entry.manacost = atoi(row[6]); + entry.recast_delay = atoi(row[7]); + entry.priority = atoi(row[8]); + entry.resist_adjust = atoi(row[9]); + entry.min_hp = atoi(row[10]); + entry.max_hp = atoi(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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_NPC_SPELLS_ENTRIES_REPOSITORY_H diff --git a/common/repositories/base/base_npc_spells_repository.h b/common/repositories/base/base_npc_spells_repository.h new file mode 100644 index 000000000..10bf88898 --- /dev/null +++ b/common/repositories/base/base_npc_spells_repository.h @@ -0,0 +1,477 @@ +/** + * 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 on Apr 5, 2020 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_NPC_SPELLS_REPOSITORY_H +#define EQEMU_BASE_NPC_SPELLS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseNpcSpellsRepository { +public: + struct NpcSpells { + int id; + std::string name; + int parent_list; + int16 attack_proc; + int8 proc_chance; + int16 range_proc; + int16 rproc_chance; + int16 defensive_proc; + int16 dproc_chance; + int fail_recast; + int engaged_no_sp_recast_min; + int engaged_no_sp_recast_max; + int8 engaged_b_self_chance; + int8 engaged_b_other_chance; + int8 engaged_d_chance; + int pursue_no_sp_recast_min; + int pursue_no_sp_recast_max; + int8 pursue_d_chance; + int idle_no_sp_recast_min; + int idle_no_sp_recast_max; + int8 idle_b_chance; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "name", + "parent_list", + "attack_proc", + "proc_chance", + "range_proc", + "rproc_chance", + "defensive_proc", + "dproc_chance", + "fail_recast", + "engaged_no_sp_recast_min", + "engaged_no_sp_recast_max", + "engaged_b_self_chance", + "engaged_b_other_chance", + "engaged_d_chance", + "pursue_no_sp_recast_min", + "pursue_no_sp_recast_max", + "pursue_d_chance", + "idle_no_sp_recast_min", + "idle_no_sp_recast_max", + "idle_b_chance", + }; + } + + 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("npc_spells"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static NpcSpells NewEntity() + { + NpcSpells entry{}; + + entry.id = 0; + entry.name = ""; + entry.parent_list = 0; + entry.attack_proc = -1; + entry.proc_chance = 3; + entry.range_proc = -1; + entry.rproc_chance = 0; + entry.defensive_proc = -1; + entry.dproc_chance = 0; + entry.fail_recast = 0; + entry.engaged_no_sp_recast_min = 0; + entry.engaged_no_sp_recast_max = 0; + entry.engaged_b_self_chance = 0; + entry.engaged_b_other_chance = 0; + entry.engaged_d_chance = 0; + entry.pursue_no_sp_recast_min = 0; + entry.pursue_no_sp_recast_max = 0; + entry.pursue_d_chance = 0; + entry.idle_no_sp_recast_min = 0; + entry.idle_no_sp_recast_max = 0; + entry.idle_b_chance = 0; + + return entry; + } + + static NpcSpells GetNpcSpellsEntry( + const std::vector &npc_spellss, + int npc_spells_id + ) + { + for (auto &npc_spells : npc_spellss) { + if (npc_spells.id == npc_spells_id) { + return npc_spells; + } + } + + return NewEntity(); + } + + static NpcSpells FindOne( + int npc_spells_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + npc_spells_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + NpcSpells entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.parent_list = atoi(row[2]); + entry.attack_proc = atoi(row[3]); + entry.proc_chance = atoi(row[4]); + entry.range_proc = atoi(row[5]); + entry.rproc_chance = atoi(row[6]); + entry.defensive_proc = atoi(row[7]); + entry.dproc_chance = atoi(row[8]); + entry.fail_recast = atoi(row[9]); + entry.engaged_no_sp_recast_min = atoi(row[10]); + entry.engaged_no_sp_recast_max = atoi(row[11]); + entry.engaged_b_self_chance = atoi(row[12]); + entry.engaged_b_other_chance = atoi(row[13]); + entry.engaged_d_chance = atoi(row[14]); + entry.pursue_no_sp_recast_min = atoi(row[15]); + entry.pursue_no_sp_recast_max = atoi(row[16]); + entry.pursue_d_chance = atoi(row[17]); + entry.idle_no_sp_recast_min = atoi(row[18]); + entry.idle_no_sp_recast_max = atoi(row[19]); + entry.idle_b_chance = atoi(row[20]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int npc_spells_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + npc_spells_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + NpcSpells npc_spells_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(npc_spells_entry.name) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(npc_spells_entry.parent_list)); + update_values.push_back(columns[3] + " = " + std::to_string(npc_spells_entry.attack_proc)); + update_values.push_back(columns[4] + " = " + std::to_string(npc_spells_entry.proc_chance)); + update_values.push_back(columns[5] + " = " + std::to_string(npc_spells_entry.range_proc)); + update_values.push_back(columns[6] + " = " + std::to_string(npc_spells_entry.rproc_chance)); + update_values.push_back(columns[7] + " = " + std::to_string(npc_spells_entry.defensive_proc)); + update_values.push_back(columns[8] + " = " + std::to_string(npc_spells_entry.dproc_chance)); + update_values.push_back(columns[9] + " = " + std::to_string(npc_spells_entry.fail_recast)); + update_values.push_back(columns[10] + " = " + std::to_string(npc_spells_entry.engaged_no_sp_recast_min)); + update_values.push_back(columns[11] + " = " + std::to_string(npc_spells_entry.engaged_no_sp_recast_max)); + update_values.push_back(columns[12] + " = " + std::to_string(npc_spells_entry.engaged_b_self_chance)); + update_values.push_back(columns[13] + " = " + std::to_string(npc_spells_entry.engaged_b_other_chance)); + update_values.push_back(columns[14] + " = " + std::to_string(npc_spells_entry.engaged_d_chance)); + update_values.push_back(columns[15] + " = " + std::to_string(npc_spells_entry.pursue_no_sp_recast_min)); + update_values.push_back(columns[16] + " = " + std::to_string(npc_spells_entry.pursue_no_sp_recast_max)); + update_values.push_back(columns[17] + " = " + std::to_string(npc_spells_entry.pursue_d_chance)); + update_values.push_back(columns[18] + " = " + std::to_string(npc_spells_entry.idle_no_sp_recast_min)); + update_values.push_back(columns[19] + " = " + std::to_string(npc_spells_entry.idle_no_sp_recast_max)); + update_values.push_back(columns[20] + " = " + std::to_string(npc_spells_entry.idle_b_chance)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + npc_spells_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static NpcSpells InsertOne( + NpcSpells npc_spells_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(npc_spells_entry.name) + "'"); + insert_values.push_back(std::to_string(npc_spells_entry.parent_list)); + insert_values.push_back(std::to_string(npc_spells_entry.attack_proc)); + insert_values.push_back(std::to_string(npc_spells_entry.proc_chance)); + insert_values.push_back(std::to_string(npc_spells_entry.range_proc)); + insert_values.push_back(std::to_string(npc_spells_entry.rproc_chance)); + insert_values.push_back(std::to_string(npc_spells_entry.defensive_proc)); + insert_values.push_back(std::to_string(npc_spells_entry.dproc_chance)); + insert_values.push_back(std::to_string(npc_spells_entry.fail_recast)); + insert_values.push_back(std::to_string(npc_spells_entry.engaged_no_sp_recast_min)); + insert_values.push_back(std::to_string(npc_spells_entry.engaged_no_sp_recast_max)); + insert_values.push_back(std::to_string(npc_spells_entry.engaged_b_self_chance)); + insert_values.push_back(std::to_string(npc_spells_entry.engaged_b_other_chance)); + insert_values.push_back(std::to_string(npc_spells_entry.engaged_d_chance)); + insert_values.push_back(std::to_string(npc_spells_entry.pursue_no_sp_recast_min)); + insert_values.push_back(std::to_string(npc_spells_entry.pursue_no_sp_recast_max)); + insert_values.push_back(std::to_string(npc_spells_entry.pursue_d_chance)); + insert_values.push_back(std::to_string(npc_spells_entry.idle_no_sp_recast_min)); + insert_values.push_back(std::to_string(npc_spells_entry.idle_no_sp_recast_max)); + insert_values.push_back(std::to_string(npc_spells_entry.idle_b_chance)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + npc_spells_entry.id = results.LastInsertedID(); + return npc_spells_entry; + } + + npc_spells_entry = NewEntity(); + + return npc_spells_entry; + } + + static int InsertMany( + std::vector npc_spells_entries + ) + { + std::vector insert_chunks; + + for (auto &npc_spells_entry: npc_spells_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(npc_spells_entry.name) + "'"); + insert_values.push_back(std::to_string(npc_spells_entry.parent_list)); + insert_values.push_back(std::to_string(npc_spells_entry.attack_proc)); + insert_values.push_back(std::to_string(npc_spells_entry.proc_chance)); + insert_values.push_back(std::to_string(npc_spells_entry.range_proc)); + insert_values.push_back(std::to_string(npc_spells_entry.rproc_chance)); + insert_values.push_back(std::to_string(npc_spells_entry.defensive_proc)); + insert_values.push_back(std::to_string(npc_spells_entry.dproc_chance)); + insert_values.push_back(std::to_string(npc_spells_entry.fail_recast)); + insert_values.push_back(std::to_string(npc_spells_entry.engaged_no_sp_recast_min)); + insert_values.push_back(std::to_string(npc_spells_entry.engaged_no_sp_recast_max)); + insert_values.push_back(std::to_string(npc_spells_entry.engaged_b_self_chance)); + insert_values.push_back(std::to_string(npc_spells_entry.engaged_b_other_chance)); + insert_values.push_back(std::to_string(npc_spells_entry.engaged_d_chance)); + insert_values.push_back(std::to_string(npc_spells_entry.pursue_no_sp_recast_min)); + insert_values.push_back(std::to_string(npc_spells_entry.pursue_no_sp_recast_max)); + insert_values.push_back(std::to_string(npc_spells_entry.pursue_d_chance)); + insert_values.push_back(std::to_string(npc_spells_entry.idle_no_sp_recast_min)); + insert_values.push_back(std::to_string(npc_spells_entry.idle_no_sp_recast_max)); + insert_values.push_back(std::to_string(npc_spells_entry.idle_b_chance)); + + 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) { + NpcSpells entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.parent_list = atoi(row[2]); + entry.attack_proc = atoi(row[3]); + entry.proc_chance = atoi(row[4]); + entry.range_proc = atoi(row[5]); + entry.rproc_chance = atoi(row[6]); + entry.defensive_proc = atoi(row[7]); + entry.dproc_chance = atoi(row[8]); + entry.fail_recast = atoi(row[9]); + entry.engaged_no_sp_recast_min = atoi(row[10]); + entry.engaged_no_sp_recast_max = atoi(row[11]); + entry.engaged_b_self_chance = atoi(row[12]); + entry.engaged_b_other_chance = atoi(row[13]); + entry.engaged_d_chance = atoi(row[14]); + entry.pursue_no_sp_recast_min = atoi(row[15]); + entry.pursue_no_sp_recast_max = atoi(row[16]); + entry.pursue_d_chance = atoi(row[17]); + entry.idle_no_sp_recast_min = atoi(row[18]); + entry.idle_no_sp_recast_max = atoi(row[19]); + entry.idle_b_chance = atoi(row[20]); + + 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) { + NpcSpells entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.parent_list = atoi(row[2]); + entry.attack_proc = atoi(row[3]); + entry.proc_chance = atoi(row[4]); + entry.range_proc = atoi(row[5]); + entry.rproc_chance = atoi(row[6]); + entry.defensive_proc = atoi(row[7]); + entry.dproc_chance = atoi(row[8]); + entry.fail_recast = atoi(row[9]); + entry.engaged_no_sp_recast_min = atoi(row[10]); + entry.engaged_no_sp_recast_max = atoi(row[11]); + entry.engaged_b_self_chance = atoi(row[12]); + entry.engaged_b_other_chance = atoi(row[13]); + entry.engaged_d_chance = atoi(row[14]); + entry.pursue_no_sp_recast_min = atoi(row[15]); + entry.pursue_no_sp_recast_max = atoi(row[16]); + entry.pursue_d_chance = atoi(row[17]); + entry.idle_no_sp_recast_min = atoi(row[18]); + entry.idle_no_sp_recast_max = atoi(row[19]); + entry.idle_b_chance = atoi(row[20]); + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_NPC_SPELLS_REPOSITORY_H diff --git a/common/repositories/base/base_npc_types_repository.h b/common/repositories/base/base_npc_types_repository.h new file mode 100644 index 000000000..62a75c88f --- /dev/null +++ b/common/repositories/base/base_npc_types_repository.h @@ -0,0 +1,1386 @@ +/** + * 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 on Apr 5, 2020 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_NPC_TYPES_REPOSITORY_H +#define EQEMU_BASE_NPC_TYPES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseNpcTypesRepository { +public: + struct NpcTypes { + int id; + std::string name; + std::string lastname; + int8 level; + int16 race; + int8 class; + int bodytype; + int hp; + int mana; + int8 gender; + int8 texture; + int8 helmtexture; + int herosforgemodel; + float size; + int hp_regen_rate; + int mana_regen_rate; + int loottable_id; + int merchant_id; + int alt_currency_id; + int npc_spells_id; + int npc_spells_effects_id; + int npc_faction_id; + int adventure_template_id; + int trap_template; + int mindmg; + int maxdmg; + int16 attack_count; + std::string npcspecialattks; + std::string special_abilities; + int aggroradius; + int assistradius; + int face; + int luclin_hairstyle; + int luclin_haircolor; + int luclin_eyecolor; + int luclin_eyecolor2; + int luclin_beardcolor; + int luclin_beard; + int drakkin_heritage; + int drakkin_tattoo; + int drakkin_details; + int armortint_id; + int8 armortint_red; + int8 armortint_green; + int8 armortint_blue; + int d_melee_texture1; + int d_melee_texture2; + std::string ammo_idfile; + int8 prim_melee_type; + int8 sec_melee_type; + int8 ranged_type; + float runspeed; + int16 MR; + int16 CR; + int16 DR; + int16 FR; + int16 PR; + int16 Corrup; + int16 PhR; + int16 see_invis; + int16 see_invis_undead; + int qglobal; + int16 AC; + int8 npc_aggro; + int8 spawn_limit; + float attack_speed; + int8 attack_delay; + int8 findable; + int STR; + int STA; + int DEX; + int AGI; + int _INT; + int WIS; + int CHA; + int8 see_hide; + int8 see_improved_hide; + int8 trackable; + int8 isbot; + int8 exclude; + int ATK; + int Accuracy; + int Avoidance; + int16 slow_mitigation; + int16 version; + int8 maxlevel; + int scalerate; + int8 private_corpse; + int8 unique_spawn_by_name; + int8 underwater; + int8 isquest; + int emoteid; + float spellscale; + float healscale; + int8 no_target_hotkey; + int8 raid_target; + int8 armtexture; + int8 bracertexture; + int8 handtexture; + int8 legtexture; + int8 feettexture; + int8 light; + int8 walkspeed; + int peqid; + int8 unique_; + int8 fixed; + int8 ignore_despawn; + int8 show_name; + int8 untargetable; + int16 charm_ac; + int charm_min_dmg; + int charm_max_dmg; + int8 charm_attack_delay; + int charm_accuracy_rating; + int charm_avoidance_rating; + int charm_atk; + int8 skip_global_loot; + int8 rare_spawn; + int8 stuck_behavior; + int16 model; + int8 flymode; + int8 always_aggro; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "name", + "lastname", + "level", + "race", + "class", + "bodytype", + "hp", + "mana", + "gender", + "texture", + "helmtexture", + "herosforgemodel", + "size", + "hp_regen_rate", + "mana_regen_rate", + "loottable_id", + "merchant_id", + "alt_currency_id", + "npc_spells_id", + "npc_spells_effects_id", + "npc_faction_id", + "adventure_template_id", + "trap_template", + "mindmg", + "maxdmg", + "attack_count", + "npcspecialattks", + "special_abilities", + "aggroradius", + "assistradius", + "face", + "luclin_hairstyle", + "luclin_haircolor", + "luclin_eyecolor", + "luclin_eyecolor2", + "luclin_beardcolor", + "luclin_beard", + "drakkin_heritage", + "drakkin_tattoo", + "drakkin_details", + "armortint_id", + "armortint_red", + "armortint_green", + "armortint_blue", + "d_melee_texture1", + "d_melee_texture2", + "ammo_idfile", + "prim_melee_type", + "sec_melee_type", + "ranged_type", + "runspeed", + "MR", + "CR", + "DR", + "FR", + "PR", + "Corrup", + "PhR", + "see_invis", + "see_invis_undead", + "qglobal", + "AC", + "npc_aggro", + "spawn_limit", + "attack_speed", + "attack_delay", + "findable", + "STR", + "STA", + "DEX", + "AGI", + "_INT", + "WIS", + "CHA", + "see_hide", + "see_improved_hide", + "trackable", + "isbot", + "exclude", + "ATK", + "Accuracy", + "Avoidance", + "slow_mitigation", + "version", + "maxlevel", + "scalerate", + "private_corpse", + "unique_spawn_by_name", + "underwater", + "isquest", + "emoteid", + "spellscale", + "healscale", + "no_target_hotkey", + "raid_target", + "armtexture", + "bracertexture", + "handtexture", + "legtexture", + "feettexture", + "light", + "walkspeed", + "peqid", + "unique_", + "fixed", + "ignore_despawn", + "show_name", + "untargetable", + "charm_ac", + "charm_min_dmg", + "charm_max_dmg", + "charm_attack_delay", + "charm_accuracy_rating", + "charm_avoidance_rating", + "charm_atk", + "skip_global_loot", + "rare_spawn", + "stuck_behavior", + "model", + "flymode", + "always_aggro", + }; + } + + 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("npc_types"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static NpcTypes NewEntity() + { + NpcTypes entry{}; + + entry.id = 0; + entry.name = ""; + entry.lastname = ""; + entry.level = 0; + entry.race = 0; + entry.class = 0; + entry.bodytype = 1; + entry.hp = 0; + entry.mana = 0; + entry.gender = 0; + entry.texture = 0; + entry.helmtexture = 0; + entry.herosforgemodel = 0; + entry.size = 0; + entry.hp_regen_rate = 0; + entry.mana_regen_rate = 0; + entry.loottable_id = 0; + entry.merchant_id = 0; + entry.alt_currency_id = 0; + entry.npc_spells_id = 0; + entry.npc_spells_effects_id = 0; + entry.npc_faction_id = 0; + entry.adventure_template_id = 0; + entry.trap_template = 0; + entry.mindmg = 0; + entry.maxdmg = 0; + entry.attack_count = -1; + entry.npcspecialattks = ""; + entry.special_abilities = ""; + entry.aggroradius = 0; + entry.assistradius = 0; + entry.face = 1; + entry.luclin_hairstyle = 1; + entry.luclin_haircolor = 1; + entry.luclin_eyecolor = 1; + entry.luclin_eyecolor2 = 1; + entry.luclin_beardcolor = 1; + entry.luclin_beard = 0; + entry.drakkin_heritage = 0; + entry.drakkin_tattoo = 0; + entry.drakkin_details = 0; + entry.armortint_id = 0; + entry.armortint_red = 0; + entry.armortint_green = 0; + entry.armortint_blue = 0; + entry.d_melee_texture1 = 0; + entry.d_melee_texture2 = 0; + entry.ammo_idfile = "IT10"; + entry.prim_melee_type = 28; + entry.sec_melee_type = 28; + entry.ranged_type = 7; + entry.runspeed = 0; + entry.MR = 0; + entry.CR = 0; + entry.DR = 0; + entry.FR = 0; + entry.PR = 0; + entry.Corrup = 0; + entry.PhR = 0; + entry.see_invis = 0; + entry.see_invis_undead = 0; + entry.qglobal = 0; + entry.AC = 0; + entry.npc_aggro = 0; + entry.spawn_limit = 0; + entry.attack_speed = 0; + entry.attack_delay = 30; + entry.findable = 0; + entry.STR = 75; + entry.STA = 75; + entry.DEX = 75; + entry.AGI = 75; + entry._INT = 80; + entry.WIS = 75; + entry.CHA = 75; + entry.see_hide = 0; + entry.see_improved_hide = 0; + entry.trackable = 1; + entry.isbot = 0; + entry.exclude = 1; + entry.ATK = 0; + entry.Accuracy = 0; + entry.Avoidance = 0; + entry.slow_mitigation = 0; + entry.version = 0; + entry.maxlevel = 0; + entry.scalerate = 100; + entry.private_corpse = 0; + entry.unique_spawn_by_name = 0; + entry.underwater = 0; + entry.isquest = 0; + entry.emoteid = 0; + entry.spellscale = 100; + entry.healscale = 100; + entry.no_target_hotkey = 0; + entry.raid_target = 0; + entry.armtexture = 0; + entry.bracertexture = 0; + entry.handtexture = 0; + entry.legtexture = 0; + entry.feettexture = 0; + entry.light = 0; + entry.walkspeed = 0; + entry.peqid = 0; + entry.unique_ = 0; + entry.fixed = 0; + entry.ignore_despawn = 0; + entry.show_name = 1; + entry.untargetable = 0; + entry.charm_ac = 0; + entry.charm_min_dmg = 0; + entry.charm_max_dmg = 0; + entry.charm_attack_delay = 0; + entry.charm_accuracy_rating = 0; + entry.charm_avoidance_rating = 0; + entry.charm_atk = 0; + entry.skip_global_loot = 0; + entry.rare_spawn = 0; + entry.stuck_behavior = 0; + entry.model = 0; + entry.flymode = -1; + entry.always_aggro = 0; + + return entry; + } + + static NpcTypes GetNpcTypesEntry( + const std::vector &npc_typess, + int npc_types_id + ) + { + for (auto &npc_types : npc_typess) { + if (npc_types.id == npc_types_id) { + return npc_types; + } + } + + return NewEntity(); + } + + static NpcTypes FindOne( + int npc_types_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + npc_types_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + NpcTypes entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.lastname = row[2] ? row[2] : ""; + entry.level = atoi(row[3]); + entry.race = atoi(row[4]); + entry.class = atoi(row[5]); + entry.bodytype = atoi(row[6]); + entry.hp = atoi(row[7]); + entry.mana = atoi(row[8]); + entry.gender = atoi(row[9]); + entry.texture = atoi(row[10]); + entry.helmtexture = atoi(row[11]); + entry.herosforgemodel = atoi(row[12]); + entry.size = atof(row[13]); + entry.hp_regen_rate = atoi(row[14]); + entry.mana_regen_rate = atoi(row[15]); + entry.loottable_id = atoi(row[16]); + entry.merchant_id = atoi(row[17]); + entry.alt_currency_id = atoi(row[18]); + entry.npc_spells_id = atoi(row[19]); + entry.npc_spells_effects_id = atoi(row[20]); + entry.npc_faction_id = atoi(row[21]); + entry.adventure_template_id = atoi(row[22]); + entry.trap_template = atoi(row[23]); + entry.mindmg = atoi(row[24]); + entry.maxdmg = atoi(row[25]); + entry.attack_count = atoi(row[26]); + entry.npcspecialattks = row[27] ? row[27] : ""; + entry.special_abilities = row[28] ? row[28] : ""; + entry.aggroradius = atoi(row[29]); + entry.assistradius = atoi(row[30]); + entry.face = atoi(row[31]); + entry.luclin_hairstyle = atoi(row[32]); + entry.luclin_haircolor = atoi(row[33]); + entry.luclin_eyecolor = atoi(row[34]); + entry.luclin_eyecolor2 = atoi(row[35]); + entry.luclin_beardcolor = atoi(row[36]); + entry.luclin_beard = atoi(row[37]); + entry.drakkin_heritage = atoi(row[38]); + entry.drakkin_tattoo = atoi(row[39]); + entry.drakkin_details = atoi(row[40]); + entry.armortint_id = atoi(row[41]); + entry.armortint_red = atoi(row[42]); + entry.armortint_green = atoi(row[43]); + entry.armortint_blue = atoi(row[44]); + entry.d_melee_texture1 = atoi(row[45]); + entry.d_melee_texture2 = atoi(row[46]); + entry.ammo_idfile = row[47] ? row[47] : ""; + entry.prim_melee_type = atoi(row[48]); + entry.sec_melee_type = atoi(row[49]); + entry.ranged_type = atoi(row[50]); + entry.runspeed = atof(row[51]); + entry.MR = atoi(row[52]); + entry.CR = atoi(row[53]); + entry.DR = atoi(row[54]); + entry.FR = atoi(row[55]); + entry.PR = atoi(row[56]); + entry.Corrup = atoi(row[57]); + entry.PhR = atoi(row[58]); + entry.see_invis = atoi(row[59]); + entry.see_invis_undead = atoi(row[60]); + entry.qglobal = atoi(row[61]); + entry.AC = atoi(row[62]); + entry.npc_aggro = atoi(row[63]); + entry.spawn_limit = atoi(row[64]); + entry.attack_speed = atof(row[65]); + entry.attack_delay = atoi(row[66]); + entry.findable = atoi(row[67]); + entry.STR = atoi(row[68]); + entry.STA = atoi(row[69]); + entry.DEX = atoi(row[70]); + entry.AGI = atoi(row[71]); + entry._INT = atoi(row[72]); + entry.WIS = atoi(row[73]); + entry.CHA = atoi(row[74]); + entry.see_hide = atoi(row[75]); + entry.see_improved_hide = atoi(row[76]); + entry.trackable = atoi(row[77]); + entry.isbot = atoi(row[78]); + entry.exclude = atoi(row[79]); + entry.ATK = atoi(row[80]); + entry.Accuracy = atoi(row[81]); + entry.Avoidance = atoi(row[82]); + entry.slow_mitigation = atoi(row[83]); + entry.version = atoi(row[84]); + entry.maxlevel = atoi(row[85]); + entry.scalerate = atoi(row[86]); + entry.private_corpse = atoi(row[87]); + entry.unique_spawn_by_name = atoi(row[88]); + entry.underwater = atoi(row[89]); + entry.isquest = atoi(row[90]); + entry.emoteid = atoi(row[91]); + entry.spellscale = atof(row[92]); + entry.healscale = atof(row[93]); + entry.no_target_hotkey = atoi(row[94]); + entry.raid_target = atoi(row[95]); + entry.armtexture = atoi(row[96]); + entry.bracertexture = atoi(row[97]); + entry.handtexture = atoi(row[98]); + entry.legtexture = atoi(row[99]); + entry.feettexture = atoi(row[100]); + entry.light = atoi(row[101]); + entry.walkspeed = atoi(row[102]); + entry.peqid = atoi(row[103]); + entry.unique_ = atoi(row[104]); + entry.fixed = atoi(row[105]); + entry.ignore_despawn = atoi(row[106]); + entry.show_name = atoi(row[107]); + entry.untargetable = atoi(row[108]); + entry.charm_ac = atoi(row[109]); + entry.charm_min_dmg = atoi(row[110]); + entry.charm_max_dmg = atoi(row[111]); + entry.charm_attack_delay = atoi(row[112]); + entry.charm_accuracy_rating = atoi(row[113]); + entry.charm_avoidance_rating = atoi(row[114]); + entry.charm_atk = atoi(row[115]); + entry.skip_global_loot = atoi(row[116]); + entry.rare_spawn = atoi(row[117]); + entry.stuck_behavior = atoi(row[118]); + entry.model = atoi(row[119]); + entry.flymode = atoi(row[120]); + entry.always_aggro = atoi(row[121]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int npc_types_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + npc_types_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + NpcTypes npc_types_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(npc_types_entry.name) + "'"); + update_values.push_back(columns[2] + " = '" + EscapeString(npc_types_entry.lastname) + "'"); + update_values.push_back(columns[3] + " = " + std::to_string(npc_types_entry.level)); + update_values.push_back(columns[4] + " = " + std::to_string(npc_types_entry.race)); + update_values.push_back(columns[5] + " = " + std::to_string(npc_types_entry.class)); + update_values.push_back(columns[6] + " = " + std::to_string(npc_types_entry.bodytype)); + update_values.push_back(columns[7] + " = " + std::to_string(npc_types_entry.hp)); + update_values.push_back(columns[8] + " = " + std::to_string(npc_types_entry.mana)); + update_values.push_back(columns[9] + " = " + std::to_string(npc_types_entry.gender)); + update_values.push_back(columns[10] + " = " + std::to_string(npc_types_entry.texture)); + update_values.push_back(columns[11] + " = " + std::to_string(npc_types_entry.helmtexture)); + update_values.push_back(columns[12] + " = " + std::to_string(npc_types_entry.herosforgemodel)); + update_values.push_back(columns[13] + " = " + std::to_string(npc_types_entry.size)); + update_values.push_back(columns[14] + " = " + std::to_string(npc_types_entry.hp_regen_rate)); + update_values.push_back(columns[15] + " = " + std::to_string(npc_types_entry.mana_regen_rate)); + update_values.push_back(columns[16] + " = " + std::to_string(npc_types_entry.loottable_id)); + update_values.push_back(columns[17] + " = " + std::to_string(npc_types_entry.merchant_id)); + update_values.push_back(columns[18] + " = " + std::to_string(npc_types_entry.alt_currency_id)); + update_values.push_back(columns[19] + " = " + std::to_string(npc_types_entry.npc_spells_id)); + update_values.push_back(columns[20] + " = " + std::to_string(npc_types_entry.npc_spells_effects_id)); + update_values.push_back(columns[21] + " = " + std::to_string(npc_types_entry.npc_faction_id)); + update_values.push_back(columns[22] + " = " + std::to_string(npc_types_entry.adventure_template_id)); + update_values.push_back(columns[23] + " = " + std::to_string(npc_types_entry.trap_template)); + update_values.push_back(columns[24] + " = " + std::to_string(npc_types_entry.mindmg)); + update_values.push_back(columns[25] + " = " + std::to_string(npc_types_entry.maxdmg)); + update_values.push_back(columns[26] + " = " + std::to_string(npc_types_entry.attack_count)); + update_values.push_back(columns[27] + " = '" + EscapeString(npc_types_entry.npcspecialattks) + "'"); + update_values.push_back(columns[28] + " = '" + EscapeString(npc_types_entry.special_abilities) + "'"); + update_values.push_back(columns[29] + " = " + std::to_string(npc_types_entry.aggroradius)); + update_values.push_back(columns[30] + " = " + std::to_string(npc_types_entry.assistradius)); + update_values.push_back(columns[31] + " = " + std::to_string(npc_types_entry.face)); + update_values.push_back(columns[32] + " = " + std::to_string(npc_types_entry.luclin_hairstyle)); + update_values.push_back(columns[33] + " = " + std::to_string(npc_types_entry.luclin_haircolor)); + update_values.push_back(columns[34] + " = " + std::to_string(npc_types_entry.luclin_eyecolor)); + update_values.push_back(columns[35] + " = " + std::to_string(npc_types_entry.luclin_eyecolor2)); + update_values.push_back(columns[36] + " = " + std::to_string(npc_types_entry.luclin_beardcolor)); + update_values.push_back(columns[37] + " = " + std::to_string(npc_types_entry.luclin_beard)); + update_values.push_back(columns[38] + " = " + std::to_string(npc_types_entry.drakkin_heritage)); + update_values.push_back(columns[39] + " = " + std::to_string(npc_types_entry.drakkin_tattoo)); + update_values.push_back(columns[40] + " = " + std::to_string(npc_types_entry.drakkin_details)); + update_values.push_back(columns[41] + " = " + std::to_string(npc_types_entry.armortint_id)); + update_values.push_back(columns[42] + " = " + std::to_string(npc_types_entry.armortint_red)); + update_values.push_back(columns[43] + " = " + std::to_string(npc_types_entry.armortint_green)); + update_values.push_back(columns[44] + " = " + std::to_string(npc_types_entry.armortint_blue)); + update_values.push_back(columns[45] + " = " + std::to_string(npc_types_entry.d_melee_texture1)); + update_values.push_back(columns[46] + " = " + std::to_string(npc_types_entry.d_melee_texture2)); + update_values.push_back(columns[47] + " = '" + EscapeString(npc_types_entry.ammo_idfile) + "'"); + update_values.push_back(columns[48] + " = " + std::to_string(npc_types_entry.prim_melee_type)); + update_values.push_back(columns[49] + " = " + std::to_string(npc_types_entry.sec_melee_type)); + update_values.push_back(columns[50] + " = " + std::to_string(npc_types_entry.ranged_type)); + update_values.push_back(columns[51] + " = " + std::to_string(npc_types_entry.runspeed)); + update_values.push_back(columns[52] + " = " + std::to_string(npc_types_entry.MR)); + update_values.push_back(columns[53] + " = " + std::to_string(npc_types_entry.CR)); + update_values.push_back(columns[54] + " = " + std::to_string(npc_types_entry.DR)); + update_values.push_back(columns[55] + " = " + std::to_string(npc_types_entry.FR)); + update_values.push_back(columns[56] + " = " + std::to_string(npc_types_entry.PR)); + update_values.push_back(columns[57] + " = " + std::to_string(npc_types_entry.Corrup)); + update_values.push_back(columns[58] + " = " + std::to_string(npc_types_entry.PhR)); + update_values.push_back(columns[59] + " = " + std::to_string(npc_types_entry.see_invis)); + update_values.push_back(columns[60] + " = " + std::to_string(npc_types_entry.see_invis_undead)); + update_values.push_back(columns[61] + " = " + std::to_string(npc_types_entry.qglobal)); + update_values.push_back(columns[62] + " = " + std::to_string(npc_types_entry.AC)); + update_values.push_back(columns[63] + " = " + std::to_string(npc_types_entry.npc_aggro)); + update_values.push_back(columns[64] + " = " + std::to_string(npc_types_entry.spawn_limit)); + update_values.push_back(columns[65] + " = " + std::to_string(npc_types_entry.attack_speed)); + update_values.push_back(columns[66] + " = " + std::to_string(npc_types_entry.attack_delay)); + update_values.push_back(columns[67] + " = " + std::to_string(npc_types_entry.findable)); + update_values.push_back(columns[68] + " = " + std::to_string(npc_types_entry.STR)); + update_values.push_back(columns[69] + " = " + std::to_string(npc_types_entry.STA)); + update_values.push_back(columns[70] + " = " + std::to_string(npc_types_entry.DEX)); + update_values.push_back(columns[71] + " = " + std::to_string(npc_types_entry.AGI)); + update_values.push_back(columns[72] + " = " + std::to_string(npc_types_entry._INT)); + update_values.push_back(columns[73] + " = " + std::to_string(npc_types_entry.WIS)); + update_values.push_back(columns[74] + " = " + std::to_string(npc_types_entry.CHA)); + update_values.push_back(columns[75] + " = " + std::to_string(npc_types_entry.see_hide)); + update_values.push_back(columns[76] + " = " + std::to_string(npc_types_entry.see_improved_hide)); + update_values.push_back(columns[77] + " = " + std::to_string(npc_types_entry.trackable)); + update_values.push_back(columns[78] + " = " + std::to_string(npc_types_entry.isbot)); + update_values.push_back(columns[79] + " = " + std::to_string(npc_types_entry.exclude)); + update_values.push_back(columns[80] + " = " + std::to_string(npc_types_entry.ATK)); + update_values.push_back(columns[81] + " = " + std::to_string(npc_types_entry.Accuracy)); + update_values.push_back(columns[82] + " = " + std::to_string(npc_types_entry.Avoidance)); + update_values.push_back(columns[83] + " = " + std::to_string(npc_types_entry.slow_mitigation)); + update_values.push_back(columns[84] + " = " + std::to_string(npc_types_entry.version)); + update_values.push_back(columns[85] + " = " + std::to_string(npc_types_entry.maxlevel)); + update_values.push_back(columns[86] + " = " + std::to_string(npc_types_entry.scalerate)); + update_values.push_back(columns[87] + " = " + std::to_string(npc_types_entry.private_corpse)); + update_values.push_back(columns[88] + " = " + std::to_string(npc_types_entry.unique_spawn_by_name)); + update_values.push_back(columns[89] + " = " + std::to_string(npc_types_entry.underwater)); + update_values.push_back(columns[90] + " = " + std::to_string(npc_types_entry.isquest)); + update_values.push_back(columns[91] + " = " + std::to_string(npc_types_entry.emoteid)); + update_values.push_back(columns[92] + " = " + std::to_string(npc_types_entry.spellscale)); + update_values.push_back(columns[93] + " = " + std::to_string(npc_types_entry.healscale)); + update_values.push_back(columns[94] + " = " + std::to_string(npc_types_entry.no_target_hotkey)); + update_values.push_back(columns[95] + " = " + std::to_string(npc_types_entry.raid_target)); + update_values.push_back(columns[96] + " = " + std::to_string(npc_types_entry.armtexture)); + update_values.push_back(columns[97] + " = " + std::to_string(npc_types_entry.bracertexture)); + update_values.push_back(columns[98] + " = " + std::to_string(npc_types_entry.handtexture)); + update_values.push_back(columns[99] + " = " + std::to_string(npc_types_entry.legtexture)); + update_values.push_back(columns[100] + " = " + std::to_string(npc_types_entry.feettexture)); + update_values.push_back(columns[101] + " = " + std::to_string(npc_types_entry.light)); + update_values.push_back(columns[102] + " = " + std::to_string(npc_types_entry.walkspeed)); + update_values.push_back(columns[103] + " = " + std::to_string(npc_types_entry.peqid)); + update_values.push_back(columns[104] + " = " + std::to_string(npc_types_entry.unique_)); + update_values.push_back(columns[105] + " = " + std::to_string(npc_types_entry.fixed)); + update_values.push_back(columns[106] + " = " + std::to_string(npc_types_entry.ignore_despawn)); + update_values.push_back(columns[107] + " = " + std::to_string(npc_types_entry.show_name)); + update_values.push_back(columns[108] + " = " + std::to_string(npc_types_entry.untargetable)); + update_values.push_back(columns[109] + " = " + std::to_string(npc_types_entry.charm_ac)); + update_values.push_back(columns[110] + " = " + std::to_string(npc_types_entry.charm_min_dmg)); + update_values.push_back(columns[111] + " = " + std::to_string(npc_types_entry.charm_max_dmg)); + update_values.push_back(columns[112] + " = " + std::to_string(npc_types_entry.charm_attack_delay)); + update_values.push_back(columns[113] + " = " + std::to_string(npc_types_entry.charm_accuracy_rating)); + update_values.push_back(columns[114] + " = " + std::to_string(npc_types_entry.charm_avoidance_rating)); + update_values.push_back(columns[115] + " = " + std::to_string(npc_types_entry.charm_atk)); + update_values.push_back(columns[116] + " = " + std::to_string(npc_types_entry.skip_global_loot)); + update_values.push_back(columns[117] + " = " + std::to_string(npc_types_entry.rare_spawn)); + update_values.push_back(columns[118] + " = " + std::to_string(npc_types_entry.stuck_behavior)); + update_values.push_back(columns[119] + " = " + std::to_string(npc_types_entry.model)); + update_values.push_back(columns[120] + " = " + std::to_string(npc_types_entry.flymode)); + update_values.push_back(columns[121] + " = " + std::to_string(npc_types_entry.always_aggro)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + npc_types_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static NpcTypes InsertOne( + NpcTypes npc_types_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(npc_types_entry.name) + "'"); + insert_values.push_back("'" + EscapeString(npc_types_entry.lastname) + "'"); + insert_values.push_back(std::to_string(npc_types_entry.level)); + insert_values.push_back(std::to_string(npc_types_entry.race)); + insert_values.push_back(std::to_string(npc_types_entry.class)); + insert_values.push_back(std::to_string(npc_types_entry.bodytype)); + insert_values.push_back(std::to_string(npc_types_entry.hp)); + insert_values.push_back(std::to_string(npc_types_entry.mana)); + insert_values.push_back(std::to_string(npc_types_entry.gender)); + insert_values.push_back(std::to_string(npc_types_entry.texture)); + insert_values.push_back(std::to_string(npc_types_entry.helmtexture)); + insert_values.push_back(std::to_string(npc_types_entry.herosforgemodel)); + insert_values.push_back(std::to_string(npc_types_entry.size)); + insert_values.push_back(std::to_string(npc_types_entry.hp_regen_rate)); + insert_values.push_back(std::to_string(npc_types_entry.mana_regen_rate)); + insert_values.push_back(std::to_string(npc_types_entry.loottable_id)); + insert_values.push_back(std::to_string(npc_types_entry.merchant_id)); + insert_values.push_back(std::to_string(npc_types_entry.alt_currency_id)); + insert_values.push_back(std::to_string(npc_types_entry.npc_spells_id)); + insert_values.push_back(std::to_string(npc_types_entry.npc_spells_effects_id)); + insert_values.push_back(std::to_string(npc_types_entry.npc_faction_id)); + insert_values.push_back(std::to_string(npc_types_entry.adventure_template_id)); + insert_values.push_back(std::to_string(npc_types_entry.trap_template)); + insert_values.push_back(std::to_string(npc_types_entry.mindmg)); + insert_values.push_back(std::to_string(npc_types_entry.maxdmg)); + insert_values.push_back(std::to_string(npc_types_entry.attack_count)); + insert_values.push_back("'" + EscapeString(npc_types_entry.npcspecialattks) + "'"); + insert_values.push_back("'" + EscapeString(npc_types_entry.special_abilities) + "'"); + insert_values.push_back(std::to_string(npc_types_entry.aggroradius)); + insert_values.push_back(std::to_string(npc_types_entry.assistradius)); + insert_values.push_back(std::to_string(npc_types_entry.face)); + insert_values.push_back(std::to_string(npc_types_entry.luclin_hairstyle)); + insert_values.push_back(std::to_string(npc_types_entry.luclin_haircolor)); + insert_values.push_back(std::to_string(npc_types_entry.luclin_eyecolor)); + insert_values.push_back(std::to_string(npc_types_entry.luclin_eyecolor2)); + insert_values.push_back(std::to_string(npc_types_entry.luclin_beardcolor)); + insert_values.push_back(std::to_string(npc_types_entry.luclin_beard)); + insert_values.push_back(std::to_string(npc_types_entry.drakkin_heritage)); + insert_values.push_back(std::to_string(npc_types_entry.drakkin_tattoo)); + insert_values.push_back(std::to_string(npc_types_entry.drakkin_details)); + insert_values.push_back(std::to_string(npc_types_entry.armortint_id)); + insert_values.push_back(std::to_string(npc_types_entry.armortint_red)); + insert_values.push_back(std::to_string(npc_types_entry.armortint_green)); + insert_values.push_back(std::to_string(npc_types_entry.armortint_blue)); + insert_values.push_back(std::to_string(npc_types_entry.d_melee_texture1)); + insert_values.push_back(std::to_string(npc_types_entry.d_melee_texture2)); + insert_values.push_back("'" + EscapeString(npc_types_entry.ammo_idfile) + "'"); + insert_values.push_back(std::to_string(npc_types_entry.prim_melee_type)); + insert_values.push_back(std::to_string(npc_types_entry.sec_melee_type)); + insert_values.push_back(std::to_string(npc_types_entry.ranged_type)); + insert_values.push_back(std::to_string(npc_types_entry.runspeed)); + insert_values.push_back(std::to_string(npc_types_entry.MR)); + insert_values.push_back(std::to_string(npc_types_entry.CR)); + insert_values.push_back(std::to_string(npc_types_entry.DR)); + insert_values.push_back(std::to_string(npc_types_entry.FR)); + insert_values.push_back(std::to_string(npc_types_entry.PR)); + insert_values.push_back(std::to_string(npc_types_entry.Corrup)); + insert_values.push_back(std::to_string(npc_types_entry.PhR)); + insert_values.push_back(std::to_string(npc_types_entry.see_invis)); + insert_values.push_back(std::to_string(npc_types_entry.see_invis_undead)); + insert_values.push_back(std::to_string(npc_types_entry.qglobal)); + insert_values.push_back(std::to_string(npc_types_entry.AC)); + insert_values.push_back(std::to_string(npc_types_entry.npc_aggro)); + insert_values.push_back(std::to_string(npc_types_entry.spawn_limit)); + insert_values.push_back(std::to_string(npc_types_entry.attack_speed)); + insert_values.push_back(std::to_string(npc_types_entry.attack_delay)); + insert_values.push_back(std::to_string(npc_types_entry.findable)); + insert_values.push_back(std::to_string(npc_types_entry.STR)); + insert_values.push_back(std::to_string(npc_types_entry.STA)); + insert_values.push_back(std::to_string(npc_types_entry.DEX)); + insert_values.push_back(std::to_string(npc_types_entry.AGI)); + insert_values.push_back(std::to_string(npc_types_entry._INT)); + insert_values.push_back(std::to_string(npc_types_entry.WIS)); + insert_values.push_back(std::to_string(npc_types_entry.CHA)); + insert_values.push_back(std::to_string(npc_types_entry.see_hide)); + insert_values.push_back(std::to_string(npc_types_entry.see_improved_hide)); + insert_values.push_back(std::to_string(npc_types_entry.trackable)); + insert_values.push_back(std::to_string(npc_types_entry.isbot)); + insert_values.push_back(std::to_string(npc_types_entry.exclude)); + insert_values.push_back(std::to_string(npc_types_entry.ATK)); + insert_values.push_back(std::to_string(npc_types_entry.Accuracy)); + insert_values.push_back(std::to_string(npc_types_entry.Avoidance)); + insert_values.push_back(std::to_string(npc_types_entry.slow_mitigation)); + insert_values.push_back(std::to_string(npc_types_entry.version)); + insert_values.push_back(std::to_string(npc_types_entry.maxlevel)); + insert_values.push_back(std::to_string(npc_types_entry.scalerate)); + insert_values.push_back(std::to_string(npc_types_entry.private_corpse)); + insert_values.push_back(std::to_string(npc_types_entry.unique_spawn_by_name)); + insert_values.push_back(std::to_string(npc_types_entry.underwater)); + insert_values.push_back(std::to_string(npc_types_entry.isquest)); + insert_values.push_back(std::to_string(npc_types_entry.emoteid)); + insert_values.push_back(std::to_string(npc_types_entry.spellscale)); + insert_values.push_back(std::to_string(npc_types_entry.healscale)); + insert_values.push_back(std::to_string(npc_types_entry.no_target_hotkey)); + insert_values.push_back(std::to_string(npc_types_entry.raid_target)); + insert_values.push_back(std::to_string(npc_types_entry.armtexture)); + insert_values.push_back(std::to_string(npc_types_entry.bracertexture)); + insert_values.push_back(std::to_string(npc_types_entry.handtexture)); + insert_values.push_back(std::to_string(npc_types_entry.legtexture)); + insert_values.push_back(std::to_string(npc_types_entry.feettexture)); + insert_values.push_back(std::to_string(npc_types_entry.light)); + insert_values.push_back(std::to_string(npc_types_entry.walkspeed)); + insert_values.push_back(std::to_string(npc_types_entry.peqid)); + insert_values.push_back(std::to_string(npc_types_entry.unique_)); + insert_values.push_back(std::to_string(npc_types_entry.fixed)); + insert_values.push_back(std::to_string(npc_types_entry.ignore_despawn)); + insert_values.push_back(std::to_string(npc_types_entry.show_name)); + insert_values.push_back(std::to_string(npc_types_entry.untargetable)); + insert_values.push_back(std::to_string(npc_types_entry.charm_ac)); + insert_values.push_back(std::to_string(npc_types_entry.charm_min_dmg)); + insert_values.push_back(std::to_string(npc_types_entry.charm_max_dmg)); + insert_values.push_back(std::to_string(npc_types_entry.charm_attack_delay)); + insert_values.push_back(std::to_string(npc_types_entry.charm_accuracy_rating)); + insert_values.push_back(std::to_string(npc_types_entry.charm_avoidance_rating)); + insert_values.push_back(std::to_string(npc_types_entry.charm_atk)); + insert_values.push_back(std::to_string(npc_types_entry.skip_global_loot)); + insert_values.push_back(std::to_string(npc_types_entry.rare_spawn)); + insert_values.push_back(std::to_string(npc_types_entry.stuck_behavior)); + insert_values.push_back(std::to_string(npc_types_entry.model)); + insert_values.push_back(std::to_string(npc_types_entry.flymode)); + insert_values.push_back(std::to_string(npc_types_entry.always_aggro)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + npc_types_entry.id = results.LastInsertedID(); + return npc_types_entry; + } + + npc_types_entry = NewEntity(); + + return npc_types_entry; + } + + static int InsertMany( + std::vector npc_types_entries + ) + { + std::vector insert_chunks; + + for (auto &npc_types_entry: npc_types_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(npc_types_entry.name) + "'"); + insert_values.push_back("'" + EscapeString(npc_types_entry.lastname) + "'"); + insert_values.push_back(std::to_string(npc_types_entry.level)); + insert_values.push_back(std::to_string(npc_types_entry.race)); + insert_values.push_back(std::to_string(npc_types_entry.class)); + insert_values.push_back(std::to_string(npc_types_entry.bodytype)); + insert_values.push_back(std::to_string(npc_types_entry.hp)); + insert_values.push_back(std::to_string(npc_types_entry.mana)); + insert_values.push_back(std::to_string(npc_types_entry.gender)); + insert_values.push_back(std::to_string(npc_types_entry.texture)); + insert_values.push_back(std::to_string(npc_types_entry.helmtexture)); + insert_values.push_back(std::to_string(npc_types_entry.herosforgemodel)); + insert_values.push_back(std::to_string(npc_types_entry.size)); + insert_values.push_back(std::to_string(npc_types_entry.hp_regen_rate)); + insert_values.push_back(std::to_string(npc_types_entry.mana_regen_rate)); + insert_values.push_back(std::to_string(npc_types_entry.loottable_id)); + insert_values.push_back(std::to_string(npc_types_entry.merchant_id)); + insert_values.push_back(std::to_string(npc_types_entry.alt_currency_id)); + insert_values.push_back(std::to_string(npc_types_entry.npc_spells_id)); + insert_values.push_back(std::to_string(npc_types_entry.npc_spells_effects_id)); + insert_values.push_back(std::to_string(npc_types_entry.npc_faction_id)); + insert_values.push_back(std::to_string(npc_types_entry.adventure_template_id)); + insert_values.push_back(std::to_string(npc_types_entry.trap_template)); + insert_values.push_back(std::to_string(npc_types_entry.mindmg)); + insert_values.push_back(std::to_string(npc_types_entry.maxdmg)); + insert_values.push_back(std::to_string(npc_types_entry.attack_count)); + insert_values.push_back("'" + EscapeString(npc_types_entry.npcspecialattks) + "'"); + insert_values.push_back("'" + EscapeString(npc_types_entry.special_abilities) + "'"); + insert_values.push_back(std::to_string(npc_types_entry.aggroradius)); + insert_values.push_back(std::to_string(npc_types_entry.assistradius)); + insert_values.push_back(std::to_string(npc_types_entry.face)); + insert_values.push_back(std::to_string(npc_types_entry.luclin_hairstyle)); + insert_values.push_back(std::to_string(npc_types_entry.luclin_haircolor)); + insert_values.push_back(std::to_string(npc_types_entry.luclin_eyecolor)); + insert_values.push_back(std::to_string(npc_types_entry.luclin_eyecolor2)); + insert_values.push_back(std::to_string(npc_types_entry.luclin_beardcolor)); + insert_values.push_back(std::to_string(npc_types_entry.luclin_beard)); + insert_values.push_back(std::to_string(npc_types_entry.drakkin_heritage)); + insert_values.push_back(std::to_string(npc_types_entry.drakkin_tattoo)); + insert_values.push_back(std::to_string(npc_types_entry.drakkin_details)); + insert_values.push_back(std::to_string(npc_types_entry.armortint_id)); + insert_values.push_back(std::to_string(npc_types_entry.armortint_red)); + insert_values.push_back(std::to_string(npc_types_entry.armortint_green)); + insert_values.push_back(std::to_string(npc_types_entry.armortint_blue)); + insert_values.push_back(std::to_string(npc_types_entry.d_melee_texture1)); + insert_values.push_back(std::to_string(npc_types_entry.d_melee_texture2)); + insert_values.push_back("'" + EscapeString(npc_types_entry.ammo_idfile) + "'"); + insert_values.push_back(std::to_string(npc_types_entry.prim_melee_type)); + insert_values.push_back(std::to_string(npc_types_entry.sec_melee_type)); + insert_values.push_back(std::to_string(npc_types_entry.ranged_type)); + insert_values.push_back(std::to_string(npc_types_entry.runspeed)); + insert_values.push_back(std::to_string(npc_types_entry.MR)); + insert_values.push_back(std::to_string(npc_types_entry.CR)); + insert_values.push_back(std::to_string(npc_types_entry.DR)); + insert_values.push_back(std::to_string(npc_types_entry.FR)); + insert_values.push_back(std::to_string(npc_types_entry.PR)); + insert_values.push_back(std::to_string(npc_types_entry.Corrup)); + insert_values.push_back(std::to_string(npc_types_entry.PhR)); + insert_values.push_back(std::to_string(npc_types_entry.see_invis)); + insert_values.push_back(std::to_string(npc_types_entry.see_invis_undead)); + insert_values.push_back(std::to_string(npc_types_entry.qglobal)); + insert_values.push_back(std::to_string(npc_types_entry.AC)); + insert_values.push_back(std::to_string(npc_types_entry.npc_aggro)); + insert_values.push_back(std::to_string(npc_types_entry.spawn_limit)); + insert_values.push_back(std::to_string(npc_types_entry.attack_speed)); + insert_values.push_back(std::to_string(npc_types_entry.attack_delay)); + insert_values.push_back(std::to_string(npc_types_entry.findable)); + insert_values.push_back(std::to_string(npc_types_entry.STR)); + insert_values.push_back(std::to_string(npc_types_entry.STA)); + insert_values.push_back(std::to_string(npc_types_entry.DEX)); + insert_values.push_back(std::to_string(npc_types_entry.AGI)); + insert_values.push_back(std::to_string(npc_types_entry._INT)); + insert_values.push_back(std::to_string(npc_types_entry.WIS)); + insert_values.push_back(std::to_string(npc_types_entry.CHA)); + insert_values.push_back(std::to_string(npc_types_entry.see_hide)); + insert_values.push_back(std::to_string(npc_types_entry.see_improved_hide)); + insert_values.push_back(std::to_string(npc_types_entry.trackable)); + insert_values.push_back(std::to_string(npc_types_entry.isbot)); + insert_values.push_back(std::to_string(npc_types_entry.exclude)); + insert_values.push_back(std::to_string(npc_types_entry.ATK)); + insert_values.push_back(std::to_string(npc_types_entry.Accuracy)); + insert_values.push_back(std::to_string(npc_types_entry.Avoidance)); + insert_values.push_back(std::to_string(npc_types_entry.slow_mitigation)); + insert_values.push_back(std::to_string(npc_types_entry.version)); + insert_values.push_back(std::to_string(npc_types_entry.maxlevel)); + insert_values.push_back(std::to_string(npc_types_entry.scalerate)); + insert_values.push_back(std::to_string(npc_types_entry.private_corpse)); + insert_values.push_back(std::to_string(npc_types_entry.unique_spawn_by_name)); + insert_values.push_back(std::to_string(npc_types_entry.underwater)); + insert_values.push_back(std::to_string(npc_types_entry.isquest)); + insert_values.push_back(std::to_string(npc_types_entry.emoteid)); + insert_values.push_back(std::to_string(npc_types_entry.spellscale)); + insert_values.push_back(std::to_string(npc_types_entry.healscale)); + insert_values.push_back(std::to_string(npc_types_entry.no_target_hotkey)); + insert_values.push_back(std::to_string(npc_types_entry.raid_target)); + insert_values.push_back(std::to_string(npc_types_entry.armtexture)); + insert_values.push_back(std::to_string(npc_types_entry.bracertexture)); + insert_values.push_back(std::to_string(npc_types_entry.handtexture)); + insert_values.push_back(std::to_string(npc_types_entry.legtexture)); + insert_values.push_back(std::to_string(npc_types_entry.feettexture)); + insert_values.push_back(std::to_string(npc_types_entry.light)); + insert_values.push_back(std::to_string(npc_types_entry.walkspeed)); + insert_values.push_back(std::to_string(npc_types_entry.peqid)); + insert_values.push_back(std::to_string(npc_types_entry.unique_)); + insert_values.push_back(std::to_string(npc_types_entry.fixed)); + insert_values.push_back(std::to_string(npc_types_entry.ignore_despawn)); + insert_values.push_back(std::to_string(npc_types_entry.show_name)); + insert_values.push_back(std::to_string(npc_types_entry.untargetable)); + insert_values.push_back(std::to_string(npc_types_entry.charm_ac)); + insert_values.push_back(std::to_string(npc_types_entry.charm_min_dmg)); + insert_values.push_back(std::to_string(npc_types_entry.charm_max_dmg)); + insert_values.push_back(std::to_string(npc_types_entry.charm_attack_delay)); + insert_values.push_back(std::to_string(npc_types_entry.charm_accuracy_rating)); + insert_values.push_back(std::to_string(npc_types_entry.charm_avoidance_rating)); + insert_values.push_back(std::to_string(npc_types_entry.charm_atk)); + insert_values.push_back(std::to_string(npc_types_entry.skip_global_loot)); + insert_values.push_back(std::to_string(npc_types_entry.rare_spawn)); + insert_values.push_back(std::to_string(npc_types_entry.stuck_behavior)); + insert_values.push_back(std::to_string(npc_types_entry.model)); + insert_values.push_back(std::to_string(npc_types_entry.flymode)); + insert_values.push_back(std::to_string(npc_types_entry.always_aggro)); + + 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) { + NpcTypes entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.lastname = row[2] ? row[2] : ""; + entry.level = atoi(row[3]); + entry.race = atoi(row[4]); + entry.class = atoi(row[5]); + entry.bodytype = atoi(row[6]); + entry.hp = atoi(row[7]); + entry.mana = atoi(row[8]); + entry.gender = atoi(row[9]); + entry.texture = atoi(row[10]); + entry.helmtexture = atoi(row[11]); + entry.herosforgemodel = atoi(row[12]); + entry.size = atof(row[13]); + entry.hp_regen_rate = atoi(row[14]); + entry.mana_regen_rate = atoi(row[15]); + entry.loottable_id = atoi(row[16]); + entry.merchant_id = atoi(row[17]); + entry.alt_currency_id = atoi(row[18]); + entry.npc_spells_id = atoi(row[19]); + entry.npc_spells_effects_id = atoi(row[20]); + entry.npc_faction_id = atoi(row[21]); + entry.adventure_template_id = atoi(row[22]); + entry.trap_template = atoi(row[23]); + entry.mindmg = atoi(row[24]); + entry.maxdmg = atoi(row[25]); + entry.attack_count = atoi(row[26]); + entry.npcspecialattks = row[27] ? row[27] : ""; + entry.special_abilities = row[28] ? row[28] : ""; + entry.aggroradius = atoi(row[29]); + entry.assistradius = atoi(row[30]); + entry.face = atoi(row[31]); + entry.luclin_hairstyle = atoi(row[32]); + entry.luclin_haircolor = atoi(row[33]); + entry.luclin_eyecolor = atoi(row[34]); + entry.luclin_eyecolor2 = atoi(row[35]); + entry.luclin_beardcolor = atoi(row[36]); + entry.luclin_beard = atoi(row[37]); + entry.drakkin_heritage = atoi(row[38]); + entry.drakkin_tattoo = atoi(row[39]); + entry.drakkin_details = atoi(row[40]); + entry.armortint_id = atoi(row[41]); + entry.armortint_red = atoi(row[42]); + entry.armortint_green = atoi(row[43]); + entry.armortint_blue = atoi(row[44]); + entry.d_melee_texture1 = atoi(row[45]); + entry.d_melee_texture2 = atoi(row[46]); + entry.ammo_idfile = row[47] ? row[47] : ""; + entry.prim_melee_type = atoi(row[48]); + entry.sec_melee_type = atoi(row[49]); + entry.ranged_type = atoi(row[50]); + entry.runspeed = atof(row[51]); + entry.MR = atoi(row[52]); + entry.CR = atoi(row[53]); + entry.DR = atoi(row[54]); + entry.FR = atoi(row[55]); + entry.PR = atoi(row[56]); + entry.Corrup = atoi(row[57]); + entry.PhR = atoi(row[58]); + entry.see_invis = atoi(row[59]); + entry.see_invis_undead = atoi(row[60]); + entry.qglobal = atoi(row[61]); + entry.AC = atoi(row[62]); + entry.npc_aggro = atoi(row[63]); + entry.spawn_limit = atoi(row[64]); + entry.attack_speed = atof(row[65]); + entry.attack_delay = atoi(row[66]); + entry.findable = atoi(row[67]); + entry.STR = atoi(row[68]); + entry.STA = atoi(row[69]); + entry.DEX = atoi(row[70]); + entry.AGI = atoi(row[71]); + entry._INT = atoi(row[72]); + entry.WIS = atoi(row[73]); + entry.CHA = atoi(row[74]); + entry.see_hide = atoi(row[75]); + entry.see_improved_hide = atoi(row[76]); + entry.trackable = atoi(row[77]); + entry.isbot = atoi(row[78]); + entry.exclude = atoi(row[79]); + entry.ATK = atoi(row[80]); + entry.Accuracy = atoi(row[81]); + entry.Avoidance = atoi(row[82]); + entry.slow_mitigation = atoi(row[83]); + entry.version = atoi(row[84]); + entry.maxlevel = atoi(row[85]); + entry.scalerate = atoi(row[86]); + entry.private_corpse = atoi(row[87]); + entry.unique_spawn_by_name = atoi(row[88]); + entry.underwater = atoi(row[89]); + entry.isquest = atoi(row[90]); + entry.emoteid = atoi(row[91]); + entry.spellscale = atof(row[92]); + entry.healscale = atof(row[93]); + entry.no_target_hotkey = atoi(row[94]); + entry.raid_target = atoi(row[95]); + entry.armtexture = atoi(row[96]); + entry.bracertexture = atoi(row[97]); + entry.handtexture = atoi(row[98]); + entry.legtexture = atoi(row[99]); + entry.feettexture = atoi(row[100]); + entry.light = atoi(row[101]); + entry.walkspeed = atoi(row[102]); + entry.peqid = atoi(row[103]); + entry.unique_ = atoi(row[104]); + entry.fixed = atoi(row[105]); + entry.ignore_despawn = atoi(row[106]); + entry.show_name = atoi(row[107]); + entry.untargetable = atoi(row[108]); + entry.charm_ac = atoi(row[109]); + entry.charm_min_dmg = atoi(row[110]); + entry.charm_max_dmg = atoi(row[111]); + entry.charm_attack_delay = atoi(row[112]); + entry.charm_accuracy_rating = atoi(row[113]); + entry.charm_avoidance_rating = atoi(row[114]); + entry.charm_atk = atoi(row[115]); + entry.skip_global_loot = atoi(row[116]); + entry.rare_spawn = atoi(row[117]); + entry.stuck_behavior = atoi(row[118]); + entry.model = atoi(row[119]); + entry.flymode = atoi(row[120]); + entry.always_aggro = atoi(row[121]); + + 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) { + NpcTypes entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.lastname = row[2] ? row[2] : ""; + entry.level = atoi(row[3]); + entry.race = atoi(row[4]); + entry.class = atoi(row[5]); + entry.bodytype = atoi(row[6]); + entry.hp = atoi(row[7]); + entry.mana = atoi(row[8]); + entry.gender = atoi(row[9]); + entry.texture = atoi(row[10]); + entry.helmtexture = atoi(row[11]); + entry.herosforgemodel = atoi(row[12]); + entry.size = atof(row[13]); + entry.hp_regen_rate = atoi(row[14]); + entry.mana_regen_rate = atoi(row[15]); + entry.loottable_id = atoi(row[16]); + entry.merchant_id = atoi(row[17]); + entry.alt_currency_id = atoi(row[18]); + entry.npc_spells_id = atoi(row[19]); + entry.npc_spells_effects_id = atoi(row[20]); + entry.npc_faction_id = atoi(row[21]); + entry.adventure_template_id = atoi(row[22]); + entry.trap_template = atoi(row[23]); + entry.mindmg = atoi(row[24]); + entry.maxdmg = atoi(row[25]); + entry.attack_count = atoi(row[26]); + entry.npcspecialattks = row[27] ? row[27] : ""; + entry.special_abilities = row[28] ? row[28] : ""; + entry.aggroradius = atoi(row[29]); + entry.assistradius = atoi(row[30]); + entry.face = atoi(row[31]); + entry.luclin_hairstyle = atoi(row[32]); + entry.luclin_haircolor = atoi(row[33]); + entry.luclin_eyecolor = atoi(row[34]); + entry.luclin_eyecolor2 = atoi(row[35]); + entry.luclin_beardcolor = atoi(row[36]); + entry.luclin_beard = atoi(row[37]); + entry.drakkin_heritage = atoi(row[38]); + entry.drakkin_tattoo = atoi(row[39]); + entry.drakkin_details = atoi(row[40]); + entry.armortint_id = atoi(row[41]); + entry.armortint_red = atoi(row[42]); + entry.armortint_green = atoi(row[43]); + entry.armortint_blue = atoi(row[44]); + entry.d_melee_texture1 = atoi(row[45]); + entry.d_melee_texture2 = atoi(row[46]); + entry.ammo_idfile = row[47] ? row[47] : ""; + entry.prim_melee_type = atoi(row[48]); + entry.sec_melee_type = atoi(row[49]); + entry.ranged_type = atoi(row[50]); + entry.runspeed = atof(row[51]); + entry.MR = atoi(row[52]); + entry.CR = atoi(row[53]); + entry.DR = atoi(row[54]); + entry.FR = atoi(row[55]); + entry.PR = atoi(row[56]); + entry.Corrup = atoi(row[57]); + entry.PhR = atoi(row[58]); + entry.see_invis = atoi(row[59]); + entry.see_invis_undead = atoi(row[60]); + entry.qglobal = atoi(row[61]); + entry.AC = atoi(row[62]); + entry.npc_aggro = atoi(row[63]); + entry.spawn_limit = atoi(row[64]); + entry.attack_speed = atof(row[65]); + entry.attack_delay = atoi(row[66]); + entry.findable = atoi(row[67]); + entry.STR = atoi(row[68]); + entry.STA = atoi(row[69]); + entry.DEX = atoi(row[70]); + entry.AGI = atoi(row[71]); + entry._INT = atoi(row[72]); + entry.WIS = atoi(row[73]); + entry.CHA = atoi(row[74]); + entry.see_hide = atoi(row[75]); + entry.see_improved_hide = atoi(row[76]); + entry.trackable = atoi(row[77]); + entry.isbot = atoi(row[78]); + entry.exclude = atoi(row[79]); + entry.ATK = atoi(row[80]); + entry.Accuracy = atoi(row[81]); + entry.Avoidance = atoi(row[82]); + entry.slow_mitigation = atoi(row[83]); + entry.version = atoi(row[84]); + entry.maxlevel = atoi(row[85]); + entry.scalerate = atoi(row[86]); + entry.private_corpse = atoi(row[87]); + entry.unique_spawn_by_name = atoi(row[88]); + entry.underwater = atoi(row[89]); + entry.isquest = atoi(row[90]); + entry.emoteid = atoi(row[91]); + entry.spellscale = atof(row[92]); + entry.healscale = atof(row[93]); + entry.no_target_hotkey = atoi(row[94]); + entry.raid_target = atoi(row[95]); + entry.armtexture = atoi(row[96]); + entry.bracertexture = atoi(row[97]); + entry.handtexture = atoi(row[98]); + entry.legtexture = atoi(row[99]); + entry.feettexture = atoi(row[100]); + entry.light = atoi(row[101]); + entry.walkspeed = atoi(row[102]); + entry.peqid = atoi(row[103]); + entry.unique_ = atoi(row[104]); + entry.fixed = atoi(row[105]); + entry.ignore_despawn = atoi(row[106]); + entry.show_name = atoi(row[107]); + entry.untargetable = atoi(row[108]); + entry.charm_ac = atoi(row[109]); + entry.charm_min_dmg = atoi(row[110]); + entry.charm_max_dmg = atoi(row[111]); + entry.charm_attack_delay = atoi(row[112]); + entry.charm_accuracy_rating = atoi(row[113]); + entry.charm_avoidance_rating = atoi(row[114]); + entry.charm_atk = atoi(row[115]); + entry.skip_global_loot = atoi(row[116]); + entry.rare_spawn = atoi(row[117]); + entry.stuck_behavior = atoi(row[118]); + entry.model = atoi(row[119]); + entry.flymode = atoi(row[120]); + entry.always_aggro = atoi(row[121]); + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_NPC_TYPES_REPOSITORY_H diff --git a/common/repositories/base/base_npc_types_tint_repository.h b/common/repositories/base/base_npc_types_tint_repository.h new file mode 100644 index 000000000..3c11932ed --- /dev/null +++ b/common/repositories/base/base_npc_types_tint_repository.h @@ -0,0 +1,549 @@ +/** + * 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 on Apr 5, 2020 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_NPC_TYPES_TINT_REPOSITORY_H +#define EQEMU_BASE_NPC_TYPES_TINT_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseNpcTypesTintRepository { +public: + struct NpcTypesTint { + int id; + std::string tint_set_name; + int8 red1h; + int8 grn1h; + int8 blu1h; + int8 red2c; + int8 grn2c; + int8 blu2c; + int8 red3a; + int8 grn3a; + int8 blu3a; + int8 red4b; + int8 grn4b; + int8 blu4b; + int8 red5g; + int8 grn5g; + int8 blu5g; + int8 red6l; + int8 grn6l; + int8 blu6l; + int8 red7f; + int8 grn7f; + int8 blu7f; + int8 red8x; + int8 grn8x; + int8 blu8x; + int8 red9x; + int8 grn9x; + int8 blu9x; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "tint_set_name", + "red1h", + "grn1h", + "blu1h", + "red2c", + "grn2c", + "blu2c", + "red3a", + "grn3a", + "blu3a", + "red4b", + "grn4b", + "blu4b", + "red5g", + "grn5g", + "blu5g", + "red6l", + "grn6l", + "blu6l", + "red7f", + "grn7f", + "blu7f", + "red8x", + "grn8x", + "blu8x", + "red9x", + "grn9x", + "blu9x", + }; + } + + 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("npc_types_tint"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static NpcTypesTint NewEntity() + { + NpcTypesTint entry{}; + + entry.id = 0; + entry.tint_set_name = ""; + entry.red1h = 0; + entry.grn1h = 0; + entry.blu1h = 0; + entry.red2c = 0; + entry.grn2c = 0; + entry.blu2c = 0; + entry.red3a = 0; + entry.grn3a = 0; + entry.blu3a = 0; + entry.red4b = 0; + entry.grn4b = 0; + entry.blu4b = 0; + entry.red5g = 0; + entry.grn5g = 0; + entry.blu5g = 0; + entry.red6l = 0; + entry.grn6l = 0; + entry.blu6l = 0; + entry.red7f = 0; + entry.grn7f = 0; + entry.blu7f = 0; + entry.red8x = 0; + entry.grn8x = 0; + entry.blu8x = 0; + entry.red9x = 0; + entry.grn9x = 0; + entry.blu9x = 0; + + return entry; + } + + static NpcTypesTint GetNpcTypesTintEntry( + const std::vector &npc_types_tints, + int npc_types_tint_id + ) + { + for (auto &npc_types_tint : npc_types_tints) { + if (npc_types_tint.id == npc_types_tint_id) { + return npc_types_tint; + } + } + + return NewEntity(); + } + + static NpcTypesTint FindOne( + int npc_types_tint_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + npc_types_tint_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + NpcTypesTint entry{}; + + entry.id = atoi(row[0]); + entry.tint_set_name = row[1] ? row[1] : ""; + entry.red1h = atoi(row[2]); + entry.grn1h = atoi(row[3]); + entry.blu1h = atoi(row[4]); + entry.red2c = atoi(row[5]); + entry.grn2c = atoi(row[6]); + entry.blu2c = atoi(row[7]); + entry.red3a = atoi(row[8]); + entry.grn3a = atoi(row[9]); + entry.blu3a = atoi(row[10]); + entry.red4b = atoi(row[11]); + entry.grn4b = atoi(row[12]); + entry.blu4b = atoi(row[13]); + entry.red5g = atoi(row[14]); + entry.grn5g = atoi(row[15]); + entry.blu5g = atoi(row[16]); + entry.red6l = atoi(row[17]); + entry.grn6l = atoi(row[18]); + entry.blu6l = atoi(row[19]); + entry.red7f = atoi(row[20]); + entry.grn7f = atoi(row[21]); + entry.blu7f = atoi(row[22]); + entry.red8x = atoi(row[23]); + entry.grn8x = atoi(row[24]); + entry.blu8x = atoi(row[25]); + entry.red9x = atoi(row[26]); + entry.grn9x = atoi(row[27]); + entry.blu9x = atoi(row[28]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int npc_types_tint_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + npc_types_tint_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + NpcTypesTint npc_types_tint_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(npc_types_tint_entry.tint_set_name) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(npc_types_tint_entry.red1h)); + update_values.push_back(columns[3] + " = " + std::to_string(npc_types_tint_entry.grn1h)); + update_values.push_back(columns[4] + " = " + std::to_string(npc_types_tint_entry.blu1h)); + update_values.push_back(columns[5] + " = " + std::to_string(npc_types_tint_entry.red2c)); + update_values.push_back(columns[6] + " = " + std::to_string(npc_types_tint_entry.grn2c)); + update_values.push_back(columns[7] + " = " + std::to_string(npc_types_tint_entry.blu2c)); + update_values.push_back(columns[8] + " = " + std::to_string(npc_types_tint_entry.red3a)); + update_values.push_back(columns[9] + " = " + std::to_string(npc_types_tint_entry.grn3a)); + update_values.push_back(columns[10] + " = " + std::to_string(npc_types_tint_entry.blu3a)); + update_values.push_back(columns[11] + " = " + std::to_string(npc_types_tint_entry.red4b)); + update_values.push_back(columns[12] + " = " + std::to_string(npc_types_tint_entry.grn4b)); + update_values.push_back(columns[13] + " = " + std::to_string(npc_types_tint_entry.blu4b)); + update_values.push_back(columns[14] + " = " + std::to_string(npc_types_tint_entry.red5g)); + update_values.push_back(columns[15] + " = " + std::to_string(npc_types_tint_entry.grn5g)); + update_values.push_back(columns[16] + " = " + std::to_string(npc_types_tint_entry.blu5g)); + update_values.push_back(columns[17] + " = " + std::to_string(npc_types_tint_entry.red6l)); + update_values.push_back(columns[18] + " = " + std::to_string(npc_types_tint_entry.grn6l)); + update_values.push_back(columns[19] + " = " + std::to_string(npc_types_tint_entry.blu6l)); + update_values.push_back(columns[20] + " = " + std::to_string(npc_types_tint_entry.red7f)); + update_values.push_back(columns[21] + " = " + std::to_string(npc_types_tint_entry.grn7f)); + update_values.push_back(columns[22] + " = " + std::to_string(npc_types_tint_entry.blu7f)); + update_values.push_back(columns[23] + " = " + std::to_string(npc_types_tint_entry.red8x)); + update_values.push_back(columns[24] + " = " + std::to_string(npc_types_tint_entry.grn8x)); + update_values.push_back(columns[25] + " = " + std::to_string(npc_types_tint_entry.blu8x)); + update_values.push_back(columns[26] + " = " + std::to_string(npc_types_tint_entry.red9x)); + update_values.push_back(columns[27] + " = " + std::to_string(npc_types_tint_entry.grn9x)); + update_values.push_back(columns[28] + " = " + std::to_string(npc_types_tint_entry.blu9x)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + npc_types_tint_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static NpcTypesTint InsertOne( + NpcTypesTint npc_types_tint_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(npc_types_tint_entry.tint_set_name) + "'"); + insert_values.push_back(std::to_string(npc_types_tint_entry.red1h)); + insert_values.push_back(std::to_string(npc_types_tint_entry.grn1h)); + insert_values.push_back(std::to_string(npc_types_tint_entry.blu1h)); + insert_values.push_back(std::to_string(npc_types_tint_entry.red2c)); + insert_values.push_back(std::to_string(npc_types_tint_entry.grn2c)); + insert_values.push_back(std::to_string(npc_types_tint_entry.blu2c)); + insert_values.push_back(std::to_string(npc_types_tint_entry.red3a)); + insert_values.push_back(std::to_string(npc_types_tint_entry.grn3a)); + insert_values.push_back(std::to_string(npc_types_tint_entry.blu3a)); + insert_values.push_back(std::to_string(npc_types_tint_entry.red4b)); + insert_values.push_back(std::to_string(npc_types_tint_entry.grn4b)); + insert_values.push_back(std::to_string(npc_types_tint_entry.blu4b)); + insert_values.push_back(std::to_string(npc_types_tint_entry.red5g)); + insert_values.push_back(std::to_string(npc_types_tint_entry.grn5g)); + insert_values.push_back(std::to_string(npc_types_tint_entry.blu5g)); + insert_values.push_back(std::to_string(npc_types_tint_entry.red6l)); + insert_values.push_back(std::to_string(npc_types_tint_entry.grn6l)); + insert_values.push_back(std::to_string(npc_types_tint_entry.blu6l)); + insert_values.push_back(std::to_string(npc_types_tint_entry.red7f)); + insert_values.push_back(std::to_string(npc_types_tint_entry.grn7f)); + insert_values.push_back(std::to_string(npc_types_tint_entry.blu7f)); + insert_values.push_back(std::to_string(npc_types_tint_entry.red8x)); + insert_values.push_back(std::to_string(npc_types_tint_entry.grn8x)); + insert_values.push_back(std::to_string(npc_types_tint_entry.blu8x)); + insert_values.push_back(std::to_string(npc_types_tint_entry.red9x)); + insert_values.push_back(std::to_string(npc_types_tint_entry.grn9x)); + insert_values.push_back(std::to_string(npc_types_tint_entry.blu9x)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + npc_types_tint_entry.id = results.LastInsertedID(); + return npc_types_tint_entry; + } + + npc_types_tint_entry = NewEntity(); + + return npc_types_tint_entry; + } + + static int InsertMany( + std::vector npc_types_tint_entries + ) + { + std::vector insert_chunks; + + for (auto &npc_types_tint_entry: npc_types_tint_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(npc_types_tint_entry.tint_set_name) + "'"); + insert_values.push_back(std::to_string(npc_types_tint_entry.red1h)); + insert_values.push_back(std::to_string(npc_types_tint_entry.grn1h)); + insert_values.push_back(std::to_string(npc_types_tint_entry.blu1h)); + insert_values.push_back(std::to_string(npc_types_tint_entry.red2c)); + insert_values.push_back(std::to_string(npc_types_tint_entry.grn2c)); + insert_values.push_back(std::to_string(npc_types_tint_entry.blu2c)); + insert_values.push_back(std::to_string(npc_types_tint_entry.red3a)); + insert_values.push_back(std::to_string(npc_types_tint_entry.grn3a)); + insert_values.push_back(std::to_string(npc_types_tint_entry.blu3a)); + insert_values.push_back(std::to_string(npc_types_tint_entry.red4b)); + insert_values.push_back(std::to_string(npc_types_tint_entry.grn4b)); + insert_values.push_back(std::to_string(npc_types_tint_entry.blu4b)); + insert_values.push_back(std::to_string(npc_types_tint_entry.red5g)); + insert_values.push_back(std::to_string(npc_types_tint_entry.grn5g)); + insert_values.push_back(std::to_string(npc_types_tint_entry.blu5g)); + insert_values.push_back(std::to_string(npc_types_tint_entry.red6l)); + insert_values.push_back(std::to_string(npc_types_tint_entry.grn6l)); + insert_values.push_back(std::to_string(npc_types_tint_entry.blu6l)); + insert_values.push_back(std::to_string(npc_types_tint_entry.red7f)); + insert_values.push_back(std::to_string(npc_types_tint_entry.grn7f)); + insert_values.push_back(std::to_string(npc_types_tint_entry.blu7f)); + insert_values.push_back(std::to_string(npc_types_tint_entry.red8x)); + insert_values.push_back(std::to_string(npc_types_tint_entry.grn8x)); + insert_values.push_back(std::to_string(npc_types_tint_entry.blu8x)); + insert_values.push_back(std::to_string(npc_types_tint_entry.red9x)); + insert_values.push_back(std::to_string(npc_types_tint_entry.grn9x)); + insert_values.push_back(std::to_string(npc_types_tint_entry.blu9x)); + + 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) { + NpcTypesTint entry{}; + + entry.id = atoi(row[0]); + entry.tint_set_name = row[1] ? row[1] : ""; + entry.red1h = atoi(row[2]); + entry.grn1h = atoi(row[3]); + entry.blu1h = atoi(row[4]); + entry.red2c = atoi(row[5]); + entry.grn2c = atoi(row[6]); + entry.blu2c = atoi(row[7]); + entry.red3a = atoi(row[8]); + entry.grn3a = atoi(row[9]); + entry.blu3a = atoi(row[10]); + entry.red4b = atoi(row[11]); + entry.grn4b = atoi(row[12]); + entry.blu4b = atoi(row[13]); + entry.red5g = atoi(row[14]); + entry.grn5g = atoi(row[15]); + entry.blu5g = atoi(row[16]); + entry.red6l = atoi(row[17]); + entry.grn6l = atoi(row[18]); + entry.blu6l = atoi(row[19]); + entry.red7f = atoi(row[20]); + entry.grn7f = atoi(row[21]); + entry.blu7f = atoi(row[22]); + entry.red8x = atoi(row[23]); + entry.grn8x = atoi(row[24]); + entry.blu8x = atoi(row[25]); + entry.red9x = atoi(row[26]); + entry.grn9x = atoi(row[27]); + entry.blu9x = atoi(row[28]); + + 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) { + NpcTypesTint entry{}; + + entry.id = atoi(row[0]); + entry.tint_set_name = row[1] ? row[1] : ""; + entry.red1h = atoi(row[2]); + entry.grn1h = atoi(row[3]); + entry.blu1h = atoi(row[4]); + entry.red2c = atoi(row[5]); + entry.grn2c = atoi(row[6]); + entry.blu2c = atoi(row[7]); + entry.red3a = atoi(row[8]); + entry.grn3a = atoi(row[9]); + entry.blu3a = atoi(row[10]); + entry.red4b = atoi(row[11]); + entry.grn4b = atoi(row[12]); + entry.blu4b = atoi(row[13]); + entry.red5g = atoi(row[14]); + entry.grn5g = atoi(row[15]); + entry.blu5g = atoi(row[16]); + entry.red6l = atoi(row[17]); + entry.grn6l = atoi(row[18]); + entry.blu6l = atoi(row[19]); + entry.red7f = atoi(row[20]); + entry.grn7f = atoi(row[21]); + entry.blu7f = atoi(row[22]); + entry.red8x = atoi(row[23]); + entry.grn8x = atoi(row[24]); + entry.blu8x = atoi(row[25]); + entry.red9x = atoi(row[26]); + entry.grn9x = atoi(row[27]); + entry.blu9x = atoi(row[28]); + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_NPC_TYPES_TINT_REPOSITORY_H diff --git a/common/repositories/base/base_object_contents_repository.h b/common/repositories/base/base_object_contents_repository.h new file mode 100644 index 000000000..04a261381 --- /dev/null +++ b/common/repositories/base/base_object_contents_repository.h @@ -0,0 +1,393 @@ +/** + * 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 on Apr 5, 2020 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_OBJECT_CONTENTS_REPOSITORY_H +#define EQEMU_BASE_OBJECT_CONTENTS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseObjectContentsRepository { +public: + struct ObjectContents { + int zoneid; + int parentid; + int bagidx; + int itemid; + int16 charges; + std::string droptime; + int augslot1; + int augslot2; + int augslot3; + int augslot4; + int augslot5; + int augslot6; + }; + + static std::string PrimaryKey() + { + return std::string("bagidx"); + } + + static std::vector Columns() + { + return { + "zoneid", + "parentid", + "bagidx", + "itemid", + "charges", + "droptime", + "augslot1", + "augslot2", + "augslot3", + "augslot4", + "augslot5", + "augslot6", + }; + } + + 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("object_contents"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static ObjectContents NewEntity() + { + ObjectContents entry{}; + + entry.zoneid = 0; + entry.parentid = 0; + entry.bagidx = 0; + entry.itemid = 0; + entry.charges = 0; + entry.droptime = "0000-00-00 00:00:00"; + entry.augslot1 = 0; + entry.augslot2 = 0; + entry.augslot3 = 0; + entry.augslot4 = 0; + entry.augslot5 = 0; + entry.augslot6 = 0; + + return entry; + } + + static ObjectContents GetObjectContentsEntry( + const std::vector &object_contentss, + int object_contents_id + ) + { + for (auto &object_contents : object_contentss) { + if (object_contents.bagidx == object_contents_id) { + return object_contents; + } + } + + return NewEntity(); + } + + static ObjectContents FindOne( + int object_contents_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + object_contents_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + ObjectContents entry{}; + + entry.zoneid = atoi(row[0]); + entry.parentid = atoi(row[1]); + entry.bagidx = atoi(row[2]); + entry.itemid = atoi(row[3]); + entry.charges = atoi(row[4]); + entry.droptime = row[5] ? row[5] : ""; + entry.augslot1 = atoi(row[6]); + entry.augslot2 = atoi(row[7]); + entry.augslot3 = atoi(row[8]); + entry.augslot4 = atoi(row[9]); + entry.augslot5 = atoi(row[10]); + entry.augslot6 = atoi(row[11]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int object_contents_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + object_contents_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + ObjectContents object_contents_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[0] + " = " + std::to_string(object_contents_entry.zoneid)); + update_values.push_back(columns[3] + " = " + std::to_string(object_contents_entry.itemid)); + update_values.push_back(columns[4] + " = " + std::to_string(object_contents_entry.charges)); + update_values.push_back(columns[5] + " = '" + EscapeString(object_contents_entry.droptime) + "'"); + update_values.push_back(columns[6] + " = " + std::to_string(object_contents_entry.augslot1)); + update_values.push_back(columns[7] + " = " + std::to_string(object_contents_entry.augslot2)); + update_values.push_back(columns[8] + " = " + std::to_string(object_contents_entry.augslot3)); + update_values.push_back(columns[9] + " = " + std::to_string(object_contents_entry.augslot4)); + update_values.push_back(columns[10] + " = " + std::to_string(object_contents_entry.augslot5)); + update_values.push_back(columns[11] + " = " + std::to_string(object_contents_entry.augslot6)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + object_contents_entry.bagidx + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static ObjectContents InsertOne( + ObjectContents object_contents_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(object_contents_entry.zoneid)); + insert_values.push_back(std::to_string(object_contents_entry.itemid)); + insert_values.push_back(std::to_string(object_contents_entry.charges)); + insert_values.push_back("'" + EscapeString(object_contents_entry.droptime) + "'"); + insert_values.push_back(std::to_string(object_contents_entry.augslot1)); + insert_values.push_back(std::to_string(object_contents_entry.augslot2)); + insert_values.push_back(std::to_string(object_contents_entry.augslot3)); + insert_values.push_back(std::to_string(object_contents_entry.augslot4)); + insert_values.push_back(std::to_string(object_contents_entry.augslot5)); + insert_values.push_back(std::to_string(object_contents_entry.augslot6)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + object_contents_entry.id = results.LastInsertedID(); + return object_contents_entry; + } + + object_contents_entry = NewEntity(); + + return object_contents_entry; + } + + static int InsertMany( + std::vector object_contents_entries + ) + { + std::vector insert_chunks; + + for (auto &object_contents_entry: object_contents_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(object_contents_entry.zoneid)); + insert_values.push_back(std::to_string(object_contents_entry.itemid)); + insert_values.push_back(std::to_string(object_contents_entry.charges)); + insert_values.push_back("'" + EscapeString(object_contents_entry.droptime) + "'"); + insert_values.push_back(std::to_string(object_contents_entry.augslot1)); + insert_values.push_back(std::to_string(object_contents_entry.augslot2)); + insert_values.push_back(std::to_string(object_contents_entry.augslot3)); + insert_values.push_back(std::to_string(object_contents_entry.augslot4)); + insert_values.push_back(std::to_string(object_contents_entry.augslot5)); + insert_values.push_back(std::to_string(object_contents_entry.augslot6)); + + 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) { + ObjectContents entry{}; + + entry.zoneid = atoi(row[0]); + entry.parentid = atoi(row[1]); + entry.bagidx = atoi(row[2]); + entry.itemid = atoi(row[3]); + entry.charges = atoi(row[4]); + entry.droptime = row[5] ? row[5] : ""; + entry.augslot1 = atoi(row[6]); + entry.augslot2 = atoi(row[7]); + entry.augslot3 = atoi(row[8]); + entry.augslot4 = atoi(row[9]); + entry.augslot5 = atoi(row[10]); + entry.augslot6 = atoi(row[11]); + + 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) { + ObjectContents entry{}; + + entry.zoneid = atoi(row[0]); + entry.parentid = atoi(row[1]); + entry.bagidx = atoi(row[2]); + entry.itemid = atoi(row[3]); + entry.charges = atoi(row[4]); + entry.droptime = row[5] ? row[5] : ""; + entry.augslot1 = atoi(row[6]); + entry.augslot2 = atoi(row[7]); + entry.augslot3 = atoi(row[8]); + entry.augslot4 = atoi(row[9]); + entry.augslot5 = atoi(row[10]); + entry.augslot6 = atoi(row[11]); + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_OBJECT_CONTENTS_REPOSITORY_H diff --git a/common/repositories/base/base_object_repository.h b/common/repositories/base/base_object_repository.h new file mode 100644 index 000000000..c3287bf96 --- /dev/null +++ b/common/repositories/base/base_object_repository.h @@ -0,0 +1,522 @@ +/** + * 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 on Apr 5, 2020 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_OBJECT_REPOSITORY_H +#define EQEMU_BASE_OBJECT_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseObjectRepository { +public: + struct Object { + int id; + int zoneid; + int16 version; + float xpos; + float ypos; + float zpos; + float heading; + int itemid; + int16 charges; + std::string objectname; + int type; + int icon; + int unknown08; + int unknown10; + int unknown20; + int unknown24; + int unknown60; + int unknown64; + int unknown68; + int unknown72; + int unknown76; + int unknown84; + float size; + float tilt_x; + float tilt_y; + std::string display_name; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "zoneid", + "version", + "xpos", + "ypos", + "zpos", + "heading", + "itemid", + "charges", + "objectname", + "type", + "icon", + "unknown08", + "unknown10", + "unknown20", + "unknown24", + "unknown60", + "unknown64", + "unknown68", + "unknown72", + "unknown76", + "unknown84", + "size", + "tilt_x", + "tilt_y", + "display_name", + }; + } + + 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("object"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Object NewEntity() + { + Object entry{}; + + entry.id = 0; + entry.zoneid = 0; + entry.version = 0; + entry.xpos = 0; + entry.ypos = 0; + entry.zpos = 0; + entry.heading = 0; + entry.itemid = 0; + entry.charges = 0; + entry.objectname = ""; + entry.type = 0; + entry.icon = 0; + entry.unknown08 = 0; + entry.unknown10 = 0; + entry.unknown20 = 0; + entry.unknown24 = 0; + entry.unknown60 = 0; + entry.unknown64 = 0; + entry.unknown68 = 0; + entry.unknown72 = 0; + entry.unknown76 = 0; + entry.unknown84 = 0; + entry.size = 100; + entry.tilt_x = 0; + entry.tilt_y = 0; + entry.display_name = ""; + + return entry; + } + + static Object GetObjectEntry( + const std::vector &objects, + int object_id + ) + { + for (auto &object : objects) { + if (object.id == object_id) { + return object; + } + } + + return NewEntity(); + } + + static Object FindOne( + int object_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + object_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Object entry{}; + + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.version = atoi(row[2]); + entry.xpos = atof(row[3]); + entry.ypos = atof(row[4]); + entry.zpos = atof(row[5]); + entry.heading = atof(row[6]); + entry.itemid = atoi(row[7]); + entry.charges = atoi(row[8]); + entry.objectname = row[9] ? row[9] : ""; + entry.type = atoi(row[10]); + entry.icon = atoi(row[11]); + entry.unknown08 = atoi(row[12]); + entry.unknown10 = atoi(row[13]); + entry.unknown20 = atoi(row[14]); + entry.unknown24 = atoi(row[15]); + entry.unknown60 = atoi(row[16]); + entry.unknown64 = atoi(row[17]); + entry.unknown68 = atoi(row[18]); + entry.unknown72 = atoi(row[19]); + entry.unknown76 = atoi(row[20]); + entry.unknown84 = atoi(row[21]); + entry.size = atof(row[22]); + entry.tilt_x = atof(row[23]); + entry.tilt_y = atof(row[24]); + entry.display_name = row[25] ? row[25] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int object_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + object_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Object object_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(object_entry.zoneid)); + update_values.push_back(columns[2] + " = " + std::to_string(object_entry.version)); + update_values.push_back(columns[3] + " = " + std::to_string(object_entry.xpos)); + update_values.push_back(columns[4] + " = " + std::to_string(object_entry.ypos)); + update_values.push_back(columns[5] + " = " + std::to_string(object_entry.zpos)); + update_values.push_back(columns[6] + " = " + std::to_string(object_entry.heading)); + update_values.push_back(columns[7] + " = " + std::to_string(object_entry.itemid)); + update_values.push_back(columns[8] + " = " + std::to_string(object_entry.charges)); + update_values.push_back(columns[9] + " = '" + EscapeString(object_entry.objectname) + "'"); + update_values.push_back(columns[10] + " = " + std::to_string(object_entry.type)); + update_values.push_back(columns[11] + " = " + std::to_string(object_entry.icon)); + update_values.push_back(columns[12] + " = " + std::to_string(object_entry.unknown08)); + update_values.push_back(columns[13] + " = " + std::to_string(object_entry.unknown10)); + update_values.push_back(columns[14] + " = " + std::to_string(object_entry.unknown20)); + update_values.push_back(columns[15] + " = " + std::to_string(object_entry.unknown24)); + update_values.push_back(columns[16] + " = " + std::to_string(object_entry.unknown60)); + update_values.push_back(columns[17] + " = " + std::to_string(object_entry.unknown64)); + update_values.push_back(columns[18] + " = " + std::to_string(object_entry.unknown68)); + update_values.push_back(columns[19] + " = " + std::to_string(object_entry.unknown72)); + update_values.push_back(columns[20] + " = " + std::to_string(object_entry.unknown76)); + update_values.push_back(columns[21] + " = " + std::to_string(object_entry.unknown84)); + update_values.push_back(columns[22] + " = " + std::to_string(object_entry.size)); + update_values.push_back(columns[23] + " = " + std::to_string(object_entry.tilt_x)); + update_values.push_back(columns[24] + " = " + std::to_string(object_entry.tilt_y)); + update_values.push_back(columns[25] + " = '" + EscapeString(object_entry.display_name) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + object_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Object InsertOne( + Object object_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(object_entry.zoneid)); + insert_values.push_back(std::to_string(object_entry.version)); + insert_values.push_back(std::to_string(object_entry.xpos)); + insert_values.push_back(std::to_string(object_entry.ypos)); + insert_values.push_back(std::to_string(object_entry.zpos)); + insert_values.push_back(std::to_string(object_entry.heading)); + insert_values.push_back(std::to_string(object_entry.itemid)); + insert_values.push_back(std::to_string(object_entry.charges)); + insert_values.push_back("'" + EscapeString(object_entry.objectname) + "'"); + insert_values.push_back(std::to_string(object_entry.type)); + insert_values.push_back(std::to_string(object_entry.icon)); + insert_values.push_back(std::to_string(object_entry.unknown08)); + insert_values.push_back(std::to_string(object_entry.unknown10)); + insert_values.push_back(std::to_string(object_entry.unknown20)); + insert_values.push_back(std::to_string(object_entry.unknown24)); + insert_values.push_back(std::to_string(object_entry.unknown60)); + insert_values.push_back(std::to_string(object_entry.unknown64)); + insert_values.push_back(std::to_string(object_entry.unknown68)); + insert_values.push_back(std::to_string(object_entry.unknown72)); + insert_values.push_back(std::to_string(object_entry.unknown76)); + insert_values.push_back(std::to_string(object_entry.unknown84)); + insert_values.push_back(std::to_string(object_entry.size)); + insert_values.push_back(std::to_string(object_entry.tilt_x)); + insert_values.push_back(std::to_string(object_entry.tilt_y)); + insert_values.push_back("'" + EscapeString(object_entry.display_name) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + object_entry.id = results.LastInsertedID(); + return object_entry; + } + + object_entry = NewEntity(); + + return object_entry; + } + + static int InsertMany( + std::vector object_entries + ) + { + std::vector insert_chunks; + + for (auto &object_entry: object_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(object_entry.zoneid)); + insert_values.push_back(std::to_string(object_entry.version)); + insert_values.push_back(std::to_string(object_entry.xpos)); + insert_values.push_back(std::to_string(object_entry.ypos)); + insert_values.push_back(std::to_string(object_entry.zpos)); + insert_values.push_back(std::to_string(object_entry.heading)); + insert_values.push_back(std::to_string(object_entry.itemid)); + insert_values.push_back(std::to_string(object_entry.charges)); + insert_values.push_back("'" + EscapeString(object_entry.objectname) + "'"); + insert_values.push_back(std::to_string(object_entry.type)); + insert_values.push_back(std::to_string(object_entry.icon)); + insert_values.push_back(std::to_string(object_entry.unknown08)); + insert_values.push_back(std::to_string(object_entry.unknown10)); + insert_values.push_back(std::to_string(object_entry.unknown20)); + insert_values.push_back(std::to_string(object_entry.unknown24)); + insert_values.push_back(std::to_string(object_entry.unknown60)); + insert_values.push_back(std::to_string(object_entry.unknown64)); + insert_values.push_back(std::to_string(object_entry.unknown68)); + insert_values.push_back(std::to_string(object_entry.unknown72)); + insert_values.push_back(std::to_string(object_entry.unknown76)); + insert_values.push_back(std::to_string(object_entry.unknown84)); + insert_values.push_back(std::to_string(object_entry.size)); + insert_values.push_back(std::to_string(object_entry.tilt_x)); + insert_values.push_back(std::to_string(object_entry.tilt_y)); + insert_values.push_back("'" + EscapeString(object_entry.display_name) + "'"); + + 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) { + Object entry{}; + + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.version = atoi(row[2]); + entry.xpos = atof(row[3]); + entry.ypos = atof(row[4]); + entry.zpos = atof(row[5]); + entry.heading = atof(row[6]); + entry.itemid = atoi(row[7]); + entry.charges = atoi(row[8]); + entry.objectname = row[9] ? row[9] : ""; + entry.type = atoi(row[10]); + entry.icon = atoi(row[11]); + entry.unknown08 = atoi(row[12]); + entry.unknown10 = atoi(row[13]); + entry.unknown20 = atoi(row[14]); + entry.unknown24 = atoi(row[15]); + entry.unknown60 = atoi(row[16]); + entry.unknown64 = atoi(row[17]); + entry.unknown68 = atoi(row[18]); + entry.unknown72 = atoi(row[19]); + entry.unknown76 = atoi(row[20]); + entry.unknown84 = atoi(row[21]); + entry.size = atof(row[22]); + entry.tilt_x = atof(row[23]); + entry.tilt_y = atof(row[24]); + entry.display_name = row[25] ? row[25] : ""; + + 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) { + Object entry{}; + + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.version = atoi(row[2]); + entry.xpos = atof(row[3]); + entry.ypos = atof(row[4]); + entry.zpos = atof(row[5]); + entry.heading = atof(row[6]); + entry.itemid = atoi(row[7]); + entry.charges = atoi(row[8]); + entry.objectname = row[9] ? row[9] : ""; + entry.type = atoi(row[10]); + entry.icon = atoi(row[11]); + entry.unknown08 = atoi(row[12]); + entry.unknown10 = atoi(row[13]); + entry.unknown20 = atoi(row[14]); + entry.unknown24 = atoi(row[15]); + entry.unknown60 = atoi(row[16]); + entry.unknown64 = atoi(row[17]); + entry.unknown68 = atoi(row[18]); + entry.unknown72 = atoi(row[19]); + entry.unknown76 = atoi(row[20]); + entry.unknown84 = atoi(row[21]); + entry.size = atof(row[22]); + entry.tilt_x = atof(row[23]); + entry.tilt_y = atof(row[24]); + entry.display_name = row[25] ? row[25] : ""; + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_OBJECT_REPOSITORY_H diff --git a/common/repositories/base/base_perl_event_export_settings_repository.h b/common/repositories/base/base_perl_event_export_settings_repository.h new file mode 100644 index 000000000..8e72aa8eb --- /dev/null +++ b/common/repositories/base/base_perl_event_export_settings_repository.h @@ -0,0 +1,351 @@ +/** + * 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 on Apr 5, 2020 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_PERL_EVENT_EXPORT_SETTINGS_REPOSITORY_H +#define EQEMU_BASE_PERL_EVENT_EXPORT_SETTINGS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BasePerlEventExportSettingsRepository { +public: + struct PerlEventExportSettings { + int event_id; + std::string event_description; + int16 export_qglobals; + int16 export_mob; + int16 export_zone; + int16 export_item; + int16 export_event; + }; + + static std::string PrimaryKey() + { + return std::string("event_id"); + } + + static std::vector Columns() + { + return { + "event_id", + "event_description", + "export_qglobals", + "export_mob", + "export_zone", + "export_item", + "export_event", + }; + } + + 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("perl_event_export_settings"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static PerlEventExportSettings NewEntity() + { + PerlEventExportSettings entry{}; + + entry.event_id = 0; + entry.event_description = ""; + entry.export_qglobals = 0; + entry.export_mob = 0; + entry.export_zone = 0; + entry.export_item = 0; + entry.export_event = 0; + + return entry; + } + + static PerlEventExportSettings GetPerlEventExportSettingsEntry( + const std::vector &perl_event_export_settingss, + int perl_event_export_settings_id + ) + { + for (auto &perl_event_export_settings : perl_event_export_settingss) { + if (perl_event_export_settings.event_id == perl_event_export_settings_id) { + return perl_event_export_settings; + } + } + + return NewEntity(); + } + + static PerlEventExportSettings FindOne( + int perl_event_export_settings_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + perl_event_export_settings_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + PerlEventExportSettings entry{}; + + entry.event_id = atoi(row[0]); + entry.event_description = row[1] ? row[1] : ""; + entry.export_qglobals = atoi(row[2]); + entry.export_mob = atoi(row[3]); + entry.export_zone = atoi(row[4]); + entry.export_item = atoi(row[5]); + entry.export_event = atoi(row[6]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int perl_event_export_settings_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + perl_event_export_settings_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + PerlEventExportSettings perl_event_export_settings_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(perl_event_export_settings_entry.event_description) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(perl_event_export_settings_entry.export_qglobals)); + update_values.push_back(columns[3] + " = " + std::to_string(perl_event_export_settings_entry.export_mob)); + update_values.push_back(columns[4] + " = " + std::to_string(perl_event_export_settings_entry.export_zone)); + update_values.push_back(columns[5] + " = " + std::to_string(perl_event_export_settings_entry.export_item)); + update_values.push_back(columns[6] + " = " + std::to_string(perl_event_export_settings_entry.export_event)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + perl_event_export_settings_entry.event_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static PerlEventExportSettings InsertOne( + PerlEventExportSettings perl_event_export_settings_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(perl_event_export_settings_entry.event_description) + "'"); + insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_qglobals)); + insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_mob)); + insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_zone)); + insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_item)); + insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_event)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + perl_event_export_settings_entry.id = results.LastInsertedID(); + return perl_event_export_settings_entry; + } + + perl_event_export_settings_entry = NewEntity(); + + return perl_event_export_settings_entry; + } + + static int InsertMany( + std::vector perl_event_export_settings_entries + ) + { + std::vector insert_chunks; + + for (auto &perl_event_export_settings_entry: perl_event_export_settings_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(perl_event_export_settings_entry.event_description) + "'"); + insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_qglobals)); + insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_mob)); + insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_zone)); + insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_item)); + insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_event)); + + 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) { + PerlEventExportSettings entry{}; + + entry.event_id = atoi(row[0]); + entry.event_description = row[1] ? row[1] : ""; + entry.export_qglobals = atoi(row[2]); + entry.export_mob = atoi(row[3]); + entry.export_zone = atoi(row[4]); + entry.export_item = atoi(row[5]); + entry.export_event = atoi(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) { + PerlEventExportSettings entry{}; + + entry.event_id = atoi(row[0]); + entry.event_description = row[1] ? row[1] : ""; + entry.export_qglobals = atoi(row[2]); + entry.export_mob = atoi(row[3]); + entry.export_zone = atoi(row[4]); + entry.export_item = atoi(row[5]); + entry.export_event = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_PERL_EVENT_EXPORT_SETTINGS_REPOSITORY_H diff --git a/common/repositories/base/base_petitions_repository.h b/common/repositories/base/base_petitions_repository.h new file mode 100644 index 000000000..97a9e5761 --- /dev/null +++ b/common/repositories/base/base_petitions_repository.h @@ -0,0 +1,432 @@ +/** + * 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 on Apr 5, 2020 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_PETITIONS_REPOSITORY_H +#define EQEMU_BASE_PETITIONS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BasePetitionsRepository { +public: + struct Petitions { + int dib; + int petid; + std::string charname; + std::string accountname; + std::string lastgm; + std::string petitiontext; + std::string gmtext; + std::string zone; + int urgency; + int charclass; + int charrace; + int charlevel; + int checkouts; + int unavailables; + int8 ischeckedout; + int senttime; + }; + + static std::string PrimaryKey() + { + return std::string("dib"); + } + + static std::vector Columns() + { + return { + "dib", + "petid", + "charname", + "accountname", + "lastgm", + "petitiontext", + "gmtext", + "zone", + "urgency", + "charclass", + "charrace", + "charlevel", + "checkouts", + "unavailables", + "ischeckedout", + "senttime", + }; + } + + 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("petitions"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Petitions NewEntity() + { + Petitions entry{}; + + entry.dib = 0; + entry.petid = 0; + entry.charname = ""; + entry.accountname = ""; + entry.lastgm = ""; + entry.petitiontext = ""; + entry.gmtext = ""; + entry.zone = ""; + entry.urgency = 0; + entry.charclass = 0; + entry.charrace = 0; + entry.charlevel = 0; + entry.checkouts = 0; + entry.unavailables = 0; + entry.ischeckedout = 0; + entry.senttime = 0; + + return entry; + } + + static Petitions GetPetitionsEntry( + const std::vector &petitionss, + int petitions_id + ) + { + for (auto &petitions : petitionss) { + if (petitions.dib == petitions_id) { + return petitions; + } + } + + return NewEntity(); + } + + static Petitions FindOne( + int petitions_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + petitions_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Petitions entry{}; + + entry.dib = atoi(row[0]); + entry.petid = atoi(row[1]); + entry.charname = row[2] ? row[2] : ""; + entry.accountname = row[3] ? row[3] : ""; + entry.lastgm = row[4] ? row[4] : ""; + entry.petitiontext = row[5] ? row[5] : ""; + entry.gmtext = row[6] ? row[6] : ""; + entry.zone = row[7] ? row[7] : ""; + entry.urgency = atoi(row[8]); + entry.charclass = atoi(row[9]); + entry.charrace = atoi(row[10]); + entry.charlevel = atoi(row[11]); + entry.checkouts = atoi(row[12]); + entry.unavailables = atoi(row[13]); + entry.ischeckedout = atoi(row[14]); + entry.senttime = atoi(row[15]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int petitions_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + petitions_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Petitions petitions_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(petitions_entry.petid)); + update_values.push_back(columns[2] + " = '" + EscapeString(petitions_entry.charname) + "'"); + update_values.push_back(columns[3] + " = '" + EscapeString(petitions_entry.accountname) + "'"); + update_values.push_back(columns[4] + " = '" + EscapeString(petitions_entry.lastgm) + "'"); + update_values.push_back(columns[5] + " = '" + EscapeString(petitions_entry.petitiontext) + "'"); + update_values.push_back(columns[6] + " = '" + EscapeString(petitions_entry.gmtext) + "'"); + update_values.push_back(columns[7] + " = '" + EscapeString(petitions_entry.zone) + "'"); + update_values.push_back(columns[8] + " = " + std::to_string(petitions_entry.urgency)); + update_values.push_back(columns[9] + " = " + std::to_string(petitions_entry.charclass)); + update_values.push_back(columns[10] + " = " + std::to_string(petitions_entry.charrace)); + update_values.push_back(columns[11] + " = " + std::to_string(petitions_entry.charlevel)); + update_values.push_back(columns[12] + " = " + std::to_string(petitions_entry.checkouts)); + update_values.push_back(columns[13] + " = " + std::to_string(petitions_entry.unavailables)); + update_values.push_back(columns[14] + " = " + std::to_string(petitions_entry.ischeckedout)); + update_values.push_back(columns[15] + " = " + std::to_string(petitions_entry.senttime)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + petitions_entry.dib + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Petitions InsertOne( + Petitions petitions_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(petitions_entry.petid)); + insert_values.push_back("'" + EscapeString(petitions_entry.charname) + "'"); + insert_values.push_back("'" + EscapeString(petitions_entry.accountname) + "'"); + insert_values.push_back("'" + EscapeString(petitions_entry.lastgm) + "'"); + insert_values.push_back("'" + EscapeString(petitions_entry.petitiontext) + "'"); + insert_values.push_back("'" + EscapeString(petitions_entry.gmtext) + "'"); + insert_values.push_back("'" + EscapeString(petitions_entry.zone) + "'"); + insert_values.push_back(std::to_string(petitions_entry.urgency)); + insert_values.push_back(std::to_string(petitions_entry.charclass)); + insert_values.push_back(std::to_string(petitions_entry.charrace)); + insert_values.push_back(std::to_string(petitions_entry.charlevel)); + insert_values.push_back(std::to_string(petitions_entry.checkouts)); + insert_values.push_back(std::to_string(petitions_entry.unavailables)); + insert_values.push_back(std::to_string(petitions_entry.ischeckedout)); + insert_values.push_back(std::to_string(petitions_entry.senttime)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + petitions_entry.id = results.LastInsertedID(); + return petitions_entry; + } + + petitions_entry = NewEntity(); + + return petitions_entry; + } + + static int InsertMany( + std::vector petitions_entries + ) + { + std::vector insert_chunks; + + for (auto &petitions_entry: petitions_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(petitions_entry.petid)); + insert_values.push_back("'" + EscapeString(petitions_entry.charname) + "'"); + insert_values.push_back("'" + EscapeString(petitions_entry.accountname) + "'"); + insert_values.push_back("'" + EscapeString(petitions_entry.lastgm) + "'"); + insert_values.push_back("'" + EscapeString(petitions_entry.petitiontext) + "'"); + insert_values.push_back("'" + EscapeString(petitions_entry.gmtext) + "'"); + insert_values.push_back("'" + EscapeString(petitions_entry.zone) + "'"); + insert_values.push_back(std::to_string(petitions_entry.urgency)); + insert_values.push_back(std::to_string(petitions_entry.charclass)); + insert_values.push_back(std::to_string(petitions_entry.charrace)); + insert_values.push_back(std::to_string(petitions_entry.charlevel)); + insert_values.push_back(std::to_string(petitions_entry.checkouts)); + insert_values.push_back(std::to_string(petitions_entry.unavailables)); + insert_values.push_back(std::to_string(petitions_entry.ischeckedout)); + insert_values.push_back(std::to_string(petitions_entry.senttime)); + + 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) { + Petitions entry{}; + + entry.dib = atoi(row[0]); + entry.petid = atoi(row[1]); + entry.charname = row[2] ? row[2] : ""; + entry.accountname = row[3] ? row[3] : ""; + entry.lastgm = row[4] ? row[4] : ""; + entry.petitiontext = row[5] ? row[5] : ""; + entry.gmtext = row[6] ? row[6] : ""; + entry.zone = row[7] ? row[7] : ""; + entry.urgency = atoi(row[8]); + entry.charclass = atoi(row[9]); + entry.charrace = atoi(row[10]); + entry.charlevel = atoi(row[11]); + entry.checkouts = atoi(row[12]); + entry.unavailables = atoi(row[13]); + entry.ischeckedout = atoi(row[14]); + entry.senttime = atoi(row[15]); + + 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) { + Petitions entry{}; + + entry.dib = atoi(row[0]); + entry.petid = atoi(row[1]); + entry.charname = row[2] ? row[2] : ""; + entry.accountname = row[3] ? row[3] : ""; + entry.lastgm = row[4] ? row[4] : ""; + entry.petitiontext = row[5] ? row[5] : ""; + entry.gmtext = row[6] ? row[6] : ""; + entry.zone = row[7] ? row[7] : ""; + entry.urgency = atoi(row[8]); + entry.charclass = atoi(row[9]); + entry.charrace = atoi(row[10]); + entry.charlevel = atoi(row[11]); + entry.checkouts = atoi(row[12]); + entry.unavailables = atoi(row[13]); + entry.ischeckedout = atoi(row[14]); + entry.senttime = atoi(row[15]); + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_PETITIONS_REPOSITORY_H diff --git a/common/repositories/base/base_pets_equipmentset_entries_repository.h b/common/repositories/base/base_pets_equipmentset_entries_repository.h new file mode 100644 index 000000000..6b27208f2 --- /dev/null +++ b/common/repositories/base/base_pets_equipmentset_entries_repository.h @@ -0,0 +1,312 @@ +/** + * 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 on Apr 5, 2020 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_PETS_EQUIPMENTSET_ENTRIES_REPOSITORY_H +#define EQEMU_BASE_PETS_EQUIPMENTSET_ENTRIES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BasePetsEquipmentsetEntriesRepository { +public: + struct PetsEquipmentsetEntries { + int set_id; + int slot; + int item_id; + }; + + static std::string PrimaryKey() + { + return std::string("slot"); + } + + static std::vector Columns() + { + return { + "set_id", + "slot", + "item_id", + }; + } + + 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("pets_equipmentset_entries"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static PetsEquipmentsetEntries NewEntity() + { + PetsEquipmentsetEntries entry{}; + + entry.set_id = 0; + entry.slot = 0; + entry.item_id = 0; + + return entry; + } + + static PetsEquipmentsetEntries GetPetsEquipmentsetEntriesEntry( + const std::vector &pets_equipmentset_entriess, + int pets_equipmentset_entries_id + ) + { + for (auto &pets_equipmentset_entries : pets_equipmentset_entriess) { + if (pets_equipmentset_entries.slot == pets_equipmentset_entries_id) { + return pets_equipmentset_entries; + } + } + + return NewEntity(); + } + + static PetsEquipmentsetEntries FindOne( + int pets_equipmentset_entries_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + pets_equipmentset_entries_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + PetsEquipmentsetEntries entry{}; + + entry.set_id = atoi(row[0]); + entry.slot = atoi(row[1]); + entry.item_id = atoi(row[2]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int pets_equipmentset_entries_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + pets_equipmentset_entries_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + PetsEquipmentsetEntries pets_equipmentset_entries_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = " + std::to_string(pets_equipmentset_entries_entry.item_id)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + pets_equipmentset_entries_entry.slot + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static PetsEquipmentsetEntries InsertOne( + PetsEquipmentsetEntries pets_equipmentset_entries_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(pets_equipmentset_entries_entry.item_id)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + pets_equipmentset_entries_entry.id = results.LastInsertedID(); + return pets_equipmentset_entries_entry; + } + + pets_equipmentset_entries_entry = NewEntity(); + + return pets_equipmentset_entries_entry; + } + + static int InsertMany( + std::vector pets_equipmentset_entries_entries + ) + { + std::vector insert_chunks; + + for (auto &pets_equipmentset_entries_entry: pets_equipmentset_entries_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(pets_equipmentset_entries_entry.item_id)); + + 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) { + PetsEquipmentsetEntries entry{}; + + entry.set_id = atoi(row[0]); + entry.slot = atoi(row[1]); + entry.item_id = atoi(row[2]); + + 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) { + PetsEquipmentsetEntries entry{}; + + entry.set_id = atoi(row[0]); + entry.slot = atoi(row[1]); + entry.item_id = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_PETS_EQUIPMENTSET_ENTRIES_REPOSITORY_H diff --git a/common/repositories/base/base_pets_equipmentset_repository.h b/common/repositories/base/base_pets_equipmentset_repository.h new file mode 100644 index 000000000..0a2fe7143 --- /dev/null +++ b/common/repositories/base/base_pets_equipmentset_repository.h @@ -0,0 +1,315 @@ +/** + * 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 on Apr 5, 2020 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_PETS_EQUIPMENTSET_REPOSITORY_H +#define EQEMU_BASE_PETS_EQUIPMENTSET_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BasePetsEquipmentsetRepository { +public: + struct PetsEquipmentset { + int set_id; + std::string setname; + int nested_set; + }; + + static std::string PrimaryKey() + { + return std::string("set_id"); + } + + static std::vector Columns() + { + return { + "set_id", + "setname", + "nested_set", + }; + } + + 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("pets_equipmentset"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static PetsEquipmentset NewEntity() + { + PetsEquipmentset entry{}; + + entry.set_id = 0; + entry.setname = ""; + entry.nested_set = -1; + + return entry; + } + + static PetsEquipmentset GetPetsEquipmentsetEntry( + const std::vector &pets_equipmentsets, + int pets_equipmentset_id + ) + { + for (auto &pets_equipmentset : pets_equipmentsets) { + if (pets_equipmentset.set_id == pets_equipmentset_id) { + return pets_equipmentset; + } + } + + return NewEntity(); + } + + static PetsEquipmentset FindOne( + int pets_equipmentset_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + pets_equipmentset_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + PetsEquipmentset entry{}; + + entry.set_id = atoi(row[0]); + entry.setname = row[1] ? row[1] : ""; + entry.nested_set = atoi(row[2]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int pets_equipmentset_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + pets_equipmentset_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + PetsEquipmentset pets_equipmentset_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(pets_equipmentset_entry.setname) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(pets_equipmentset_entry.nested_set)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + pets_equipmentset_entry.set_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static PetsEquipmentset InsertOne( + PetsEquipmentset pets_equipmentset_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(pets_equipmentset_entry.setname) + "'"); + insert_values.push_back(std::to_string(pets_equipmentset_entry.nested_set)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + pets_equipmentset_entry.id = results.LastInsertedID(); + return pets_equipmentset_entry; + } + + pets_equipmentset_entry = NewEntity(); + + return pets_equipmentset_entry; + } + + static int InsertMany( + std::vector pets_equipmentset_entries + ) + { + std::vector insert_chunks; + + for (auto &pets_equipmentset_entry: pets_equipmentset_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(pets_equipmentset_entry.setname) + "'"); + insert_values.push_back(std::to_string(pets_equipmentset_entry.nested_set)); + + 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) { + PetsEquipmentset entry{}; + + entry.set_id = atoi(row[0]); + entry.setname = row[1] ? row[1] : ""; + entry.nested_set = atoi(row[2]); + + 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) { + PetsEquipmentset entry{}; + + entry.set_id = atoi(row[0]); + entry.setname = row[1] ? row[1] : ""; + entry.nested_set = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_PETS_EQUIPMENTSET_REPOSITORY_H diff --git a/common/repositories/base/base_pets_repository.h b/common/repositories/base/base_pets_repository.h new file mode 100644 index 000000000..adfccf8d5 --- /dev/null +++ b/common/repositories/base/base_pets_repository.h @@ -0,0 +1,357 @@ +/** + * 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 on Apr 5, 2020 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_PETS_REPOSITORY_H +#define EQEMU_BASE_PETS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BasePetsRepository { +public: + struct Pets { + std::string type; + int petpower; + int npcID; + int8 temp; + int8 petcontrol; + int8 petnaming; + int8 monsterflag; + int equipmentset; + }; + + static std::string PrimaryKey() + { + return std::string("petpower"); + } + + static std::vector Columns() + { + return { + "type", + "petpower", + "npcID", + "temp", + "petcontrol", + "petnaming", + "monsterflag", + "equipmentset", + }; + } + + 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("pets"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Pets NewEntity() + { + Pets entry{}; + + entry.type = ""; + entry.petpower = 0; + entry.npcID = 0; + entry.temp = 0; + entry.petcontrol = 0; + entry.petnaming = 0; + entry.monsterflag = 0; + entry.equipmentset = -1; + + return entry; + } + + static Pets GetPetsEntry( + const std::vector &petss, + int pets_id + ) + { + for (auto &pets : petss) { + if (pets.petpower == pets_id) { + return pets; + } + } + + return NewEntity(); + } + + static Pets FindOne( + int pets_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + pets_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Pets entry{}; + + entry.type = row[0] ? row[0] : ""; + entry.petpower = atoi(row[1]); + entry.npcID = atoi(row[2]); + entry.temp = atoi(row[3]); + entry.petcontrol = atoi(row[4]); + entry.petnaming = atoi(row[5]); + entry.monsterflag = atoi(row[6]); + entry.equipmentset = atoi(row[7]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int pets_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + pets_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Pets pets_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = " + std::to_string(pets_entry.npcID)); + update_values.push_back(columns[3] + " = " + std::to_string(pets_entry.temp)); + update_values.push_back(columns[4] + " = " + std::to_string(pets_entry.petcontrol)); + update_values.push_back(columns[5] + " = " + std::to_string(pets_entry.petnaming)); + update_values.push_back(columns[6] + " = " + std::to_string(pets_entry.monsterflag)); + update_values.push_back(columns[7] + " = " + std::to_string(pets_entry.equipmentset)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + pets_entry.petpower + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Pets InsertOne( + Pets pets_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(pets_entry.npcID)); + insert_values.push_back(std::to_string(pets_entry.temp)); + insert_values.push_back(std::to_string(pets_entry.petcontrol)); + insert_values.push_back(std::to_string(pets_entry.petnaming)); + insert_values.push_back(std::to_string(pets_entry.monsterflag)); + insert_values.push_back(std::to_string(pets_entry.equipmentset)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + pets_entry.id = results.LastInsertedID(); + return pets_entry; + } + + pets_entry = NewEntity(); + + return pets_entry; + } + + static int InsertMany( + std::vector pets_entries + ) + { + std::vector insert_chunks; + + for (auto &pets_entry: pets_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(pets_entry.npcID)); + insert_values.push_back(std::to_string(pets_entry.temp)); + insert_values.push_back(std::to_string(pets_entry.petcontrol)); + insert_values.push_back(std::to_string(pets_entry.petnaming)); + insert_values.push_back(std::to_string(pets_entry.monsterflag)); + insert_values.push_back(std::to_string(pets_entry.equipmentset)); + + 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) { + Pets entry{}; + + entry.type = row[0] ? row[0] : ""; + entry.petpower = atoi(row[1]); + entry.npcID = atoi(row[2]); + entry.temp = atoi(row[3]); + entry.petcontrol = atoi(row[4]); + entry.petnaming = atoi(row[5]); + entry.monsterflag = atoi(row[6]); + entry.equipmentset = atoi(row[7]); + + 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) { + Pets entry{}; + + entry.type = row[0] ? row[0] : ""; + entry.petpower = atoi(row[1]); + entry.npcID = atoi(row[2]); + entry.temp = atoi(row[3]); + entry.petcontrol = atoi(row[4]); + entry.petnaming = atoi(row[5]); + entry.monsterflag = atoi(row[6]); + entry.equipmentset = atoi(row[7]); + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_PETS_REPOSITORY_H diff --git a/common/repositories/base/base_player_titlesets_repository.h b/common/repositories/base/base_player_titlesets_repository.h new file mode 100644 index 000000000..4f036f2a5 --- /dev/null +++ b/common/repositories/base/base_player_titlesets_repository.h @@ -0,0 +1,315 @@ +/** + * 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 on Apr 5, 2020 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_PLAYER_TITLESETS_REPOSITORY_H +#define EQEMU_BASE_PLAYER_TITLESETS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BasePlayerTitlesetsRepository { +public: + struct PlayerTitlesets { + int id; + int char_id; + int title_set; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "char_id", + "title_set", + }; + } + + 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("player_titlesets"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static PlayerTitlesets NewEntity() + { + PlayerTitlesets entry{}; + + entry.id = 0; + entry.char_id = 0; + entry.title_set = 0; + + return entry; + } + + static PlayerTitlesets GetPlayerTitlesetsEntry( + const std::vector &player_titlesetss, + int player_titlesets_id + ) + { + for (auto &player_titlesets : player_titlesetss) { + if (player_titlesets.id == player_titlesets_id) { + return player_titlesets; + } + } + + return NewEntity(); + } + + static PlayerTitlesets FindOne( + int player_titlesets_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + player_titlesets_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + PlayerTitlesets entry{}; + + entry.id = atoi(row[0]); + entry.char_id = atoi(row[1]); + entry.title_set = atoi(row[2]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int player_titlesets_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + player_titlesets_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + PlayerTitlesets player_titlesets_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(player_titlesets_entry.char_id)); + update_values.push_back(columns[2] + " = " + std::to_string(player_titlesets_entry.title_set)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + player_titlesets_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static PlayerTitlesets InsertOne( + PlayerTitlesets player_titlesets_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(player_titlesets_entry.char_id)); + insert_values.push_back(std::to_string(player_titlesets_entry.title_set)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + player_titlesets_entry.id = results.LastInsertedID(); + return player_titlesets_entry; + } + + player_titlesets_entry = NewEntity(); + + return player_titlesets_entry; + } + + static int InsertMany( + std::vector player_titlesets_entries + ) + { + std::vector insert_chunks; + + for (auto &player_titlesets_entry: player_titlesets_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(player_titlesets_entry.char_id)); + insert_values.push_back(std::to_string(player_titlesets_entry.title_set)); + + 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) { + PlayerTitlesets entry{}; + + entry.id = atoi(row[0]); + entry.char_id = atoi(row[1]); + entry.title_set = atoi(row[2]); + + 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) { + PlayerTitlesets entry{}; + + entry.id = atoi(row[0]); + entry.char_id = atoi(row[1]); + entry.title_set = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_PLAYER_TITLESETS_REPOSITORY_H diff --git a/common/repositories/base/base_proximities_repository.h b/common/repositories/base/base_proximities_repository.h new file mode 100644 index 000000000..b1257616e --- /dev/null +++ b/common/repositories/base/base_proximities_repository.h @@ -0,0 +1,357 @@ +/** + * 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 on Apr 5, 2020 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_PROXIMITIES_REPOSITORY_H +#define EQEMU_BASE_PROXIMITIES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseProximitiesRepository { +public: + struct Proximities { + int zoneid; + int exploreid; + float minx; + float maxx; + float miny; + float maxy; + float minz; + float maxz; + }; + + static std::string PrimaryKey() + { + return std::string("exploreid"); + } + + static std::vector Columns() + { + return { + "zoneid", + "exploreid", + "minx", + "maxx", + "miny", + "maxy", + "minz", + "maxz", + }; + } + + 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("proximities"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Proximities NewEntity() + { + Proximities entry{}; + + entry.zoneid = 0; + entry.exploreid = 0; + entry.minx = 0.000000; + entry.maxx = 0.000000; + entry.miny = 0.000000; + entry.maxy = 0.000000; + entry.minz = 0.000000; + entry.maxz = 0.000000; + + return entry; + } + + static Proximities GetProximitiesEntry( + const std::vector &proximitiess, + int proximities_id + ) + { + for (auto &proximities : proximitiess) { + if (proximities.exploreid == proximities_id) { + return proximities; + } + } + + return NewEntity(); + } + + static Proximities FindOne( + int proximities_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + proximities_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Proximities entry{}; + + entry.zoneid = atoi(row[0]); + entry.exploreid = atoi(row[1]); + entry.minx = atof(row[2]); + entry.maxx = atof(row[3]); + entry.miny = atof(row[4]); + entry.maxy = atof(row[5]); + entry.minz = atof(row[6]); + entry.maxz = atof(row[7]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int proximities_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + proximities_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Proximities proximities_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = " + std::to_string(proximities_entry.minx)); + update_values.push_back(columns[3] + " = " + std::to_string(proximities_entry.maxx)); + update_values.push_back(columns[4] + " = " + std::to_string(proximities_entry.miny)); + update_values.push_back(columns[5] + " = " + std::to_string(proximities_entry.maxy)); + update_values.push_back(columns[6] + " = " + std::to_string(proximities_entry.minz)); + update_values.push_back(columns[7] + " = " + std::to_string(proximities_entry.maxz)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + proximities_entry.exploreid + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Proximities InsertOne( + Proximities proximities_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(proximities_entry.minx)); + insert_values.push_back(std::to_string(proximities_entry.maxx)); + insert_values.push_back(std::to_string(proximities_entry.miny)); + insert_values.push_back(std::to_string(proximities_entry.maxy)); + insert_values.push_back(std::to_string(proximities_entry.minz)); + insert_values.push_back(std::to_string(proximities_entry.maxz)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + proximities_entry.id = results.LastInsertedID(); + return proximities_entry; + } + + proximities_entry = NewEntity(); + + return proximities_entry; + } + + static int InsertMany( + std::vector proximities_entries + ) + { + std::vector insert_chunks; + + for (auto &proximities_entry: proximities_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(proximities_entry.minx)); + insert_values.push_back(std::to_string(proximities_entry.maxx)); + insert_values.push_back(std::to_string(proximities_entry.miny)); + insert_values.push_back(std::to_string(proximities_entry.maxy)); + insert_values.push_back(std::to_string(proximities_entry.minz)); + insert_values.push_back(std::to_string(proximities_entry.maxz)); + + 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) { + Proximities entry{}; + + entry.zoneid = atoi(row[0]); + entry.exploreid = atoi(row[1]); + entry.minx = atof(row[2]); + entry.maxx = atof(row[3]); + entry.miny = atof(row[4]); + entry.maxy = atof(row[5]); + entry.minz = atof(row[6]); + entry.maxz = atof(row[7]); + + 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) { + Proximities entry{}; + + entry.zoneid = atoi(row[0]); + entry.exploreid = atoi(row[1]); + entry.minx = atof(row[2]); + entry.maxx = atof(row[3]); + entry.miny = atof(row[4]); + entry.maxy = atof(row[5]); + entry.minz = atof(row[6]); + entry.maxz = atof(row[7]); + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_PROXIMITIES_REPOSITORY_H diff --git a/common/repositories/base/base_quest_globals_repository.h b/common/repositories/base/base_quest_globals_repository.h new file mode 100644 index 000000000..944bc4c44 --- /dev/null +++ b/common/repositories/base/base_quest_globals_repository.h @@ -0,0 +1,333 @@ +/** + * 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 on Apr 5, 2020 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_QUEST_GLOBALS_REPOSITORY_H +#define EQEMU_BASE_QUEST_GLOBALS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseQuestGlobalsRepository { +public: + struct QuestGlobals { + int charid; + int npcid; + int zoneid; + std::string name; + std::string value; + int expdate; + }; + + static std::string PrimaryKey() + { + return std::string("name"); + } + + static std::vector Columns() + { + return { + "charid", + "npcid", + "zoneid", + "name", + "value", + "expdate", + }; + } + + 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("quest_globals"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static QuestGlobals NewEntity() + { + QuestGlobals entry{}; + + entry.charid = 0; + entry.npcid = 0; + entry.zoneid = 0; + entry.name = ""; + entry.value = "?"; + entry.expdate = 0; + + return entry; + } + + static QuestGlobals GetQuestGlobalsEntry( + const std::vector &quest_globalss, + int quest_globals_id + ) + { + for (auto &quest_globals : quest_globalss) { + if (quest_globals.name == quest_globals_id) { + return quest_globals; + } + } + + return NewEntity(); + } + + static QuestGlobals FindOne( + int quest_globals_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + quest_globals_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + QuestGlobals entry{}; + + entry.charid = atoi(row[0]); + entry.npcid = atoi(row[1]); + entry.zoneid = atoi(row[2]); + entry.name = row[3] ? row[3] : ""; + entry.value = row[4] ? row[4] : ""; + entry.expdate = atoi(row[5]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int quest_globals_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + quest_globals_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + QuestGlobals quest_globals_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[4] + " = '" + EscapeString(quest_globals_entry.value) + "'"); + update_values.push_back(columns[5] + " = " + std::to_string(quest_globals_entry.expdate)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + quest_globals_entry.name + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static QuestGlobals InsertOne( + QuestGlobals quest_globals_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(quest_globals_entry.value) + "'"); + insert_values.push_back(std::to_string(quest_globals_entry.expdate)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + quest_globals_entry.id = results.LastInsertedID(); + return quest_globals_entry; + } + + quest_globals_entry = NewEntity(); + + return quest_globals_entry; + } + + static int InsertMany( + std::vector quest_globals_entries + ) + { + std::vector insert_chunks; + + for (auto &quest_globals_entry: quest_globals_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(quest_globals_entry.value) + "'"); + insert_values.push_back(std::to_string(quest_globals_entry.expdate)); + + 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) { + QuestGlobals entry{}; + + entry.charid = atoi(row[0]); + entry.npcid = atoi(row[1]); + entry.zoneid = atoi(row[2]); + entry.name = row[3] ? row[3] : ""; + entry.value = row[4] ? row[4] : ""; + entry.expdate = atoi(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) { + QuestGlobals entry{}; + + entry.charid = atoi(row[0]); + entry.npcid = atoi(row[1]); + entry.zoneid = atoi(row[2]); + entry.name = row[3] ? row[3] : ""; + entry.value = row[4] ? row[4] : ""; + entry.expdate = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_QUEST_GLOBALS_REPOSITORY_H diff --git a/common/repositories/base/base_raid_details_repository.h b/common/repositories/base/base_raid_details_repository.h new file mode 100644 index 000000000..e5e9ca728 --- /dev/null +++ b/common/repositories/base/base_raid_details_repository.h @@ -0,0 +1,324 @@ +/** + * 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 on Apr 5, 2020 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_RAID_DETAILS_REPOSITORY_H +#define EQEMU_BASE_RAID_DETAILS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseRaidDetailsRepository { +public: + struct RaidDetails { + int raidid; + int loottype; + int8 locked; + std::string motd; + }; + + static std::string PrimaryKey() + { + return std::string("raidid"); + } + + static std::vector Columns() + { + return { + "raidid", + "loottype", + "locked", + "motd", + }; + } + + 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("raid_details"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static RaidDetails NewEntity() + { + RaidDetails entry{}; + + entry.raidid = 0; + entry.loottype = 0; + entry.locked = 0; + entry.motd = ""; + + return entry; + } + + static RaidDetails GetRaidDetailsEntry( + const std::vector &raid_detailss, + int raid_details_id + ) + { + for (auto &raid_details : raid_detailss) { + if (raid_details.raidid == raid_details_id) { + return raid_details; + } + } + + return NewEntity(); + } + + static RaidDetails FindOne( + int raid_details_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + raid_details_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + RaidDetails entry{}; + + entry.raidid = atoi(row[0]); + entry.loottype = atoi(row[1]); + entry.locked = atoi(row[2]); + entry.motd = row[3] ? row[3] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int raid_details_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + raid_details_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + RaidDetails raid_details_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(raid_details_entry.loottype)); + update_values.push_back(columns[2] + " = " + std::to_string(raid_details_entry.locked)); + update_values.push_back(columns[3] + " = '" + EscapeString(raid_details_entry.motd) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + raid_details_entry.raidid + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static RaidDetails InsertOne( + RaidDetails raid_details_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(raid_details_entry.loottype)); + insert_values.push_back(std::to_string(raid_details_entry.locked)); + insert_values.push_back("'" + EscapeString(raid_details_entry.motd) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + raid_details_entry.id = results.LastInsertedID(); + return raid_details_entry; + } + + raid_details_entry = NewEntity(); + + return raid_details_entry; + } + + static int InsertMany( + std::vector raid_details_entries + ) + { + std::vector insert_chunks; + + for (auto &raid_details_entry: raid_details_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(raid_details_entry.loottype)); + insert_values.push_back(std::to_string(raid_details_entry.locked)); + insert_values.push_back("'" + EscapeString(raid_details_entry.motd) + "'"); + + 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) { + RaidDetails entry{}; + + entry.raidid = atoi(row[0]); + entry.loottype = atoi(row[1]); + entry.locked = atoi(row[2]); + entry.motd = row[3] ? 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) { + RaidDetails entry{}; + + entry.raidid = atoi(row[0]); + entry.loottype = atoi(row[1]); + entry.locked = atoi(row[2]); + entry.motd = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_RAID_DETAILS_REPOSITORY_H diff --git a/common/repositories/base/base_raid_members_repository.h b/common/repositories/base/base_raid_members_repository.h new file mode 100644 index 000000000..c69a369ac --- /dev/null +++ b/common/repositories/base/base_raid_members_repository.h @@ -0,0 +1,369 @@ +/** + * 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 on Apr 5, 2020 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_RAID_MEMBERS_REPOSITORY_H +#define EQEMU_BASE_RAID_MEMBERS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseRaidMembersRepository { +public: + struct RaidMembers { + int raidid; + int charid; + int groupid; + int8 _class; + int8 level; + std::string name; + int8 isgroupleader; + int8 israidleader; + int8 islooter; + }; + + static std::string PrimaryKey() + { + return std::string("charid"); + } + + static std::vector Columns() + { + return { + "raidid", + "charid", + "groupid", + "_class", + "level", + "name", + "isgroupleader", + "israidleader", + "islooter", + }; + } + + 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("raid_members"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static RaidMembers NewEntity() + { + RaidMembers entry{}; + + entry.raidid = 0; + entry.charid = 0; + entry.groupid = 0; + entry._class = 0; + entry.level = 0; + entry.name = ""; + entry.isgroupleader = 0; + entry.israidleader = 0; + entry.islooter = 0; + + return entry; + } + + static RaidMembers GetRaidMembersEntry( + const std::vector &raid_memberss, + int raid_members_id + ) + { + for (auto &raid_members : raid_memberss) { + if (raid_members.charid == raid_members_id) { + return raid_members; + } + } + + return NewEntity(); + } + + static RaidMembers FindOne( + int raid_members_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + raid_members_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + RaidMembers entry{}; + + entry.raidid = atoi(row[0]); + entry.charid = atoi(row[1]); + entry.groupid = atoi(row[2]); + entry._class = atoi(row[3]); + entry.level = atoi(row[4]); + entry.name = row[5] ? row[5] : ""; + entry.isgroupleader = atoi(row[6]); + entry.israidleader = atoi(row[7]); + entry.islooter = atoi(row[8]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int raid_members_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + raid_members_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + RaidMembers raid_members_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[0] + " = " + std::to_string(raid_members_entry.raidid)); + update_values.push_back(columns[2] + " = " + std::to_string(raid_members_entry.groupid)); + update_values.push_back(columns[3] + " = " + std::to_string(raid_members_entry._class)); + update_values.push_back(columns[4] + " = " + std::to_string(raid_members_entry.level)); + update_values.push_back(columns[5] + " = '" + EscapeString(raid_members_entry.name) + "'"); + update_values.push_back(columns[6] + " = " + std::to_string(raid_members_entry.isgroupleader)); + update_values.push_back(columns[7] + " = " + std::to_string(raid_members_entry.israidleader)); + update_values.push_back(columns[8] + " = " + std::to_string(raid_members_entry.islooter)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + raid_members_entry.charid + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static RaidMembers InsertOne( + RaidMembers raid_members_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(raid_members_entry.raidid)); + insert_values.push_back(std::to_string(raid_members_entry.groupid)); + insert_values.push_back(std::to_string(raid_members_entry._class)); + insert_values.push_back(std::to_string(raid_members_entry.level)); + insert_values.push_back("'" + EscapeString(raid_members_entry.name) + "'"); + insert_values.push_back(std::to_string(raid_members_entry.isgroupleader)); + insert_values.push_back(std::to_string(raid_members_entry.israidleader)); + insert_values.push_back(std::to_string(raid_members_entry.islooter)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + raid_members_entry.id = results.LastInsertedID(); + return raid_members_entry; + } + + raid_members_entry = NewEntity(); + + return raid_members_entry; + } + + static int InsertMany( + std::vector raid_members_entries + ) + { + std::vector insert_chunks; + + for (auto &raid_members_entry: raid_members_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(raid_members_entry.raidid)); + insert_values.push_back(std::to_string(raid_members_entry.groupid)); + insert_values.push_back(std::to_string(raid_members_entry._class)); + insert_values.push_back(std::to_string(raid_members_entry.level)); + insert_values.push_back("'" + EscapeString(raid_members_entry.name) + "'"); + insert_values.push_back(std::to_string(raid_members_entry.isgroupleader)); + insert_values.push_back(std::to_string(raid_members_entry.israidleader)); + insert_values.push_back(std::to_string(raid_members_entry.islooter)); + + 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) { + RaidMembers entry{}; + + entry.raidid = atoi(row[0]); + entry.charid = atoi(row[1]); + entry.groupid = atoi(row[2]); + entry._class = atoi(row[3]); + entry.level = atoi(row[4]); + entry.name = row[5] ? row[5] : ""; + entry.isgroupleader = atoi(row[6]); + entry.israidleader = atoi(row[7]); + entry.islooter = 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) { + RaidMembers entry{}; + + entry.raidid = atoi(row[0]); + entry.charid = atoi(row[1]); + entry.groupid = atoi(row[2]); + entry._class = atoi(row[3]); + entry.level = atoi(row[4]); + entry.name = row[5] ? row[5] : ""; + entry.isgroupleader = atoi(row[6]); + entry.israidleader = atoi(row[7]); + entry.islooter = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_RAID_MEMBERS_REPOSITORY_H diff --git a/common/repositories/base/base_reports_repository.h b/common/repositories/base/base_reports_repository.h new file mode 100644 index 000000000..5d61e1d9b --- /dev/null +++ b/common/repositories/base/base_reports_repository.h @@ -0,0 +1,324 @@ +/** + * 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 on Apr 5, 2020 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_REPORTS_REPOSITORY_H +#define EQEMU_BASE_REPORTS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseReportsRepository { +public: + struct Reports { + int id; + std::string name; + std::string reported; + std::string reported_text; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "name", + "reported", + "reported_text", + }; + } + + 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("reports"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Reports NewEntity() + { + Reports entry{}; + + entry.id = 0; + entry.name = ""; + entry.reported = ""; + entry.reported_text = ""; + + return entry; + } + + static Reports GetReportsEntry( + const std::vector &reportss, + int reports_id + ) + { + for (auto &reports : reportss) { + if (reports.id == reports_id) { + return reports; + } + } + + return NewEntity(); + } + + static Reports FindOne( + int reports_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + reports_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Reports entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.reported = row[2] ? row[2] : ""; + entry.reported_text = row[3] ? row[3] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int reports_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + reports_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Reports reports_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(reports_entry.name) + "'"); + update_values.push_back(columns[2] + " = '" + EscapeString(reports_entry.reported) + "'"); + update_values.push_back(columns[3] + " = '" + EscapeString(reports_entry.reported_text) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + reports_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Reports InsertOne( + Reports reports_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(reports_entry.name) + "'"); + insert_values.push_back("'" + EscapeString(reports_entry.reported) + "'"); + insert_values.push_back("'" + EscapeString(reports_entry.reported_text) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + reports_entry.id = results.LastInsertedID(); + return reports_entry; + } + + reports_entry = NewEntity(); + + return reports_entry; + } + + static int InsertMany( + std::vector reports_entries + ) + { + std::vector insert_chunks; + + for (auto &reports_entry: reports_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(reports_entry.name) + "'"); + insert_values.push_back("'" + EscapeString(reports_entry.reported) + "'"); + insert_values.push_back("'" + EscapeString(reports_entry.reported_text) + "'"); + + 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) { + Reports entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.reported = row[2] ? row[2] : ""; + entry.reported_text = row[3] ? 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) { + Reports entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.reported = row[2] ? row[2] : ""; + entry.reported_text = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_REPORTS_REPOSITORY_H diff --git a/common/repositories/base/base_respawn_times_repository.h b/common/repositories/base/base_respawn_times_repository.h new file mode 100644 index 000000000..86f6c8785 --- /dev/null +++ b/common/repositories/base/base_respawn_times_repository.h @@ -0,0 +1,321 @@ +/** + * 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 on Apr 5, 2020 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_RESPAWN_TIMES_REPOSITORY_H +#define EQEMU_BASE_RESPAWN_TIMES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseRespawnTimesRepository { +public: + struct RespawnTimes { + int id; + int start; + int duration; + int16 instance_id; + }; + + static std::string PrimaryKey() + { + return std::string("instance_id"); + } + + static std::vector Columns() + { + return { + "id", + "start", + "duration", + "instance_id", + }; + } + + 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("respawn_times"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static RespawnTimes NewEntity() + { + RespawnTimes entry{}; + + entry.id = 0; + entry.start = 0; + entry.duration = 0; + entry.instance_id = 0; + + return entry; + } + + static RespawnTimes GetRespawnTimesEntry( + const std::vector &respawn_timess, + int respawn_times_id + ) + { + for (auto &respawn_times : respawn_timess) { + if (respawn_times.instance_id == respawn_times_id) { + return respawn_times; + } + } + + return NewEntity(); + } + + static RespawnTimes FindOne( + int respawn_times_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + respawn_times_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + RespawnTimes entry{}; + + entry.id = atoi(row[0]); + entry.start = atoi(row[1]); + entry.duration = atoi(row[2]); + entry.instance_id = atoi(row[3]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int respawn_times_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + respawn_times_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + RespawnTimes respawn_times_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(respawn_times_entry.start)); + update_values.push_back(columns[2] + " = " + std::to_string(respawn_times_entry.duration)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + respawn_times_entry.instance_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static RespawnTimes InsertOne( + RespawnTimes respawn_times_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(respawn_times_entry.start)); + insert_values.push_back(std::to_string(respawn_times_entry.duration)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + respawn_times_entry.id = results.LastInsertedID(); + return respawn_times_entry; + } + + respawn_times_entry = NewEntity(); + + return respawn_times_entry; + } + + static int InsertMany( + std::vector respawn_times_entries + ) + { + std::vector insert_chunks; + + for (auto &respawn_times_entry: respawn_times_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(respawn_times_entry.start)); + insert_values.push_back(std::to_string(respawn_times_entry.duration)); + + 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) { + RespawnTimes entry{}; + + entry.id = atoi(row[0]); + entry.start = atoi(row[1]); + entry.duration = atoi(row[2]); + entry.instance_id = 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) { + RespawnTimes entry{}; + + entry.id = atoi(row[0]); + entry.start = atoi(row[1]); + entry.duration = atoi(row[2]); + entry.instance_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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_RESPAWN_TIMES_REPOSITORY_H diff --git a/common/repositories/base/base_rule_sets_repository.h b/common/repositories/base/base_rule_sets_repository.h new file mode 100644 index 000000000..e6a6c5717 --- /dev/null +++ b/common/repositories/base/base_rule_sets_repository.h @@ -0,0 +1,306 @@ +/** + * 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 on Apr 5, 2020 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_RULE_SETS_REPOSITORY_H +#define EQEMU_BASE_RULE_SETS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseRuleSetsRepository { +public: + struct RuleSets { + int8 ruleset_id; + std::string name; + }; + + static std::string PrimaryKey() + { + return std::string("ruleset_id"); + } + + static std::vector Columns() + { + return { + "ruleset_id", + "name", + }; + } + + 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("rule_sets"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static RuleSets NewEntity() + { + RuleSets entry{}; + + entry.ruleset_id = 0; + entry.name = ""; + + return entry; + } + + static RuleSets GetRuleSetsEntry( + const std::vector &rule_setss, + int rule_sets_id + ) + { + for (auto &rule_sets : rule_setss) { + if (rule_sets.ruleset_id == rule_sets_id) { + return rule_sets; + } + } + + return NewEntity(); + } + + static RuleSets FindOne( + int rule_sets_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + rule_sets_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + RuleSets entry{}; + + entry.ruleset_id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int rule_sets_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + rule_sets_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + RuleSets rule_sets_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(rule_sets_entry.name) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + rule_sets_entry.ruleset_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static RuleSets InsertOne( + RuleSets rule_sets_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(rule_sets_entry.name) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + rule_sets_entry.id = results.LastInsertedID(); + return rule_sets_entry; + } + + rule_sets_entry = NewEntity(); + + return rule_sets_entry; + } + + static int InsertMany( + std::vector rule_sets_entries + ) + { + std::vector insert_chunks; + + for (auto &rule_sets_entry: rule_sets_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(rule_sets_entry.name) + "'"); + + 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) { + RuleSets entry{}; + + entry.ruleset_id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + + 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) { + RuleSets entry{}; + + entry.ruleset_id = atoi(row[0]); + entry.name = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_RULE_SETS_REPOSITORY_H diff --git a/common/repositories/base/base_rule_values_repository.h b/common/repositories/base/base_rule_values_repository.h new file mode 100644 index 000000000..f6dd33980 --- /dev/null +++ b/common/repositories/base/base_rule_values_repository.h @@ -0,0 +1,321 @@ +/** + * 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 on Apr 5, 2020 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_RULE_VALUES_REPOSITORY_H +#define EQEMU_BASE_RULE_VALUES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseRuleValuesRepository { +public: + struct RuleValues { + int8 ruleset_id; + std::string rule_name; + std::string rule_value; + std::string notes; + }; + + static std::string PrimaryKey() + { + return std::string("rule_name"); + } + + static std::vector Columns() + { + return { + "ruleset_id", + "rule_name", + "rule_value", + "notes", + }; + } + + 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("rule_values"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static RuleValues NewEntity() + { + RuleValues entry{}; + + entry.ruleset_id = 0; + entry.rule_name = ""; + entry.rule_value = ""; + entry.notes = ""; + + return entry; + } + + static RuleValues GetRuleValuesEntry( + const std::vector &rule_valuess, + int rule_values_id + ) + { + for (auto &rule_values : rule_valuess) { + if (rule_values.rule_name == rule_values_id) { + return rule_values; + } + } + + return NewEntity(); + } + + static RuleValues FindOne( + int rule_values_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + rule_values_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + RuleValues entry{}; + + entry.ruleset_id = atoi(row[0]); + entry.rule_name = row[1] ? row[1] : ""; + entry.rule_value = row[2] ? row[2] : ""; + entry.notes = row[3] ? row[3] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int rule_values_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + rule_values_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + RuleValues rule_values_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = '" + EscapeString(rule_values_entry.rule_value) + "'"); + update_values.push_back(columns[3] + " = '" + EscapeString(rule_values_entry.notes) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + rule_values_entry.rule_name + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static RuleValues InsertOne( + RuleValues rule_values_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(rule_values_entry.rule_value) + "'"); + insert_values.push_back("'" + EscapeString(rule_values_entry.notes) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + rule_values_entry.id = results.LastInsertedID(); + return rule_values_entry; + } + + rule_values_entry = NewEntity(); + + return rule_values_entry; + } + + static int InsertMany( + std::vector rule_values_entries + ) + { + std::vector insert_chunks; + + for (auto &rule_values_entry: rule_values_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(rule_values_entry.rule_value) + "'"); + insert_values.push_back("'" + EscapeString(rule_values_entry.notes) + "'"); + + 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) { + RuleValues entry{}; + + entry.ruleset_id = atoi(row[0]); + entry.rule_name = row[1] ? row[1] : ""; + entry.rule_value = row[2] ? row[2] : ""; + entry.notes = row[3] ? 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) { + RuleValues entry{}; + + entry.ruleset_id = atoi(row[0]); + entry.rule_name = row[1] ? row[1] : ""; + entry.rule_value = row[2] ? 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_RULE_VALUES_REPOSITORY_H diff --git a/common/repositories/base/base_saylink_repository.h b/common/repositories/base/base_saylink_repository.h new file mode 100644 index 000000000..2d8da9040 --- /dev/null +++ b/common/repositories/base/base_saylink_repository.h @@ -0,0 +1,306 @@ +/** + * 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 on Apr 5, 2020 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_SAYLINK_REPOSITORY_H +#define EQEMU_BASE_SAYLINK_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseSaylinkRepository { +public: + struct Saylink { + int id; + std::string phrase; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "phrase", + }; + } + + 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("saylink"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Saylink NewEntity() + { + Saylink entry{}; + + entry.id = 0; + entry.phrase = ""; + + return entry; + } + + static Saylink GetSaylinkEntry( + const std::vector &saylinks, + int saylink_id + ) + { + for (auto &saylink : saylinks) { + if (saylink.id == saylink_id) { + return saylink; + } + } + + return NewEntity(); + } + + static Saylink FindOne( + int saylink_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + saylink_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Saylink entry{}; + + entry.id = atoi(row[0]); + entry.phrase = row[1] ? row[1] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int saylink_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + saylink_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Saylink saylink_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(saylink_entry.phrase) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + saylink_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Saylink InsertOne( + Saylink saylink_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(saylink_entry.phrase) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + saylink_entry.id = results.LastInsertedID(); + return saylink_entry; + } + + saylink_entry = NewEntity(); + + return saylink_entry; + } + + static int InsertMany( + std::vector saylink_entries + ) + { + std::vector insert_chunks; + + for (auto &saylink_entry: saylink_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(saylink_entry.phrase) + "'"); + + 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) { + Saylink entry{}; + + entry.id = atoi(row[0]); + entry.phrase = row[1] ? row[1] : ""; + + 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) { + Saylink entry{}; + + entry.id = atoi(row[0]); + entry.phrase = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_SAYLINK_REPOSITORY_H diff --git a/common/repositories/base/base_skill_caps_repository.h b/common/repositories/base/base_skill_caps_repository.h new file mode 100644 index 000000000..daf293f0a --- /dev/null +++ b/common/repositories/base/base_skill_caps_repository.h @@ -0,0 +1,324 @@ +/** + * 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 on Apr 5, 2020 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_SKILL_CAPS_REPOSITORY_H +#define EQEMU_BASE_SKILL_CAPS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseSkillCapsRepository { +public: + struct SkillCaps { + int8 skillID; + int8 class; + int8 level; + int cap; + int8 class_; + }; + + static std::string PrimaryKey() + { + return std::string("class_"); + } + + static std::vector Columns() + { + return { + "skillID", + "class", + "level", + "cap", + "class_", + }; + } + + 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("skill_caps"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static SkillCaps NewEntity() + { + SkillCaps entry{}; + + entry.skillID = 0; + entry.class = 0; + entry.level = 0; + entry.cap = 0; + entry.class_ = 0; + + return entry; + } + + static SkillCaps GetSkillCapsEntry( + const std::vector &skill_capss, + int skill_caps_id + ) + { + for (auto &skill_caps : skill_capss) { + if (skill_caps.class_ == skill_caps_id) { + return skill_caps; + } + } + + return NewEntity(); + } + + static SkillCaps FindOne( + int skill_caps_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + skill_caps_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + SkillCaps entry{}; + + entry.skillID = atoi(row[0]); + entry.class = atoi(row[1]); + entry.level = atoi(row[2]); + entry.cap = atoi(row[3]); + entry.class_ = atoi(row[4]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int skill_caps_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + skill_caps_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + SkillCaps skill_caps_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[3] + " = " + std::to_string(skill_caps_entry.cap)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + skill_caps_entry.class_ + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static SkillCaps InsertOne( + SkillCaps skill_caps_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(skill_caps_entry.cap)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + skill_caps_entry.id = results.LastInsertedID(); + return skill_caps_entry; + } + + skill_caps_entry = NewEntity(); + + return skill_caps_entry; + } + + static int InsertMany( + std::vector skill_caps_entries + ) + { + std::vector insert_chunks; + + for (auto &skill_caps_entry: skill_caps_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(skill_caps_entry.cap)); + + 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) { + SkillCaps entry{}; + + entry.skillID = atoi(row[0]); + entry.class = atoi(row[1]); + entry.level = atoi(row[2]); + entry.cap = atoi(row[3]); + entry.class_ = atoi(row[4]); + + 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) { + SkillCaps entry{}; + + entry.skillID = atoi(row[0]); + entry.class = atoi(row[1]); + entry.level = atoi(row[2]); + entry.cap = atoi(row[3]); + entry.class_ = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_SKILL_CAPS_REPOSITORY_H diff --git a/common/repositories/base/base_spawn2_repository.h b/common/repositories/base/base_spawn2_repository.h new file mode 100644 index 000000000..423e9798d --- /dev/null +++ b/common/repositories/base/base_spawn2_repository.h @@ -0,0 +1,423 @@ +/** + * 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 on Apr 5, 2020 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_SPAWN2_REPOSITORY_H +#define EQEMU_BASE_SPAWN2_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseSpawn2Repository { +public: + struct Spawn2 { + int id; + int spawngroupID; + std::string zone; + int16 version; + float x; + float y; + float z; + float heading; + int respawntime; + int variance; + int pathgrid; + int _condition; + int cond_value; + int8 enabled; + int8 animation; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "spawngroupID", + "zone", + "version", + "x", + "y", + "z", + "heading", + "respawntime", + "variance", + "pathgrid", + "_condition", + "cond_value", + "enabled", + "animation", + }; + } + + 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("spawn2"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Spawn2 NewEntity() + { + Spawn2 entry{}; + + entry.id = 0; + entry.spawngroupID = 0; + entry.zone = ""; + entry.version = 0; + entry.x = 0.000000; + entry.y = 0.000000; + entry.z = 0.000000; + entry.heading = 0.000000; + entry.respawntime = 0; + entry.variance = 0; + entry.pathgrid = 0; + entry._condition = 0; + entry.cond_value = 1; + entry.enabled = 1; + entry.animation = 0; + + return entry; + } + + static Spawn2 GetSpawn2Entry( + const std::vector &spawn2s, + int spawn2_id + ) + { + for (auto &spawn2 : spawn2s) { + if (spawn2.id == spawn2_id) { + return spawn2; + } + } + + return NewEntity(); + } + + static Spawn2 FindOne( + int spawn2_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + spawn2_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Spawn2 entry{}; + + entry.id = atoi(row[0]); + entry.spawngroupID = atoi(row[1]); + entry.zone = row[2] ? row[2] : ""; + entry.version = atoi(row[3]); + entry.x = atof(row[4]); + entry.y = atof(row[5]); + entry.z = atof(row[6]); + entry.heading = atof(row[7]); + entry.respawntime = atoi(row[8]); + entry.variance = atoi(row[9]); + entry.pathgrid = atoi(row[10]); + entry._condition = atoi(row[11]); + entry.cond_value = atoi(row[12]); + entry.enabled = atoi(row[13]); + entry.animation = atoi(row[14]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int spawn2_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + spawn2_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Spawn2 spawn2_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(spawn2_entry.spawngroupID)); + update_values.push_back(columns[2] + " = '" + EscapeString(spawn2_entry.zone) + "'"); + update_values.push_back(columns[3] + " = " + std::to_string(spawn2_entry.version)); + update_values.push_back(columns[4] + " = " + std::to_string(spawn2_entry.x)); + update_values.push_back(columns[5] + " = " + std::to_string(spawn2_entry.y)); + update_values.push_back(columns[6] + " = " + std::to_string(spawn2_entry.z)); + update_values.push_back(columns[7] + " = " + std::to_string(spawn2_entry.heading)); + update_values.push_back(columns[8] + " = " + std::to_string(spawn2_entry.respawntime)); + update_values.push_back(columns[9] + " = " + std::to_string(spawn2_entry.variance)); + update_values.push_back(columns[10] + " = " + std::to_string(spawn2_entry.pathgrid)); + update_values.push_back(columns[11] + " = " + std::to_string(spawn2_entry._condition)); + update_values.push_back(columns[12] + " = " + std::to_string(spawn2_entry.cond_value)); + update_values.push_back(columns[13] + " = " + std::to_string(spawn2_entry.enabled)); + update_values.push_back(columns[14] + " = " + std::to_string(spawn2_entry.animation)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + spawn2_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Spawn2 InsertOne( + Spawn2 spawn2_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(spawn2_entry.spawngroupID)); + insert_values.push_back("'" + EscapeString(spawn2_entry.zone) + "'"); + insert_values.push_back(std::to_string(spawn2_entry.version)); + insert_values.push_back(std::to_string(spawn2_entry.x)); + insert_values.push_back(std::to_string(spawn2_entry.y)); + insert_values.push_back(std::to_string(spawn2_entry.z)); + insert_values.push_back(std::to_string(spawn2_entry.heading)); + insert_values.push_back(std::to_string(spawn2_entry.respawntime)); + insert_values.push_back(std::to_string(spawn2_entry.variance)); + insert_values.push_back(std::to_string(spawn2_entry.pathgrid)); + insert_values.push_back(std::to_string(spawn2_entry._condition)); + insert_values.push_back(std::to_string(spawn2_entry.cond_value)); + insert_values.push_back(std::to_string(spawn2_entry.enabled)); + insert_values.push_back(std::to_string(spawn2_entry.animation)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + spawn2_entry.id = results.LastInsertedID(); + return spawn2_entry; + } + + spawn2_entry = NewEntity(); + + return spawn2_entry; + } + + static int InsertMany( + std::vector spawn2_entries + ) + { + std::vector insert_chunks; + + for (auto &spawn2_entry: spawn2_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(spawn2_entry.spawngroupID)); + insert_values.push_back("'" + EscapeString(spawn2_entry.zone) + "'"); + insert_values.push_back(std::to_string(spawn2_entry.version)); + insert_values.push_back(std::to_string(spawn2_entry.x)); + insert_values.push_back(std::to_string(spawn2_entry.y)); + insert_values.push_back(std::to_string(spawn2_entry.z)); + insert_values.push_back(std::to_string(spawn2_entry.heading)); + insert_values.push_back(std::to_string(spawn2_entry.respawntime)); + insert_values.push_back(std::to_string(spawn2_entry.variance)); + insert_values.push_back(std::to_string(spawn2_entry.pathgrid)); + insert_values.push_back(std::to_string(spawn2_entry._condition)); + insert_values.push_back(std::to_string(spawn2_entry.cond_value)); + insert_values.push_back(std::to_string(spawn2_entry.enabled)); + insert_values.push_back(std::to_string(spawn2_entry.animation)); + + 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) { + Spawn2 entry{}; + + entry.id = atoi(row[0]); + entry.spawngroupID = atoi(row[1]); + entry.zone = row[2] ? row[2] : ""; + entry.version = atoi(row[3]); + entry.x = atof(row[4]); + entry.y = atof(row[5]); + entry.z = atof(row[6]); + entry.heading = atof(row[7]); + entry.respawntime = atoi(row[8]); + entry.variance = atoi(row[9]); + entry.pathgrid = atoi(row[10]); + entry._condition = atoi(row[11]); + entry.cond_value = atoi(row[12]); + entry.enabled = atoi(row[13]); + entry.animation = atoi(row[14]); + + 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) { + Spawn2 entry{}; + + entry.id = atoi(row[0]); + entry.spawngroupID = atoi(row[1]); + entry.zone = row[2] ? row[2] : ""; + entry.version = atoi(row[3]); + entry.x = atof(row[4]); + entry.y = atof(row[5]); + entry.z = atof(row[6]); + entry.heading = atof(row[7]); + entry.respawntime = atoi(row[8]); + entry.variance = atoi(row[9]); + entry.pathgrid = atoi(row[10]); + entry._condition = atoi(row[11]); + entry.cond_value = atoi(row[12]); + entry.enabled = atoi(row[13]); + entry.animation = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_SPAWN2_REPOSITORY_H diff --git a/common/repositories/base/base_spawn_condition_values_repository.h b/common/repositories/base/base_spawn_condition_values_repository.h new file mode 100644 index 000000000..de279e9f7 --- /dev/null +++ b/common/repositories/base/base_spawn_condition_values_repository.h @@ -0,0 +1,318 @@ +/** + * 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 on Apr 5, 2020 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_SPAWN_CONDITION_VALUES_REPOSITORY_H +#define EQEMU_BASE_SPAWN_CONDITION_VALUES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseSpawnConditionValuesRepository { +public: + struct SpawnConditionValues { + int id; + int8 value; + std::string zone; + int instance_id; + }; + + static std::string PrimaryKey() + { + return std::string("instance_id"); + } + + static std::vector Columns() + { + return { + "id", + "value", + "zone", + "instance_id", + }; + } + + 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("spawn_condition_values"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static SpawnConditionValues NewEntity() + { + SpawnConditionValues entry{}; + + entry.id = 0; + entry.value = 0; + entry.zone = ""; + entry.instance_id = 0; + + return entry; + } + + static SpawnConditionValues GetSpawnConditionValuesEntry( + const std::vector &spawn_condition_valuess, + int spawn_condition_values_id + ) + { + for (auto &spawn_condition_values : spawn_condition_valuess) { + if (spawn_condition_values.instance_id == spawn_condition_values_id) { + return spawn_condition_values; + } + } + + return NewEntity(); + } + + static SpawnConditionValues FindOne( + int spawn_condition_values_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + spawn_condition_values_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + SpawnConditionValues entry{}; + + entry.id = atoi(row[0]); + entry.value = atoi(row[1]); + entry.zone = row[2] ? row[2] : ""; + entry.instance_id = atoi(row[3]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int spawn_condition_values_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + spawn_condition_values_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + SpawnConditionValues spawn_condition_values_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(spawn_condition_values_entry.value)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + spawn_condition_values_entry.instance_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static SpawnConditionValues InsertOne( + SpawnConditionValues spawn_condition_values_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(spawn_condition_values_entry.value)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + spawn_condition_values_entry.id = results.LastInsertedID(); + return spawn_condition_values_entry; + } + + spawn_condition_values_entry = NewEntity(); + + return spawn_condition_values_entry; + } + + static int InsertMany( + std::vector spawn_condition_values_entries + ) + { + std::vector insert_chunks; + + for (auto &spawn_condition_values_entry: spawn_condition_values_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(spawn_condition_values_entry.value)); + + 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) { + SpawnConditionValues entry{}; + + entry.id = atoi(row[0]); + entry.value = atoi(row[1]); + entry.zone = row[2] ? row[2] : ""; + entry.instance_id = 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) { + SpawnConditionValues entry{}; + + entry.id = atoi(row[0]); + entry.value = atoi(row[1]); + entry.zone = row[2] ? row[2] : ""; + entry.instance_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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_SPAWN_CONDITION_VALUES_REPOSITORY_H diff --git a/common/repositories/base/base_spawn_conditions_repository.h b/common/repositories/base/base_spawn_conditions_repository.h new file mode 100644 index 000000000..b6671182d --- /dev/null +++ b/common/repositories/base/base_spawn_conditions_repository.h @@ -0,0 +1,330 @@ +/** + * 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 on Apr 5, 2020 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_SPAWN_CONDITIONS_REPOSITORY_H +#define EQEMU_BASE_SPAWN_CONDITIONS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseSpawnConditionsRepository { +public: + struct SpawnConditions { + std::string zone; + int id; + int value; + int8 onchange; + std::string name; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "zone", + "id", + "value", + "onchange", + "name", + }; + } + + 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("spawn_conditions"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static SpawnConditions NewEntity() + { + SpawnConditions entry{}; + + entry.zone = ""; + entry.id = 1; + entry.value = 0; + entry.onchange = 0; + entry.name = ""; + + return entry; + } + + static SpawnConditions GetSpawnConditionsEntry( + const std::vector &spawn_conditionss, + int spawn_conditions_id + ) + { + for (auto &spawn_conditions : spawn_conditionss) { + if (spawn_conditions.id == spawn_conditions_id) { + return spawn_conditions; + } + } + + return NewEntity(); + } + + static SpawnConditions FindOne( + int spawn_conditions_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + spawn_conditions_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + SpawnConditions entry{}; + + entry.zone = row[0] ? row[0] : ""; + entry.id = atoi(row[1]); + entry.value = atoi(row[2]); + entry.onchange = atoi(row[3]); + entry.name = row[4] ? row[4] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int spawn_conditions_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + spawn_conditions_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + SpawnConditions spawn_conditions_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = " + std::to_string(spawn_conditions_entry.value)); + update_values.push_back(columns[3] + " = " + std::to_string(spawn_conditions_entry.onchange)); + update_values.push_back(columns[4] + " = '" + EscapeString(spawn_conditions_entry.name) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + spawn_conditions_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static SpawnConditions InsertOne( + SpawnConditions spawn_conditions_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(spawn_conditions_entry.value)); + insert_values.push_back(std::to_string(spawn_conditions_entry.onchange)); + insert_values.push_back("'" + EscapeString(spawn_conditions_entry.name) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + spawn_conditions_entry.id = results.LastInsertedID(); + return spawn_conditions_entry; + } + + spawn_conditions_entry = NewEntity(); + + return spawn_conditions_entry; + } + + static int InsertMany( + std::vector spawn_conditions_entries + ) + { + std::vector insert_chunks; + + for (auto &spawn_conditions_entry: spawn_conditions_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(spawn_conditions_entry.value)); + insert_values.push_back(std::to_string(spawn_conditions_entry.onchange)); + insert_values.push_back("'" + EscapeString(spawn_conditions_entry.name) + "'"); + + 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) { + SpawnConditions entry{}; + + entry.zone = row[0] ? row[0] : ""; + entry.id = atoi(row[1]); + entry.value = atoi(row[2]); + entry.onchange = atoi(row[3]); + entry.name = row[4] ? row[4] : ""; + + 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) { + SpawnConditions entry{}; + + entry.zone = row[0] ? row[0] : ""; + entry.id = atoi(row[1]); + entry.value = atoi(row[2]); + entry.onchange = atoi(row[3]); + entry.name = row[4] ? 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_SPAWN_CONDITIONS_REPOSITORY_H diff --git a/common/repositories/base/base_spawn_events_repository.h b/common/repositories/base/base_spawn_events_repository.h new file mode 100644 index 000000000..4fa81b0fc --- /dev/null +++ b/common/repositories/base/base_spawn_events_repository.h @@ -0,0 +1,414 @@ +/** + * 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 on Apr 5, 2020 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_SPAWN_EVENTS_REPOSITORY_H +#define EQEMU_BASE_SPAWN_EVENTS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseSpawnEventsRepository { +public: + struct SpawnEvents { + int id; + std::string zone; + int cond_id; + std::string name; + int period; + int8 next_minute; + int8 next_hour; + int8 next_day; + int8 next_month; + int next_year; + int8 enabled; + int8 action; + int argument; + int8 strict; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "zone", + "cond_id", + "name", + "period", + "next_minute", + "next_hour", + "next_day", + "next_month", + "next_year", + "enabled", + "action", + "argument", + "strict", + }; + } + + 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("spawn_events"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static SpawnEvents NewEntity() + { + SpawnEvents entry{}; + + entry.id = 0; + entry.zone = ""; + entry.cond_id = 0; + entry.name = ""; + entry.period = 0; + entry.next_minute = 0; + entry.next_hour = 0; + entry.next_day = 0; + entry.next_month = 0; + entry.next_year = 0; + entry.enabled = 1; + entry.action = 0; + entry.argument = 0; + entry.strict = 0; + + return entry; + } + + static SpawnEvents GetSpawnEventsEntry( + const std::vector &spawn_eventss, + int spawn_events_id + ) + { + for (auto &spawn_events : spawn_eventss) { + if (spawn_events.id == spawn_events_id) { + return spawn_events; + } + } + + return NewEntity(); + } + + static SpawnEvents FindOne( + int spawn_events_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + spawn_events_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + SpawnEvents entry{}; + + entry.id = atoi(row[0]); + entry.zone = row[1] ? row[1] : ""; + entry.cond_id = atoi(row[2]); + entry.name = row[3] ? row[3] : ""; + entry.period = atoi(row[4]); + entry.next_minute = atoi(row[5]); + entry.next_hour = atoi(row[6]); + entry.next_day = atoi(row[7]); + entry.next_month = atoi(row[8]); + entry.next_year = atoi(row[9]); + entry.enabled = atoi(row[10]); + entry.action = atoi(row[11]); + entry.argument = atoi(row[12]); + entry.strict = atoi(row[13]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int spawn_events_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + spawn_events_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + SpawnEvents spawn_events_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(spawn_events_entry.zone) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(spawn_events_entry.cond_id)); + update_values.push_back(columns[3] + " = '" + EscapeString(spawn_events_entry.name) + "'"); + update_values.push_back(columns[4] + " = " + std::to_string(spawn_events_entry.period)); + update_values.push_back(columns[5] + " = " + std::to_string(spawn_events_entry.next_minute)); + update_values.push_back(columns[6] + " = " + std::to_string(spawn_events_entry.next_hour)); + update_values.push_back(columns[7] + " = " + std::to_string(spawn_events_entry.next_day)); + update_values.push_back(columns[8] + " = " + std::to_string(spawn_events_entry.next_month)); + update_values.push_back(columns[9] + " = " + std::to_string(spawn_events_entry.next_year)); + update_values.push_back(columns[10] + " = " + std::to_string(spawn_events_entry.enabled)); + update_values.push_back(columns[11] + " = " + std::to_string(spawn_events_entry.action)); + update_values.push_back(columns[12] + " = " + std::to_string(spawn_events_entry.argument)); + update_values.push_back(columns[13] + " = " + std::to_string(spawn_events_entry.strict)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + spawn_events_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static SpawnEvents InsertOne( + SpawnEvents spawn_events_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(spawn_events_entry.zone) + "'"); + insert_values.push_back(std::to_string(spawn_events_entry.cond_id)); + insert_values.push_back("'" + EscapeString(spawn_events_entry.name) + "'"); + insert_values.push_back(std::to_string(spawn_events_entry.period)); + insert_values.push_back(std::to_string(spawn_events_entry.next_minute)); + insert_values.push_back(std::to_string(spawn_events_entry.next_hour)); + insert_values.push_back(std::to_string(spawn_events_entry.next_day)); + insert_values.push_back(std::to_string(spawn_events_entry.next_month)); + insert_values.push_back(std::to_string(spawn_events_entry.next_year)); + insert_values.push_back(std::to_string(spawn_events_entry.enabled)); + insert_values.push_back(std::to_string(spawn_events_entry.action)); + insert_values.push_back(std::to_string(spawn_events_entry.argument)); + insert_values.push_back(std::to_string(spawn_events_entry.strict)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + spawn_events_entry.id = results.LastInsertedID(); + return spawn_events_entry; + } + + spawn_events_entry = NewEntity(); + + return spawn_events_entry; + } + + static int InsertMany( + std::vector spawn_events_entries + ) + { + std::vector insert_chunks; + + for (auto &spawn_events_entry: spawn_events_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(spawn_events_entry.zone) + "'"); + insert_values.push_back(std::to_string(spawn_events_entry.cond_id)); + insert_values.push_back("'" + EscapeString(spawn_events_entry.name) + "'"); + insert_values.push_back(std::to_string(spawn_events_entry.period)); + insert_values.push_back(std::to_string(spawn_events_entry.next_minute)); + insert_values.push_back(std::to_string(spawn_events_entry.next_hour)); + insert_values.push_back(std::to_string(spawn_events_entry.next_day)); + insert_values.push_back(std::to_string(spawn_events_entry.next_month)); + insert_values.push_back(std::to_string(spawn_events_entry.next_year)); + insert_values.push_back(std::to_string(spawn_events_entry.enabled)); + insert_values.push_back(std::to_string(spawn_events_entry.action)); + insert_values.push_back(std::to_string(spawn_events_entry.argument)); + insert_values.push_back(std::to_string(spawn_events_entry.strict)); + + 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) { + SpawnEvents entry{}; + + entry.id = atoi(row[0]); + entry.zone = row[1] ? row[1] : ""; + entry.cond_id = atoi(row[2]); + entry.name = row[3] ? row[3] : ""; + entry.period = atoi(row[4]); + entry.next_minute = atoi(row[5]); + entry.next_hour = atoi(row[6]); + entry.next_day = atoi(row[7]); + entry.next_month = atoi(row[8]); + entry.next_year = atoi(row[9]); + entry.enabled = atoi(row[10]); + entry.action = atoi(row[11]); + entry.argument = atoi(row[12]); + entry.strict = atoi(row[13]); + + 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) { + SpawnEvents entry{}; + + entry.id = atoi(row[0]); + entry.zone = row[1] ? row[1] : ""; + entry.cond_id = atoi(row[2]); + entry.name = row[3] ? row[3] : ""; + entry.period = atoi(row[4]); + entry.next_minute = atoi(row[5]); + entry.next_hour = atoi(row[6]); + entry.next_day = atoi(row[7]); + entry.next_month = atoi(row[8]); + entry.next_year = atoi(row[9]); + entry.enabled = atoi(row[10]); + entry.action = atoi(row[11]); + entry.argument = atoi(row[12]); + entry.strict = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_SPAWN_EVENTS_REPOSITORY_H diff --git a/common/repositories/base/base_spawnentry_repository.h b/common/repositories/base/base_spawnentry_repository.h new file mode 100644 index 000000000..7733ddea0 --- /dev/null +++ b/common/repositories/base/base_spawnentry_repository.h @@ -0,0 +1,321 @@ +/** + * 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 on Apr 5, 2020 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_SPAWNENTRY_REPOSITORY_H +#define EQEMU_BASE_SPAWNENTRY_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseSpawnentryRepository { +public: + struct Spawnentry { + int spawngroupID; + int npcID; + int16 chance; + int condition_value_filter; + }; + + static std::string PrimaryKey() + { + return std::string("npcID"); + } + + static std::vector Columns() + { + return { + "spawngroupID", + "npcID", + "chance", + "condition_value_filter", + }; + } + + 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("spawnentry"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Spawnentry NewEntity() + { + Spawnentry entry{}; + + entry.spawngroupID = 0; + entry.npcID = 0; + entry.chance = 0; + entry.condition_value_filter = 1; + + return entry; + } + + static Spawnentry GetSpawnentryEntry( + const std::vector &spawnentrys, + int spawnentry_id + ) + { + for (auto &spawnentry : spawnentrys) { + if (spawnentry.npcID == spawnentry_id) { + return spawnentry; + } + } + + return NewEntity(); + } + + static Spawnentry FindOne( + int spawnentry_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + spawnentry_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Spawnentry entry{}; + + entry.spawngroupID = atoi(row[0]); + entry.npcID = atoi(row[1]); + entry.chance = atoi(row[2]); + entry.condition_value_filter = atoi(row[3]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int spawnentry_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + spawnentry_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Spawnentry spawnentry_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = " + std::to_string(spawnentry_entry.chance)); + update_values.push_back(columns[3] + " = " + std::to_string(spawnentry_entry.condition_value_filter)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + spawnentry_entry.npcID + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Spawnentry InsertOne( + Spawnentry spawnentry_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(spawnentry_entry.chance)); + insert_values.push_back(std::to_string(spawnentry_entry.condition_value_filter)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + spawnentry_entry.id = results.LastInsertedID(); + return spawnentry_entry; + } + + spawnentry_entry = NewEntity(); + + return spawnentry_entry; + } + + static int InsertMany( + std::vector spawnentry_entries + ) + { + std::vector insert_chunks; + + for (auto &spawnentry_entry: spawnentry_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(spawnentry_entry.chance)); + insert_values.push_back(std::to_string(spawnentry_entry.condition_value_filter)); + + 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) { + Spawnentry entry{}; + + entry.spawngroupID = atoi(row[0]); + entry.npcID = atoi(row[1]); + entry.chance = atoi(row[2]); + entry.condition_value_filter = 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 = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Spawnentry entry{}; + + entry.spawngroupID = atoi(row[0]); + entry.npcID = atoi(row[1]); + entry.chance = atoi(row[2]); + entry.condition_value_filter = atoi(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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_SPAWNENTRY_REPOSITORY_H diff --git a/common/repositories/base/base_spawngroup_repository.h b/common/repositories/base/base_spawngroup_repository.h new file mode 100644 index 000000000..6f0897d1b --- /dev/null +++ b/common/repositories/base/base_spawngroup_repository.h @@ -0,0 +1,405 @@ +/** + * 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 on Apr 5, 2020 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_SPAWNGROUP_REPOSITORY_H +#define EQEMU_BASE_SPAWNGROUP_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseSpawngroupRepository { +public: + struct Spawngroup { + int id; + std::string name; + int8 spawn_limit; + float dist; + float max_x; + float min_x; + float max_y; + float min_y; + int delay; + int mindelay; + int8 despawn; + int despawn_timer; + int8 wp_spawns; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "name", + "spawn_limit", + "dist", + "max_x", + "min_x", + "max_y", + "min_y", + "delay", + "mindelay", + "despawn", + "despawn_timer", + "wp_spawns", + }; + } + + 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("spawngroup"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Spawngroup NewEntity() + { + Spawngroup entry{}; + + entry.id = 0; + entry.name = ""; + entry.spawn_limit = 0; + entry.dist = 0; + entry.max_x = 0; + entry.min_x = 0; + entry.max_y = 0; + entry.min_y = 0; + entry.delay = 45000; + entry.mindelay = 15000; + entry.despawn = 0; + entry.despawn_timer = 100; + entry.wp_spawns = 0; + + return entry; + } + + static Spawngroup GetSpawngroupEntry( + const std::vector &spawngroups, + int spawngroup_id + ) + { + for (auto &spawngroup : spawngroups) { + if (spawngroup.id == spawngroup_id) { + return spawngroup; + } + } + + return NewEntity(); + } + + static Spawngroup FindOne( + int spawngroup_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + spawngroup_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Spawngroup entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.spawn_limit = atoi(row[2]); + entry.dist = atof(row[3]); + entry.max_x = atof(row[4]); + entry.min_x = atof(row[5]); + entry.max_y = atof(row[6]); + entry.min_y = atof(row[7]); + entry.delay = atoi(row[8]); + entry.mindelay = atoi(row[9]); + entry.despawn = atoi(row[10]); + entry.despawn_timer = atoi(row[11]); + entry.wp_spawns = atoi(row[12]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int spawngroup_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + spawngroup_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Spawngroup spawngroup_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(spawngroup_entry.name) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(spawngroup_entry.spawn_limit)); + update_values.push_back(columns[3] + " = " + std::to_string(spawngroup_entry.dist)); + update_values.push_back(columns[4] + " = " + std::to_string(spawngroup_entry.max_x)); + update_values.push_back(columns[5] + " = " + std::to_string(spawngroup_entry.min_x)); + update_values.push_back(columns[6] + " = " + std::to_string(spawngroup_entry.max_y)); + update_values.push_back(columns[7] + " = " + std::to_string(spawngroup_entry.min_y)); + update_values.push_back(columns[8] + " = " + std::to_string(spawngroup_entry.delay)); + update_values.push_back(columns[9] + " = " + std::to_string(spawngroup_entry.mindelay)); + update_values.push_back(columns[10] + " = " + std::to_string(spawngroup_entry.despawn)); + update_values.push_back(columns[11] + " = " + std::to_string(spawngroup_entry.despawn_timer)); + update_values.push_back(columns[12] + " = " + std::to_string(spawngroup_entry.wp_spawns)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + spawngroup_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Spawngroup InsertOne( + Spawngroup spawngroup_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(spawngroup_entry.name) + "'"); + insert_values.push_back(std::to_string(spawngroup_entry.spawn_limit)); + insert_values.push_back(std::to_string(spawngroup_entry.dist)); + insert_values.push_back(std::to_string(spawngroup_entry.max_x)); + insert_values.push_back(std::to_string(spawngroup_entry.min_x)); + insert_values.push_back(std::to_string(spawngroup_entry.max_y)); + insert_values.push_back(std::to_string(spawngroup_entry.min_y)); + insert_values.push_back(std::to_string(spawngroup_entry.delay)); + insert_values.push_back(std::to_string(spawngroup_entry.mindelay)); + insert_values.push_back(std::to_string(spawngroup_entry.despawn)); + insert_values.push_back(std::to_string(spawngroup_entry.despawn_timer)); + insert_values.push_back(std::to_string(spawngroup_entry.wp_spawns)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + spawngroup_entry.id = results.LastInsertedID(); + return spawngroup_entry; + } + + spawngroup_entry = NewEntity(); + + return spawngroup_entry; + } + + static int InsertMany( + std::vector spawngroup_entries + ) + { + std::vector insert_chunks; + + for (auto &spawngroup_entry: spawngroup_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(spawngroup_entry.name) + "'"); + insert_values.push_back(std::to_string(spawngroup_entry.spawn_limit)); + insert_values.push_back(std::to_string(spawngroup_entry.dist)); + insert_values.push_back(std::to_string(spawngroup_entry.max_x)); + insert_values.push_back(std::to_string(spawngroup_entry.min_x)); + insert_values.push_back(std::to_string(spawngroup_entry.max_y)); + insert_values.push_back(std::to_string(spawngroup_entry.min_y)); + insert_values.push_back(std::to_string(spawngroup_entry.delay)); + insert_values.push_back(std::to_string(spawngroup_entry.mindelay)); + insert_values.push_back(std::to_string(spawngroup_entry.despawn)); + insert_values.push_back(std::to_string(spawngroup_entry.despawn_timer)); + insert_values.push_back(std::to_string(spawngroup_entry.wp_spawns)); + + 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) { + Spawngroup entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.spawn_limit = atoi(row[2]); + entry.dist = atof(row[3]); + entry.max_x = atof(row[4]); + entry.min_x = atof(row[5]); + entry.max_y = atof(row[6]); + entry.min_y = atof(row[7]); + entry.delay = atoi(row[8]); + entry.mindelay = atoi(row[9]); + entry.despawn = atoi(row[10]); + entry.despawn_timer = atoi(row[11]); + entry.wp_spawns = atoi(row[12]); + + 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) { + Spawngroup entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.spawn_limit = atoi(row[2]); + entry.dist = atof(row[3]); + entry.max_x = atof(row[4]); + entry.min_x = atof(row[5]); + entry.max_y = atof(row[6]); + entry.min_y = atof(row[7]); + entry.delay = atoi(row[8]); + entry.mindelay = atoi(row[9]); + entry.despawn = atoi(row[10]); + entry.despawn_timer = atoi(row[11]); + entry.wp_spawns = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_SPAWNGROUP_REPOSITORY_H diff --git a/common/repositories/base/base_spell_buckets_repository.h b/common/repositories/base/base_spell_buckets_repository.h new file mode 100644 index 000000000..1c0e9505f --- /dev/null +++ b/common/repositories/base/base_spell_buckets_repository.h @@ -0,0 +1,315 @@ +/** + * 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 on Apr 5, 2020 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_SPELL_BUCKETS_REPOSITORY_H +#define EQEMU_BASE_SPELL_BUCKETS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseSpellBucketsRepository { +public: + struct SpellBuckets { + int spellid; + std::string key; + std::string value; + }; + + static std::string PrimaryKey() + { + return std::string("spellid"); + } + + static std::vector Columns() + { + return { + "spellid", + "key", + "value", + }; + } + + 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("spell_buckets"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static SpellBuckets NewEntity() + { + SpellBuckets entry{}; + + entry.spellid = 0; + entry.key = ""; + entry.value = ""; + + return entry; + } + + static SpellBuckets GetSpellBucketsEntry( + const std::vector &spell_bucketss, + int spell_buckets_id + ) + { + for (auto &spell_buckets : spell_bucketss) { + if (spell_buckets.spellid == spell_buckets_id) { + return spell_buckets; + } + } + + return NewEntity(); + } + + static SpellBuckets FindOne( + int spell_buckets_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + spell_buckets_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + SpellBuckets entry{}; + + entry.spellid = atoi(row[0]); + entry.key = row[1] ? row[1] : ""; + entry.value = row[2] ? row[2] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int spell_buckets_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + spell_buckets_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + SpellBuckets spell_buckets_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(spell_buckets_entry.key) + "'"); + update_values.push_back(columns[2] + " = '" + EscapeString(spell_buckets_entry.value) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + spell_buckets_entry.spellid + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static SpellBuckets InsertOne( + SpellBuckets spell_buckets_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(spell_buckets_entry.key) + "'"); + insert_values.push_back("'" + EscapeString(spell_buckets_entry.value) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + spell_buckets_entry.id = results.LastInsertedID(); + return spell_buckets_entry; + } + + spell_buckets_entry = NewEntity(); + + return spell_buckets_entry; + } + + static int InsertMany( + std::vector spell_buckets_entries + ) + { + std::vector insert_chunks; + + for (auto &spell_buckets_entry: spell_buckets_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(spell_buckets_entry.key) + "'"); + insert_values.push_back("'" + EscapeString(spell_buckets_entry.value) + "'"); + + 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) { + SpellBuckets entry{}; + + entry.spellid = atoi(row[0]); + entry.key = row[1] ? row[1] : ""; + entry.value = row[2] ? row[2] : ""; + + 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) { + SpellBuckets entry{}; + + entry.spellid = atoi(row[0]); + entry.key = row[1] ? 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_SPELL_BUCKETS_REPOSITORY_H diff --git a/common/repositories/base/base_spell_globals_repository.h b/common/repositories/base/base_spell_globals_repository.h new file mode 100644 index 000000000..8350ee3dc --- /dev/null +++ b/common/repositories/base/base_spell_globals_repository.h @@ -0,0 +1,324 @@ +/** + * 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 on Apr 5, 2020 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_SPELL_GLOBALS_REPOSITORY_H +#define EQEMU_BASE_SPELL_GLOBALS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseSpellGlobalsRepository { +public: + struct SpellGlobals { + int spellid; + std::string spell_name; + std::string qglobal; + std::string value; + }; + + static std::string PrimaryKey() + { + return std::string("spellid"); + } + + static std::vector Columns() + { + return { + "spellid", + "spell_name", + "qglobal", + "value", + }; + } + + 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("spell_globals"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static SpellGlobals NewEntity() + { + SpellGlobals entry{}; + + entry.spellid = 0; + entry.spell_name = ""; + entry.qglobal = ""; + entry.value = ""; + + return entry; + } + + static SpellGlobals GetSpellGlobalsEntry( + const std::vector &spell_globalss, + int spell_globals_id + ) + { + for (auto &spell_globals : spell_globalss) { + if (spell_globals.spellid == spell_globals_id) { + return spell_globals; + } + } + + return NewEntity(); + } + + static SpellGlobals FindOne( + int spell_globals_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + spell_globals_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + SpellGlobals entry{}; + + entry.spellid = atoi(row[0]); + entry.spell_name = row[1] ? row[1] : ""; + entry.qglobal = row[2] ? row[2] : ""; + entry.value = row[3] ? row[3] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int spell_globals_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + spell_globals_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + SpellGlobals spell_globals_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(spell_globals_entry.spell_name) + "'"); + update_values.push_back(columns[2] + " = '" + EscapeString(spell_globals_entry.qglobal) + "'"); + update_values.push_back(columns[3] + " = '" + EscapeString(spell_globals_entry.value) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + spell_globals_entry.spellid + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static SpellGlobals InsertOne( + SpellGlobals spell_globals_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(spell_globals_entry.spell_name) + "'"); + insert_values.push_back("'" + EscapeString(spell_globals_entry.qglobal) + "'"); + insert_values.push_back("'" + EscapeString(spell_globals_entry.value) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + spell_globals_entry.id = results.LastInsertedID(); + return spell_globals_entry; + } + + spell_globals_entry = NewEntity(); + + return spell_globals_entry; + } + + static int InsertMany( + std::vector spell_globals_entries + ) + { + std::vector insert_chunks; + + for (auto &spell_globals_entry: spell_globals_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(spell_globals_entry.spell_name) + "'"); + insert_values.push_back("'" + EscapeString(spell_globals_entry.qglobal) + "'"); + insert_values.push_back("'" + EscapeString(spell_globals_entry.value) + "'"); + + 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) { + SpellGlobals entry{}; + + entry.spellid = atoi(row[0]); + entry.spell_name = row[1] ? row[1] : ""; + entry.qglobal = row[2] ? row[2] : ""; + entry.value = row[3] ? 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) { + SpellGlobals entry{}; + + entry.spellid = atoi(row[0]); + entry.spell_name = row[1] ? row[1] : ""; + entry.qglobal = row[2] ? row[2] : ""; + entry.value = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_SPELL_GLOBALS_REPOSITORY_H diff --git a/common/repositories/base/base_spells_new_repository.h b/common/repositories/base/base_spells_new_repository.h new file mode 100644 index 000000000..4fbdcea1f --- /dev/null +++ b/common/repositories/base/base_spells_new_repository.h @@ -0,0 +1,2421 @@ +/** + * 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 on Apr 5, 2020 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_SPELLS_NEW_REPOSITORY_H +#define EQEMU_BASE_SPELLS_NEW_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseSpellsNewRepository { +public: + struct SpellsNew { + int id; + std::string name; + std::string player_1; + std::string teleport_zone; + std::string you_cast; + std::string other_casts; + std::string cast_on_you; + std::string cast_on_other; + std::string spell_fades; + int range; + int aoerange; + int pushback; + int pushup; + int cast_time; + int recovery_time; + int recast_time; + int buffdurationformula; + int buffduration; + int AEDuration; + int mana; + int effect_base_value1; + int effect_base_value2; + int effect_base_value3; + int effect_base_value4; + int effect_base_value5; + int effect_base_value6; + int effect_base_value7; + int effect_base_value8; + int effect_base_value9; + int effect_base_value10; + int effect_base_value11; + int effect_base_value12; + int effect_limit_value1; + int effect_limit_value2; + int effect_limit_value3; + int effect_limit_value4; + int effect_limit_value5; + int effect_limit_value6; + int effect_limit_value7; + int effect_limit_value8; + int effect_limit_value9; + int effect_limit_value10; + int effect_limit_value11; + int effect_limit_value12; + int max1; + int max2; + int max3; + int max4; + int max5; + int max6; + int max7; + int max8; + int max9; + int max10; + int max11; + int max12; + int icon; + int memicon; + int components1; + int components2; + int components3; + int components4; + int component_counts1; + int component_counts2; + int component_counts3; + int component_counts4; + int NoexpendReagent1; + int NoexpendReagent2; + int NoexpendReagent3; + int NoexpendReagent4; + int formula1; + int formula2; + int formula3; + int formula4; + int formula5; + int formula6; + int formula7; + int formula8; + int formula9; + int formula10; + int formula11; + int formula12; + int LightType; + int goodEffect; + int Activated; + int resisttype; + int effectid1; + int effectid2; + int effectid3; + int effectid4; + int effectid5; + int effectid6; + int effectid7; + int effectid8; + int effectid9; + int effectid10; + int effectid11; + int effectid12; + int targettype; + int basediff; + int skill; + int zonetype; + int EnvironmentType; + int TimeOfDay; + int classes1; + int classes2; + int classes3; + int classes4; + int classes5; + int classes6; + int classes7; + int classes8; + int classes9; + int classes10; + int classes11; + int classes12; + int classes13; + int classes14; + int classes15; + int classes16; + int CastingAnim; + int TargetAnim; + int TravelType; + int SpellAffectIndex; + int disallow_sit; + int deities0; + int deities1; + int deities2; + int deities3; + int deities4; + int deities5; + int deities6; + int deities7; + int deities8; + int deities9; + int deities10; + int deities11; + int deities12; + int deities13; + int deities14; + int deities15; + int deities16; + int field142; + int field143; + int new_icon; + int spellanim; + int uninterruptable; + int ResistDiff; + int dot_stacking_exempt; + int deleteable; + int RecourseLink; + int no_partial_resist; + int field152; + int field153; + int short_buff_box; + int descnum; + int typedescnum; + int effectdescnum; + int effectdescnum2; + int npc_no_los; + int field160; + int reflectable; + int bonushate; + int field163; + int field164; + int ldon_trap; + int EndurCost; + int EndurTimerIndex; + int IsDiscipline; + int field169; + int field170; + int field171; + int field172; + int HateAdded; + int EndurUpkeep; + int numhitstype; + int numhits; + int pvpresistbase; + int pvpresistcalc; + int pvpresistcap; + int spell_category; + int field181; + int field182; + int pcnpc_only_flag; + int cast_not_standing; + int can_mgb; + int nodispell; + int npc_category; + int npc_usefulness; + int MinResist; + int MaxResist; + int viral_targets; + int viral_timer; + int nimbuseffect; + int ConeStartAngle; + int ConeStopAngle; + int sneaking; + int not_extendable; + int field198; + int field199; + int suspendable; + int viral_range; + int songcap; + int field203; + int field204; + int no_block; + int field206; + int spellgroup; + int rank; + int field209; + int field210; + int CastRestriction; + int allowrest; + int InCombat; + int OutofCombat; + int field215; + int field216; + int field217; + int aemaxtargets; + int maxtargets; + int field220; + int field221; + int field222; + int field223; + int persistdeath; + int field225; + int field226; + float min_dist; + float min_dist_mod; + float max_dist; + float max_dist_mod; + int min_range; + int field232; + int field233; + int field234; + int field235; + int field236; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "name", + "player_1", + "teleport_zone", + "you_cast", + "other_casts", + "cast_on_you", + "cast_on_other", + "spell_fades", + "range", + "aoerange", + "pushback", + "pushup", + "cast_time", + "recovery_time", + "recast_time", + "buffdurationformula", + "buffduration", + "AEDuration", + "mana", + "effect_base_value1", + "effect_base_value2", + "effect_base_value3", + "effect_base_value4", + "effect_base_value5", + "effect_base_value6", + "effect_base_value7", + "effect_base_value8", + "effect_base_value9", + "effect_base_value10", + "effect_base_value11", + "effect_base_value12", + "effect_limit_value1", + "effect_limit_value2", + "effect_limit_value3", + "effect_limit_value4", + "effect_limit_value5", + "effect_limit_value6", + "effect_limit_value7", + "effect_limit_value8", + "effect_limit_value9", + "effect_limit_value10", + "effect_limit_value11", + "effect_limit_value12", + "max1", + "max2", + "max3", + "max4", + "max5", + "max6", + "max7", + "max8", + "max9", + "max10", + "max11", + "max12", + "icon", + "memicon", + "components1", + "components2", + "components3", + "components4", + "component_counts1", + "component_counts2", + "component_counts3", + "component_counts4", + "NoexpendReagent1", + "NoexpendReagent2", + "NoexpendReagent3", + "NoexpendReagent4", + "formula1", + "formula2", + "formula3", + "formula4", + "formula5", + "formula6", + "formula7", + "formula8", + "formula9", + "formula10", + "formula11", + "formula12", + "LightType", + "goodEffect", + "Activated", + "resisttype", + "effectid1", + "effectid2", + "effectid3", + "effectid4", + "effectid5", + "effectid6", + "effectid7", + "effectid8", + "effectid9", + "effectid10", + "effectid11", + "effectid12", + "targettype", + "basediff", + "skill", + "zonetype", + "EnvironmentType", + "TimeOfDay", + "classes1", + "classes2", + "classes3", + "classes4", + "classes5", + "classes6", + "classes7", + "classes8", + "classes9", + "classes10", + "classes11", + "classes12", + "classes13", + "classes14", + "classes15", + "classes16", + "CastingAnim", + "TargetAnim", + "TravelType", + "SpellAffectIndex", + "disallow_sit", + "deities0", + "deities1", + "deities2", + "deities3", + "deities4", + "deities5", + "deities6", + "deities7", + "deities8", + "deities9", + "deities10", + "deities11", + "deities12", + "deities13", + "deities14", + "deities15", + "deities16", + "field142", + "field143", + "new_icon", + "spellanim", + "uninterruptable", + "ResistDiff", + "dot_stacking_exempt", + "deleteable", + "RecourseLink", + "no_partial_resist", + "field152", + "field153", + "short_buff_box", + "descnum", + "typedescnum", + "effectdescnum", + "effectdescnum2", + "npc_no_los", + "field160", + "reflectable", + "bonushate", + "field163", + "field164", + "ldon_trap", + "EndurCost", + "EndurTimerIndex", + "IsDiscipline", + "field169", + "field170", + "field171", + "field172", + "HateAdded", + "EndurUpkeep", + "numhitstype", + "numhits", + "pvpresistbase", + "pvpresistcalc", + "pvpresistcap", + "spell_category", + "field181", + "field182", + "pcnpc_only_flag", + "cast_not_standing", + "can_mgb", + "nodispell", + "npc_category", + "npc_usefulness", + "MinResist", + "MaxResist", + "viral_targets", + "viral_timer", + "nimbuseffect", + "ConeStartAngle", + "ConeStopAngle", + "sneaking", + "not_extendable", + "field198", + "field199", + "suspendable", + "viral_range", + "songcap", + "field203", + "field204", + "no_block", + "field206", + "spellgroup", + "rank", + "field209", + "field210", + "CastRestriction", + "allowrest", + "InCombat", + "OutofCombat", + "field215", + "field216", + "field217", + "aemaxtargets", + "maxtargets", + "field220", + "field221", + "field222", + "field223", + "persistdeath", + "field225", + "field226", + "min_dist", + "min_dist_mod", + "max_dist", + "max_dist_mod", + "min_range", + "field232", + "field233", + "field234", + "field235", + "field236", + }; + } + + 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("spells_new"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static SpellsNew NewEntity() + { + SpellsNew entry{}; + + entry.id = 0; + entry.name = ""; + entry.player_1 = "BLUE_TRAIL"; + entry.teleport_zone = ""; + entry.you_cast = ""; + entry.other_casts = ""; + entry.cast_on_you = ""; + entry.cast_on_other = ""; + entry.spell_fades = ""; + entry.range = 100; + entry.aoerange = 0; + entry.pushback = 0; + entry.pushup = 0; + entry.cast_time = 0; + entry.recovery_time = 0; + entry.recast_time = 0; + entry.buffdurationformula = 7; + entry.buffduration = 65; + entry.AEDuration = 0; + entry.mana = 0; + entry.effect_base_value1 = 100; + entry.effect_base_value2 = 0; + entry.effect_base_value3 = 0; + entry.effect_base_value4 = 0; + entry.effect_base_value5 = 0; + entry.effect_base_value6 = 0; + entry.effect_base_value7 = 0; + entry.effect_base_value8 = 0; + entry.effect_base_value9 = 0; + entry.effect_base_value10 = 0; + entry.effect_base_value11 = 0; + entry.effect_base_value12 = 0; + entry.effect_limit_value1 = 0; + entry.effect_limit_value2 = 0; + entry.effect_limit_value3 = 0; + entry.effect_limit_value4 = 0; + entry.effect_limit_value5 = 0; + entry.effect_limit_value6 = 0; + entry.effect_limit_value7 = 0; + entry.effect_limit_value8 = 0; + entry.effect_limit_value9 = 0; + entry.effect_limit_value10 = 0; + entry.effect_limit_value11 = 0; + entry.effect_limit_value12 = 0; + entry.max1 = 0; + entry.max2 = 0; + entry.max3 = 0; + entry.max4 = 0; + entry.max5 = 0; + entry.max6 = 0; + entry.max7 = 0; + entry.max8 = 0; + entry.max9 = 0; + entry.max10 = 0; + entry.max11 = 0; + entry.max12 = 0; + entry.icon = 0; + entry.memicon = 0; + entry.components1 = -1; + entry.components2 = -1; + entry.components3 = -1; + entry.components4 = -1; + entry.component_counts1 = 1; + entry.component_counts2 = 1; + entry.component_counts3 = 1; + entry.component_counts4 = 1; + entry.NoexpendReagent1 = -1; + entry.NoexpendReagent2 = -1; + entry.NoexpendReagent3 = -1; + entry.NoexpendReagent4 = -1; + entry.formula1 = 100; + entry.formula2 = 100; + entry.formula3 = 100; + entry.formula4 = 100; + entry.formula5 = 100; + entry.formula6 = 100; + entry.formula7 = 100; + entry.formula8 = 100; + entry.formula9 = 100; + entry.formula10 = 100; + entry.formula11 = 100; + entry.formula12 = 100; + entry.LightType = 0; + entry.goodEffect = 0; + entry.Activated = 0; + entry.resisttype = 0; + entry.effectid1 = 254; + entry.effectid2 = 254; + entry.effectid3 = 254; + entry.effectid4 = 254; + entry.effectid5 = 254; + entry.effectid6 = 254; + entry.effectid7 = 254; + entry.effectid8 = 254; + entry.effectid9 = 254; + entry.effectid10 = 254; + entry.effectid11 = 254; + entry.effectid12 = 254; + entry.targettype = 2; + entry.basediff = 0; + entry.skill = 98; + entry.zonetype = -1; + entry.EnvironmentType = 0; + entry.TimeOfDay = 0; + entry.classes1 = 255; + entry.classes2 = 255; + entry.classes3 = 255; + entry.classes4 = 255; + entry.classes5 = 255; + entry.classes6 = 255; + entry.classes7 = 255; + entry.classes8 = 255; + entry.classes9 = 255; + entry.classes10 = 255; + entry.classes11 = 255; + entry.classes12 = 255; + entry.classes13 = 255; + entry.classes14 = 255; + entry.classes15 = 255; + entry.classes16 = 255; + entry.CastingAnim = 44; + entry.TargetAnim = 13; + entry.TravelType = 0; + entry.SpellAffectIndex = -1; + entry.disallow_sit = 0; + entry.deities0 = 0; + entry.deities1 = 0; + entry.deities2 = 0; + entry.deities3 = 0; + entry.deities4 = 0; + entry.deities5 = 0; + entry.deities6 = 0; + entry.deities7 = 0; + entry.deities8 = 0; + entry.deities9 = 0; + entry.deities10 = 0; + entry.deities11 = 0; + entry.deities12 = 0; + entry.deities13 = 0; + entry.deities14 = 0; + entry.deities15 = 0; + entry.deities16 = 0; + entry.field142 = 100; + entry.field143 = 0; + entry.new_icon = 161; + entry.spellanim = 0; + entry.uninterruptable = 0; + entry.ResistDiff = -150; + entry.dot_stacking_exempt = 0; + entry.deleteable = 0; + entry.RecourseLink = 0; + entry.no_partial_resist = 0; + entry.field152 = 0; + entry.field153 = 0; + entry.short_buff_box = -1; + entry.descnum = 0; + entry.typedescnum = 0; + entry.effectdescnum = 0; + entry.effectdescnum2 = 0; + entry.npc_no_los = 0; + entry.field160 = 0; + entry.reflectable = 0; + entry.bonushate = 0; + entry.field163 = 100; + entry.field164 = -150; + entry.ldon_trap = 0; + entry.EndurCost = 0; + entry.EndurTimerIndex = 0; + entry.IsDiscipline = 0; + entry.field169 = 0; + entry.field170 = 0; + entry.field171 = 0; + entry.field172 = 0; + entry.HateAdded = 0; + entry.EndurUpkeep = 0; + entry.numhitstype = 0; + entry.numhits = 0; + entry.pvpresistbase = -150; + entry.pvpresistcalc = 100; + entry.pvpresistcap = -150; + entry.spell_category = -99; + entry.field181 = 7; + entry.field182 = 65; + entry.pcnpc_only_flag = 0; + entry.cast_not_standing = 0; + entry.can_mgb = 0; + entry.nodispell = -1; + entry.npc_category = 0; + entry.npc_usefulness = 0; + entry.MinResist = 0; + entry.MaxResist = 0; + entry.viral_targets = 0; + entry.viral_timer = 0; + entry.nimbuseffect = 0; + entry.ConeStartAngle = 0; + entry.ConeStopAngle = 0; + entry.sneaking = 0; + entry.not_extendable = 0; + entry.field198 = 0; + entry.field199 = 1; + entry.suspendable = 0; + entry.viral_range = 0; + entry.songcap = 0; + entry.field203 = 0; + entry.field204 = 0; + entry.no_block = 0; + entry.field206 = -1; + entry.spellgroup = 0; + entry.rank = 0; + entry.field209 = 0; + entry.field210 = 1; + entry.CastRestriction = 0; + entry.allowrest = 0; + entry.InCombat = 0; + entry.OutofCombat = 0; + entry.field215 = 0; + entry.field216 = 0; + entry.field217 = 0; + entry.aemaxtargets = 0; + entry.maxtargets = 0; + entry.field220 = 0; + entry.field221 = 0; + entry.field222 = 0; + entry.field223 = 0; + entry.persistdeath = 0; + entry.field225 = 0; + entry.field226 = 0; + entry.min_dist = 0; + entry.min_dist_mod = 0; + entry.max_dist = 0; + entry.max_dist_mod = 0; + entry.min_range = 0; + entry.field232 = 0; + entry.field233 = 0; + entry.field234 = 0; + entry.field235 = 0; + entry.field236 = 0; + + return entry; + } + + static SpellsNew GetSpellsNewEntry( + const std::vector &spells_news, + int spells_new_id + ) + { + for (auto &spells_new : spells_news) { + if (spells_new.id == spells_new_id) { + return spells_new; + } + } + + return NewEntity(); + } + + static SpellsNew FindOne( + int spells_new_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + spells_new_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + SpellsNew entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.player_1 = row[2] ? row[2] : ""; + entry.teleport_zone = row[3] ? row[3] : ""; + entry.you_cast = row[4] ? row[4] : ""; + entry.other_casts = row[5] ? row[5] : ""; + entry.cast_on_you = row[6] ? row[6] : ""; + entry.cast_on_other = row[7] ? row[7] : ""; + entry.spell_fades = row[8] ? row[8] : ""; + entry.range = atoi(row[9]); + entry.aoerange = atoi(row[10]); + entry.pushback = atoi(row[11]); + entry.pushup = atoi(row[12]); + entry.cast_time = atoi(row[13]); + entry.recovery_time = atoi(row[14]); + entry.recast_time = atoi(row[15]); + entry.buffdurationformula = atoi(row[16]); + entry.buffduration = atoi(row[17]); + entry.AEDuration = atoi(row[18]); + entry.mana = atoi(row[19]); + entry.effect_base_value1 = atoi(row[20]); + entry.effect_base_value2 = atoi(row[21]); + entry.effect_base_value3 = atoi(row[22]); + entry.effect_base_value4 = atoi(row[23]); + entry.effect_base_value5 = atoi(row[24]); + entry.effect_base_value6 = atoi(row[25]); + entry.effect_base_value7 = atoi(row[26]); + entry.effect_base_value8 = atoi(row[27]); + entry.effect_base_value9 = atoi(row[28]); + entry.effect_base_value10 = atoi(row[29]); + entry.effect_base_value11 = atoi(row[30]); + entry.effect_base_value12 = atoi(row[31]); + entry.effect_limit_value1 = atoi(row[32]); + entry.effect_limit_value2 = atoi(row[33]); + entry.effect_limit_value3 = atoi(row[34]); + entry.effect_limit_value4 = atoi(row[35]); + entry.effect_limit_value5 = atoi(row[36]); + entry.effect_limit_value6 = atoi(row[37]); + entry.effect_limit_value7 = atoi(row[38]); + entry.effect_limit_value8 = atoi(row[39]); + entry.effect_limit_value9 = atoi(row[40]); + entry.effect_limit_value10 = atoi(row[41]); + entry.effect_limit_value11 = atoi(row[42]); + entry.effect_limit_value12 = atoi(row[43]); + entry.max1 = atoi(row[44]); + entry.max2 = atoi(row[45]); + entry.max3 = atoi(row[46]); + entry.max4 = atoi(row[47]); + entry.max5 = atoi(row[48]); + entry.max6 = atoi(row[49]); + entry.max7 = atoi(row[50]); + entry.max8 = atoi(row[51]); + entry.max9 = atoi(row[52]); + entry.max10 = atoi(row[53]); + entry.max11 = atoi(row[54]); + entry.max12 = atoi(row[55]); + entry.icon = atoi(row[56]); + entry.memicon = atoi(row[57]); + entry.components1 = atoi(row[58]); + entry.components2 = atoi(row[59]); + entry.components3 = atoi(row[60]); + entry.components4 = atoi(row[61]); + entry.component_counts1 = atoi(row[62]); + entry.component_counts2 = atoi(row[63]); + entry.component_counts3 = atoi(row[64]); + entry.component_counts4 = atoi(row[65]); + entry.NoexpendReagent1 = atoi(row[66]); + entry.NoexpendReagent2 = atoi(row[67]); + entry.NoexpendReagent3 = atoi(row[68]); + entry.NoexpendReagent4 = atoi(row[69]); + entry.formula1 = atoi(row[70]); + entry.formula2 = atoi(row[71]); + entry.formula3 = atoi(row[72]); + entry.formula4 = atoi(row[73]); + entry.formula5 = atoi(row[74]); + entry.formula6 = atoi(row[75]); + entry.formula7 = atoi(row[76]); + entry.formula8 = atoi(row[77]); + entry.formula9 = atoi(row[78]); + entry.formula10 = atoi(row[79]); + entry.formula11 = atoi(row[80]); + entry.formula12 = atoi(row[81]); + entry.LightType = atoi(row[82]); + entry.goodEffect = atoi(row[83]); + entry.Activated = atoi(row[84]); + entry.resisttype = atoi(row[85]); + entry.effectid1 = atoi(row[86]); + entry.effectid2 = atoi(row[87]); + entry.effectid3 = atoi(row[88]); + entry.effectid4 = atoi(row[89]); + entry.effectid5 = atoi(row[90]); + entry.effectid6 = atoi(row[91]); + entry.effectid7 = atoi(row[92]); + entry.effectid8 = atoi(row[93]); + entry.effectid9 = atoi(row[94]); + entry.effectid10 = atoi(row[95]); + entry.effectid11 = atoi(row[96]); + entry.effectid12 = atoi(row[97]); + entry.targettype = atoi(row[98]); + entry.basediff = atoi(row[99]); + entry.skill = atoi(row[100]); + entry.zonetype = atoi(row[101]); + entry.EnvironmentType = atoi(row[102]); + entry.TimeOfDay = atoi(row[103]); + entry.classes1 = atoi(row[104]); + entry.classes2 = atoi(row[105]); + entry.classes3 = atoi(row[106]); + entry.classes4 = atoi(row[107]); + entry.classes5 = atoi(row[108]); + entry.classes6 = atoi(row[109]); + entry.classes7 = atoi(row[110]); + entry.classes8 = atoi(row[111]); + entry.classes9 = atoi(row[112]); + entry.classes10 = atoi(row[113]); + entry.classes11 = atoi(row[114]); + entry.classes12 = atoi(row[115]); + entry.classes13 = atoi(row[116]); + entry.classes14 = atoi(row[117]); + entry.classes15 = atoi(row[118]); + entry.classes16 = atoi(row[119]); + entry.CastingAnim = atoi(row[120]); + entry.TargetAnim = atoi(row[121]); + entry.TravelType = atoi(row[122]); + entry.SpellAffectIndex = atoi(row[123]); + entry.disallow_sit = atoi(row[124]); + entry.deities0 = atoi(row[125]); + entry.deities1 = atoi(row[126]); + entry.deities2 = atoi(row[127]); + entry.deities3 = atoi(row[128]); + entry.deities4 = atoi(row[129]); + entry.deities5 = atoi(row[130]); + entry.deities6 = atoi(row[131]); + entry.deities7 = atoi(row[132]); + entry.deities8 = atoi(row[133]); + entry.deities9 = atoi(row[134]); + entry.deities10 = atoi(row[135]); + entry.deities11 = atoi(row[136]); + entry.deities12 = atoi(row[137]); + entry.deities13 = atoi(row[138]); + entry.deities14 = atoi(row[139]); + entry.deities15 = atoi(row[140]); + entry.deities16 = atoi(row[141]); + entry.field142 = atoi(row[142]); + entry.field143 = atoi(row[143]); + entry.new_icon = atoi(row[144]); + entry.spellanim = atoi(row[145]); + entry.uninterruptable = atoi(row[146]); + entry.ResistDiff = atoi(row[147]); + entry.dot_stacking_exempt = atoi(row[148]); + entry.deleteable = atoi(row[149]); + entry.RecourseLink = atoi(row[150]); + entry.no_partial_resist = atoi(row[151]); + entry.field152 = atoi(row[152]); + entry.field153 = atoi(row[153]); + entry.short_buff_box = atoi(row[154]); + entry.descnum = atoi(row[155]); + entry.typedescnum = atoi(row[156]); + entry.effectdescnum = atoi(row[157]); + entry.effectdescnum2 = atoi(row[158]); + entry.npc_no_los = atoi(row[159]); + entry.field160 = atoi(row[160]); + entry.reflectable = atoi(row[161]); + entry.bonushate = atoi(row[162]); + entry.field163 = atoi(row[163]); + entry.field164 = atoi(row[164]); + entry.ldon_trap = atoi(row[165]); + entry.EndurCost = atoi(row[166]); + entry.EndurTimerIndex = atoi(row[167]); + entry.IsDiscipline = atoi(row[168]); + entry.field169 = atoi(row[169]); + entry.field170 = atoi(row[170]); + entry.field171 = atoi(row[171]); + entry.field172 = atoi(row[172]); + entry.HateAdded = atoi(row[173]); + entry.EndurUpkeep = atoi(row[174]); + entry.numhitstype = atoi(row[175]); + entry.numhits = atoi(row[176]); + entry.pvpresistbase = atoi(row[177]); + entry.pvpresistcalc = atoi(row[178]); + entry.pvpresistcap = atoi(row[179]); + entry.spell_category = atoi(row[180]); + entry.field181 = atoi(row[181]); + entry.field182 = atoi(row[182]); + entry.pcnpc_only_flag = atoi(row[183]); + entry.cast_not_standing = atoi(row[184]); + entry.can_mgb = atoi(row[185]); + entry.nodispell = atoi(row[186]); + entry.npc_category = atoi(row[187]); + entry.npc_usefulness = atoi(row[188]); + entry.MinResist = atoi(row[189]); + entry.MaxResist = atoi(row[190]); + entry.viral_targets = atoi(row[191]); + entry.viral_timer = atoi(row[192]); + entry.nimbuseffect = atoi(row[193]); + entry.ConeStartAngle = atoi(row[194]); + entry.ConeStopAngle = atoi(row[195]); + entry.sneaking = atoi(row[196]); + entry.not_extendable = atoi(row[197]); + entry.field198 = atoi(row[198]); + entry.field199 = atoi(row[199]); + entry.suspendable = atoi(row[200]); + entry.viral_range = atoi(row[201]); + entry.songcap = atoi(row[202]); + entry.field203 = atoi(row[203]); + entry.field204 = atoi(row[204]); + entry.no_block = atoi(row[205]); + entry.field206 = atoi(row[206]); + entry.spellgroup = atoi(row[207]); + entry.rank = atoi(row[208]); + entry.field209 = atoi(row[209]); + entry.field210 = atoi(row[210]); + entry.CastRestriction = atoi(row[211]); + entry.allowrest = atoi(row[212]); + entry.InCombat = atoi(row[213]); + entry.OutofCombat = atoi(row[214]); + entry.field215 = atoi(row[215]); + entry.field216 = atoi(row[216]); + entry.field217 = atoi(row[217]); + entry.aemaxtargets = atoi(row[218]); + entry.maxtargets = atoi(row[219]); + entry.field220 = atoi(row[220]); + entry.field221 = atoi(row[221]); + entry.field222 = atoi(row[222]); + entry.field223 = atoi(row[223]); + entry.persistdeath = atoi(row[224]); + entry.field225 = atoi(row[225]); + entry.field226 = atoi(row[226]); + entry.min_dist = atof(row[227]); + entry.min_dist_mod = atof(row[228]); + entry.max_dist = atof(row[229]); + entry.max_dist_mod = atof(row[230]); + entry.min_range = atoi(row[231]); + entry.field232 = atoi(row[232]); + entry.field233 = atoi(row[233]); + entry.field234 = atoi(row[234]); + entry.field235 = atoi(row[235]); + entry.field236 = atoi(row[236]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int spells_new_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + spells_new_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + SpellsNew spells_new_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(spells_new_entry.name) + "'"); + update_values.push_back(columns[2] + " = '" + EscapeString(spells_new_entry.player_1) + "'"); + update_values.push_back(columns[3] + " = '" + EscapeString(spells_new_entry.teleport_zone) + "'"); + update_values.push_back(columns[4] + " = '" + EscapeString(spells_new_entry.you_cast) + "'"); + update_values.push_back(columns[5] + " = '" + EscapeString(spells_new_entry.other_casts) + "'"); + update_values.push_back(columns[6] + " = '" + EscapeString(spells_new_entry.cast_on_you) + "'"); + update_values.push_back(columns[7] + " = '" + EscapeString(spells_new_entry.cast_on_other) + "'"); + update_values.push_back(columns[8] + " = '" + EscapeString(spells_new_entry.spell_fades) + "'"); + update_values.push_back(columns[9] + " = " + std::to_string(spells_new_entry.range)); + update_values.push_back(columns[10] + " = " + std::to_string(spells_new_entry.aoerange)); + update_values.push_back(columns[11] + " = " + std::to_string(spells_new_entry.pushback)); + update_values.push_back(columns[12] + " = " + std::to_string(spells_new_entry.pushup)); + update_values.push_back(columns[13] + " = " + std::to_string(spells_new_entry.cast_time)); + update_values.push_back(columns[14] + " = " + std::to_string(spells_new_entry.recovery_time)); + update_values.push_back(columns[15] + " = " + std::to_string(spells_new_entry.recast_time)); + update_values.push_back(columns[16] + " = " + std::to_string(spells_new_entry.buffdurationformula)); + update_values.push_back(columns[17] + " = " + std::to_string(spells_new_entry.buffduration)); + update_values.push_back(columns[18] + " = " + std::to_string(spells_new_entry.AEDuration)); + update_values.push_back(columns[19] + " = " + std::to_string(spells_new_entry.mana)); + update_values.push_back(columns[20] + " = " + std::to_string(spells_new_entry.effect_base_value1)); + update_values.push_back(columns[21] + " = " + std::to_string(spells_new_entry.effect_base_value2)); + update_values.push_back(columns[22] + " = " + std::to_string(spells_new_entry.effect_base_value3)); + update_values.push_back(columns[23] + " = " + std::to_string(spells_new_entry.effect_base_value4)); + update_values.push_back(columns[24] + " = " + std::to_string(spells_new_entry.effect_base_value5)); + update_values.push_back(columns[25] + " = " + std::to_string(spells_new_entry.effect_base_value6)); + update_values.push_back(columns[26] + " = " + std::to_string(spells_new_entry.effect_base_value7)); + update_values.push_back(columns[27] + " = " + std::to_string(spells_new_entry.effect_base_value8)); + update_values.push_back(columns[28] + " = " + std::to_string(spells_new_entry.effect_base_value9)); + update_values.push_back(columns[29] + " = " + std::to_string(spells_new_entry.effect_base_value10)); + update_values.push_back(columns[30] + " = " + std::to_string(spells_new_entry.effect_base_value11)); + update_values.push_back(columns[31] + " = " + std::to_string(spells_new_entry.effect_base_value12)); + update_values.push_back(columns[32] + " = " + std::to_string(spells_new_entry.effect_limit_value1)); + update_values.push_back(columns[33] + " = " + std::to_string(spells_new_entry.effect_limit_value2)); + update_values.push_back(columns[34] + " = " + std::to_string(spells_new_entry.effect_limit_value3)); + update_values.push_back(columns[35] + " = " + std::to_string(spells_new_entry.effect_limit_value4)); + update_values.push_back(columns[36] + " = " + std::to_string(spells_new_entry.effect_limit_value5)); + update_values.push_back(columns[37] + " = " + std::to_string(spells_new_entry.effect_limit_value6)); + update_values.push_back(columns[38] + " = " + std::to_string(spells_new_entry.effect_limit_value7)); + update_values.push_back(columns[39] + " = " + std::to_string(spells_new_entry.effect_limit_value8)); + update_values.push_back(columns[40] + " = " + std::to_string(spells_new_entry.effect_limit_value9)); + update_values.push_back(columns[41] + " = " + std::to_string(spells_new_entry.effect_limit_value10)); + update_values.push_back(columns[42] + " = " + std::to_string(spells_new_entry.effect_limit_value11)); + update_values.push_back(columns[43] + " = " + std::to_string(spells_new_entry.effect_limit_value12)); + update_values.push_back(columns[44] + " = " + std::to_string(spells_new_entry.max1)); + update_values.push_back(columns[45] + " = " + std::to_string(spells_new_entry.max2)); + update_values.push_back(columns[46] + " = " + std::to_string(spells_new_entry.max3)); + update_values.push_back(columns[47] + " = " + std::to_string(spells_new_entry.max4)); + update_values.push_back(columns[48] + " = " + std::to_string(spells_new_entry.max5)); + update_values.push_back(columns[49] + " = " + std::to_string(spells_new_entry.max6)); + update_values.push_back(columns[50] + " = " + std::to_string(spells_new_entry.max7)); + update_values.push_back(columns[51] + " = " + std::to_string(spells_new_entry.max8)); + update_values.push_back(columns[52] + " = " + std::to_string(spells_new_entry.max9)); + update_values.push_back(columns[53] + " = " + std::to_string(spells_new_entry.max10)); + update_values.push_back(columns[54] + " = " + std::to_string(spells_new_entry.max11)); + update_values.push_back(columns[55] + " = " + std::to_string(spells_new_entry.max12)); + update_values.push_back(columns[56] + " = " + std::to_string(spells_new_entry.icon)); + update_values.push_back(columns[57] + " = " + std::to_string(spells_new_entry.memicon)); + update_values.push_back(columns[58] + " = " + std::to_string(spells_new_entry.components1)); + update_values.push_back(columns[59] + " = " + std::to_string(spells_new_entry.components2)); + update_values.push_back(columns[60] + " = " + std::to_string(spells_new_entry.components3)); + update_values.push_back(columns[61] + " = " + std::to_string(spells_new_entry.components4)); + update_values.push_back(columns[62] + " = " + std::to_string(spells_new_entry.component_counts1)); + update_values.push_back(columns[63] + " = " + std::to_string(spells_new_entry.component_counts2)); + update_values.push_back(columns[64] + " = " + std::to_string(spells_new_entry.component_counts3)); + update_values.push_back(columns[65] + " = " + std::to_string(spells_new_entry.component_counts4)); + update_values.push_back(columns[66] + " = " + std::to_string(spells_new_entry.NoexpendReagent1)); + update_values.push_back(columns[67] + " = " + std::to_string(spells_new_entry.NoexpendReagent2)); + update_values.push_back(columns[68] + " = " + std::to_string(spells_new_entry.NoexpendReagent3)); + update_values.push_back(columns[69] + " = " + std::to_string(spells_new_entry.NoexpendReagent4)); + update_values.push_back(columns[70] + " = " + std::to_string(spells_new_entry.formula1)); + update_values.push_back(columns[71] + " = " + std::to_string(spells_new_entry.formula2)); + update_values.push_back(columns[72] + " = " + std::to_string(spells_new_entry.formula3)); + update_values.push_back(columns[73] + " = " + std::to_string(spells_new_entry.formula4)); + update_values.push_back(columns[74] + " = " + std::to_string(spells_new_entry.formula5)); + update_values.push_back(columns[75] + " = " + std::to_string(spells_new_entry.formula6)); + update_values.push_back(columns[76] + " = " + std::to_string(spells_new_entry.formula7)); + update_values.push_back(columns[77] + " = " + std::to_string(spells_new_entry.formula8)); + update_values.push_back(columns[78] + " = " + std::to_string(spells_new_entry.formula9)); + update_values.push_back(columns[79] + " = " + std::to_string(spells_new_entry.formula10)); + update_values.push_back(columns[80] + " = " + std::to_string(spells_new_entry.formula11)); + update_values.push_back(columns[81] + " = " + std::to_string(spells_new_entry.formula12)); + update_values.push_back(columns[82] + " = " + std::to_string(spells_new_entry.LightType)); + update_values.push_back(columns[83] + " = " + std::to_string(spells_new_entry.goodEffect)); + update_values.push_back(columns[84] + " = " + std::to_string(spells_new_entry.Activated)); + update_values.push_back(columns[85] + " = " + std::to_string(spells_new_entry.resisttype)); + update_values.push_back(columns[86] + " = " + std::to_string(spells_new_entry.effectid1)); + update_values.push_back(columns[87] + " = " + std::to_string(spells_new_entry.effectid2)); + update_values.push_back(columns[88] + " = " + std::to_string(spells_new_entry.effectid3)); + update_values.push_back(columns[89] + " = " + std::to_string(spells_new_entry.effectid4)); + update_values.push_back(columns[90] + " = " + std::to_string(spells_new_entry.effectid5)); + update_values.push_back(columns[91] + " = " + std::to_string(spells_new_entry.effectid6)); + update_values.push_back(columns[92] + " = " + std::to_string(spells_new_entry.effectid7)); + update_values.push_back(columns[93] + " = " + std::to_string(spells_new_entry.effectid8)); + update_values.push_back(columns[94] + " = " + std::to_string(spells_new_entry.effectid9)); + update_values.push_back(columns[95] + " = " + std::to_string(spells_new_entry.effectid10)); + update_values.push_back(columns[96] + " = " + std::to_string(spells_new_entry.effectid11)); + update_values.push_back(columns[97] + " = " + std::to_string(spells_new_entry.effectid12)); + update_values.push_back(columns[98] + " = " + std::to_string(spells_new_entry.targettype)); + update_values.push_back(columns[99] + " = " + std::to_string(spells_new_entry.basediff)); + update_values.push_back(columns[100] + " = " + std::to_string(spells_new_entry.skill)); + update_values.push_back(columns[101] + " = " + std::to_string(spells_new_entry.zonetype)); + update_values.push_back(columns[102] + " = " + std::to_string(spells_new_entry.EnvironmentType)); + update_values.push_back(columns[103] + " = " + std::to_string(spells_new_entry.TimeOfDay)); + update_values.push_back(columns[104] + " = " + std::to_string(spells_new_entry.classes1)); + update_values.push_back(columns[105] + " = " + std::to_string(spells_new_entry.classes2)); + update_values.push_back(columns[106] + " = " + std::to_string(spells_new_entry.classes3)); + update_values.push_back(columns[107] + " = " + std::to_string(spells_new_entry.classes4)); + update_values.push_back(columns[108] + " = " + std::to_string(spells_new_entry.classes5)); + update_values.push_back(columns[109] + " = " + std::to_string(spells_new_entry.classes6)); + update_values.push_back(columns[110] + " = " + std::to_string(spells_new_entry.classes7)); + update_values.push_back(columns[111] + " = " + std::to_string(spells_new_entry.classes8)); + update_values.push_back(columns[112] + " = " + std::to_string(spells_new_entry.classes9)); + update_values.push_back(columns[113] + " = " + std::to_string(spells_new_entry.classes10)); + update_values.push_back(columns[114] + " = " + std::to_string(spells_new_entry.classes11)); + update_values.push_back(columns[115] + " = " + std::to_string(spells_new_entry.classes12)); + update_values.push_back(columns[116] + " = " + std::to_string(spells_new_entry.classes13)); + update_values.push_back(columns[117] + " = " + std::to_string(spells_new_entry.classes14)); + update_values.push_back(columns[118] + " = " + std::to_string(spells_new_entry.classes15)); + update_values.push_back(columns[119] + " = " + std::to_string(spells_new_entry.classes16)); + update_values.push_back(columns[120] + " = " + std::to_string(spells_new_entry.CastingAnim)); + update_values.push_back(columns[121] + " = " + std::to_string(spells_new_entry.TargetAnim)); + update_values.push_back(columns[122] + " = " + std::to_string(spells_new_entry.TravelType)); + update_values.push_back(columns[123] + " = " + std::to_string(spells_new_entry.SpellAffectIndex)); + update_values.push_back(columns[124] + " = " + std::to_string(spells_new_entry.disallow_sit)); + update_values.push_back(columns[125] + " = " + std::to_string(spells_new_entry.deities0)); + update_values.push_back(columns[126] + " = " + std::to_string(spells_new_entry.deities1)); + update_values.push_back(columns[127] + " = " + std::to_string(spells_new_entry.deities2)); + update_values.push_back(columns[128] + " = " + std::to_string(spells_new_entry.deities3)); + update_values.push_back(columns[129] + " = " + std::to_string(spells_new_entry.deities4)); + update_values.push_back(columns[130] + " = " + std::to_string(spells_new_entry.deities5)); + update_values.push_back(columns[131] + " = " + std::to_string(spells_new_entry.deities6)); + update_values.push_back(columns[132] + " = " + std::to_string(spells_new_entry.deities7)); + update_values.push_back(columns[133] + " = " + std::to_string(spells_new_entry.deities8)); + update_values.push_back(columns[134] + " = " + std::to_string(spells_new_entry.deities9)); + update_values.push_back(columns[135] + " = " + std::to_string(spells_new_entry.deities10)); + update_values.push_back(columns[136] + " = " + std::to_string(spells_new_entry.deities11)); + update_values.push_back(columns[137] + " = " + std::to_string(spells_new_entry.deities12)); + update_values.push_back(columns[138] + " = " + std::to_string(spells_new_entry.deities13)); + update_values.push_back(columns[139] + " = " + std::to_string(spells_new_entry.deities14)); + update_values.push_back(columns[140] + " = " + std::to_string(spells_new_entry.deities15)); + update_values.push_back(columns[141] + " = " + std::to_string(spells_new_entry.deities16)); + update_values.push_back(columns[142] + " = " + std::to_string(spells_new_entry.field142)); + update_values.push_back(columns[143] + " = " + std::to_string(spells_new_entry.field143)); + update_values.push_back(columns[144] + " = " + std::to_string(spells_new_entry.new_icon)); + update_values.push_back(columns[145] + " = " + std::to_string(spells_new_entry.spellanim)); + update_values.push_back(columns[146] + " = " + std::to_string(spells_new_entry.uninterruptable)); + update_values.push_back(columns[147] + " = " + std::to_string(spells_new_entry.ResistDiff)); + update_values.push_back(columns[148] + " = " + std::to_string(spells_new_entry.dot_stacking_exempt)); + update_values.push_back(columns[149] + " = " + std::to_string(spells_new_entry.deleteable)); + update_values.push_back(columns[150] + " = " + std::to_string(spells_new_entry.RecourseLink)); + update_values.push_back(columns[151] + " = " + std::to_string(spells_new_entry.no_partial_resist)); + update_values.push_back(columns[152] + " = " + std::to_string(spells_new_entry.field152)); + update_values.push_back(columns[153] + " = " + std::to_string(spells_new_entry.field153)); + update_values.push_back(columns[154] + " = " + std::to_string(spells_new_entry.short_buff_box)); + update_values.push_back(columns[155] + " = " + std::to_string(spells_new_entry.descnum)); + update_values.push_back(columns[156] + " = " + std::to_string(spells_new_entry.typedescnum)); + update_values.push_back(columns[157] + " = " + std::to_string(spells_new_entry.effectdescnum)); + update_values.push_back(columns[158] + " = " + std::to_string(spells_new_entry.effectdescnum2)); + update_values.push_back(columns[159] + " = " + std::to_string(spells_new_entry.npc_no_los)); + update_values.push_back(columns[160] + " = " + std::to_string(spells_new_entry.field160)); + update_values.push_back(columns[161] + " = " + std::to_string(spells_new_entry.reflectable)); + update_values.push_back(columns[162] + " = " + std::to_string(spells_new_entry.bonushate)); + update_values.push_back(columns[163] + " = " + std::to_string(spells_new_entry.field163)); + update_values.push_back(columns[164] + " = " + std::to_string(spells_new_entry.field164)); + update_values.push_back(columns[165] + " = " + std::to_string(spells_new_entry.ldon_trap)); + update_values.push_back(columns[166] + " = " + std::to_string(spells_new_entry.EndurCost)); + update_values.push_back(columns[167] + " = " + std::to_string(spells_new_entry.EndurTimerIndex)); + update_values.push_back(columns[168] + " = " + std::to_string(spells_new_entry.IsDiscipline)); + update_values.push_back(columns[169] + " = " + std::to_string(spells_new_entry.field169)); + update_values.push_back(columns[170] + " = " + std::to_string(spells_new_entry.field170)); + update_values.push_back(columns[171] + " = " + std::to_string(spells_new_entry.field171)); + update_values.push_back(columns[172] + " = " + std::to_string(spells_new_entry.field172)); + update_values.push_back(columns[173] + " = " + std::to_string(spells_new_entry.HateAdded)); + update_values.push_back(columns[174] + " = " + std::to_string(spells_new_entry.EndurUpkeep)); + update_values.push_back(columns[175] + " = " + std::to_string(spells_new_entry.numhitstype)); + update_values.push_back(columns[176] + " = " + std::to_string(spells_new_entry.numhits)); + update_values.push_back(columns[177] + " = " + std::to_string(spells_new_entry.pvpresistbase)); + update_values.push_back(columns[178] + " = " + std::to_string(spells_new_entry.pvpresistcalc)); + update_values.push_back(columns[179] + " = " + std::to_string(spells_new_entry.pvpresistcap)); + update_values.push_back(columns[180] + " = " + std::to_string(spells_new_entry.spell_category)); + update_values.push_back(columns[181] + " = " + std::to_string(spells_new_entry.field181)); + update_values.push_back(columns[182] + " = " + std::to_string(spells_new_entry.field182)); + update_values.push_back(columns[183] + " = " + std::to_string(spells_new_entry.pcnpc_only_flag)); + update_values.push_back(columns[184] + " = " + std::to_string(spells_new_entry.cast_not_standing)); + update_values.push_back(columns[185] + " = " + std::to_string(spells_new_entry.can_mgb)); + update_values.push_back(columns[186] + " = " + std::to_string(spells_new_entry.nodispell)); + update_values.push_back(columns[187] + " = " + std::to_string(spells_new_entry.npc_category)); + update_values.push_back(columns[188] + " = " + std::to_string(spells_new_entry.npc_usefulness)); + update_values.push_back(columns[189] + " = " + std::to_string(spells_new_entry.MinResist)); + update_values.push_back(columns[190] + " = " + std::to_string(spells_new_entry.MaxResist)); + update_values.push_back(columns[191] + " = " + std::to_string(spells_new_entry.viral_targets)); + update_values.push_back(columns[192] + " = " + std::to_string(spells_new_entry.viral_timer)); + update_values.push_back(columns[193] + " = " + std::to_string(spells_new_entry.nimbuseffect)); + update_values.push_back(columns[194] + " = " + std::to_string(spells_new_entry.ConeStartAngle)); + update_values.push_back(columns[195] + " = " + std::to_string(spells_new_entry.ConeStopAngle)); + update_values.push_back(columns[196] + " = " + std::to_string(spells_new_entry.sneaking)); + update_values.push_back(columns[197] + " = " + std::to_string(spells_new_entry.not_extendable)); + update_values.push_back(columns[198] + " = " + std::to_string(spells_new_entry.field198)); + update_values.push_back(columns[199] + " = " + std::to_string(spells_new_entry.field199)); + update_values.push_back(columns[200] + " = " + std::to_string(spells_new_entry.suspendable)); + update_values.push_back(columns[201] + " = " + std::to_string(spells_new_entry.viral_range)); + update_values.push_back(columns[202] + " = " + std::to_string(spells_new_entry.songcap)); + update_values.push_back(columns[203] + " = " + std::to_string(spells_new_entry.field203)); + update_values.push_back(columns[204] + " = " + std::to_string(spells_new_entry.field204)); + update_values.push_back(columns[205] + " = " + std::to_string(spells_new_entry.no_block)); + update_values.push_back(columns[206] + " = " + std::to_string(spells_new_entry.field206)); + update_values.push_back(columns[207] + " = " + std::to_string(spells_new_entry.spellgroup)); + update_values.push_back(columns[208] + " = " + std::to_string(spells_new_entry.rank)); + update_values.push_back(columns[209] + " = " + std::to_string(spells_new_entry.field209)); + update_values.push_back(columns[210] + " = " + std::to_string(spells_new_entry.field210)); + update_values.push_back(columns[211] + " = " + std::to_string(spells_new_entry.CastRestriction)); + update_values.push_back(columns[212] + " = " + std::to_string(spells_new_entry.allowrest)); + update_values.push_back(columns[213] + " = " + std::to_string(spells_new_entry.InCombat)); + update_values.push_back(columns[214] + " = " + std::to_string(spells_new_entry.OutofCombat)); + update_values.push_back(columns[215] + " = " + std::to_string(spells_new_entry.field215)); + update_values.push_back(columns[216] + " = " + std::to_string(spells_new_entry.field216)); + update_values.push_back(columns[217] + " = " + std::to_string(spells_new_entry.field217)); + update_values.push_back(columns[218] + " = " + std::to_string(spells_new_entry.aemaxtargets)); + update_values.push_back(columns[219] + " = " + std::to_string(spells_new_entry.maxtargets)); + update_values.push_back(columns[220] + " = " + std::to_string(spells_new_entry.field220)); + update_values.push_back(columns[221] + " = " + std::to_string(spells_new_entry.field221)); + update_values.push_back(columns[222] + " = " + std::to_string(spells_new_entry.field222)); + update_values.push_back(columns[223] + " = " + std::to_string(spells_new_entry.field223)); + update_values.push_back(columns[224] + " = " + std::to_string(spells_new_entry.persistdeath)); + update_values.push_back(columns[225] + " = " + std::to_string(spells_new_entry.field225)); + update_values.push_back(columns[226] + " = " + std::to_string(spells_new_entry.field226)); + update_values.push_back(columns[227] + " = " + std::to_string(spells_new_entry.min_dist)); + update_values.push_back(columns[228] + " = " + std::to_string(spells_new_entry.min_dist_mod)); + update_values.push_back(columns[229] + " = " + std::to_string(spells_new_entry.max_dist)); + update_values.push_back(columns[230] + " = " + std::to_string(spells_new_entry.max_dist_mod)); + update_values.push_back(columns[231] + " = " + std::to_string(spells_new_entry.min_range)); + update_values.push_back(columns[232] + " = " + std::to_string(spells_new_entry.field232)); + update_values.push_back(columns[233] + " = " + std::to_string(spells_new_entry.field233)); + update_values.push_back(columns[234] + " = " + std::to_string(spells_new_entry.field234)); + update_values.push_back(columns[235] + " = " + std::to_string(spells_new_entry.field235)); + update_values.push_back(columns[236] + " = " + std::to_string(spells_new_entry.field236)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + spells_new_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static SpellsNew InsertOne( + SpellsNew spells_new_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(spells_new_entry.name) + "'"); + insert_values.push_back("'" + EscapeString(spells_new_entry.player_1) + "'"); + insert_values.push_back("'" + EscapeString(spells_new_entry.teleport_zone) + "'"); + insert_values.push_back("'" + EscapeString(spells_new_entry.you_cast) + "'"); + insert_values.push_back("'" + EscapeString(spells_new_entry.other_casts) + "'"); + insert_values.push_back("'" + EscapeString(spells_new_entry.cast_on_you) + "'"); + insert_values.push_back("'" + EscapeString(spells_new_entry.cast_on_other) + "'"); + insert_values.push_back("'" + EscapeString(spells_new_entry.spell_fades) + "'"); + insert_values.push_back(std::to_string(spells_new_entry.range)); + insert_values.push_back(std::to_string(spells_new_entry.aoerange)); + insert_values.push_back(std::to_string(spells_new_entry.pushback)); + insert_values.push_back(std::to_string(spells_new_entry.pushup)); + insert_values.push_back(std::to_string(spells_new_entry.cast_time)); + insert_values.push_back(std::to_string(spells_new_entry.recovery_time)); + insert_values.push_back(std::to_string(spells_new_entry.recast_time)); + insert_values.push_back(std::to_string(spells_new_entry.buffdurationformula)); + insert_values.push_back(std::to_string(spells_new_entry.buffduration)); + insert_values.push_back(std::to_string(spells_new_entry.AEDuration)); + insert_values.push_back(std::to_string(spells_new_entry.mana)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value1)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value2)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value3)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value4)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value5)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value6)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value7)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value8)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value9)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value10)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value11)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value12)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value1)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value2)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value3)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value4)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value5)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value6)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value7)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value8)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value9)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value10)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value11)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value12)); + insert_values.push_back(std::to_string(spells_new_entry.max1)); + insert_values.push_back(std::to_string(spells_new_entry.max2)); + insert_values.push_back(std::to_string(spells_new_entry.max3)); + insert_values.push_back(std::to_string(spells_new_entry.max4)); + insert_values.push_back(std::to_string(spells_new_entry.max5)); + insert_values.push_back(std::to_string(spells_new_entry.max6)); + insert_values.push_back(std::to_string(spells_new_entry.max7)); + insert_values.push_back(std::to_string(spells_new_entry.max8)); + insert_values.push_back(std::to_string(spells_new_entry.max9)); + insert_values.push_back(std::to_string(spells_new_entry.max10)); + insert_values.push_back(std::to_string(spells_new_entry.max11)); + insert_values.push_back(std::to_string(spells_new_entry.max12)); + insert_values.push_back(std::to_string(spells_new_entry.icon)); + insert_values.push_back(std::to_string(spells_new_entry.memicon)); + insert_values.push_back(std::to_string(spells_new_entry.components1)); + insert_values.push_back(std::to_string(spells_new_entry.components2)); + insert_values.push_back(std::to_string(spells_new_entry.components3)); + insert_values.push_back(std::to_string(spells_new_entry.components4)); + insert_values.push_back(std::to_string(spells_new_entry.component_counts1)); + insert_values.push_back(std::to_string(spells_new_entry.component_counts2)); + insert_values.push_back(std::to_string(spells_new_entry.component_counts3)); + insert_values.push_back(std::to_string(spells_new_entry.component_counts4)); + insert_values.push_back(std::to_string(spells_new_entry.NoexpendReagent1)); + insert_values.push_back(std::to_string(spells_new_entry.NoexpendReagent2)); + insert_values.push_back(std::to_string(spells_new_entry.NoexpendReagent3)); + insert_values.push_back(std::to_string(spells_new_entry.NoexpendReagent4)); + insert_values.push_back(std::to_string(spells_new_entry.formula1)); + insert_values.push_back(std::to_string(spells_new_entry.formula2)); + insert_values.push_back(std::to_string(spells_new_entry.formula3)); + insert_values.push_back(std::to_string(spells_new_entry.formula4)); + insert_values.push_back(std::to_string(spells_new_entry.formula5)); + insert_values.push_back(std::to_string(spells_new_entry.formula6)); + insert_values.push_back(std::to_string(spells_new_entry.formula7)); + insert_values.push_back(std::to_string(spells_new_entry.formula8)); + insert_values.push_back(std::to_string(spells_new_entry.formula9)); + insert_values.push_back(std::to_string(spells_new_entry.formula10)); + insert_values.push_back(std::to_string(spells_new_entry.formula11)); + insert_values.push_back(std::to_string(spells_new_entry.formula12)); + insert_values.push_back(std::to_string(spells_new_entry.LightType)); + insert_values.push_back(std::to_string(spells_new_entry.goodEffect)); + insert_values.push_back(std::to_string(spells_new_entry.Activated)); + insert_values.push_back(std::to_string(spells_new_entry.resisttype)); + insert_values.push_back(std::to_string(spells_new_entry.effectid1)); + insert_values.push_back(std::to_string(spells_new_entry.effectid2)); + insert_values.push_back(std::to_string(spells_new_entry.effectid3)); + insert_values.push_back(std::to_string(spells_new_entry.effectid4)); + insert_values.push_back(std::to_string(spells_new_entry.effectid5)); + insert_values.push_back(std::to_string(spells_new_entry.effectid6)); + insert_values.push_back(std::to_string(spells_new_entry.effectid7)); + insert_values.push_back(std::to_string(spells_new_entry.effectid8)); + insert_values.push_back(std::to_string(spells_new_entry.effectid9)); + insert_values.push_back(std::to_string(spells_new_entry.effectid10)); + insert_values.push_back(std::to_string(spells_new_entry.effectid11)); + insert_values.push_back(std::to_string(spells_new_entry.effectid12)); + insert_values.push_back(std::to_string(spells_new_entry.targettype)); + insert_values.push_back(std::to_string(spells_new_entry.basediff)); + insert_values.push_back(std::to_string(spells_new_entry.skill)); + insert_values.push_back(std::to_string(spells_new_entry.zonetype)); + insert_values.push_back(std::to_string(spells_new_entry.EnvironmentType)); + insert_values.push_back(std::to_string(spells_new_entry.TimeOfDay)); + insert_values.push_back(std::to_string(spells_new_entry.classes1)); + insert_values.push_back(std::to_string(spells_new_entry.classes2)); + insert_values.push_back(std::to_string(spells_new_entry.classes3)); + insert_values.push_back(std::to_string(spells_new_entry.classes4)); + insert_values.push_back(std::to_string(spells_new_entry.classes5)); + insert_values.push_back(std::to_string(spells_new_entry.classes6)); + insert_values.push_back(std::to_string(spells_new_entry.classes7)); + insert_values.push_back(std::to_string(spells_new_entry.classes8)); + insert_values.push_back(std::to_string(spells_new_entry.classes9)); + insert_values.push_back(std::to_string(spells_new_entry.classes10)); + insert_values.push_back(std::to_string(spells_new_entry.classes11)); + insert_values.push_back(std::to_string(spells_new_entry.classes12)); + insert_values.push_back(std::to_string(spells_new_entry.classes13)); + insert_values.push_back(std::to_string(spells_new_entry.classes14)); + insert_values.push_back(std::to_string(spells_new_entry.classes15)); + insert_values.push_back(std::to_string(spells_new_entry.classes16)); + insert_values.push_back(std::to_string(spells_new_entry.CastingAnim)); + insert_values.push_back(std::to_string(spells_new_entry.TargetAnim)); + insert_values.push_back(std::to_string(spells_new_entry.TravelType)); + insert_values.push_back(std::to_string(spells_new_entry.SpellAffectIndex)); + insert_values.push_back(std::to_string(spells_new_entry.disallow_sit)); + insert_values.push_back(std::to_string(spells_new_entry.deities0)); + insert_values.push_back(std::to_string(spells_new_entry.deities1)); + insert_values.push_back(std::to_string(spells_new_entry.deities2)); + insert_values.push_back(std::to_string(spells_new_entry.deities3)); + insert_values.push_back(std::to_string(spells_new_entry.deities4)); + insert_values.push_back(std::to_string(spells_new_entry.deities5)); + insert_values.push_back(std::to_string(spells_new_entry.deities6)); + insert_values.push_back(std::to_string(spells_new_entry.deities7)); + insert_values.push_back(std::to_string(spells_new_entry.deities8)); + insert_values.push_back(std::to_string(spells_new_entry.deities9)); + insert_values.push_back(std::to_string(spells_new_entry.deities10)); + insert_values.push_back(std::to_string(spells_new_entry.deities11)); + insert_values.push_back(std::to_string(spells_new_entry.deities12)); + insert_values.push_back(std::to_string(spells_new_entry.deities13)); + insert_values.push_back(std::to_string(spells_new_entry.deities14)); + insert_values.push_back(std::to_string(spells_new_entry.deities15)); + insert_values.push_back(std::to_string(spells_new_entry.deities16)); + insert_values.push_back(std::to_string(spells_new_entry.field142)); + insert_values.push_back(std::to_string(spells_new_entry.field143)); + insert_values.push_back(std::to_string(spells_new_entry.new_icon)); + insert_values.push_back(std::to_string(spells_new_entry.spellanim)); + insert_values.push_back(std::to_string(spells_new_entry.uninterruptable)); + insert_values.push_back(std::to_string(spells_new_entry.ResistDiff)); + insert_values.push_back(std::to_string(spells_new_entry.dot_stacking_exempt)); + insert_values.push_back(std::to_string(spells_new_entry.deleteable)); + insert_values.push_back(std::to_string(spells_new_entry.RecourseLink)); + insert_values.push_back(std::to_string(spells_new_entry.no_partial_resist)); + insert_values.push_back(std::to_string(spells_new_entry.field152)); + insert_values.push_back(std::to_string(spells_new_entry.field153)); + insert_values.push_back(std::to_string(spells_new_entry.short_buff_box)); + insert_values.push_back(std::to_string(spells_new_entry.descnum)); + insert_values.push_back(std::to_string(spells_new_entry.typedescnum)); + insert_values.push_back(std::to_string(spells_new_entry.effectdescnum)); + insert_values.push_back(std::to_string(spells_new_entry.effectdescnum2)); + insert_values.push_back(std::to_string(spells_new_entry.npc_no_los)); + insert_values.push_back(std::to_string(spells_new_entry.field160)); + insert_values.push_back(std::to_string(spells_new_entry.reflectable)); + insert_values.push_back(std::to_string(spells_new_entry.bonushate)); + insert_values.push_back(std::to_string(spells_new_entry.field163)); + insert_values.push_back(std::to_string(spells_new_entry.field164)); + insert_values.push_back(std::to_string(spells_new_entry.ldon_trap)); + insert_values.push_back(std::to_string(spells_new_entry.EndurCost)); + insert_values.push_back(std::to_string(spells_new_entry.EndurTimerIndex)); + insert_values.push_back(std::to_string(spells_new_entry.IsDiscipline)); + insert_values.push_back(std::to_string(spells_new_entry.field169)); + insert_values.push_back(std::to_string(spells_new_entry.field170)); + insert_values.push_back(std::to_string(spells_new_entry.field171)); + insert_values.push_back(std::to_string(spells_new_entry.field172)); + insert_values.push_back(std::to_string(spells_new_entry.HateAdded)); + insert_values.push_back(std::to_string(spells_new_entry.EndurUpkeep)); + insert_values.push_back(std::to_string(spells_new_entry.numhitstype)); + insert_values.push_back(std::to_string(spells_new_entry.numhits)); + insert_values.push_back(std::to_string(spells_new_entry.pvpresistbase)); + insert_values.push_back(std::to_string(spells_new_entry.pvpresistcalc)); + insert_values.push_back(std::to_string(spells_new_entry.pvpresistcap)); + insert_values.push_back(std::to_string(spells_new_entry.spell_category)); + insert_values.push_back(std::to_string(spells_new_entry.field181)); + insert_values.push_back(std::to_string(spells_new_entry.field182)); + insert_values.push_back(std::to_string(spells_new_entry.pcnpc_only_flag)); + insert_values.push_back(std::to_string(spells_new_entry.cast_not_standing)); + insert_values.push_back(std::to_string(spells_new_entry.can_mgb)); + insert_values.push_back(std::to_string(spells_new_entry.nodispell)); + insert_values.push_back(std::to_string(spells_new_entry.npc_category)); + insert_values.push_back(std::to_string(spells_new_entry.npc_usefulness)); + insert_values.push_back(std::to_string(spells_new_entry.MinResist)); + insert_values.push_back(std::to_string(spells_new_entry.MaxResist)); + insert_values.push_back(std::to_string(spells_new_entry.viral_targets)); + insert_values.push_back(std::to_string(spells_new_entry.viral_timer)); + insert_values.push_back(std::to_string(spells_new_entry.nimbuseffect)); + insert_values.push_back(std::to_string(spells_new_entry.ConeStartAngle)); + insert_values.push_back(std::to_string(spells_new_entry.ConeStopAngle)); + insert_values.push_back(std::to_string(spells_new_entry.sneaking)); + insert_values.push_back(std::to_string(spells_new_entry.not_extendable)); + insert_values.push_back(std::to_string(spells_new_entry.field198)); + insert_values.push_back(std::to_string(spells_new_entry.field199)); + insert_values.push_back(std::to_string(spells_new_entry.suspendable)); + insert_values.push_back(std::to_string(spells_new_entry.viral_range)); + insert_values.push_back(std::to_string(spells_new_entry.songcap)); + insert_values.push_back(std::to_string(spells_new_entry.field203)); + insert_values.push_back(std::to_string(spells_new_entry.field204)); + insert_values.push_back(std::to_string(spells_new_entry.no_block)); + insert_values.push_back(std::to_string(spells_new_entry.field206)); + insert_values.push_back(std::to_string(spells_new_entry.spellgroup)); + insert_values.push_back(std::to_string(spells_new_entry.rank)); + insert_values.push_back(std::to_string(spells_new_entry.field209)); + insert_values.push_back(std::to_string(spells_new_entry.field210)); + insert_values.push_back(std::to_string(spells_new_entry.CastRestriction)); + insert_values.push_back(std::to_string(spells_new_entry.allowrest)); + insert_values.push_back(std::to_string(spells_new_entry.InCombat)); + insert_values.push_back(std::to_string(spells_new_entry.OutofCombat)); + insert_values.push_back(std::to_string(spells_new_entry.field215)); + insert_values.push_back(std::to_string(spells_new_entry.field216)); + insert_values.push_back(std::to_string(spells_new_entry.field217)); + insert_values.push_back(std::to_string(spells_new_entry.aemaxtargets)); + insert_values.push_back(std::to_string(spells_new_entry.maxtargets)); + insert_values.push_back(std::to_string(spells_new_entry.field220)); + insert_values.push_back(std::to_string(spells_new_entry.field221)); + insert_values.push_back(std::to_string(spells_new_entry.field222)); + insert_values.push_back(std::to_string(spells_new_entry.field223)); + insert_values.push_back(std::to_string(spells_new_entry.persistdeath)); + insert_values.push_back(std::to_string(spells_new_entry.field225)); + insert_values.push_back(std::to_string(spells_new_entry.field226)); + insert_values.push_back(std::to_string(spells_new_entry.min_dist)); + insert_values.push_back(std::to_string(spells_new_entry.min_dist_mod)); + insert_values.push_back(std::to_string(spells_new_entry.max_dist)); + insert_values.push_back(std::to_string(spells_new_entry.max_dist_mod)); + insert_values.push_back(std::to_string(spells_new_entry.min_range)); + insert_values.push_back(std::to_string(spells_new_entry.field232)); + insert_values.push_back(std::to_string(spells_new_entry.field233)); + insert_values.push_back(std::to_string(spells_new_entry.field234)); + insert_values.push_back(std::to_string(spells_new_entry.field235)); + insert_values.push_back(std::to_string(spells_new_entry.field236)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + spells_new_entry.id = results.LastInsertedID(); + return spells_new_entry; + } + + spells_new_entry = NewEntity(); + + return spells_new_entry; + } + + static int InsertMany( + std::vector spells_new_entries + ) + { + std::vector insert_chunks; + + for (auto &spells_new_entry: spells_new_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(spells_new_entry.name) + "'"); + insert_values.push_back("'" + EscapeString(spells_new_entry.player_1) + "'"); + insert_values.push_back("'" + EscapeString(spells_new_entry.teleport_zone) + "'"); + insert_values.push_back("'" + EscapeString(spells_new_entry.you_cast) + "'"); + insert_values.push_back("'" + EscapeString(spells_new_entry.other_casts) + "'"); + insert_values.push_back("'" + EscapeString(spells_new_entry.cast_on_you) + "'"); + insert_values.push_back("'" + EscapeString(spells_new_entry.cast_on_other) + "'"); + insert_values.push_back("'" + EscapeString(spells_new_entry.spell_fades) + "'"); + insert_values.push_back(std::to_string(spells_new_entry.range)); + insert_values.push_back(std::to_string(spells_new_entry.aoerange)); + insert_values.push_back(std::to_string(spells_new_entry.pushback)); + insert_values.push_back(std::to_string(spells_new_entry.pushup)); + insert_values.push_back(std::to_string(spells_new_entry.cast_time)); + insert_values.push_back(std::to_string(spells_new_entry.recovery_time)); + insert_values.push_back(std::to_string(spells_new_entry.recast_time)); + insert_values.push_back(std::to_string(spells_new_entry.buffdurationformula)); + insert_values.push_back(std::to_string(spells_new_entry.buffduration)); + insert_values.push_back(std::to_string(spells_new_entry.AEDuration)); + insert_values.push_back(std::to_string(spells_new_entry.mana)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value1)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value2)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value3)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value4)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value5)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value6)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value7)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value8)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value9)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value10)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value11)); + insert_values.push_back(std::to_string(spells_new_entry.effect_base_value12)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value1)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value2)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value3)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value4)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value5)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value6)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value7)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value8)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value9)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value10)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value11)); + insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value12)); + insert_values.push_back(std::to_string(spells_new_entry.max1)); + insert_values.push_back(std::to_string(spells_new_entry.max2)); + insert_values.push_back(std::to_string(spells_new_entry.max3)); + insert_values.push_back(std::to_string(spells_new_entry.max4)); + insert_values.push_back(std::to_string(spells_new_entry.max5)); + insert_values.push_back(std::to_string(spells_new_entry.max6)); + insert_values.push_back(std::to_string(spells_new_entry.max7)); + insert_values.push_back(std::to_string(spells_new_entry.max8)); + insert_values.push_back(std::to_string(spells_new_entry.max9)); + insert_values.push_back(std::to_string(spells_new_entry.max10)); + insert_values.push_back(std::to_string(spells_new_entry.max11)); + insert_values.push_back(std::to_string(spells_new_entry.max12)); + insert_values.push_back(std::to_string(spells_new_entry.icon)); + insert_values.push_back(std::to_string(spells_new_entry.memicon)); + insert_values.push_back(std::to_string(spells_new_entry.components1)); + insert_values.push_back(std::to_string(spells_new_entry.components2)); + insert_values.push_back(std::to_string(spells_new_entry.components3)); + insert_values.push_back(std::to_string(spells_new_entry.components4)); + insert_values.push_back(std::to_string(spells_new_entry.component_counts1)); + insert_values.push_back(std::to_string(spells_new_entry.component_counts2)); + insert_values.push_back(std::to_string(spells_new_entry.component_counts3)); + insert_values.push_back(std::to_string(spells_new_entry.component_counts4)); + insert_values.push_back(std::to_string(spells_new_entry.NoexpendReagent1)); + insert_values.push_back(std::to_string(spells_new_entry.NoexpendReagent2)); + insert_values.push_back(std::to_string(spells_new_entry.NoexpendReagent3)); + insert_values.push_back(std::to_string(spells_new_entry.NoexpendReagent4)); + insert_values.push_back(std::to_string(spells_new_entry.formula1)); + insert_values.push_back(std::to_string(spells_new_entry.formula2)); + insert_values.push_back(std::to_string(spells_new_entry.formula3)); + insert_values.push_back(std::to_string(spells_new_entry.formula4)); + insert_values.push_back(std::to_string(spells_new_entry.formula5)); + insert_values.push_back(std::to_string(spells_new_entry.formula6)); + insert_values.push_back(std::to_string(spells_new_entry.formula7)); + insert_values.push_back(std::to_string(spells_new_entry.formula8)); + insert_values.push_back(std::to_string(spells_new_entry.formula9)); + insert_values.push_back(std::to_string(spells_new_entry.formula10)); + insert_values.push_back(std::to_string(spells_new_entry.formula11)); + insert_values.push_back(std::to_string(spells_new_entry.formula12)); + insert_values.push_back(std::to_string(spells_new_entry.LightType)); + insert_values.push_back(std::to_string(spells_new_entry.goodEffect)); + insert_values.push_back(std::to_string(spells_new_entry.Activated)); + insert_values.push_back(std::to_string(spells_new_entry.resisttype)); + insert_values.push_back(std::to_string(spells_new_entry.effectid1)); + insert_values.push_back(std::to_string(spells_new_entry.effectid2)); + insert_values.push_back(std::to_string(spells_new_entry.effectid3)); + insert_values.push_back(std::to_string(spells_new_entry.effectid4)); + insert_values.push_back(std::to_string(spells_new_entry.effectid5)); + insert_values.push_back(std::to_string(spells_new_entry.effectid6)); + insert_values.push_back(std::to_string(spells_new_entry.effectid7)); + insert_values.push_back(std::to_string(spells_new_entry.effectid8)); + insert_values.push_back(std::to_string(spells_new_entry.effectid9)); + insert_values.push_back(std::to_string(spells_new_entry.effectid10)); + insert_values.push_back(std::to_string(spells_new_entry.effectid11)); + insert_values.push_back(std::to_string(spells_new_entry.effectid12)); + insert_values.push_back(std::to_string(spells_new_entry.targettype)); + insert_values.push_back(std::to_string(spells_new_entry.basediff)); + insert_values.push_back(std::to_string(spells_new_entry.skill)); + insert_values.push_back(std::to_string(spells_new_entry.zonetype)); + insert_values.push_back(std::to_string(spells_new_entry.EnvironmentType)); + insert_values.push_back(std::to_string(spells_new_entry.TimeOfDay)); + insert_values.push_back(std::to_string(spells_new_entry.classes1)); + insert_values.push_back(std::to_string(spells_new_entry.classes2)); + insert_values.push_back(std::to_string(spells_new_entry.classes3)); + insert_values.push_back(std::to_string(spells_new_entry.classes4)); + insert_values.push_back(std::to_string(spells_new_entry.classes5)); + insert_values.push_back(std::to_string(spells_new_entry.classes6)); + insert_values.push_back(std::to_string(spells_new_entry.classes7)); + insert_values.push_back(std::to_string(spells_new_entry.classes8)); + insert_values.push_back(std::to_string(spells_new_entry.classes9)); + insert_values.push_back(std::to_string(spells_new_entry.classes10)); + insert_values.push_back(std::to_string(spells_new_entry.classes11)); + insert_values.push_back(std::to_string(spells_new_entry.classes12)); + insert_values.push_back(std::to_string(spells_new_entry.classes13)); + insert_values.push_back(std::to_string(spells_new_entry.classes14)); + insert_values.push_back(std::to_string(spells_new_entry.classes15)); + insert_values.push_back(std::to_string(spells_new_entry.classes16)); + insert_values.push_back(std::to_string(spells_new_entry.CastingAnim)); + insert_values.push_back(std::to_string(spells_new_entry.TargetAnim)); + insert_values.push_back(std::to_string(spells_new_entry.TravelType)); + insert_values.push_back(std::to_string(spells_new_entry.SpellAffectIndex)); + insert_values.push_back(std::to_string(spells_new_entry.disallow_sit)); + insert_values.push_back(std::to_string(spells_new_entry.deities0)); + insert_values.push_back(std::to_string(spells_new_entry.deities1)); + insert_values.push_back(std::to_string(spells_new_entry.deities2)); + insert_values.push_back(std::to_string(spells_new_entry.deities3)); + insert_values.push_back(std::to_string(spells_new_entry.deities4)); + insert_values.push_back(std::to_string(spells_new_entry.deities5)); + insert_values.push_back(std::to_string(spells_new_entry.deities6)); + insert_values.push_back(std::to_string(spells_new_entry.deities7)); + insert_values.push_back(std::to_string(spells_new_entry.deities8)); + insert_values.push_back(std::to_string(spells_new_entry.deities9)); + insert_values.push_back(std::to_string(spells_new_entry.deities10)); + insert_values.push_back(std::to_string(spells_new_entry.deities11)); + insert_values.push_back(std::to_string(spells_new_entry.deities12)); + insert_values.push_back(std::to_string(spells_new_entry.deities13)); + insert_values.push_back(std::to_string(spells_new_entry.deities14)); + insert_values.push_back(std::to_string(spells_new_entry.deities15)); + insert_values.push_back(std::to_string(spells_new_entry.deities16)); + insert_values.push_back(std::to_string(spells_new_entry.field142)); + insert_values.push_back(std::to_string(spells_new_entry.field143)); + insert_values.push_back(std::to_string(spells_new_entry.new_icon)); + insert_values.push_back(std::to_string(spells_new_entry.spellanim)); + insert_values.push_back(std::to_string(spells_new_entry.uninterruptable)); + insert_values.push_back(std::to_string(spells_new_entry.ResistDiff)); + insert_values.push_back(std::to_string(spells_new_entry.dot_stacking_exempt)); + insert_values.push_back(std::to_string(spells_new_entry.deleteable)); + insert_values.push_back(std::to_string(spells_new_entry.RecourseLink)); + insert_values.push_back(std::to_string(spells_new_entry.no_partial_resist)); + insert_values.push_back(std::to_string(spells_new_entry.field152)); + insert_values.push_back(std::to_string(spells_new_entry.field153)); + insert_values.push_back(std::to_string(spells_new_entry.short_buff_box)); + insert_values.push_back(std::to_string(spells_new_entry.descnum)); + insert_values.push_back(std::to_string(spells_new_entry.typedescnum)); + insert_values.push_back(std::to_string(spells_new_entry.effectdescnum)); + insert_values.push_back(std::to_string(spells_new_entry.effectdescnum2)); + insert_values.push_back(std::to_string(spells_new_entry.npc_no_los)); + insert_values.push_back(std::to_string(spells_new_entry.field160)); + insert_values.push_back(std::to_string(spells_new_entry.reflectable)); + insert_values.push_back(std::to_string(spells_new_entry.bonushate)); + insert_values.push_back(std::to_string(spells_new_entry.field163)); + insert_values.push_back(std::to_string(spells_new_entry.field164)); + insert_values.push_back(std::to_string(spells_new_entry.ldon_trap)); + insert_values.push_back(std::to_string(spells_new_entry.EndurCost)); + insert_values.push_back(std::to_string(spells_new_entry.EndurTimerIndex)); + insert_values.push_back(std::to_string(spells_new_entry.IsDiscipline)); + insert_values.push_back(std::to_string(spells_new_entry.field169)); + insert_values.push_back(std::to_string(spells_new_entry.field170)); + insert_values.push_back(std::to_string(spells_new_entry.field171)); + insert_values.push_back(std::to_string(spells_new_entry.field172)); + insert_values.push_back(std::to_string(spells_new_entry.HateAdded)); + insert_values.push_back(std::to_string(spells_new_entry.EndurUpkeep)); + insert_values.push_back(std::to_string(spells_new_entry.numhitstype)); + insert_values.push_back(std::to_string(spells_new_entry.numhits)); + insert_values.push_back(std::to_string(spells_new_entry.pvpresistbase)); + insert_values.push_back(std::to_string(spells_new_entry.pvpresistcalc)); + insert_values.push_back(std::to_string(spells_new_entry.pvpresistcap)); + insert_values.push_back(std::to_string(spells_new_entry.spell_category)); + insert_values.push_back(std::to_string(spells_new_entry.field181)); + insert_values.push_back(std::to_string(spells_new_entry.field182)); + insert_values.push_back(std::to_string(spells_new_entry.pcnpc_only_flag)); + insert_values.push_back(std::to_string(spells_new_entry.cast_not_standing)); + insert_values.push_back(std::to_string(spells_new_entry.can_mgb)); + insert_values.push_back(std::to_string(spells_new_entry.nodispell)); + insert_values.push_back(std::to_string(spells_new_entry.npc_category)); + insert_values.push_back(std::to_string(spells_new_entry.npc_usefulness)); + insert_values.push_back(std::to_string(spells_new_entry.MinResist)); + insert_values.push_back(std::to_string(spells_new_entry.MaxResist)); + insert_values.push_back(std::to_string(spells_new_entry.viral_targets)); + insert_values.push_back(std::to_string(spells_new_entry.viral_timer)); + insert_values.push_back(std::to_string(spells_new_entry.nimbuseffect)); + insert_values.push_back(std::to_string(spells_new_entry.ConeStartAngle)); + insert_values.push_back(std::to_string(spells_new_entry.ConeStopAngle)); + insert_values.push_back(std::to_string(spells_new_entry.sneaking)); + insert_values.push_back(std::to_string(spells_new_entry.not_extendable)); + insert_values.push_back(std::to_string(spells_new_entry.field198)); + insert_values.push_back(std::to_string(spells_new_entry.field199)); + insert_values.push_back(std::to_string(spells_new_entry.suspendable)); + insert_values.push_back(std::to_string(spells_new_entry.viral_range)); + insert_values.push_back(std::to_string(spells_new_entry.songcap)); + insert_values.push_back(std::to_string(spells_new_entry.field203)); + insert_values.push_back(std::to_string(spells_new_entry.field204)); + insert_values.push_back(std::to_string(spells_new_entry.no_block)); + insert_values.push_back(std::to_string(spells_new_entry.field206)); + insert_values.push_back(std::to_string(spells_new_entry.spellgroup)); + insert_values.push_back(std::to_string(spells_new_entry.rank)); + insert_values.push_back(std::to_string(spells_new_entry.field209)); + insert_values.push_back(std::to_string(spells_new_entry.field210)); + insert_values.push_back(std::to_string(spells_new_entry.CastRestriction)); + insert_values.push_back(std::to_string(spells_new_entry.allowrest)); + insert_values.push_back(std::to_string(spells_new_entry.InCombat)); + insert_values.push_back(std::to_string(spells_new_entry.OutofCombat)); + insert_values.push_back(std::to_string(spells_new_entry.field215)); + insert_values.push_back(std::to_string(spells_new_entry.field216)); + insert_values.push_back(std::to_string(spells_new_entry.field217)); + insert_values.push_back(std::to_string(spells_new_entry.aemaxtargets)); + insert_values.push_back(std::to_string(spells_new_entry.maxtargets)); + insert_values.push_back(std::to_string(spells_new_entry.field220)); + insert_values.push_back(std::to_string(spells_new_entry.field221)); + insert_values.push_back(std::to_string(spells_new_entry.field222)); + insert_values.push_back(std::to_string(spells_new_entry.field223)); + insert_values.push_back(std::to_string(spells_new_entry.persistdeath)); + insert_values.push_back(std::to_string(spells_new_entry.field225)); + insert_values.push_back(std::to_string(spells_new_entry.field226)); + insert_values.push_back(std::to_string(spells_new_entry.min_dist)); + insert_values.push_back(std::to_string(spells_new_entry.min_dist_mod)); + insert_values.push_back(std::to_string(spells_new_entry.max_dist)); + insert_values.push_back(std::to_string(spells_new_entry.max_dist_mod)); + insert_values.push_back(std::to_string(spells_new_entry.min_range)); + insert_values.push_back(std::to_string(spells_new_entry.field232)); + insert_values.push_back(std::to_string(spells_new_entry.field233)); + insert_values.push_back(std::to_string(spells_new_entry.field234)); + insert_values.push_back(std::to_string(spells_new_entry.field235)); + insert_values.push_back(std::to_string(spells_new_entry.field236)); + + 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) { + SpellsNew entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.player_1 = row[2] ? row[2] : ""; + entry.teleport_zone = row[3] ? row[3] : ""; + entry.you_cast = row[4] ? row[4] : ""; + entry.other_casts = row[5] ? row[5] : ""; + entry.cast_on_you = row[6] ? row[6] : ""; + entry.cast_on_other = row[7] ? row[7] : ""; + entry.spell_fades = row[8] ? row[8] : ""; + entry.range = atoi(row[9]); + entry.aoerange = atoi(row[10]); + entry.pushback = atoi(row[11]); + entry.pushup = atoi(row[12]); + entry.cast_time = atoi(row[13]); + entry.recovery_time = atoi(row[14]); + entry.recast_time = atoi(row[15]); + entry.buffdurationformula = atoi(row[16]); + entry.buffduration = atoi(row[17]); + entry.AEDuration = atoi(row[18]); + entry.mana = atoi(row[19]); + entry.effect_base_value1 = atoi(row[20]); + entry.effect_base_value2 = atoi(row[21]); + entry.effect_base_value3 = atoi(row[22]); + entry.effect_base_value4 = atoi(row[23]); + entry.effect_base_value5 = atoi(row[24]); + entry.effect_base_value6 = atoi(row[25]); + entry.effect_base_value7 = atoi(row[26]); + entry.effect_base_value8 = atoi(row[27]); + entry.effect_base_value9 = atoi(row[28]); + entry.effect_base_value10 = atoi(row[29]); + entry.effect_base_value11 = atoi(row[30]); + entry.effect_base_value12 = atoi(row[31]); + entry.effect_limit_value1 = atoi(row[32]); + entry.effect_limit_value2 = atoi(row[33]); + entry.effect_limit_value3 = atoi(row[34]); + entry.effect_limit_value4 = atoi(row[35]); + entry.effect_limit_value5 = atoi(row[36]); + entry.effect_limit_value6 = atoi(row[37]); + entry.effect_limit_value7 = atoi(row[38]); + entry.effect_limit_value8 = atoi(row[39]); + entry.effect_limit_value9 = atoi(row[40]); + entry.effect_limit_value10 = atoi(row[41]); + entry.effect_limit_value11 = atoi(row[42]); + entry.effect_limit_value12 = atoi(row[43]); + entry.max1 = atoi(row[44]); + entry.max2 = atoi(row[45]); + entry.max3 = atoi(row[46]); + entry.max4 = atoi(row[47]); + entry.max5 = atoi(row[48]); + entry.max6 = atoi(row[49]); + entry.max7 = atoi(row[50]); + entry.max8 = atoi(row[51]); + entry.max9 = atoi(row[52]); + entry.max10 = atoi(row[53]); + entry.max11 = atoi(row[54]); + entry.max12 = atoi(row[55]); + entry.icon = atoi(row[56]); + entry.memicon = atoi(row[57]); + entry.components1 = atoi(row[58]); + entry.components2 = atoi(row[59]); + entry.components3 = atoi(row[60]); + entry.components4 = atoi(row[61]); + entry.component_counts1 = atoi(row[62]); + entry.component_counts2 = atoi(row[63]); + entry.component_counts3 = atoi(row[64]); + entry.component_counts4 = atoi(row[65]); + entry.NoexpendReagent1 = atoi(row[66]); + entry.NoexpendReagent2 = atoi(row[67]); + entry.NoexpendReagent3 = atoi(row[68]); + entry.NoexpendReagent4 = atoi(row[69]); + entry.formula1 = atoi(row[70]); + entry.formula2 = atoi(row[71]); + entry.formula3 = atoi(row[72]); + entry.formula4 = atoi(row[73]); + entry.formula5 = atoi(row[74]); + entry.formula6 = atoi(row[75]); + entry.formula7 = atoi(row[76]); + entry.formula8 = atoi(row[77]); + entry.formula9 = atoi(row[78]); + entry.formula10 = atoi(row[79]); + entry.formula11 = atoi(row[80]); + entry.formula12 = atoi(row[81]); + entry.LightType = atoi(row[82]); + entry.goodEffect = atoi(row[83]); + entry.Activated = atoi(row[84]); + entry.resisttype = atoi(row[85]); + entry.effectid1 = atoi(row[86]); + entry.effectid2 = atoi(row[87]); + entry.effectid3 = atoi(row[88]); + entry.effectid4 = atoi(row[89]); + entry.effectid5 = atoi(row[90]); + entry.effectid6 = atoi(row[91]); + entry.effectid7 = atoi(row[92]); + entry.effectid8 = atoi(row[93]); + entry.effectid9 = atoi(row[94]); + entry.effectid10 = atoi(row[95]); + entry.effectid11 = atoi(row[96]); + entry.effectid12 = atoi(row[97]); + entry.targettype = atoi(row[98]); + entry.basediff = atoi(row[99]); + entry.skill = atoi(row[100]); + entry.zonetype = atoi(row[101]); + entry.EnvironmentType = atoi(row[102]); + entry.TimeOfDay = atoi(row[103]); + entry.classes1 = atoi(row[104]); + entry.classes2 = atoi(row[105]); + entry.classes3 = atoi(row[106]); + entry.classes4 = atoi(row[107]); + entry.classes5 = atoi(row[108]); + entry.classes6 = atoi(row[109]); + entry.classes7 = atoi(row[110]); + entry.classes8 = atoi(row[111]); + entry.classes9 = atoi(row[112]); + entry.classes10 = atoi(row[113]); + entry.classes11 = atoi(row[114]); + entry.classes12 = atoi(row[115]); + entry.classes13 = atoi(row[116]); + entry.classes14 = atoi(row[117]); + entry.classes15 = atoi(row[118]); + entry.classes16 = atoi(row[119]); + entry.CastingAnim = atoi(row[120]); + entry.TargetAnim = atoi(row[121]); + entry.TravelType = atoi(row[122]); + entry.SpellAffectIndex = atoi(row[123]); + entry.disallow_sit = atoi(row[124]); + entry.deities0 = atoi(row[125]); + entry.deities1 = atoi(row[126]); + entry.deities2 = atoi(row[127]); + entry.deities3 = atoi(row[128]); + entry.deities4 = atoi(row[129]); + entry.deities5 = atoi(row[130]); + entry.deities6 = atoi(row[131]); + entry.deities7 = atoi(row[132]); + entry.deities8 = atoi(row[133]); + entry.deities9 = atoi(row[134]); + entry.deities10 = atoi(row[135]); + entry.deities11 = atoi(row[136]); + entry.deities12 = atoi(row[137]); + entry.deities13 = atoi(row[138]); + entry.deities14 = atoi(row[139]); + entry.deities15 = atoi(row[140]); + entry.deities16 = atoi(row[141]); + entry.field142 = atoi(row[142]); + entry.field143 = atoi(row[143]); + entry.new_icon = atoi(row[144]); + entry.spellanim = atoi(row[145]); + entry.uninterruptable = atoi(row[146]); + entry.ResistDiff = atoi(row[147]); + entry.dot_stacking_exempt = atoi(row[148]); + entry.deleteable = atoi(row[149]); + entry.RecourseLink = atoi(row[150]); + entry.no_partial_resist = atoi(row[151]); + entry.field152 = atoi(row[152]); + entry.field153 = atoi(row[153]); + entry.short_buff_box = atoi(row[154]); + entry.descnum = atoi(row[155]); + entry.typedescnum = atoi(row[156]); + entry.effectdescnum = atoi(row[157]); + entry.effectdescnum2 = atoi(row[158]); + entry.npc_no_los = atoi(row[159]); + entry.field160 = atoi(row[160]); + entry.reflectable = atoi(row[161]); + entry.bonushate = atoi(row[162]); + entry.field163 = atoi(row[163]); + entry.field164 = atoi(row[164]); + entry.ldon_trap = atoi(row[165]); + entry.EndurCost = atoi(row[166]); + entry.EndurTimerIndex = atoi(row[167]); + entry.IsDiscipline = atoi(row[168]); + entry.field169 = atoi(row[169]); + entry.field170 = atoi(row[170]); + entry.field171 = atoi(row[171]); + entry.field172 = atoi(row[172]); + entry.HateAdded = atoi(row[173]); + entry.EndurUpkeep = atoi(row[174]); + entry.numhitstype = atoi(row[175]); + entry.numhits = atoi(row[176]); + entry.pvpresistbase = atoi(row[177]); + entry.pvpresistcalc = atoi(row[178]); + entry.pvpresistcap = atoi(row[179]); + entry.spell_category = atoi(row[180]); + entry.field181 = atoi(row[181]); + entry.field182 = atoi(row[182]); + entry.pcnpc_only_flag = atoi(row[183]); + entry.cast_not_standing = atoi(row[184]); + entry.can_mgb = atoi(row[185]); + entry.nodispell = atoi(row[186]); + entry.npc_category = atoi(row[187]); + entry.npc_usefulness = atoi(row[188]); + entry.MinResist = atoi(row[189]); + entry.MaxResist = atoi(row[190]); + entry.viral_targets = atoi(row[191]); + entry.viral_timer = atoi(row[192]); + entry.nimbuseffect = atoi(row[193]); + entry.ConeStartAngle = atoi(row[194]); + entry.ConeStopAngle = atoi(row[195]); + entry.sneaking = atoi(row[196]); + entry.not_extendable = atoi(row[197]); + entry.field198 = atoi(row[198]); + entry.field199 = atoi(row[199]); + entry.suspendable = atoi(row[200]); + entry.viral_range = atoi(row[201]); + entry.songcap = atoi(row[202]); + entry.field203 = atoi(row[203]); + entry.field204 = atoi(row[204]); + entry.no_block = atoi(row[205]); + entry.field206 = atoi(row[206]); + entry.spellgroup = atoi(row[207]); + entry.rank = atoi(row[208]); + entry.field209 = atoi(row[209]); + entry.field210 = atoi(row[210]); + entry.CastRestriction = atoi(row[211]); + entry.allowrest = atoi(row[212]); + entry.InCombat = atoi(row[213]); + entry.OutofCombat = atoi(row[214]); + entry.field215 = atoi(row[215]); + entry.field216 = atoi(row[216]); + entry.field217 = atoi(row[217]); + entry.aemaxtargets = atoi(row[218]); + entry.maxtargets = atoi(row[219]); + entry.field220 = atoi(row[220]); + entry.field221 = atoi(row[221]); + entry.field222 = atoi(row[222]); + entry.field223 = atoi(row[223]); + entry.persistdeath = atoi(row[224]); + entry.field225 = atoi(row[225]); + entry.field226 = atoi(row[226]); + entry.min_dist = atof(row[227]); + entry.min_dist_mod = atof(row[228]); + entry.max_dist = atof(row[229]); + entry.max_dist_mod = atof(row[230]); + entry.min_range = atoi(row[231]); + entry.field232 = atoi(row[232]); + entry.field233 = atoi(row[233]); + entry.field234 = atoi(row[234]); + entry.field235 = atoi(row[235]); + entry.field236 = atoi(row[236]); + + 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) { + SpellsNew entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.player_1 = row[2] ? row[2] : ""; + entry.teleport_zone = row[3] ? row[3] : ""; + entry.you_cast = row[4] ? row[4] : ""; + entry.other_casts = row[5] ? row[5] : ""; + entry.cast_on_you = row[6] ? row[6] : ""; + entry.cast_on_other = row[7] ? row[7] : ""; + entry.spell_fades = row[8] ? row[8] : ""; + entry.range = atoi(row[9]); + entry.aoerange = atoi(row[10]); + entry.pushback = atoi(row[11]); + entry.pushup = atoi(row[12]); + entry.cast_time = atoi(row[13]); + entry.recovery_time = atoi(row[14]); + entry.recast_time = atoi(row[15]); + entry.buffdurationformula = atoi(row[16]); + entry.buffduration = atoi(row[17]); + entry.AEDuration = atoi(row[18]); + entry.mana = atoi(row[19]); + entry.effect_base_value1 = atoi(row[20]); + entry.effect_base_value2 = atoi(row[21]); + entry.effect_base_value3 = atoi(row[22]); + entry.effect_base_value4 = atoi(row[23]); + entry.effect_base_value5 = atoi(row[24]); + entry.effect_base_value6 = atoi(row[25]); + entry.effect_base_value7 = atoi(row[26]); + entry.effect_base_value8 = atoi(row[27]); + entry.effect_base_value9 = atoi(row[28]); + entry.effect_base_value10 = atoi(row[29]); + entry.effect_base_value11 = atoi(row[30]); + entry.effect_base_value12 = atoi(row[31]); + entry.effect_limit_value1 = atoi(row[32]); + entry.effect_limit_value2 = atoi(row[33]); + entry.effect_limit_value3 = atoi(row[34]); + entry.effect_limit_value4 = atoi(row[35]); + entry.effect_limit_value5 = atoi(row[36]); + entry.effect_limit_value6 = atoi(row[37]); + entry.effect_limit_value7 = atoi(row[38]); + entry.effect_limit_value8 = atoi(row[39]); + entry.effect_limit_value9 = atoi(row[40]); + entry.effect_limit_value10 = atoi(row[41]); + entry.effect_limit_value11 = atoi(row[42]); + entry.effect_limit_value12 = atoi(row[43]); + entry.max1 = atoi(row[44]); + entry.max2 = atoi(row[45]); + entry.max3 = atoi(row[46]); + entry.max4 = atoi(row[47]); + entry.max5 = atoi(row[48]); + entry.max6 = atoi(row[49]); + entry.max7 = atoi(row[50]); + entry.max8 = atoi(row[51]); + entry.max9 = atoi(row[52]); + entry.max10 = atoi(row[53]); + entry.max11 = atoi(row[54]); + entry.max12 = atoi(row[55]); + entry.icon = atoi(row[56]); + entry.memicon = atoi(row[57]); + entry.components1 = atoi(row[58]); + entry.components2 = atoi(row[59]); + entry.components3 = atoi(row[60]); + entry.components4 = atoi(row[61]); + entry.component_counts1 = atoi(row[62]); + entry.component_counts2 = atoi(row[63]); + entry.component_counts3 = atoi(row[64]); + entry.component_counts4 = atoi(row[65]); + entry.NoexpendReagent1 = atoi(row[66]); + entry.NoexpendReagent2 = atoi(row[67]); + entry.NoexpendReagent3 = atoi(row[68]); + entry.NoexpendReagent4 = atoi(row[69]); + entry.formula1 = atoi(row[70]); + entry.formula2 = atoi(row[71]); + entry.formula3 = atoi(row[72]); + entry.formula4 = atoi(row[73]); + entry.formula5 = atoi(row[74]); + entry.formula6 = atoi(row[75]); + entry.formula7 = atoi(row[76]); + entry.formula8 = atoi(row[77]); + entry.formula9 = atoi(row[78]); + entry.formula10 = atoi(row[79]); + entry.formula11 = atoi(row[80]); + entry.formula12 = atoi(row[81]); + entry.LightType = atoi(row[82]); + entry.goodEffect = atoi(row[83]); + entry.Activated = atoi(row[84]); + entry.resisttype = atoi(row[85]); + entry.effectid1 = atoi(row[86]); + entry.effectid2 = atoi(row[87]); + entry.effectid3 = atoi(row[88]); + entry.effectid4 = atoi(row[89]); + entry.effectid5 = atoi(row[90]); + entry.effectid6 = atoi(row[91]); + entry.effectid7 = atoi(row[92]); + entry.effectid8 = atoi(row[93]); + entry.effectid9 = atoi(row[94]); + entry.effectid10 = atoi(row[95]); + entry.effectid11 = atoi(row[96]); + entry.effectid12 = atoi(row[97]); + entry.targettype = atoi(row[98]); + entry.basediff = atoi(row[99]); + entry.skill = atoi(row[100]); + entry.zonetype = atoi(row[101]); + entry.EnvironmentType = atoi(row[102]); + entry.TimeOfDay = atoi(row[103]); + entry.classes1 = atoi(row[104]); + entry.classes2 = atoi(row[105]); + entry.classes3 = atoi(row[106]); + entry.classes4 = atoi(row[107]); + entry.classes5 = atoi(row[108]); + entry.classes6 = atoi(row[109]); + entry.classes7 = atoi(row[110]); + entry.classes8 = atoi(row[111]); + entry.classes9 = atoi(row[112]); + entry.classes10 = atoi(row[113]); + entry.classes11 = atoi(row[114]); + entry.classes12 = atoi(row[115]); + entry.classes13 = atoi(row[116]); + entry.classes14 = atoi(row[117]); + entry.classes15 = atoi(row[118]); + entry.classes16 = atoi(row[119]); + entry.CastingAnim = atoi(row[120]); + entry.TargetAnim = atoi(row[121]); + entry.TravelType = atoi(row[122]); + entry.SpellAffectIndex = atoi(row[123]); + entry.disallow_sit = atoi(row[124]); + entry.deities0 = atoi(row[125]); + entry.deities1 = atoi(row[126]); + entry.deities2 = atoi(row[127]); + entry.deities3 = atoi(row[128]); + entry.deities4 = atoi(row[129]); + entry.deities5 = atoi(row[130]); + entry.deities6 = atoi(row[131]); + entry.deities7 = atoi(row[132]); + entry.deities8 = atoi(row[133]); + entry.deities9 = atoi(row[134]); + entry.deities10 = atoi(row[135]); + entry.deities11 = atoi(row[136]); + entry.deities12 = atoi(row[137]); + entry.deities13 = atoi(row[138]); + entry.deities14 = atoi(row[139]); + entry.deities15 = atoi(row[140]); + entry.deities16 = atoi(row[141]); + entry.field142 = atoi(row[142]); + entry.field143 = atoi(row[143]); + entry.new_icon = atoi(row[144]); + entry.spellanim = atoi(row[145]); + entry.uninterruptable = atoi(row[146]); + entry.ResistDiff = atoi(row[147]); + entry.dot_stacking_exempt = atoi(row[148]); + entry.deleteable = atoi(row[149]); + entry.RecourseLink = atoi(row[150]); + entry.no_partial_resist = atoi(row[151]); + entry.field152 = atoi(row[152]); + entry.field153 = atoi(row[153]); + entry.short_buff_box = atoi(row[154]); + entry.descnum = atoi(row[155]); + entry.typedescnum = atoi(row[156]); + entry.effectdescnum = atoi(row[157]); + entry.effectdescnum2 = atoi(row[158]); + entry.npc_no_los = atoi(row[159]); + entry.field160 = atoi(row[160]); + entry.reflectable = atoi(row[161]); + entry.bonushate = atoi(row[162]); + entry.field163 = atoi(row[163]); + entry.field164 = atoi(row[164]); + entry.ldon_trap = atoi(row[165]); + entry.EndurCost = atoi(row[166]); + entry.EndurTimerIndex = atoi(row[167]); + entry.IsDiscipline = atoi(row[168]); + entry.field169 = atoi(row[169]); + entry.field170 = atoi(row[170]); + entry.field171 = atoi(row[171]); + entry.field172 = atoi(row[172]); + entry.HateAdded = atoi(row[173]); + entry.EndurUpkeep = atoi(row[174]); + entry.numhitstype = atoi(row[175]); + entry.numhits = atoi(row[176]); + entry.pvpresistbase = atoi(row[177]); + entry.pvpresistcalc = atoi(row[178]); + entry.pvpresistcap = atoi(row[179]); + entry.spell_category = atoi(row[180]); + entry.field181 = atoi(row[181]); + entry.field182 = atoi(row[182]); + entry.pcnpc_only_flag = atoi(row[183]); + entry.cast_not_standing = atoi(row[184]); + entry.can_mgb = atoi(row[185]); + entry.nodispell = atoi(row[186]); + entry.npc_category = atoi(row[187]); + entry.npc_usefulness = atoi(row[188]); + entry.MinResist = atoi(row[189]); + entry.MaxResist = atoi(row[190]); + entry.viral_targets = atoi(row[191]); + entry.viral_timer = atoi(row[192]); + entry.nimbuseffect = atoi(row[193]); + entry.ConeStartAngle = atoi(row[194]); + entry.ConeStopAngle = atoi(row[195]); + entry.sneaking = atoi(row[196]); + entry.not_extendable = atoi(row[197]); + entry.field198 = atoi(row[198]); + entry.field199 = atoi(row[199]); + entry.suspendable = atoi(row[200]); + entry.viral_range = atoi(row[201]); + entry.songcap = atoi(row[202]); + entry.field203 = atoi(row[203]); + entry.field204 = atoi(row[204]); + entry.no_block = atoi(row[205]); + entry.field206 = atoi(row[206]); + entry.spellgroup = atoi(row[207]); + entry.rank = atoi(row[208]); + entry.field209 = atoi(row[209]); + entry.field210 = atoi(row[210]); + entry.CastRestriction = atoi(row[211]); + entry.allowrest = atoi(row[212]); + entry.InCombat = atoi(row[213]); + entry.OutofCombat = atoi(row[214]); + entry.field215 = atoi(row[215]); + entry.field216 = atoi(row[216]); + entry.field217 = atoi(row[217]); + entry.aemaxtargets = atoi(row[218]); + entry.maxtargets = atoi(row[219]); + entry.field220 = atoi(row[220]); + entry.field221 = atoi(row[221]); + entry.field222 = atoi(row[222]); + entry.field223 = atoi(row[223]); + entry.persistdeath = atoi(row[224]); + entry.field225 = atoi(row[225]); + entry.field226 = atoi(row[226]); + entry.min_dist = atof(row[227]); + entry.min_dist_mod = atof(row[228]); + entry.max_dist = atof(row[229]); + entry.max_dist_mod = atof(row[230]); + entry.min_range = atoi(row[231]); + entry.field232 = atoi(row[232]); + entry.field233 = atoi(row[233]); + entry.field234 = atoi(row[234]); + entry.field235 = atoi(row[235]); + entry.field236 = atoi(row[236]); + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_SPELLS_NEW_REPOSITORY_H diff --git a/common/repositories/base/base_start_zones_repository.h b/common/repositories/base/base_start_zones_repository.h new file mode 100644 index 000000000..c0a8b3c6a --- /dev/null +++ b/common/repositories/base/base_start_zones_repository.h @@ -0,0 +1,441 @@ +/** + * 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 on Apr 5, 2020 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_START_ZONES_REPOSITORY_H +#define EQEMU_BASE_START_ZONES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseStartZonesRepository { +public: + struct StartZones { + float x; + float y; + float z; + float heading; + int zone_id; + int bind_id; + int player_choice; + int player_class; + int player_deity; + int player_race; + int start_zone; + float bind_x; + float bind_y; + float bind_z; + int8 select_rank; + int8 min_expansion; + int8 max_expansion; + std::string content_flags; + }; + + static std::string PrimaryKey() + { + return std::string("player_race"); + } + + static std::vector Columns() + { + return { + "x", + "y", + "z", + "heading", + "zone_id", + "bind_id", + "player_choice", + "player_class", + "player_deity", + "player_race", + "start_zone", + "bind_x", + "bind_y", + "bind_z", + "select_rank", + "min_expansion", + "max_expansion", + "content_flags", + }; + } + + 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("start_zones"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static StartZones NewEntity() + { + StartZones entry{}; + + entry.x = 0; + entry.y = 0; + entry.z = 0; + entry.heading = 0; + entry.zone_id = 0; + entry.bind_id = 0; + entry.player_choice = 0; + entry.player_class = 0; + entry.player_deity = 0; + entry.player_race = 0; + entry.start_zone = 0; + entry.bind_x = 0; + entry.bind_y = 0; + entry.bind_z = 0; + entry.select_rank = 50; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; + + return entry; + } + + static StartZones GetStartZonesEntry( + const std::vector &start_zoness, + int start_zones_id + ) + { + for (auto &start_zones : start_zoness) { + if (start_zones.player_race == start_zones_id) { + return start_zones; + } + } + + return NewEntity(); + } + + static StartZones FindOne( + int start_zones_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + start_zones_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + StartZones entry{}; + + entry.x = atof(row[0]); + entry.y = atof(row[1]); + entry.z = atof(row[2]); + entry.heading = atof(row[3]); + entry.zone_id = atoi(row[4]); + entry.bind_id = atoi(row[5]); + entry.player_choice = atoi(row[6]); + entry.player_class = atoi(row[7]); + entry.player_deity = atoi(row[8]); + entry.player_race = atoi(row[9]); + entry.start_zone = atoi(row[10]); + entry.bind_x = atof(row[11]); + entry.bind_y = atof(row[12]); + entry.bind_z = atof(row[13]); + entry.select_rank = atoi(row[14]); + entry.min_expansion = atoi(row[15]); + entry.max_expansion = atoi(row[16]); + entry.content_flags = row[17] ? row[17] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int start_zones_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + start_zones_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + StartZones start_zones_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[0] + " = " + std::to_string(start_zones_entry.x)); + update_values.push_back(columns[1] + " = " + std::to_string(start_zones_entry.y)); + update_values.push_back(columns[2] + " = " + std::to_string(start_zones_entry.z)); + update_values.push_back(columns[3] + " = " + std::to_string(start_zones_entry.heading)); + update_values.push_back(columns[4] + " = " + std::to_string(start_zones_entry.zone_id)); + update_values.push_back(columns[5] + " = " + std::to_string(start_zones_entry.bind_id)); + update_values.push_back(columns[10] + " = " + std::to_string(start_zones_entry.start_zone)); + update_values.push_back(columns[11] + " = " + std::to_string(start_zones_entry.bind_x)); + update_values.push_back(columns[12] + " = " + std::to_string(start_zones_entry.bind_y)); + update_values.push_back(columns[13] + " = " + std::to_string(start_zones_entry.bind_z)); + update_values.push_back(columns[14] + " = " + std::to_string(start_zones_entry.select_rank)); + update_values.push_back(columns[15] + " = " + std::to_string(start_zones_entry.min_expansion)); + update_values.push_back(columns[16] + " = " + std::to_string(start_zones_entry.max_expansion)); + update_values.push_back(columns[17] + " = '" + EscapeString(start_zones_entry.content_flags) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + start_zones_entry.player_race + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static StartZones InsertOne( + StartZones start_zones_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(start_zones_entry.x)); + insert_values.push_back(std::to_string(start_zones_entry.y)); + insert_values.push_back(std::to_string(start_zones_entry.z)); + insert_values.push_back(std::to_string(start_zones_entry.heading)); + insert_values.push_back(std::to_string(start_zones_entry.zone_id)); + insert_values.push_back(std::to_string(start_zones_entry.bind_id)); + insert_values.push_back(std::to_string(start_zones_entry.start_zone)); + insert_values.push_back(std::to_string(start_zones_entry.bind_x)); + insert_values.push_back(std::to_string(start_zones_entry.bind_y)); + insert_values.push_back(std::to_string(start_zones_entry.bind_z)); + insert_values.push_back(std::to_string(start_zones_entry.select_rank)); + insert_values.push_back(std::to_string(start_zones_entry.min_expansion)); + insert_values.push_back(std::to_string(start_zones_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(start_zones_entry.content_flags) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + start_zones_entry.id = results.LastInsertedID(); + return start_zones_entry; + } + + start_zones_entry = NewEntity(); + + return start_zones_entry; + } + + static int InsertMany( + std::vector start_zones_entries + ) + { + std::vector insert_chunks; + + for (auto &start_zones_entry: start_zones_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(start_zones_entry.x)); + insert_values.push_back(std::to_string(start_zones_entry.y)); + insert_values.push_back(std::to_string(start_zones_entry.z)); + insert_values.push_back(std::to_string(start_zones_entry.heading)); + insert_values.push_back(std::to_string(start_zones_entry.zone_id)); + insert_values.push_back(std::to_string(start_zones_entry.bind_id)); + insert_values.push_back(std::to_string(start_zones_entry.start_zone)); + insert_values.push_back(std::to_string(start_zones_entry.bind_x)); + insert_values.push_back(std::to_string(start_zones_entry.bind_y)); + insert_values.push_back(std::to_string(start_zones_entry.bind_z)); + insert_values.push_back(std::to_string(start_zones_entry.select_rank)); + insert_values.push_back(std::to_string(start_zones_entry.min_expansion)); + insert_values.push_back(std::to_string(start_zones_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(start_zones_entry.content_flags) + "'"); + + 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) { + StartZones entry{}; + + entry.x = atof(row[0]); + entry.y = atof(row[1]); + entry.z = atof(row[2]); + entry.heading = atof(row[3]); + entry.zone_id = atoi(row[4]); + entry.bind_id = atoi(row[5]); + entry.player_choice = atoi(row[6]); + entry.player_class = atoi(row[7]); + entry.player_deity = atoi(row[8]); + entry.player_race = atoi(row[9]); + entry.start_zone = atoi(row[10]); + entry.bind_x = atof(row[11]); + entry.bind_y = atof(row[12]); + entry.bind_z = atof(row[13]); + entry.select_rank = atoi(row[14]); + entry.min_expansion = atoi(row[15]); + entry.max_expansion = atoi(row[16]); + entry.content_flags = row[17] ? row[17] : ""; + + 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) { + StartZones entry{}; + + entry.x = atof(row[0]); + entry.y = atof(row[1]); + entry.z = atof(row[2]); + entry.heading = atof(row[3]); + entry.zone_id = atoi(row[4]); + entry.bind_id = atoi(row[5]); + entry.player_choice = atoi(row[6]); + entry.player_class = atoi(row[7]); + entry.player_deity = atoi(row[8]); + entry.player_race = atoi(row[9]); + entry.start_zone = atoi(row[10]); + entry.bind_x = atof(row[11]); + entry.bind_y = atof(row[12]); + entry.bind_z = atof(row[13]); + entry.select_rank = atoi(row[14]); + entry.min_expansion = atoi(row[15]); + entry.max_expansion = atoi(row[16]); + entry.content_flags = row[17] ? row[17] : ""; + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_START_ZONES_REPOSITORY_H diff --git a/common/repositories/base/base_starting_items_repository.h b/common/repositories/base/base_starting_items_repository.h new file mode 100644 index 000000000..64bdd124a --- /dev/null +++ b/common/repositories/base/base_starting_items_repository.h @@ -0,0 +1,393 @@ +/** + * 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 on Apr 5, 2020 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_STARTING_ITEMS_REPOSITORY_H +#define EQEMU_BASE_STARTING_ITEMS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseStartingItemsRepository { +public: + struct StartingItems { + int id; + int race; + int class; + int deityid; + int zoneid; + int itemid; + int8 item_charges; + int8 gm; + int slot; + int8 min_expansion; + int8 max_expansion; + std::string content_flags; + }; + + static std::string PrimaryKey() + { + return std::string("race"); + } + + static std::vector Columns() + { + return { + "id", + "race", + "class", + "deityid", + "zoneid", + "itemid", + "item_charges", + "gm", + "slot", + "min_expansion", + "max_expansion", + "content_flags", + }; + } + + 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("starting_items"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static StartingItems NewEntity() + { + StartingItems entry{}; + + entry.id = 0; + entry.race = 0; + entry.class = 0; + entry.deityid = 0; + entry.zoneid = 0; + entry.itemid = 0; + entry.item_charges = 1; + entry.gm = 0; + entry.slot = -1; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; + + return entry; + } + + static StartingItems GetStartingItemsEntry( + const std::vector &starting_itemss, + int starting_items_id + ) + { + for (auto &starting_items : starting_itemss) { + if (starting_items.race == starting_items_id) { + return starting_items; + } + } + + return NewEntity(); + } + + static StartingItems FindOne( + int starting_items_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + starting_items_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + StartingItems entry{}; + + entry.id = atoi(row[0]); + entry.race = atoi(row[1]); + entry.class = atoi(row[2]); + entry.deityid = atoi(row[3]); + entry.zoneid = atoi(row[4]); + entry.itemid = atoi(row[5]); + entry.item_charges = atoi(row[6]); + entry.gm = atoi(row[7]); + entry.slot = atoi(row[8]); + entry.min_expansion = atoi(row[9]); + entry.max_expansion = atoi(row[10]); + entry.content_flags = row[11] ? row[11] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int starting_items_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + starting_items_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + StartingItems starting_items_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = " + std::to_string(starting_items_entry.class)); + update_values.push_back(columns[3] + " = " + std::to_string(starting_items_entry.deityid)); + update_values.push_back(columns[4] + " = " + std::to_string(starting_items_entry.zoneid)); + update_values.push_back(columns[5] + " = " + std::to_string(starting_items_entry.itemid)); + update_values.push_back(columns[6] + " = " + std::to_string(starting_items_entry.item_charges)); + update_values.push_back(columns[7] + " = " + std::to_string(starting_items_entry.gm)); + update_values.push_back(columns[8] + " = " + std::to_string(starting_items_entry.slot)); + update_values.push_back(columns[9] + " = " + std::to_string(starting_items_entry.min_expansion)); + update_values.push_back(columns[10] + " = " + std::to_string(starting_items_entry.max_expansion)); + update_values.push_back(columns[11] + " = '" + EscapeString(starting_items_entry.content_flags) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + starting_items_entry.race + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static StartingItems InsertOne( + StartingItems starting_items_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(starting_items_entry.class)); + insert_values.push_back(std::to_string(starting_items_entry.deityid)); + insert_values.push_back(std::to_string(starting_items_entry.zoneid)); + insert_values.push_back(std::to_string(starting_items_entry.itemid)); + insert_values.push_back(std::to_string(starting_items_entry.item_charges)); + insert_values.push_back(std::to_string(starting_items_entry.gm)); + insert_values.push_back(std::to_string(starting_items_entry.slot)); + insert_values.push_back(std::to_string(starting_items_entry.min_expansion)); + insert_values.push_back(std::to_string(starting_items_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(starting_items_entry.content_flags) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + starting_items_entry.id = results.LastInsertedID(); + return starting_items_entry; + } + + starting_items_entry = NewEntity(); + + return starting_items_entry; + } + + static int InsertMany( + std::vector starting_items_entries + ) + { + std::vector insert_chunks; + + for (auto &starting_items_entry: starting_items_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(starting_items_entry.class)); + insert_values.push_back(std::to_string(starting_items_entry.deityid)); + insert_values.push_back(std::to_string(starting_items_entry.zoneid)); + insert_values.push_back(std::to_string(starting_items_entry.itemid)); + insert_values.push_back(std::to_string(starting_items_entry.item_charges)); + insert_values.push_back(std::to_string(starting_items_entry.gm)); + insert_values.push_back(std::to_string(starting_items_entry.slot)); + insert_values.push_back(std::to_string(starting_items_entry.min_expansion)); + insert_values.push_back(std::to_string(starting_items_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(starting_items_entry.content_flags) + "'"); + + 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) { + StartingItems entry{}; + + entry.id = atoi(row[0]); + entry.race = atoi(row[1]); + entry.class = atoi(row[2]); + entry.deityid = atoi(row[3]); + entry.zoneid = atoi(row[4]); + entry.itemid = atoi(row[5]); + entry.item_charges = atoi(row[6]); + entry.gm = atoi(row[7]); + entry.slot = atoi(row[8]); + entry.min_expansion = atoi(row[9]); + entry.max_expansion = atoi(row[10]); + entry.content_flags = row[11] ? row[11] : ""; + + 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) { + StartingItems entry{}; + + entry.id = atoi(row[0]); + entry.race = atoi(row[1]); + entry.class = atoi(row[2]); + entry.deityid = atoi(row[3]); + entry.zoneid = atoi(row[4]); + entry.itemid = atoi(row[5]); + entry.item_charges = atoi(row[6]); + entry.gm = atoi(row[7]); + entry.slot = atoi(row[8]); + entry.min_expansion = atoi(row[9]); + entry.max_expansion = atoi(row[10]); + entry.content_flags = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_STARTING_ITEMS_REPOSITORY_H diff --git a/common/repositories/base/base_task_activities_repository.h b/common/repositories/base/base_task_activities_repository.h new file mode 100644 index 000000000..2182bf508 --- /dev/null +++ b/common/repositories/base/base_task_activities_repository.h @@ -0,0 +1,420 @@ +/** + * 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 on Apr 5, 2020 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_TASK_ACTIVITIES_REPOSITORY_H +#define EQEMU_BASE_TASK_ACTIVITIES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseTaskActivitiesRepository { +public: + struct TaskActivities { + int taskid; + int activityid; + int step; + int8 activitytype; + std::string target_name; + std::string item_list; + std::string skill_list; + std::string spell_list; + std::string description_override; + int goalid; + int goalmethod; + int goalcount; + int delivertonpc; + std::string zones; + int8 optional; + }; + + static std::string PrimaryKey() + { + return std::string("activityid"); + } + + static std::vector Columns() + { + return { + "taskid", + "activityid", + "step", + "activitytype", + "target_name", + "item_list", + "skill_list", + "spell_list", + "description_override", + "goalid", + "goalmethod", + "goalcount", + "delivertonpc", + "zones", + "optional", + }; + } + + 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("task_activities"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static TaskActivities NewEntity() + { + TaskActivities entry{}; + + entry.taskid = 0; + entry.activityid = 0; + entry.step = 0; + entry.activitytype = 0; + entry.target_name = ""; + entry.item_list = ""; + entry.skill_list = "-1"; + entry.spell_list = "0"; + entry.description_override = ""; + entry.goalid = 0; + entry.goalmethod = 0; + entry.goalcount = 1; + entry.delivertonpc = 0; + entry.zones = ""; + entry.optional = 0; + + return entry; + } + + static TaskActivities GetTaskActivitiesEntry( + const std::vector &task_activitiess, + int task_activities_id + ) + { + for (auto &task_activities : task_activitiess) { + if (task_activities.activityid == task_activities_id) { + return task_activities; + } + } + + return NewEntity(); + } + + static TaskActivities FindOne( + int task_activities_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + task_activities_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + TaskActivities entry{}; + + entry.taskid = atoi(row[0]); + entry.activityid = atoi(row[1]); + entry.step = atoi(row[2]); + entry.activitytype = atoi(row[3]); + entry.target_name = row[4] ? row[4] : ""; + entry.item_list = row[5] ? row[5] : ""; + entry.skill_list = row[6] ? row[6] : ""; + entry.spell_list = row[7] ? row[7] : ""; + entry.description_override = row[8] ? row[8] : ""; + entry.goalid = atoi(row[9]); + entry.goalmethod = atoi(row[10]); + entry.goalcount = atoi(row[11]); + entry.delivertonpc = atoi(row[12]); + entry.zones = row[13] ? row[13] : ""; + entry.optional = atoi(row[14]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int task_activities_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + task_activities_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + TaskActivities task_activities_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = " + std::to_string(task_activities_entry.step)); + update_values.push_back(columns[3] + " = " + std::to_string(task_activities_entry.activitytype)); + update_values.push_back(columns[4] + " = '" + EscapeString(task_activities_entry.target_name) + "'"); + update_values.push_back(columns[5] + " = '" + EscapeString(task_activities_entry.item_list) + "'"); + update_values.push_back(columns[6] + " = '" + EscapeString(task_activities_entry.skill_list) + "'"); + update_values.push_back(columns[7] + " = '" + EscapeString(task_activities_entry.spell_list) + "'"); + update_values.push_back(columns[8] + " = '" + EscapeString(task_activities_entry.description_override) + "'"); + update_values.push_back(columns[9] + " = " + std::to_string(task_activities_entry.goalid)); + update_values.push_back(columns[10] + " = " + std::to_string(task_activities_entry.goalmethod)); + update_values.push_back(columns[11] + " = " + std::to_string(task_activities_entry.goalcount)); + update_values.push_back(columns[12] + " = " + std::to_string(task_activities_entry.delivertonpc)); + update_values.push_back(columns[13] + " = '" + EscapeString(task_activities_entry.zones) + "'"); + update_values.push_back(columns[14] + " = " + std::to_string(task_activities_entry.optional)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + task_activities_entry.activityid + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static TaskActivities InsertOne( + TaskActivities task_activities_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(task_activities_entry.step)); + insert_values.push_back(std::to_string(task_activities_entry.activitytype)); + insert_values.push_back("'" + EscapeString(task_activities_entry.target_name) + "'"); + insert_values.push_back("'" + EscapeString(task_activities_entry.item_list) + "'"); + insert_values.push_back("'" + EscapeString(task_activities_entry.skill_list) + "'"); + insert_values.push_back("'" + EscapeString(task_activities_entry.spell_list) + "'"); + insert_values.push_back("'" + EscapeString(task_activities_entry.description_override) + "'"); + insert_values.push_back(std::to_string(task_activities_entry.goalid)); + insert_values.push_back(std::to_string(task_activities_entry.goalmethod)); + insert_values.push_back(std::to_string(task_activities_entry.goalcount)); + insert_values.push_back(std::to_string(task_activities_entry.delivertonpc)); + insert_values.push_back("'" + EscapeString(task_activities_entry.zones) + "'"); + insert_values.push_back(std::to_string(task_activities_entry.optional)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + task_activities_entry.id = results.LastInsertedID(); + return task_activities_entry; + } + + task_activities_entry = NewEntity(); + + return task_activities_entry; + } + + static int InsertMany( + std::vector task_activities_entries + ) + { + std::vector insert_chunks; + + for (auto &task_activities_entry: task_activities_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(task_activities_entry.step)); + insert_values.push_back(std::to_string(task_activities_entry.activitytype)); + insert_values.push_back("'" + EscapeString(task_activities_entry.target_name) + "'"); + insert_values.push_back("'" + EscapeString(task_activities_entry.item_list) + "'"); + insert_values.push_back("'" + EscapeString(task_activities_entry.skill_list) + "'"); + insert_values.push_back("'" + EscapeString(task_activities_entry.spell_list) + "'"); + insert_values.push_back("'" + EscapeString(task_activities_entry.description_override) + "'"); + insert_values.push_back(std::to_string(task_activities_entry.goalid)); + insert_values.push_back(std::to_string(task_activities_entry.goalmethod)); + insert_values.push_back(std::to_string(task_activities_entry.goalcount)); + insert_values.push_back(std::to_string(task_activities_entry.delivertonpc)); + insert_values.push_back("'" + EscapeString(task_activities_entry.zones) + "'"); + insert_values.push_back(std::to_string(task_activities_entry.optional)); + + 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) { + TaskActivities entry{}; + + entry.taskid = atoi(row[0]); + entry.activityid = atoi(row[1]); + entry.step = atoi(row[2]); + entry.activitytype = atoi(row[3]); + entry.target_name = row[4] ? row[4] : ""; + entry.item_list = row[5] ? row[5] : ""; + entry.skill_list = row[6] ? row[6] : ""; + entry.spell_list = row[7] ? row[7] : ""; + entry.description_override = row[8] ? row[8] : ""; + entry.goalid = atoi(row[9]); + entry.goalmethod = atoi(row[10]); + entry.goalcount = atoi(row[11]); + entry.delivertonpc = atoi(row[12]); + entry.zones = row[13] ? row[13] : ""; + entry.optional = atoi(row[14]); + + 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) { + TaskActivities entry{}; + + entry.taskid = atoi(row[0]); + entry.activityid = atoi(row[1]); + entry.step = atoi(row[2]); + entry.activitytype = atoi(row[3]); + entry.target_name = row[4] ? row[4] : ""; + entry.item_list = row[5] ? row[5] : ""; + entry.skill_list = row[6] ? row[6] : ""; + entry.spell_list = row[7] ? row[7] : ""; + entry.description_override = row[8] ? row[8] : ""; + entry.goalid = atoi(row[9]); + entry.goalmethod = atoi(row[10]); + entry.goalcount = atoi(row[11]); + entry.delivertonpc = atoi(row[12]); + entry.zones = row[13] ? row[13] : ""; + entry.optional = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_TASK_ACTIVITIES_REPOSITORY_H diff --git a/common/repositories/base/base_tasks_repository.h b/common/repositories/base/base_tasks_repository.h new file mode 100644 index 000000000..042141d8e --- /dev/null +++ b/common/repositories/base/base_tasks_repository.h @@ -0,0 +1,432 @@ +/** + * 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 on Apr 5, 2020 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_TASKS_REPOSITORY_H +#define EQEMU_BASE_TASKS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseTasksRepository { +public: + struct Tasks { + int id; + int8 type; + int duration; + int8 duration_code; + std::string title; + std::string description; + std::string reward; + int rewardid; + int cashreward; + int xpreward; + int8 rewardmethod; + int8 minlevel; + int8 maxlevel; + int8 repeatable; + int faction_reward; + std::string completion_emote; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "type", + "duration", + "duration_code", + "title", + "description", + "reward", + "rewardid", + "cashreward", + "xpreward", + "rewardmethod", + "minlevel", + "maxlevel", + "repeatable", + "faction_reward", + "completion_emote", + }; + } + + 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("tasks"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Tasks NewEntity() + { + Tasks entry{}; + + entry.id = 0; + entry.type = 0; + entry.duration = 0; + entry.duration_code = 0; + entry.title = ""; + entry.description = ""; + entry.reward = ""; + entry.rewardid = 0; + entry.cashreward = 0; + entry.xpreward = 0; + entry.rewardmethod = 2; + entry.minlevel = 0; + entry.maxlevel = 0; + entry.repeatable = 1; + entry.faction_reward = 0; + entry.completion_emote = ""; + + return entry; + } + + static Tasks GetTasksEntry( + const std::vector &taskss, + int tasks_id + ) + { + for (auto &tasks : taskss) { + if (tasks.id == tasks_id) { + return tasks; + } + } + + return NewEntity(); + } + + static Tasks FindOne( + int tasks_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + tasks_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Tasks entry{}; + + entry.id = atoi(row[0]); + entry.type = atoi(row[1]); + entry.duration = atoi(row[2]); + entry.duration_code = atoi(row[3]); + entry.title = row[4] ? row[4] : ""; + entry.description = row[5] ? row[5] : ""; + entry.reward = row[6] ? row[6] : ""; + entry.rewardid = atoi(row[7]); + entry.cashreward = atoi(row[8]); + entry.xpreward = atoi(row[9]); + entry.rewardmethod = atoi(row[10]); + entry.minlevel = atoi(row[11]); + entry.maxlevel = atoi(row[12]); + entry.repeatable = atoi(row[13]); + entry.faction_reward = atoi(row[14]); + entry.completion_emote = row[15] ? row[15] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int tasks_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + tasks_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Tasks tasks_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(tasks_entry.type)); + update_values.push_back(columns[2] + " = " + std::to_string(tasks_entry.duration)); + update_values.push_back(columns[3] + " = " + std::to_string(tasks_entry.duration_code)); + update_values.push_back(columns[4] + " = '" + EscapeString(tasks_entry.title) + "'"); + update_values.push_back(columns[5] + " = '" + EscapeString(tasks_entry.description) + "'"); + update_values.push_back(columns[6] + " = '" + EscapeString(tasks_entry.reward) + "'"); + update_values.push_back(columns[7] + " = " + std::to_string(tasks_entry.rewardid)); + update_values.push_back(columns[8] + " = " + std::to_string(tasks_entry.cashreward)); + update_values.push_back(columns[9] + " = " + std::to_string(tasks_entry.xpreward)); + update_values.push_back(columns[10] + " = " + std::to_string(tasks_entry.rewardmethod)); + update_values.push_back(columns[11] + " = " + std::to_string(tasks_entry.minlevel)); + update_values.push_back(columns[12] + " = " + std::to_string(tasks_entry.maxlevel)); + update_values.push_back(columns[13] + " = " + std::to_string(tasks_entry.repeatable)); + update_values.push_back(columns[14] + " = " + std::to_string(tasks_entry.faction_reward)); + update_values.push_back(columns[15] + " = '" + EscapeString(tasks_entry.completion_emote) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + tasks_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Tasks InsertOne( + Tasks tasks_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(tasks_entry.type)); + insert_values.push_back(std::to_string(tasks_entry.duration)); + insert_values.push_back(std::to_string(tasks_entry.duration_code)); + insert_values.push_back("'" + EscapeString(tasks_entry.title) + "'"); + insert_values.push_back("'" + EscapeString(tasks_entry.description) + "'"); + insert_values.push_back("'" + EscapeString(tasks_entry.reward) + "'"); + insert_values.push_back(std::to_string(tasks_entry.rewardid)); + insert_values.push_back(std::to_string(tasks_entry.cashreward)); + insert_values.push_back(std::to_string(tasks_entry.xpreward)); + insert_values.push_back(std::to_string(tasks_entry.rewardmethod)); + insert_values.push_back(std::to_string(tasks_entry.minlevel)); + insert_values.push_back(std::to_string(tasks_entry.maxlevel)); + insert_values.push_back(std::to_string(tasks_entry.repeatable)); + insert_values.push_back(std::to_string(tasks_entry.faction_reward)); + insert_values.push_back("'" + EscapeString(tasks_entry.completion_emote) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + tasks_entry.id = results.LastInsertedID(); + return tasks_entry; + } + + tasks_entry = NewEntity(); + + return tasks_entry; + } + + static int InsertMany( + std::vector tasks_entries + ) + { + std::vector insert_chunks; + + for (auto &tasks_entry: tasks_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(tasks_entry.type)); + insert_values.push_back(std::to_string(tasks_entry.duration)); + insert_values.push_back(std::to_string(tasks_entry.duration_code)); + insert_values.push_back("'" + EscapeString(tasks_entry.title) + "'"); + insert_values.push_back("'" + EscapeString(tasks_entry.description) + "'"); + insert_values.push_back("'" + EscapeString(tasks_entry.reward) + "'"); + insert_values.push_back(std::to_string(tasks_entry.rewardid)); + insert_values.push_back(std::to_string(tasks_entry.cashreward)); + insert_values.push_back(std::to_string(tasks_entry.xpreward)); + insert_values.push_back(std::to_string(tasks_entry.rewardmethod)); + insert_values.push_back(std::to_string(tasks_entry.minlevel)); + insert_values.push_back(std::to_string(tasks_entry.maxlevel)); + insert_values.push_back(std::to_string(tasks_entry.repeatable)); + insert_values.push_back(std::to_string(tasks_entry.faction_reward)); + insert_values.push_back("'" + EscapeString(tasks_entry.completion_emote) + "'"); + + 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) { + Tasks entry{}; + + entry.id = atoi(row[0]); + entry.type = atoi(row[1]); + entry.duration = atoi(row[2]); + entry.duration_code = atoi(row[3]); + entry.title = row[4] ? row[4] : ""; + entry.description = row[5] ? row[5] : ""; + entry.reward = row[6] ? row[6] : ""; + entry.rewardid = atoi(row[7]); + entry.cashreward = atoi(row[8]); + entry.xpreward = atoi(row[9]); + entry.rewardmethod = atoi(row[10]); + entry.minlevel = atoi(row[11]); + entry.maxlevel = atoi(row[12]); + entry.repeatable = atoi(row[13]); + entry.faction_reward = atoi(row[14]); + entry.completion_emote = row[15] ? row[15] : ""; + + 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) { + Tasks entry{}; + + entry.id = atoi(row[0]); + entry.type = atoi(row[1]); + entry.duration = atoi(row[2]); + entry.duration_code = atoi(row[3]); + entry.title = row[4] ? row[4] : ""; + entry.description = row[5] ? row[5] : ""; + entry.reward = row[6] ? row[6] : ""; + entry.rewardid = atoi(row[7]); + entry.cashreward = atoi(row[8]); + entry.xpreward = atoi(row[9]); + entry.rewardmethod = atoi(row[10]); + entry.minlevel = atoi(row[11]); + entry.maxlevel = atoi(row[12]); + entry.repeatable = atoi(row[13]); + entry.faction_reward = atoi(row[14]); + entry.completion_emote = row[15] ? row[15] : ""; + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_TASKS_REPOSITORY_H diff --git a/common/repositories/base/base_tasksets_repository.h b/common/repositories/base/base_tasksets_repository.h new file mode 100644 index 000000000..84b50f78f --- /dev/null +++ b/common/repositories/base/base_tasksets_repository.h @@ -0,0 +1,306 @@ +/** + * 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 on Apr 5, 2020 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_TASKSETS_REPOSITORY_H +#define EQEMU_BASE_TASKSETS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseTasksetsRepository { +public: + struct Tasksets { + int id; + int taskid; + }; + + static std::string PrimaryKey() + { + return std::string("taskid"); + } + + static std::vector Columns() + { + return { + "id", + "taskid", + }; + } + + 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("tasksets"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Tasksets NewEntity() + { + Tasksets entry{}; + + entry.id = 0; + entry.taskid = 0; + + return entry; + } + + static Tasksets GetTasksetsEntry( + const std::vector &tasksetss, + int tasksets_id + ) + { + for (auto &tasksets : tasksetss) { + if (tasksets.taskid == tasksets_id) { + return tasksets; + } + } + + return NewEntity(); + } + + static Tasksets FindOne( + int tasksets_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + tasksets_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Tasksets entry{}; + + entry.id = atoi(row[0]); + entry.taskid = atoi(row[1]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int tasksets_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + tasksets_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Tasksets tasksets_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + tasksets_entry.taskid + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Tasksets InsertOne( + Tasksets tasksets_entry + ) + { + std::vector insert_values; + + + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + tasksets_entry.id = results.LastInsertedID(); + return tasksets_entry; + } + + tasksets_entry = NewEntity(); + + return tasksets_entry; + } + + static int InsertMany( + std::vector tasksets_entries + ) + { + std::vector insert_chunks; + + for (auto &tasksets_entry: tasksets_entries) { + std::vector insert_values; + + + + 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) { + Tasksets entry{}; + + entry.id = atoi(row[0]); + entry.taskid = 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) { + Tasksets entry{}; + + entry.id = atoi(row[0]); + entry.taskid = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_TASKSETS_REPOSITORY_H diff --git a/common/repositories/base/base_timers_repository.h b/common/repositories/base/base_timers_repository.h new file mode 100644 index 000000000..620a90d7a --- /dev/null +++ b/common/repositories/base/base_timers_repository.h @@ -0,0 +1,330 @@ +/** + * 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 on Apr 5, 2020 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_TIMERS_REPOSITORY_H +#define EQEMU_BASE_TIMERS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseTimersRepository { +public: + struct Timers { + int char_id; + int type; + int start; + int duration; + int8 enable; + }; + + static std::string PrimaryKey() + { + return std::string("type"); + } + + static std::vector Columns() + { + return { + "char_id", + "type", + "start", + "duration", + "enable", + }; + } + + 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("timers"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Timers NewEntity() + { + Timers entry{}; + + entry.char_id = 0; + entry.type = 0; + entry.start = 0; + entry.duration = 0; + entry.enable = 0; + + return entry; + } + + static Timers GetTimersEntry( + const std::vector &timerss, + int timers_id + ) + { + for (auto &timers : timerss) { + if (timers.type == timers_id) { + return timers; + } + } + + return NewEntity(); + } + + static Timers FindOne( + int timers_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + timers_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Timers entry{}; + + entry.char_id = atoi(row[0]); + entry.type = atoi(row[1]); + entry.start = atoi(row[2]); + entry.duration = atoi(row[3]); + entry.enable = atoi(row[4]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int timers_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + timers_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Timers timers_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = " + std::to_string(timers_entry.start)); + update_values.push_back(columns[3] + " = " + std::to_string(timers_entry.duration)); + update_values.push_back(columns[4] + " = " + std::to_string(timers_entry.enable)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + timers_entry.type + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Timers InsertOne( + Timers timers_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(timers_entry.start)); + insert_values.push_back(std::to_string(timers_entry.duration)); + insert_values.push_back(std::to_string(timers_entry.enable)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + timers_entry.id = results.LastInsertedID(); + return timers_entry; + } + + timers_entry = NewEntity(); + + return timers_entry; + } + + static int InsertMany( + std::vector timers_entries + ) + { + std::vector insert_chunks; + + for (auto &timers_entry: timers_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(timers_entry.start)); + insert_values.push_back(std::to_string(timers_entry.duration)); + insert_values.push_back(std::to_string(timers_entry.enable)); + + 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) { + Timers entry{}; + + entry.char_id = atoi(row[0]); + entry.type = atoi(row[1]); + entry.start = atoi(row[2]); + entry.duration = atoi(row[3]); + entry.enable = atoi(row[4]); + + 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) { + Timers entry{}; + + entry.char_id = atoi(row[0]); + entry.type = atoi(row[1]); + entry.start = atoi(row[2]); + entry.duration = atoi(row[3]); + entry.enable = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_TIMERS_REPOSITORY_H diff --git a/common/repositories/base/base_titles_repository.h b/common/repositories/base/base_titles_repository.h new file mode 100644 index 000000000..f0ad144f7 --- /dev/null +++ b/common/repositories/base/base_titles_repository.h @@ -0,0 +1,441 @@ +/** + * 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 on Apr 5, 2020 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_TITLES_REPOSITORY_H +#define EQEMU_BASE_TITLES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseTitlesRepository { +public: + struct Titles { + int id; + int8 skill_id; + int min_skill_value; + int max_skill_value; + int min_aa_points; + int max_aa_points; + int8 class; + int8 gender; + int char_id; + int status; + int item_id; + std::string prefix; + std::string suffix; + int title_set; + int8 min_expansion; + int8 max_expansion; + std::string content_flags; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "skill_id", + "min_skill_value", + "max_skill_value", + "min_aa_points", + "max_aa_points", + "class", + "gender", + "char_id", + "status", + "item_id", + "prefix", + "suffix", + "title_set", + "min_expansion", + "max_expansion", + "content_flags", + }; + } + + 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("titles"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Titles NewEntity() + { + Titles entry{}; + + entry.id = 0; + entry.skill_id = -1; + entry.min_skill_value = -1; + entry.max_skill_value = -1; + entry.min_aa_points = -1; + entry.max_aa_points = -1; + entry.class = -1; + entry.gender = -1; + entry.char_id = -1; + entry.status = -1; + entry.item_id = -1; + entry.prefix = ""; + entry.suffix = ""; + entry.title_set = 0; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; + + return entry; + } + + static Titles GetTitlesEntry( + const std::vector &titless, + int titles_id + ) + { + for (auto &titles : titless) { + if (titles.id == titles_id) { + return titles; + } + } + + return NewEntity(); + } + + static Titles FindOne( + int titles_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + titles_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Titles entry{}; + + entry.id = atoi(row[0]); + entry.skill_id = atoi(row[1]); + entry.min_skill_value = atoi(row[2]); + entry.max_skill_value = atoi(row[3]); + entry.min_aa_points = atoi(row[4]); + entry.max_aa_points = atoi(row[5]); + entry.class = atoi(row[6]); + entry.gender = atoi(row[7]); + entry.char_id = atoi(row[8]); + entry.status = atoi(row[9]); + entry.item_id = atoi(row[10]); + entry.prefix = row[11] ? row[11] : ""; + entry.suffix = row[12] ? row[12] : ""; + entry.title_set = atoi(row[13]); + entry.min_expansion = atoi(row[14]); + entry.max_expansion = atoi(row[15]); + entry.content_flags = row[16] ? row[16] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int titles_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + titles_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Titles titles_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(titles_entry.skill_id)); + update_values.push_back(columns[2] + " = " + std::to_string(titles_entry.min_skill_value)); + update_values.push_back(columns[3] + " = " + std::to_string(titles_entry.max_skill_value)); + update_values.push_back(columns[4] + " = " + std::to_string(titles_entry.min_aa_points)); + update_values.push_back(columns[5] + " = " + std::to_string(titles_entry.max_aa_points)); + update_values.push_back(columns[6] + " = " + std::to_string(titles_entry.class)); + update_values.push_back(columns[7] + " = " + std::to_string(titles_entry.gender)); + update_values.push_back(columns[8] + " = " + std::to_string(titles_entry.char_id)); + update_values.push_back(columns[9] + " = " + std::to_string(titles_entry.status)); + update_values.push_back(columns[10] + " = " + std::to_string(titles_entry.item_id)); + update_values.push_back(columns[11] + " = '" + EscapeString(titles_entry.prefix) + "'"); + update_values.push_back(columns[12] + " = '" + EscapeString(titles_entry.suffix) + "'"); + update_values.push_back(columns[13] + " = " + std::to_string(titles_entry.title_set)); + update_values.push_back(columns[14] + " = " + std::to_string(titles_entry.min_expansion)); + update_values.push_back(columns[15] + " = " + std::to_string(titles_entry.max_expansion)); + update_values.push_back(columns[16] + " = '" + EscapeString(titles_entry.content_flags) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + titles_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Titles InsertOne( + Titles titles_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(titles_entry.skill_id)); + insert_values.push_back(std::to_string(titles_entry.min_skill_value)); + insert_values.push_back(std::to_string(titles_entry.max_skill_value)); + insert_values.push_back(std::to_string(titles_entry.min_aa_points)); + insert_values.push_back(std::to_string(titles_entry.max_aa_points)); + insert_values.push_back(std::to_string(titles_entry.class)); + insert_values.push_back(std::to_string(titles_entry.gender)); + insert_values.push_back(std::to_string(titles_entry.char_id)); + insert_values.push_back(std::to_string(titles_entry.status)); + insert_values.push_back(std::to_string(titles_entry.item_id)); + insert_values.push_back("'" + EscapeString(titles_entry.prefix) + "'"); + insert_values.push_back("'" + EscapeString(titles_entry.suffix) + "'"); + insert_values.push_back(std::to_string(titles_entry.title_set)); + insert_values.push_back(std::to_string(titles_entry.min_expansion)); + insert_values.push_back(std::to_string(titles_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(titles_entry.content_flags) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + titles_entry.id = results.LastInsertedID(); + return titles_entry; + } + + titles_entry = NewEntity(); + + return titles_entry; + } + + static int InsertMany( + std::vector titles_entries + ) + { + std::vector insert_chunks; + + for (auto &titles_entry: titles_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(titles_entry.skill_id)); + insert_values.push_back(std::to_string(titles_entry.min_skill_value)); + insert_values.push_back(std::to_string(titles_entry.max_skill_value)); + insert_values.push_back(std::to_string(titles_entry.min_aa_points)); + insert_values.push_back(std::to_string(titles_entry.max_aa_points)); + insert_values.push_back(std::to_string(titles_entry.class)); + insert_values.push_back(std::to_string(titles_entry.gender)); + insert_values.push_back(std::to_string(titles_entry.char_id)); + insert_values.push_back(std::to_string(titles_entry.status)); + insert_values.push_back(std::to_string(titles_entry.item_id)); + insert_values.push_back("'" + EscapeString(titles_entry.prefix) + "'"); + insert_values.push_back("'" + EscapeString(titles_entry.suffix) + "'"); + insert_values.push_back(std::to_string(titles_entry.title_set)); + insert_values.push_back(std::to_string(titles_entry.min_expansion)); + insert_values.push_back(std::to_string(titles_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(titles_entry.content_flags) + "'"); + + 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) { + Titles entry{}; + + entry.id = atoi(row[0]); + entry.skill_id = atoi(row[1]); + entry.min_skill_value = atoi(row[2]); + entry.max_skill_value = atoi(row[3]); + entry.min_aa_points = atoi(row[4]); + entry.max_aa_points = atoi(row[5]); + entry.class = atoi(row[6]); + entry.gender = atoi(row[7]); + entry.char_id = atoi(row[8]); + entry.status = atoi(row[9]); + entry.item_id = atoi(row[10]); + entry.prefix = row[11] ? row[11] : ""; + entry.suffix = row[12] ? row[12] : ""; + entry.title_set = atoi(row[13]); + entry.min_expansion = atoi(row[14]); + entry.max_expansion = atoi(row[15]); + entry.content_flags = row[16] ? 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) { + Titles entry{}; + + entry.id = atoi(row[0]); + entry.skill_id = atoi(row[1]); + entry.min_skill_value = atoi(row[2]); + entry.max_skill_value = atoi(row[3]); + entry.min_aa_points = atoi(row[4]); + entry.max_aa_points = atoi(row[5]); + entry.class = atoi(row[6]); + entry.gender = atoi(row[7]); + entry.char_id = atoi(row[8]); + entry.status = atoi(row[9]); + entry.item_id = atoi(row[10]); + entry.prefix = row[11] ? row[11] : ""; + entry.suffix = row[12] ? row[12] : ""; + entry.title_set = atoi(row[13]); + entry.min_expansion = atoi(row[14]); + entry.max_expansion = atoi(row[15]); + entry.content_flags = row[16] ? 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_TITLES_REPOSITORY_H diff --git a/common/repositories/base/base_trader_repository.h b/common/repositories/base/base_trader_repository.h new file mode 100644 index 000000000..49f9da6e0 --- /dev/null +++ b/common/repositories/base/base_trader_repository.h @@ -0,0 +1,339 @@ +/** + * 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 on Apr 5, 2020 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_TRADER_REPOSITORY_H +#define EQEMU_BASE_TRADER_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseTraderRepository { +public: + struct Trader { + int char_id; + int item_id; + int serialnumber; + int charges; + int item_cost; + int8 slot_id; + }; + + static std::string PrimaryKey() + { + return std::string("slot_id"); + } + + static std::vector Columns() + { + return { + "char_id", + "item_id", + "serialnumber", + "charges", + "item_cost", + "slot_id", + }; + } + + 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("trader"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Trader NewEntity() + { + Trader entry{}; + + entry.char_id = 0; + entry.item_id = 0; + entry.serialnumber = 0; + entry.charges = 0; + entry.item_cost = 0; + entry.slot_id = 0; + + return entry; + } + + static Trader GetTraderEntry( + const std::vector &traders, + int trader_id + ) + { + for (auto &trader : traders) { + if (trader.slot_id == trader_id) { + return trader; + } + } + + return NewEntity(); + } + + static Trader FindOne( + int trader_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + trader_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Trader entry{}; + + entry.char_id = atoi(row[0]); + entry.item_id = atoi(row[1]); + entry.serialnumber = atoi(row[2]); + entry.charges = atoi(row[3]); + entry.item_cost = atoi(row[4]); + entry.slot_id = atoi(row[5]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int trader_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + trader_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Trader trader_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(trader_entry.item_id)); + update_values.push_back(columns[2] + " = " + std::to_string(trader_entry.serialnumber)); + update_values.push_back(columns[3] + " = " + std::to_string(trader_entry.charges)); + update_values.push_back(columns[4] + " = " + std::to_string(trader_entry.item_cost)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + trader_entry.slot_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Trader InsertOne( + Trader trader_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(trader_entry.item_id)); + insert_values.push_back(std::to_string(trader_entry.serialnumber)); + insert_values.push_back(std::to_string(trader_entry.charges)); + insert_values.push_back(std::to_string(trader_entry.item_cost)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + trader_entry.id = results.LastInsertedID(); + return trader_entry; + } + + trader_entry = NewEntity(); + + return trader_entry; + } + + static int InsertMany( + std::vector trader_entries + ) + { + std::vector insert_chunks; + + for (auto &trader_entry: trader_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(trader_entry.item_id)); + insert_values.push_back(std::to_string(trader_entry.serialnumber)); + insert_values.push_back(std::to_string(trader_entry.charges)); + insert_values.push_back(std::to_string(trader_entry.item_cost)); + + 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) { + Trader entry{}; + + entry.char_id = atoi(row[0]); + entry.item_id = atoi(row[1]); + entry.serialnumber = atoi(row[2]); + entry.charges = atoi(row[3]); + entry.item_cost = atoi(row[4]); + entry.slot_id = atoi(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) { + Trader entry{}; + + entry.char_id = atoi(row[0]); + entry.item_id = atoi(row[1]); + entry.serialnumber = atoi(row[2]); + entry.charges = atoi(row[3]); + entry.item_cost = atoi(row[4]); + entry.slot_id = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_TRADER_REPOSITORY_H diff --git a/common/repositories/base/base_tradeskill_recipe_entries_repository.h b/common/repositories/base/base_tradeskill_recipe_entries_repository.h new file mode 100644 index 000000000..23b2afbc2 --- /dev/null +++ b/common/repositories/base/base_tradeskill_recipe_entries_repository.h @@ -0,0 +1,360 @@ +/** + * 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 on Apr 5, 2020 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_TRADESKILL_RECIPE_ENTRIES_REPOSITORY_H +#define EQEMU_BASE_TRADESKILL_RECIPE_ENTRIES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseTradeskillRecipeEntriesRepository { +public: + struct TradeskillRecipeEntries { + int id; + int recipe_id; + int item_id; + int8 successcount; + int8 failcount; + int8 componentcount; + int8 salvagecount; + int8 iscontainer; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "recipe_id", + "item_id", + "successcount", + "failcount", + "componentcount", + "salvagecount", + "iscontainer", + }; + } + + 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("tradeskill_recipe_entries"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static TradeskillRecipeEntries NewEntity() + { + TradeskillRecipeEntries entry{}; + + entry.id = 0; + entry.recipe_id = 0; + entry.item_id = 0; + entry.successcount = 0; + entry.failcount = 0; + entry.componentcount = 1; + entry.salvagecount = 0; + entry.iscontainer = 0; + + return entry; + } + + static TradeskillRecipeEntries GetTradeskillRecipeEntriesEntry( + const std::vector &tradeskill_recipe_entriess, + int tradeskill_recipe_entries_id + ) + { + for (auto &tradeskill_recipe_entries : tradeskill_recipe_entriess) { + if (tradeskill_recipe_entries.id == tradeskill_recipe_entries_id) { + return tradeskill_recipe_entries; + } + } + + return NewEntity(); + } + + static TradeskillRecipeEntries FindOne( + int tradeskill_recipe_entries_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + tradeskill_recipe_entries_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + TradeskillRecipeEntries entry{}; + + entry.id = atoi(row[0]); + entry.recipe_id = atoi(row[1]); + entry.item_id = atoi(row[2]); + entry.successcount = atoi(row[3]); + entry.failcount = atoi(row[4]); + entry.componentcount = atoi(row[5]); + entry.salvagecount = atoi(row[6]); + entry.iscontainer = atoi(row[7]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int tradeskill_recipe_entries_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + tradeskill_recipe_entries_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + TradeskillRecipeEntries tradeskill_recipe_entries_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(tradeskill_recipe_entries_entry.recipe_id)); + update_values.push_back(columns[2] + " = " + std::to_string(tradeskill_recipe_entries_entry.item_id)); + update_values.push_back(columns[3] + " = " + std::to_string(tradeskill_recipe_entries_entry.successcount)); + update_values.push_back(columns[4] + " = " + std::to_string(tradeskill_recipe_entries_entry.failcount)); + update_values.push_back(columns[5] + " = " + std::to_string(tradeskill_recipe_entries_entry.componentcount)); + update_values.push_back(columns[6] + " = " + std::to_string(tradeskill_recipe_entries_entry.salvagecount)); + update_values.push_back(columns[7] + " = " + std::to_string(tradeskill_recipe_entries_entry.iscontainer)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + tradeskill_recipe_entries_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static TradeskillRecipeEntries InsertOne( + TradeskillRecipeEntries tradeskill_recipe_entries_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.recipe_id)); + insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.item_id)); + insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.successcount)); + insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.failcount)); + insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.componentcount)); + insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.salvagecount)); + insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.iscontainer)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + tradeskill_recipe_entries_entry.id = results.LastInsertedID(); + return tradeskill_recipe_entries_entry; + } + + tradeskill_recipe_entries_entry = NewEntity(); + + return tradeskill_recipe_entries_entry; + } + + static int InsertMany( + std::vector tradeskill_recipe_entries_entries + ) + { + std::vector insert_chunks; + + for (auto &tradeskill_recipe_entries_entry: tradeskill_recipe_entries_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.recipe_id)); + insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.item_id)); + insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.successcount)); + insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.failcount)); + insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.componentcount)); + insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.salvagecount)); + insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.iscontainer)); + + 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) { + TradeskillRecipeEntries entry{}; + + entry.id = atoi(row[0]); + entry.recipe_id = atoi(row[1]); + entry.item_id = atoi(row[2]); + entry.successcount = atoi(row[3]); + entry.failcount = atoi(row[4]); + entry.componentcount = atoi(row[5]); + entry.salvagecount = atoi(row[6]); + entry.iscontainer = atoi(row[7]); + + 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) { + TradeskillRecipeEntries entry{}; + + entry.id = atoi(row[0]); + entry.recipe_id = atoi(row[1]); + entry.item_id = atoi(row[2]); + entry.successcount = atoi(row[3]); + entry.failcount = atoi(row[4]); + entry.componentcount = atoi(row[5]); + entry.salvagecount = atoi(row[6]); + entry.iscontainer = atoi(row[7]); + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_TRADESKILL_RECIPE_ENTRIES_REPOSITORY_H diff --git a/common/repositories/base/base_tradeskill_recipe_repository.h b/common/repositories/base/base_tradeskill_recipe_repository.h new file mode 100644 index 000000000..58ca82916 --- /dev/null +++ b/common/repositories/base/base_tradeskill_recipe_repository.h @@ -0,0 +1,414 @@ +/** + * 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 on Apr 5, 2020 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_TRADESKILL_RECIPE_REPOSITORY_H +#define EQEMU_BASE_TRADESKILL_RECIPE_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseTradeskillRecipeRepository { +public: + struct TradeskillRecipe { + int id; + std::string name; + int16 tradeskill; + int16 skillneeded; + int16 trivial; + int8 nofail; + int8 replace_container; + std::string notes; + int8 must_learn; + int8 quest; + int8 enabled; + int8 min_expansion; + int8 max_expansion; + std::string content_flags; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "name", + "tradeskill", + "skillneeded", + "trivial", + "nofail", + "replace_container", + "notes", + "must_learn", + "quest", + "enabled", + "min_expansion", + "max_expansion", + "content_flags", + }; + } + + 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("tradeskill_recipe"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static TradeskillRecipe NewEntity() + { + TradeskillRecipe entry{}; + + entry.id = 0; + entry.name = ""; + entry.tradeskill = 0; + entry.skillneeded = 0; + entry.trivial = 0; + entry.nofail = 0; + entry.replace_container = 0; + entry.notes = ""; + entry.must_learn = 0; + entry.quest = 0; + entry.enabled = 1; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; + + return entry; + } + + static TradeskillRecipe GetTradeskillRecipeEntry( + const std::vector &tradeskill_recipes, + int tradeskill_recipe_id + ) + { + for (auto &tradeskill_recipe : tradeskill_recipes) { + if (tradeskill_recipe.id == tradeskill_recipe_id) { + return tradeskill_recipe; + } + } + + return NewEntity(); + } + + static TradeskillRecipe FindOne( + int tradeskill_recipe_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + tradeskill_recipe_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + TradeskillRecipe entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.tradeskill = atoi(row[2]); + entry.skillneeded = atoi(row[3]); + entry.trivial = atoi(row[4]); + entry.nofail = atoi(row[5]); + entry.replace_container = atoi(row[6]); + entry.notes = row[7] ? row[7] : ""; + entry.must_learn = atoi(row[8]); + entry.quest = atoi(row[9]); + entry.enabled = atoi(row[10]); + entry.min_expansion = atoi(row[11]); + entry.max_expansion = atoi(row[12]); + entry.content_flags = row[13] ? row[13] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int tradeskill_recipe_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + tradeskill_recipe_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + TradeskillRecipe tradeskill_recipe_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(tradeskill_recipe_entry.name) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(tradeskill_recipe_entry.tradeskill)); + update_values.push_back(columns[3] + " = " + std::to_string(tradeskill_recipe_entry.skillneeded)); + update_values.push_back(columns[4] + " = " + std::to_string(tradeskill_recipe_entry.trivial)); + update_values.push_back(columns[5] + " = " + std::to_string(tradeskill_recipe_entry.nofail)); + update_values.push_back(columns[6] + " = " + std::to_string(tradeskill_recipe_entry.replace_container)); + update_values.push_back(columns[7] + " = '" + EscapeString(tradeskill_recipe_entry.notes) + "'"); + update_values.push_back(columns[8] + " = " + std::to_string(tradeskill_recipe_entry.must_learn)); + update_values.push_back(columns[9] + " = " + std::to_string(tradeskill_recipe_entry.quest)); + update_values.push_back(columns[10] + " = " + std::to_string(tradeskill_recipe_entry.enabled)); + update_values.push_back(columns[11] + " = " + std::to_string(tradeskill_recipe_entry.min_expansion)); + update_values.push_back(columns[12] + " = " + std::to_string(tradeskill_recipe_entry.max_expansion)); + update_values.push_back(columns[13] + " = '" + EscapeString(tradeskill_recipe_entry.content_flags) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + tradeskill_recipe_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static TradeskillRecipe InsertOne( + TradeskillRecipe tradeskill_recipe_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.name) + "'"); + insert_values.push_back(std::to_string(tradeskill_recipe_entry.tradeskill)); + insert_values.push_back(std::to_string(tradeskill_recipe_entry.skillneeded)); + insert_values.push_back(std::to_string(tradeskill_recipe_entry.trivial)); + insert_values.push_back(std::to_string(tradeskill_recipe_entry.nofail)); + insert_values.push_back(std::to_string(tradeskill_recipe_entry.replace_container)); + insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.notes) + "'"); + insert_values.push_back(std::to_string(tradeskill_recipe_entry.must_learn)); + insert_values.push_back(std::to_string(tradeskill_recipe_entry.quest)); + insert_values.push_back(std::to_string(tradeskill_recipe_entry.enabled)); + insert_values.push_back(std::to_string(tradeskill_recipe_entry.min_expansion)); + insert_values.push_back(std::to_string(tradeskill_recipe_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.content_flags) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + tradeskill_recipe_entry.id = results.LastInsertedID(); + return tradeskill_recipe_entry; + } + + tradeskill_recipe_entry = NewEntity(); + + return tradeskill_recipe_entry; + } + + static int InsertMany( + std::vector tradeskill_recipe_entries + ) + { + std::vector insert_chunks; + + for (auto &tradeskill_recipe_entry: tradeskill_recipe_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.name) + "'"); + insert_values.push_back(std::to_string(tradeskill_recipe_entry.tradeskill)); + insert_values.push_back(std::to_string(tradeskill_recipe_entry.skillneeded)); + insert_values.push_back(std::to_string(tradeskill_recipe_entry.trivial)); + insert_values.push_back(std::to_string(tradeskill_recipe_entry.nofail)); + insert_values.push_back(std::to_string(tradeskill_recipe_entry.replace_container)); + insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.notes) + "'"); + insert_values.push_back(std::to_string(tradeskill_recipe_entry.must_learn)); + insert_values.push_back(std::to_string(tradeskill_recipe_entry.quest)); + insert_values.push_back(std::to_string(tradeskill_recipe_entry.enabled)); + insert_values.push_back(std::to_string(tradeskill_recipe_entry.min_expansion)); + insert_values.push_back(std::to_string(tradeskill_recipe_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(tradeskill_recipe_entry.content_flags) + "'"); + + 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) { + TradeskillRecipe entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.tradeskill = atoi(row[2]); + entry.skillneeded = atoi(row[3]); + entry.trivial = atoi(row[4]); + entry.nofail = atoi(row[5]); + entry.replace_container = atoi(row[6]); + entry.notes = row[7] ? row[7] : ""; + entry.must_learn = atoi(row[8]); + entry.quest = atoi(row[9]); + entry.enabled = atoi(row[10]); + entry.min_expansion = atoi(row[11]); + entry.max_expansion = atoi(row[12]); + entry.content_flags = row[13] ? row[13] : ""; + + 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) { + TradeskillRecipe entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.tradeskill = atoi(row[2]); + entry.skillneeded = atoi(row[3]); + entry.trivial = atoi(row[4]); + entry.nofail = atoi(row[5]); + entry.replace_container = atoi(row[6]); + entry.notes = row[7] ? row[7] : ""; + entry.must_learn = atoi(row[8]); + entry.quest = atoi(row[9]); + entry.enabled = atoi(row[10]); + entry.min_expansion = atoi(row[11]); + entry.max_expansion = atoi(row[12]); + entry.content_flags = row[13] ? 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_TRADESKILL_RECIPE_REPOSITORY_H diff --git a/common/repositories/base/base_traps_repository.h b/common/repositories/base/base_traps_repository.h new file mode 100644 index 000000000..679083ba8 --- /dev/null +++ b/common/repositories/base/base_traps_repository.h @@ -0,0 +1,504 @@ +/** + * 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 on Apr 5, 2020 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_TRAPS_REPOSITORY_H +#define EQEMU_BASE_TRAPS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseTrapsRepository { +public: + struct Traps { + int id; + std::string zone; + int16 version; + int x; + int y; + int z; + int8 chance; + float maxzdiff; + float radius; + int effect; + int effectvalue; + int effectvalue2; + std::string message; + int skill; + int level; + int respawn_time; + int respawn_var; + int8 triggered_number; + int8 group; + int8 despawn_when_triggered; + int8 undetectable; + int8 min_expansion; + int8 max_expansion; + std::string content_flags; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "zone", + "version", + "x", + "y", + "z", + "chance", + "maxzdiff", + "radius", + "effect", + "effectvalue", + "effectvalue2", + "message", + "skill", + "level", + "respawn_time", + "respawn_var", + "triggered_number", + "group", + "despawn_when_triggered", + "undetectable", + "min_expansion", + "max_expansion", + "content_flags", + }; + } + + 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("traps"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Traps NewEntity() + { + Traps entry{}; + + entry.id = 0; + entry.zone = ""; + entry.version = 0; + entry.x = 0; + entry.y = 0; + entry.z = 0; + entry.chance = 0; + entry.maxzdiff = 0; + entry.radius = 0; + entry.effect = 0; + entry.effectvalue = 0; + entry.effectvalue2 = 0; + entry.message = ""; + entry.skill = 0; + entry.level = 1; + entry.respawn_time = 60; + entry.respawn_var = 0; + entry.triggered_number = 0; + entry.group = 0; + entry.despawn_when_triggered = 0; + entry.undetectable = 0; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; + + return entry; + } + + static Traps GetTrapsEntry( + const std::vector &trapss, + int traps_id + ) + { + for (auto &traps : trapss) { + if (traps.id == traps_id) { + return traps; + } + } + + return NewEntity(); + } + + static Traps FindOne( + int traps_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + traps_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Traps entry{}; + + entry.id = atoi(row[0]); + entry.zone = row[1] ? row[1] : ""; + entry.version = atoi(row[2]); + entry.x = atoi(row[3]); + entry.y = atoi(row[4]); + entry.z = atoi(row[5]); + entry.chance = atoi(row[6]); + entry.maxzdiff = atof(row[7]); + entry.radius = atof(row[8]); + entry.effect = atoi(row[9]); + entry.effectvalue = atoi(row[10]); + entry.effectvalue2 = atoi(row[11]); + entry.message = row[12] ? row[12] : ""; + entry.skill = atoi(row[13]); + entry.level = atoi(row[14]); + entry.respawn_time = atoi(row[15]); + entry.respawn_var = atoi(row[16]); + entry.triggered_number = atoi(row[17]); + entry.group = atoi(row[18]); + entry.despawn_when_triggered = atoi(row[19]); + entry.undetectable = atoi(row[20]); + entry.min_expansion = atoi(row[21]); + entry.max_expansion = atoi(row[22]); + entry.content_flags = row[23] ? row[23] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int traps_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + traps_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Traps traps_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(traps_entry.zone) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(traps_entry.version)); + update_values.push_back(columns[3] + " = " + std::to_string(traps_entry.x)); + update_values.push_back(columns[4] + " = " + std::to_string(traps_entry.y)); + update_values.push_back(columns[5] + " = " + std::to_string(traps_entry.z)); + update_values.push_back(columns[6] + " = " + std::to_string(traps_entry.chance)); + update_values.push_back(columns[7] + " = " + std::to_string(traps_entry.maxzdiff)); + update_values.push_back(columns[8] + " = " + std::to_string(traps_entry.radius)); + update_values.push_back(columns[9] + " = " + std::to_string(traps_entry.effect)); + update_values.push_back(columns[10] + " = " + std::to_string(traps_entry.effectvalue)); + update_values.push_back(columns[11] + " = " + std::to_string(traps_entry.effectvalue2)); + update_values.push_back(columns[12] + " = '" + EscapeString(traps_entry.message) + "'"); + update_values.push_back(columns[13] + " = " + std::to_string(traps_entry.skill)); + update_values.push_back(columns[14] + " = " + std::to_string(traps_entry.level)); + update_values.push_back(columns[15] + " = " + std::to_string(traps_entry.respawn_time)); + update_values.push_back(columns[16] + " = " + std::to_string(traps_entry.respawn_var)); + update_values.push_back(columns[17] + " = " + std::to_string(traps_entry.triggered_number)); + update_values.push_back(columns[18] + " = " + std::to_string(traps_entry.group)); + update_values.push_back(columns[19] + " = " + std::to_string(traps_entry.despawn_when_triggered)); + update_values.push_back(columns[20] + " = " + std::to_string(traps_entry.undetectable)); + update_values.push_back(columns[21] + " = " + std::to_string(traps_entry.min_expansion)); + update_values.push_back(columns[22] + " = " + std::to_string(traps_entry.max_expansion)); + update_values.push_back(columns[23] + " = '" + EscapeString(traps_entry.content_flags) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + traps_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Traps InsertOne( + Traps traps_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(traps_entry.zone) + "'"); + insert_values.push_back(std::to_string(traps_entry.version)); + insert_values.push_back(std::to_string(traps_entry.x)); + insert_values.push_back(std::to_string(traps_entry.y)); + insert_values.push_back(std::to_string(traps_entry.z)); + insert_values.push_back(std::to_string(traps_entry.chance)); + insert_values.push_back(std::to_string(traps_entry.maxzdiff)); + insert_values.push_back(std::to_string(traps_entry.radius)); + insert_values.push_back(std::to_string(traps_entry.effect)); + insert_values.push_back(std::to_string(traps_entry.effectvalue)); + insert_values.push_back(std::to_string(traps_entry.effectvalue2)); + insert_values.push_back("'" + EscapeString(traps_entry.message) + "'"); + insert_values.push_back(std::to_string(traps_entry.skill)); + insert_values.push_back(std::to_string(traps_entry.level)); + insert_values.push_back(std::to_string(traps_entry.respawn_time)); + insert_values.push_back(std::to_string(traps_entry.respawn_var)); + insert_values.push_back(std::to_string(traps_entry.triggered_number)); + insert_values.push_back(std::to_string(traps_entry.group)); + insert_values.push_back(std::to_string(traps_entry.despawn_when_triggered)); + insert_values.push_back(std::to_string(traps_entry.undetectable)); + insert_values.push_back(std::to_string(traps_entry.min_expansion)); + insert_values.push_back(std::to_string(traps_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(traps_entry.content_flags) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + traps_entry.id = results.LastInsertedID(); + return traps_entry; + } + + traps_entry = NewEntity(); + + return traps_entry; + } + + static int InsertMany( + std::vector traps_entries + ) + { + std::vector insert_chunks; + + for (auto &traps_entry: traps_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(traps_entry.zone) + "'"); + insert_values.push_back(std::to_string(traps_entry.version)); + insert_values.push_back(std::to_string(traps_entry.x)); + insert_values.push_back(std::to_string(traps_entry.y)); + insert_values.push_back(std::to_string(traps_entry.z)); + insert_values.push_back(std::to_string(traps_entry.chance)); + insert_values.push_back(std::to_string(traps_entry.maxzdiff)); + insert_values.push_back(std::to_string(traps_entry.radius)); + insert_values.push_back(std::to_string(traps_entry.effect)); + insert_values.push_back(std::to_string(traps_entry.effectvalue)); + insert_values.push_back(std::to_string(traps_entry.effectvalue2)); + insert_values.push_back("'" + EscapeString(traps_entry.message) + "'"); + insert_values.push_back(std::to_string(traps_entry.skill)); + insert_values.push_back(std::to_string(traps_entry.level)); + insert_values.push_back(std::to_string(traps_entry.respawn_time)); + insert_values.push_back(std::to_string(traps_entry.respawn_var)); + insert_values.push_back(std::to_string(traps_entry.triggered_number)); + insert_values.push_back(std::to_string(traps_entry.group)); + insert_values.push_back(std::to_string(traps_entry.despawn_when_triggered)); + insert_values.push_back(std::to_string(traps_entry.undetectable)); + insert_values.push_back(std::to_string(traps_entry.min_expansion)); + insert_values.push_back(std::to_string(traps_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(traps_entry.content_flags) + "'"); + + 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) { + Traps entry{}; + + entry.id = atoi(row[0]); + entry.zone = row[1] ? row[1] : ""; + entry.version = atoi(row[2]); + entry.x = atoi(row[3]); + entry.y = atoi(row[4]); + entry.z = atoi(row[5]); + entry.chance = atoi(row[6]); + entry.maxzdiff = atof(row[7]); + entry.radius = atof(row[8]); + entry.effect = atoi(row[9]); + entry.effectvalue = atoi(row[10]); + entry.effectvalue2 = atoi(row[11]); + entry.message = row[12] ? row[12] : ""; + entry.skill = atoi(row[13]); + entry.level = atoi(row[14]); + entry.respawn_time = atoi(row[15]); + entry.respawn_var = atoi(row[16]); + entry.triggered_number = atoi(row[17]); + entry.group = atoi(row[18]); + entry.despawn_when_triggered = atoi(row[19]); + entry.undetectable = atoi(row[20]); + entry.min_expansion = atoi(row[21]); + entry.max_expansion = atoi(row[22]); + entry.content_flags = row[23] ? row[23] : ""; + + 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) { + Traps entry{}; + + entry.id = atoi(row[0]); + entry.zone = row[1] ? row[1] : ""; + entry.version = atoi(row[2]); + entry.x = atoi(row[3]); + entry.y = atoi(row[4]); + entry.z = atoi(row[5]); + entry.chance = atoi(row[6]); + entry.maxzdiff = atof(row[7]); + entry.radius = atof(row[8]); + entry.effect = atoi(row[9]); + entry.effectvalue = atoi(row[10]); + entry.effectvalue2 = atoi(row[11]); + entry.message = row[12] ? row[12] : ""; + entry.skill = atoi(row[13]); + entry.level = atoi(row[14]); + entry.respawn_time = atoi(row[15]); + entry.respawn_var = atoi(row[16]); + entry.triggered_number = atoi(row[17]); + entry.group = atoi(row[18]); + entry.despawn_when_triggered = atoi(row[19]); + entry.undetectable = atoi(row[20]); + entry.min_expansion = atoi(row[21]); + entry.max_expansion = atoi(row[22]); + entry.content_flags = row[23] ? row[23] : ""; + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_TRAPS_REPOSITORY_H diff --git a/common/repositories/base/base_tribute_levels_repository.h b/common/repositories/base/base_tribute_levels_repository.h new file mode 100644 index 000000000..a821b9055 --- /dev/null +++ b/common/repositories/base/base_tribute_levels_repository.h @@ -0,0 +1,321 @@ +/** + * 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 on Apr 5, 2020 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_TRIBUTE_LEVELS_REPOSITORY_H +#define EQEMU_BASE_TRIBUTE_LEVELS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseTributeLevelsRepository { +public: + struct TributeLevels { + int tribute_id; + int level; + int cost; + int item_id; + }; + + static std::string PrimaryKey() + { + return std::string("level"); + } + + static std::vector Columns() + { + return { + "tribute_id", + "level", + "cost", + "item_id", + }; + } + + 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("tribute_levels"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static TributeLevels NewEntity() + { + TributeLevels entry{}; + + entry.tribute_id = 0; + entry.level = 0; + entry.cost = 0; + entry.item_id = 0; + + return entry; + } + + static TributeLevels GetTributeLevelsEntry( + const std::vector &tribute_levelss, + int tribute_levels_id + ) + { + for (auto &tribute_levels : tribute_levelss) { + if (tribute_levels.level == tribute_levels_id) { + return tribute_levels; + } + } + + return NewEntity(); + } + + static TributeLevels FindOne( + int tribute_levels_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + tribute_levels_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + TributeLevels entry{}; + + entry.tribute_id = atoi(row[0]); + entry.level = atoi(row[1]); + entry.cost = atoi(row[2]); + entry.item_id = atoi(row[3]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int tribute_levels_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + tribute_levels_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + TributeLevels tribute_levels_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[2] + " = " + std::to_string(tribute_levels_entry.cost)); + update_values.push_back(columns[3] + " = " + std::to_string(tribute_levels_entry.item_id)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + tribute_levels_entry.level + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static TributeLevels InsertOne( + TributeLevels tribute_levels_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(tribute_levels_entry.cost)); + insert_values.push_back(std::to_string(tribute_levels_entry.item_id)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + tribute_levels_entry.id = results.LastInsertedID(); + return tribute_levels_entry; + } + + tribute_levels_entry = NewEntity(); + + return tribute_levels_entry; + } + + static int InsertMany( + std::vector tribute_levels_entries + ) + { + std::vector insert_chunks; + + for (auto &tribute_levels_entry: tribute_levels_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(tribute_levels_entry.cost)); + insert_values.push_back(std::to_string(tribute_levels_entry.item_id)); + + 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) { + TributeLevels entry{}; + + entry.tribute_id = atoi(row[0]); + entry.level = atoi(row[1]); + entry.cost = atoi(row[2]); + entry.item_id = 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 = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + TributeLevels entry{}; + + entry.tribute_id = atoi(row[0]); + entry.level = atoi(row[1]); + entry.cost = 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 = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_TRIBUTE_LEVELS_REPOSITORY_H diff --git a/common/repositories/base/base_tributes_repository.h b/common/repositories/base/base_tributes_repository.h new file mode 100644 index 000000000..fe8ac3ed4 --- /dev/null +++ b/common/repositories/base/base_tributes_repository.h @@ -0,0 +1,330 @@ +/** + * 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 on Apr 5, 2020 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_TRIBUTES_REPOSITORY_H +#define EQEMU_BASE_TRIBUTES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseTributesRepository { +public: + struct Tributes { + int id; + int unknown; + std::string name; + std::string descr; + int8 isguild; + }; + + static std::string PrimaryKey() + { + return std::string("isguild"); + } + + static std::vector Columns() + { + return { + "id", + "unknown", + "name", + "descr", + "isguild", + }; + } + + 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("tributes"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Tributes NewEntity() + { + Tributes entry{}; + + entry.id = 0; + entry.unknown = 0; + entry.name = ""; + entry.descr = ""; + entry.isguild = 0; + + return entry; + } + + static Tributes GetTributesEntry( + const std::vector &tributess, + int tributes_id + ) + { + for (auto &tributes : tributess) { + if (tributes.isguild == tributes_id) { + return tributes; + } + } + + return NewEntity(); + } + + static Tributes FindOne( + int tributes_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + tributes_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Tributes entry{}; + + entry.id = atoi(row[0]); + entry.unknown = atoi(row[1]); + entry.name = row[2] ? row[2] : ""; + entry.descr = row[3] ? row[3] : ""; + entry.isguild = atoi(row[4]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int tributes_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + tributes_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Tributes tributes_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = " + std::to_string(tributes_entry.unknown)); + update_values.push_back(columns[2] + " = '" + EscapeString(tributes_entry.name) + "'"); + update_values.push_back(columns[3] + " = '" + EscapeString(tributes_entry.descr) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + tributes_entry.isguild + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Tributes InsertOne( + Tributes tributes_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(tributes_entry.unknown)); + insert_values.push_back("'" + EscapeString(tributes_entry.name) + "'"); + insert_values.push_back("'" + EscapeString(tributes_entry.descr) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + tributes_entry.id = results.LastInsertedID(); + return tributes_entry; + } + + tributes_entry = NewEntity(); + + return tributes_entry; + } + + static int InsertMany( + std::vector tributes_entries + ) + { + std::vector insert_chunks; + + for (auto &tributes_entry: tributes_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(tributes_entry.unknown)); + insert_values.push_back("'" + EscapeString(tributes_entry.name) + "'"); + insert_values.push_back("'" + EscapeString(tributes_entry.descr) + "'"); + + 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) { + Tributes entry{}; + + entry.id = atoi(row[0]); + entry.unknown = atoi(row[1]); + entry.name = row[2] ? row[2] : ""; + entry.descr = row[3] ? row[3] : ""; + entry.isguild = atoi(row[4]); + + 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) { + Tributes entry{}; + + entry.id = atoi(row[0]); + entry.unknown = atoi(row[1]); + entry.name = row[2] ? row[2] : ""; + entry.descr = row[3] ? row[3] : ""; + entry.isguild = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_TRIBUTES_REPOSITORY_H diff --git a/common/repositories/base/base_variables_repository.h b/common/repositories/base/base_variables_repository.h new file mode 100644 index 000000000..a7635a3ae --- /dev/null +++ b/common/repositories/base/base_variables_repository.h @@ -0,0 +1,324 @@ +/** + * 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 on Apr 5, 2020 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_VARIABLES_REPOSITORY_H +#define EQEMU_BASE_VARIABLES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseVariablesRepository { +public: + struct Variables { + std::string varname; + std::string value; + std::string information; + std::string ts; + }; + + static std::string PrimaryKey() + { + return std::string("varname"); + } + + static std::vector Columns() + { + return { + "varname", + "value", + "information", + "ts", + }; + } + + 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("variables"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Variables NewEntity() + { + Variables entry{}; + + entry.varname = ""; + entry.value = ""; + entry.information = ""; + entry.ts = current_timestamp(); + + return entry; + } + + static Variables GetVariablesEntry( + const std::vector &variabless, + int variables_id + ) + { + for (auto &variables : variabless) { + if (variables.varname == variables_id) { + return variables; + } + } + + return NewEntity(); + } + + static Variables FindOne( + int variables_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + variables_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Variables entry{}; + + entry.varname = row[0] ? row[0] : ""; + entry.value = row[1] ? row[1] : ""; + entry.information = row[2] ? row[2] : ""; + entry.ts = row[3] ? row[3] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int variables_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + variables_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Variables variables_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(variables_entry.value) + "'"); + update_values.push_back(columns[2] + " = '" + EscapeString(variables_entry.information) + "'"); + update_values.push_back(columns[3] + " = '" + EscapeString(variables_entry.ts) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + variables_entry.varname + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Variables InsertOne( + Variables variables_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(variables_entry.value) + "'"); + insert_values.push_back("'" + EscapeString(variables_entry.information) + "'"); + insert_values.push_back("'" + EscapeString(variables_entry.ts) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + variables_entry.id = results.LastInsertedID(); + return variables_entry; + } + + variables_entry = NewEntity(); + + return variables_entry; + } + + static int InsertMany( + std::vector variables_entries + ) + { + std::vector insert_chunks; + + for (auto &variables_entry: variables_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(variables_entry.value) + "'"); + insert_values.push_back("'" + EscapeString(variables_entry.information) + "'"); + insert_values.push_back("'" + EscapeString(variables_entry.ts) + "'"); + + 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) { + Variables entry{}; + + entry.varname = row[0] ? row[0] : ""; + entry.value = row[1] ? row[1] : ""; + entry.information = row[2] ? row[2] : ""; + entry.ts = row[3] ? 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) { + Variables entry{}; + + entry.varname = row[0] ? row[0] : ""; + entry.value = row[1] ? row[1] : ""; + entry.information = row[2] ? row[2] : ""; + entry.ts = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_VARIABLES_REPOSITORY_H diff --git a/common/repositories/base/base_veteran_reward_templates_repository.h b/common/repositories/base/base_veteran_reward_templates_repository.h new file mode 100644 index 000000000..6ad7e1093 --- /dev/null +++ b/common/repositories/base/base_veteran_reward_templates_repository.h @@ -0,0 +1,330 @@ +/** + * 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 on Apr 5, 2020 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_VETERAN_REWARD_TEMPLATES_REPOSITORY_H +#define EQEMU_BASE_VETERAN_REWARD_TEMPLATES_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseVeteranRewardTemplatesRepository { +public: + struct VeteranRewardTemplates { + int claim_id; + std::string name; + int item_id; + int16 charges; + int8 reward_slot; + }; + + static std::string PrimaryKey() + { + return std::string("reward_slot"); + } + + static std::vector Columns() + { + return { + "claim_id", + "name", + "item_id", + "charges", + "reward_slot", + }; + } + + 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("veteran_reward_templates"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static VeteranRewardTemplates NewEntity() + { + VeteranRewardTemplates entry{}; + + entry.claim_id = 0; + entry.name = ""; + entry.item_id = 0; + entry.charges = 0; + entry.reward_slot = 0; + + return entry; + } + + static VeteranRewardTemplates GetVeteranRewardTemplatesEntry( + const std::vector &veteran_reward_templatess, + int veteran_reward_templates_id + ) + { + for (auto &veteran_reward_templates : veteran_reward_templatess) { + if (veteran_reward_templates.reward_slot == veteran_reward_templates_id) { + return veteran_reward_templates; + } + } + + return NewEntity(); + } + + static VeteranRewardTemplates FindOne( + int veteran_reward_templates_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + veteran_reward_templates_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + VeteranRewardTemplates entry{}; + + entry.claim_id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.item_id = atoi(row[2]); + entry.charges = atoi(row[3]); + entry.reward_slot = atoi(row[4]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int veteran_reward_templates_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + veteran_reward_templates_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + VeteranRewardTemplates veteran_reward_templates_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(veteran_reward_templates_entry.name) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(veteran_reward_templates_entry.item_id)); + update_values.push_back(columns[3] + " = " + std::to_string(veteran_reward_templates_entry.charges)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + veteran_reward_templates_entry.reward_slot + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static VeteranRewardTemplates InsertOne( + VeteranRewardTemplates veteran_reward_templates_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(veteran_reward_templates_entry.name) + "'"); + insert_values.push_back(std::to_string(veteran_reward_templates_entry.item_id)); + insert_values.push_back(std::to_string(veteran_reward_templates_entry.charges)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + veteran_reward_templates_entry.id = results.LastInsertedID(); + return veteran_reward_templates_entry; + } + + veteran_reward_templates_entry = NewEntity(); + + return veteran_reward_templates_entry; + } + + static int InsertMany( + std::vector veteran_reward_templates_entries + ) + { + std::vector insert_chunks; + + for (auto &veteran_reward_templates_entry: veteran_reward_templates_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(veteran_reward_templates_entry.name) + "'"); + insert_values.push_back(std::to_string(veteran_reward_templates_entry.item_id)); + insert_values.push_back(std::to_string(veteran_reward_templates_entry.charges)); + + 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) { + VeteranRewardTemplates entry{}; + + entry.claim_id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.item_id = atoi(row[2]); + entry.charges = atoi(row[3]); + entry.reward_slot = atoi(row[4]); + + 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) { + VeteranRewardTemplates entry{}; + + entry.claim_id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.item_id = atoi(row[2]); + entry.charges = atoi(row[3]); + entry.reward_slot = 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_VETERAN_REWARD_TEMPLATES_REPOSITORY_H diff --git a/common/repositories/base/base_zone_points_repository.h b/common/repositories/base/base_zone_points_repository.h new file mode 100644 index 000000000..fbe7c211d --- /dev/null +++ b/common/repositories/base/base_zone_points_repository.h @@ -0,0 +1,468 @@ +/** + * 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 on Apr 5, 2020 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_ZONE_POINTS_REPOSITORY_H +#define EQEMU_BASE_ZONE_POINTS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseZonePointsRepository { +public: + struct ZonePoints { + int id; + std::string zone; + int version; + int16 number; + float y; + float x; + float z; + float heading; + float target_y; + float target_x; + float target_z; + float target_heading; + int16 zoneinst; + int target_zone_id; + int target_instance; + float buffer; + int client_version_mask; + int8 min_expansion; + int8 max_expansion; + std::string content_flags; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "zone", + "version", + "number", + "y", + "x", + "z", + "heading", + "target_y", + "target_x", + "target_z", + "target_heading", + "zoneinst", + "target_zone_id", + "target_instance", + "buffer", + "client_version_mask", + "min_expansion", + "max_expansion", + "content_flags", + }; + } + + 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("zone_points"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static ZonePoints NewEntity() + { + ZonePoints entry{}; + + entry.id = 0; + entry.zone = ""; + entry.version = 0; + entry.number = 1; + entry.y = 0; + entry.x = 0; + entry.z = 0; + entry.heading = 0; + entry.target_y = 0; + entry.target_x = 0; + entry.target_z = 0; + entry.target_heading = 0; + entry.zoneinst = 0; + entry.target_zone_id = 0; + entry.target_instance = 0; + entry.buffer = 0; + entry.client_version_mask = 4294967295; + entry.min_expansion = 0; + entry.max_expansion = 0; + entry.content_flags = ""; + + return entry; + } + + static ZonePoints GetZonePointsEntry( + const std::vector &zone_pointss, + int zone_points_id + ) + { + for (auto &zone_points : zone_pointss) { + if (zone_points.id == zone_points_id) { + return zone_points; + } + } + + return NewEntity(); + } + + static ZonePoints FindOne( + int zone_points_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + zone_points_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + ZonePoints entry{}; + + entry.id = atoi(row[0]); + entry.zone = row[1] ? row[1] : ""; + entry.version = atoi(row[2]); + entry.number = atoi(row[3]); + entry.y = atof(row[4]); + entry.x = atof(row[5]); + entry.z = atof(row[6]); + entry.heading = atof(row[7]); + entry.target_y = atof(row[8]); + entry.target_x = atof(row[9]); + entry.target_z = atof(row[10]); + entry.target_heading = atof(row[11]); + entry.zoneinst = atoi(row[12]); + entry.target_zone_id = atoi(row[13]); + entry.target_instance = atoi(row[14]); + entry.buffer = atof(row[15]); + entry.client_version_mask = atoi(row[16]); + entry.min_expansion = atoi(row[17]); + entry.max_expansion = atoi(row[18]); + entry.content_flags = row[19] ? row[19] : ""; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int zone_points_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + zone_points_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + ZonePoints zone_points_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(zone_points_entry.zone) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(zone_points_entry.version)); + update_values.push_back(columns[3] + " = " + std::to_string(zone_points_entry.number)); + update_values.push_back(columns[4] + " = " + std::to_string(zone_points_entry.y)); + update_values.push_back(columns[5] + " = " + std::to_string(zone_points_entry.x)); + update_values.push_back(columns[6] + " = " + std::to_string(zone_points_entry.z)); + update_values.push_back(columns[7] + " = " + std::to_string(zone_points_entry.heading)); + update_values.push_back(columns[8] + " = " + std::to_string(zone_points_entry.target_y)); + update_values.push_back(columns[9] + " = " + std::to_string(zone_points_entry.target_x)); + update_values.push_back(columns[10] + " = " + std::to_string(zone_points_entry.target_z)); + update_values.push_back(columns[11] + " = " + std::to_string(zone_points_entry.target_heading)); + update_values.push_back(columns[12] + " = " + std::to_string(zone_points_entry.zoneinst)); + update_values.push_back(columns[13] + " = " + std::to_string(zone_points_entry.target_zone_id)); + update_values.push_back(columns[14] + " = " + std::to_string(zone_points_entry.target_instance)); + update_values.push_back(columns[15] + " = " + std::to_string(zone_points_entry.buffer)); + update_values.push_back(columns[16] + " = " + std::to_string(zone_points_entry.client_version_mask)); + update_values.push_back(columns[17] + " = " + std::to_string(zone_points_entry.min_expansion)); + update_values.push_back(columns[18] + " = " + std::to_string(zone_points_entry.max_expansion)); + update_values.push_back(columns[19] + " = '" + EscapeString(zone_points_entry.content_flags) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + zone_points_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static ZonePoints InsertOne( + ZonePoints zone_points_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(zone_points_entry.zone) + "'"); + insert_values.push_back(std::to_string(zone_points_entry.version)); + insert_values.push_back(std::to_string(zone_points_entry.number)); + insert_values.push_back(std::to_string(zone_points_entry.y)); + insert_values.push_back(std::to_string(zone_points_entry.x)); + insert_values.push_back(std::to_string(zone_points_entry.z)); + insert_values.push_back(std::to_string(zone_points_entry.heading)); + insert_values.push_back(std::to_string(zone_points_entry.target_y)); + insert_values.push_back(std::to_string(zone_points_entry.target_x)); + insert_values.push_back(std::to_string(zone_points_entry.target_z)); + insert_values.push_back(std::to_string(zone_points_entry.target_heading)); + insert_values.push_back(std::to_string(zone_points_entry.zoneinst)); + insert_values.push_back(std::to_string(zone_points_entry.target_zone_id)); + insert_values.push_back(std::to_string(zone_points_entry.target_instance)); + insert_values.push_back(std::to_string(zone_points_entry.buffer)); + insert_values.push_back(std::to_string(zone_points_entry.client_version_mask)); + insert_values.push_back(std::to_string(zone_points_entry.min_expansion)); + insert_values.push_back(std::to_string(zone_points_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(zone_points_entry.content_flags) + "'"); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + zone_points_entry.id = results.LastInsertedID(); + return zone_points_entry; + } + + zone_points_entry = NewEntity(); + + return zone_points_entry; + } + + static int InsertMany( + std::vector zone_points_entries + ) + { + std::vector insert_chunks; + + for (auto &zone_points_entry: zone_points_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(zone_points_entry.zone) + "'"); + insert_values.push_back(std::to_string(zone_points_entry.version)); + insert_values.push_back(std::to_string(zone_points_entry.number)); + insert_values.push_back(std::to_string(zone_points_entry.y)); + insert_values.push_back(std::to_string(zone_points_entry.x)); + insert_values.push_back(std::to_string(zone_points_entry.z)); + insert_values.push_back(std::to_string(zone_points_entry.heading)); + insert_values.push_back(std::to_string(zone_points_entry.target_y)); + insert_values.push_back(std::to_string(zone_points_entry.target_x)); + insert_values.push_back(std::to_string(zone_points_entry.target_z)); + insert_values.push_back(std::to_string(zone_points_entry.target_heading)); + insert_values.push_back(std::to_string(zone_points_entry.zoneinst)); + insert_values.push_back(std::to_string(zone_points_entry.target_zone_id)); + insert_values.push_back(std::to_string(zone_points_entry.target_instance)); + insert_values.push_back(std::to_string(zone_points_entry.buffer)); + insert_values.push_back(std::to_string(zone_points_entry.client_version_mask)); + insert_values.push_back(std::to_string(zone_points_entry.min_expansion)); + insert_values.push_back(std::to_string(zone_points_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(zone_points_entry.content_flags) + "'"); + + 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) { + ZonePoints entry{}; + + entry.id = atoi(row[0]); + entry.zone = row[1] ? row[1] : ""; + entry.version = atoi(row[2]); + entry.number = atoi(row[3]); + entry.y = atof(row[4]); + entry.x = atof(row[5]); + entry.z = atof(row[6]); + entry.heading = atof(row[7]); + entry.target_y = atof(row[8]); + entry.target_x = atof(row[9]); + entry.target_z = atof(row[10]); + entry.target_heading = atof(row[11]); + entry.zoneinst = atoi(row[12]); + entry.target_zone_id = atoi(row[13]); + entry.target_instance = atoi(row[14]); + entry.buffer = atof(row[15]); + entry.client_version_mask = atoi(row[16]); + entry.min_expansion = atoi(row[17]); + entry.max_expansion = atoi(row[18]); + entry.content_flags = row[19] ? row[19] : ""; + + 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) { + ZonePoints entry{}; + + entry.id = atoi(row[0]); + entry.zone = row[1] ? row[1] : ""; + entry.version = atoi(row[2]); + entry.number = atoi(row[3]); + entry.y = atof(row[4]); + entry.x = atof(row[5]); + entry.z = atof(row[6]); + entry.heading = atof(row[7]); + entry.target_y = atof(row[8]); + entry.target_x = atof(row[9]); + entry.target_z = atof(row[10]); + entry.target_heading = atof(row[11]); + entry.zoneinst = atoi(row[12]); + entry.target_zone_id = atoi(row[13]); + entry.target_instance = atoi(row[14]); + entry.buffer = atof(row[15]); + entry.client_version_mask = atoi(row[16]); + entry.min_expansion = atoi(row[17]); + entry.max_expansion = atoi(row[18]); + entry.content_flags = row[19] ? row[19] : ""; + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_ZONE_POINTS_REPOSITORY_H diff --git a/common/repositories/base/base_zone_repository.h b/common/repositories/base/base_zone_repository.h new file mode 100644 index 000000000..172c172c2 --- /dev/null +++ b/common/repositories/base/base_zone_repository.h @@ -0,0 +1,1062 @@ +/** + * 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 on Apr 5, 2020 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_ZONE_REPOSITORY_H +#define EQEMU_BASE_ZONE_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class BaseZoneRepository { +public: + struct Zone { + std::string short_name; + int id; + std::string file_name; + std::string long_name; + std::string map_file_name; + float safe_x; + float safe_y; + float safe_z; + float graveyard_id; + int8 min_level; + int8 min_status; + int zoneidnumber; + int8 version; + int timezone; + int maxclients; + int ruleset; + std::string note; + float underworld; + float minclip; + float maxclip; + float fog_minclip; + float fog_maxclip; + int8 fog_blue; + int8 fog_red; + int8 fog_green; + int8 sky; + int8 ztype; + float zone_exp_multiplier; + float walkspeed; + int8 time_type; + int8 fog_red1; + int8 fog_green1; + int8 fog_blue1; + float fog_minclip1; + float fog_maxclip1; + int8 fog_red2; + int8 fog_green2; + int8 fog_blue2; + float fog_minclip2; + float fog_maxclip2; + int8 fog_red3; + int8 fog_green3; + int8 fog_blue3; + float fog_minclip3; + float fog_maxclip3; + int8 fog_red4; + int8 fog_green4; + int8 fog_blue4; + float fog_minclip4; + float fog_maxclip4; + float fog_density; + std::string flag_needed; + int8 canbind; + int8 cancombat; + int8 canlevitate; + int8 castoutdoor; + int8 hotzone; + int8 insttype; + int shutdowndelay; + int8 peqzone; + int8 expansion; + int8 suspendbuffs; + int rain_chance1; + int rain_chance2; + int rain_chance3; + int rain_chance4; + int rain_duration1; + int rain_duration2; + int rain_duration3; + int rain_duration4; + int snow_chance1; + int snow_chance2; + int snow_chance3; + int snow_chance4; + int snow_duration1; + int snow_duration2; + int snow_duration3; + int snow_duration4; + float gravity; + int type; + int8 skylock; + int fast_regen_hp; + int fast_regen_mana; + int fast_regen_endurance; + int npc_max_aggro_dist; + int max_movement_update_range; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "short_name", + "id", + "file_name", + "long_name", + "map_file_name", + "safe_x", + "safe_y", + "safe_z", + "graveyard_id", + "min_level", + "min_status", + "zoneidnumber", + "version", + "timezone", + "maxclients", + "ruleset", + "note", + "underworld", + "minclip", + "maxclip", + "fog_minclip", + "fog_maxclip", + "fog_blue", + "fog_red", + "fog_green", + "sky", + "ztype", + "zone_exp_multiplier", + "walkspeed", + "time_type", + "fog_red1", + "fog_green1", + "fog_blue1", + "fog_minclip1", + "fog_maxclip1", + "fog_red2", + "fog_green2", + "fog_blue2", + "fog_minclip2", + "fog_maxclip2", + "fog_red3", + "fog_green3", + "fog_blue3", + "fog_minclip3", + "fog_maxclip3", + "fog_red4", + "fog_green4", + "fog_blue4", + "fog_minclip4", + "fog_maxclip4", + "fog_density", + "flag_needed", + "canbind", + "cancombat", + "canlevitate", + "castoutdoor", + "hotzone", + "insttype", + "shutdowndelay", + "peqzone", + "expansion", + "suspendbuffs", + "rain_chance1", + "rain_chance2", + "rain_chance3", + "rain_chance4", + "rain_duration1", + "rain_duration2", + "rain_duration3", + "rain_duration4", + "snow_chance1", + "snow_chance2", + "snow_chance3", + "snow_chance4", + "snow_duration1", + "snow_duration2", + "snow_duration3", + "snow_duration4", + "gravity", + "type", + "skylock", + "fast_regen_hp", + "fast_regen_mana", + "fast_regen_endurance", + "npc_max_aggro_dist", + "max_movement_update_range", + }; + } + + 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("zone"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Zone NewEntity() + { + Zone entry{}; + + entry.short_name = ""; + entry.id = 0; + entry.file_name = ""; + entry.long_name = ""; + entry.map_file_name = ""; + entry.safe_x = 0; + entry.safe_y = 0; + entry.safe_z = 0; + entry.graveyard_id = 0; + entry.min_level = 0; + entry.min_status = 0; + entry.zoneidnumber = 0; + entry.version = 0; + entry.timezone = 0; + entry.maxclients = 0; + entry.ruleset = 0; + entry.note = ""; + entry.underworld = 0; + entry.minclip = 450; + entry.maxclip = 450; + entry.fog_minclip = 450; + entry.fog_maxclip = 450; + entry.fog_blue = 0; + entry.fog_red = 0; + entry.fog_green = 0; + entry.sky = 1; + entry.ztype = 1; + entry.zone_exp_multiplier = 0.00; + entry.walkspeed = 0.4; + entry.time_type = 2; + entry.fog_red1 = 0; + entry.fog_green1 = 0; + entry.fog_blue1 = 0; + entry.fog_minclip1 = 450; + entry.fog_maxclip1 = 450; + entry.fog_red2 = 0; + entry.fog_green2 = 0; + entry.fog_blue2 = 0; + entry.fog_minclip2 = 450; + entry.fog_maxclip2 = 450; + entry.fog_red3 = 0; + entry.fog_green3 = 0; + entry.fog_blue3 = 0; + entry.fog_minclip3 = 450; + entry.fog_maxclip3 = 450; + entry.fog_red4 = 0; + entry.fog_green4 = 0; + entry.fog_blue4 = 0; + entry.fog_minclip4 = 450; + entry.fog_maxclip4 = 450; + entry.fog_density = 0; + entry.flag_needed = ""; + entry.canbind = 1; + entry.cancombat = 1; + entry.canlevitate = 1; + entry.castoutdoor = 1; + entry.hotzone = 0; + entry.insttype = 0; + entry.shutdowndelay = 5000; + entry.peqzone = 1; + entry.expansion = 0; + entry.suspendbuffs = 0; + entry.rain_chance1 = 0; + entry.rain_chance2 = 0; + entry.rain_chance3 = 0; + entry.rain_chance4 = 0; + entry.rain_duration1 = 0; + entry.rain_duration2 = 0; + entry.rain_duration3 = 0; + entry.rain_duration4 = 0; + entry.snow_chance1 = 0; + entry.snow_chance2 = 0; + entry.snow_chance3 = 0; + entry.snow_chance4 = 0; + entry.snow_duration1 = 0; + entry.snow_duration2 = 0; + entry.snow_duration3 = 0; + entry.snow_duration4 = 0; + entry.gravity = 0.4; + entry.type = 0; + entry.skylock = 0; + entry.fast_regen_hp = 180; + entry.fast_regen_mana = 180; + entry.fast_regen_endurance = 180; + entry.npc_max_aggro_dist = 600; + entry.max_movement_update_range = 600; + + return entry; + } + + static Zone GetZoneEntry( + const std::vector &zones, + int zone_id + ) + { + for (auto &zone : zones) { + if (zone.id == zone_id) { + return zone; + } + } + + return NewEntity(); + } + + static Zone FindOne( + int zone_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + zone_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Zone entry{}; + + entry.short_name = row[0] ? row[0] : ""; + entry.id = atoi(row[1]); + entry.file_name = row[2] ? row[2] : ""; + entry.long_name = row[3] ? row[3] : ""; + entry.map_file_name = row[4] ? row[4] : ""; + entry.safe_x = atof(row[5]); + entry.safe_y = atof(row[6]); + entry.safe_z = atof(row[7]); + entry.graveyard_id = atof(row[8]); + entry.min_level = atoi(row[9]); + entry.min_status = atoi(row[10]); + entry.zoneidnumber = atoi(row[11]); + entry.version = atoi(row[12]); + entry.timezone = atoi(row[13]); + entry.maxclients = atoi(row[14]); + entry.ruleset = atoi(row[15]); + entry.note = row[16] ? row[16] : ""; + entry.underworld = atof(row[17]); + entry.minclip = atof(row[18]); + entry.maxclip = atof(row[19]); + entry.fog_minclip = atof(row[20]); + entry.fog_maxclip = atof(row[21]); + entry.fog_blue = atoi(row[22]); + entry.fog_red = atoi(row[23]); + entry.fog_green = atoi(row[24]); + entry.sky = atoi(row[25]); + entry.ztype = atoi(row[26]); + entry.zone_exp_multiplier = atof(row[27]); + entry.walkspeed = atof(row[28]); + entry.time_type = atoi(row[29]); + entry.fog_red1 = atoi(row[30]); + entry.fog_green1 = atoi(row[31]); + entry.fog_blue1 = atoi(row[32]); + entry.fog_minclip1 = atof(row[33]); + entry.fog_maxclip1 = atof(row[34]); + entry.fog_red2 = atoi(row[35]); + entry.fog_green2 = atoi(row[36]); + entry.fog_blue2 = atoi(row[37]); + entry.fog_minclip2 = atof(row[38]); + entry.fog_maxclip2 = atof(row[39]); + entry.fog_red3 = atoi(row[40]); + entry.fog_green3 = atoi(row[41]); + entry.fog_blue3 = atoi(row[42]); + entry.fog_minclip3 = atof(row[43]); + entry.fog_maxclip3 = atof(row[44]); + entry.fog_red4 = atoi(row[45]); + entry.fog_green4 = atoi(row[46]); + entry.fog_blue4 = atoi(row[47]); + entry.fog_minclip4 = atof(row[48]); + entry.fog_maxclip4 = atof(row[49]); + entry.fog_density = atof(row[50]); + entry.flag_needed = row[51] ? row[51] : ""; + entry.canbind = atoi(row[52]); + entry.cancombat = atoi(row[53]); + entry.canlevitate = atoi(row[54]); + entry.castoutdoor = atoi(row[55]); + entry.hotzone = atoi(row[56]); + entry.insttype = atoi(row[57]); + entry.shutdowndelay = atoi(row[58]); + entry.peqzone = atoi(row[59]); + entry.expansion = atoi(row[60]); + entry.suspendbuffs = atoi(row[61]); + entry.rain_chance1 = atoi(row[62]); + entry.rain_chance2 = atoi(row[63]); + entry.rain_chance3 = atoi(row[64]); + entry.rain_chance4 = atoi(row[65]); + entry.rain_duration1 = atoi(row[66]); + entry.rain_duration2 = atoi(row[67]); + entry.rain_duration3 = atoi(row[68]); + entry.rain_duration4 = atoi(row[69]); + entry.snow_chance1 = atoi(row[70]); + entry.snow_chance2 = atoi(row[71]); + entry.snow_chance3 = atoi(row[72]); + entry.snow_chance4 = atoi(row[73]); + entry.snow_duration1 = atoi(row[74]); + entry.snow_duration2 = atoi(row[75]); + entry.snow_duration3 = atoi(row[76]); + entry.snow_duration4 = atoi(row[77]); + entry.gravity = atof(row[78]); + entry.type = atoi(row[79]); + entry.skylock = atoi(row[80]); + entry.fast_regen_hp = atoi(row[81]); + entry.fast_regen_mana = atoi(row[82]); + entry.fast_regen_endurance = atoi(row[83]); + entry.npc_max_aggro_dist = atoi(row[84]); + entry.max_movement_update_range = atoi(row[85]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int zone_id + ) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + zone_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Zone zone_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[0] + " = '" + EscapeString(zone_entry.short_name) + "'"); + update_values.push_back(columns[2] + " = '" + EscapeString(zone_entry.file_name) + "'"); + update_values.push_back(columns[3] + " = '" + EscapeString(zone_entry.long_name) + "'"); + update_values.push_back(columns[4] + " = '" + EscapeString(zone_entry.map_file_name) + "'"); + update_values.push_back(columns[5] + " = " + std::to_string(zone_entry.safe_x)); + update_values.push_back(columns[6] + " = " + std::to_string(zone_entry.safe_y)); + update_values.push_back(columns[7] + " = " + std::to_string(zone_entry.safe_z)); + update_values.push_back(columns[8] + " = " + std::to_string(zone_entry.graveyard_id)); + update_values.push_back(columns[9] + " = " + std::to_string(zone_entry.min_level)); + update_values.push_back(columns[10] + " = " + std::to_string(zone_entry.min_status)); + update_values.push_back(columns[11] + " = " + std::to_string(zone_entry.zoneidnumber)); + update_values.push_back(columns[12] + " = " + std::to_string(zone_entry.version)); + update_values.push_back(columns[13] + " = " + std::to_string(zone_entry.timezone)); + update_values.push_back(columns[14] + " = " + std::to_string(zone_entry.maxclients)); + update_values.push_back(columns[15] + " = " + std::to_string(zone_entry.ruleset)); + update_values.push_back(columns[16] + " = '" + EscapeString(zone_entry.note) + "'"); + update_values.push_back(columns[17] + " = " + std::to_string(zone_entry.underworld)); + update_values.push_back(columns[18] + " = " + std::to_string(zone_entry.minclip)); + update_values.push_back(columns[19] + " = " + std::to_string(zone_entry.maxclip)); + update_values.push_back(columns[20] + " = " + std::to_string(zone_entry.fog_minclip)); + update_values.push_back(columns[21] + " = " + std::to_string(zone_entry.fog_maxclip)); + update_values.push_back(columns[22] + " = " + std::to_string(zone_entry.fog_blue)); + update_values.push_back(columns[23] + " = " + std::to_string(zone_entry.fog_red)); + update_values.push_back(columns[24] + " = " + std::to_string(zone_entry.fog_green)); + update_values.push_back(columns[25] + " = " + std::to_string(zone_entry.sky)); + update_values.push_back(columns[26] + " = " + std::to_string(zone_entry.ztype)); + update_values.push_back(columns[27] + " = " + std::to_string(zone_entry.zone_exp_multiplier)); + update_values.push_back(columns[28] + " = " + std::to_string(zone_entry.walkspeed)); + update_values.push_back(columns[29] + " = " + std::to_string(zone_entry.time_type)); + update_values.push_back(columns[30] + " = " + std::to_string(zone_entry.fog_red1)); + update_values.push_back(columns[31] + " = " + std::to_string(zone_entry.fog_green1)); + update_values.push_back(columns[32] + " = " + std::to_string(zone_entry.fog_blue1)); + update_values.push_back(columns[33] + " = " + std::to_string(zone_entry.fog_minclip1)); + update_values.push_back(columns[34] + " = " + std::to_string(zone_entry.fog_maxclip1)); + update_values.push_back(columns[35] + " = " + std::to_string(zone_entry.fog_red2)); + update_values.push_back(columns[36] + " = " + std::to_string(zone_entry.fog_green2)); + update_values.push_back(columns[37] + " = " + std::to_string(zone_entry.fog_blue2)); + update_values.push_back(columns[38] + " = " + std::to_string(zone_entry.fog_minclip2)); + update_values.push_back(columns[39] + " = " + std::to_string(zone_entry.fog_maxclip2)); + update_values.push_back(columns[40] + " = " + std::to_string(zone_entry.fog_red3)); + update_values.push_back(columns[41] + " = " + std::to_string(zone_entry.fog_green3)); + update_values.push_back(columns[42] + " = " + std::to_string(zone_entry.fog_blue3)); + update_values.push_back(columns[43] + " = " + std::to_string(zone_entry.fog_minclip3)); + update_values.push_back(columns[44] + " = " + std::to_string(zone_entry.fog_maxclip3)); + update_values.push_back(columns[45] + " = " + std::to_string(zone_entry.fog_red4)); + update_values.push_back(columns[46] + " = " + std::to_string(zone_entry.fog_green4)); + update_values.push_back(columns[47] + " = " + std::to_string(zone_entry.fog_blue4)); + update_values.push_back(columns[48] + " = " + std::to_string(zone_entry.fog_minclip4)); + update_values.push_back(columns[49] + " = " + std::to_string(zone_entry.fog_maxclip4)); + update_values.push_back(columns[50] + " = " + std::to_string(zone_entry.fog_density)); + update_values.push_back(columns[51] + " = '" + EscapeString(zone_entry.flag_needed) + "'"); + update_values.push_back(columns[52] + " = " + std::to_string(zone_entry.canbind)); + update_values.push_back(columns[53] + " = " + std::to_string(zone_entry.cancombat)); + update_values.push_back(columns[54] + " = " + std::to_string(zone_entry.canlevitate)); + update_values.push_back(columns[55] + " = " + std::to_string(zone_entry.castoutdoor)); + update_values.push_back(columns[56] + " = " + std::to_string(zone_entry.hotzone)); + update_values.push_back(columns[57] + " = " + std::to_string(zone_entry.insttype)); + update_values.push_back(columns[58] + " = " + std::to_string(zone_entry.shutdowndelay)); + update_values.push_back(columns[59] + " = " + std::to_string(zone_entry.peqzone)); + update_values.push_back(columns[60] + " = " + std::to_string(zone_entry.expansion)); + update_values.push_back(columns[61] + " = " + std::to_string(zone_entry.suspendbuffs)); + update_values.push_back(columns[62] + " = " + std::to_string(zone_entry.rain_chance1)); + update_values.push_back(columns[63] + " = " + std::to_string(zone_entry.rain_chance2)); + update_values.push_back(columns[64] + " = " + std::to_string(zone_entry.rain_chance3)); + update_values.push_back(columns[65] + " = " + std::to_string(zone_entry.rain_chance4)); + update_values.push_back(columns[66] + " = " + std::to_string(zone_entry.rain_duration1)); + update_values.push_back(columns[67] + " = " + std::to_string(zone_entry.rain_duration2)); + update_values.push_back(columns[68] + " = " + std::to_string(zone_entry.rain_duration3)); + update_values.push_back(columns[69] + " = " + std::to_string(zone_entry.rain_duration4)); + update_values.push_back(columns[70] + " = " + std::to_string(zone_entry.snow_chance1)); + update_values.push_back(columns[71] + " = " + std::to_string(zone_entry.snow_chance2)); + update_values.push_back(columns[72] + " = " + std::to_string(zone_entry.snow_chance3)); + update_values.push_back(columns[73] + " = " + std::to_string(zone_entry.snow_chance4)); + update_values.push_back(columns[74] + " = " + std::to_string(zone_entry.snow_duration1)); + update_values.push_back(columns[75] + " = " + std::to_string(zone_entry.snow_duration2)); + update_values.push_back(columns[76] + " = " + std::to_string(zone_entry.snow_duration3)); + update_values.push_back(columns[77] + " = " + std::to_string(zone_entry.snow_duration4)); + update_values.push_back(columns[78] + " = " + std::to_string(zone_entry.gravity)); + update_values.push_back(columns[79] + " = " + std::to_string(zone_entry.type)); + update_values.push_back(columns[80] + " = " + std::to_string(zone_entry.skylock)); + update_values.push_back(columns[81] + " = " + std::to_string(zone_entry.fast_regen_hp)); + update_values.push_back(columns[82] + " = " + std::to_string(zone_entry.fast_regen_mana)); + update_values.push_back(columns[83] + " = " + std::to_string(zone_entry.fast_regen_endurance)); + update_values.push_back(columns[84] + " = " + std::to_string(zone_entry.npc_max_aggro_dist)); + update_values.push_back(columns[85] + " = " + std::to_string(zone_entry.max_movement_update_range)); + + auto results = content_db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + zone_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Zone InsertOne( + Zone zone_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(zone_entry.short_name) + "'"); + insert_values.push_back("'" + EscapeString(zone_entry.file_name) + "'"); + insert_values.push_back("'" + EscapeString(zone_entry.long_name) + "'"); + insert_values.push_back("'" + EscapeString(zone_entry.map_file_name) + "'"); + insert_values.push_back(std::to_string(zone_entry.safe_x)); + insert_values.push_back(std::to_string(zone_entry.safe_y)); + insert_values.push_back(std::to_string(zone_entry.safe_z)); + insert_values.push_back(std::to_string(zone_entry.graveyard_id)); + insert_values.push_back(std::to_string(zone_entry.min_level)); + insert_values.push_back(std::to_string(zone_entry.min_status)); + insert_values.push_back(std::to_string(zone_entry.zoneidnumber)); + insert_values.push_back(std::to_string(zone_entry.version)); + insert_values.push_back(std::to_string(zone_entry.timezone)); + insert_values.push_back(std::to_string(zone_entry.maxclients)); + insert_values.push_back(std::to_string(zone_entry.ruleset)); + insert_values.push_back("'" + EscapeString(zone_entry.note) + "'"); + insert_values.push_back(std::to_string(zone_entry.underworld)); + insert_values.push_back(std::to_string(zone_entry.minclip)); + insert_values.push_back(std::to_string(zone_entry.maxclip)); + insert_values.push_back(std::to_string(zone_entry.fog_minclip)); + insert_values.push_back(std::to_string(zone_entry.fog_maxclip)); + insert_values.push_back(std::to_string(zone_entry.fog_blue)); + insert_values.push_back(std::to_string(zone_entry.fog_red)); + insert_values.push_back(std::to_string(zone_entry.fog_green)); + insert_values.push_back(std::to_string(zone_entry.sky)); + insert_values.push_back(std::to_string(zone_entry.ztype)); + insert_values.push_back(std::to_string(zone_entry.zone_exp_multiplier)); + insert_values.push_back(std::to_string(zone_entry.walkspeed)); + insert_values.push_back(std::to_string(zone_entry.time_type)); + insert_values.push_back(std::to_string(zone_entry.fog_red1)); + insert_values.push_back(std::to_string(zone_entry.fog_green1)); + insert_values.push_back(std::to_string(zone_entry.fog_blue1)); + insert_values.push_back(std::to_string(zone_entry.fog_minclip1)); + insert_values.push_back(std::to_string(zone_entry.fog_maxclip1)); + insert_values.push_back(std::to_string(zone_entry.fog_red2)); + insert_values.push_back(std::to_string(zone_entry.fog_green2)); + insert_values.push_back(std::to_string(zone_entry.fog_blue2)); + insert_values.push_back(std::to_string(zone_entry.fog_minclip2)); + insert_values.push_back(std::to_string(zone_entry.fog_maxclip2)); + insert_values.push_back(std::to_string(zone_entry.fog_red3)); + insert_values.push_back(std::to_string(zone_entry.fog_green3)); + insert_values.push_back(std::to_string(zone_entry.fog_blue3)); + insert_values.push_back(std::to_string(zone_entry.fog_minclip3)); + insert_values.push_back(std::to_string(zone_entry.fog_maxclip3)); + insert_values.push_back(std::to_string(zone_entry.fog_red4)); + insert_values.push_back(std::to_string(zone_entry.fog_green4)); + insert_values.push_back(std::to_string(zone_entry.fog_blue4)); + insert_values.push_back(std::to_string(zone_entry.fog_minclip4)); + insert_values.push_back(std::to_string(zone_entry.fog_maxclip4)); + insert_values.push_back(std::to_string(zone_entry.fog_density)); + insert_values.push_back("'" + EscapeString(zone_entry.flag_needed) + "'"); + insert_values.push_back(std::to_string(zone_entry.canbind)); + insert_values.push_back(std::to_string(zone_entry.cancombat)); + insert_values.push_back(std::to_string(zone_entry.canlevitate)); + insert_values.push_back(std::to_string(zone_entry.castoutdoor)); + insert_values.push_back(std::to_string(zone_entry.hotzone)); + insert_values.push_back(std::to_string(zone_entry.insttype)); + insert_values.push_back(std::to_string(zone_entry.shutdowndelay)); + insert_values.push_back(std::to_string(zone_entry.peqzone)); + insert_values.push_back(std::to_string(zone_entry.expansion)); + insert_values.push_back(std::to_string(zone_entry.suspendbuffs)); + insert_values.push_back(std::to_string(zone_entry.rain_chance1)); + insert_values.push_back(std::to_string(zone_entry.rain_chance2)); + insert_values.push_back(std::to_string(zone_entry.rain_chance3)); + insert_values.push_back(std::to_string(zone_entry.rain_chance4)); + insert_values.push_back(std::to_string(zone_entry.rain_duration1)); + insert_values.push_back(std::to_string(zone_entry.rain_duration2)); + insert_values.push_back(std::to_string(zone_entry.rain_duration3)); + insert_values.push_back(std::to_string(zone_entry.rain_duration4)); + insert_values.push_back(std::to_string(zone_entry.snow_chance1)); + insert_values.push_back(std::to_string(zone_entry.snow_chance2)); + insert_values.push_back(std::to_string(zone_entry.snow_chance3)); + insert_values.push_back(std::to_string(zone_entry.snow_chance4)); + insert_values.push_back(std::to_string(zone_entry.snow_duration1)); + insert_values.push_back(std::to_string(zone_entry.snow_duration2)); + insert_values.push_back(std::to_string(zone_entry.snow_duration3)); + insert_values.push_back(std::to_string(zone_entry.snow_duration4)); + insert_values.push_back(std::to_string(zone_entry.gravity)); + insert_values.push_back(std::to_string(zone_entry.type)); + insert_values.push_back(std::to_string(zone_entry.skylock)); + insert_values.push_back(std::to_string(zone_entry.fast_regen_hp)); + insert_values.push_back(std::to_string(zone_entry.fast_regen_mana)); + insert_values.push_back(std::to_string(zone_entry.fast_regen_endurance)); + insert_values.push_back(std::to_string(zone_entry.npc_max_aggro_dist)); + insert_values.push_back(std::to_string(zone_entry.max_movement_update_range)); + + auto results = content_db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + zone_entry.id = results.LastInsertedID(); + return zone_entry; + } + + zone_entry = NewEntity(); + + return zone_entry; + } + + static int InsertMany( + std::vector zone_entries + ) + { + std::vector insert_chunks; + + for (auto &zone_entry: zone_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(zone_entry.short_name) + "'"); + insert_values.push_back("'" + EscapeString(zone_entry.file_name) + "'"); + insert_values.push_back("'" + EscapeString(zone_entry.long_name) + "'"); + insert_values.push_back("'" + EscapeString(zone_entry.map_file_name) + "'"); + insert_values.push_back(std::to_string(zone_entry.safe_x)); + insert_values.push_back(std::to_string(zone_entry.safe_y)); + insert_values.push_back(std::to_string(zone_entry.safe_z)); + insert_values.push_back(std::to_string(zone_entry.graveyard_id)); + insert_values.push_back(std::to_string(zone_entry.min_level)); + insert_values.push_back(std::to_string(zone_entry.min_status)); + insert_values.push_back(std::to_string(zone_entry.zoneidnumber)); + insert_values.push_back(std::to_string(zone_entry.version)); + insert_values.push_back(std::to_string(zone_entry.timezone)); + insert_values.push_back(std::to_string(zone_entry.maxclients)); + insert_values.push_back(std::to_string(zone_entry.ruleset)); + insert_values.push_back("'" + EscapeString(zone_entry.note) + "'"); + insert_values.push_back(std::to_string(zone_entry.underworld)); + insert_values.push_back(std::to_string(zone_entry.minclip)); + insert_values.push_back(std::to_string(zone_entry.maxclip)); + insert_values.push_back(std::to_string(zone_entry.fog_minclip)); + insert_values.push_back(std::to_string(zone_entry.fog_maxclip)); + insert_values.push_back(std::to_string(zone_entry.fog_blue)); + insert_values.push_back(std::to_string(zone_entry.fog_red)); + insert_values.push_back(std::to_string(zone_entry.fog_green)); + insert_values.push_back(std::to_string(zone_entry.sky)); + insert_values.push_back(std::to_string(zone_entry.ztype)); + insert_values.push_back(std::to_string(zone_entry.zone_exp_multiplier)); + insert_values.push_back(std::to_string(zone_entry.walkspeed)); + insert_values.push_back(std::to_string(zone_entry.time_type)); + insert_values.push_back(std::to_string(zone_entry.fog_red1)); + insert_values.push_back(std::to_string(zone_entry.fog_green1)); + insert_values.push_back(std::to_string(zone_entry.fog_blue1)); + insert_values.push_back(std::to_string(zone_entry.fog_minclip1)); + insert_values.push_back(std::to_string(zone_entry.fog_maxclip1)); + insert_values.push_back(std::to_string(zone_entry.fog_red2)); + insert_values.push_back(std::to_string(zone_entry.fog_green2)); + insert_values.push_back(std::to_string(zone_entry.fog_blue2)); + insert_values.push_back(std::to_string(zone_entry.fog_minclip2)); + insert_values.push_back(std::to_string(zone_entry.fog_maxclip2)); + insert_values.push_back(std::to_string(zone_entry.fog_red3)); + insert_values.push_back(std::to_string(zone_entry.fog_green3)); + insert_values.push_back(std::to_string(zone_entry.fog_blue3)); + insert_values.push_back(std::to_string(zone_entry.fog_minclip3)); + insert_values.push_back(std::to_string(zone_entry.fog_maxclip3)); + insert_values.push_back(std::to_string(zone_entry.fog_red4)); + insert_values.push_back(std::to_string(zone_entry.fog_green4)); + insert_values.push_back(std::to_string(zone_entry.fog_blue4)); + insert_values.push_back(std::to_string(zone_entry.fog_minclip4)); + insert_values.push_back(std::to_string(zone_entry.fog_maxclip4)); + insert_values.push_back(std::to_string(zone_entry.fog_density)); + insert_values.push_back("'" + EscapeString(zone_entry.flag_needed) + "'"); + insert_values.push_back(std::to_string(zone_entry.canbind)); + insert_values.push_back(std::to_string(zone_entry.cancombat)); + insert_values.push_back(std::to_string(zone_entry.canlevitate)); + insert_values.push_back(std::to_string(zone_entry.castoutdoor)); + insert_values.push_back(std::to_string(zone_entry.hotzone)); + insert_values.push_back(std::to_string(zone_entry.insttype)); + insert_values.push_back(std::to_string(zone_entry.shutdowndelay)); + insert_values.push_back(std::to_string(zone_entry.peqzone)); + insert_values.push_back(std::to_string(zone_entry.expansion)); + insert_values.push_back(std::to_string(zone_entry.suspendbuffs)); + insert_values.push_back(std::to_string(zone_entry.rain_chance1)); + insert_values.push_back(std::to_string(zone_entry.rain_chance2)); + insert_values.push_back(std::to_string(zone_entry.rain_chance3)); + insert_values.push_back(std::to_string(zone_entry.rain_chance4)); + insert_values.push_back(std::to_string(zone_entry.rain_duration1)); + insert_values.push_back(std::to_string(zone_entry.rain_duration2)); + insert_values.push_back(std::to_string(zone_entry.rain_duration3)); + insert_values.push_back(std::to_string(zone_entry.rain_duration4)); + insert_values.push_back(std::to_string(zone_entry.snow_chance1)); + insert_values.push_back(std::to_string(zone_entry.snow_chance2)); + insert_values.push_back(std::to_string(zone_entry.snow_chance3)); + insert_values.push_back(std::to_string(zone_entry.snow_chance4)); + insert_values.push_back(std::to_string(zone_entry.snow_duration1)); + insert_values.push_back(std::to_string(zone_entry.snow_duration2)); + insert_values.push_back(std::to_string(zone_entry.snow_duration3)); + insert_values.push_back(std::to_string(zone_entry.snow_duration4)); + insert_values.push_back(std::to_string(zone_entry.gravity)); + insert_values.push_back(std::to_string(zone_entry.type)); + insert_values.push_back(std::to_string(zone_entry.skylock)); + insert_values.push_back(std::to_string(zone_entry.fast_regen_hp)); + insert_values.push_back(std::to_string(zone_entry.fast_regen_mana)); + insert_values.push_back(std::to_string(zone_entry.fast_regen_endurance)); + insert_values.push_back(std::to_string(zone_entry.npc_max_aggro_dist)); + insert_values.push_back(std::to_string(zone_entry.max_movement_update_range)); + + 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) { + Zone entry{}; + + entry.short_name = row[0] ? row[0] : ""; + entry.id = atoi(row[1]); + entry.file_name = row[2] ? row[2] : ""; + entry.long_name = row[3] ? row[3] : ""; + entry.map_file_name = row[4] ? row[4] : ""; + entry.safe_x = atof(row[5]); + entry.safe_y = atof(row[6]); + entry.safe_z = atof(row[7]); + entry.graveyard_id = atof(row[8]); + entry.min_level = atoi(row[9]); + entry.min_status = atoi(row[10]); + entry.zoneidnumber = atoi(row[11]); + entry.version = atoi(row[12]); + entry.timezone = atoi(row[13]); + entry.maxclients = atoi(row[14]); + entry.ruleset = atoi(row[15]); + entry.note = row[16] ? row[16] : ""; + entry.underworld = atof(row[17]); + entry.minclip = atof(row[18]); + entry.maxclip = atof(row[19]); + entry.fog_minclip = atof(row[20]); + entry.fog_maxclip = atof(row[21]); + entry.fog_blue = atoi(row[22]); + entry.fog_red = atoi(row[23]); + entry.fog_green = atoi(row[24]); + entry.sky = atoi(row[25]); + entry.ztype = atoi(row[26]); + entry.zone_exp_multiplier = atof(row[27]); + entry.walkspeed = atof(row[28]); + entry.time_type = atoi(row[29]); + entry.fog_red1 = atoi(row[30]); + entry.fog_green1 = atoi(row[31]); + entry.fog_blue1 = atoi(row[32]); + entry.fog_minclip1 = atof(row[33]); + entry.fog_maxclip1 = atof(row[34]); + entry.fog_red2 = atoi(row[35]); + entry.fog_green2 = atoi(row[36]); + entry.fog_blue2 = atoi(row[37]); + entry.fog_minclip2 = atof(row[38]); + entry.fog_maxclip2 = atof(row[39]); + entry.fog_red3 = atoi(row[40]); + entry.fog_green3 = atoi(row[41]); + entry.fog_blue3 = atoi(row[42]); + entry.fog_minclip3 = atof(row[43]); + entry.fog_maxclip3 = atof(row[44]); + entry.fog_red4 = atoi(row[45]); + entry.fog_green4 = atoi(row[46]); + entry.fog_blue4 = atoi(row[47]); + entry.fog_minclip4 = atof(row[48]); + entry.fog_maxclip4 = atof(row[49]); + entry.fog_density = atof(row[50]); + entry.flag_needed = row[51] ? row[51] : ""; + entry.canbind = atoi(row[52]); + entry.cancombat = atoi(row[53]); + entry.canlevitate = atoi(row[54]); + entry.castoutdoor = atoi(row[55]); + entry.hotzone = atoi(row[56]); + entry.insttype = atoi(row[57]); + entry.shutdowndelay = atoi(row[58]); + entry.peqzone = atoi(row[59]); + entry.expansion = atoi(row[60]); + entry.suspendbuffs = atoi(row[61]); + entry.rain_chance1 = atoi(row[62]); + entry.rain_chance2 = atoi(row[63]); + entry.rain_chance3 = atoi(row[64]); + entry.rain_chance4 = atoi(row[65]); + entry.rain_duration1 = atoi(row[66]); + entry.rain_duration2 = atoi(row[67]); + entry.rain_duration3 = atoi(row[68]); + entry.rain_duration4 = atoi(row[69]); + entry.snow_chance1 = atoi(row[70]); + entry.snow_chance2 = atoi(row[71]); + entry.snow_chance3 = atoi(row[72]); + entry.snow_chance4 = atoi(row[73]); + entry.snow_duration1 = atoi(row[74]); + entry.snow_duration2 = atoi(row[75]); + entry.snow_duration3 = atoi(row[76]); + entry.snow_duration4 = atoi(row[77]); + entry.gravity = atof(row[78]); + entry.type = atoi(row[79]); + entry.skylock = atoi(row[80]); + entry.fast_regen_hp = atoi(row[81]); + entry.fast_regen_mana = atoi(row[82]); + entry.fast_regen_endurance = atoi(row[83]); + entry.npc_max_aggro_dist = atoi(row[84]); + entry.max_movement_update_range = atoi(row[85]); + + 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) { + Zone entry{}; + + entry.short_name = row[0] ? row[0] : ""; + entry.id = atoi(row[1]); + entry.file_name = row[2] ? row[2] : ""; + entry.long_name = row[3] ? row[3] : ""; + entry.map_file_name = row[4] ? row[4] : ""; + entry.safe_x = atof(row[5]); + entry.safe_y = atof(row[6]); + entry.safe_z = atof(row[7]); + entry.graveyard_id = atof(row[8]); + entry.min_level = atoi(row[9]); + entry.min_status = atoi(row[10]); + entry.zoneidnumber = atoi(row[11]); + entry.version = atoi(row[12]); + entry.timezone = atoi(row[13]); + entry.maxclients = atoi(row[14]); + entry.ruleset = atoi(row[15]); + entry.note = row[16] ? row[16] : ""; + entry.underworld = atof(row[17]); + entry.minclip = atof(row[18]); + entry.maxclip = atof(row[19]); + entry.fog_minclip = atof(row[20]); + entry.fog_maxclip = atof(row[21]); + entry.fog_blue = atoi(row[22]); + entry.fog_red = atoi(row[23]); + entry.fog_green = atoi(row[24]); + entry.sky = atoi(row[25]); + entry.ztype = atoi(row[26]); + entry.zone_exp_multiplier = atof(row[27]); + entry.walkspeed = atof(row[28]); + entry.time_type = atoi(row[29]); + entry.fog_red1 = atoi(row[30]); + entry.fog_green1 = atoi(row[31]); + entry.fog_blue1 = atoi(row[32]); + entry.fog_minclip1 = atof(row[33]); + entry.fog_maxclip1 = atof(row[34]); + entry.fog_red2 = atoi(row[35]); + entry.fog_green2 = atoi(row[36]); + entry.fog_blue2 = atoi(row[37]); + entry.fog_minclip2 = atof(row[38]); + entry.fog_maxclip2 = atof(row[39]); + entry.fog_red3 = atoi(row[40]); + entry.fog_green3 = atoi(row[41]); + entry.fog_blue3 = atoi(row[42]); + entry.fog_minclip3 = atof(row[43]); + entry.fog_maxclip3 = atof(row[44]); + entry.fog_red4 = atoi(row[45]); + entry.fog_green4 = atoi(row[46]); + entry.fog_blue4 = atoi(row[47]); + entry.fog_minclip4 = atof(row[48]); + entry.fog_maxclip4 = atof(row[49]); + entry.fog_density = atof(row[50]); + entry.flag_needed = row[51] ? row[51] : ""; + entry.canbind = atoi(row[52]); + entry.cancombat = atoi(row[53]); + entry.canlevitate = atoi(row[54]); + entry.castoutdoor = atoi(row[55]); + entry.hotzone = atoi(row[56]); + entry.insttype = atoi(row[57]); + entry.shutdowndelay = atoi(row[58]); + entry.peqzone = atoi(row[59]); + entry.expansion = atoi(row[60]); + entry.suspendbuffs = atoi(row[61]); + entry.rain_chance1 = atoi(row[62]); + entry.rain_chance2 = atoi(row[63]); + entry.rain_chance3 = atoi(row[64]); + entry.rain_chance4 = atoi(row[65]); + entry.rain_duration1 = atoi(row[66]); + entry.rain_duration2 = atoi(row[67]); + entry.rain_duration3 = atoi(row[68]); + entry.rain_duration4 = atoi(row[69]); + entry.snow_chance1 = atoi(row[70]); + entry.snow_chance2 = atoi(row[71]); + entry.snow_chance3 = atoi(row[72]); + entry.snow_chance4 = atoi(row[73]); + entry.snow_duration1 = atoi(row[74]); + entry.snow_duration2 = atoi(row[75]); + entry.snow_duration3 = atoi(row[76]); + entry.snow_duration4 = atoi(row[77]); + entry.gravity = atof(row[78]); + entry.type = atoi(row[79]); + entry.skylock = atoi(row[80]); + entry.fast_regen_hp = atoi(row[81]); + entry.fast_regen_mana = atoi(row[82]); + entry.fast_regen_endurance = atoi(row[83]); + entry.npc_max_aggro_dist = atoi(row[84]); + entry.max_movement_update_range = atoi(row[85]); + + 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(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_ZONE_REPOSITORY_H diff --git a/common/repositories/base_data_repository.h b/common/repositories/base_data_repository.h new file mode 100644 index 000000000..27b453bcc --- /dev/null +++ b/common/repositories/base_data_repository.h @@ -0,0 +1,68 @@ +/** + * 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_BASE_DATA_REPOSITORY_H +#define EQEMU_BASE_DATA_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_base_data_repository.h" + +class BaseDataRepository: public BaseBaseDataRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * BaseDataRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * BaseDataRepository::GetWhereNeverExpires() + * BaseDataRepository::GetWhereXAndY() + * BaseDataRepository::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_BASE_DATA_REPOSITORY_H diff --git a/common/repositories/blocked_spells_repository.h b/common/repositories/blocked_spells_repository.h new file mode 100644 index 000000000..0f5add1df --- /dev/null +++ b/common/repositories/blocked_spells_repository.h @@ -0,0 +1,68 @@ +/** + * 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_BLOCKED_SPELLS_REPOSITORY_H +#define EQEMU_BLOCKED_SPELLS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_blocked_spells_repository.h" + +class BlockedSpellsRepository: public BaseBlockedSpellsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * BlockedSpellsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * BlockedSpellsRepository::GetWhereNeverExpires() + * BlockedSpellsRepository::GetWhereXAndY() + * BlockedSpellsRepository::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_BLOCKED_SPELLS_REPOSITORY_H diff --git a/common/repositories/books_repository.h b/common/repositories/books_repository.h new file mode 100644 index 000000000..a1e6aab98 --- /dev/null +++ b/common/repositories/books_repository.h @@ -0,0 +1,68 @@ +/** + * 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_BOOKS_REPOSITORY_H +#define EQEMU_BOOKS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_books_repository.h" + +class BooksRepository: public BaseBooksRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * BooksRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * BooksRepository::GetWhereNeverExpires() + * BooksRepository::GetWhereXAndY() + * BooksRepository::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_BOOKS_REPOSITORY_H diff --git a/common/repositories/bug_reports_repository.h b/common/repositories/bug_reports_repository.h new file mode 100644 index 000000000..39f19275b --- /dev/null +++ b/common/repositories/bug_reports_repository.h @@ -0,0 +1,68 @@ +/** + * 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_BUG_REPORTS_REPOSITORY_H +#define EQEMU_BUG_REPORTS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_bug_reports_repository.h" + +class BugReportsRepository: public BaseBugReportsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * BugReportsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * BugReportsRepository::GetWhereNeverExpires() + * BugReportsRepository::GetWhereXAndY() + * BugReportsRepository::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_BUG_REPORTS_REPOSITORY_H diff --git a/common/repositories/bugs_repository.h b/common/repositories/bugs_repository.h new file mode 100644 index 000000000..b78b7f9cd --- /dev/null +++ b/common/repositories/bugs_repository.h @@ -0,0 +1,68 @@ +/** + * 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_BUGS_REPOSITORY_H +#define EQEMU_BUGS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_bugs_repository.h" + +class BugsRepository: public BaseBugsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * BugsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * BugsRepository::GetWhereNeverExpires() + * BugsRepository::GetWhereXAndY() + * BugsRepository::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_BUGS_REPOSITORY_H diff --git a/common/repositories/buyer_repository.h b/common/repositories/buyer_repository.h new file mode 100644 index 000000000..147d8266e --- /dev/null +++ b/common/repositories/buyer_repository.h @@ -0,0 +1,68 @@ +/** + * 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_BUYER_REPOSITORY_H +#define EQEMU_BUYER_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_buyer_repository.h" + +class BuyerRepository: public BaseBuyerRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * BuyerRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * BuyerRepository::GetWhereNeverExpires() + * BuyerRepository::GetWhereXAndY() + * BuyerRepository::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_BUYER_REPOSITORY_H diff --git a/common/repositories/char_create_combinations_repository.h b/common/repositories/char_create_combinations_repository.h new file mode 100644 index 000000000..22164139a --- /dev/null +++ b/common/repositories/char_create_combinations_repository.h @@ -0,0 +1,68 @@ +/** + * 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_CHAR_CREATE_COMBINATIONS_REPOSITORY_H +#define EQEMU_CHAR_CREATE_COMBINATIONS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_char_create_combinations_repository.h" + +class CharCreateCombinationsRepository: public BaseCharCreateCombinationsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharCreateCombinationsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharCreateCombinationsRepository::GetWhereNeverExpires() + * CharCreateCombinationsRepository::GetWhereXAndY() + * CharCreateCombinationsRepository::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_CHAR_CREATE_COMBINATIONS_REPOSITORY_H diff --git a/common/repositories/char_create_point_allocations_repository.h b/common/repositories/char_create_point_allocations_repository.h new file mode 100644 index 000000000..62b47e82c --- /dev/null +++ b/common/repositories/char_create_point_allocations_repository.h @@ -0,0 +1,68 @@ +/** + * 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_CHAR_CREATE_POINT_ALLOCATIONS_REPOSITORY_H +#define EQEMU_CHAR_CREATE_POINT_ALLOCATIONS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_char_create_point_allocations_repository.h" + +class CharCreatePointAllocationsRepository: public BaseCharCreatePointAllocationsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharCreatePointAllocationsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharCreatePointAllocationsRepository::GetWhereNeverExpires() + * CharCreatePointAllocationsRepository::GetWhereXAndY() + * CharCreatePointAllocationsRepository::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_CHAR_CREATE_POINT_ALLOCATIONS_REPOSITORY_H diff --git a/common/repositories/char_recipe_list_repository.h b/common/repositories/char_recipe_list_repository.h new file mode 100644 index 000000000..aa991958e --- /dev/null +++ b/common/repositories/char_recipe_list_repository.h @@ -0,0 +1,68 @@ +/** + * 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_CHAR_RECIPE_LIST_REPOSITORY_H +#define EQEMU_CHAR_RECIPE_LIST_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_char_recipe_list_repository.h" + +class CharRecipeListRepository: public BaseCharRecipeListRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharRecipeListRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharRecipeListRepository::GetWhereNeverExpires() + * CharRecipeListRepository::GetWhereXAndY() + * CharRecipeListRepository::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_CHAR_RECIPE_LIST_REPOSITORY_H diff --git a/common/repositories/character_activities_repository.h b/common/repositories/character_activities_repository.h new file mode 100644 index 000000000..256ef50e8 --- /dev/null +++ b/common/repositories/character_activities_repository.h @@ -0,0 +1,68 @@ +/** + * 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_ACTIVITIES_REPOSITORY_H +#define EQEMU_CHARACTER_ACTIVITIES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_activities_repository.h" + +class CharacterActivitiesRepository: public BaseCharacterActivitiesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterActivitiesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterActivitiesRepository::GetWhereNeverExpires() + * CharacterActivitiesRepository::GetWhereXAndY() + * CharacterActivitiesRepository::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_ACTIVITIES_REPOSITORY_H diff --git a/common/repositories/character_alt_currency_repository.h b/common/repositories/character_alt_currency_repository.h new file mode 100644 index 000000000..9624a39c8 --- /dev/null +++ b/common/repositories/character_alt_currency_repository.h @@ -0,0 +1,68 @@ +/** + * 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_ALT_CURRENCY_REPOSITORY_H +#define EQEMU_CHARACTER_ALT_CURRENCY_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_alt_currency_repository.h" + +class CharacterAltCurrencyRepository: public BaseCharacterAltCurrencyRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterAltCurrencyRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterAltCurrencyRepository::GetWhereNeverExpires() + * CharacterAltCurrencyRepository::GetWhereXAndY() + * CharacterAltCurrencyRepository::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_ALT_CURRENCY_REPOSITORY_H diff --git a/common/repositories/character_alternate_abilities_repository.h b/common/repositories/character_alternate_abilities_repository.h new file mode 100644 index 000000000..3818c60ec --- /dev/null +++ b/common/repositories/character_alternate_abilities_repository.h @@ -0,0 +1,68 @@ +/** + * 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_ALTERNATE_ABILITIES_REPOSITORY_H +#define EQEMU_CHARACTER_ALTERNATE_ABILITIES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_alternate_abilities_repository.h" + +class CharacterAlternateAbilitiesRepository: public BaseCharacterAlternateAbilitiesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterAlternateAbilitiesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterAlternateAbilitiesRepository::GetWhereNeverExpires() + * CharacterAlternateAbilitiesRepository::GetWhereXAndY() + * CharacterAlternateAbilitiesRepository::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_ALTERNATE_ABILITIES_REPOSITORY_H diff --git a/common/repositories/character_auras_repository.h b/common/repositories/character_auras_repository.h new file mode 100644 index 000000000..a7a8047ec --- /dev/null +++ b/common/repositories/character_auras_repository.h @@ -0,0 +1,68 @@ +/** + * 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_AURAS_REPOSITORY_H +#define EQEMU_CHARACTER_AURAS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_auras_repository.h" + +class CharacterAurasRepository: public BaseCharacterAurasRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterAurasRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterAurasRepository::GetWhereNeverExpires() + * CharacterAurasRepository::GetWhereXAndY() + * CharacterAurasRepository::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_AURAS_REPOSITORY_H diff --git a/common/repositories/character_bandolier_repository.h b/common/repositories/character_bandolier_repository.h new file mode 100644 index 000000000..37400929d --- /dev/null +++ b/common/repositories/character_bandolier_repository.h @@ -0,0 +1,68 @@ +/** + * 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_BANDOLIER_REPOSITORY_H +#define EQEMU_CHARACTER_BANDOLIER_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_bandolier_repository.h" + +class CharacterBandolierRepository: public BaseCharacterBandolierRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterBandolierRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterBandolierRepository::GetWhereNeverExpires() + * CharacterBandolierRepository::GetWhereXAndY() + * CharacterBandolierRepository::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_BANDOLIER_REPOSITORY_H diff --git a/common/repositories/character_bind_repository.h b/common/repositories/character_bind_repository.h new file mode 100644 index 000000000..ba61113e4 --- /dev/null +++ b/common/repositories/character_bind_repository.h @@ -0,0 +1,68 @@ +/** + * 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_BIND_REPOSITORY_H +#define EQEMU_CHARACTER_BIND_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_bind_repository.h" + +class CharacterBindRepository: public BaseCharacterBindRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterBindRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterBindRepository::GetWhereNeverExpires() + * CharacterBindRepository::GetWhereXAndY() + * CharacterBindRepository::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_BIND_REPOSITORY_H diff --git a/common/repositories/character_buffs_repository.h b/common/repositories/character_buffs_repository.h new file mode 100644 index 000000000..45c59eb8b --- /dev/null +++ b/common/repositories/character_buffs_repository.h @@ -0,0 +1,68 @@ +/** + * 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_BUFFS_REPOSITORY_H +#define EQEMU_CHARACTER_BUFFS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_buffs_repository.h" + +class CharacterBuffsRepository: public BaseCharacterBuffsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterBuffsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterBuffsRepository::GetWhereNeverExpires() + * CharacterBuffsRepository::GetWhereXAndY() + * CharacterBuffsRepository::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_BUFFS_REPOSITORY_H diff --git a/common/repositories/character_corpse_items_repository.h b/common/repositories/character_corpse_items_repository.h new file mode 100644 index 000000000..f564799ad --- /dev/null +++ b/common/repositories/character_corpse_items_repository.h @@ -0,0 +1,68 @@ +/** + * 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_CORPSE_ITEMS_REPOSITORY_H +#define EQEMU_CHARACTER_CORPSE_ITEMS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_corpse_items_repository.h" + +class CharacterCorpseItemsRepository: public BaseCharacterCorpseItemsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterCorpseItemsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterCorpseItemsRepository::GetWhereNeverExpires() + * CharacterCorpseItemsRepository::GetWhereXAndY() + * CharacterCorpseItemsRepository::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_CORPSE_ITEMS_REPOSITORY_H diff --git a/common/repositories/character_corpses_repository.h b/common/repositories/character_corpses_repository.h new file mode 100644 index 000000000..cc91ea17f --- /dev/null +++ b/common/repositories/character_corpses_repository.h @@ -0,0 +1,68 @@ +/** + * 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_CORPSES_REPOSITORY_H +#define EQEMU_CHARACTER_CORPSES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_corpses_repository.h" + +class CharacterCorpsesRepository: public BaseCharacterCorpsesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterCorpsesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterCorpsesRepository::GetWhereNeverExpires() + * CharacterCorpsesRepository::GetWhereXAndY() + * CharacterCorpsesRepository::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_CORPSES_REPOSITORY_H diff --git a/common/repositories/character_currency_repository.h b/common/repositories/character_currency_repository.h new file mode 100644 index 000000000..6b9254c82 --- /dev/null +++ b/common/repositories/character_currency_repository.h @@ -0,0 +1,68 @@ +/** + * 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_CURRENCY_REPOSITORY_H +#define EQEMU_CHARACTER_CURRENCY_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_currency_repository.h" + +class CharacterCurrencyRepository: public BaseCharacterCurrencyRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterCurrencyRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterCurrencyRepository::GetWhereNeverExpires() + * CharacterCurrencyRepository::GetWhereXAndY() + * CharacterCurrencyRepository::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_CURRENCY_REPOSITORY_H diff --git a/common/repositories/character_data_repository.h b/common/repositories/character_data_repository.h new file mode 100644 index 000000000..c9b86fc27 --- /dev/null +++ b/common/repositories/character_data_repository.h @@ -0,0 +1,68 @@ +/** + * 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_DATA_REPOSITORY_H +#define EQEMU_CHARACTER_DATA_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_data_repository.h" + +class CharacterDataRepository: public BaseCharacterDataRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterDataRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterDataRepository::GetWhereNeverExpires() + * CharacterDataRepository::GetWhereXAndY() + * CharacterDataRepository::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_DATA_REPOSITORY_H diff --git a/common/repositories/character_disciplines_repository.h b/common/repositories/character_disciplines_repository.h new file mode 100644 index 000000000..51ea09d17 --- /dev/null +++ b/common/repositories/character_disciplines_repository.h @@ -0,0 +1,68 @@ +/** + * 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_DISCIPLINES_REPOSITORY_H +#define EQEMU_CHARACTER_DISCIPLINES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_disciplines_repository.h" + +class CharacterDisciplinesRepository: public BaseCharacterDisciplinesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterDisciplinesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterDisciplinesRepository::GetWhereNeverExpires() + * CharacterDisciplinesRepository::GetWhereXAndY() + * CharacterDisciplinesRepository::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_DISCIPLINES_REPOSITORY_H diff --git a/common/repositories/character_inspect_messages_repository.h b/common/repositories/character_inspect_messages_repository.h new file mode 100644 index 000000000..998335d53 --- /dev/null +++ b/common/repositories/character_inspect_messages_repository.h @@ -0,0 +1,68 @@ +/** + * 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_INSPECT_MESSAGES_REPOSITORY_H +#define EQEMU_CHARACTER_INSPECT_MESSAGES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_inspect_messages_repository.h" + +class CharacterInspectMessagesRepository: public BaseCharacterInspectMessagesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterInspectMessagesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterInspectMessagesRepository::GetWhereNeverExpires() + * CharacterInspectMessagesRepository::GetWhereXAndY() + * CharacterInspectMessagesRepository::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_INSPECT_MESSAGES_REPOSITORY_H diff --git a/common/repositories/character_item_recast_repository.h b/common/repositories/character_item_recast_repository.h new file mode 100644 index 000000000..8fe170901 --- /dev/null +++ b/common/repositories/character_item_recast_repository.h @@ -0,0 +1,68 @@ +/** + * 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_ITEM_RECAST_REPOSITORY_H +#define EQEMU_CHARACTER_ITEM_RECAST_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_item_recast_repository.h" + +class CharacterItemRecastRepository: public BaseCharacterItemRecastRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterItemRecastRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterItemRecastRepository::GetWhereNeverExpires() + * CharacterItemRecastRepository::GetWhereXAndY() + * CharacterItemRecastRepository::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_ITEM_RECAST_REPOSITORY_H diff --git a/common/repositories/character_languages_repository.h b/common/repositories/character_languages_repository.h new file mode 100644 index 000000000..5be597adf --- /dev/null +++ b/common/repositories/character_languages_repository.h @@ -0,0 +1,68 @@ +/** + * 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_LANGUAGES_REPOSITORY_H +#define EQEMU_CHARACTER_LANGUAGES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_languages_repository.h" + +class CharacterLanguagesRepository: public BaseCharacterLanguagesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterLanguagesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterLanguagesRepository::GetWhereNeverExpires() + * CharacterLanguagesRepository::GetWhereXAndY() + * CharacterLanguagesRepository::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_LANGUAGES_REPOSITORY_H diff --git a/common/repositories/character_leadership_abilities_repository.h b/common/repositories/character_leadership_abilities_repository.h new file mode 100644 index 000000000..770c3c456 --- /dev/null +++ b/common/repositories/character_leadership_abilities_repository.h @@ -0,0 +1,68 @@ +/** + * 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_LEADERSHIP_ABILITIES_REPOSITORY_H +#define EQEMU_CHARACTER_LEADERSHIP_ABILITIES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_leadership_abilities_repository.h" + +class CharacterLeadershipAbilitiesRepository: public BaseCharacterLeadershipAbilitiesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterLeadershipAbilitiesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterLeadershipAbilitiesRepository::GetWhereNeverExpires() + * CharacterLeadershipAbilitiesRepository::GetWhereXAndY() + * CharacterLeadershipAbilitiesRepository::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_LEADERSHIP_ABILITIES_REPOSITORY_H diff --git a/common/repositories/character_material_repository.h b/common/repositories/character_material_repository.h new file mode 100644 index 000000000..644baa081 --- /dev/null +++ b/common/repositories/character_material_repository.h @@ -0,0 +1,68 @@ +/** + * 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_MATERIAL_REPOSITORY_H +#define EQEMU_CHARACTER_MATERIAL_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_material_repository.h" + +class CharacterMaterialRepository: public BaseCharacterMaterialRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterMaterialRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterMaterialRepository::GetWhereNeverExpires() + * CharacterMaterialRepository::GetWhereXAndY() + * CharacterMaterialRepository::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_MATERIAL_REPOSITORY_H diff --git a/common/repositories/character_memmed_spells_repository.h b/common/repositories/character_memmed_spells_repository.h new file mode 100644 index 000000000..59933ac23 --- /dev/null +++ b/common/repositories/character_memmed_spells_repository.h @@ -0,0 +1,68 @@ +/** + * 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_MEMMED_SPELLS_REPOSITORY_H +#define EQEMU_CHARACTER_MEMMED_SPELLS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_memmed_spells_repository.h" + +class CharacterMemmedSpellsRepository: public BaseCharacterMemmedSpellsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterMemmedSpellsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterMemmedSpellsRepository::GetWhereNeverExpires() + * CharacterMemmedSpellsRepository::GetWhereXAndY() + * CharacterMemmedSpellsRepository::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_MEMMED_SPELLS_REPOSITORY_H diff --git a/common/repositories/character_pet_buffs_repository.h b/common/repositories/character_pet_buffs_repository.h new file mode 100644 index 000000000..a7e780aed --- /dev/null +++ b/common/repositories/character_pet_buffs_repository.h @@ -0,0 +1,68 @@ +/** + * 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_PET_BUFFS_REPOSITORY_H +#define EQEMU_CHARACTER_PET_BUFFS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_pet_buffs_repository.h" + +class CharacterPetBuffsRepository: public BaseCharacterPetBuffsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterPetBuffsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterPetBuffsRepository::GetWhereNeverExpires() + * CharacterPetBuffsRepository::GetWhereXAndY() + * CharacterPetBuffsRepository::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_PET_BUFFS_REPOSITORY_H diff --git a/common/repositories/character_pet_info_repository.h b/common/repositories/character_pet_info_repository.h new file mode 100644 index 000000000..06e400abb --- /dev/null +++ b/common/repositories/character_pet_info_repository.h @@ -0,0 +1,68 @@ +/** + * 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_PET_INFO_REPOSITORY_H +#define EQEMU_CHARACTER_PET_INFO_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_pet_info_repository.h" + +class CharacterPetInfoRepository: public BaseCharacterPetInfoRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterPetInfoRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterPetInfoRepository::GetWhereNeverExpires() + * CharacterPetInfoRepository::GetWhereXAndY() + * CharacterPetInfoRepository::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_PET_INFO_REPOSITORY_H diff --git a/common/repositories/character_pet_inventory_repository.h b/common/repositories/character_pet_inventory_repository.h new file mode 100644 index 000000000..972b0b7c6 --- /dev/null +++ b/common/repositories/character_pet_inventory_repository.h @@ -0,0 +1,68 @@ +/** + * 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_PET_INVENTORY_REPOSITORY_H +#define EQEMU_CHARACTER_PET_INVENTORY_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_pet_inventory_repository.h" + +class CharacterPetInventoryRepository: public BaseCharacterPetInventoryRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterPetInventoryRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterPetInventoryRepository::GetWhereNeverExpires() + * CharacterPetInventoryRepository::GetWhereXAndY() + * CharacterPetInventoryRepository::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_PET_INVENTORY_REPOSITORY_H diff --git a/common/repositories/character_potionbelt_repository.h b/common/repositories/character_potionbelt_repository.h new file mode 100644 index 000000000..7d02c1f39 --- /dev/null +++ b/common/repositories/character_potionbelt_repository.h @@ -0,0 +1,68 @@ +/** + * 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_POTIONBELT_REPOSITORY_H +#define EQEMU_CHARACTER_POTIONBELT_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_potionbelt_repository.h" + +class CharacterPotionbeltRepository: public BaseCharacterPotionbeltRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterPotionbeltRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterPotionbeltRepository::GetWhereNeverExpires() + * CharacterPotionbeltRepository::GetWhereXAndY() + * CharacterPotionbeltRepository::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_POTIONBELT_REPOSITORY_H diff --git a/common/repositories/character_skills_repository.h b/common/repositories/character_skills_repository.h new file mode 100644 index 000000000..044f5987a --- /dev/null +++ b/common/repositories/character_skills_repository.h @@ -0,0 +1,68 @@ +/** + * 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_SKILLS_REPOSITORY_H +#define EQEMU_CHARACTER_SKILLS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_skills_repository.h" + +class CharacterSkillsRepository: public BaseCharacterSkillsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterSkillsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterSkillsRepository::GetWhereNeverExpires() + * CharacterSkillsRepository::GetWhereXAndY() + * CharacterSkillsRepository::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_SKILLS_REPOSITORY_H diff --git a/common/repositories/character_spells_repository.h b/common/repositories/character_spells_repository.h new file mode 100644 index 000000000..f2af87b01 --- /dev/null +++ b/common/repositories/character_spells_repository.h @@ -0,0 +1,68 @@ +/** + * 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_SPELLS_REPOSITORY_H +#define EQEMU_CHARACTER_SPELLS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_spells_repository.h" + +class CharacterSpellsRepository: public BaseCharacterSpellsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterSpellsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterSpellsRepository::GetWhereNeverExpires() + * CharacterSpellsRepository::GetWhereXAndY() + * CharacterSpellsRepository::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_SPELLS_REPOSITORY_H diff --git a/common/repositories/character_tasks_repository.h b/common/repositories/character_tasks_repository.h new file mode 100644 index 000000000..33a452327 --- /dev/null +++ b/common/repositories/character_tasks_repository.h @@ -0,0 +1,68 @@ +/** + * 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_TASKS_REPOSITORY_H +#define EQEMU_CHARACTER_TASKS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_tasks_repository.h" + +class CharacterTasksRepository: public BaseCharacterTasksRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterTasksRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterTasksRepository::GetWhereNeverExpires() + * CharacterTasksRepository::GetWhereXAndY() + * CharacterTasksRepository::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_TASKS_REPOSITORY_H diff --git a/common/repositories/character_tribute_repository.h b/common/repositories/character_tribute_repository.h new file mode 100644 index 000000000..30edd2bfb --- /dev/null +++ b/common/repositories/character_tribute_repository.h @@ -0,0 +1,68 @@ +/** + * 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_TRIBUTE_REPOSITORY_H +#define EQEMU_CHARACTER_TRIBUTE_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_tribute_repository.h" + +class CharacterTributeRepository: public BaseCharacterTributeRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterTributeRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterTributeRepository::GetWhereNeverExpires() + * CharacterTributeRepository::GetWhereXAndY() + * CharacterTributeRepository::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_TRIBUTE_REPOSITORY_H diff --git a/common/repositories/chatchannels_repository.h b/common/repositories/chatchannels_repository.h new file mode 100644 index 000000000..3fef234f6 --- /dev/null +++ b/common/repositories/chatchannels_repository.h @@ -0,0 +1,68 @@ +/** + * 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_CHATCHANNELS_REPOSITORY_H +#define EQEMU_CHATCHANNELS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_chatchannels_repository.h" + +class ChatchannelsRepository: public BaseChatchannelsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * ChatchannelsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * ChatchannelsRepository::GetWhereNeverExpires() + * ChatchannelsRepository::GetWhereXAndY() + * ChatchannelsRepository::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_CHATCHANNELS_REPOSITORY_H diff --git a/common/repositories/command_settings_repository.h b/common/repositories/command_settings_repository.h new file mode 100644 index 000000000..34021b399 --- /dev/null +++ b/common/repositories/command_settings_repository.h @@ -0,0 +1,68 @@ +/** + * 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_COMMAND_SETTINGS_REPOSITORY_H +#define EQEMU_COMMAND_SETTINGS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_command_settings_repository.h" + +class CommandSettingsRepository: public BaseCommandSettingsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CommandSettingsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CommandSettingsRepository::GetWhereNeverExpires() + * CommandSettingsRepository::GetWhereXAndY() + * CommandSettingsRepository::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_COMMAND_SETTINGS_REPOSITORY_H diff --git a/common/repositories/completed_tasks_repository.h b/common/repositories/completed_tasks_repository.h new file mode 100644 index 000000000..ae2a50b3f --- /dev/null +++ b/common/repositories/completed_tasks_repository.h @@ -0,0 +1,68 @@ +/** + * 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_COMPLETED_TASKS_REPOSITORY_H +#define EQEMU_COMPLETED_TASKS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_completed_tasks_repository.h" + +class CompletedTasksRepository: public BaseCompletedTasksRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CompletedTasksRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CompletedTasksRepository::GetWhereNeverExpires() + * CompletedTasksRepository::GetWhereXAndY() + * CompletedTasksRepository::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_COMPLETED_TASKS_REPOSITORY_H diff --git a/common/repositories/data_buckets_repository.h b/common/repositories/data_buckets_repository.h new file mode 100644 index 000000000..19a24c68e --- /dev/null +++ b/common/repositories/data_buckets_repository.h @@ -0,0 +1,68 @@ +/** + * 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_DATA_BUCKETS_REPOSITORY_H +#define EQEMU_DATA_BUCKETS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_data_buckets_repository.h" + +class DataBucketsRepository: public BaseDataBucketsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * DataBucketsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * DataBucketsRepository::GetWhereNeverExpires() + * DataBucketsRepository::GetWhereXAndY() + * DataBucketsRepository::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_DATA_BUCKETS_REPOSITORY_H diff --git a/common/repositories/db_str_repository.h b/common/repositories/db_str_repository.h new file mode 100644 index 000000000..70287a843 --- /dev/null +++ b/common/repositories/db_str_repository.h @@ -0,0 +1,68 @@ +/** + * 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_DB_STR_REPOSITORY_H +#define EQEMU_DB_STR_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_db_str_repository.h" + +class DbStrRepository: public BaseDbStrRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * DbStrRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * DbStrRepository::GetWhereNeverExpires() + * DbStrRepository::GetWhereXAndY() + * DbStrRepository::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_DB_STR_REPOSITORY_H diff --git a/common/repositories/discovered_items_repository.h b/common/repositories/discovered_items_repository.h new file mode 100644 index 000000000..b77872a9a --- /dev/null +++ b/common/repositories/discovered_items_repository.h @@ -0,0 +1,68 @@ +/** + * 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_DISCOVERED_ITEMS_REPOSITORY_H +#define EQEMU_DISCOVERED_ITEMS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_discovered_items_repository.h" + +class DiscoveredItemsRepository: public BaseDiscoveredItemsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * DiscoveredItemsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * DiscoveredItemsRepository::GetWhereNeverExpires() + * DiscoveredItemsRepository::GetWhereXAndY() + * DiscoveredItemsRepository::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_DISCOVERED_ITEMS_REPOSITORY_H diff --git a/common/repositories/doors_repository.h b/common/repositories/doors_repository.h new file mode 100644 index 000000000..1e66478d6 --- /dev/null +++ b/common/repositories/doors_repository.h @@ -0,0 +1,68 @@ +/** + * 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_DOORS_REPOSITORY_H +#define EQEMU_DOORS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_doors_repository.h" + +class DoorsRepository: public BaseDoorsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * DoorsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * DoorsRepository::GetWhereNeverExpires() + * DoorsRepository::GetWhereXAndY() + * DoorsRepository::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_DOORS_REPOSITORY_H diff --git a/common/repositories/eventlog_repository.h b/common/repositories/eventlog_repository.h new file mode 100644 index 000000000..e316a5d54 --- /dev/null +++ b/common/repositories/eventlog_repository.h @@ -0,0 +1,68 @@ +/** + * 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_EVENTLOG_REPOSITORY_H +#define EQEMU_EVENTLOG_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_eventlog_repository.h" + +class EventlogRepository: public BaseEventlogRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * EventlogRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * EventlogRepository::GetWhereNeverExpires() + * EventlogRepository::GetWhereXAndY() + * EventlogRepository::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_EVENTLOG_REPOSITORY_H diff --git a/common/repositories/faction_base_data_repository.h b/common/repositories/faction_base_data_repository.h new file mode 100644 index 000000000..0cc968803 --- /dev/null +++ b/common/repositories/faction_base_data_repository.h @@ -0,0 +1,68 @@ +/** + * 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_FACTION_BASE_DATA_REPOSITORY_H +#define EQEMU_FACTION_BASE_DATA_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_faction_base_data_repository.h" + +class FactionBaseDataRepository: public BaseFactionBaseDataRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * FactionBaseDataRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * FactionBaseDataRepository::GetWhereNeverExpires() + * FactionBaseDataRepository::GetWhereXAndY() + * FactionBaseDataRepository::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_FACTION_BASE_DATA_REPOSITORY_H diff --git a/common/repositories/faction_list_mod_repository.h b/common/repositories/faction_list_mod_repository.h new file mode 100644 index 000000000..99834150f --- /dev/null +++ b/common/repositories/faction_list_mod_repository.h @@ -0,0 +1,68 @@ +/** + * 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_FACTION_LIST_MOD_REPOSITORY_H +#define EQEMU_FACTION_LIST_MOD_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_faction_list_mod_repository.h" + +class FactionListModRepository: public BaseFactionListModRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * FactionListModRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * FactionListModRepository::GetWhereNeverExpires() + * FactionListModRepository::GetWhereXAndY() + * FactionListModRepository::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_FACTION_LIST_MOD_REPOSITORY_H diff --git a/common/repositories/faction_list_repository.h b/common/repositories/faction_list_repository.h new file mode 100644 index 000000000..8a83996e7 --- /dev/null +++ b/common/repositories/faction_list_repository.h @@ -0,0 +1,68 @@ +/** + * 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_FACTION_LIST_REPOSITORY_H +#define EQEMU_FACTION_LIST_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_faction_list_repository.h" + +class FactionListRepository: public BaseFactionListRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * FactionListRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * FactionListRepository::GetWhereNeverExpires() + * FactionListRepository::GetWhereXAndY() + * FactionListRepository::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_FACTION_LIST_REPOSITORY_H diff --git a/common/repositories/faction_values_repository.h b/common/repositories/faction_values_repository.h new file mode 100644 index 000000000..721a535dd --- /dev/null +++ b/common/repositories/faction_values_repository.h @@ -0,0 +1,68 @@ +/** + * 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_FACTION_VALUES_REPOSITORY_H +#define EQEMU_FACTION_VALUES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_faction_values_repository.h" + +class FactionValuesRepository: public BaseFactionValuesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * FactionValuesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * FactionValuesRepository::GetWhereNeverExpires() + * FactionValuesRepository::GetWhereXAndY() + * FactionValuesRepository::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_FACTION_VALUES_REPOSITORY_H diff --git a/common/repositories/fishing_repository.h b/common/repositories/fishing_repository.h new file mode 100644 index 000000000..3ca1da433 --- /dev/null +++ b/common/repositories/fishing_repository.h @@ -0,0 +1,68 @@ +/** + * 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_FISHING_REPOSITORY_H +#define EQEMU_FISHING_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_fishing_repository.h" + +class FishingRepository: public BaseFishingRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * FishingRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * FishingRepository::GetWhereNeverExpires() + * FishingRepository::GetWhereXAndY() + * FishingRepository::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_FISHING_REPOSITORY_H diff --git a/common/repositories/forage_repository.h b/common/repositories/forage_repository.h new file mode 100644 index 000000000..8f291ce09 --- /dev/null +++ b/common/repositories/forage_repository.h @@ -0,0 +1,68 @@ +/** + * 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_FORAGE_REPOSITORY_H +#define EQEMU_FORAGE_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_forage_repository.h" + +class ForageRepository: public BaseForageRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * ForageRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * ForageRepository::GetWhereNeverExpires() + * ForageRepository::GetWhereXAndY() + * ForageRepository::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_FORAGE_REPOSITORY_H diff --git a/common/repositories/friends_repository.h b/common/repositories/friends_repository.h new file mode 100644 index 000000000..273280511 --- /dev/null +++ b/common/repositories/friends_repository.h @@ -0,0 +1,68 @@ +/** + * 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_FRIENDS_REPOSITORY_H +#define EQEMU_FRIENDS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_friends_repository.h" + +class FriendsRepository: public BaseFriendsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * FriendsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * FriendsRepository::GetWhereNeverExpires() + * FriendsRepository::GetWhereXAndY() + * FriendsRepository::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_FRIENDS_REPOSITORY_H diff --git a/common/repositories/global_loot_repository.h b/common/repositories/global_loot_repository.h new file mode 100644 index 000000000..16614452c --- /dev/null +++ b/common/repositories/global_loot_repository.h @@ -0,0 +1,68 @@ +/** + * 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_GLOBAL_LOOT_REPOSITORY_H +#define EQEMU_GLOBAL_LOOT_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_global_loot_repository.h" + +class GlobalLootRepository: public BaseGlobalLootRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * GlobalLootRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * GlobalLootRepository::GetWhereNeverExpires() + * GlobalLootRepository::GetWhereXAndY() + * GlobalLootRepository::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_GLOBAL_LOOT_REPOSITORY_H diff --git a/common/repositories/gm_ips_repository.h b/common/repositories/gm_ips_repository.h new file mode 100644 index 000000000..656285424 --- /dev/null +++ b/common/repositories/gm_ips_repository.h @@ -0,0 +1,68 @@ +/** + * 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_GM_IPS_REPOSITORY_H +#define EQEMU_GM_IPS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_gm_ips_repository.h" + +class GmIpsRepository: public BaseGmIpsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * GmIpsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * GmIpsRepository::GetWhereNeverExpires() + * GmIpsRepository::GetWhereXAndY() + * GmIpsRepository::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_GM_IPS_REPOSITORY_H diff --git a/common/repositories/goallists_repository.h b/common/repositories/goallists_repository.h new file mode 100644 index 000000000..d1fd6e48a --- /dev/null +++ b/common/repositories/goallists_repository.h @@ -0,0 +1,68 @@ +/** + * 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_GOALLISTS_REPOSITORY_H +#define EQEMU_GOALLISTS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_goallists_repository.h" + +class GoallistsRepository: public BaseGoallistsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * GoallistsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * GoallistsRepository::GetWhereNeverExpires() + * GoallistsRepository::GetWhereXAndY() + * GoallistsRepository::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_GOALLISTS_REPOSITORY_H diff --git a/common/repositories/graveyard_repository.h b/common/repositories/graveyard_repository.h new file mode 100644 index 000000000..d18725c32 --- /dev/null +++ b/common/repositories/graveyard_repository.h @@ -0,0 +1,68 @@ +/** + * 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_GRAVEYARD_REPOSITORY_H +#define EQEMU_GRAVEYARD_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_graveyard_repository.h" + +class GraveyardRepository: public BaseGraveyardRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * GraveyardRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * GraveyardRepository::GetWhereNeverExpires() + * GraveyardRepository::GetWhereXAndY() + * GraveyardRepository::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_GRAVEYARD_REPOSITORY_H diff --git a/common/repositories/grid_repository.h b/common/repositories/grid_repository.h index 49305c33b..ea965546e 100644 --- a/common/repositories/grid_repository.h +++ b/common/repositories/grid_repository.h @@ -23,58 +23,45 @@ #include "../database.h" #include "../string_util.h" +#include "base/base_grid_repository.h" -class GridRepository { +class GridRepository : public BaseGridRepository { public: - struct Grid { - int id; - int zoneid; - int type; - int type2; - }; - static std::vector Columns() - { - return { - "id", - "zoneid", - "type", - "type2", - }; - } + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * GridRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * GridRepository::GetWhereNeverExpires() + * GridRepository::GetWhereXAndY() + * GridRepository::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 + */ - static std::string ColumnsRaw() - { - return std::string(implode(", ", Columns())); - } - - static std::string TableName() - { - return std::string("grid"); - } - - static std::string BaseSelect() - { - return std::string( - fmt::format( - "SELECT {} FROM {}", - ColumnsRaw(), - TableName() - ) - ); - } - - static Grid NewEntity() - { - Grid entry{}; - - entry.id = 0; - entry.zoneid = 0; - entry.type = 0; - entry.type2 = 0; - - return entry; - } + // Custom extended repository methods here static std::vector GetZoneGrids(int zone_id) { @@ -103,7 +90,7 @@ public: } static Grid GetGrid( - const std::vector& grids, + const std::vector &grids, int grid_id ) { @@ -118,4 +105,4 @@ public: }; -#endif +#endif //EQEMU_GRID_REPOSITORY_H diff --git a/common/repositories/ground_spawns_repository.h b/common/repositories/ground_spawns_repository.h new file mode 100644 index 000000000..e56d25d97 --- /dev/null +++ b/common/repositories/ground_spawns_repository.h @@ -0,0 +1,68 @@ +/** + * 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_GROUND_SPAWNS_REPOSITORY_H +#define EQEMU_GROUND_SPAWNS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_ground_spawns_repository.h" + +class GroundSpawnsRepository: public BaseGroundSpawnsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * GroundSpawnsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * GroundSpawnsRepository::GetWhereNeverExpires() + * GroundSpawnsRepository::GetWhereXAndY() + * GroundSpawnsRepository::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_GROUND_SPAWNS_REPOSITORY_H diff --git a/common/repositories/group_id_repository.h b/common/repositories/group_id_repository.h new file mode 100644 index 000000000..8b78b6eeb --- /dev/null +++ b/common/repositories/group_id_repository.h @@ -0,0 +1,68 @@ +/** + * 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_GROUP_ID_REPOSITORY_H +#define EQEMU_GROUP_ID_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_group_id_repository.h" + +class GroupIdRepository: public BaseGroupIdRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * GroupIdRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * GroupIdRepository::GetWhereNeverExpires() + * GroupIdRepository::GetWhereXAndY() + * GroupIdRepository::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_GROUP_ID_REPOSITORY_H diff --git a/common/repositories/group_leaders_repository.h b/common/repositories/group_leaders_repository.h new file mode 100644 index 000000000..5a44bb751 --- /dev/null +++ b/common/repositories/group_leaders_repository.h @@ -0,0 +1,68 @@ +/** + * 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_GROUP_LEADERS_REPOSITORY_H +#define EQEMU_GROUP_LEADERS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_group_leaders_repository.h" + +class GroupLeadersRepository: public BaseGroupLeadersRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * GroupLeadersRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * GroupLeadersRepository::GetWhereNeverExpires() + * GroupLeadersRepository::GetWhereXAndY() + * GroupLeadersRepository::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_GROUP_LEADERS_REPOSITORY_H diff --git a/common/repositories/guild_bank_repository.h b/common/repositories/guild_bank_repository.h new file mode 100644 index 000000000..d23b66653 --- /dev/null +++ b/common/repositories/guild_bank_repository.h @@ -0,0 +1,309 @@ +/** + * 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_GUILD_BANK_REPOSITORY_H +#define EQEMU_GUILD_BANK_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" + +class GuildBankRepository { +public: + struct GuildBank { + int guildid; + int8 area; + int slot; + int itemid; + int qty; + std::string donator; + int8 permissions; + std::string whofor; + }; + + static std::string PrimaryKey() + { + return std::string(""); + } + + static std::vector Columns() + { + return { + "guildid", + "area", + "slot", + "itemid", + "qty", + "donator", + "permissions", + "whofor", + }; + } + + 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("guild_bank"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static GuildBank NewEntity() + { + GuildBank entry{}; + + entry.guildid = 0; + entry.area = 0; + entry.slot = 0; + entry.itemid = 0; + entry.qty = 0; + entry.donator = 0; + entry.permissions = 0; + entry.whofor = 0; + + return entry; + } + + static GuildBank GetGuildBankEntry( + const std::vector &guild_banks, + int guild_bank_id + ) + { + for (auto &guild_bank : guild_banks) { + if (guild_bank. == guild_bank_id) { + return guild_bank; + } + } + + return NewEntity(); + } + + static GuildBank FindOne( + int guild_bank_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + guild_bank_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + GuildBank entry{}; + + entry.guildid = atoi(row[0]); + entry.area = atoi(row[1]); + entry.slot = atoi(row[2]); + entry.itemid = atoi(row[3]); + entry.qty = atoi(row[4]); + entry.donator = row[5]; + entry.permissions = atoi(row[6]); + entry.whofor = row[7]; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int guild_bank_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + guild_bank_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + GuildBank guild_bank_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[0] + " = " + std::to_string(guild_bank_entry.guildid)); + update_values.push_back(columns[1] + " = " + std::to_string(guild_bank_entry.area)); + update_values.push_back(columns[2] + " = " + std::to_string(guild_bank_entry.slot)); + update_values.push_back(columns[3] + " = " + std::to_string(guild_bank_entry.itemid)); + update_values.push_back(columns[4] + " = " + std::to_string(guild_bank_entry.qty)); + update_values.push_back(columns[5] + " = '" + EscapeString(guild_bank_entry.donator) + "'"); + update_values.push_back(columns[6] + " = " + std::to_string(guild_bank_entry.permissions)); + update_values.push_back(columns[7] + " = '" + EscapeString(guild_bank_entry.whofor) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + guild_bank_entry. + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static GuildBank InsertOne( + GuildBank guild_bank_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(guild_bank_entry.guildid)); + insert_values.push_back(std::to_string(guild_bank_entry.area)); + insert_values.push_back(std::to_string(guild_bank_entry.slot)); + insert_values.push_back(std::to_string(guild_bank_entry.itemid)); + insert_values.push_back(std::to_string(guild_bank_entry.qty)); + insert_values.push_back("'" + EscapeString(guild_bank_entry.donator) + "'"); + insert_values.push_back(std::to_string(guild_bank_entry.permissions)); + insert_values.push_back("'" + EscapeString(guild_bank_entry.whofor) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + guild_bank_entry.id = results.LastInsertedID(); + return guild_bank_entry; + } + + guild_bank_entry = InstanceListRepository::NewEntity(); + + return guild_bank_entry; + } + + static int InsertMany( + std::vector guild_bank_entries + ) + { + std::vector insert_chunks; + + for (auto &guild_bank_entry: guild_bank_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(guild_bank_entry.guildid)); + insert_values.push_back(std::to_string(guild_bank_entry.area)); + insert_values.push_back(std::to_string(guild_bank_entry.slot)); + insert_values.push_back(std::to_string(guild_bank_entry.itemid)); + insert_values.push_back(std::to_string(guild_bank_entry.qty)); + insert_values.push_back("'" + EscapeString(guild_bank_entry.donator) + "'"); + insert_values.push_back(std::to_string(guild_bank_entry.permissions)); + insert_values.push_back("'" + EscapeString(guild_bank_entry.whofor) + "'"); + + 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) { + GuildBank entry{}; + + entry.guildid = atoi(row[0]); + entry.area = atoi(row[1]); + entry.slot = atoi(row[2]); + entry.itemid = atoi(row[3]); + entry.qty = atoi(row[4]); + entry.donator = row[5]; + entry.permissions = atoi(row[6]); + entry.whofor = row[7]; + + all_entries.push_back(entry); + } + + return all_entries; + } + +}; + +#endif //EQEMU_GUILD_BANK_REPOSITORY_H diff --git a/common/repositories/guild_members_repository.h b/common/repositories/guild_members_repository.h new file mode 100644 index 000000000..16cbdbc10 --- /dev/null +++ b/common/repositories/guild_members_repository.h @@ -0,0 +1,68 @@ +/** + * 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_GUILD_MEMBERS_REPOSITORY_H +#define EQEMU_GUILD_MEMBERS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_guild_members_repository.h" + +class GuildMembersRepository: public BaseGuildMembersRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * GuildMembersRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * GuildMembersRepository::GetWhereNeverExpires() + * GuildMembersRepository::GetWhereXAndY() + * GuildMembersRepository::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_GUILD_MEMBERS_REPOSITORY_H diff --git a/common/repositories/guild_ranks_repository.h b/common/repositories/guild_ranks_repository.h new file mode 100644 index 000000000..24e012eb3 --- /dev/null +++ b/common/repositories/guild_ranks_repository.h @@ -0,0 +1,68 @@ +/** + * 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_GUILD_RANKS_REPOSITORY_H +#define EQEMU_GUILD_RANKS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_guild_ranks_repository.h" + +class GuildRanksRepository: public BaseGuildRanksRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * GuildRanksRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * GuildRanksRepository::GetWhereNeverExpires() + * GuildRanksRepository::GetWhereXAndY() + * GuildRanksRepository::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_GUILD_RANKS_REPOSITORY_H diff --git a/common/repositories/guild_relations_repository.h b/common/repositories/guild_relations_repository.h new file mode 100644 index 000000000..ce2e6f638 --- /dev/null +++ b/common/repositories/guild_relations_repository.h @@ -0,0 +1,68 @@ +/** + * 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_GUILD_RELATIONS_REPOSITORY_H +#define EQEMU_GUILD_RELATIONS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_guild_relations_repository.h" + +class GuildRelationsRepository: public BaseGuildRelationsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * GuildRelationsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * GuildRelationsRepository::GetWhereNeverExpires() + * GuildRelationsRepository::GetWhereXAndY() + * GuildRelationsRepository::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_GUILD_RELATIONS_REPOSITORY_H diff --git a/common/repositories/guilds_repository.h b/common/repositories/guilds_repository.h new file mode 100644 index 000000000..dbb2984e9 --- /dev/null +++ b/common/repositories/guilds_repository.h @@ -0,0 +1,68 @@ +/** + * 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_GUILDS_REPOSITORY_H +#define EQEMU_GUILDS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_guilds_repository.h" + +class GuildsRepository: public BaseGuildsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * GuildsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * GuildsRepository::GetWhereNeverExpires() + * GuildsRepository::GetWhereXAndY() + * GuildsRepository::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_GUILDS_REPOSITORY_H diff --git a/common/repositories/hackers_repository.h b/common/repositories/hackers_repository.h new file mode 100644 index 000000000..8bacd5b7a --- /dev/null +++ b/common/repositories/hackers_repository.h @@ -0,0 +1,68 @@ +/** + * 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_HACKERS_REPOSITORY_H +#define EQEMU_HACKERS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_hackers_repository.h" + +class HackersRepository: public BaseHackersRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * HackersRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * HackersRepository::GetWhereNeverExpires() + * HackersRepository::GetWhereXAndY() + * HackersRepository::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_HACKERS_REPOSITORY_H diff --git a/common/repositories/horses_repository.h b/common/repositories/horses_repository.h new file mode 100644 index 000000000..108d7c1da --- /dev/null +++ b/common/repositories/horses_repository.h @@ -0,0 +1,68 @@ +/** + * 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_HORSES_REPOSITORY_H +#define EQEMU_HORSES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_horses_repository.h" + +class HorsesRepository: public BaseHorsesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * HorsesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * HorsesRepository::GetWhereNeverExpires() + * HorsesRepository::GetWhereXAndY() + * HorsesRepository::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_HORSES_REPOSITORY_H diff --git a/common/repositories/instance_list_player_repository.h b/common/repositories/instance_list_player_repository.h new file mode 100644 index 000000000..474b34917 --- /dev/null +++ b/common/repositories/instance_list_player_repository.h @@ -0,0 +1,68 @@ +/** + * 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_INSTANCE_LIST_PLAYER_REPOSITORY_H +#define EQEMU_INSTANCE_LIST_PLAYER_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_instance_list_player_repository.h" + +class InstanceListPlayerRepository: public BaseInstanceListPlayerRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * InstanceListPlayerRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * InstanceListPlayerRepository::GetWhereNeverExpires() + * InstanceListPlayerRepository::GetWhereXAndY() + * InstanceListPlayerRepository::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_INSTANCE_LIST_PLAYER_REPOSITORY_H diff --git a/common/repositories/instance_list_repository.h b/common/repositories/instance_list_repository.h index cc2c113a3..39cbd9b47 100644 --- a/common/repositories/instance_list_repository.h +++ b/common/repositories/instance_list_repository.h @@ -23,275 +23,45 @@ #include "../database.h" #include "../string_util.h" +#include "base/base_instance_list_repository.h" -class InstanceListRepository { +class InstanceListRepository: public BaseInstanceListRepository { public: - struct InstanceList { - int id; - int zone; - int8 version; - int8 is_global; - int start_time; - int duration; - int8 never_expires; - }; - static std::string PrimaryKey() - { - return std::string("id"); - } + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * InstanceListRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * InstanceListRepository::GetWhereNeverExpires() + * InstanceListRepository::GetWhereXAndY() + * InstanceListRepository::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 + */ - static std::vector Columns() - { - return { - "id", - "zone", - "version", - "is_global", - "start_time", - "duration", - "never_expires", - }; - } - - 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("instance_list"); - } - - static std::string BaseSelect() - { - return fmt::format( - "SELECT {} FROM {}", - ColumnsRaw(), - TableName() - ); - } - - static std::string BaseInsert() - { - return fmt::format( - "INSERT INTO {} ({}) ", - TableName(), - InsertColumnsRaw() - ); - } - - static InstanceList NewEntity() - { - InstanceList entry{}; - - entry.id = 0; - entry.zone = 0; - entry.version = 0; - entry.is_global = 0; - entry.start_time = 0; - entry.duration = 0; - entry.never_expires = 0; - - return entry; - } - - static InstanceList GetInstanceListEntry( - const std::vector &instance_lists, - int instance_list_id - ) - { - for (auto &instance_list : instance_lists) { - if (instance_list.id == instance_list_id) { - return instance_list; - } - } - - return NewEntity(); - } - - static InstanceList FindOne( - int instance_list_id - ) - { - auto results = database.QueryDatabase( - fmt::format( - "{} WHERE id = {} LIMIT 1", - BaseSelect(), - instance_list_id - ) - ); - - auto row = results.begin(); - if (results.RowCount() == 1) { - InstanceList entry{}; - - entry.id = atoi(row[0]); - entry.zone = atoi(row[1]); - entry.version = atoi(row[2]); - entry.is_global = atoi(row[3]); - entry.start_time = atoi(row[4]); - entry.duration = atoi(row[5]); - entry.never_expires = atoi(row[6]); - - return entry; - } - - return NewEntity(); - } - - static int DeleteOne( - int instance_list_id - ) - { - auto results = database.QueryDatabase( - fmt::format( - "DELETE FROM {} WHERE {} = {}", - TableName(), - PrimaryKey(), - instance_list_id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static int UpdateOne( - InstanceList instance_list_entry - ) - { - std::vector update_values; - - auto columns = Columns(); - - update_values.push_back(columns[1] + " = " + std::to_string(instance_list_entry.zone)); - update_values.push_back(columns[2] + " = " + std::to_string(instance_list_entry.version)); - update_values.push_back(columns[3] + " = " + std::to_string(instance_list_entry.is_global)); - update_values.push_back(columns[4] + " = " + std::to_string(instance_list_entry.start_time)); - update_values.push_back(columns[5] + " = " + std::to_string(instance_list_entry.duration)); - update_values.push_back(columns[6] + " = " + std::to_string(instance_list_entry.never_expires)); - - auto results = database.QueryDatabase( - fmt::format( - "UPDATE {} SET {} WHERE {} = {}", - TableName(), - implode(", ", update_values), - PrimaryKey(), - instance_list_entry.id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static InstanceList InsertOne( - InstanceList instance_list_entry - ) - { - std::vector insert_values; - - insert_values.push_back(std::to_string(instance_list_entry.zone)); - insert_values.push_back(std::to_string(instance_list_entry.version)); - insert_values.push_back(std::to_string(instance_list_entry.is_global)); - insert_values.push_back(std::to_string(instance_list_entry.start_time)); - insert_values.push_back(std::to_string(instance_list_entry.duration)); - insert_values.push_back(std::to_string(instance_list_entry.never_expires)); - - auto results = database.QueryDatabase( - fmt::format( - "{} VALUES ({})", - BaseInsert(), - implode(",", insert_values) - ) - ); - - if (results.Success()) { - instance_list_entry.id = results.LastInsertedID(); - return instance_list_entry; - } - - instance_list_entry = InstanceListRepository::NewEntity(); - - return instance_list_entry; - } - - static int InsertMany( - std::vector instance_list_entries - ) - { - std::vector insert_chunks; - - for (auto &instance_list_entry: instance_list_entries) { - std::vector insert_values; - - insert_values.push_back(std::to_string(instance_list_entry.zone)); - insert_values.push_back(std::to_string(instance_list_entry.version)); - insert_values.push_back(std::to_string(instance_list_entry.is_global)); - insert_values.push_back(std::to_string(instance_list_entry.start_time)); - insert_values.push_back(std::to_string(instance_list_entry.duration)); - insert_values.push_back(std::to_string(instance_list_entry.never_expires)); - - 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) { - InstanceList entry{}; - - entry.id = atoi(row[0]); - entry.zone = atoi(row[1]); - entry.version = atoi(row[2]); - entry.is_global = atoi(row[3]); - entry.start_time = atoi(row[4]); - entry.duration = atoi(row[5]); - entry.never_expires = atoi(row[6]); - - all_entries.push_back(entry); - } - - return all_entries; - } + // Custom extended repository methods here }; diff --git a/common/repositories/inventory_repository.h b/common/repositories/inventory_repository.h new file mode 100644 index 000000000..8ae1d1c46 --- /dev/null +++ b/common/repositories/inventory_repository.h @@ -0,0 +1,68 @@ +/** + * 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_INVENTORY_REPOSITORY_H +#define EQEMU_INVENTORY_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_inventory_repository.h" + +class InventoryRepository: public BaseInventoryRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * InventoryRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * InventoryRepository::GetWhereNeverExpires() + * InventoryRepository::GetWhereXAndY() + * InventoryRepository::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_INVENTORY_REPOSITORY_H diff --git a/common/repositories/inventory_snapshots_repository.h b/common/repositories/inventory_snapshots_repository.h new file mode 100644 index 000000000..b8d60eeaf --- /dev/null +++ b/common/repositories/inventory_snapshots_repository.h @@ -0,0 +1,68 @@ +/** + * 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_INVENTORY_SNAPSHOTS_REPOSITORY_H +#define EQEMU_INVENTORY_SNAPSHOTS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_inventory_snapshots_repository.h" + +class InventorySnapshotsRepository: public BaseInventorySnapshotsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * InventorySnapshotsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * InventorySnapshotsRepository::GetWhereNeverExpires() + * InventorySnapshotsRepository::GetWhereXAndY() + * InventorySnapshotsRepository::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_INVENTORY_SNAPSHOTS_REPOSITORY_H diff --git a/common/repositories/inventory_versions_repository.h b/common/repositories/inventory_versions_repository.h new file mode 100644 index 000000000..4469756de --- /dev/null +++ b/common/repositories/inventory_versions_repository.h @@ -0,0 +1,269 @@ +/** + * 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_INVENTORY_VERSIONS_REPOSITORY_H +#define EQEMU_INVENTORY_VERSIONS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" + +class InventoryVersionsRepository { +public: + struct InventoryVersions { + int version; + int step; + int bot_step; + }; + + static std::string PrimaryKey() + { + return std::string(""); + } + + static std::vector Columns() + { + return { + "version", + "step", + "bot_step", + }; + } + + 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("inventory_versions"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static InventoryVersions NewEntity() + { + InventoryVersions entry{}; + + entry.version = 0; + entry.step = 0; + entry.bot_step = 0; + + return entry; + } + + static InventoryVersions GetInventoryVersionsEntry( + const std::vector &inventory_versionss, + int inventory_versions_id + ) + { + for (auto &inventory_versions : inventory_versionss) { + if (inventory_versions. == inventory_versions_id) { + return inventory_versions; + } + } + + return NewEntity(); + } + + static InventoryVersions FindOne( + int inventory_versions_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + inventory_versions_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + InventoryVersions entry{}; + + entry.version = atoi(row[0]); + entry.step = atoi(row[1]); + entry.bot_step = atoi(row[2]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int inventory_versions_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + inventory_versions_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + InventoryVersions inventory_versions_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[0] + " = " + std::to_string(inventory_versions_entry.version)); + update_values.push_back(columns[1] + " = " + std::to_string(inventory_versions_entry.step)); + update_values.push_back(columns[2] + " = " + std::to_string(inventory_versions_entry.bot_step)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + inventory_versions_entry. + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static InventoryVersions InsertOne( + InventoryVersions inventory_versions_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(inventory_versions_entry.version)); + insert_values.push_back(std::to_string(inventory_versions_entry.step)); + insert_values.push_back(std::to_string(inventory_versions_entry.bot_step)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + inventory_versions_entry.id = results.LastInsertedID(); + return inventory_versions_entry; + } + + inventory_versions_entry = InstanceListRepository::NewEntity(); + + return inventory_versions_entry; + } + + static int InsertMany( + std::vector inventory_versions_entries + ) + { + std::vector insert_chunks; + + for (auto &inventory_versions_entry: inventory_versions_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(inventory_versions_entry.version)); + insert_values.push_back(std::to_string(inventory_versions_entry.step)); + insert_values.push_back(std::to_string(inventory_versions_entry.bot_step)); + + 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) { + InventoryVersions entry{}; + + entry.version = atoi(row[0]); + entry.step = atoi(row[1]); + entry.bot_step = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + +}; + +#endif //EQEMU_INVENTORY_VERSIONS_REPOSITORY_H diff --git a/common/repositories/ip_exemptions_repository.h b/common/repositories/ip_exemptions_repository.h new file mode 100644 index 000000000..71ad7dfb3 --- /dev/null +++ b/common/repositories/ip_exemptions_repository.h @@ -0,0 +1,68 @@ +/** + * 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_IP_EXEMPTIONS_REPOSITORY_H +#define EQEMU_IP_EXEMPTIONS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_ip_exemptions_repository.h" + +class IpExemptionsRepository: public BaseIpExemptionsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * IpExemptionsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * IpExemptionsRepository::GetWhereNeverExpires() + * IpExemptionsRepository::GetWhereXAndY() + * IpExemptionsRepository::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_IP_EXEMPTIONS_REPOSITORY_H diff --git a/common/repositories/item_tick_repository.h b/common/repositories/item_tick_repository.h new file mode 100644 index 000000000..b120aa794 --- /dev/null +++ b/common/repositories/item_tick_repository.h @@ -0,0 +1,68 @@ +/** + * 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_ITEM_TICK_REPOSITORY_H +#define EQEMU_ITEM_TICK_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_item_tick_repository.h" + +class ItemTickRepository: public BaseItemTickRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * ItemTickRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * ItemTickRepository::GetWhereNeverExpires() + * ItemTickRepository::GetWhereXAndY() + * ItemTickRepository::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_ITEM_TICK_REPOSITORY_H diff --git a/common/repositories/items_repository.h b/common/repositories/items_repository.h new file mode 100644 index 000000000..1e12a4720 --- /dev/null +++ b/common/repositories/items_repository.h @@ -0,0 +1,68 @@ +/** + * 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_ITEMS_REPOSITORY_H +#define EQEMU_ITEMS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_items_repository.h" + +class ItemsRepository: public BaseItemsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * ItemsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * ItemsRepository::GetWhereNeverExpires() + * ItemsRepository::GetWhereXAndY() + * ItemsRepository::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_ITEMS_REPOSITORY_H diff --git a/common/repositories/launcher_repository.h b/common/repositories/launcher_repository.h new file mode 100644 index 000000000..413167faf --- /dev/null +++ b/common/repositories/launcher_repository.h @@ -0,0 +1,68 @@ +/** + * 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_LAUNCHER_REPOSITORY_H +#define EQEMU_LAUNCHER_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_launcher_repository.h" + +class LauncherRepository: public BaseLauncherRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * LauncherRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * LauncherRepository::GetWhereNeverExpires() + * LauncherRepository::GetWhereXAndY() + * LauncherRepository::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_LAUNCHER_REPOSITORY_H diff --git a/common/repositories/launcher_zones_repository.h b/common/repositories/launcher_zones_repository.h new file mode 100644 index 000000000..ed0facae4 --- /dev/null +++ b/common/repositories/launcher_zones_repository.h @@ -0,0 +1,68 @@ +/** + * 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_LAUNCHER_ZONES_REPOSITORY_H +#define EQEMU_LAUNCHER_ZONES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_launcher_zones_repository.h" + +class LauncherZonesRepository: public BaseLauncherZonesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * LauncherZonesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * LauncherZonesRepository::GetWhereNeverExpires() + * LauncherZonesRepository::GetWhereXAndY() + * LauncherZonesRepository::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_LAUNCHER_ZONES_REPOSITORY_H diff --git a/common/repositories/ldon_trap_entries_repository.h b/common/repositories/ldon_trap_entries_repository.h new file mode 100644 index 000000000..9bd96ed2f --- /dev/null +++ b/common/repositories/ldon_trap_entries_repository.h @@ -0,0 +1,68 @@ +/** + * 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_LDON_TRAP_ENTRIES_REPOSITORY_H +#define EQEMU_LDON_TRAP_ENTRIES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_ldon_trap_entries_repository.h" + +class LdonTrapEntriesRepository: public BaseLdonTrapEntriesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * LdonTrapEntriesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * LdonTrapEntriesRepository::GetWhereNeverExpires() + * LdonTrapEntriesRepository::GetWhereXAndY() + * LdonTrapEntriesRepository::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_LDON_TRAP_ENTRIES_REPOSITORY_H diff --git a/common/repositories/ldon_trap_templates_repository.h b/common/repositories/ldon_trap_templates_repository.h new file mode 100644 index 000000000..636c6592f --- /dev/null +++ b/common/repositories/ldon_trap_templates_repository.h @@ -0,0 +1,68 @@ +/** + * 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_LDON_TRAP_TEMPLATES_REPOSITORY_H +#define EQEMU_LDON_TRAP_TEMPLATES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_ldon_trap_templates_repository.h" + +class LdonTrapTemplatesRepository: public BaseLdonTrapTemplatesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * LdonTrapTemplatesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * LdonTrapTemplatesRepository::GetWhereNeverExpires() + * LdonTrapTemplatesRepository::GetWhereXAndY() + * LdonTrapTemplatesRepository::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_LDON_TRAP_TEMPLATES_REPOSITORY_H diff --git a/common/repositories/level_exp_mods_repository.h b/common/repositories/level_exp_mods_repository.h new file mode 100644 index 000000000..5e1485814 --- /dev/null +++ b/common/repositories/level_exp_mods_repository.h @@ -0,0 +1,68 @@ +/** + * 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_LEVEL_EXP_MODS_REPOSITORY_H +#define EQEMU_LEVEL_EXP_MODS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_level_exp_mods_repository.h" + +class LevelExpModsRepository: public BaseLevelExpModsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * LevelExpModsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * LevelExpModsRepository::GetWhereNeverExpires() + * LevelExpModsRepository::GetWhereXAndY() + * LevelExpModsRepository::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_LEVEL_EXP_MODS_REPOSITORY_H diff --git a/common/repositories/lfguild_repository.h b/common/repositories/lfguild_repository.h new file mode 100644 index 000000000..4552fb776 --- /dev/null +++ b/common/repositories/lfguild_repository.h @@ -0,0 +1,68 @@ +/** + * 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_LFGUILD_REPOSITORY_H +#define EQEMU_LFGUILD_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_lfguild_repository.h" + +class LfguildRepository: public BaseLfguildRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * LfguildRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * LfguildRepository::GetWhereNeverExpires() + * LfguildRepository::GetWhereXAndY() + * LfguildRepository::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_LFGUILD_REPOSITORY_H diff --git a/common/repositories/login_accounts_repository.h b/common/repositories/login_accounts_repository.h new file mode 100644 index 000000000..72eda1280 --- /dev/null +++ b/common/repositories/login_accounts_repository.h @@ -0,0 +1,68 @@ +/** + * 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_LOGIN_ACCOUNTS_REPOSITORY_H +#define EQEMU_LOGIN_ACCOUNTS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_login_accounts_repository.h" + +class LoginAccountsRepository: public BaseLoginAccountsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * LoginAccountsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * LoginAccountsRepository::GetWhereNeverExpires() + * LoginAccountsRepository::GetWhereXAndY() + * LoginAccountsRepository::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_LOGIN_ACCOUNTS_REPOSITORY_H diff --git a/common/repositories/login_api_tokens_repository.h b/common/repositories/login_api_tokens_repository.h new file mode 100644 index 000000000..64aa1022d --- /dev/null +++ b/common/repositories/login_api_tokens_repository.h @@ -0,0 +1,68 @@ +/** + * 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_LOGIN_API_TOKENS_REPOSITORY_H +#define EQEMU_LOGIN_API_TOKENS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_login_api_tokens_repository.h" + +class LoginApiTokensRepository: public BaseLoginApiTokensRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * LoginApiTokensRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * LoginApiTokensRepository::GetWhereNeverExpires() + * LoginApiTokensRepository::GetWhereXAndY() + * LoginApiTokensRepository::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_LOGIN_API_TOKENS_REPOSITORY_H diff --git a/common/repositories/login_server_admins_repository.h b/common/repositories/login_server_admins_repository.h new file mode 100644 index 000000000..e11868d53 --- /dev/null +++ b/common/repositories/login_server_admins_repository.h @@ -0,0 +1,68 @@ +/** + * 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_LOGIN_SERVER_ADMINS_REPOSITORY_H +#define EQEMU_LOGIN_SERVER_ADMINS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_login_server_admins_repository.h" + +class LoginServerAdminsRepository: public BaseLoginServerAdminsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * LoginServerAdminsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * LoginServerAdminsRepository::GetWhereNeverExpires() + * LoginServerAdminsRepository::GetWhereXAndY() + * LoginServerAdminsRepository::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_LOGIN_SERVER_ADMINS_REPOSITORY_H diff --git a/common/repositories/login_server_list_types_repository.h b/common/repositories/login_server_list_types_repository.h new file mode 100644 index 000000000..4a2593326 --- /dev/null +++ b/common/repositories/login_server_list_types_repository.h @@ -0,0 +1,68 @@ +/** + * 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_LOGIN_SERVER_LIST_TYPES_REPOSITORY_H +#define EQEMU_LOGIN_SERVER_LIST_TYPES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_login_server_list_types_repository.h" + +class LoginServerListTypesRepository: public BaseLoginServerListTypesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * LoginServerListTypesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * LoginServerListTypesRepository::GetWhereNeverExpires() + * LoginServerListTypesRepository::GetWhereXAndY() + * LoginServerListTypesRepository::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_LOGIN_SERVER_LIST_TYPES_REPOSITORY_H diff --git a/common/repositories/login_world_servers_repository.h b/common/repositories/login_world_servers_repository.h new file mode 100644 index 000000000..4a90a696e --- /dev/null +++ b/common/repositories/login_world_servers_repository.h @@ -0,0 +1,68 @@ +/** + * 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_LOGIN_WORLD_SERVERS_REPOSITORY_H +#define EQEMU_LOGIN_WORLD_SERVERS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_login_world_servers_repository.h" + +class LoginWorldServersRepository: public BaseLoginWorldServersRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * LoginWorldServersRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * LoginWorldServersRepository::GetWhereNeverExpires() + * LoginWorldServersRepository::GetWhereXAndY() + * LoginWorldServersRepository::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_LOGIN_WORLD_SERVERS_REPOSITORY_H diff --git a/common/repositories/logsys_categories_repository.h b/common/repositories/logsys_categories_repository.h new file mode 100644 index 000000000..1ce6fe15c --- /dev/null +++ b/common/repositories/logsys_categories_repository.h @@ -0,0 +1,68 @@ +/** + * 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_LOGSYS_CATEGORIES_REPOSITORY_H +#define EQEMU_LOGSYS_CATEGORIES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_logsys_categories_repository.h" + +class LogsysCategoriesRepository: public BaseLogsysCategoriesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * LogsysCategoriesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * LogsysCategoriesRepository::GetWhereNeverExpires() + * LogsysCategoriesRepository::GetWhereXAndY() + * LogsysCategoriesRepository::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_LOGSYS_CATEGORIES_REPOSITORY_H diff --git a/common/repositories/lootdrop_entries_repository.h b/common/repositories/lootdrop_entries_repository.h new file mode 100644 index 000000000..801f9cfb5 --- /dev/null +++ b/common/repositories/lootdrop_entries_repository.h @@ -0,0 +1,68 @@ +/** + * 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_LOOTDROP_ENTRIES_REPOSITORY_H +#define EQEMU_LOOTDROP_ENTRIES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_lootdrop_entries_repository.h" + +class LootdropEntriesRepository: public BaseLootdropEntriesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * LootdropEntriesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * LootdropEntriesRepository::GetWhereNeverExpires() + * LootdropEntriesRepository::GetWhereXAndY() + * LootdropEntriesRepository::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_LOOTDROP_ENTRIES_REPOSITORY_H diff --git a/common/repositories/lootdrop_repository.h b/common/repositories/lootdrop_repository.h new file mode 100644 index 000000000..54ef936c0 --- /dev/null +++ b/common/repositories/lootdrop_repository.h @@ -0,0 +1,68 @@ +/** + * 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_LOOTDROP_REPOSITORY_H +#define EQEMU_LOOTDROP_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_lootdrop_repository.h" + +class LootdropRepository: public BaseLootdropRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * LootdropRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * LootdropRepository::GetWhereNeverExpires() + * LootdropRepository::GetWhereXAndY() + * LootdropRepository::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_LOOTDROP_REPOSITORY_H diff --git a/common/repositories/loottable_entries_repository.h b/common/repositories/loottable_entries_repository.h new file mode 100644 index 000000000..99c05fa0c --- /dev/null +++ b/common/repositories/loottable_entries_repository.h @@ -0,0 +1,68 @@ +/** + * 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_LOOTTABLE_ENTRIES_REPOSITORY_H +#define EQEMU_LOOTTABLE_ENTRIES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_loottable_entries_repository.h" + +class LoottableEntriesRepository: public BaseLoottableEntriesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * LoottableEntriesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * LoottableEntriesRepository::GetWhereNeverExpires() + * LoottableEntriesRepository::GetWhereXAndY() + * LoottableEntriesRepository::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_LOOTTABLE_ENTRIES_REPOSITORY_H diff --git a/common/repositories/loottable_repository.h b/common/repositories/loottable_repository.h new file mode 100644 index 000000000..489156be1 --- /dev/null +++ b/common/repositories/loottable_repository.h @@ -0,0 +1,68 @@ +/** + * 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_LOOTTABLE_REPOSITORY_H +#define EQEMU_LOOTTABLE_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_loottable_repository.h" + +class LoottableRepository: public BaseLoottableRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * LoottableRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * LoottableRepository::GetWhereNeverExpires() + * LoottableRepository::GetWhereXAndY() + * LoottableRepository::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_LOOTTABLE_REPOSITORY_H diff --git a/common/repositories/mail_repository.h b/common/repositories/mail_repository.h new file mode 100644 index 000000000..29c783625 --- /dev/null +++ b/common/repositories/mail_repository.h @@ -0,0 +1,68 @@ +/** + * 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_MAIL_REPOSITORY_H +#define EQEMU_MAIL_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_mail_repository.h" + +class MailRepository: public BaseMailRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * MailRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * MailRepository::GetWhereNeverExpires() + * MailRepository::GetWhereXAndY() + * MailRepository::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_MAIL_REPOSITORY_H diff --git a/common/repositories/merchantlist_repository.h b/common/repositories/merchantlist_repository.h new file mode 100644 index 000000000..9e96290ec --- /dev/null +++ b/common/repositories/merchantlist_repository.h @@ -0,0 +1,68 @@ +/** + * 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_MERCHANTLIST_REPOSITORY_H +#define EQEMU_MERCHANTLIST_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_merchantlist_repository.h" + +class MerchantlistRepository: public BaseMerchantlistRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * MerchantlistRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * MerchantlistRepository::GetWhereNeverExpires() + * MerchantlistRepository::GetWhereXAndY() + * MerchantlistRepository::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_MERCHANTLIST_REPOSITORY_H diff --git a/common/repositories/merchantlist_temp_repository.h b/common/repositories/merchantlist_temp_repository.h new file mode 100644 index 000000000..4b4879fb4 --- /dev/null +++ b/common/repositories/merchantlist_temp_repository.h @@ -0,0 +1,68 @@ +/** + * 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_MERCHANTLIST_TEMP_REPOSITORY_H +#define EQEMU_MERCHANTLIST_TEMP_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_merchantlist_temp_repository.h" + +class MerchantlistTempRepository: public BaseMerchantlistTempRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * MerchantlistTempRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * MerchantlistTempRepository::GetWhereNeverExpires() + * MerchantlistTempRepository::GetWhereXAndY() + * MerchantlistTempRepository::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_MERCHANTLIST_TEMP_REPOSITORY_H diff --git a/common/repositories/name_filter_repository.h b/common/repositories/name_filter_repository.h new file mode 100644 index 000000000..f476d53a8 --- /dev/null +++ b/common/repositories/name_filter_repository.h @@ -0,0 +1,68 @@ +/** + * 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_NAME_FILTER_REPOSITORY_H +#define EQEMU_NAME_FILTER_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_name_filter_repository.h" + +class NameFilterRepository: public BaseNameFilterRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * NameFilterRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * NameFilterRepository::GetWhereNeverExpires() + * NameFilterRepository::GetWhereXAndY() + * NameFilterRepository::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_NAME_FILTER_REPOSITORY_H diff --git a/common/repositories/npc_emotes_repository.h b/common/repositories/npc_emotes_repository.h new file mode 100644 index 000000000..65957cc57 --- /dev/null +++ b/common/repositories/npc_emotes_repository.h @@ -0,0 +1,68 @@ +/** + * 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_NPC_EMOTES_REPOSITORY_H +#define EQEMU_NPC_EMOTES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_npc_emotes_repository.h" + +class NpcEmotesRepository: public BaseNpcEmotesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * NpcEmotesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * NpcEmotesRepository::GetWhereNeverExpires() + * NpcEmotesRepository::GetWhereXAndY() + * NpcEmotesRepository::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_NPC_EMOTES_REPOSITORY_H diff --git a/common/repositories/npc_faction_entries_repository.h b/common/repositories/npc_faction_entries_repository.h new file mode 100644 index 000000000..5a755792e --- /dev/null +++ b/common/repositories/npc_faction_entries_repository.h @@ -0,0 +1,68 @@ +/** + * 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_NPC_FACTION_ENTRIES_REPOSITORY_H +#define EQEMU_NPC_FACTION_ENTRIES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_npc_faction_entries_repository.h" + +class NpcFactionEntriesRepository: public BaseNpcFactionEntriesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * NpcFactionEntriesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * NpcFactionEntriesRepository::GetWhereNeverExpires() + * NpcFactionEntriesRepository::GetWhereXAndY() + * NpcFactionEntriesRepository::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_NPC_FACTION_ENTRIES_REPOSITORY_H diff --git a/common/repositories/npc_faction_repository.h b/common/repositories/npc_faction_repository.h new file mode 100644 index 000000000..425063ca5 --- /dev/null +++ b/common/repositories/npc_faction_repository.h @@ -0,0 +1,68 @@ +/** + * 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_NPC_FACTION_REPOSITORY_H +#define EQEMU_NPC_FACTION_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_npc_faction_repository.h" + +class NpcFactionRepository: public BaseNpcFactionRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * NpcFactionRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * NpcFactionRepository::GetWhereNeverExpires() + * NpcFactionRepository::GetWhereXAndY() + * NpcFactionRepository::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_NPC_FACTION_REPOSITORY_H diff --git a/common/repositories/npc_scale_global_base_repository.h b/common/repositories/npc_scale_global_base_repository.h new file mode 100644 index 000000000..92ee8cf84 --- /dev/null +++ b/common/repositories/npc_scale_global_base_repository.h @@ -0,0 +1,68 @@ +/** + * 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_NPC_SCALE_GLOBAL_BASE_REPOSITORY_H +#define EQEMU_NPC_SCALE_GLOBAL_BASE_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_npc_scale_global_base_repository.h" + +class NpcScaleGlobalBaseRepository: public BaseNpcScaleGlobalBaseRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * NpcScaleGlobalBaseRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * NpcScaleGlobalBaseRepository::GetWhereNeverExpires() + * NpcScaleGlobalBaseRepository::GetWhereXAndY() + * NpcScaleGlobalBaseRepository::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_NPC_SCALE_GLOBAL_BASE_REPOSITORY_H diff --git a/common/repositories/npc_spells_effects_entries_repository.h b/common/repositories/npc_spells_effects_entries_repository.h new file mode 100644 index 000000000..c93e7ebfb --- /dev/null +++ b/common/repositories/npc_spells_effects_entries_repository.h @@ -0,0 +1,68 @@ +/** + * 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_NPC_SPELLS_EFFECTS_ENTRIES_REPOSITORY_H +#define EQEMU_NPC_SPELLS_EFFECTS_ENTRIES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_npc_spells_effects_entries_repository.h" + +class NpcSpellsEffectsEntriesRepository: public BaseNpcSpellsEffectsEntriesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * NpcSpellsEffectsEntriesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * NpcSpellsEffectsEntriesRepository::GetWhereNeverExpires() + * NpcSpellsEffectsEntriesRepository::GetWhereXAndY() + * NpcSpellsEffectsEntriesRepository::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_NPC_SPELLS_EFFECTS_ENTRIES_REPOSITORY_H diff --git a/common/repositories/npc_spells_effects_repository.h b/common/repositories/npc_spells_effects_repository.h new file mode 100644 index 000000000..8f059976c --- /dev/null +++ b/common/repositories/npc_spells_effects_repository.h @@ -0,0 +1,68 @@ +/** + * 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_NPC_SPELLS_EFFECTS_REPOSITORY_H +#define EQEMU_NPC_SPELLS_EFFECTS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_npc_spells_effects_repository.h" + +class NpcSpellsEffectsRepository: public BaseNpcSpellsEffectsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * NpcSpellsEffectsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * NpcSpellsEffectsRepository::GetWhereNeverExpires() + * NpcSpellsEffectsRepository::GetWhereXAndY() + * NpcSpellsEffectsRepository::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_NPC_SPELLS_EFFECTS_REPOSITORY_H diff --git a/common/repositories/npc_spells_entries_repository.h b/common/repositories/npc_spells_entries_repository.h new file mode 100644 index 000000000..a9597fd55 --- /dev/null +++ b/common/repositories/npc_spells_entries_repository.h @@ -0,0 +1,68 @@ +/** + * 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_NPC_SPELLS_ENTRIES_REPOSITORY_H +#define EQEMU_NPC_SPELLS_ENTRIES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_npc_spells_entries_repository.h" + +class NpcSpellsEntriesRepository: public BaseNpcSpellsEntriesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * NpcSpellsEntriesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * NpcSpellsEntriesRepository::GetWhereNeverExpires() + * NpcSpellsEntriesRepository::GetWhereXAndY() + * NpcSpellsEntriesRepository::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_NPC_SPELLS_ENTRIES_REPOSITORY_H diff --git a/common/repositories/npc_spells_repository.h b/common/repositories/npc_spells_repository.h new file mode 100644 index 000000000..9df6e7214 --- /dev/null +++ b/common/repositories/npc_spells_repository.h @@ -0,0 +1,68 @@ +/** + * 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_NPC_SPELLS_REPOSITORY_H +#define EQEMU_NPC_SPELLS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_npc_spells_repository.h" + +class NpcSpellsRepository: public BaseNpcSpellsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * NpcSpellsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * NpcSpellsRepository::GetWhereNeverExpires() + * NpcSpellsRepository::GetWhereXAndY() + * NpcSpellsRepository::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_NPC_SPELLS_REPOSITORY_H diff --git a/common/repositories/npc_types_repository.h b/common/repositories/npc_types_repository.h new file mode 100644 index 000000000..cbcc9e735 --- /dev/null +++ b/common/repositories/npc_types_repository.h @@ -0,0 +1,68 @@ +/** + * 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_NPC_TYPES_REPOSITORY_H +#define EQEMU_NPC_TYPES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_npc_types_repository.h" + +class NpcTypesRepository: public BaseNpcTypesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * NpcTypesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * NpcTypesRepository::GetWhereNeverExpires() + * NpcTypesRepository::GetWhereXAndY() + * NpcTypesRepository::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_NPC_TYPES_REPOSITORY_H diff --git a/common/repositories/npc_types_tint_repository.h b/common/repositories/npc_types_tint_repository.h new file mode 100644 index 000000000..37fdb7714 --- /dev/null +++ b/common/repositories/npc_types_tint_repository.h @@ -0,0 +1,68 @@ +/** + * 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_NPC_TYPES_TINT_REPOSITORY_H +#define EQEMU_NPC_TYPES_TINT_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_npc_types_tint_repository.h" + +class NpcTypesTintRepository: public BaseNpcTypesTintRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * NpcTypesTintRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * NpcTypesTintRepository::GetWhereNeverExpires() + * NpcTypesTintRepository::GetWhereXAndY() + * NpcTypesTintRepository::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_NPC_TYPES_TINT_REPOSITORY_H diff --git a/common/repositories/object_contents_repository.h b/common/repositories/object_contents_repository.h new file mode 100644 index 000000000..ed64e8162 --- /dev/null +++ b/common/repositories/object_contents_repository.h @@ -0,0 +1,68 @@ +/** + * 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_OBJECT_CONTENTS_REPOSITORY_H +#define EQEMU_OBJECT_CONTENTS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_object_contents_repository.h" + +class ObjectContentsRepository: public BaseObjectContentsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * ObjectContentsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * ObjectContentsRepository::GetWhereNeverExpires() + * ObjectContentsRepository::GetWhereXAndY() + * ObjectContentsRepository::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_OBJECT_CONTENTS_REPOSITORY_H diff --git a/common/repositories/object_repository.h b/common/repositories/object_repository.h new file mode 100644 index 000000000..7f4ab5e17 --- /dev/null +++ b/common/repositories/object_repository.h @@ -0,0 +1,68 @@ +/** + * 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_OBJECT_REPOSITORY_H +#define EQEMU_OBJECT_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_object_repository.h" + +class ObjectRepository: public BaseObjectRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * ObjectRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * ObjectRepository::GetWhereNeverExpires() + * ObjectRepository::GetWhereXAndY() + * ObjectRepository::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_OBJECT_REPOSITORY_H diff --git a/common/repositories/perl_event_export_settings_repository.h b/common/repositories/perl_event_export_settings_repository.h new file mode 100644 index 000000000..3b838c410 --- /dev/null +++ b/common/repositories/perl_event_export_settings_repository.h @@ -0,0 +1,68 @@ +/** + * 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_PERL_EVENT_EXPORT_SETTINGS_REPOSITORY_H +#define EQEMU_PERL_EVENT_EXPORT_SETTINGS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_perl_event_export_settings_repository.h" + +class PerlEventExportSettingsRepository: public BasePerlEventExportSettingsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * PerlEventExportSettingsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * PerlEventExportSettingsRepository::GetWhereNeverExpires() + * PerlEventExportSettingsRepository::GetWhereXAndY() + * PerlEventExportSettingsRepository::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_PERL_EVENT_EXPORT_SETTINGS_REPOSITORY_H diff --git a/common/repositories/petitions_repository.h b/common/repositories/petitions_repository.h new file mode 100644 index 000000000..6617527c0 --- /dev/null +++ b/common/repositories/petitions_repository.h @@ -0,0 +1,68 @@ +/** + * 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_PETITIONS_REPOSITORY_H +#define EQEMU_PETITIONS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_petitions_repository.h" + +class PetitionsRepository: public BasePetitionsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * PetitionsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * PetitionsRepository::GetWhereNeverExpires() + * PetitionsRepository::GetWhereXAndY() + * PetitionsRepository::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_PETITIONS_REPOSITORY_H diff --git a/common/repositories/pets_equipmentset_entries_repository.h b/common/repositories/pets_equipmentset_entries_repository.h new file mode 100644 index 000000000..a9d225d9a --- /dev/null +++ b/common/repositories/pets_equipmentset_entries_repository.h @@ -0,0 +1,68 @@ +/** + * 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_PETS_EQUIPMENTSET_ENTRIES_REPOSITORY_H +#define EQEMU_PETS_EQUIPMENTSET_ENTRIES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_pets_equipmentset_entries_repository.h" + +class PetsEquipmentsetEntriesRepository: public BasePetsEquipmentsetEntriesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * PetsEquipmentsetEntriesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * PetsEquipmentsetEntriesRepository::GetWhereNeverExpires() + * PetsEquipmentsetEntriesRepository::GetWhereXAndY() + * PetsEquipmentsetEntriesRepository::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_PETS_EQUIPMENTSET_ENTRIES_REPOSITORY_H diff --git a/common/repositories/pets_equipmentset_repository.h b/common/repositories/pets_equipmentset_repository.h new file mode 100644 index 000000000..5860df600 --- /dev/null +++ b/common/repositories/pets_equipmentset_repository.h @@ -0,0 +1,68 @@ +/** + * 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_PETS_EQUIPMENTSET_REPOSITORY_H +#define EQEMU_PETS_EQUIPMENTSET_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_pets_equipmentset_repository.h" + +class PetsEquipmentsetRepository: public BasePetsEquipmentsetRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * PetsEquipmentsetRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * PetsEquipmentsetRepository::GetWhereNeverExpires() + * PetsEquipmentsetRepository::GetWhereXAndY() + * PetsEquipmentsetRepository::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_PETS_EQUIPMENTSET_REPOSITORY_H diff --git a/common/repositories/pets_repository.h b/common/repositories/pets_repository.h new file mode 100644 index 000000000..88aadd1ec --- /dev/null +++ b/common/repositories/pets_repository.h @@ -0,0 +1,68 @@ +/** + * 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_PETS_REPOSITORY_H +#define EQEMU_PETS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_pets_repository.h" + +class PetsRepository: public BasePetsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * PetsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * PetsRepository::GetWhereNeverExpires() + * PetsRepository::GetWhereXAndY() + * PetsRepository::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_PETS_REPOSITORY_H diff --git a/common/repositories/player_titlesets_repository.h b/common/repositories/player_titlesets_repository.h new file mode 100644 index 000000000..9aa21efa3 --- /dev/null +++ b/common/repositories/player_titlesets_repository.h @@ -0,0 +1,68 @@ +/** + * 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_PLAYER_TITLESETS_REPOSITORY_H +#define EQEMU_PLAYER_TITLESETS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_player_titlesets_repository.h" + +class PlayerTitlesetsRepository: public BasePlayerTitlesetsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * PlayerTitlesetsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * PlayerTitlesetsRepository::GetWhereNeverExpires() + * PlayerTitlesetsRepository::GetWhereXAndY() + * PlayerTitlesetsRepository::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_PLAYER_TITLESETS_REPOSITORY_H diff --git a/common/repositories/proximities_repository.h b/common/repositories/proximities_repository.h new file mode 100644 index 000000000..752b1d11a --- /dev/null +++ b/common/repositories/proximities_repository.h @@ -0,0 +1,68 @@ +/** + * 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_PROXIMITIES_REPOSITORY_H +#define EQEMU_PROXIMITIES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_proximities_repository.h" + +class ProximitiesRepository: public BaseProximitiesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * ProximitiesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * ProximitiesRepository::GetWhereNeverExpires() + * ProximitiesRepository::GetWhereXAndY() + * ProximitiesRepository::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_PROXIMITIES_REPOSITORY_H diff --git a/common/repositories/quest_globals_repository.h b/common/repositories/quest_globals_repository.h new file mode 100644 index 000000000..a82d6adec --- /dev/null +++ b/common/repositories/quest_globals_repository.h @@ -0,0 +1,68 @@ +/** + * 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_QUEST_GLOBALS_REPOSITORY_H +#define EQEMU_QUEST_GLOBALS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_quest_globals_repository.h" + +class QuestGlobalsRepository: public BaseQuestGlobalsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * QuestGlobalsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * QuestGlobalsRepository::GetWhereNeverExpires() + * QuestGlobalsRepository::GetWhereXAndY() + * QuestGlobalsRepository::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_QUEST_GLOBALS_REPOSITORY_H diff --git a/common/repositories/raid_details_repository.h b/common/repositories/raid_details_repository.h new file mode 100644 index 000000000..325077a54 --- /dev/null +++ b/common/repositories/raid_details_repository.h @@ -0,0 +1,68 @@ +/** + * 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_RAID_DETAILS_REPOSITORY_H +#define EQEMU_RAID_DETAILS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_raid_details_repository.h" + +class RaidDetailsRepository: public BaseRaidDetailsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * RaidDetailsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * RaidDetailsRepository::GetWhereNeverExpires() + * RaidDetailsRepository::GetWhereXAndY() + * RaidDetailsRepository::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_RAID_DETAILS_REPOSITORY_H diff --git a/common/repositories/raid_leaders_repository.h b/common/repositories/raid_leaders_repository.h new file mode 100644 index 000000000..592f0ca01 --- /dev/null +++ b/common/repositories/raid_leaders_repository.h @@ -0,0 +1,317 @@ +/** + * 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_RAID_LEADERS_REPOSITORY_H +#define EQEMU_RAID_LEADERS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" + +class RaidLeadersRepository { +public: + struct RaidLeaders { + int gid; + int rid; + std::string marknpc; + std::string maintank; + std::string assist; + std::string puller; + std::string leadershipaa; + std::string mentoree; + int mentor_percent; + }; + + static std::string PrimaryKey() + { + return std::string(""); + } + + static std::vector Columns() + { + return { + "gid", + "rid", + "marknpc", + "maintank", + "assist", + "puller", + "leadershipaa", + "mentoree", + "mentor_percent", + }; + } + + 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("raid_leaders"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static RaidLeaders NewEntity() + { + RaidLeaders entry{}; + + entry.gid = 0; + entry.rid = 0; + entry.marknpc = ""; + entry.maintank = ""; + entry.assist = ""; + entry.puller = ""; + entry.leadershipaa = 0; + entry.mentoree = ""; + entry.mentor_percent = 0; + + return entry; + } + + static RaidLeaders GetRaidLeadersEntry( + const std::vector &raid_leaderss, + int raid_leaders_id + ) + { + for (auto &raid_leaders : raid_leaderss) { + if (raid_leaders. == raid_leaders_id) { + return raid_leaders; + } + } + + return NewEntity(); + } + + static RaidLeaders FindOne( + int raid_leaders_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + raid_leaders_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + RaidLeaders entry{}; + + entry.gid = atoi(row[0]); + entry.rid = atoi(row[1]); + entry.marknpc = row[2]; + entry.maintank = row[3]; + entry.assist = row[4]; + entry.puller = row[5]; + entry.leadershipaa = row[6]; + entry.mentoree = row[7]; + entry.mentor_percent = atoi(row[8]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int raid_leaders_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + raid_leaders_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + RaidLeaders raid_leaders_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[0] + " = " + std::to_string(raid_leaders_entry.gid)); + update_values.push_back(columns[1] + " = " + std::to_string(raid_leaders_entry.rid)); + update_values.push_back(columns[2] + " = '" + EscapeString(raid_leaders_entry.marknpc) + "'"); + update_values.push_back(columns[3] + " = '" + EscapeString(raid_leaders_entry.maintank) + "'"); + update_values.push_back(columns[4] + " = '" + EscapeString(raid_leaders_entry.assist) + "'"); + update_values.push_back(columns[5] + " = '" + EscapeString(raid_leaders_entry.puller) + "'"); + update_values.push_back(columns[6] + " = '" + EscapeString(raid_leaders_entry.leadershipaa) + "'"); + update_values.push_back(columns[7] + " = '" + EscapeString(raid_leaders_entry.mentoree) + "'"); + update_values.push_back(columns[8] + " = " + std::to_string(raid_leaders_entry.mentor_percent)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + raid_leaders_entry. + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static RaidLeaders InsertOne( + RaidLeaders raid_leaders_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(raid_leaders_entry.gid)); + insert_values.push_back(std::to_string(raid_leaders_entry.rid)); + insert_values.push_back("'" + EscapeString(raid_leaders_entry.marknpc) + "'"); + insert_values.push_back("'" + EscapeString(raid_leaders_entry.maintank) + "'"); + insert_values.push_back("'" + EscapeString(raid_leaders_entry.assist) + "'"); + insert_values.push_back("'" + EscapeString(raid_leaders_entry.puller) + "'"); + insert_values.push_back("'" + EscapeString(raid_leaders_entry.leadershipaa) + "'"); + insert_values.push_back("'" + EscapeString(raid_leaders_entry.mentoree) + "'"); + insert_values.push_back(std::to_string(raid_leaders_entry.mentor_percent)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + raid_leaders_entry.id = results.LastInsertedID(); + return raid_leaders_entry; + } + + raid_leaders_entry = InstanceListRepository::NewEntity(); + + return raid_leaders_entry; + } + + static int InsertMany( + std::vector raid_leaders_entries + ) + { + std::vector insert_chunks; + + for (auto &raid_leaders_entry: raid_leaders_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(raid_leaders_entry.gid)); + insert_values.push_back(std::to_string(raid_leaders_entry.rid)); + insert_values.push_back("'" + EscapeString(raid_leaders_entry.marknpc) + "'"); + insert_values.push_back("'" + EscapeString(raid_leaders_entry.maintank) + "'"); + insert_values.push_back("'" + EscapeString(raid_leaders_entry.assist) + "'"); + insert_values.push_back("'" + EscapeString(raid_leaders_entry.puller) + "'"); + insert_values.push_back("'" + EscapeString(raid_leaders_entry.leadershipaa) + "'"); + insert_values.push_back("'" + EscapeString(raid_leaders_entry.mentoree) + "'"); + insert_values.push_back(std::to_string(raid_leaders_entry.mentor_percent)); + + 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) { + RaidLeaders entry{}; + + entry.gid = atoi(row[0]); + entry.rid = atoi(row[1]); + entry.marknpc = row[2]; + entry.maintank = row[3]; + entry.assist = row[4]; + entry.puller = row[5]; + entry.leadershipaa = row[6]; + entry.mentoree = row[7]; + entry.mentor_percent = atoi(row[8]); + + all_entries.push_back(entry); + } + + return all_entries; + } + +}; + +#endif //EQEMU_RAID_LEADERS_REPOSITORY_H diff --git a/common/repositories/raid_members_repository.h b/common/repositories/raid_members_repository.h new file mode 100644 index 000000000..9b6fba9f9 --- /dev/null +++ b/common/repositories/raid_members_repository.h @@ -0,0 +1,68 @@ +/** + * 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_RAID_MEMBERS_REPOSITORY_H +#define EQEMU_RAID_MEMBERS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_raid_members_repository.h" + +class RaidMembersRepository: public BaseRaidMembersRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * RaidMembersRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * RaidMembersRepository::GetWhereNeverExpires() + * RaidMembersRepository::GetWhereXAndY() + * RaidMembersRepository::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_RAID_MEMBERS_REPOSITORY_H diff --git a/common/repositories/reports_repository.h b/common/repositories/reports_repository.h new file mode 100644 index 000000000..2d389028b --- /dev/null +++ b/common/repositories/reports_repository.h @@ -0,0 +1,68 @@ +/** + * 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_REPORTS_REPOSITORY_H +#define EQEMU_REPORTS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_reports_repository.h" + +class ReportsRepository: public BaseReportsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * ReportsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * ReportsRepository::GetWhereNeverExpires() + * ReportsRepository::GetWhereXAndY() + * ReportsRepository::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_REPORTS_REPOSITORY_H diff --git a/common/repositories/respawn_times_repository.h b/common/repositories/respawn_times_repository.h new file mode 100644 index 000000000..3aca3852a --- /dev/null +++ b/common/repositories/respawn_times_repository.h @@ -0,0 +1,68 @@ +/** + * 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_RESPAWN_TIMES_REPOSITORY_H +#define EQEMU_RESPAWN_TIMES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_respawn_times_repository.h" + +class RespawnTimesRepository: public BaseRespawnTimesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * RespawnTimesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * RespawnTimesRepository::GetWhereNeverExpires() + * RespawnTimesRepository::GetWhereXAndY() + * RespawnTimesRepository::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_RESPAWN_TIMES_REPOSITORY_H diff --git a/common/repositories/rule_sets_repository.h b/common/repositories/rule_sets_repository.h new file mode 100644 index 000000000..5d275e28f --- /dev/null +++ b/common/repositories/rule_sets_repository.h @@ -0,0 +1,68 @@ +/** + * 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_RULE_SETS_REPOSITORY_H +#define EQEMU_RULE_SETS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_rule_sets_repository.h" + +class RuleSetsRepository: public BaseRuleSetsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * RuleSetsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * RuleSetsRepository::GetWhereNeverExpires() + * RuleSetsRepository::GetWhereXAndY() + * RuleSetsRepository::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_RULE_SETS_REPOSITORY_H diff --git a/common/repositories/rule_values_repository.h b/common/repositories/rule_values_repository.h new file mode 100644 index 000000000..49fda8ef6 --- /dev/null +++ b/common/repositories/rule_values_repository.h @@ -0,0 +1,68 @@ +/** + * 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_RULE_VALUES_REPOSITORY_H +#define EQEMU_RULE_VALUES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_rule_values_repository.h" + +class RuleValuesRepository: public BaseRuleValuesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * RuleValuesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * RuleValuesRepository::GetWhereNeverExpires() + * RuleValuesRepository::GetWhereXAndY() + * RuleValuesRepository::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_RULE_VALUES_REPOSITORY_H diff --git a/common/repositories/saylink_repository.h b/common/repositories/saylink_repository.h new file mode 100644 index 000000000..6618720b1 --- /dev/null +++ b/common/repositories/saylink_repository.h @@ -0,0 +1,68 @@ +/** + * 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_SAYLINK_REPOSITORY_H +#define EQEMU_SAYLINK_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_saylink_repository.h" + +class SaylinkRepository: public BaseSaylinkRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * SaylinkRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * SaylinkRepository::GetWhereNeverExpires() + * SaylinkRepository::GetWhereXAndY() + * SaylinkRepository::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_SAYLINK_REPOSITORY_H diff --git a/common/repositories/sharedbank_repository.h b/common/repositories/sharedbank_repository.h new file mode 100644 index 000000000..440412ff4 --- /dev/null +++ b/common/repositories/sharedbank_repository.h @@ -0,0 +1,333 @@ +/** + * 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_SHAREDBANK_REPOSITORY_H +#define EQEMU_SHAREDBANK_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" + +class SharedbankRepository { +public: + struct Sharedbank { + int acctid; + int slotid; + int itemid; + int16 charges; + int augslot1; + int augslot2; + int augslot3; + int augslot4; + int augslot5; + int augslot6; + std::string custom_data; + }; + + static std::string PrimaryKey() + { + return std::string(""); + } + + static std::vector Columns() + { + return { + "acctid", + "slotid", + "itemid", + "charges", + "augslot1", + "augslot2", + "augslot3", + "augslot4", + "augslot5", + "augslot6", + "custom_data", + }; + } + + 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("sharedbank"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static Sharedbank NewEntity() + { + Sharedbank entry{}; + + entry.acctid = 0; + entry.slotid = 0; + entry.itemid = 0; + entry.charges = 0; + entry.augslot1 = 0; + entry.augslot2 = 0; + entry.augslot3 = 0; + entry.augslot4 = 0; + entry.augslot5 = 0; + entry.augslot6 = 0; + entry.custom_data = 0; + + return entry; + } + + static Sharedbank GetSharedbankEntry( + const std::vector &sharedbanks, + int sharedbank_id + ) + { + for (auto &sharedbank : sharedbanks) { + if (sharedbank. == sharedbank_id) { + return sharedbank; + } + } + + return NewEntity(); + } + + static Sharedbank FindOne( + int sharedbank_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + sharedbank_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Sharedbank entry{}; + + entry.acctid = atoi(row[0]); + entry.slotid = atoi(row[1]); + entry.itemid = atoi(row[2]); + entry.charges = atoi(row[3]); + entry.augslot1 = atoi(row[4]); + entry.augslot2 = atoi(row[5]); + entry.augslot3 = atoi(row[6]); + entry.augslot4 = atoi(row[7]); + entry.augslot5 = atoi(row[8]); + entry.augslot6 = atoi(row[9]); + entry.custom_data = row[10]; + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int sharedbank_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + sharedbank_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Sharedbank sharedbank_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[0] + " = " + std::to_string(sharedbank_entry.acctid)); + update_values.push_back(columns[1] + " = " + std::to_string(sharedbank_entry.slotid)); + update_values.push_back(columns[2] + " = " + std::to_string(sharedbank_entry.itemid)); + update_values.push_back(columns[3] + " = " + std::to_string(sharedbank_entry.charges)); + update_values.push_back(columns[4] + " = " + std::to_string(sharedbank_entry.augslot1)); + update_values.push_back(columns[5] + " = " + std::to_string(sharedbank_entry.augslot2)); + update_values.push_back(columns[6] + " = " + std::to_string(sharedbank_entry.augslot3)); + update_values.push_back(columns[7] + " = " + std::to_string(sharedbank_entry.augslot4)); + update_values.push_back(columns[8] + " = " + std::to_string(sharedbank_entry.augslot5)); + update_values.push_back(columns[9] + " = " + std::to_string(sharedbank_entry.augslot6)); + update_values.push_back(columns[10] + " = '" + EscapeString(sharedbank_entry.custom_data) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + sharedbank_entry. + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Sharedbank InsertOne( + Sharedbank sharedbank_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(sharedbank_entry.acctid)); + insert_values.push_back(std::to_string(sharedbank_entry.slotid)); + insert_values.push_back(std::to_string(sharedbank_entry.itemid)); + insert_values.push_back(std::to_string(sharedbank_entry.charges)); + insert_values.push_back(std::to_string(sharedbank_entry.augslot1)); + insert_values.push_back(std::to_string(sharedbank_entry.augslot2)); + insert_values.push_back(std::to_string(sharedbank_entry.augslot3)); + insert_values.push_back(std::to_string(sharedbank_entry.augslot4)); + insert_values.push_back(std::to_string(sharedbank_entry.augslot5)); + insert_values.push_back(std::to_string(sharedbank_entry.augslot6)); + insert_values.push_back("'" + EscapeString(sharedbank_entry.custom_data) + "'"); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + sharedbank_entry.id = results.LastInsertedID(); + return sharedbank_entry; + } + + sharedbank_entry = InstanceListRepository::NewEntity(); + + return sharedbank_entry; + } + + static int InsertMany( + std::vector sharedbank_entries + ) + { + std::vector insert_chunks; + + for (auto &sharedbank_entry: sharedbank_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(sharedbank_entry.acctid)); + insert_values.push_back(std::to_string(sharedbank_entry.slotid)); + insert_values.push_back(std::to_string(sharedbank_entry.itemid)); + insert_values.push_back(std::to_string(sharedbank_entry.charges)); + insert_values.push_back(std::to_string(sharedbank_entry.augslot1)); + insert_values.push_back(std::to_string(sharedbank_entry.augslot2)); + insert_values.push_back(std::to_string(sharedbank_entry.augslot3)); + insert_values.push_back(std::to_string(sharedbank_entry.augslot4)); + insert_values.push_back(std::to_string(sharedbank_entry.augslot5)); + insert_values.push_back(std::to_string(sharedbank_entry.augslot6)); + insert_values.push_back("'" + EscapeString(sharedbank_entry.custom_data) + "'"); + + 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) { + Sharedbank entry{}; + + entry.acctid = atoi(row[0]); + entry.slotid = atoi(row[1]); + entry.itemid = atoi(row[2]); + entry.charges = atoi(row[3]); + entry.augslot1 = atoi(row[4]); + entry.augslot2 = atoi(row[5]); + entry.augslot3 = atoi(row[6]); + entry.augslot4 = atoi(row[7]); + entry.augslot5 = atoi(row[8]); + entry.augslot6 = atoi(row[9]); + entry.custom_data = row[10]; + + all_entries.push_back(entry); + } + + return all_entries; + } + +}; + +#endif //EQEMU_SHAREDBANK_REPOSITORY_H diff --git a/common/repositories/skill_caps_repository.h b/common/repositories/skill_caps_repository.h new file mode 100644 index 000000000..f55f7e164 --- /dev/null +++ b/common/repositories/skill_caps_repository.h @@ -0,0 +1,68 @@ +/** + * 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_SKILL_CAPS_REPOSITORY_H +#define EQEMU_SKILL_CAPS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_skill_caps_repository.h" + +class SkillCapsRepository: public BaseSkillCapsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * SkillCapsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * SkillCapsRepository::GetWhereNeverExpires() + * SkillCapsRepository::GetWhereXAndY() + * SkillCapsRepository::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_SKILL_CAPS_REPOSITORY_H diff --git a/common/repositories/spawn2_repository.h b/common/repositories/spawn2_repository.h new file mode 100644 index 000000000..f83ba3bd1 --- /dev/null +++ b/common/repositories/spawn2_repository.h @@ -0,0 +1,68 @@ +/** + * 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_SPAWN2_REPOSITORY_H +#define EQEMU_SPAWN2_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_spawn2_repository.h" + +class Spawn2Repository: public BaseSpawn2Repository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * Spawn2Repository::GetByZoneAndVersion(int zone_id, int zone_version) + * Spawn2Repository::GetWhereNeverExpires() + * Spawn2Repository::GetWhereXAndY() + * Spawn2Repository::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_SPAWN2_REPOSITORY_H diff --git a/common/repositories/spawn_condition_values_repository.h b/common/repositories/spawn_condition_values_repository.h new file mode 100644 index 000000000..5c641cce0 --- /dev/null +++ b/common/repositories/spawn_condition_values_repository.h @@ -0,0 +1,68 @@ +/** + * 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_SPAWN_CONDITION_VALUES_REPOSITORY_H +#define EQEMU_SPAWN_CONDITION_VALUES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_spawn_condition_values_repository.h" + +class SpawnConditionValuesRepository: public BaseSpawnConditionValuesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * SpawnConditionValuesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * SpawnConditionValuesRepository::GetWhereNeverExpires() + * SpawnConditionValuesRepository::GetWhereXAndY() + * SpawnConditionValuesRepository::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_SPAWN_CONDITION_VALUES_REPOSITORY_H diff --git a/common/repositories/spawn_conditions_repository.h b/common/repositories/spawn_conditions_repository.h new file mode 100644 index 000000000..30f9850ef --- /dev/null +++ b/common/repositories/spawn_conditions_repository.h @@ -0,0 +1,68 @@ +/** + * 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_SPAWN_CONDITIONS_REPOSITORY_H +#define EQEMU_SPAWN_CONDITIONS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_spawn_conditions_repository.h" + +class SpawnConditionsRepository: public BaseSpawnConditionsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * SpawnConditionsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * SpawnConditionsRepository::GetWhereNeverExpires() + * SpawnConditionsRepository::GetWhereXAndY() + * SpawnConditionsRepository::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_SPAWN_CONDITIONS_REPOSITORY_H diff --git a/common/repositories/spawn_events_repository.h b/common/repositories/spawn_events_repository.h new file mode 100644 index 000000000..aa36b895b --- /dev/null +++ b/common/repositories/spawn_events_repository.h @@ -0,0 +1,68 @@ +/** + * 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_SPAWN_EVENTS_REPOSITORY_H +#define EQEMU_SPAWN_EVENTS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_spawn_events_repository.h" + +class SpawnEventsRepository: public BaseSpawnEventsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * SpawnEventsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * SpawnEventsRepository::GetWhereNeverExpires() + * SpawnEventsRepository::GetWhereXAndY() + * SpawnEventsRepository::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_SPAWN_EVENTS_REPOSITORY_H diff --git a/common/repositories/spawnentry_repository.h b/common/repositories/spawnentry_repository.h new file mode 100644 index 000000000..a6ad875d7 --- /dev/null +++ b/common/repositories/spawnentry_repository.h @@ -0,0 +1,68 @@ +/** + * 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_SPAWNENTRY_REPOSITORY_H +#define EQEMU_SPAWNENTRY_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_spawnentry_repository.h" + +class SpawnentryRepository: public BaseSpawnentryRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * SpawnentryRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * SpawnentryRepository::GetWhereNeverExpires() + * SpawnentryRepository::GetWhereXAndY() + * SpawnentryRepository::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_SPAWNENTRY_REPOSITORY_H diff --git a/common/repositories/spawngroup_repository.h b/common/repositories/spawngroup_repository.h index 7c55711b6..b9f5e21ad 100644 --- a/common/repositories/spawngroup_repository.h +++ b/common/repositories/spawngroup_repository.h @@ -17,148 +17,52 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ + #ifndef EQEMU_SPAWNGROUP_REPOSITORY_H #define EQEMU_SPAWNGROUP_REPOSITORY_H #include "../database.h" #include "../string_util.h" +#include "base/base_spawngroup_repository.h" -class SpawnGroupRepository { +class SpawngroupRepository: public BaseSpawngroupRepository { public: - struct SpawnGroup { - int id; - std::string name; - int8 spawn_limit; - int dist; - float max_x; - float min_x; - float max_y; - float min_y; - int delay; - int mindelay; - int despawn; - int despawn_timer; - int wp_spawns; - }; - static std::vector Columns() - { - return { - "id", - "name", - "spawn_limit", - "dist", - "max_x", - "min_x", - "max_y", - "min_y", - "delay", - "mindelay", - "despawn", - "despawn_timer", - "wp_spawns", - }; - } + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * SpawngroupRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * SpawngroupRepository::GetWhereNeverExpires() + * SpawngroupRepository::GetWhereXAndY() + * SpawngroupRepository::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 + */ - static std::string ColumnsRaw() - { - return std::string(implode(", ", Columns())); - } - - static std::string TableName() - { - return std::string("spawngroup"); - } - - static std::string BaseSelect() - { - return std::string( - fmt::format( - "SELECT {} FROM {}", - ColumnsRaw(), - TableName() - ) - ); - } - - static SpawnGroup NewEntity() - { - SpawnGroup entry; - - entry.id = 0; - entry.name = ""; - entry.spawn_limit = 0; - entry.dist = 0; - entry.max_x = 0; - entry.min_x = 0; - entry.max_y = 0; - entry.min_y = 0; - entry.delay = 0; - entry.mindelay = 0; - entry.despawn = 0; - entry.despawn_timer = 0; - entry.wp_spawns = 0; - - return entry; - } - - static std::vector GetZoneSpawnGroups( - const std::string &zone_short_name, - int zone_version - ) - { - std::vector spawn_groups; - - auto results = content_db.QueryDatabase( - fmt::format( - SQL ( - {} INNER JOIN spawn2 ON spawn2.spawngroupID = spawngroup.id - WHERE spawn2.zone = '{}' and spawn2.version = {} - ), - BaseSelect(), - zone_short_name, - zone_version - ) - ); - - for (auto row = results.begin(); row != results.end(); ++row) { - SpawnGroup entry{}; - - entry.id = atoi(row[0]); - entry.name = row[1]; - entry.spawn_limit = atoi(row[2]); - entry.dist = atof(row[3]); - entry.max_x = atof(row[4]); - entry.min_x = atof(row[5]); - entry.max_y = atof(row[6]); - entry.min_y = atof(row[7]); - entry.delay = atoi(row[8]); - entry.mindelay = atoi(row[9]); - entry.despawn = atoi(row[10]); - entry.despawn_timer = atoi(row[11]); - entry.wp_spawns = atoi(row[12]); - - spawn_groups.push_back(entry); - } - - return spawn_groups; - } - - static SpawnGroup GetGrid( - const std::vector &spawn_groups, - int spawn_group_id - ) - { - for (auto &row : spawn_groups) { - if (row.id == spawn_group_id) { - return row; - } - } - - return NewEntity(); - } + // Custom extended repository methods here }; - #endif //EQEMU_SPAWNGROUP_REPOSITORY_H diff --git a/common/repositories/spell_buckets_repository.h b/common/repositories/spell_buckets_repository.h new file mode 100644 index 000000000..90d2a6d1f --- /dev/null +++ b/common/repositories/spell_buckets_repository.h @@ -0,0 +1,68 @@ +/** + * 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_SPELL_BUCKETS_REPOSITORY_H +#define EQEMU_SPELL_BUCKETS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_spell_buckets_repository.h" + +class SpellBucketsRepository: public BaseSpellBucketsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * SpellBucketsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * SpellBucketsRepository::GetWhereNeverExpires() + * SpellBucketsRepository::GetWhereXAndY() + * SpellBucketsRepository::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_SPELL_BUCKETS_REPOSITORY_H diff --git a/common/repositories/spell_globals_repository.h b/common/repositories/spell_globals_repository.h new file mode 100644 index 000000000..2d5132109 --- /dev/null +++ b/common/repositories/spell_globals_repository.h @@ -0,0 +1,68 @@ +/** + * 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_SPELL_GLOBALS_REPOSITORY_H +#define EQEMU_SPELL_GLOBALS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_spell_globals_repository.h" + +class SpellGlobalsRepository: public BaseSpellGlobalsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * SpellGlobalsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * SpellGlobalsRepository::GetWhereNeverExpires() + * SpellGlobalsRepository::GetWhereXAndY() + * SpellGlobalsRepository::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_SPELL_GLOBALS_REPOSITORY_H diff --git a/common/repositories/spells_new_repository.h b/common/repositories/spells_new_repository.h new file mode 100644 index 000000000..49a5497d8 --- /dev/null +++ b/common/repositories/spells_new_repository.h @@ -0,0 +1,68 @@ +/** + * 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_SPELLS_NEW_REPOSITORY_H +#define EQEMU_SPELLS_NEW_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_spells_new_repository.h" + +class SpellsNewRepository: public BaseSpellsNewRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * SpellsNewRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * SpellsNewRepository::GetWhereNeverExpires() + * SpellsNewRepository::GetWhereXAndY() + * SpellsNewRepository::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_SPELLS_NEW_REPOSITORY_H diff --git a/common/repositories/start_zones_repository.h b/common/repositories/start_zones_repository.h new file mode 100644 index 000000000..c185825f1 --- /dev/null +++ b/common/repositories/start_zones_repository.h @@ -0,0 +1,68 @@ +/** + * 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_START_ZONES_REPOSITORY_H +#define EQEMU_START_ZONES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_start_zones_repository.h" + +class StartZonesRepository: public BaseStartZonesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * StartZonesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * StartZonesRepository::GetWhereNeverExpires() + * StartZonesRepository::GetWhereXAndY() + * StartZonesRepository::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_START_ZONES_REPOSITORY_H diff --git a/common/repositories/starting_items_repository.h b/common/repositories/starting_items_repository.h new file mode 100644 index 000000000..fa18d7d16 --- /dev/null +++ b/common/repositories/starting_items_repository.h @@ -0,0 +1,68 @@ +/** + * 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_STARTING_ITEMS_REPOSITORY_H +#define EQEMU_STARTING_ITEMS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_starting_items_repository.h" + +class StartingItemsRepository: public BaseStartingItemsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * StartingItemsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * StartingItemsRepository::GetWhereNeverExpires() + * StartingItemsRepository::GetWhereXAndY() + * StartingItemsRepository::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_STARTING_ITEMS_REPOSITORY_H diff --git a/common/repositories/task_activities_repository.h b/common/repositories/task_activities_repository.h new file mode 100644 index 000000000..864dff5bf --- /dev/null +++ b/common/repositories/task_activities_repository.h @@ -0,0 +1,68 @@ +/** + * 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_TASK_ACTIVITIES_REPOSITORY_H +#define EQEMU_TASK_ACTIVITIES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_task_activities_repository.h" + +class TaskActivitiesRepository: public BaseTaskActivitiesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * TaskActivitiesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * TaskActivitiesRepository::GetWhereNeverExpires() + * TaskActivitiesRepository::GetWhereXAndY() + * TaskActivitiesRepository::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_TASK_ACTIVITIES_REPOSITORY_H diff --git a/common/repositories/tasks_repository.h b/common/repositories/tasks_repository.h new file mode 100644 index 000000000..a7e03c3a0 --- /dev/null +++ b/common/repositories/tasks_repository.h @@ -0,0 +1,68 @@ +/** + * 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_TASKS_REPOSITORY_H +#define EQEMU_TASKS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_tasks_repository.h" + +class TasksRepository: public BaseTasksRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * TasksRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * TasksRepository::GetWhereNeverExpires() + * TasksRepository::GetWhereXAndY() + * TasksRepository::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_TASKS_REPOSITORY_H diff --git a/common/repositories/tasksets_repository.h b/common/repositories/tasksets_repository.h new file mode 100644 index 000000000..acea03204 --- /dev/null +++ b/common/repositories/tasksets_repository.h @@ -0,0 +1,68 @@ +/** + * 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_TASKSETS_REPOSITORY_H +#define EQEMU_TASKSETS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_tasksets_repository.h" + +class TasksetsRepository: public BaseTasksetsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * TasksetsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * TasksetsRepository::GetWhereNeverExpires() + * TasksetsRepository::GetWhereXAndY() + * TasksetsRepository::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_TASKSETS_REPOSITORY_H diff --git a/common/repositories/template/base_repository.template b/common/repositories/template/base_repository.template new file mode 100644 index 000000000..67b0322a0 --- /dev/null +++ b/common/repositories/template/base_repository.template @@ -0,0 +1,299 @@ +/** + * 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 on {{GENERATED_DATE}} 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_{{TABLE_NAME_UPPER}}_REPOSITORY_H +#define EQEMU_BASE_{{TABLE_NAME_UPPER}}_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" + +class Base{{TABLE_NAME_CLASS}}Repository { +public: + struct {{TABLE_NAME_STRUCT}} { +{{TABLE_STRUCT_COLUMNS}} + }; + + static std::string PrimaryKey() + { + return std::string("{{PRIMARY_KEY_STRING}}"); + } + + static std::vector Columns() + { + return { +{{COLUMNS_LIST_QUOTED}} + }; + } + + 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("{{TABLE_NAME_VAR}}"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static {{TABLE_NAME_STRUCT}} NewEntity() + { + {{TABLE_NAME_STRUCT}} entry{}; + +{{DEFAULT_ENTRIES}} + + return entry; + } + + static {{TABLE_NAME_STRUCT}} Get{{TABLE_NAME_STRUCT}}Entry( + const std::vector<{{TABLE_NAME_STRUCT}}> &{{TABLE_NAME_VAR}}s, + int {{TABLE_NAME_VAR}}_id + ) + { + for (auto &{{TABLE_NAME_VAR}} : {{TABLE_NAME_VAR}}s) { + if ({{TABLE_NAME_VAR}}.{{PRIMARY_KEY_STRING}} == {{TABLE_NAME_VAR}}_id) { + return {{TABLE_NAME_VAR}}; + } + } + + return NewEntity(); + } + + static {{TABLE_NAME_STRUCT}} FindOne( + int {{TABLE_NAME_VAR}}_id + ) + { + auto results = {{DATABASE_CONNECTION}}.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + {{TABLE_NAME_VAR}}_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + {{TABLE_NAME_STRUCT}} entry{}; + +{{FIND_ONE_ENTRIES}} + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int {{TABLE_NAME_VAR}}_id + ) + { + auto results = {{DATABASE_CONNECTION}}.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + {{TABLE_NAME_VAR}}_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + {{TABLE_NAME_STRUCT}} {{TABLE_NAME_VAR}}_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + +{{UPDATE_ONE_ENTRIES}} + + auto results = {{DATABASE_CONNECTION}}.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + {{TABLE_NAME_VAR}}_entry.{{PRIMARY_KEY_STRING}} + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static {{TABLE_NAME_STRUCT}} InsertOne( + {{TABLE_NAME_STRUCT}} {{TABLE_NAME_VAR}}_entry + ) + { + std::vector insert_values; + +{{INSERT_ONE_ENTRIES}} + + auto results = {{DATABASE_CONNECTION}}.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + {{TABLE_NAME_VAR}}_entry.id = results.LastInsertedID(); + return {{TABLE_NAME_VAR}}_entry; + } + + {{TABLE_NAME_VAR}}_entry = NewEntity(); + + return {{TABLE_NAME_VAR}}_entry; + } + + static int InsertMany( + std::vector<{{TABLE_NAME_STRUCT}}> {{TABLE_NAME_VAR}}_entries + ) + { + std::vector insert_chunks; + + for (auto &{{TABLE_NAME_VAR}}_entry: {{TABLE_NAME_VAR}}_entries) { + std::vector insert_values; + +{{INSERT_MANY_ENTRIES}} + + insert_chunks.push_back("(" + implode(",", insert_values) + ")"); + } + + std::vector insert_values; + + auto results = {{DATABASE_CONNECTION}}.QueryDatabase( + fmt::format( + "{} VALUES {}", + BaseInsert(), + implode(",", insert_chunks) + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static std::vector<{{TABLE_NAME_STRUCT}}> All() + { + std::vector<{{TABLE_NAME_STRUCT}}> all_entries; + + auto results = {{DATABASE_CONNECTION}}.QueryDatabase( + fmt::format( + "{}", + BaseSelect() + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + {{TABLE_NAME_STRUCT}} entry{}; + +{{ALL_ENTRIES}} + + all_entries.push_back(entry); + } + + return all_entries; + } + + static std::vector<{{TABLE_NAME_STRUCT}}> GetWhere(std::string where_filter) + { + std::vector<{{TABLE_NAME_STRUCT}}> all_entries; + + auto results = {{DATABASE_CONNECTION}}.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + {{TABLE_NAME_STRUCT}} entry{}; + +{{ALL_ENTRIES}} + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = {{DATABASE_CONNECTION}}.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_{{TABLE_NAME_UPPER}}_REPOSITORY_H diff --git a/common/repositories/template/repository.template b/common/repositories/template/repository.template index e13624359..3d49157bd 100644 --- a/common/repositories/template/repository.template +++ b/common/repositories/template/repository.template @@ -23,229 +23,45 @@ #include "../database.h" #include "../string_util.h" +#include "base/base_{{TABLE_NAME_VAR}}_repository.h" -class {{TABLE_NAME_CLASS}}Repository { +class {{TABLE_NAME_CLASS}}Repository: public Base{{TABLE_NAME_CLASS}}Repository { public: - struct {{TABLE_NAME_STRUCT}} { -{{TABLE_STRUCT_COLUMNS}} - }; - static std::string PrimaryKey() - { - return std::string("{{PRIMARY_KEY_STRING}}"); - } + /** + * This file was auto generated on {{GENERATED_DATE}} 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * {{TABLE_NAME_CLASS}}Repository::GetByZoneAndVersion(int zone_id, int zone_version) + * {{TABLE_NAME_CLASS}}Repository::GetWhereNeverExpires() + * {{TABLE_NAME_CLASS}}Repository::GetWhereXAndY() + * {{TABLE_NAME_CLASS}}Repository::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 + */ - static std::vector Columns() - { - return { -{{COLUMNS_LIST_QUOTED}} - }; - } - - 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("{{TABLE_NAME_VAR}}"); - } - - static std::string BaseSelect() - { - return fmt::format( - "SELECT {} FROM {}", - ColumnsRaw(), - TableName() - ); - } - - static std::string BaseInsert() - { - return fmt::format( - "INSERT INTO {} ({}) ", - TableName(), - InsertColumnsRaw() - ); - } - - static {{TABLE_NAME_STRUCT}} NewEntity() - { - {{TABLE_NAME_STRUCT}} entry{}; - -{{DEFAULT_ENTRIES}} - - return entry; - } - - static {{TABLE_NAME_STRUCT}} Get{{TABLE_NAME_STRUCT}}Entry( - const std::vector<{{TABLE_NAME_STRUCT}}> &{{TABLE_NAME_VAR}}s, - int {{TABLE_NAME_VAR}}_id - ) - { - for (auto &{{TABLE_NAME_VAR}} : {{TABLE_NAME_VAR}}s) { - if ({{TABLE_NAME_VAR}}.{{PRIMARY_KEY_STRING}} == {{TABLE_NAME_VAR}}_id) { - return {{TABLE_NAME_VAR}}; - } - } - - return NewEntity(); - } - - static {{TABLE_NAME_STRUCT}} FindOne( - int {{TABLE_NAME_VAR}}_id - ) - { - auto results = {{DATABASE_CONNECTION}}.QueryDatabase( - fmt::format( - "{} WHERE id = {} LIMIT 1", - BaseSelect(), - {{TABLE_NAME_VAR}}_id - ) - ); - - auto row = results.begin(); - if (results.RowCount() == 1) { - {{TABLE_NAME_STRUCT}} entry{}; - -{{FIND_ONE_ENTRIES}} - return entry; - } - - return NewEntity(); - } - - static int DeleteOne( - int {{TABLE_NAME_VAR}}_id - ) - { - auto results = {{DATABASE_CONNECTION}}.QueryDatabase( - fmt::format( - "DELETE FROM {} WHERE {} = {}", - TableName(), - PrimaryKey(), - {{TABLE_NAME_VAR}}_id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static int UpdateOne( - {{TABLE_NAME_STRUCT}} {{TABLE_NAME_VAR}}_entry - ) - { - std::vector update_values; - - auto columns = Columns(); - -{{UPDATE_ONE_ENTRIES}} - - auto results = {{DATABASE_CONNECTION}}.QueryDatabase( - fmt::format( - "UPDATE {} SET {} WHERE {} = {}", - TableName(), - implode(", ", update_values), - PrimaryKey(), - {{TABLE_NAME_VAR}}_entry.{{PRIMARY_KEY_STRING}} - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static {{TABLE_NAME_STRUCT}} InsertOne( - {{TABLE_NAME_STRUCT}} {{TABLE_NAME_VAR}}_entry - ) - { - std::vector insert_values; - -{{INSERT_ONE_ENTRIES}} - - auto results = {{DATABASE_CONNECTION}}.QueryDatabase( - fmt::format( - "{} VALUES ({})", - BaseInsert(), - implode(",", insert_values) - ) - ); - - if (results.Success()) { - {{TABLE_NAME_VAR}}_entry.id = results.LastInsertedID(); - return {{TABLE_NAME_VAR}}_entry; - } - - {{TABLE_NAME_VAR}}_entry = InstanceListRepository::NewEntity(); - - return {{TABLE_NAME_VAR}}_entry; - } - - static int InsertMany( - std::vector<{{TABLE_NAME_STRUCT}}> {{TABLE_NAME_VAR}}_entries - ) - { - std::vector insert_chunks; - - for (auto &{{TABLE_NAME_VAR}}_entry: {{TABLE_NAME_VAR}}_entries) { - std::vector insert_values; - -{{INSERT_MANY_ENTRIES}} - - insert_chunks.push_back("(" + implode(",", insert_values) + ")"); - } - - std::vector insert_values; - - auto results = {{DATABASE_CONNECTION}}.QueryDatabase( - fmt::format( - "{} VALUES {}", - BaseInsert(), - implode(",", insert_chunks) - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static std::vector<{{TABLE_NAME_STRUCT}}> All() - { - std::vector<{{TABLE_NAME_STRUCT}}> all_entries; - - auto results = {{DATABASE_CONNECTION}}.QueryDatabase( - fmt::format( - "{}", - BaseSelect() - ) - ); - - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) { - {{TABLE_NAME_STRUCT}} entry{}; - -{{ALL_ENTRIES}} - - all_entries.push_back(entry); - } - - return all_entries; - } + // Custom extended repository methods here }; diff --git a/common/repositories/timers_repository.h b/common/repositories/timers_repository.h new file mode 100644 index 000000000..b942a6e23 --- /dev/null +++ b/common/repositories/timers_repository.h @@ -0,0 +1,68 @@ +/** + * 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_TIMERS_REPOSITORY_H +#define EQEMU_TIMERS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_timers_repository.h" + +class TimersRepository: public BaseTimersRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * TimersRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * TimersRepository::GetWhereNeverExpires() + * TimersRepository::GetWhereXAndY() + * TimersRepository::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_TIMERS_REPOSITORY_H diff --git a/common/repositories/titles_repository.h b/common/repositories/titles_repository.h new file mode 100644 index 000000000..387b670ee --- /dev/null +++ b/common/repositories/titles_repository.h @@ -0,0 +1,68 @@ +/** + * 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_TITLES_REPOSITORY_H +#define EQEMU_TITLES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_titles_repository.h" + +class TitlesRepository: public BaseTitlesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * TitlesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * TitlesRepository::GetWhereNeverExpires() + * TitlesRepository::GetWhereXAndY() + * TitlesRepository::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_TITLES_REPOSITORY_H diff --git a/common/repositories/trader_audit_repository.h b/common/repositories/trader_audit_repository.h new file mode 100644 index 000000000..e7be6f677 --- /dev/null +++ b/common/repositories/trader_audit_repository.h @@ -0,0 +1,301 @@ +/** + * 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_TRADER_AUDIT_REPOSITORY_H +#define EQEMU_TRADER_AUDIT_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" + +class TraderAuditRepository { +public: + struct TraderAudit { + std::string time; + std::string seller; + std::string buyer; + std::string itemname; + int quantity; + int totalcost; + int8 trantype; + }; + + static std::string PrimaryKey() + { + return std::string(""); + } + + static std::vector Columns() + { + return { + "time", + "seller", + "buyer", + "itemname", + "quantity", + "totalcost", + "trantype", + }; + } + + 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("trader_audit"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + ColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + InsertColumnsRaw() + ); + } + + static TraderAudit NewEntity() + { + TraderAudit entry{}; + + entry.time = '0000-00-00 00:00:00'; + entry.seller = ""; + entry.buyer = ""; + entry.itemname = ""; + entry.quantity = 0; + entry.totalcost = 0; + entry.trantype = 0; + + return entry; + } + + static TraderAudit GetTraderAuditEntry( + const std::vector &trader_audits, + int trader_audit_id + ) + { + for (auto &trader_audit : trader_audits) { + if (trader_audit. == trader_audit_id) { + return trader_audit; + } + } + + return NewEntity(); + } + + static TraderAudit FindOne( + int trader_audit_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + trader_audit_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + TraderAudit entry{}; + + entry.time = row[0]; + entry.seller = row[1]; + entry.buyer = row[2]; + entry.itemname = row[3]; + entry.quantity = atoi(row[4]); + entry.totalcost = atoi(row[5]); + entry.trantype = atoi(row[6]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + int trader_audit_id + ) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + trader_audit_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + TraderAudit trader_audit_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[0] + " = '" + EscapeString(trader_audit_entry.time) + "'"); + update_values.push_back(columns[1] + " = '" + EscapeString(trader_audit_entry.seller) + "'"); + update_values.push_back(columns[2] + " = '" + EscapeString(trader_audit_entry.buyer) + "'"); + update_values.push_back(columns[3] + " = '" + EscapeString(trader_audit_entry.itemname) + "'"); + update_values.push_back(columns[4] + " = " + std::to_string(trader_audit_entry.quantity)); + update_values.push_back(columns[5] + " = " + std::to_string(trader_audit_entry.totalcost)); + update_values.push_back(columns[6] + " = " + std::to_string(trader_audit_entry.trantype)); + + auto results = database.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + trader_audit_entry. + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static TraderAudit InsertOne( + TraderAudit trader_audit_entry + ) + { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(trader_audit_entry.time) + "'"); + insert_values.push_back("'" + EscapeString(trader_audit_entry.seller) + "'"); + insert_values.push_back("'" + EscapeString(trader_audit_entry.buyer) + "'"); + insert_values.push_back("'" + EscapeString(trader_audit_entry.itemname) + "'"); + insert_values.push_back(std::to_string(trader_audit_entry.quantity)); + insert_values.push_back(std::to_string(trader_audit_entry.totalcost)); + insert_values.push_back(std::to_string(trader_audit_entry.trantype)); + + auto results = database.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + trader_audit_entry.id = results.LastInsertedID(); + return trader_audit_entry; + } + + trader_audit_entry = InstanceListRepository::NewEntity(); + + return trader_audit_entry; + } + + static int InsertMany( + std::vector trader_audit_entries + ) + { + std::vector insert_chunks; + + for (auto &trader_audit_entry: trader_audit_entries) { + std::vector insert_values; + + insert_values.push_back("'" + EscapeString(trader_audit_entry.time) + "'"); + insert_values.push_back("'" + EscapeString(trader_audit_entry.seller) + "'"); + insert_values.push_back("'" + EscapeString(trader_audit_entry.buyer) + "'"); + insert_values.push_back("'" + EscapeString(trader_audit_entry.itemname) + "'"); + insert_values.push_back(std::to_string(trader_audit_entry.quantity)); + insert_values.push_back(std::to_string(trader_audit_entry.totalcost)); + insert_values.push_back(std::to_string(trader_audit_entry.trantype)); + + 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) { + TraderAudit entry{}; + + entry.time = row[0]; + entry.seller = row[1]; + entry.buyer = row[2]; + entry.itemname = row[3]; + entry.quantity = atoi(row[4]); + entry.totalcost = atoi(row[5]); + entry.trantype = atoi(row[6]); + + all_entries.push_back(entry); + } + + return all_entries; + } + +}; + +#endif //EQEMU_TRADER_AUDIT_REPOSITORY_H diff --git a/common/repositories/trader_repository.h b/common/repositories/trader_repository.h new file mode 100644 index 000000000..1e346e783 --- /dev/null +++ b/common/repositories/trader_repository.h @@ -0,0 +1,68 @@ +/** + * 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_TRADER_REPOSITORY_H +#define EQEMU_TRADER_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_trader_repository.h" + +class TraderRepository: public BaseTraderRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * TraderRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * TraderRepository::GetWhereNeverExpires() + * TraderRepository::GetWhereXAndY() + * TraderRepository::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_TRADER_REPOSITORY_H diff --git a/common/repositories/tradeskill_recipe_entries_repository.h b/common/repositories/tradeskill_recipe_entries_repository.h new file mode 100644 index 000000000..6e3fe4bbf --- /dev/null +++ b/common/repositories/tradeskill_recipe_entries_repository.h @@ -0,0 +1,68 @@ +/** + * 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_TRADESKILL_RECIPE_ENTRIES_REPOSITORY_H +#define EQEMU_TRADESKILL_RECIPE_ENTRIES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_tradeskill_recipe_entries_repository.h" + +class TradeskillRecipeEntriesRepository: public BaseTradeskillRecipeEntriesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * TradeskillRecipeEntriesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * TradeskillRecipeEntriesRepository::GetWhereNeverExpires() + * TradeskillRecipeEntriesRepository::GetWhereXAndY() + * TradeskillRecipeEntriesRepository::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_TRADESKILL_RECIPE_ENTRIES_REPOSITORY_H diff --git a/common/repositories/tradeskill_recipe_repository.h b/common/repositories/tradeskill_recipe_repository.h index 15ee26ce3..f0445aa11 100644 --- a/common/repositories/tradeskill_recipe_repository.h +++ b/common/repositories/tradeskill_recipe_repository.h @@ -23,112 +23,48 @@ #include "../database.h" #include "../string_util.h" +#include "base/base_tradeskill_recipe_repository.h" -class TradeskillRecipeRepository { +class TradeskillRecipeRepository: public BaseTradeskillRecipeRepository { public: - struct TradeskillRecipe { - int id; - std::string name; - int tradeskill; - int skillneeded; - int trivial; - uint8 nofail; - int replace_container; - std::string notes; - uint8 must_learn; - uint8 quest; - uint8 enabled; - }; - static std::vector Columns() - { - return { - "id", - "name", - "tradeskill", - "skillneeded", - "trivial", - "nofail", - "replace_container", - "notes", - "must_learn", - "quest", - "enabled", - }; - } + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * TradeskillRecipeRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * TradeskillRecipeRepository::GetWhereNeverExpires() + * TradeskillRecipeRepository::GetWhereXAndY() + * TradeskillRecipeRepository::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 + */ - static std::string ColumnsRaw() - { - return std::string(implode(", ", Columns())); - } + // Custom extended repository methods here - static std::string TableName() - { - return std::string("tradeskill_recipe"); - } - static std::string BaseSelect() - { - return std::string( - fmt::format( - "SELECT {} FROM {}", - ColumnsRaw(), - TableName() - ) - ); - } - - static TradeskillRecipe NewEntity() - { - TradeskillRecipe entry; - - entry.id = 0; - entry.name = ""; - entry.tradeskill = 0; - entry.skillneeded = 0; - entry.trivial = 0; - entry.nofail = 0; - entry.replace_container = 0; - entry.notes = ""; - entry.must_learn = 0; - entry.quest = 0; - entry.enabled = 0; - - return entry; - } - - static TradeskillRecipe GetRecipe(int recipe_id) - { - auto results = content_db.QueryDatabase( - fmt::format( - "{} WHERE id = {}", - BaseSelect(), - recipe_id - ) - ); - - TradeskillRecipe tradeskill_recipe = NewEntity(); - - auto row = results.begin(); - if (results.RowCount() == 0) { - return tradeskill_recipe; - } - - tradeskill_recipe.id = atoi(row[0]); - tradeskill_recipe.name = (row[1] ? row[1] : ""); - tradeskill_recipe.tradeskill = atoi(row[2]); - tradeskill_recipe.skillneeded = atoi(row[3]); - tradeskill_recipe.trivial = atoi(row[4]); - tradeskill_recipe.nofail = atoi(row[5]); - tradeskill_recipe.replace_container = atoi(row[6]); - tradeskill_recipe.notes = (row[7] ? row[7] : ""); - tradeskill_recipe.must_learn = atoi(row[8]); - tradeskill_recipe.quest = atoi(row[9]); - tradeskill_recipe.enabled = atoi(row[10]); - - return tradeskill_recipe; - } }; -#endif +#endif //EQEMU_TRADESKILL_RECIPE_REPOSITORY_H diff --git a/common/repositories/traps_repository.h b/common/repositories/traps_repository.h new file mode 100644 index 000000000..6b5226aa3 --- /dev/null +++ b/common/repositories/traps_repository.h @@ -0,0 +1,68 @@ +/** + * 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_TRAPS_REPOSITORY_H +#define EQEMU_TRAPS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_traps_repository.h" + +class TrapsRepository: public BaseTrapsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * TrapsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * TrapsRepository::GetWhereNeverExpires() + * TrapsRepository::GetWhereXAndY() + * TrapsRepository::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_TRAPS_REPOSITORY_H diff --git a/common/repositories/tribute_levels_repository.h b/common/repositories/tribute_levels_repository.h new file mode 100644 index 000000000..162d6cdb2 --- /dev/null +++ b/common/repositories/tribute_levels_repository.h @@ -0,0 +1,68 @@ +/** + * 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_TRIBUTE_LEVELS_REPOSITORY_H +#define EQEMU_TRIBUTE_LEVELS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_tribute_levels_repository.h" + +class TributeLevelsRepository: public BaseTributeLevelsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * TributeLevelsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * TributeLevelsRepository::GetWhereNeverExpires() + * TributeLevelsRepository::GetWhereXAndY() + * TributeLevelsRepository::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_TRIBUTE_LEVELS_REPOSITORY_H diff --git a/common/repositories/tributes_repository.h b/common/repositories/tributes_repository.h new file mode 100644 index 000000000..480d42c6c --- /dev/null +++ b/common/repositories/tributes_repository.h @@ -0,0 +1,68 @@ +/** + * 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_TRIBUTES_REPOSITORY_H +#define EQEMU_TRIBUTES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_tributes_repository.h" + +class TributesRepository: public BaseTributesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * TributesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * TributesRepository::GetWhereNeverExpires() + * TributesRepository::GetWhereXAndY() + * TributesRepository::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_TRIBUTES_REPOSITORY_H diff --git a/common/repositories/variables_repository.h b/common/repositories/variables_repository.h new file mode 100644 index 000000000..6e07e1bb2 --- /dev/null +++ b/common/repositories/variables_repository.h @@ -0,0 +1,68 @@ +/** + * 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_VARIABLES_REPOSITORY_H +#define EQEMU_VARIABLES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_variables_repository.h" + +class VariablesRepository: public BaseVariablesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * VariablesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * VariablesRepository::GetWhereNeverExpires() + * VariablesRepository::GetWhereXAndY() + * VariablesRepository::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_VARIABLES_REPOSITORY_H diff --git a/common/repositories/veteran_reward_templates_repository.h b/common/repositories/veteran_reward_templates_repository.h new file mode 100644 index 000000000..71a4592ae --- /dev/null +++ b/common/repositories/veteran_reward_templates_repository.h @@ -0,0 +1,68 @@ +/** + * 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_VETERAN_REWARD_TEMPLATES_REPOSITORY_H +#define EQEMU_VETERAN_REWARD_TEMPLATES_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_veteran_reward_templates_repository.h" + +class VeteranRewardTemplatesRepository: public BaseVeteranRewardTemplatesRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * VeteranRewardTemplatesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * VeteranRewardTemplatesRepository::GetWhereNeverExpires() + * VeteranRewardTemplatesRepository::GetWhereXAndY() + * VeteranRewardTemplatesRepository::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_VETERAN_REWARD_TEMPLATES_REPOSITORY_H diff --git a/common/repositories/zone_points_repository.h b/common/repositories/zone_points_repository.h new file mode 100644 index 000000000..424a54421 --- /dev/null +++ b/common/repositories/zone_points_repository.h @@ -0,0 +1,68 @@ +/** + * 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_ZONE_POINTS_REPOSITORY_H +#define EQEMU_ZONE_POINTS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_zone_points_repository.h" + +class ZonePointsRepository: public BaseZonePointsRepository { +public: + + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * ZonePointsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * ZonePointsRepository::GetWhereNeverExpires() + * ZonePointsRepository::GetWhereXAndY() + * ZonePointsRepository::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_ZONE_POINTS_REPOSITORY_H diff --git a/common/repositories/zone_repository.h b/common/repositories/zone_repository.h index d4f29fa65..d61534938 100644 --- a/common/repositories/zone_repository.h +++ b/common/repositories/zone_repository.h @@ -23,1031 +23,45 @@ #include "../database.h" #include "../string_util.h" +#include "base/base_zone_repository.h" -class ZoneRepository { +class ZoneRepository: public BaseZoneRepository { public: - struct Zone { - std::string short_name; - int id; - std::string file_name; - std::string long_name; - std::string map_file_name; - float safe_x; - float safe_y; - float safe_z; - float graveyard_id; - int8 min_level; - int8 min_status; - int zoneidnumber; - int8 version; - int timezone; - int maxclients; - int ruleset; - std::string note; - float underworld; - float minclip; - float maxclip; - float fog_minclip; - float fog_maxclip; - int8 fog_blue; - int8 fog_red; - int8 fog_green; - int8 sky; - int8 ztype; - float zone_exp_multiplier; - float walkspeed; - int8 time_type; - int8 fog_red1; - int8 fog_green1; - int8 fog_blue1; - float fog_minclip1; - float fog_maxclip1; - int8 fog_red2; - int8 fog_green2; - int8 fog_blue2; - float fog_minclip2; - float fog_maxclip2; - int8 fog_red3; - int8 fog_green3; - int8 fog_blue3; - float fog_minclip3; - float fog_maxclip3; - int8 fog_red4; - int8 fog_green4; - int8 fog_blue4; - float fog_minclip4; - float fog_maxclip4; - float fog_density; - std::string flag_needed; - int8 canbind; - int8 cancombat; - int8 canlevitate; - int8 castoutdoor; - int8 hotzone; - int8 insttype; - int shutdowndelay; - int8 peqzone; - int8 expansion; - int8 suspendbuffs; - int rain_chance1; - int rain_chance2; - int rain_chance3; - int rain_chance4; - int rain_duration1; - int rain_duration2; - int rain_duration3; - int rain_duration4; - int snow_chance1; - int snow_chance2; - int snow_chance3; - int snow_chance4; - int snow_duration1; - int snow_duration2; - int snow_duration3; - int snow_duration4; - float gravity; - int type; - int8 skylock; - int fast_regen_hp; - int fast_regen_mana; - int fast_regen_endurance; - int npc_max_aggro_dist; - int max_movement_update_range; - }; - static std::string PrimaryKey() - { - return std::string("id"); - } + /** + * This file was auto generated on Apr 5, 2020 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) + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * ZoneRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * ZoneRepository::GetWhereNeverExpires() + * ZoneRepository::GetWhereXAndY() + * ZoneRepository::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 + */ - static std::vector Columns() - { - return { - "short_name", - "id", - "file_name", - "long_name", - "map_file_name", - "safe_x", - "safe_y", - "safe_z", - "graveyard_id", - "min_level", - "min_status", - "zoneidnumber", - "version", - "timezone", - "maxclients", - "ruleset", - "note", - "underworld", - "minclip", - "maxclip", - "fog_minclip", - "fog_maxclip", - "fog_blue", - "fog_red", - "fog_green", - "sky", - "ztype", - "zone_exp_multiplier", - "walkspeed", - "time_type", - "fog_red1", - "fog_green1", - "fog_blue1", - "fog_minclip1", - "fog_maxclip1", - "fog_red2", - "fog_green2", - "fog_blue2", - "fog_minclip2", - "fog_maxclip2", - "fog_red3", - "fog_green3", - "fog_blue3", - "fog_minclip3", - "fog_maxclip3", - "fog_red4", - "fog_green4", - "fog_blue4", - "fog_minclip4", - "fog_maxclip4", - "fog_density", - "flag_needed", - "canbind", - "cancombat", - "canlevitate", - "castoutdoor", - "hotzone", - "insttype", - "shutdowndelay", - "peqzone", - "expansion", - "suspendbuffs", - "rain_chance1", - "rain_chance2", - "rain_chance3", - "rain_chance4", - "rain_duration1", - "rain_duration2", - "rain_duration3", - "rain_duration4", - "snow_chance1", - "snow_chance2", - "snow_chance3", - "snow_chance4", - "snow_duration1", - "snow_duration2", - "snow_duration3", - "snow_duration4", - "gravity", - "type", - "skylock", - "fast_regen_hp", - "fast_regen_mana", - "fast_regen_endurance", - "npc_max_aggro_dist", - "max_movement_update_range", - }; - } - - 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("zone"); - } - - static std::string BaseSelect() - { - return fmt::format( - "SELECT {} FROM {}", - ColumnsRaw(), - TableName() - ); - } - - static std::string BaseInsert() - { - return fmt::format( - "INSERT INTO {} ({}) ", - TableName(), - InsertColumnsRaw() - ); - } - - static Zone NewEntity() - { - Zone entry{}; - - entry.short_name = ""; - entry.id = 0; - entry.file_name = ""; - entry.long_name = ""; - entry.map_file_name = ""; - entry.safe_x = 0; - entry.safe_y = 0; - entry.safe_z = 0; - entry.graveyard_id = 0; - entry.min_level = 0; - entry.min_status = 0; - entry.zoneidnumber = 0; - entry.version = 0; - entry.timezone = 0; - entry.maxclients = 0; - entry.ruleset = 0; - entry.note = ""; - entry.underworld = 0; - entry.minclip = 450; - entry.maxclip = 450; - entry.fog_minclip = 450; - entry.fog_maxclip = 450; - entry.fog_blue = 0; - entry.fog_red = 0; - entry.fog_green = 0; - entry.sky = 1; - entry.ztype = 1; - entry.zone_exp_multiplier = 0.00; - entry.walkspeed = 0.4; - entry.time_type = 2; - entry.fog_red1 = 0; - entry.fog_green1 = 0; - entry.fog_blue1 = 0; - entry.fog_minclip1 = 450; - entry.fog_maxclip1 = 450; - entry.fog_red2 = 0; - entry.fog_green2 = 0; - entry.fog_blue2 = 0; - entry.fog_minclip2 = 450; - entry.fog_maxclip2 = 450; - entry.fog_red3 = 0; - entry.fog_green3 = 0; - entry.fog_blue3 = 0; - entry.fog_minclip3 = 450; - entry.fog_maxclip3 = 450; - entry.fog_red4 = 0; - entry.fog_green4 = 0; - entry.fog_blue4 = 0; - entry.fog_minclip4 = 450; - entry.fog_maxclip4 = 450; - entry.fog_density = 0; - entry.flag_needed = ""; - entry.canbind = 1; - entry.cancombat = 1; - entry.canlevitate = 1; - entry.castoutdoor = 1; - entry.hotzone = 0; - entry.insttype = 0; - entry.shutdowndelay = 5000; - entry.peqzone = 1; - entry.expansion = 0; - entry.suspendbuffs = 0; - entry.rain_chance1 = 0; - entry.rain_chance2 = 0; - entry.rain_chance3 = 0; - entry.rain_chance4 = 0; - entry.rain_duration1 = 0; - entry.rain_duration2 = 0; - entry.rain_duration3 = 0; - entry.rain_duration4 = 0; - entry.snow_chance1 = 0; - entry.snow_chance2 = 0; - entry.snow_chance3 = 0; - entry.snow_chance4 = 0; - entry.snow_duration1 = 0; - entry.snow_duration2 = 0; - entry.snow_duration3 = 0; - entry.snow_duration4 = 0; - entry.gravity = 0.4; - entry.type = 0; - entry.skylock = 0; - entry.fast_regen_hp = 180; - entry.fast_regen_mana = 180; - entry.fast_regen_endurance = 180; - entry.npc_max_aggro_dist = 600; - entry.max_movement_update_range = 600; - - return entry; - } - - static Zone GetZoneEntry( - const std::vector &zones, - int zone_id - ) - { - for (auto &zone : zones) { - if (zone.id == zone_id) { - return zone; - } - } - - return NewEntity(); - } - - static Zone FindOne( - int zone_id - ) - { - auto results = content_db.QueryDatabase( - fmt::format( - "{} WHERE id = {} LIMIT 1", - BaseSelect(), - zone_id - ) - ); - - auto row = results.begin(); - if (results.RowCount() == 1) { - Zone entry{}; - - entry.short_name = row[0] ? row[0] : ""; - entry.id = atoi(row[1]); - entry.file_name = row[2] ? row[2] : ""; - entry.long_name = row[3] ? row[3] : ""; - entry.map_file_name = row[4] ? row[4] : ""; - entry.safe_x = atof(row[5]); - entry.safe_y = atof(row[6]); - entry.safe_z = atof(row[7]); - entry.graveyard_id = atof(row[8]); - entry.min_level = atoi(row[9]); - entry.min_status = atoi(row[10]); - entry.zoneidnumber = atoi(row[11]); - entry.version = atoi(row[12]); - entry.timezone = atoi(row[13]); - entry.maxclients = atoi(row[14]); - entry.ruleset = atoi(row[15]); - entry.note = row[16] ? row[16] : ""; - entry.underworld = atof(row[17]); - entry.minclip = atof(row[18]); - entry.maxclip = atof(row[19]); - entry.fog_minclip = atof(row[20]); - entry.fog_maxclip = atof(row[21]); - entry.fog_blue = atoi(row[22]); - entry.fog_red = atoi(row[23]); - entry.fog_green = atoi(row[24]); - entry.sky = atoi(row[25]); - entry.ztype = atoi(row[26]); - entry.zone_exp_multiplier = atof(row[27]); - entry.walkspeed = atof(row[28]); - entry.time_type = atoi(row[29]); - entry.fog_red1 = atoi(row[30]); - entry.fog_green1 = atoi(row[31]); - entry.fog_blue1 = atoi(row[32]); - entry.fog_minclip1 = atof(row[33]); - entry.fog_maxclip1 = atof(row[34]); - entry.fog_red2 = atoi(row[35]); - entry.fog_green2 = atoi(row[36]); - entry.fog_blue2 = atoi(row[37]); - entry.fog_minclip2 = atof(row[38]); - entry.fog_maxclip2 = atof(row[39]); - entry.fog_red3 = atoi(row[40]); - entry.fog_green3 = atoi(row[41]); - entry.fog_blue3 = atoi(row[42]); - entry.fog_minclip3 = atof(row[43]); - entry.fog_maxclip3 = atof(row[44]); - entry.fog_red4 = atoi(row[45]); - entry.fog_green4 = atoi(row[46]); - entry.fog_blue4 = atoi(row[47]); - entry.fog_minclip4 = atof(row[48]); - entry.fog_maxclip4 = atof(row[49]); - entry.fog_density = atof(row[50]); - entry.flag_needed = row[51] ? row[51] : ""; - entry.canbind = atoi(row[52]); - entry.cancombat = atoi(row[53]); - entry.canlevitate = atoi(row[54]); - entry.castoutdoor = atoi(row[55]); - entry.hotzone = atoi(row[56]); - entry.insttype = atoi(row[57]); - entry.shutdowndelay = atoi(row[58]); - entry.peqzone = atoi(row[59]); - entry.expansion = atoi(row[60]); - entry.suspendbuffs = atoi(row[61]); - entry.rain_chance1 = atoi(row[62]); - entry.rain_chance2 = atoi(row[63]); - entry.rain_chance3 = atoi(row[64]); - entry.rain_chance4 = atoi(row[65]); - entry.rain_duration1 = atoi(row[66]); - entry.rain_duration2 = atoi(row[67]); - entry.rain_duration3 = atoi(row[68]); - entry.rain_duration4 = atoi(row[69]); - entry.snow_chance1 = atoi(row[70]); - entry.snow_chance2 = atoi(row[71]); - entry.snow_chance3 = atoi(row[72]); - entry.snow_chance4 = atoi(row[73]); - entry.snow_duration1 = atoi(row[74]); - entry.snow_duration2 = atoi(row[75]); - entry.snow_duration3 = atoi(row[76]); - entry.snow_duration4 = atoi(row[77]); - entry.gravity = atof(row[78]); - entry.type = atoi(row[79]); - entry.skylock = atoi(row[80]); - entry.fast_regen_hp = atoi(row[81]); - entry.fast_regen_mana = atoi(row[82]); - entry.fast_regen_endurance = atoi(row[83]); - entry.npc_max_aggro_dist = atoi(row[84]); - entry.max_movement_update_range = atoi(row[85]); - - return entry; - } - - return NewEntity(); - } - - static int DeleteOne( - int zone_id - ) - { - auto results = content_db.QueryDatabase( - fmt::format( - "DELETE FROM {} WHERE {} = {}", - TableName(), - PrimaryKey(), - zone_id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static int UpdateOne( - Zone zone_entry - ) - { - std::vector update_values; - - auto columns = Columns(); - - update_values.push_back(columns[0] + " = '" + EscapeString(zone_entry.short_name) + "'"); - update_values.push_back(columns[2] + " = '" + EscapeString(zone_entry.file_name) + "'"); - update_values.push_back(columns[3] + " = '" + EscapeString(zone_entry.long_name) + "'"); - update_values.push_back(columns[4] + " = '" + EscapeString(zone_entry.map_file_name) + "'"); - update_values.push_back(columns[5] + " = " + std::to_string(zone_entry.safe_x)); - update_values.push_back(columns[6] + " = " + std::to_string(zone_entry.safe_y)); - update_values.push_back(columns[7] + " = " + std::to_string(zone_entry.safe_z)); - update_values.push_back(columns[8] + " = " + std::to_string(zone_entry.graveyard_id)); - update_values.push_back(columns[9] + " = " + std::to_string(zone_entry.min_level)); - update_values.push_back(columns[10] + " = " + std::to_string(zone_entry.min_status)); - update_values.push_back(columns[11] + " = " + std::to_string(zone_entry.zoneidnumber)); - update_values.push_back(columns[12] + " = " + std::to_string(zone_entry.version)); - update_values.push_back(columns[13] + " = " + std::to_string(zone_entry.timezone)); - update_values.push_back(columns[14] + " = " + std::to_string(zone_entry.maxclients)); - update_values.push_back(columns[15] + " = " + std::to_string(zone_entry.ruleset)); - update_values.push_back(columns[16] + " = '" + EscapeString(zone_entry.note) + "'"); - update_values.push_back(columns[17] + " = " + std::to_string(zone_entry.underworld)); - update_values.push_back(columns[18] + " = " + std::to_string(zone_entry.minclip)); - update_values.push_back(columns[19] + " = " + std::to_string(zone_entry.maxclip)); - update_values.push_back(columns[20] + " = " + std::to_string(zone_entry.fog_minclip)); - update_values.push_back(columns[21] + " = " + std::to_string(zone_entry.fog_maxclip)); - update_values.push_back(columns[22] + " = " + std::to_string(zone_entry.fog_blue)); - update_values.push_back(columns[23] + " = " + std::to_string(zone_entry.fog_red)); - update_values.push_back(columns[24] + " = " + std::to_string(zone_entry.fog_green)); - update_values.push_back(columns[25] + " = " + std::to_string(zone_entry.sky)); - update_values.push_back(columns[26] + " = " + std::to_string(zone_entry.ztype)); - update_values.push_back(columns[27] + " = " + std::to_string(zone_entry.zone_exp_multiplier)); - update_values.push_back(columns[28] + " = " + std::to_string(zone_entry.walkspeed)); - update_values.push_back(columns[29] + " = " + std::to_string(zone_entry.time_type)); - update_values.push_back(columns[30] + " = " + std::to_string(zone_entry.fog_red1)); - update_values.push_back(columns[31] + " = " + std::to_string(zone_entry.fog_green1)); - update_values.push_back(columns[32] + " = " + std::to_string(zone_entry.fog_blue1)); - update_values.push_back(columns[33] + " = " + std::to_string(zone_entry.fog_minclip1)); - update_values.push_back(columns[34] + " = " + std::to_string(zone_entry.fog_maxclip1)); - update_values.push_back(columns[35] + " = " + std::to_string(zone_entry.fog_red2)); - update_values.push_back(columns[36] + " = " + std::to_string(zone_entry.fog_green2)); - update_values.push_back(columns[37] + " = " + std::to_string(zone_entry.fog_blue2)); - update_values.push_back(columns[38] + " = " + std::to_string(zone_entry.fog_minclip2)); - update_values.push_back(columns[39] + " = " + std::to_string(zone_entry.fog_maxclip2)); - update_values.push_back(columns[40] + " = " + std::to_string(zone_entry.fog_red3)); - update_values.push_back(columns[41] + " = " + std::to_string(zone_entry.fog_green3)); - update_values.push_back(columns[42] + " = " + std::to_string(zone_entry.fog_blue3)); - update_values.push_back(columns[43] + " = " + std::to_string(zone_entry.fog_minclip3)); - update_values.push_back(columns[44] + " = " + std::to_string(zone_entry.fog_maxclip3)); - update_values.push_back(columns[45] + " = " + std::to_string(zone_entry.fog_red4)); - update_values.push_back(columns[46] + " = " + std::to_string(zone_entry.fog_green4)); - update_values.push_back(columns[47] + " = " + std::to_string(zone_entry.fog_blue4)); - update_values.push_back(columns[48] + " = " + std::to_string(zone_entry.fog_minclip4)); - update_values.push_back(columns[49] + " = " + std::to_string(zone_entry.fog_maxclip4)); - update_values.push_back(columns[50] + " = " + std::to_string(zone_entry.fog_density)); - update_values.push_back(columns[51] + " = '" + EscapeString(zone_entry.flag_needed) + "'"); - update_values.push_back(columns[52] + " = " + std::to_string(zone_entry.canbind)); - update_values.push_back(columns[53] + " = " + std::to_string(zone_entry.cancombat)); - update_values.push_back(columns[54] + " = " + std::to_string(zone_entry.canlevitate)); - update_values.push_back(columns[55] + " = " + std::to_string(zone_entry.castoutdoor)); - update_values.push_back(columns[56] + " = " + std::to_string(zone_entry.hotzone)); - update_values.push_back(columns[57] + " = " + std::to_string(zone_entry.insttype)); - update_values.push_back(columns[58] + " = " + std::to_string(zone_entry.shutdowndelay)); - update_values.push_back(columns[59] + " = " + std::to_string(zone_entry.peqzone)); - update_values.push_back(columns[60] + " = " + std::to_string(zone_entry.expansion)); - update_values.push_back(columns[61] + " = " + std::to_string(zone_entry.suspendbuffs)); - update_values.push_back(columns[62] + " = " + std::to_string(zone_entry.rain_chance1)); - update_values.push_back(columns[63] + " = " + std::to_string(zone_entry.rain_chance2)); - update_values.push_back(columns[64] + " = " + std::to_string(zone_entry.rain_chance3)); - update_values.push_back(columns[65] + " = " + std::to_string(zone_entry.rain_chance4)); - update_values.push_back(columns[66] + " = " + std::to_string(zone_entry.rain_duration1)); - update_values.push_back(columns[67] + " = " + std::to_string(zone_entry.rain_duration2)); - update_values.push_back(columns[68] + " = " + std::to_string(zone_entry.rain_duration3)); - update_values.push_back(columns[69] + " = " + std::to_string(zone_entry.rain_duration4)); - update_values.push_back(columns[70] + " = " + std::to_string(zone_entry.snow_chance1)); - update_values.push_back(columns[71] + " = " + std::to_string(zone_entry.snow_chance2)); - update_values.push_back(columns[72] + " = " + std::to_string(zone_entry.snow_chance3)); - update_values.push_back(columns[73] + " = " + std::to_string(zone_entry.snow_chance4)); - update_values.push_back(columns[74] + " = " + std::to_string(zone_entry.snow_duration1)); - update_values.push_back(columns[75] + " = " + std::to_string(zone_entry.snow_duration2)); - update_values.push_back(columns[76] + " = " + std::to_string(zone_entry.snow_duration3)); - update_values.push_back(columns[77] + " = " + std::to_string(zone_entry.snow_duration4)); - update_values.push_back(columns[78] + " = " + std::to_string(zone_entry.gravity)); - update_values.push_back(columns[79] + " = " + std::to_string(zone_entry.type)); - update_values.push_back(columns[80] + " = " + std::to_string(zone_entry.skylock)); - update_values.push_back(columns[81] + " = " + std::to_string(zone_entry.fast_regen_hp)); - update_values.push_back(columns[82] + " = " + std::to_string(zone_entry.fast_regen_mana)); - update_values.push_back(columns[83] + " = " + std::to_string(zone_entry.fast_regen_endurance)); - update_values.push_back(columns[84] + " = " + std::to_string(zone_entry.npc_max_aggro_dist)); - update_values.push_back(columns[85] + " = " + std::to_string(zone_entry.max_movement_update_range)); - - auto results = content_db.QueryDatabase( - fmt::format( - "UPDATE {} SET {} WHERE {} = {}", - TableName(), - implode(", ", update_values), - PrimaryKey(), - zone_entry.id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static Zone InsertOne( - Zone zone_entry - ) - { - std::vector insert_values; - - insert_values.push_back("'" + EscapeString(zone_entry.short_name) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.file_name) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.long_name) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.map_file_name) + "'"); - insert_values.push_back(std::to_string(zone_entry.safe_x)); - insert_values.push_back(std::to_string(zone_entry.safe_y)); - insert_values.push_back(std::to_string(zone_entry.safe_z)); - insert_values.push_back(std::to_string(zone_entry.graveyard_id)); - insert_values.push_back(std::to_string(zone_entry.min_level)); - insert_values.push_back(std::to_string(zone_entry.min_status)); - insert_values.push_back(std::to_string(zone_entry.zoneidnumber)); - insert_values.push_back(std::to_string(zone_entry.version)); - insert_values.push_back(std::to_string(zone_entry.timezone)); - insert_values.push_back(std::to_string(zone_entry.maxclients)); - insert_values.push_back(std::to_string(zone_entry.ruleset)); - insert_values.push_back("'" + EscapeString(zone_entry.note) + "'"); - insert_values.push_back(std::to_string(zone_entry.underworld)); - insert_values.push_back(std::to_string(zone_entry.minclip)); - insert_values.push_back(std::to_string(zone_entry.maxclip)); - insert_values.push_back(std::to_string(zone_entry.fog_minclip)); - insert_values.push_back(std::to_string(zone_entry.fog_maxclip)); - insert_values.push_back(std::to_string(zone_entry.fog_blue)); - insert_values.push_back(std::to_string(zone_entry.fog_red)); - insert_values.push_back(std::to_string(zone_entry.fog_green)); - insert_values.push_back(std::to_string(zone_entry.sky)); - insert_values.push_back(std::to_string(zone_entry.ztype)); - insert_values.push_back(std::to_string(zone_entry.zone_exp_multiplier)); - insert_values.push_back(std::to_string(zone_entry.walkspeed)); - insert_values.push_back(std::to_string(zone_entry.time_type)); - insert_values.push_back(std::to_string(zone_entry.fog_red1)); - insert_values.push_back(std::to_string(zone_entry.fog_green1)); - insert_values.push_back(std::to_string(zone_entry.fog_blue1)); - insert_values.push_back(std::to_string(zone_entry.fog_minclip1)); - insert_values.push_back(std::to_string(zone_entry.fog_maxclip1)); - insert_values.push_back(std::to_string(zone_entry.fog_red2)); - insert_values.push_back(std::to_string(zone_entry.fog_green2)); - insert_values.push_back(std::to_string(zone_entry.fog_blue2)); - insert_values.push_back(std::to_string(zone_entry.fog_minclip2)); - insert_values.push_back(std::to_string(zone_entry.fog_maxclip2)); - insert_values.push_back(std::to_string(zone_entry.fog_red3)); - insert_values.push_back(std::to_string(zone_entry.fog_green3)); - insert_values.push_back(std::to_string(zone_entry.fog_blue3)); - insert_values.push_back(std::to_string(zone_entry.fog_minclip3)); - insert_values.push_back(std::to_string(zone_entry.fog_maxclip3)); - insert_values.push_back(std::to_string(zone_entry.fog_red4)); - insert_values.push_back(std::to_string(zone_entry.fog_green4)); - insert_values.push_back(std::to_string(zone_entry.fog_blue4)); - insert_values.push_back(std::to_string(zone_entry.fog_minclip4)); - insert_values.push_back(std::to_string(zone_entry.fog_maxclip4)); - insert_values.push_back(std::to_string(zone_entry.fog_density)); - insert_values.push_back("'" + EscapeString(zone_entry.flag_needed) + "'"); - insert_values.push_back(std::to_string(zone_entry.canbind)); - insert_values.push_back(std::to_string(zone_entry.cancombat)); - insert_values.push_back(std::to_string(zone_entry.canlevitate)); - insert_values.push_back(std::to_string(zone_entry.castoutdoor)); - insert_values.push_back(std::to_string(zone_entry.hotzone)); - insert_values.push_back(std::to_string(zone_entry.insttype)); - insert_values.push_back(std::to_string(zone_entry.shutdowndelay)); - insert_values.push_back(std::to_string(zone_entry.peqzone)); - insert_values.push_back(std::to_string(zone_entry.expansion)); - insert_values.push_back(std::to_string(zone_entry.suspendbuffs)); - insert_values.push_back(std::to_string(zone_entry.rain_chance1)); - insert_values.push_back(std::to_string(zone_entry.rain_chance2)); - insert_values.push_back(std::to_string(zone_entry.rain_chance3)); - insert_values.push_back(std::to_string(zone_entry.rain_chance4)); - insert_values.push_back(std::to_string(zone_entry.rain_duration1)); - insert_values.push_back(std::to_string(zone_entry.rain_duration2)); - insert_values.push_back(std::to_string(zone_entry.rain_duration3)); - insert_values.push_back(std::to_string(zone_entry.rain_duration4)); - insert_values.push_back(std::to_string(zone_entry.snow_chance1)); - insert_values.push_back(std::to_string(zone_entry.snow_chance2)); - insert_values.push_back(std::to_string(zone_entry.snow_chance3)); - insert_values.push_back(std::to_string(zone_entry.snow_chance4)); - insert_values.push_back(std::to_string(zone_entry.snow_duration1)); - insert_values.push_back(std::to_string(zone_entry.snow_duration2)); - insert_values.push_back(std::to_string(zone_entry.snow_duration3)); - insert_values.push_back(std::to_string(zone_entry.snow_duration4)); - insert_values.push_back(std::to_string(zone_entry.gravity)); - insert_values.push_back(std::to_string(zone_entry.type)); - insert_values.push_back(std::to_string(zone_entry.skylock)); - insert_values.push_back(std::to_string(zone_entry.fast_regen_hp)); - insert_values.push_back(std::to_string(zone_entry.fast_regen_mana)); - insert_values.push_back(std::to_string(zone_entry.fast_regen_endurance)); - insert_values.push_back(std::to_string(zone_entry.npc_max_aggro_dist)); - insert_values.push_back(std::to_string(zone_entry.max_movement_update_range)); - - auto results = content_db.QueryDatabase( - fmt::format( - "{} VALUES ({})", - BaseInsert(), - implode(",", insert_values) - ) - ); - - if (results.Success()) { - zone_entry.id = results.LastInsertedID(); - return zone_entry; - } - - zone_entry = ZoneRepository::NewEntity(); - - return zone_entry; - } - - static int InsertMany( - std::vector zone_entries - ) - { - std::vector insert_chunks; - - for (auto &zone_entry: zone_entries) { - std::vector insert_values; - - insert_values.push_back("'" + EscapeString(zone_entry.short_name) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.file_name) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.long_name) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.map_file_name) + "'"); - insert_values.push_back(std::to_string(zone_entry.safe_x)); - insert_values.push_back(std::to_string(zone_entry.safe_y)); - insert_values.push_back(std::to_string(zone_entry.safe_z)); - insert_values.push_back(std::to_string(zone_entry.graveyard_id)); - insert_values.push_back(std::to_string(zone_entry.min_level)); - insert_values.push_back(std::to_string(zone_entry.min_status)); - insert_values.push_back(std::to_string(zone_entry.zoneidnumber)); - insert_values.push_back(std::to_string(zone_entry.version)); - insert_values.push_back(std::to_string(zone_entry.timezone)); - insert_values.push_back(std::to_string(zone_entry.maxclients)); - insert_values.push_back(std::to_string(zone_entry.ruleset)); - insert_values.push_back("'" + EscapeString(zone_entry.note) + "'"); - insert_values.push_back(std::to_string(zone_entry.underworld)); - insert_values.push_back(std::to_string(zone_entry.minclip)); - insert_values.push_back(std::to_string(zone_entry.maxclip)); - insert_values.push_back(std::to_string(zone_entry.fog_minclip)); - insert_values.push_back(std::to_string(zone_entry.fog_maxclip)); - insert_values.push_back(std::to_string(zone_entry.fog_blue)); - insert_values.push_back(std::to_string(zone_entry.fog_red)); - insert_values.push_back(std::to_string(zone_entry.fog_green)); - insert_values.push_back(std::to_string(zone_entry.sky)); - insert_values.push_back(std::to_string(zone_entry.ztype)); - insert_values.push_back(std::to_string(zone_entry.zone_exp_multiplier)); - insert_values.push_back(std::to_string(zone_entry.walkspeed)); - insert_values.push_back(std::to_string(zone_entry.time_type)); - insert_values.push_back(std::to_string(zone_entry.fog_red1)); - insert_values.push_back(std::to_string(zone_entry.fog_green1)); - insert_values.push_back(std::to_string(zone_entry.fog_blue1)); - insert_values.push_back(std::to_string(zone_entry.fog_minclip1)); - insert_values.push_back(std::to_string(zone_entry.fog_maxclip1)); - insert_values.push_back(std::to_string(zone_entry.fog_red2)); - insert_values.push_back(std::to_string(zone_entry.fog_green2)); - insert_values.push_back(std::to_string(zone_entry.fog_blue2)); - insert_values.push_back(std::to_string(zone_entry.fog_minclip2)); - insert_values.push_back(std::to_string(zone_entry.fog_maxclip2)); - insert_values.push_back(std::to_string(zone_entry.fog_red3)); - insert_values.push_back(std::to_string(zone_entry.fog_green3)); - insert_values.push_back(std::to_string(zone_entry.fog_blue3)); - insert_values.push_back(std::to_string(zone_entry.fog_minclip3)); - insert_values.push_back(std::to_string(zone_entry.fog_maxclip3)); - insert_values.push_back(std::to_string(zone_entry.fog_red4)); - insert_values.push_back(std::to_string(zone_entry.fog_green4)); - insert_values.push_back(std::to_string(zone_entry.fog_blue4)); - insert_values.push_back(std::to_string(zone_entry.fog_minclip4)); - insert_values.push_back(std::to_string(zone_entry.fog_maxclip4)); - insert_values.push_back(std::to_string(zone_entry.fog_density)); - insert_values.push_back("'" + EscapeString(zone_entry.flag_needed) + "'"); - insert_values.push_back(std::to_string(zone_entry.canbind)); - insert_values.push_back(std::to_string(zone_entry.cancombat)); - insert_values.push_back(std::to_string(zone_entry.canlevitate)); - insert_values.push_back(std::to_string(zone_entry.castoutdoor)); - insert_values.push_back(std::to_string(zone_entry.hotzone)); - insert_values.push_back(std::to_string(zone_entry.insttype)); - insert_values.push_back(std::to_string(zone_entry.shutdowndelay)); - insert_values.push_back(std::to_string(zone_entry.peqzone)); - insert_values.push_back(std::to_string(zone_entry.expansion)); - insert_values.push_back(std::to_string(zone_entry.suspendbuffs)); - insert_values.push_back(std::to_string(zone_entry.rain_chance1)); - insert_values.push_back(std::to_string(zone_entry.rain_chance2)); - insert_values.push_back(std::to_string(zone_entry.rain_chance3)); - insert_values.push_back(std::to_string(zone_entry.rain_chance4)); - insert_values.push_back(std::to_string(zone_entry.rain_duration1)); - insert_values.push_back(std::to_string(zone_entry.rain_duration2)); - insert_values.push_back(std::to_string(zone_entry.rain_duration3)); - insert_values.push_back(std::to_string(zone_entry.rain_duration4)); - insert_values.push_back(std::to_string(zone_entry.snow_chance1)); - insert_values.push_back(std::to_string(zone_entry.snow_chance2)); - insert_values.push_back(std::to_string(zone_entry.snow_chance3)); - insert_values.push_back(std::to_string(zone_entry.snow_chance4)); - insert_values.push_back(std::to_string(zone_entry.snow_duration1)); - insert_values.push_back(std::to_string(zone_entry.snow_duration2)); - insert_values.push_back(std::to_string(zone_entry.snow_duration3)); - insert_values.push_back(std::to_string(zone_entry.snow_duration4)); - insert_values.push_back(std::to_string(zone_entry.gravity)); - insert_values.push_back(std::to_string(zone_entry.type)); - insert_values.push_back(std::to_string(zone_entry.skylock)); - insert_values.push_back(std::to_string(zone_entry.fast_regen_hp)); - insert_values.push_back(std::to_string(zone_entry.fast_regen_mana)); - insert_values.push_back(std::to_string(zone_entry.fast_regen_endurance)); - insert_values.push_back(std::to_string(zone_entry.npc_max_aggro_dist)); - insert_values.push_back(std::to_string(zone_entry.max_movement_update_range)); - - 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) { - Zone entry{}; - - entry.short_name = row[0] ? row[0] : ""; - entry.id = atoi(row[1]); - entry.file_name = row[2] ? row[2] : ""; - entry.long_name = row[3] ? row[3] : ""; - entry.map_file_name = row[4] ? row[4] : ""; - entry.safe_x = atof(row[5]); - entry.safe_y = atof(row[6]); - entry.safe_z = atof(row[7]); - entry.graveyard_id = atof(row[8]); - entry.min_level = atoi(row[9]); - entry.min_status = atoi(row[10]); - entry.zoneidnumber = atoi(row[11]); - entry.version = atoi(row[12]); - entry.timezone = atoi(row[13]); - entry.maxclients = atoi(row[14]); - entry.ruleset = atoi(row[15]); - entry.note = row[16] ? row[16] : ""; - entry.underworld = atof(row[17]); - entry.minclip = atof(row[18]); - entry.maxclip = atof(row[19]); - entry.fog_minclip = atof(row[20]); - entry.fog_maxclip = atof(row[21]); - entry.fog_blue = atoi(row[22]); - entry.fog_red = atoi(row[23]); - entry.fog_green = atoi(row[24]); - entry.sky = atoi(row[25]); - entry.ztype = atoi(row[26]); - entry.zone_exp_multiplier = atof(row[27]); - entry.walkspeed = atof(row[28]); - entry.time_type = atoi(row[29]); - entry.fog_red1 = atoi(row[30]); - entry.fog_green1 = atoi(row[31]); - entry.fog_blue1 = atoi(row[32]); - entry.fog_minclip1 = atof(row[33]); - entry.fog_maxclip1 = atof(row[34]); - entry.fog_red2 = atoi(row[35]); - entry.fog_green2 = atoi(row[36]); - entry.fog_blue2 = atoi(row[37]); - entry.fog_minclip2 = atof(row[38]); - entry.fog_maxclip2 = atof(row[39]); - entry.fog_red3 = atoi(row[40]); - entry.fog_green3 = atoi(row[41]); - entry.fog_blue3 = atoi(row[42]); - entry.fog_minclip3 = atof(row[43]); - entry.fog_maxclip3 = atof(row[44]); - entry.fog_red4 = atoi(row[45]); - entry.fog_green4 = atoi(row[46]); - entry.fog_blue4 = atoi(row[47]); - entry.fog_minclip4 = atof(row[48]); - entry.fog_maxclip4 = atof(row[49]); - entry.fog_density = atof(row[50]); - entry.flag_needed = row[51] ? row[51] : ""; - entry.canbind = atoi(row[52]); - entry.cancombat = atoi(row[53]); - entry.canlevitate = atoi(row[54]); - entry.castoutdoor = atoi(row[55]); - entry.hotzone = atoi(row[56]); - entry.insttype = atoi(row[57]); - entry.shutdowndelay = atoi(row[58]); - entry.peqzone = atoi(row[59]); - entry.expansion = atoi(row[60]); - entry.suspendbuffs = atoi(row[61]); - entry.rain_chance1 = atoi(row[62]); - entry.rain_chance2 = atoi(row[63]); - entry.rain_chance3 = atoi(row[64]); - entry.rain_chance4 = atoi(row[65]); - entry.rain_duration1 = atoi(row[66]); - entry.rain_duration2 = atoi(row[67]); - entry.rain_duration3 = atoi(row[68]); - entry.rain_duration4 = atoi(row[69]); - entry.snow_chance1 = atoi(row[70]); - entry.snow_chance2 = atoi(row[71]); - entry.snow_chance3 = atoi(row[72]); - entry.snow_chance4 = atoi(row[73]); - entry.snow_duration1 = atoi(row[74]); - entry.snow_duration2 = atoi(row[75]); - entry.snow_duration3 = atoi(row[76]); - entry.snow_duration4 = atoi(row[77]); - entry.gravity = atof(row[78]); - entry.type = atoi(row[79]); - entry.skylock = atoi(row[80]); - entry.fast_regen_hp = atoi(row[81]); - entry.fast_regen_mana = atoi(row[82]); - entry.fast_regen_endurance = atoi(row[83]); - entry.npc_max_aggro_dist = atoi(row[84]); - entry.max_movement_update_range = atoi(row[85]); - - 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) { - Zone entry{}; - - entry.short_name = row[0] ? row[0] : ""; - entry.id = atoi(row[1]); - entry.file_name = row[2] ? row[2] : ""; - entry.long_name = row[3] ? row[3] : ""; - entry.map_file_name = row[4] ? row[4] : ""; - entry.safe_x = atof(row[5]); - entry.safe_y = atof(row[6]); - entry.safe_z = atof(row[7]); - entry.graveyard_id = atof(row[8]); - entry.min_level = atoi(row[9]); - entry.min_status = atoi(row[10]); - entry.zoneidnumber = atoi(row[11]); - entry.version = atoi(row[12]); - entry.timezone = atoi(row[13]); - entry.maxclients = atoi(row[14]); - entry.ruleset = atoi(row[15]); - entry.note = row[16] ? row[16] : ""; - entry.underworld = atof(row[17]); - entry.minclip = atof(row[18]); - entry.maxclip = atof(row[19]); - entry.fog_minclip = atof(row[20]); - entry.fog_maxclip = atof(row[21]); - entry.fog_blue = atoi(row[22]); - entry.fog_red = atoi(row[23]); - entry.fog_green = atoi(row[24]); - entry.sky = atoi(row[25]); - entry.ztype = atoi(row[26]); - entry.zone_exp_multiplier = atof(row[27]); - entry.walkspeed = atof(row[28]); - entry.time_type = atoi(row[29]); - entry.fog_red1 = atoi(row[30]); - entry.fog_green1 = atoi(row[31]); - entry.fog_blue1 = atoi(row[32]); - entry.fog_minclip1 = atof(row[33]); - entry.fog_maxclip1 = atof(row[34]); - entry.fog_red2 = atoi(row[35]); - entry.fog_green2 = atoi(row[36]); - entry.fog_blue2 = atoi(row[37]); - entry.fog_minclip2 = atof(row[38]); - entry.fog_maxclip2 = atof(row[39]); - entry.fog_red3 = atoi(row[40]); - entry.fog_green3 = atoi(row[41]); - entry.fog_blue3 = atoi(row[42]); - entry.fog_minclip3 = atof(row[43]); - entry.fog_maxclip3 = atof(row[44]); - entry.fog_red4 = atoi(row[45]); - entry.fog_green4 = atoi(row[46]); - entry.fog_blue4 = atoi(row[47]); - entry.fog_minclip4 = atof(row[48]); - entry.fog_maxclip4 = atof(row[49]); - entry.fog_density = atof(row[50]); - entry.flag_needed = row[51] ? row[51] : ""; - entry.canbind = atoi(row[52]); - entry.cancombat = atoi(row[53]); - entry.canlevitate = atoi(row[54]); - entry.castoutdoor = atoi(row[55]); - entry.hotzone = atoi(row[56]); - entry.insttype = atoi(row[57]); - entry.shutdowndelay = atoi(row[58]); - entry.peqzone = atoi(row[59]); - entry.expansion = atoi(row[60]); - entry.suspendbuffs = atoi(row[61]); - entry.rain_chance1 = atoi(row[62]); - entry.rain_chance2 = atoi(row[63]); - entry.rain_chance3 = atoi(row[64]); - entry.rain_chance4 = atoi(row[65]); - entry.rain_duration1 = atoi(row[66]); - entry.rain_duration2 = atoi(row[67]); - entry.rain_duration3 = atoi(row[68]); - entry.rain_duration4 = atoi(row[69]); - entry.snow_chance1 = atoi(row[70]); - entry.snow_chance2 = atoi(row[71]); - entry.snow_chance3 = atoi(row[72]); - entry.snow_chance4 = atoi(row[73]); - entry.snow_duration1 = atoi(row[74]); - entry.snow_duration2 = atoi(row[75]); - entry.snow_duration3 = atoi(row[76]); - entry.snow_duration4 = atoi(row[77]); - entry.gravity = atof(row[78]); - entry.type = atoi(row[79]); - entry.skylock = atoi(row[80]); - entry.fast_regen_hp = atoi(row[81]); - entry.fast_regen_mana = atoi(row[82]); - entry.fast_regen_endurance = atoi(row[83]); - entry.npc_max_aggro_dist = atoi(row[84]); - entry.max_movement_update_range = atoi(row[85]); - - 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(), - PrimaryKey(), - where_filter - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } + // Custom extended repository methods here }; diff --git a/utils/scripts/generators/repository-generator.pl b/utils/scripts/generators/repository-generator.pl index 15bec02b0..060b6b010 100644 --- a/utils/scripts/generators/repository-generator.pl +++ b/utils/scripts/generators/repository-generator.pl @@ -2,7 +2,7 @@ # Author: Akkadius # @file: repository-generator.pl # @description: Script used to generate database repositories -# @example perl ~/code/utils/scripts/generators/repository-generator.pl ~/server/ +# @example perl ~/code/utils/scripts/generators/repository-generator.pl ~/server/ [table|all] [base|extended|all] ############################################# # modules @@ -20,9 +20,10 @@ my $json = new JSON(); ############################################# # args ############################################# -my $server_path = $ARGV[0]; -my $config_path = $server_path . "/eqemu_config.json"; -my $requested_table_to_generate = $ARGV[1] ? $ARGV[1] : ""; +my $server_path = $ARGV[0]; +my $config_path = $server_path . "/eqemu_config.json"; +my $requested_table_to_generate = $ARGV[1] ? $ARGV[1] : "all"; +my $repository_generation_option = $ARGV[2] ? $ARGV[2] : "all"; ############################################# # world path @@ -78,9 +79,8 @@ my $pass = $config->{"server"}{"database"}{"password"}; my $dsn = "dbi:mysql:$database_name:$host:3306"; my $connect = DBI->connect($dsn, $user, $pass); -my @tables = (); +my @tables = ($requested_table_to_generate); if ($requested_table_to_generate eq "all" || !$requested_table_to_generate) { - my $table_names_exec = $connect->prepare( " SELECT @@ -100,7 +100,8 @@ if ($requested_table_to_generate eq "all" || !$requested_table_to_generate) { } } -my $generated_repository_files = ""; +my $generated_base_repository_files = ""; +my $generated_repository_files = ""; foreach my $table_to_generate (@tables) { @@ -115,12 +116,36 @@ foreach my $table_to_generate (@tables) { "login_tables", ); + # These tables don't have a typical schema + my @table_ignore_list = ( + "character_enabledtasks", + # "grid", # Manually created + "grid_entries", # Manually created + # "tradeskill_recipe", # Manually created + # "character_recipe_list", # Manually created + "guild_bank", + "inventory_versions", + "raid_leaders", + "sharedbank", + "trader_audit", + "eqtime", + "db_version", + "keyring", + "profanity_list", + "zone_flags", + ); + foreach my $category (@categories) { if ($table_to_generate ~~ $database_schema->{$category}) { $table_found_in_schema = 1; } } + if ($table_to_generate ~~ @table_ignore_list) { + print "Table [$table_to_generate] is on ignore list... skipping...\n"; + $table_found_in_schema = 0; + } + if ($table_found_in_schema == 0) { print "Table [$table_to_generate] not found in schema, skipping\n"; next; @@ -177,6 +202,9 @@ foreach my $table_to_generate (@tables) { my %table_data = (); my %table_primary_key = (); $ex->execute($database_name, $table_to_generate); + + $table_primary_key{$table_to_generate} = "id"; + while (my @row = $ex->fetchrow_array()) { my $column_name = $row[0]; my $table_name = $row[1]; @@ -186,15 +214,19 @@ foreach my $table_to_generate (@tables) { my $column_key = $row[5]; my $column_default = ($row[6] ? $row[6] : ""); - if ($column_key eq "PRI") { + if ($column_key eq "PRI" || ($ordinal_position == 0 && $column_name =~ /id/i)) { $table_primary_key{$table_name} = $column_name; } my $default_value = 0; if ($column_default ne "NULL" && $column_default ne "") { + $column_default =~ s/'/"/g; $default_value = $column_default; } - if ($column_default eq "''") { + elsif ($column_default eq "''") { + $default_value = '""'; + } + elsif ((trim($column_default) eq "" || $column_default eq "NULL") && $column_type =~ /text|varchar/i) { $default_value = '""'; } @@ -212,7 +244,7 @@ foreach my $table_to_generate (@tables) { # update one if ($column_key ne "PRI") { my $query_value = sprintf('\'" + EscapeString(%s_entry.%s) + "\'");', $table_name, $column_name); - if ($data_type =~ /int/) { + if ($data_type =~ /int|float|double|decimal/) { $query_value = sprintf('" + std::to_string(%s_entry.%s));', $table_name, $column_name); } @@ -226,7 +258,7 @@ foreach my $table_to_generate (@tables) { # insert one if ($column_key ne "PRI") { my $value = sprintf("\"'\" + EscapeString(%s_entry.%s) + \"'\"", $table_name, $column_name); - if ($data_type =~ /int/) { + if ($data_type =~ /int|float|double|decimal/) { $value = sprintf('std::to_string(%s_entry.%s)', $table_name, $column_name); } @@ -244,8 +276,8 @@ foreach my $table_to_generate (@tables) { $find_one_entries .= sprintf("\t\t\tentry.%-${longest_column_length}s = atof(row[%s]);\n", $column_name, $index); } else { - $all_entries .= sprintf("\t\t\tentry.%-${longest_column_length}s = row[%s];\n", $column_name, $index); - $find_one_entries .= sprintf("\t\t\tentry.%-${longest_column_length}s = row[%s];\n", $column_name, $index); + $all_entries .= sprintf("\t\t\tentry.%-${longest_column_length}s = row[%s] ? row[%s] : \"\";\n", $column_name, $index, $index); + $find_one_entries .= sprintf("\t\t\tentry.%-${longest_column_length}s = row[%s] ? row[%s] : \"\";\n", $column_name, $index, $index); } # print $column_name . "\n"; @@ -255,6 +287,26 @@ foreach my $table_to_generate (@tables) { $index++; } + ############################################# + # base repository template + ############################################# + my $base_repository_template_file = './common/repositories/template/base_repository.template'; + my $base_repository_template = ""; + if (-e $base_repository_template_file) { + open(my $fh, '<:encoding(UTF-8)', $base_repository_template_file) or die "Could not open file '$base_repository_template_file' $!"; + + while (my $line = <$fh>) { + $base_repository_template .= $line; + } + + close $fh; + } + + if (trim($base_repository_template) eq "") { + print "Base repository template not found! [$repository_template_file]\n"; + exit; + } + ############################################# # repository template ############################################# @@ -270,21 +322,11 @@ foreach my $table_to_generate (@tables) { close $fh; } - if (trim($repository_template) eq "") { + if (trim($repository_template_file) eq "") { print "Repository template not found! [$repository_template_file]\n"; exit; } - foreach my $column (keys %{ $table_data{$table_to_generate} }) { - my $column_data = $table_data{$table_to_generate}{$column}; - my $data_type = $column_data->[0]; - my $column_type = $column_data->[1]; - my $ordinal_position = $column_data->[2]; - my $column_default = $column_data->[3]; - - # print "Column [$column] data_type [$data_type] column_type [$column_type] ordinal [$ordinal_position]\n"; - } - my $table_name_camel_case = $table_to_generate; my $table_name_upper_case = uc($table_to_generate); $table_name_camel_case =~ s#(_|^)(.)#\u$2#g; @@ -303,13 +345,34 @@ foreach my $table_to_generate (@tables) { chomp($insert_many_entries); chomp($all_entries); + use POSIX qw(strftime); + my $generated_date = strftime "%b%e, %Y", localtime; + print "Table name CamelCase [$table_name_camel_case]\n"; print "Table name UPPER_CASE [$table_name_upper_case]\n"; print "Table PRIMARY KEY [$primary_key]\n"; print "Database connection [$database_connection]\n"; - my $new_repository = $repository_template; + # Base repository + my $new_base_repository = $base_repository_template; + $new_base_repository =~ s/\{\{TABLE_NAME_CLASS}}/$table_name_camel_case/g; + $new_base_repository =~ s/\{\{TABLE_NAME_UPPER}}/$table_name_upper_case/g; + $new_base_repository =~ s/\{\{PRIMARY_KEY_STRING}}/$primary_key/g; + $new_base_repository =~ s/\{\{TABLE_NAME_STRUCT}}/$table_name_camel_case/g; + $new_base_repository =~ s/\{\{TABLE_NAME_VAR}}/$table_to_generate/g; + $new_base_repository =~ s/\{\{DATABASE_CONNECTION}}/$database_connection/g; + $new_base_repository =~ s/\{\{DEFAULT_ENTRIES}}/$default_entries/g; + $new_base_repository =~ s/\{\{COLUMNS_LIST_QUOTED}}/$column_names_quoted/g; + $new_base_repository =~ s/\{\{TABLE_STRUCT_COLUMNS}}/$table_struct_columns/g; + $new_base_repository =~ s/\{\{FIND_ONE_ENTRIES}}/$find_one_entries/g; + $new_base_repository =~ s/\{\{UPDATE_ONE_ENTRIES}}/$update_one_entries/g; + $new_base_repository =~ s/\{\{INSERT_ONE_ENTRIES}}/$insert_one_entries/g; + $new_base_repository =~ s/\{\{INSERT_MANY_ENTRIES}}/$insert_many_entries/g; + $new_base_repository =~ s/\{\{ALL_ENTRIES}}/$all_entries/g; + $new_base_repository =~ s/\{\{GENERATED_DATE}}/$generated_date/g; + # Extended repository + my $new_repository = $repository_template; $new_repository =~ s/\{\{TABLE_NAME_CLASS}}/$table_name_camel_case/g; $new_repository =~ s/\{\{TABLE_NAME_UPPER}}/$table_name_upper_case/g; $new_repository =~ s/\{\{PRIMARY_KEY_STRING}}/$primary_key/g; @@ -324,25 +387,50 @@ foreach my $table_to_generate (@tables) { $new_repository =~ s/\{\{INSERT_ONE_ENTRIES}}/$insert_one_entries/g; $new_repository =~ s/\{\{INSERT_MANY_ENTRIES}}/$insert_many_entries/g; $new_repository =~ s/\{\{ALL_ENTRIES}}/$all_entries/g; + $new_repository =~ s/\{\{GENERATED_DATE}}/$generated_date/g; - print $new_repository; + if ($repository_generation_option eq "all" || $repository_generation_option eq "base") { + print $new_base_repository; + } - my $generated_repository = './common/repositories/' . $table_to_generate . '_repository.h'; - my $cmake_generated_reference = $generated_repository; + if ($repository_generation_option eq "all" || $repository_generation_option eq "extended") { + print $new_repository; + } - $cmake_generated_reference =~ s/.\/common\///g; + ############################################# + # write base repository + ############################################# + if ($repository_generation_option eq "all" || $repository_generation_option eq "base") { + my $generated_base_repository = './common/repositories/base/base_' . $table_to_generate . '_repository.h'; + my $cmake_generated_base_reference = $generated_base_repository; + $cmake_generated_base_reference =~ s/.\/common\///g; + $generated_base_repository_files .= $cmake_generated_base_reference . "\n"; + open(FH, '>', $generated_base_repository) or die $!; + print FH $new_base_repository; + close(FH); + } - $generated_repository_files .= $cmake_generated_reference . "\n"; + ############################################# + # write extended repository + ############################################# + if ($repository_generation_option eq "all" || $repository_generation_option eq "extended") { + my $generated_repository = './common/repositories/' . $table_to_generate . '_repository.h'; + my $cmake_generated_reference = $generated_repository; + $cmake_generated_reference =~ s/.\/common\///g; + $generated_repository_files .= $cmake_generated_reference . "\n"; + open(FH, '>', $generated_repository) or die $!; + print FH $new_repository; + close(FH); + } - open(FH, '>', $generated_repository) or die $!; - - print FH $new_repository; - - close(FH); } print "\n# Make sure to add generated repositories to common/CMakeLists.txt under the repositories section\n\n"; +print "\n#Base Repositories\n"; +print $generated_base_repository_files . "\n"; + +print "\n#Extended Repositories\n"; print $generated_repository_files . "\n"; sub trim { @@ -362,9 +450,16 @@ sub translate_mysql_data_type_to_c { elsif ($mysql_data_type =~ /smallint/) { $struct_data_type = 'int16'; } + elsif ($mysql_data_type =~ /bigint/) { + $struct_data_type = 'int'; + # Use regular int for now until we have 64 support + } elsif ($mysql_data_type =~ /int/) { $struct_data_type = 'int'; } + elsif ($mysql_data_type =~ /float|double|decimal/) { + $struct_data_type = 'float'; + } return $struct_data_type; -} \ No newline at end of file +} diff --git a/world/world_server_command_handler.cpp b/world/world_server_command_handler.cpp index ec832271e..258221c9c 100644 --- a/world/world_server_command_handler.cpp +++ b/world/world_server_command_handler.cpp @@ -29,6 +29,7 @@ #include "../common/repositories/criteria/content_filter_criteria.h" #include "../common/rulesys.h" #include "../common/repositories/instance_list_repository.h" +#include "../common/repositories/zone_repository.h" namespace WorldserverCommandHandler { @@ -60,6 +61,7 @@ namespace WorldserverCommandHandler { function_map["test:test"] = &WorldserverCommandHandler::TestCommand; function_map["test:expansion"] = &WorldserverCommandHandler::ExpansionTestCommand; function_map["test:repository"] = &WorldserverCommandHandler::TestRepository; + function_map["test:repository2"] = &WorldserverCommandHandler::TestRepository2; EQEmuCommand::HandleMenu(function_map, cmd, argc, argv); } @@ -387,7 +389,7 @@ namespace WorldserverCommandHandler { /** * Delete one */ - int deleted = InstanceListRepository::DeleteOne(found_instance_list.id) ; + int deleted = InstanceListRepository::DeleteOne(found_instance_list.id); LogInfo("Deleting one instance [{}] deleted count [{}]", found_instance_list.id, deleted); @@ -416,10 +418,43 @@ namespace WorldserverCommandHandler { LogInfo("Bulk insertion test, inserted [{}]", inserted_count); - for (auto &entry: InstanceListRepository::All()) { + for (auto &entry: InstanceListRepository::GetWhere(fmt::format("zone = {}", 999))) { LogInfo("Iterating through entry id [{}] zone [{}]", entry.id, entry.zone); } + /** + * Delete where + */ + int deleted_count = InstanceListRepository::DeleteWhere(fmt::format("zone = {}", 999)); + + LogInfo("Bulk deletion test, deleted [{}]", deleted_count); + + } + + /** + * @param argc + * @param argv + * @param cmd + * @param description + */ + void TestRepository2(int argc, char **argv, argh::parser &cmd, std::string &description) + { + description = "Test command"; + + if (cmd[{"-h", "--help"}]) { + return; + } + + auto zones = ZoneRepository::GetWhere("short_name = 'anguish'"); + + for (auto &zone: zones) { + LogInfo( + "Zone [{}] long_name [{}] id [{}]", + zone.short_name, + zone.long_name, + zone.id + ); + } } } diff --git a/world/world_server_command_handler.h b/world/world_server_command_handler.h index 85baf7f90..251e1d048 100644 --- a/world/world_server_command_handler.h +++ b/world/world_server_command_handler.h @@ -34,6 +34,7 @@ namespace WorldserverCommandHandler { void TestCommand(int argc, char **argv, argh::parser &cmd, std::string &description); void ExpansionTestCommand(int argc, char **argv, argh::parser &cmd, std::string &description); void TestRepository(int argc, char **argv, argh::parser &cmd, std::string &description); + void TestRepository2(int argc, char **argv, argh::parser &cmd, std::string &description); }; diff --git a/zone/main.cpp b/zone/main.cpp index 3f8026cad..b82f37484 100644 --- a/zone/main.cpp +++ b/zone/main.cpp @@ -91,9 +91,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include #include "../common/unix.h" +#endif + #include "../common/content/world_content_service.h" -#endif volatile bool RunLoops = true; extern volatile bool is_zone_loaded; diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index aba4a8a5d..6c5cea48d 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -993,7 +993,7 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) { aa_chance = spellbonuses.ReduceTradeskillFail[spec->tradeskill] + itembonuses.ReduceTradeskillFail[spec->tradeskill] + aabonuses.ReduceTradeskillFail[spec->tradeskill]; const EQEmu::ItemData* item = nullptr; - + chance = mod_tradeskill_chance(chance, spec); if (((spec->tradeskill==75) || GetGM() || (chance > res)) || zone->random.Roll(aa_chance)) { @@ -1497,7 +1497,7 @@ void Client::LearnRecipe(uint32 recipe_id) return; } - auto tradeskill_recipe = TradeskillRecipeRepository::GetRecipe(recipe_id); + auto tradeskill_recipe = TradeskillRecipeRepository::FindOne(recipe_id); if (tradeskill_recipe.id == 0) { LogError("Invalid recipe [{}]", recipe_id); return; @@ -1542,8 +1542,8 @@ bool Client::CanIncreaseTradeskill(EQEmu::skills::SkillType tradeskill) { uint8 Tailoring = (GetRawSkill(EQEmu::skills::SkillTailoring) > 200) ? 1 : 0; uint8 SkillTotal = Baking + Smithing + Brewing + Fletching + Jewelry + Pottery + Tailoring; //Tradeskills above 200 //New Tanaan AA: Each level allows an additional tradeskill above 200 (first one is free) - uint8 aaLevel = spellbonuses.TradeSkillMastery + itembonuses.TradeSkillMastery + aabonuses.TradeSkillMastery; - + uint8 aaLevel = spellbonuses.TradeSkillMastery + itembonuses.TradeSkillMastery + aabonuses.TradeSkillMastery; + switch (tradeskill) { case EQEmu::skills::SkillBaking: case EQEmu::skills::SkillBlacksmithing: