Merge pull request #1018 from EQEmu/feature/generated-repositories

Code Generated Repositories
This commit is contained in:
Chris Miles 2020-04-06 02:24:43 -05:00 committed by GitHub
commit b23bc83f0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
340 changed files with 79005 additions and 2195 deletions

View File

@ -110,14 +110,343 @@ SET(common_sources
util/uuid.cpp) util/uuid.cpp)
SET(repositories SET(repositories
repositories/character_recipe_list_repository.h
# Criteria
repositories/criteria/content_filter_criteria.h 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_repository.h
repositories/grid_entries_repository.h repositories/grid_entries_repository.h
repositories/spawngroup_repository.h repositories/ground_spawns_repository.h
repositories/tradeskill_recipe_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/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 SET(common_headers
any.h any.h

View File

@ -20,6 +20,11 @@
#include "world_content_service.h" #include "world_content_service.h"
WorldContentService::WorldContentService()
{
SetCurrentExpansion(0);
}
int WorldContentService::GetCurrentExpansion() const int WorldContentService::GetCurrentExpansion() const
{ {
return current_expansion; return current_expansion;

View File

@ -93,6 +93,8 @@ namespace Expansion {
class WorldContentService { class WorldContentService {
public: public:
WorldContentService();
int GetCurrentExpansion() const; int GetCurrentExpansion() const;
void SetCurrentExpansion(int current_expansion); void SetCurrentExpansion(int current_expansion);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -23,371 +23,45 @@
#include "../database.h" #include "../database.h"
#include "../string_util.h" #include "../string_util.h"
#include "base/base_account_repository.h"
class AccountRepository { class AccountRepository: public BaseAccountRepository {
public: 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() /**
{ * This file was auto generated on Apr 5, 2020 and can be modified and extended upon
return std::string("id"); *
} * 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<std::string> Columns() // Custom extended repository methods here
{
return {
"id"
"name"
"charname"
"sharedplat"
"password"
"status"
"ls_id"
"lsaccount_id"
"gmspeed"
"revoked"
"karma"
"minilogin_ip"
"hideme"
"rulesflag"
"suspendeduntil"
"time_creation"
"expansion"
"ban_reason"
"suspend_reason"
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("{{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<Account> &accounts,
int account_id
)
{
for (auto &account : accounts) {
if (account.id == account_id) {
return account;
}
}
return NewEntity();
}
static Account FindOne(
int account_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
account_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
Account entry{};
entry.id = atoi(row[0]);
entry.name = row[1];
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<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + EscapeString(account_entry.name) + "'");
update_values.push_back(columns[2] + " = '" + EscapeString(account_entry.charname) + "'");
update_values.push_back(columns[3] + " = " + std::to_string(account_entry.sharedplat));
update_values.push_back(columns[4] + " = '" + EscapeString(account_entry.password) + "'");
update_values.push_back(columns[5] + " = " + std::to_string(account_entry.status));
update_values.push_back(columns[6] + " = '" + EscapeString(account_entry.ls_id) + "'");
update_values.push_back(columns[7] + " = " + std::to_string(account_entry.lsaccount_id));
update_values.push_back(columns[8] + " = " + std::to_string(account_entry.gmspeed));
update_values.push_back(columns[9] + " = " + std::to_string(account_entry.revoked));
update_values.push_back(columns[10] + " = " + std::to_string(account_entry.karma));
update_values.push_back(columns[11] + " = '" + EscapeString(account_entry.minilogin_ip) + "'");
update_values.push_back(columns[12] + " = " + std::to_string(account_entry.hideme));
update_values.push_back(columns[13] + " = " + std::to_string(account_entry.rulesflag));
update_values.push_back(columns[14] + " = '" + EscapeString(account_entry.suspendeduntil) + "'");
update_values.push_back(columns[15] + " = " + std::to_string(account_entry.time_creation));
update_values.push_back(columns[16] + " = " + std::to_string(account_entry.expansion));
update_values.push_back(columns[17] + " = '" + EscapeString(account_entry.ban_reason) + "'");
update_values.push_back(columns[18] + " = '" + EscapeString(account_entry.suspend_reason) + "'");
auto results = database.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
account_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static Account InsertOne(
Account account_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(account_entry.name) + "'");
insert_values.push_back("'" + EscapeString(account_entry.charname) + "'");
insert_values.push_back(std::to_string(account_entry.sharedplat));
insert_values.push_back("'" + EscapeString(account_entry.password) + "'");
insert_values.push_back(std::to_string(account_entry.status));
insert_values.push_back("'" + EscapeString(account_entry.ls_id) + "'");
insert_values.push_back(std::to_string(account_entry.lsaccount_id));
insert_values.push_back(std::to_string(account_entry.gmspeed));
insert_values.push_back(std::to_string(account_entry.revoked));
insert_values.push_back(std::to_string(account_entry.karma));
insert_values.push_back("'" + EscapeString(account_entry.minilogin_ip) + "'");
insert_values.push_back(std::to_string(account_entry.hideme));
insert_values.push_back(std::to_string(account_entry.rulesflag));
insert_values.push_back("'" + EscapeString(account_entry.suspendeduntil) + "'");
insert_values.push_back(std::to_string(account_entry.time_creation));
insert_values.push_back(std::to_string(account_entry.expansion));
insert_values.push_back("'" + EscapeString(account_entry.ban_reason) + "'");
insert_values.push_back("'" + EscapeString(account_entry.suspend_reason) + "'");
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
account_entry.id = results.LastInsertedID();
return account_entry;
}
account_entry = InstanceListRepository::NewEntity();
return account_entry;
}
static int InsertMany(
std::vector<Account> account_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &account_entry: account_entries) {
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(account_entry.name) + "'");
insert_values.push_back("'" + EscapeString(account_entry.charname) + "'");
insert_values.push_back(std::to_string(account_entry.sharedplat));
insert_values.push_back("'" + EscapeString(account_entry.password) + "'");
insert_values.push_back(std::to_string(account_entry.status));
insert_values.push_back("'" + EscapeString(account_entry.ls_id) + "'");
insert_values.push_back(std::to_string(account_entry.lsaccount_id));
insert_values.push_back(std::to_string(account_entry.gmspeed));
insert_values.push_back(std::to_string(account_entry.revoked));
insert_values.push_back(std::to_string(account_entry.karma));
insert_values.push_back("'" + EscapeString(account_entry.minilogin_ip) + "'");
insert_values.push_back(std::to_string(account_entry.hideme));
insert_values.push_back(std::to_string(account_entry.rulesflag));
insert_values.push_back("'" + EscapeString(account_entry.suspendeduntil) + "'");
insert_values.push_back(std::to_string(account_entry.time_creation));
insert_values.push_back(std::to_string(account_entry.expansion));
insert_values.push_back("'" + EscapeString(account_entry.ban_reason) + "'");
insert_values.push_back("'" + EscapeString(account_entry.suspend_reason) + "'");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Account> All()
{
std::vector<Account> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Account entry{};
entry.id = atoi(row[0]);
entry.name = row[1];
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;
}
}; };

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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<std::string> Columns()
{
return {
"id",
"name",
"category",
"classes",
"races",
"drakkin_heritage",
"deities",
"status",
"type",
"charges",
"grant_only",
"first_rank_id",
"enabled",
"reset_on_death",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("aa_ability");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static AaAbility NewEntity()
{
AaAbility entry{};
entry.id = 0;
entry.name = "";
entry.category = -1;
entry.classes = 131070;
entry.races = 65535;
entry.drakkin_heritage = 127;
entry.deities = 131071;
entry.status = 0;
entry.type = 0;
entry.charges = 0;
entry.grant_only = 0;
entry.first_rank_id = -1;
entry.enabled = 1;
entry.reset_on_death = 0;
return entry;
}
static AaAbility GetAaAbilityEntry(
const std::vector<AaAbility> &aa_abilitys,
int aa_ability_id
)
{
for (auto &aa_ability : aa_abilitys) {
if (aa_ability.id == aa_ability_id) {
return aa_ability;
}
}
return NewEntity();
}
static AaAbility FindOne(
int aa_ability_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
aa_ability_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
AaAbility entry{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.category = atoi(row[2]);
entry.classes = atoi(row[3]);
entry.races = atoi(row[4]);
entry.drakkin_heritage = atoi(row[5]);
entry.deities = atoi(row[6]);
entry.status = atoi(row[7]);
entry.type = atoi(row[8]);
entry.charges = atoi(row[9]);
entry.grant_only = atoi(row[10]);
entry.first_rank_id = atoi(row[11]);
entry.enabled = atoi(row[12]);
entry.reset_on_death = atoi(row[13]);
return entry;
}
return NewEntity();
}
static int DeleteOne(
int aa_ability_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
aa_ability_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
AaAbility aa_ability_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + EscapeString(aa_ability_entry.name) + "'");
update_values.push_back(columns[2] + " = " + std::to_string(aa_ability_entry.category));
update_values.push_back(columns[3] + " = " + std::to_string(aa_ability_entry.classes));
update_values.push_back(columns[4] + " = " + std::to_string(aa_ability_entry.races));
update_values.push_back(columns[5] + " = " + std::to_string(aa_ability_entry.drakkin_heritage));
update_values.push_back(columns[6] + " = " + std::to_string(aa_ability_entry.deities));
update_values.push_back(columns[7] + " = " + std::to_string(aa_ability_entry.status));
update_values.push_back(columns[8] + " = " + std::to_string(aa_ability_entry.type));
update_values.push_back(columns[9] + " = " + std::to_string(aa_ability_entry.charges));
update_values.push_back(columns[10] + " = " + std::to_string(aa_ability_entry.grant_only));
update_values.push_back(columns[11] + " = " + std::to_string(aa_ability_entry.first_rank_id));
update_values.push_back(columns[12] + " = " + std::to_string(aa_ability_entry.enabled));
update_values.push_back(columns[13] + " = " + std::to_string(aa_ability_entry.reset_on_death));
auto results = content_db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
aa_ability_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static AaAbility InsertOne(
AaAbility aa_ability_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(aa_ability_entry.name) + "'");
insert_values.push_back(std::to_string(aa_ability_entry.category));
insert_values.push_back(std::to_string(aa_ability_entry.classes));
insert_values.push_back(std::to_string(aa_ability_entry.races));
insert_values.push_back(std::to_string(aa_ability_entry.drakkin_heritage));
insert_values.push_back(std::to_string(aa_ability_entry.deities));
insert_values.push_back(std::to_string(aa_ability_entry.status));
insert_values.push_back(std::to_string(aa_ability_entry.type));
insert_values.push_back(std::to_string(aa_ability_entry.charges));
insert_values.push_back(std::to_string(aa_ability_entry.grant_only));
insert_values.push_back(std::to_string(aa_ability_entry.first_rank_id));
insert_values.push_back(std::to_string(aa_ability_entry.enabled));
insert_values.push_back(std::to_string(aa_ability_entry.reset_on_death));
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
aa_ability_entry.id = results.LastInsertedID();
return aa_ability_entry;
}
aa_ability_entry = NewEntity();
return aa_ability_entry;
}
static int InsertMany(
std::vector<AaAbility> aa_ability_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &aa_ability_entry: aa_ability_entries) {
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(aa_ability_entry.name) + "'");
insert_values.push_back(std::to_string(aa_ability_entry.category));
insert_values.push_back(std::to_string(aa_ability_entry.classes));
insert_values.push_back(std::to_string(aa_ability_entry.races));
insert_values.push_back(std::to_string(aa_ability_entry.drakkin_heritage));
insert_values.push_back(std::to_string(aa_ability_entry.deities));
insert_values.push_back(std::to_string(aa_ability_entry.status));
insert_values.push_back(std::to_string(aa_ability_entry.type));
insert_values.push_back(std::to_string(aa_ability_entry.charges));
insert_values.push_back(std::to_string(aa_ability_entry.grant_only));
insert_values.push_back(std::to_string(aa_ability_entry.first_rank_id));
insert_values.push_back(std::to_string(aa_ability_entry.enabled));
insert_values.push_back(std::to_string(aa_ability_entry.reset_on_death));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<AaAbility> All()
{
std::vector<AaAbility> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AaAbility entry{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.category = atoi(row[2]);
entry.classes = atoi(row[3]);
entry.races = atoi(row[4]);
entry.drakkin_heritage = atoi(row[5]);
entry.deities = atoi(row[6]);
entry.status = atoi(row[7]);
entry.type = atoi(row[8]);
entry.charges = atoi(row[9]);
entry.grant_only = atoi(row[10]);
entry.first_rank_id = atoi(row[11]);
entry.enabled = atoi(row[12]);
entry.reset_on_death = atoi(row[13]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<AaAbility> GetWhere(std::string where_filter)
{
std::vector<AaAbility> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AaAbility entry{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.category = atoi(row[2]);
entry.classes = atoi(row[3]);
entry.races = atoi(row[4]);
entry.drakkin_heritage = atoi(row[5]);
entry.deities = atoi(row[6]);
entry.status = atoi(row[7]);
entry.type = atoi(row[8]);
entry.charges = atoi(row[9]);
entry.grant_only = atoi(row[10]);
entry.first_rank_id = atoi(row[11]);
entry.enabled = atoi(row[12]);
entry.reset_on_death = atoi(row[13]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_AA_ABILITY_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"rank_id",
"slot",
"effect_id",
"base1",
"base2",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("aa_rank_effects");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static AaRankEffects NewEntity()
{
AaRankEffects entry{};
entry.rank_id = 0;
entry.slot = 1;
entry.effect_id = 0;
entry.base1 = 0;
entry.base2 = 0;
return entry;
}
static AaRankEffects GetAaRankEffectsEntry(
const std::vector<AaRankEffects> &aa_rank_effectss,
int aa_rank_effects_id
)
{
for (auto &aa_rank_effects : aa_rank_effectss) {
if (aa_rank_effects.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<std::string> 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<std::string> 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<AaRankEffects> aa_rank_effects_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &aa_rank_effects_entry: aa_rank_effects_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(aa_rank_effects_entry.effect_id));
insert_values.push_back(std::to_string(aa_rank_effects_entry.base1));
insert_values.push_back(std::to_string(aa_rank_effects_entry.base2));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<AaRankEffects> All()
{
std::vector<AaRankEffects> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AaRankEffects entry{};
entry.rank_id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.effect_id = atoi(row[2]);
entry.base1 = atoi(row[3]);
entry.base2 = atoi(row[4]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<AaRankEffects> GetWhere(std::string where_filter)
{
std::vector<AaRankEffects> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AaRankEffects entry{};
entry.rank_id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.effect_id = atoi(row[2]);
entry.base1 = atoi(row[3]);
entry.base2 = atoi(row[4]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_AA_RANK_EFFECTS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"rank_id",
"aa_id",
"points",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("aa_rank_prereqs");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static AaRankPrereqs NewEntity()
{
AaRankPrereqs entry{};
entry.rank_id = 0;
entry.aa_id = 0;
entry.points = 0;
return entry;
}
static AaRankPrereqs GetAaRankPrereqsEntry(
const std::vector<AaRankPrereqs> &aa_rank_prereqss,
int aa_rank_prereqs_id
)
{
for (auto &aa_rank_prereqs : aa_rank_prereqss) {
if (aa_rank_prereqs.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<std::string> 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<std::string> 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<AaRankPrereqs> aa_rank_prereqs_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &aa_rank_prereqs_entry: aa_rank_prereqs_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(aa_rank_prereqs_entry.points));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<AaRankPrereqs> All()
{
std::vector<AaRankPrereqs> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AaRankPrereqs entry{};
entry.rank_id = atoi(row[0]);
entry.aa_id = atoi(row[1]);
entry.points = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<AaRankPrereqs> GetWhere(std::string where_filter)
{
std::vector<AaRankPrereqs> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AaRankPrereqs entry{};
entry.rank_id = atoi(row[0]);
entry.aa_id = atoi(row[1]);
entry.points = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_AA_RANK_PREREQS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"upper_hotkey_sid",
"lower_hotkey_sid",
"title_sid",
"desc_sid",
"cost",
"level_req",
"spell",
"spell_type",
"recast_time",
"expansion",
"prev_id",
"next_id",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("aa_ranks");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static AaRanks NewEntity()
{
AaRanks entry{};
entry.id = 0;
entry.upper_hotkey_sid = -1;
entry.lower_hotkey_sid = -1;
entry.title_sid = -1;
entry.desc_sid = -1;
entry.cost = 1;
entry.level_req = 51;
entry.spell = -1;
entry.spell_type = 0;
entry.recast_time = 0;
entry.expansion = 0;
entry.prev_id = -1;
entry.next_id = -1;
return entry;
}
static AaRanks GetAaRanksEntry(
const std::vector<AaRanks> &aa_rankss,
int aa_ranks_id
)
{
for (auto &aa_ranks : aa_rankss) {
if (aa_ranks.id == aa_ranks_id) {
return aa_ranks;
}
}
return NewEntity();
}
static AaRanks FindOne(
int aa_ranks_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
aa_ranks_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
AaRanks entry{};
entry.id = atoi(row[0]);
entry.upper_hotkey_sid = atoi(row[1]);
entry.lower_hotkey_sid = atoi(row[2]);
entry.title_sid = atoi(row[3]);
entry.desc_sid = atoi(row[4]);
entry.cost = atoi(row[5]);
entry.level_req = atoi(row[6]);
entry.spell = atoi(row[7]);
entry.spell_type = atoi(row[8]);
entry.recast_time = atoi(row[9]);
entry.expansion = atoi(row[10]);
entry.prev_id = atoi(row[11]);
entry.next_id = atoi(row[12]);
return entry;
}
return NewEntity();
}
static int DeleteOne(
int aa_ranks_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
aa_ranks_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
AaRanks aa_ranks_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(aa_ranks_entry.upper_hotkey_sid));
update_values.push_back(columns[2] + " = " + std::to_string(aa_ranks_entry.lower_hotkey_sid));
update_values.push_back(columns[3] + " = " + std::to_string(aa_ranks_entry.title_sid));
update_values.push_back(columns[4] + " = " + std::to_string(aa_ranks_entry.desc_sid));
update_values.push_back(columns[5] + " = " + std::to_string(aa_ranks_entry.cost));
update_values.push_back(columns[6] + " = " + std::to_string(aa_ranks_entry.level_req));
update_values.push_back(columns[7] + " = " + std::to_string(aa_ranks_entry.spell));
update_values.push_back(columns[8] + " = " + std::to_string(aa_ranks_entry.spell_type));
update_values.push_back(columns[9] + " = " + std::to_string(aa_ranks_entry.recast_time));
update_values.push_back(columns[10] + " = " + std::to_string(aa_ranks_entry.expansion));
update_values.push_back(columns[11] + " = " + std::to_string(aa_ranks_entry.prev_id));
update_values.push_back(columns[12] + " = " + std::to_string(aa_ranks_entry.next_id));
auto results = content_db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
aa_ranks_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static AaRanks InsertOne(
AaRanks aa_ranks_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(aa_ranks_entry.upper_hotkey_sid));
insert_values.push_back(std::to_string(aa_ranks_entry.lower_hotkey_sid));
insert_values.push_back(std::to_string(aa_ranks_entry.title_sid));
insert_values.push_back(std::to_string(aa_ranks_entry.desc_sid));
insert_values.push_back(std::to_string(aa_ranks_entry.cost));
insert_values.push_back(std::to_string(aa_ranks_entry.level_req));
insert_values.push_back(std::to_string(aa_ranks_entry.spell));
insert_values.push_back(std::to_string(aa_ranks_entry.spell_type));
insert_values.push_back(std::to_string(aa_ranks_entry.recast_time));
insert_values.push_back(std::to_string(aa_ranks_entry.expansion));
insert_values.push_back(std::to_string(aa_ranks_entry.prev_id));
insert_values.push_back(std::to_string(aa_ranks_entry.next_id));
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
aa_ranks_entry.id = results.LastInsertedID();
return aa_ranks_entry;
}
aa_ranks_entry = NewEntity();
return aa_ranks_entry;
}
static int InsertMany(
std::vector<AaRanks> aa_ranks_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &aa_ranks_entry: aa_ranks_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(aa_ranks_entry.upper_hotkey_sid));
insert_values.push_back(std::to_string(aa_ranks_entry.lower_hotkey_sid));
insert_values.push_back(std::to_string(aa_ranks_entry.title_sid));
insert_values.push_back(std::to_string(aa_ranks_entry.desc_sid));
insert_values.push_back(std::to_string(aa_ranks_entry.cost));
insert_values.push_back(std::to_string(aa_ranks_entry.level_req));
insert_values.push_back(std::to_string(aa_ranks_entry.spell));
insert_values.push_back(std::to_string(aa_ranks_entry.spell_type));
insert_values.push_back(std::to_string(aa_ranks_entry.recast_time));
insert_values.push_back(std::to_string(aa_ranks_entry.expansion));
insert_values.push_back(std::to_string(aa_ranks_entry.prev_id));
insert_values.push_back(std::to_string(aa_ranks_entry.next_id));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<AaRanks> All()
{
std::vector<AaRanks> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AaRanks entry{};
entry.id = atoi(row[0]);
entry.upper_hotkey_sid = atoi(row[1]);
entry.lower_hotkey_sid = atoi(row[2]);
entry.title_sid = atoi(row[3]);
entry.desc_sid = atoi(row[4]);
entry.cost = atoi(row[5]);
entry.level_req = atoi(row[6]);
entry.spell = atoi(row[7]);
entry.spell_type = atoi(row[8]);
entry.recast_time = atoi(row[9]);
entry.expansion = atoi(row[10]);
entry.prev_id = atoi(row[11]);
entry.next_id = atoi(row[12]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<AaRanks> GetWhere(std::string where_filter)
{
std::vector<AaRanks> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AaRanks entry{};
entry.id = atoi(row[0]);
entry.upper_hotkey_sid = atoi(row[1]);
entry.lower_hotkey_sid = atoi(row[2]);
entry.title_sid = atoi(row[3]);
entry.desc_sid = atoi(row[4]);
entry.cost = atoi(row[5]);
entry.level_req = atoi(row[6]);
entry.spell = atoi(row[7]);
entry.spell_type = atoi(row[8]);
entry.recast_time = atoi(row[9]);
entry.expansion = atoi(row[10]);
entry.prev_id = atoi(row[11]);
entry.next_id = atoi(row[12]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_AA_RANKS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"p_accid",
"p_flag",
"p_value",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("account_flags");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static AccountFlags NewEntity()
{
AccountFlags entry{};
entry.p_accid = 0;
entry.p_flag = "";
entry.p_value = "";
return entry;
}
static AccountFlags GetAccountFlagsEntry(
const std::vector<AccountFlags> &account_flagss,
int account_flags_id
)
{
for (auto &account_flags : account_flagss) {
if (account_flags.p_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<std::string> 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<std::string> 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<AccountFlags> account_flags_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &account_flags_entry: account_flags_entries) {
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(account_flags_entry.p_value) + "'");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<AccountFlags> All()
{
std::vector<AccountFlags> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AccountFlags entry{};
entry.p_accid = atoi(row[0]);
entry.p_flag = row[1] ? row[1] : "";
entry.p_value = row[2] ? row[2] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<AccountFlags> GetWhere(std::string where_filter)
{
std::vector<AccountFlags> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AccountFlags entry{};
entry.p_accid = atoi(row[0]);
entry.p_flag = row[1] ? row[1] : "";
entry.p_value = row[2] ? row[2] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_ACCOUNT_FLAGS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"accid",
"ip",
"count",
"lastused",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("account_ip");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static AccountIp NewEntity()
{
AccountIp entry{};
entry.accid = 0;
entry.ip = "";
entry.count = 1;
entry.lastused = current_timestamp();
return entry;
}
static AccountIp GetAccountIpEntry(
const std::vector<AccountIp> &account_ips,
int account_ip_id
)
{
for (auto &account_ip : account_ips) {
if (account_ip.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<std::string> 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<std::string> 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<AccountIp> account_ip_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &account_ip_entry: account_ip_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(account_ip_entry.count));
insert_values.push_back("'" + EscapeString(account_ip_entry.lastused) + "'");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<AccountIp> All()
{
std::vector<AccountIp> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AccountIp entry{};
entry.accid = atoi(row[0]);
entry.ip = row[1] ? row[1] : "";
entry.count = atoi(row[2]);
entry.lastused = row[3] ? row[3] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<AccountIp> GetWhere(std::string where_filter)
{
std::vector<AccountIp> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AccountIp entry{};
entry.accid = atoi(row[0]);
entry.ip = row[1] ? row[1] : "";
entry.count = atoi(row[2]);
entry.lastused = row[3] ? row[3] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_ACCOUNT_IP_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"name",
"charname",
"sharedplat",
"password",
"status",
"ls_id",
"lsaccount_id",
"gmspeed",
"revoked",
"karma",
"minilogin_ip",
"hideme",
"rulesflag",
"suspendeduntil",
"time_creation",
"expansion",
"ban_reason",
"suspend_reason",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("account");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static Account NewEntity()
{
Account entry{};
entry.id = 0;
entry.name = "";
entry.charname = "";
entry.sharedplat = 0;
entry.password = "";
entry.status = 0;
entry.ls_id = "eqemu";
entry.lsaccount_id = 0;
entry.gmspeed = 0;
entry.revoked = 0;
entry.karma = 0;
entry.minilogin_ip = "";
entry.hideme = 0;
entry.rulesflag = 0;
entry.suspendeduntil = "0000-00-00 00:00:00";
entry.time_creation = 0;
entry.expansion = 0;
entry.ban_reason = "";
entry.suspend_reason = "";
return entry;
}
static Account GetAccountEntry(
const std::vector<Account> &accounts,
int account_id
)
{
for (auto &account : accounts) {
if (account.id == account_id) {
return account;
}
}
return NewEntity();
}
static Account FindOne(
int account_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
account_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
Account entry{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.charname = row[2] ? row[2] : "";
entry.sharedplat = atoi(row[3]);
entry.password = row[4] ? row[4] : "";
entry.status = atoi(row[5]);
entry.ls_id = row[6] ? row[6] : "";
entry.lsaccount_id = atoi(row[7]);
entry.gmspeed = atoi(row[8]);
entry.revoked = atoi(row[9]);
entry.karma = atoi(row[10]);
entry.minilogin_ip = row[11] ? row[11] : "";
entry.hideme = atoi(row[12]);
entry.rulesflag = atoi(row[13]);
entry.suspendeduntil = row[14] ? row[14] : "";
entry.time_creation = atoi(row[15]);
entry.expansion = atoi(row[16]);
entry.ban_reason = row[17] ? row[17] : "";
entry.suspend_reason = row[18] ? row[18] : "";
return entry;
}
return NewEntity();
}
static int DeleteOne(
int account_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
account_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Account account_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + EscapeString(account_entry.name) + "'");
update_values.push_back(columns[2] + " = '" + EscapeString(account_entry.charname) + "'");
update_values.push_back(columns[3] + " = " + std::to_string(account_entry.sharedplat));
update_values.push_back(columns[4] + " = '" + EscapeString(account_entry.password) + "'");
update_values.push_back(columns[5] + " = " + std::to_string(account_entry.status));
update_values.push_back(columns[6] + " = '" + EscapeString(account_entry.ls_id) + "'");
update_values.push_back(columns[7] + " = " + std::to_string(account_entry.lsaccount_id));
update_values.push_back(columns[8] + " = " + std::to_string(account_entry.gmspeed));
update_values.push_back(columns[9] + " = " + std::to_string(account_entry.revoked));
update_values.push_back(columns[10] + " = " + std::to_string(account_entry.karma));
update_values.push_back(columns[11] + " = '" + EscapeString(account_entry.minilogin_ip) + "'");
update_values.push_back(columns[12] + " = " + std::to_string(account_entry.hideme));
update_values.push_back(columns[13] + " = " + std::to_string(account_entry.rulesflag));
update_values.push_back(columns[14] + " = '" + EscapeString(account_entry.suspendeduntil) + "'");
update_values.push_back(columns[15] + " = " + std::to_string(account_entry.time_creation));
update_values.push_back(columns[16] + " = " + std::to_string(account_entry.expansion));
update_values.push_back(columns[17] + " = '" + EscapeString(account_entry.ban_reason) + "'");
update_values.push_back(columns[18] + " = '" + EscapeString(account_entry.suspend_reason) + "'");
auto results = database.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
account_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static Account InsertOne(
Account account_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(account_entry.name) + "'");
insert_values.push_back("'" + EscapeString(account_entry.charname) + "'");
insert_values.push_back(std::to_string(account_entry.sharedplat));
insert_values.push_back("'" + EscapeString(account_entry.password) + "'");
insert_values.push_back(std::to_string(account_entry.status));
insert_values.push_back("'" + EscapeString(account_entry.ls_id) + "'");
insert_values.push_back(std::to_string(account_entry.lsaccount_id));
insert_values.push_back(std::to_string(account_entry.gmspeed));
insert_values.push_back(std::to_string(account_entry.revoked));
insert_values.push_back(std::to_string(account_entry.karma));
insert_values.push_back("'" + EscapeString(account_entry.minilogin_ip) + "'");
insert_values.push_back(std::to_string(account_entry.hideme));
insert_values.push_back(std::to_string(account_entry.rulesflag));
insert_values.push_back("'" + EscapeString(account_entry.suspendeduntil) + "'");
insert_values.push_back(std::to_string(account_entry.time_creation));
insert_values.push_back(std::to_string(account_entry.expansion));
insert_values.push_back("'" + EscapeString(account_entry.ban_reason) + "'");
insert_values.push_back("'" + EscapeString(account_entry.suspend_reason) + "'");
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
account_entry.id = results.LastInsertedID();
return account_entry;
}
account_entry = NewEntity();
return account_entry;
}
static int InsertMany(
std::vector<Account> account_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &account_entry: account_entries) {
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(account_entry.name) + "'");
insert_values.push_back("'" + EscapeString(account_entry.charname) + "'");
insert_values.push_back(std::to_string(account_entry.sharedplat));
insert_values.push_back("'" + EscapeString(account_entry.password) + "'");
insert_values.push_back(std::to_string(account_entry.status));
insert_values.push_back("'" + EscapeString(account_entry.ls_id) + "'");
insert_values.push_back(std::to_string(account_entry.lsaccount_id));
insert_values.push_back(std::to_string(account_entry.gmspeed));
insert_values.push_back(std::to_string(account_entry.revoked));
insert_values.push_back(std::to_string(account_entry.karma));
insert_values.push_back("'" + EscapeString(account_entry.minilogin_ip) + "'");
insert_values.push_back(std::to_string(account_entry.hideme));
insert_values.push_back(std::to_string(account_entry.rulesflag));
insert_values.push_back("'" + EscapeString(account_entry.suspendeduntil) + "'");
insert_values.push_back(std::to_string(account_entry.time_creation));
insert_values.push_back(std::to_string(account_entry.expansion));
insert_values.push_back("'" + EscapeString(account_entry.ban_reason) + "'");
insert_values.push_back("'" + EscapeString(account_entry.suspend_reason) + "'");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Account> All()
{
std::vector<Account> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Account entry{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.charname = row[2] ? row[2] : "";
entry.sharedplat = atoi(row[3]);
entry.password = row[4] ? row[4] : "";
entry.status = atoi(row[5]);
entry.ls_id = row[6] ? row[6] : "";
entry.lsaccount_id = atoi(row[7]);
entry.gmspeed = atoi(row[8]);
entry.revoked = atoi(row[9]);
entry.karma = atoi(row[10]);
entry.minilogin_ip = row[11] ? row[11] : "";
entry.hideme = atoi(row[12]);
entry.rulesflag = atoi(row[13]);
entry.suspendeduntil = row[14] ? row[14] : "";
entry.time_creation = atoi(row[15]);
entry.expansion = atoi(row[16]);
entry.ban_reason = row[17] ? row[17] : "";
entry.suspend_reason = row[18] ? row[18] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<Account> GetWhere(std::string where_filter)
{
std::vector<Account> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Account entry{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.charname = row[2] ? row[2] : "";
entry.sharedplat = atoi(row[3]);
entry.password = row[4] ? row[4] : "";
entry.status = atoi(row[5]);
entry.ls_id = row[6] ? row[6] : "";
entry.lsaccount_id = atoi(row[7]);
entry.gmspeed = atoi(row[8]);
entry.revoked = atoi(row[9]);
entry.karma = atoi(row[10]);
entry.minilogin_ip = row[11] ? row[11] : "";
entry.hideme = atoi(row[12]);
entry.rulesflag = atoi(row[13]);
entry.suspendeduntil = row[14] ? row[14] : "";
entry.time_creation = atoi(row[15]);
entry.expansion = atoi(row[16]);
entry.ban_reason = row[17] ? row[17] : "";
entry.suspend_reason = row[18] ? row[18] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_ACCOUNT_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"account_id",
"reward_id",
"amount",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("account_rewards");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static AccountRewards NewEntity()
{
AccountRewards entry{};
entry.account_id = 0;
entry.reward_id = 0;
entry.amount = 0;
return entry;
}
static AccountRewards GetAccountRewardsEntry(
const std::vector<AccountRewards> &account_rewardss,
int account_rewards_id
)
{
for (auto &account_rewards : account_rewardss) {
if (account_rewards.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<std::string> 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<std::string> 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<AccountRewards> account_rewards_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &account_rewards_entry: account_rewards_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(account_rewards_entry.amount));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<AccountRewards> All()
{
std::vector<AccountRewards> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AccountRewards entry{};
entry.account_id = atoi(row[0]);
entry.reward_id = atoi(row[1]);
entry.amount = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<AccountRewards> GetWhere(std::string where_filter)
{
std::vector<AccountRewards> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AccountRewards entry{};
entry.account_id = atoi(row[0]);
entry.reward_id = atoi(row[1]);
entry.amount = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_ACCOUNT_REWARDS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"adventure_id",
"instance_id",
"count",
"assassinate_count",
"status",
"time_created",
"time_zoned",
"time_completed",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("adventure_details");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static AdventureDetails NewEntity()
{
AdventureDetails entry{};
entry.id = 0;
entry.adventure_id = 0;
entry.instance_id = -1;
entry.count = 0;
entry.assassinate_count = 0;
entry.status = 0;
entry.time_created = 0;
entry.time_zoned = 0;
entry.time_completed = 0;
return entry;
}
static AdventureDetails GetAdventureDetailsEntry(
const std::vector<AdventureDetails> &adventure_detailss,
int adventure_details_id
)
{
for (auto &adventure_details : adventure_detailss) {
if (adventure_details.id == adventure_details_id) {
return adventure_details;
}
}
return NewEntity();
}
static AdventureDetails FindOne(
int adventure_details_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
adventure_details_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
AdventureDetails entry{};
entry.id = atoi(row[0]);
entry.adventure_id = atoi(row[1]);
entry.instance_id = atoi(row[2]);
entry.count = atoi(row[3]);
entry.assassinate_count = atoi(row[4]);
entry.status = atoi(row[5]);
entry.time_created = atoi(row[6]);
entry.time_zoned = atoi(row[7]);
entry.time_completed = atoi(row[8]);
return entry;
}
return NewEntity();
}
static int DeleteOne(
int adventure_details_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
adventure_details_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
AdventureDetails adventure_details_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(adventure_details_entry.adventure_id));
update_values.push_back(columns[2] + " = " + std::to_string(adventure_details_entry.instance_id));
update_values.push_back(columns[3] + " = " + std::to_string(adventure_details_entry.count));
update_values.push_back(columns[4] + " = " + std::to_string(adventure_details_entry.assassinate_count));
update_values.push_back(columns[5] + " = " + std::to_string(adventure_details_entry.status));
update_values.push_back(columns[6] + " = " + std::to_string(adventure_details_entry.time_created));
update_values.push_back(columns[7] + " = " + std::to_string(adventure_details_entry.time_zoned));
update_values.push_back(columns[8] + " = " + std::to_string(adventure_details_entry.time_completed));
auto results = database.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
adventure_details_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static AdventureDetails InsertOne(
AdventureDetails adventure_details_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(adventure_details_entry.adventure_id));
insert_values.push_back(std::to_string(adventure_details_entry.instance_id));
insert_values.push_back(std::to_string(adventure_details_entry.count));
insert_values.push_back(std::to_string(adventure_details_entry.assassinate_count));
insert_values.push_back(std::to_string(adventure_details_entry.status));
insert_values.push_back(std::to_string(adventure_details_entry.time_created));
insert_values.push_back(std::to_string(adventure_details_entry.time_zoned));
insert_values.push_back(std::to_string(adventure_details_entry.time_completed));
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
adventure_details_entry.id = results.LastInsertedID();
return adventure_details_entry;
}
adventure_details_entry = NewEntity();
return adventure_details_entry;
}
static int InsertMany(
std::vector<AdventureDetails> adventure_details_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &adventure_details_entry: adventure_details_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(adventure_details_entry.adventure_id));
insert_values.push_back(std::to_string(adventure_details_entry.instance_id));
insert_values.push_back(std::to_string(adventure_details_entry.count));
insert_values.push_back(std::to_string(adventure_details_entry.assassinate_count));
insert_values.push_back(std::to_string(adventure_details_entry.status));
insert_values.push_back(std::to_string(adventure_details_entry.time_created));
insert_values.push_back(std::to_string(adventure_details_entry.time_zoned));
insert_values.push_back(std::to_string(adventure_details_entry.time_completed));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<AdventureDetails> All()
{
std::vector<AdventureDetails> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureDetails entry{};
entry.id = atoi(row[0]);
entry.adventure_id = atoi(row[1]);
entry.instance_id = atoi(row[2]);
entry.count = atoi(row[3]);
entry.assassinate_count = atoi(row[4]);
entry.status = atoi(row[5]);
entry.time_created = atoi(row[6]);
entry.time_zoned = atoi(row[7]);
entry.time_completed = atoi(row[8]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<AdventureDetails> GetWhere(std::string where_filter)
{
std::vector<AdventureDetails> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureDetails entry{};
entry.id = atoi(row[0]);
entry.adventure_id = atoi(row[1]);
entry.instance_id = atoi(row[2]);
entry.count = atoi(row[3]);
entry.assassinate_count = atoi(row[4]);
entry.status = atoi(row[5]);
entry.time_created = atoi(row[6]);
entry.time_zoned = atoi(row[7]);
entry.time_completed = atoi(row[8]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_ADVENTURE_DETAILS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"charid",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("adventure_members");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static AdventureMembers NewEntity()
{
AdventureMembers entry{};
entry.id = 0;
entry.charid = 0;
return entry;
}
static AdventureMembers GetAdventureMembersEntry(
const std::vector<AdventureMembers> &adventure_memberss,
int adventure_members_id
)
{
for (auto &adventure_members : adventure_memberss) {
if (adventure_members.charid == adventure_members_id) {
return adventure_members;
}
}
return NewEntity();
}
static AdventureMembers FindOne(
int adventure_members_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
adventure_members_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
AdventureMembers entry{};
entry.id = atoi(row[0]);
entry.charid = atoi(row[1]);
return entry;
}
return NewEntity();
}
static int DeleteOne(
int adventure_members_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
adventure_members_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
AdventureMembers adventure_members_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(adventure_members_entry.id));
auto results = database.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
adventure_members_entry.charid
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static AdventureMembers InsertOne(
AdventureMembers adventure_members_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(adventure_members_entry.id));
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<AdventureMembers> adventure_members_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &adventure_members_entry: adventure_members_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(adventure_members_entry.id));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<AdventureMembers> All()
{
std::vector<AdventureMembers> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureMembers entry{};
entry.id = atoi(row[0]);
entry.charid = atoi(row[1]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<AdventureMembers> GetWhere(std::string where_filter)
{
std::vector<AdventureMembers> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureMembers entry{};
entry.id = atoi(row[0]);
entry.charid = atoi(row[1]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_ADVENTURE_MEMBERS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"player_id",
"guk_wins",
"mir_wins",
"mmc_wins",
"ruj_wins",
"tak_wins",
"guk_losses",
"mir_losses",
"mmc_losses",
"ruj_losses",
"tak_losses",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("adventure_stats");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static AdventureStats NewEntity()
{
AdventureStats entry{};
entry.player_id = 0;
entry.guk_wins = 0;
entry.mir_wins = 0;
entry.mmc_wins = 0;
entry.ruj_wins = 0;
entry.tak_wins = 0;
entry.guk_losses = 0;
entry.mir_losses = 0;
entry.mmc_losses = 0;
entry.ruj_losses = 0;
entry.tak_losses = 0;
return entry;
}
static AdventureStats GetAdventureStatsEntry(
const std::vector<AdventureStats> &adventure_statss,
int adventure_stats_id
)
{
for (auto &adventure_stats : adventure_statss) {
if (adventure_stats.player_id == adventure_stats_id) {
return adventure_stats;
}
}
return NewEntity();
}
static AdventureStats FindOne(
int adventure_stats_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
adventure_stats_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
AdventureStats entry{};
entry.player_id = atoi(row[0]);
entry.guk_wins = atoi(row[1]);
entry.mir_wins = atoi(row[2]);
entry.mmc_wins = atoi(row[3]);
entry.ruj_wins = atoi(row[4]);
entry.tak_wins = atoi(row[5]);
entry.guk_losses = atoi(row[6]);
entry.mir_losses = atoi(row[7]);
entry.mmc_losses = atoi(row[8]);
entry.ruj_losses = atoi(row[9]);
entry.tak_losses = atoi(row[10]);
return entry;
}
return NewEntity();
}
static int DeleteOne(
int adventure_stats_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
adventure_stats_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
AdventureStats adventure_stats_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(adventure_stats_entry.guk_wins));
update_values.push_back(columns[2] + " = " + std::to_string(adventure_stats_entry.mir_wins));
update_values.push_back(columns[3] + " = " + std::to_string(adventure_stats_entry.mmc_wins));
update_values.push_back(columns[4] + " = " + std::to_string(adventure_stats_entry.ruj_wins));
update_values.push_back(columns[5] + " = " + std::to_string(adventure_stats_entry.tak_wins));
update_values.push_back(columns[6] + " = " + std::to_string(adventure_stats_entry.guk_losses));
update_values.push_back(columns[7] + " = " + std::to_string(adventure_stats_entry.mir_losses));
update_values.push_back(columns[8] + " = " + std::to_string(adventure_stats_entry.mmc_losses));
update_values.push_back(columns[9] + " = " + std::to_string(adventure_stats_entry.ruj_losses));
update_values.push_back(columns[10] + " = " + std::to_string(adventure_stats_entry.tak_losses));
auto results = database.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
adventure_stats_entry.player_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static AdventureStats InsertOne(
AdventureStats adventure_stats_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(adventure_stats_entry.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<AdventureStats> adventure_stats_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &adventure_stats_entry: adventure_stats_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(adventure_stats_entry.guk_wins));
insert_values.push_back(std::to_string(adventure_stats_entry.mir_wins));
insert_values.push_back(std::to_string(adventure_stats_entry.mmc_wins));
insert_values.push_back(std::to_string(adventure_stats_entry.ruj_wins));
insert_values.push_back(std::to_string(adventure_stats_entry.tak_wins));
insert_values.push_back(std::to_string(adventure_stats_entry.guk_losses));
insert_values.push_back(std::to_string(adventure_stats_entry.mir_losses));
insert_values.push_back(std::to_string(adventure_stats_entry.mmc_losses));
insert_values.push_back(std::to_string(adventure_stats_entry.ruj_losses));
insert_values.push_back(std::to_string(adventure_stats_entry.tak_losses));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<AdventureStats> All()
{
std::vector<AdventureStats> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureStats entry{};
entry.player_id = atoi(row[0]);
entry.guk_wins = atoi(row[1]);
entry.mir_wins = atoi(row[2]);
entry.mmc_wins = atoi(row[3]);
entry.ruj_wins = atoi(row[4]);
entry.tak_wins = atoi(row[5]);
entry.guk_losses = atoi(row[6]);
entry.mir_losses = atoi(row[7]);
entry.mmc_losses = atoi(row[8]);
entry.ruj_losses = atoi(row[9]);
entry.tak_losses = atoi(row[10]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<AdventureStats> GetWhere(std::string where_filter)
{
std::vector<AdventureStats> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureStats entry{};
entry.player_id = atoi(row[0]);
entry.guk_wins = atoi(row[1]);
entry.mir_wins = atoi(row[2]);
entry.mmc_wins = atoi(row[3]);
entry.ruj_wins = atoi(row[4]);
entry.tak_wins = atoi(row[5]);
entry.guk_losses = atoi(row[6]);
entry.mir_losses = atoi(row[7]);
entry.mmc_losses = atoi(row[8]);
entry.ruj_losses = atoi(row[9]);
entry.tak_losses = atoi(row[10]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_ADVENTURE_STATS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"text",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("adventure_template_entry_flavor");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static AdventureTemplateEntryFlavor NewEntity()
{
AdventureTemplateEntryFlavor entry{};
entry.id = 0;
entry.text = "";
return entry;
}
static AdventureTemplateEntryFlavor GetAdventureTemplateEntryFlavorEntry(
const std::vector<AdventureTemplateEntryFlavor> &adventure_template_entry_flavors,
int adventure_template_entry_flavor_id
)
{
for (auto &adventure_template_entry_flavor : adventure_template_entry_flavors) {
if (adventure_template_entry_flavor.id == adventure_template_entry_flavor_id) {
return adventure_template_entry_flavor;
}
}
return NewEntity();
}
static AdventureTemplateEntryFlavor FindOne(
int adventure_template_entry_flavor_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
adventure_template_entry_flavor_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
AdventureTemplateEntryFlavor entry{};
entry.id = atoi(row[0]);
entry.text = row[1] ? row[1] : "";
return entry;
}
return NewEntity();
}
static int DeleteOne(
int adventure_template_entry_flavor_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
adventure_template_entry_flavor_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
AdventureTemplateEntryFlavor adventure_template_entry_flavor_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + EscapeString(adventure_template_entry_flavor_entry.text) + "'");
auto results = content_db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
adventure_template_entry_flavor_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static AdventureTemplateEntryFlavor InsertOne(
AdventureTemplateEntryFlavor adventure_template_entry_flavor_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(adventure_template_entry_flavor_entry.text) + "'");
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
adventure_template_entry_flavor_entry.id = results.LastInsertedID();
return adventure_template_entry_flavor_entry;
}
adventure_template_entry_flavor_entry = NewEntity();
return adventure_template_entry_flavor_entry;
}
static int InsertMany(
std::vector<AdventureTemplateEntryFlavor> adventure_template_entry_flavor_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &adventure_template_entry_flavor_entry: adventure_template_entry_flavor_entries) {
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(adventure_template_entry_flavor_entry.text) + "'");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<AdventureTemplateEntryFlavor> All()
{
std::vector<AdventureTemplateEntryFlavor> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureTemplateEntryFlavor entry{};
entry.id = atoi(row[0]);
entry.text = row[1] ? row[1] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<AdventureTemplateEntryFlavor> GetWhere(std::string where_filter)
{
std::vector<AdventureTemplateEntryFlavor> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureTemplateEntryFlavor entry{};
entry.id = atoi(row[0]);
entry.text = row[1] ? row[1] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_ADVENTURE_TEMPLATE_ENTRY_FLAVOR_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"template_id",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("adventure_template_entry");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static AdventureTemplateEntry NewEntity()
{
AdventureTemplateEntry entry{};
entry.id = 0;
entry.template_id = 0;
return entry;
}
static AdventureTemplateEntry GetAdventureTemplateEntryEntry(
const std::vector<AdventureTemplateEntry> &adventure_template_entrys,
int adventure_template_entry_id
)
{
for (auto &adventure_template_entry : adventure_template_entrys) {
if (adventure_template_entry.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<std::string> 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<std::string> 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<AdventureTemplateEntry> adventure_template_entry_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &adventure_template_entry_entry: adventure_template_entry_entries) {
std::vector<std::string> insert_values;
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<AdventureTemplateEntry> All()
{
std::vector<AdventureTemplateEntry> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureTemplateEntry entry{};
entry.id = atoi(row[0]);
entry.template_id = atoi(row[1]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<AdventureTemplateEntry> GetWhere(std::string where_filter)
{
std::vector<AdventureTemplateEntry> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureTemplateEntry entry{};
entry.id = atoi(row[0]);
entry.template_id = atoi(row[1]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_ADVENTURE_TEMPLATE_ENTRY_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"zone",
"zone_version",
"is_hard",
"is_raid",
"min_level",
"max_level",
"type",
"type_data",
"type_count",
"assa_x",
"assa_y",
"assa_z",
"assa_h",
"text",
"duration",
"zone_in_time",
"win_points",
"lose_points",
"theme",
"zone_in_zone_id",
"zone_in_x",
"zone_in_y",
"zone_in_object_id",
"dest_x",
"dest_y",
"dest_z",
"dest_h",
"graveyard_zone_id",
"graveyard_x",
"graveyard_y",
"graveyard_z",
"graveyard_radius",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("adventure_template");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static AdventureTemplate NewEntity()
{
AdventureTemplate entry{};
entry.id = 0;
entry.zone = "";
entry.zone_version = 0;
entry.is_hard = 0;
entry.is_raid = 0;
entry.min_level = 1;
entry.max_level = 65;
entry.type = 0;
entry.type_data = 0;
entry.type_count = 0;
entry.assa_x = 0;
entry.assa_y = 0;
entry.assa_z = 0;
entry.assa_h = 0;
entry.text = "";
entry.duration = 7200;
entry.zone_in_time = 1800;
entry.win_points = 0;
entry.lose_points = 0;
entry.theme = 1;
entry.zone_in_zone_id = 0;
entry.zone_in_x = 0;
entry.zone_in_y = 0;
entry.zone_in_object_id = 0;
entry.dest_x = 0;
entry.dest_y = 0;
entry.dest_z = 0;
entry.dest_h = 0;
entry.graveyard_zone_id = 0;
entry.graveyard_x = 0;
entry.graveyard_y = 0;
entry.graveyard_z = 0;
entry.graveyard_radius = 0;
return entry;
}
static AdventureTemplate GetAdventureTemplateEntry(
const std::vector<AdventureTemplate> &adventure_templates,
int adventure_template_id
)
{
for (auto &adventure_template : adventure_templates) {
if (adventure_template.id == adventure_template_id) {
return adventure_template;
}
}
return NewEntity();
}
static AdventureTemplate FindOne(
int adventure_template_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
adventure_template_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
AdventureTemplate entry{};
entry.id = atoi(row[0]);
entry.zone = row[1] ? row[1] : "";
entry.zone_version = atoi(row[2]);
entry.is_hard = atoi(row[3]);
entry.is_raid = atoi(row[4]);
entry.min_level = atoi(row[5]);
entry.max_level = atoi(row[6]);
entry.type = atoi(row[7]);
entry.type_data = atoi(row[8]);
entry.type_count = atoi(row[9]);
entry.assa_x = 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<std::string> 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<std::string> 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<AdventureTemplate> adventure_template_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &adventure_template_entry: adventure_template_entries) {
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(adventure_template_entry.zone) + "'");
insert_values.push_back(std::to_string(adventure_template_entry.zone_version));
insert_values.push_back(std::to_string(adventure_template_entry.is_hard));
insert_values.push_back(std::to_string(adventure_template_entry.is_raid));
insert_values.push_back(std::to_string(adventure_template_entry.min_level));
insert_values.push_back(std::to_string(adventure_template_entry.max_level));
insert_values.push_back(std::to_string(adventure_template_entry.type));
insert_values.push_back(std::to_string(adventure_template_entry.type_data));
insert_values.push_back(std::to_string(adventure_template_entry.type_count));
insert_values.push_back(std::to_string(adventure_template_entry.assa_x));
insert_values.push_back(std::to_string(adventure_template_entry.assa_y));
insert_values.push_back(std::to_string(adventure_template_entry.assa_z));
insert_values.push_back(std::to_string(adventure_template_entry.assa_h));
insert_values.push_back("'" + EscapeString(adventure_template_entry.text) + "'");
insert_values.push_back(std::to_string(adventure_template_entry.duration));
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_time));
insert_values.push_back(std::to_string(adventure_template_entry.win_points));
insert_values.push_back(std::to_string(adventure_template_entry.lose_points));
insert_values.push_back(std::to_string(adventure_template_entry.theme));
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_zone_id));
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_x));
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_y));
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_object_id));
insert_values.push_back(std::to_string(adventure_template_entry.dest_x));
insert_values.push_back(std::to_string(adventure_template_entry.dest_y));
insert_values.push_back(std::to_string(adventure_template_entry.dest_z));
insert_values.push_back(std::to_string(adventure_template_entry.dest_h));
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_zone_id));
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_x));
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_y));
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_z));
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_radius));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<AdventureTemplate> All()
{
std::vector<AdventureTemplate> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureTemplate entry{};
entry.id = atoi(row[0]);
entry.zone = row[1] ? row[1] : "";
entry.zone_version = atoi(row[2]);
entry.is_hard = atoi(row[3]);
entry.is_raid = atoi(row[4]);
entry.min_level = atoi(row[5]);
entry.max_level = atoi(row[6]);
entry.type = atoi(row[7]);
entry.type_data = atoi(row[8]);
entry.type_count = atoi(row[9]);
entry.assa_x = 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<AdventureTemplate> GetWhere(std::string where_filter)
{
std::vector<AdventureTemplate> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureTemplate entry{};
entry.id = atoi(row[0]);
entry.zone = row[1] ? row[1] : "";
entry.zone_version = atoi(row[2]);
entry.is_hard = atoi(row[3]);
entry.is_raid = atoi(row[4]);
entry.min_level = atoi(row[5]);
entry.max_level = atoi(row[6]);
entry.type = atoi(row[7]);
entry.type_data = atoi(row[8]);
entry.type_count = atoi(row[9]);
entry.assa_x = 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

View File

@ -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<std::string> Columns()
{
return {
"id",
"item_id",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("alternate_currency");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static AlternateCurrency NewEntity()
{
AlternateCurrency entry{};
entry.id = 0;
entry.item_id = 0;
return entry;
}
static AlternateCurrency GetAlternateCurrencyEntry(
const std::vector<AlternateCurrency> &alternate_currencys,
int alternate_currency_id
)
{
for (auto &alternate_currency : alternate_currencys) {
if (alternate_currency.id == alternate_currency_id) {
return alternate_currency;
}
}
return NewEntity();
}
static AlternateCurrency FindOne(
int alternate_currency_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
alternate_currency_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
AlternateCurrency entry{};
entry.id = atoi(row[0]);
entry.item_id = atoi(row[1]);
return entry;
}
return NewEntity();
}
static int DeleteOne(
int alternate_currency_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
alternate_currency_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
AlternateCurrency alternate_currency_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(alternate_currency_entry.item_id));
auto results = content_db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
alternate_currency_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static AlternateCurrency InsertOne(
AlternateCurrency alternate_currency_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(alternate_currency_entry.item_id));
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
alternate_currency_entry.id = results.LastInsertedID();
return alternate_currency_entry;
}
alternate_currency_entry = NewEntity();
return alternate_currency_entry;
}
static int InsertMany(
std::vector<AlternateCurrency> alternate_currency_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &alternate_currency_entry: alternate_currency_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(alternate_currency_entry.item_id));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<AlternateCurrency> All()
{
std::vector<AlternateCurrency> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AlternateCurrency entry{};
entry.id = atoi(row[0]);
entry.item_id = atoi(row[1]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<AlternateCurrency> GetWhere(std::string where_filter)
{
std::vector<AlternateCurrency> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AlternateCurrency entry{};
entry.id = atoi(row[0]);
entry.item_id = atoi(row[1]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_ALTERNATE_CURRENCY_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"type",
"npc_type",
"name",
"spell_id",
"distance",
"aura_type",
"spawn_type",
"movement",
"duration",
"icon",
"cast_time",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("auras");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static Auras NewEntity()
{
Auras entry{};
entry.type = 0;
entry.npc_type = 0;
entry.name = "";
entry.spell_id = 0;
entry.distance = 60;
entry.aura_type = 1;
entry.spawn_type = 0;
entry.movement = 0;
entry.duration = 5400;
entry.icon = -1;
entry.cast_time = 0;
return entry;
}
static Auras GetAurasEntry(
const std::vector<Auras> &aurass,
int auras_id
)
{
for (auto &auras : aurass) {
if (auras.type == auras_id) {
return auras;
}
}
return NewEntity();
}
static Auras FindOne(
int auras_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
auras_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
Auras entry{};
entry.type = atoi(row[0]);
entry.npc_type = atoi(row[1]);
entry.name = row[2] ? row[2] : "";
entry.spell_id = atoi(row[3]);
entry.distance = atoi(row[4]);
entry.aura_type = atoi(row[5]);
entry.spawn_type = atoi(row[6]);
entry.movement = atoi(row[7]);
entry.duration = atoi(row[8]);
entry.icon = atoi(row[9]);
entry.cast_time = atoi(row[10]);
return entry;
}
return NewEntity();
}
static int DeleteOne(
int auras_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
auras_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Auras auras_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(auras_entry.npc_type));
update_values.push_back(columns[2] + " = '" + EscapeString(auras_entry.name) + "'");
update_values.push_back(columns[3] + " = " + std::to_string(auras_entry.spell_id));
update_values.push_back(columns[4] + " = " + std::to_string(auras_entry.distance));
update_values.push_back(columns[5] + " = " + std::to_string(auras_entry.aura_type));
update_values.push_back(columns[6] + " = " + std::to_string(auras_entry.spawn_type));
update_values.push_back(columns[7] + " = " + std::to_string(auras_entry.movement));
update_values.push_back(columns[8] + " = " + std::to_string(auras_entry.duration));
update_values.push_back(columns[9] + " = " + std::to_string(auras_entry.icon));
update_values.push_back(columns[10] + " = " + std::to_string(auras_entry.cast_time));
auto results = content_db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
auras_entry.type
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static Auras InsertOne(
Auras auras_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(auras_entry.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> auras_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &auras_entry: auras_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(auras_entry.npc_type));
insert_values.push_back("'" + EscapeString(auras_entry.name) + "'");
insert_values.push_back(std::to_string(auras_entry.spell_id));
insert_values.push_back(std::to_string(auras_entry.distance));
insert_values.push_back(std::to_string(auras_entry.aura_type));
insert_values.push_back(std::to_string(auras_entry.spawn_type));
insert_values.push_back(std::to_string(auras_entry.movement));
insert_values.push_back(std::to_string(auras_entry.duration));
insert_values.push_back(std::to_string(auras_entry.icon));
insert_values.push_back(std::to_string(auras_entry.cast_time));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Auras> All()
{
std::vector<Auras> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Auras entry{};
entry.type = atoi(row[0]);
entry.npc_type = atoi(row[1]);
entry.name = row[2] ? row[2] : "";
entry.spell_id = atoi(row[3]);
entry.distance = atoi(row[4]);
entry.aura_type = atoi(row[5]);
entry.spawn_type = atoi(row[6]);
entry.movement = atoi(row[7]);
entry.duration = atoi(row[8]);
entry.icon = atoi(row[9]);
entry.cast_time = atoi(row[10]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<Auras> GetWhere(std::string where_filter)
{
std::vector<Auras> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Auras entry{};
entry.type = atoi(row[0]);
entry.npc_type = atoi(row[1]);
entry.name = row[2] ? row[2] : "";
entry.spell_id = atoi(row[3]);
entry.distance = atoi(row[4]);
entry.aura_type = atoi(row[5]);
entry.spawn_type = atoi(row[6]);
entry.movement = atoi(row[7]);
entry.duration = atoi(row[8]);
entry.icon = atoi(row[9]);
entry.cast_time = atoi(row[10]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_AURAS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"ip_address",
"notes",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("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<BannedIps> &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<std::string> 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<std::string> 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<BannedIps> banned_ips_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &banned_ips_entry: banned_ips_entries) {
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(banned_ips_entry.notes) + "'");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<BannedIps> All()
{
std::vector<BannedIps> 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<BannedIps> GetWhere(std::string where_filter)
{
std::vector<BannedIps> 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

View File

@ -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<std::string> Columns()
{
return {
"level",
"class",
"hp",
"mana",
"end",
"unk1",
"unk2",
"hp_fac",
"mana_fac",
"end_fac",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("base_data");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static BaseData NewEntity()
{
BaseData entry{};
entry.level = 0;
entry.class = 0;
entry.hp = 0;
entry.mana = 0;
entry.end = 0;
entry.unk1 = 0;
entry.unk2 = 0;
entry.hp_fac = 0;
entry.mana_fac = 0;
entry.end_fac = 0;
return entry;
}
static BaseData GetBaseDataEntry(
const std::vector<BaseData> &base_datas,
int base_data_id
)
{
for (auto &base_data : base_datas) {
if (base_data.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<std::string> 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<std::string> 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<BaseData> base_data_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &base_data_entry: base_data_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(base_data_entry.hp));
insert_values.push_back(std::to_string(base_data_entry.mana));
insert_values.push_back(std::to_string(base_data_entry.end));
insert_values.push_back(std::to_string(base_data_entry.unk1));
insert_values.push_back(std::to_string(base_data_entry.unk2));
insert_values.push_back(std::to_string(base_data_entry.hp_fac));
insert_values.push_back(std::to_string(base_data_entry.mana_fac));
insert_values.push_back(std::to_string(base_data_entry.end_fac));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<BaseData> All()
{
std::vector<BaseData> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
BaseData entry{};
entry.level = atoi(row[0]);
entry.class = atoi(row[1]);
entry.hp = 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<BaseData> GetWhere(std::string where_filter)
{
std::vector<BaseData> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
BaseData entry{};
entry.level = atoi(row[0]);
entry.class = atoi(row[1]);
entry.hp = 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

View File

@ -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<std::string> Columns()
{
return {
"id",
"spellid",
"type",
"zoneid",
"x",
"y",
"z",
"x_diff",
"y_diff",
"z_diff",
"message",
"description",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("blocked_spells");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static BlockedSpells NewEntity()
{
BlockedSpells entry{};
entry.id = 0;
entry.spellid = 0;
entry.type = 0;
entry.zoneid = 0;
entry.x = 0;
entry.y = 0;
entry.z = 0;
entry.x_diff = 0;
entry.y_diff = 0;
entry.z_diff = 0;
entry.message = "";
entry.description = "";
return entry;
}
static BlockedSpells GetBlockedSpellsEntry(
const std::vector<BlockedSpells> &blocked_spellss,
int blocked_spells_id
)
{
for (auto &blocked_spells : blocked_spellss) {
if (blocked_spells.id == blocked_spells_id) {
return blocked_spells;
}
}
return NewEntity();
}
static BlockedSpells FindOne(
int blocked_spells_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
blocked_spells_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
BlockedSpells entry{};
entry.id = atoi(row[0]);
entry.spellid = atoi(row[1]);
entry.type = atoi(row[2]);
entry.zoneid = atoi(row[3]);
entry.x = 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<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(blocked_spells_entry.spellid));
update_values.push_back(columns[2] + " = " + std::to_string(blocked_spells_entry.type));
update_values.push_back(columns[3] + " = " + std::to_string(blocked_spells_entry.zoneid));
update_values.push_back(columns[4] + " = " + std::to_string(blocked_spells_entry.x));
update_values.push_back(columns[5] + " = " + std::to_string(blocked_spells_entry.y));
update_values.push_back(columns[6] + " = " + std::to_string(blocked_spells_entry.z));
update_values.push_back(columns[7] + " = " + std::to_string(blocked_spells_entry.x_diff));
update_values.push_back(columns[8] + " = " + std::to_string(blocked_spells_entry.y_diff));
update_values.push_back(columns[9] + " = " + std::to_string(blocked_spells_entry.z_diff));
update_values.push_back(columns[10] + " = '" + EscapeString(blocked_spells_entry.message) + "'");
update_values.push_back(columns[11] + " = '" + EscapeString(blocked_spells_entry.description) + "'");
auto results = content_db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
blocked_spells_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static BlockedSpells InsertOne(
BlockedSpells blocked_spells_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(blocked_spells_entry.spellid));
insert_values.push_back(std::to_string(blocked_spells_entry.type));
insert_values.push_back(std::to_string(blocked_spells_entry.zoneid));
insert_values.push_back(std::to_string(blocked_spells_entry.x));
insert_values.push_back(std::to_string(blocked_spells_entry.y));
insert_values.push_back(std::to_string(blocked_spells_entry.z));
insert_values.push_back(std::to_string(blocked_spells_entry.x_diff));
insert_values.push_back(std::to_string(blocked_spells_entry.y_diff));
insert_values.push_back(std::to_string(blocked_spells_entry.z_diff));
insert_values.push_back("'" + EscapeString(blocked_spells_entry.message) + "'");
insert_values.push_back("'" + EscapeString(blocked_spells_entry.description) + "'");
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
blocked_spells_entry.id = results.LastInsertedID();
return blocked_spells_entry;
}
blocked_spells_entry = NewEntity();
return blocked_spells_entry;
}
static int InsertMany(
std::vector<BlockedSpells> blocked_spells_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &blocked_spells_entry: blocked_spells_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(blocked_spells_entry.spellid));
insert_values.push_back(std::to_string(blocked_spells_entry.type));
insert_values.push_back(std::to_string(blocked_spells_entry.zoneid));
insert_values.push_back(std::to_string(blocked_spells_entry.x));
insert_values.push_back(std::to_string(blocked_spells_entry.y));
insert_values.push_back(std::to_string(blocked_spells_entry.z));
insert_values.push_back(std::to_string(blocked_spells_entry.x_diff));
insert_values.push_back(std::to_string(blocked_spells_entry.y_diff));
insert_values.push_back(std::to_string(blocked_spells_entry.z_diff));
insert_values.push_back("'" + EscapeString(blocked_spells_entry.message) + "'");
insert_values.push_back("'" + EscapeString(blocked_spells_entry.description) + "'");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<BlockedSpells> All()
{
std::vector<BlockedSpells> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
BlockedSpells entry{};
entry.id = atoi(row[0]);
entry.spellid = atoi(row[1]);
entry.type = atoi(row[2]);
entry.zoneid = atoi(row[3]);
entry.x = 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<BlockedSpells> GetWhere(std::string where_filter)
{
std::vector<BlockedSpells> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
BlockedSpells entry{};
entry.id = atoi(row[0]);
entry.spellid = atoi(row[1]);
entry.type = atoi(row[2]);
entry.zoneid = atoi(row[3]);
entry.x = 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

View File

@ -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<std::string> Columns()
{
return {
"name",
"txtfile",
"language",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("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<Books> &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<std::string> 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<std::string> 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> books_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &books_entry: books_entries) {
std::vector<std::string> 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<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Books> All()
{
std::vector<Books> 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<Books> GetWhere(std::string where_filter)
{
std::vector<Books> 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

View File

@ -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<std::string> Columns()
{
return {
"id",
"zone",
"client_version_id",
"client_version_name",
"account_id",
"character_id",
"character_name",
"reporter_spoof",
"category_id",
"category_name",
"reporter_name",
"ui_path",
"pos_x",
"pos_y",
"pos_z",
"heading",
"time_played",
"target_id",
"target_name",
"optional_info_mask",
"_can_duplicate",
"_crash_bug",
"_target_info",
"_character_flags",
"_unknown_value",
"bug_report",
"system_info",
"report_datetime",
"bug_status",
"last_review",
"last_reviewer",
"reviewer_notes",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("bug_reports");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static BugReports NewEntity()
{
BugReports entry{};
entry.id = 0;
entry.zone = "Unknown";
entry.client_version_id = 0;
entry.client_version_name = "Unknown";
entry.account_id = 0;
entry.character_id = 0;
entry.character_name = "Unknown";
entry.reporter_spoof = 1;
entry.category_id = 0;
entry.category_name = "Other";
entry.reporter_name = "Unknown";
entry.ui_path = "Unknown";
entry.pos_x = 0;
entry.pos_y = 0;
entry.pos_z = 0;
entry.heading = 0;
entry.time_played = 0;
entry.target_id = 0;
entry.target_name = "Unknown";
entry.optional_info_mask = 0;
entry._can_duplicate = 0;
entry._crash_bug = 0;
entry._target_info = 0;
entry._character_flags = 0;
entry._unknown_value = 0;
entry.bug_report = "";
entry.system_info = "";
entry.report_datetime = current_timestamp();
entry.bug_status = 0;
entry.last_review = current_timestamp();
entry.last_reviewer = "None";
entry.reviewer_notes = "";
return entry;
}
static BugReports GetBugReportsEntry(
const std::vector<BugReports> &bug_reportss,
int bug_reports_id
)
{
for (auto &bug_reports : bug_reportss) {
if (bug_reports.id == bug_reports_id) {
return bug_reports;
}
}
return NewEntity();
}
static BugReports FindOne(
int bug_reports_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
bug_reports_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
BugReports entry{};
entry.id = atoi(row[0]);
entry.zone = row[1] ? row[1] : "";
entry.client_version_id = atoi(row[2]);
entry.client_version_name = row[3] ? row[3] : "";
entry.account_id = atoi(row[4]);
entry.character_id = atoi(row[5]);
entry.character_name = row[6] ? row[6] : "";
entry.reporter_spoof = atoi(row[7]);
entry.category_id = atoi(row[8]);
entry.category_name = row[9] ? row[9] : "";
entry.reporter_name = row[10] ? row[10] : "";
entry.ui_path = row[11] ? row[11] : "";
entry.pos_x = 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<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + EscapeString(bug_reports_entry.zone) + "'");
update_values.push_back(columns[2] + " = " + std::to_string(bug_reports_entry.client_version_id));
update_values.push_back(columns[3] + " = '" + EscapeString(bug_reports_entry.client_version_name) + "'");
update_values.push_back(columns[4] + " = " + std::to_string(bug_reports_entry.account_id));
update_values.push_back(columns[5] + " = " + std::to_string(bug_reports_entry.character_id));
update_values.push_back(columns[6] + " = '" + EscapeString(bug_reports_entry.character_name) + "'");
update_values.push_back(columns[7] + " = " + std::to_string(bug_reports_entry.reporter_spoof));
update_values.push_back(columns[8] + " = " + std::to_string(bug_reports_entry.category_id));
update_values.push_back(columns[9] + " = '" + EscapeString(bug_reports_entry.category_name) + "'");
update_values.push_back(columns[10] + " = '" + EscapeString(bug_reports_entry.reporter_name) + "'");
update_values.push_back(columns[11] + " = '" + EscapeString(bug_reports_entry.ui_path) + "'");
update_values.push_back(columns[12] + " = " + std::to_string(bug_reports_entry.pos_x));
update_values.push_back(columns[13] + " = " + std::to_string(bug_reports_entry.pos_y));
update_values.push_back(columns[14] + " = " + std::to_string(bug_reports_entry.pos_z));
update_values.push_back(columns[15] + " = " + std::to_string(bug_reports_entry.heading));
update_values.push_back(columns[16] + " = " + std::to_string(bug_reports_entry.time_played));
update_values.push_back(columns[17] + " = " + std::to_string(bug_reports_entry.target_id));
update_values.push_back(columns[18] + " = '" + EscapeString(bug_reports_entry.target_name) + "'");
update_values.push_back(columns[19] + " = " + std::to_string(bug_reports_entry.optional_info_mask));
update_values.push_back(columns[20] + " = " + std::to_string(bug_reports_entry._can_duplicate));
update_values.push_back(columns[21] + " = " + std::to_string(bug_reports_entry._crash_bug));
update_values.push_back(columns[22] + " = " + std::to_string(bug_reports_entry._target_info));
update_values.push_back(columns[23] + " = " + std::to_string(bug_reports_entry._character_flags));
update_values.push_back(columns[24] + " = " + std::to_string(bug_reports_entry._unknown_value));
update_values.push_back(columns[25] + " = '" + EscapeString(bug_reports_entry.bug_report) + "'");
update_values.push_back(columns[26] + " = '" + EscapeString(bug_reports_entry.system_info) + "'");
update_values.push_back(columns[27] + " = '" + EscapeString(bug_reports_entry.report_datetime) + "'");
update_values.push_back(columns[28] + " = " + std::to_string(bug_reports_entry.bug_status));
update_values.push_back(columns[29] + " = '" + EscapeString(bug_reports_entry.last_review) + "'");
update_values.push_back(columns[30] + " = '" + EscapeString(bug_reports_entry.last_reviewer) + "'");
update_values.push_back(columns[31] + " = '" + EscapeString(bug_reports_entry.reviewer_notes) + "'");
auto results = database.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
bug_reports_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static BugReports InsertOne(
BugReports bug_reports_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(bug_reports_entry.zone) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.client_version_id));
insert_values.push_back("'" + EscapeString(bug_reports_entry.client_version_name) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.account_id));
insert_values.push_back(std::to_string(bug_reports_entry.character_id));
insert_values.push_back("'" + EscapeString(bug_reports_entry.character_name) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.reporter_spoof));
insert_values.push_back(std::to_string(bug_reports_entry.category_id));
insert_values.push_back("'" + EscapeString(bug_reports_entry.category_name) + "'");
insert_values.push_back("'" + EscapeString(bug_reports_entry.reporter_name) + "'");
insert_values.push_back("'" + EscapeString(bug_reports_entry.ui_path) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.pos_x));
insert_values.push_back(std::to_string(bug_reports_entry.pos_y));
insert_values.push_back(std::to_string(bug_reports_entry.pos_z));
insert_values.push_back(std::to_string(bug_reports_entry.heading));
insert_values.push_back(std::to_string(bug_reports_entry.time_played));
insert_values.push_back(std::to_string(bug_reports_entry.target_id));
insert_values.push_back("'" + EscapeString(bug_reports_entry.target_name) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.optional_info_mask));
insert_values.push_back(std::to_string(bug_reports_entry._can_duplicate));
insert_values.push_back(std::to_string(bug_reports_entry._crash_bug));
insert_values.push_back(std::to_string(bug_reports_entry._target_info));
insert_values.push_back(std::to_string(bug_reports_entry._character_flags));
insert_values.push_back(std::to_string(bug_reports_entry._unknown_value));
insert_values.push_back("'" + EscapeString(bug_reports_entry.bug_report) + "'");
insert_values.push_back("'" + EscapeString(bug_reports_entry.system_info) + "'");
insert_values.push_back("'" + EscapeString(bug_reports_entry.report_datetime) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.bug_status));
insert_values.push_back("'" + EscapeString(bug_reports_entry.last_review) + "'");
insert_values.push_back("'" + EscapeString(bug_reports_entry.last_reviewer) + "'");
insert_values.push_back("'" + EscapeString(bug_reports_entry.reviewer_notes) + "'");
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
bug_reports_entry.id = results.LastInsertedID();
return bug_reports_entry;
}
bug_reports_entry = NewEntity();
return bug_reports_entry;
}
static int InsertMany(
std::vector<BugReports> bug_reports_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &bug_reports_entry: bug_reports_entries) {
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(bug_reports_entry.zone) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.client_version_id));
insert_values.push_back("'" + EscapeString(bug_reports_entry.client_version_name) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.account_id));
insert_values.push_back(std::to_string(bug_reports_entry.character_id));
insert_values.push_back("'" + EscapeString(bug_reports_entry.character_name) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.reporter_spoof));
insert_values.push_back(std::to_string(bug_reports_entry.category_id));
insert_values.push_back("'" + EscapeString(bug_reports_entry.category_name) + "'");
insert_values.push_back("'" + EscapeString(bug_reports_entry.reporter_name) + "'");
insert_values.push_back("'" + EscapeString(bug_reports_entry.ui_path) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.pos_x));
insert_values.push_back(std::to_string(bug_reports_entry.pos_y));
insert_values.push_back(std::to_string(bug_reports_entry.pos_z));
insert_values.push_back(std::to_string(bug_reports_entry.heading));
insert_values.push_back(std::to_string(bug_reports_entry.time_played));
insert_values.push_back(std::to_string(bug_reports_entry.target_id));
insert_values.push_back("'" + EscapeString(bug_reports_entry.target_name) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.optional_info_mask));
insert_values.push_back(std::to_string(bug_reports_entry._can_duplicate));
insert_values.push_back(std::to_string(bug_reports_entry._crash_bug));
insert_values.push_back(std::to_string(bug_reports_entry._target_info));
insert_values.push_back(std::to_string(bug_reports_entry._character_flags));
insert_values.push_back(std::to_string(bug_reports_entry._unknown_value));
insert_values.push_back("'" + EscapeString(bug_reports_entry.bug_report) + "'");
insert_values.push_back("'" + EscapeString(bug_reports_entry.system_info) + "'");
insert_values.push_back("'" + EscapeString(bug_reports_entry.report_datetime) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.bug_status));
insert_values.push_back("'" + EscapeString(bug_reports_entry.last_review) + "'");
insert_values.push_back("'" + EscapeString(bug_reports_entry.last_reviewer) + "'");
insert_values.push_back("'" + EscapeString(bug_reports_entry.reviewer_notes) + "'");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<BugReports> All()
{
std::vector<BugReports> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
BugReports entry{};
entry.id = atoi(row[0]);
entry.zone = row[1] ? row[1] : "";
entry.client_version_id = atoi(row[2]);
entry.client_version_name = row[3] ? row[3] : "";
entry.account_id = atoi(row[4]);
entry.character_id = atoi(row[5]);
entry.character_name = row[6] ? row[6] : "";
entry.reporter_spoof = atoi(row[7]);
entry.category_id = atoi(row[8]);
entry.category_name = row[9] ? row[9] : "";
entry.reporter_name = row[10] ? row[10] : "";
entry.ui_path = row[11] ? row[11] : "";
entry.pos_x = 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<BugReports> GetWhere(std::string where_filter)
{
std::vector<BugReports> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
BugReports entry{};
entry.id = atoi(row[0]);
entry.zone = row[1] ? row[1] : "";
entry.client_version_id = atoi(row[2]);
entry.client_version_name = row[3] ? row[3] : "";
entry.account_id = atoi(row[4]);
entry.character_id = atoi(row[5]);
entry.character_name = row[6] ? row[6] : "";
entry.reporter_spoof = atoi(row[7]);
entry.category_id = atoi(row[8]);
entry.category_name = row[9] ? row[9] : "";
entry.reporter_name = row[10] ? row[10] : "";
entry.ui_path = row[11] ? row[11] : "";
entry.pos_x = 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

View File

@ -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<std::string> Columns()
{
return {
"id",
"zone",
"name",
"ui",
"x",
"y",
"z",
"type",
"flag",
"target",
"bug",
"date",
"status",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("bugs");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static Bugs NewEntity()
{
Bugs entry{};
entry.id = 0;
entry.zone = "";
entry.name = "";
entry.ui = "";
entry.x = 0;
entry.y = 0;
entry.z = 0;
entry.type = "";
entry.flag = 0;
entry.target = "";
entry.bug = "";
entry.date = 0;
entry.status = 0;
return entry;
}
static Bugs GetBugsEntry(
const std::vector<Bugs> &bugss,
int bugs_id
)
{
for (auto &bugs : bugss) {
if (bugs.id == bugs_id) {
return bugs;
}
}
return NewEntity();
}
static Bugs FindOne(
int bugs_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
bugs_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
Bugs entry{};
entry.id = atoi(row[0]);
entry.zone = row[1] ? row[1] : "";
entry.name = row[2] ? row[2] : "";
entry.ui = row[3] ? row[3] : "";
entry.x = 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<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + EscapeString(bugs_entry.zone) + "'");
update_values.push_back(columns[2] + " = '" + EscapeString(bugs_entry.name) + "'");
update_values.push_back(columns[3] + " = '" + EscapeString(bugs_entry.ui) + "'");
update_values.push_back(columns[4] + " = " + std::to_string(bugs_entry.x));
update_values.push_back(columns[5] + " = " + std::to_string(bugs_entry.y));
update_values.push_back(columns[6] + " = " + std::to_string(bugs_entry.z));
update_values.push_back(columns[7] + " = '" + EscapeString(bugs_entry.type) + "'");
update_values.push_back(columns[8] + " = " + std::to_string(bugs_entry.flag));
update_values.push_back(columns[9] + " = '" + EscapeString(bugs_entry.target) + "'");
update_values.push_back(columns[10] + " = '" + EscapeString(bugs_entry.bug) + "'");
update_values.push_back(columns[11] + " = '" + EscapeString(bugs_entry.date) + "'");
update_values.push_back(columns[12] + " = " + std::to_string(bugs_entry.status));
auto results = database.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
bugs_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static Bugs InsertOne(
Bugs bugs_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(bugs_entry.zone) + "'");
insert_values.push_back("'" + EscapeString(bugs_entry.name) + "'");
insert_values.push_back("'" + EscapeString(bugs_entry.ui) + "'");
insert_values.push_back(std::to_string(bugs_entry.x));
insert_values.push_back(std::to_string(bugs_entry.y));
insert_values.push_back(std::to_string(bugs_entry.z));
insert_values.push_back("'" + EscapeString(bugs_entry.type) + "'");
insert_values.push_back(std::to_string(bugs_entry.flag));
insert_values.push_back("'" + EscapeString(bugs_entry.target) + "'");
insert_values.push_back("'" + EscapeString(bugs_entry.bug) + "'");
insert_values.push_back("'" + EscapeString(bugs_entry.date) + "'");
insert_values.push_back(std::to_string(bugs_entry.status));
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
bugs_entry.id = results.LastInsertedID();
return bugs_entry;
}
bugs_entry = NewEntity();
return bugs_entry;
}
static int InsertMany(
std::vector<Bugs> bugs_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &bugs_entry: bugs_entries) {
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(bugs_entry.zone) + "'");
insert_values.push_back("'" + EscapeString(bugs_entry.name) + "'");
insert_values.push_back("'" + EscapeString(bugs_entry.ui) + "'");
insert_values.push_back(std::to_string(bugs_entry.x));
insert_values.push_back(std::to_string(bugs_entry.y));
insert_values.push_back(std::to_string(bugs_entry.z));
insert_values.push_back("'" + EscapeString(bugs_entry.type) + "'");
insert_values.push_back(std::to_string(bugs_entry.flag));
insert_values.push_back("'" + EscapeString(bugs_entry.target) + "'");
insert_values.push_back("'" + EscapeString(bugs_entry.bug) + "'");
insert_values.push_back("'" + EscapeString(bugs_entry.date) + "'");
insert_values.push_back(std::to_string(bugs_entry.status));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Bugs> All()
{
std::vector<Bugs> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Bugs entry{};
entry.id = atoi(row[0]);
entry.zone = row[1] ? row[1] : "";
entry.name = row[2] ? row[2] : "";
entry.ui = row[3] ? row[3] : "";
entry.x = 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<Bugs> GetWhere(std::string where_filter)
{
std::vector<Bugs> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Bugs entry{};
entry.id = atoi(row[0]);
entry.zone = row[1] ? row[1] : "";
entry.name = row[2] ? row[2] : "";
entry.ui = row[3] ? row[3] : "";
entry.x = 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

View File

@ -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<std::string> Columns()
{
return {
"charid",
"buyslot",
"itemid",
"itemname",
"quantity",
"price",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("buyer");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static Buyer NewEntity()
{
Buyer entry{};
entry.charid = 0;
entry.buyslot = 0;
entry.itemid = 0;
entry.itemname = "";
entry.quantity = 0;
entry.price = 0;
return entry;
}
static Buyer GetBuyerEntry(
const std::vector<Buyer> &buyers,
int buyer_id
)
{
for (auto &buyer : buyers) {
if (buyer.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<std::string> 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<std::string> 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> buyer_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &buyer_entry: buyer_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(buyer_entry.itemid));
insert_values.push_back("'" + EscapeString(buyer_entry.itemname) + "'");
insert_values.push_back(std::to_string(buyer_entry.quantity));
insert_values.push_back(std::to_string(buyer_entry.price));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Buyer> All()
{
std::vector<Buyer> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Buyer entry{};
entry.charid = atoi(row[0]);
entry.buyslot = atoi(row[1]);
entry.itemid = atoi(row[2]);
entry.itemname = row[3] ? row[3] : "";
entry.quantity = atoi(row[4]);
entry.price = atoi(row[5]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<Buyer> GetWhere(std::string where_filter)
{
std::vector<Buyer> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Buyer entry{};
entry.charid = atoi(row[0]);
entry.buyslot = atoi(row[1]);
entry.itemid = atoi(row[2]);
entry.itemname = row[3] ? row[3] : "";
entry.quantity = atoi(row[4]);
entry.price = atoi(row[5]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_BUYER_REPOSITORY_H

View File

@ -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<std::string> 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<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("char_create_combinations");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharCreateCombinations NewEntity()
{
CharCreateCombinations entry{};
entry.allocation_id = 0;
entry.race = 0;
entry.class = 0;
entry.deity = 0;
entry.start_zone = 0;
entry.expansions_req = 0;
entry.min_expansion = 0;
entry.max_expansion = 0;
entry.content_flags = "";
return entry;
}
static CharCreateCombinations GetCharCreateCombinationsEntry(
const std::vector<CharCreateCombinations> &char_create_combinationss,
int char_create_combinations_id
)
{
for (auto &char_create_combinations : char_create_combinationss) {
if (char_create_combinations.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<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(char_create_combinations_entry.allocation_id));
update_values.push_back(columns[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<std::string> insert_values;
insert_values.push_back(std::to_string(char_create_combinations_entry.allocation_id));
insert_values.push_back(std::to_string(char_create_combinations_entry.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<CharCreateCombinations> char_create_combinations_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &char_create_combinations_entry: char_create_combinations_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(char_create_combinations_entry.allocation_id));
insert_values.push_back(std::to_string(char_create_combinations_entry.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<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharCreateCombinations> All()
{
std::vector<CharCreateCombinations> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharCreateCombinations entry{};
entry.allocation_id = atoi(row[0]);
entry.race = atoi(row[1]);
entry.class = atoi(row[2]);
entry.deity = atoi(row[3]);
entry.start_zone = atoi(row[4]);
entry.expansions_req = atoi(row[5]);
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<CharCreateCombinations> GetWhere(std::string where_filter)
{
std::vector<CharCreateCombinations> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharCreateCombinations entry{};
entry.allocation_id = atoi(row[0]);
entry.race = atoi(row[1]);
entry.class = atoi(row[2]);
entry.deity = atoi(row[3]);
entry.start_zone = atoi(row[4]);
entry.expansions_req = atoi(row[5]);
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

View File

@ -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<std::string> Columns()
{
return {
"id",
"base_str",
"base_sta",
"base_dex",
"base_agi",
"base_int",
"base_wis",
"base_cha",
"alloc_str",
"alloc_sta",
"alloc_dex",
"alloc_agi",
"alloc_int",
"alloc_wis",
"alloc_cha",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("char_create_point_allocations");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharCreatePointAllocations NewEntity()
{
CharCreatePointAllocations entry{};
entry.id = 0;
entry.base_str = 0;
entry.base_sta = 0;
entry.base_dex = 0;
entry.base_agi = 0;
entry.base_int = 0;
entry.base_wis = 0;
entry.base_cha = 0;
entry.alloc_str = 0;
entry.alloc_sta = 0;
entry.alloc_dex = 0;
entry.alloc_agi = 0;
entry.alloc_int = 0;
entry.alloc_wis = 0;
entry.alloc_cha = 0;
return entry;
}
static CharCreatePointAllocations GetCharCreatePointAllocationsEntry(
const std::vector<CharCreatePointAllocations> &char_create_point_allocationss,
int char_create_point_allocations_id
)
{
for (auto &char_create_point_allocations : char_create_point_allocationss) {
if (char_create_point_allocations.id == char_create_point_allocations_id) {
return char_create_point_allocations;
}
}
return NewEntity();
}
static CharCreatePointAllocations FindOne(
int char_create_point_allocations_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
char_create_point_allocations_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
CharCreatePointAllocations entry{};
entry.id = atoi(row[0]);
entry.base_str = atoi(row[1]);
entry.base_sta = atoi(row[2]);
entry.base_dex = atoi(row[3]);
entry.base_agi = atoi(row[4]);
entry.base_int = atoi(row[5]);
entry.base_wis = atoi(row[6]);
entry.base_cha = atoi(row[7]);
entry.alloc_str = atoi(row[8]);
entry.alloc_sta = atoi(row[9]);
entry.alloc_dex = atoi(row[10]);
entry.alloc_agi = atoi(row[11]);
entry.alloc_int = atoi(row[12]);
entry.alloc_wis = atoi(row[13]);
entry.alloc_cha = atoi(row[14]);
return entry;
}
return NewEntity();
}
static int DeleteOne(
int char_create_point_allocations_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
char_create_point_allocations_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
CharCreatePointAllocations char_create_point_allocations_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(char_create_point_allocations_entry.base_str));
update_values.push_back(columns[2] + " = " + std::to_string(char_create_point_allocations_entry.base_sta));
update_values.push_back(columns[3] + " = " + std::to_string(char_create_point_allocations_entry.base_dex));
update_values.push_back(columns[4] + " = " + std::to_string(char_create_point_allocations_entry.base_agi));
update_values.push_back(columns[5] + " = " + std::to_string(char_create_point_allocations_entry.base_int));
update_values.push_back(columns[6] + " = " + std::to_string(char_create_point_allocations_entry.base_wis));
update_values.push_back(columns[7] + " = " + std::to_string(char_create_point_allocations_entry.base_cha));
update_values.push_back(columns[8] + " = " + std::to_string(char_create_point_allocations_entry.alloc_str));
update_values.push_back(columns[9] + " = " + std::to_string(char_create_point_allocations_entry.alloc_sta));
update_values.push_back(columns[10] + " = " + std::to_string(char_create_point_allocations_entry.alloc_dex));
update_values.push_back(columns[11] + " = " + std::to_string(char_create_point_allocations_entry.alloc_agi));
update_values.push_back(columns[12] + " = " + std::to_string(char_create_point_allocations_entry.alloc_int));
update_values.push_back(columns[13] + " = " + std::to_string(char_create_point_allocations_entry.alloc_wis));
update_values.push_back(columns[14] + " = " + std::to_string(char_create_point_allocations_entry.alloc_cha));
auto results = content_db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
char_create_point_allocations_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static CharCreatePointAllocations InsertOne(
CharCreatePointAllocations char_create_point_allocations_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_str));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_sta));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_dex));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_agi));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_int));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_wis));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_cha));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_str));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_sta));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_dex));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_agi));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_int));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_wis));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_cha));
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
char_create_point_allocations_entry.id = results.LastInsertedID();
return char_create_point_allocations_entry;
}
char_create_point_allocations_entry = NewEntity();
return char_create_point_allocations_entry;
}
static int InsertMany(
std::vector<CharCreatePointAllocations> char_create_point_allocations_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &char_create_point_allocations_entry: char_create_point_allocations_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_str));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_sta));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_dex));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_agi));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_int));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_wis));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_cha));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_str));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_sta));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_dex));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_agi));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_int));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_wis));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_cha));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharCreatePointAllocations> All()
{
std::vector<CharCreatePointAllocations> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharCreatePointAllocations entry{};
entry.id = atoi(row[0]);
entry.base_str = atoi(row[1]);
entry.base_sta = atoi(row[2]);
entry.base_dex = atoi(row[3]);
entry.base_agi = atoi(row[4]);
entry.base_int = atoi(row[5]);
entry.base_wis = atoi(row[6]);
entry.base_cha = atoi(row[7]);
entry.alloc_str = atoi(row[8]);
entry.alloc_sta = atoi(row[9]);
entry.alloc_dex = atoi(row[10]);
entry.alloc_agi = atoi(row[11]);
entry.alloc_int = atoi(row[12]);
entry.alloc_wis = atoi(row[13]);
entry.alloc_cha = atoi(row[14]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharCreatePointAllocations> GetWhere(std::string where_filter)
{
std::vector<CharCreatePointAllocations> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharCreatePointAllocations entry{};
entry.id = atoi(row[0]);
entry.base_str = atoi(row[1]);
entry.base_sta = atoi(row[2]);
entry.base_dex = atoi(row[3]);
entry.base_agi = atoi(row[4]);
entry.base_int = atoi(row[5]);
entry.base_wis = atoi(row[6]);
entry.base_cha = atoi(row[7]);
entry.alloc_str = atoi(row[8]);
entry.alloc_sta = atoi(row[9]);
entry.alloc_dex = atoi(row[10]);
entry.alloc_agi = atoi(row[11]);
entry.alloc_int = atoi(row[12]);
entry.alloc_wis = atoi(row[13]);
entry.alloc_cha = atoi(row[14]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHAR_CREATE_POINT_ALLOCATIONS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"char_id",
"recipe_id",
"madecount",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("char_recipe_list");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharRecipeList NewEntity()
{
CharRecipeList entry{};
entry.char_id = 0;
entry.recipe_id = 0;
entry.madecount = 0;
return entry;
}
static CharRecipeList GetCharRecipeListEntry(
const std::vector<CharRecipeList> &char_recipe_lists,
int char_recipe_list_id
)
{
for (auto &char_recipe_list : char_recipe_lists) {
if (char_recipe_list.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<std::string> 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<std::string> 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<CharRecipeList> char_recipe_list_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &char_recipe_list_entry: char_recipe_list_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(char_recipe_list_entry.madecount));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharRecipeList> All()
{
std::vector<CharRecipeList> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharRecipeList entry{};
entry.char_id = atoi(row[0]);
entry.recipe_id = atoi(row[1]);
entry.madecount = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharRecipeList> GetWhere(std::string where_filter)
{
std::vector<CharRecipeList> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharRecipeList entry{};
entry.char_id = atoi(row[0]);
entry.recipe_id = atoi(row[1]);
entry.madecount = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHAR_RECIPE_LIST_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"charid",
"taskid",
"activityid",
"donecount",
"completed",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_activities");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterActivities NewEntity()
{
CharacterActivities entry{};
entry.charid = 0;
entry.taskid = 0;
entry.activityid = 0;
entry.donecount = 0;
entry.completed = 0;
return entry;
}
static CharacterActivities GetCharacterActivitiesEntry(
const std::vector<CharacterActivities> &character_activitiess,
int character_activities_id
)
{
for (auto &character_activities : character_activitiess) {
if (character_activities.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<std::string> 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<std::string> 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<CharacterActivities> character_activities_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_activities_entry: character_activities_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_activities_entry.donecount));
insert_values.push_back(std::to_string(character_activities_entry.completed));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterActivities> All()
{
std::vector<CharacterActivities> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterActivities entry{};
entry.charid = atoi(row[0]);
entry.taskid = atoi(row[1]);
entry.activityid = atoi(row[2]);
entry.donecount = atoi(row[3]);
entry.completed = atoi(row[4]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterActivities> GetWhere(std::string where_filter)
{
std::vector<CharacterActivities> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterActivities entry{};
entry.charid = atoi(row[0]);
entry.taskid = atoi(row[1]);
entry.activityid = atoi(row[2]);
entry.donecount = atoi(row[3]);
entry.completed = atoi(row[4]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_ACTIVITIES_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"char_id",
"currency_id",
"amount",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_alt_currency");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterAltCurrency NewEntity()
{
CharacterAltCurrency entry{};
entry.char_id = 0;
entry.currency_id = 0;
entry.amount = 0;
return entry;
}
static CharacterAltCurrency GetCharacterAltCurrencyEntry(
const std::vector<CharacterAltCurrency> &character_alt_currencys,
int character_alt_currency_id
)
{
for (auto &character_alt_currency : character_alt_currencys) {
if (character_alt_currency.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<std::string> 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<std::string> 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<CharacterAltCurrency> character_alt_currency_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_alt_currency_entry: character_alt_currency_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_alt_currency_entry.amount));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterAltCurrency> All()
{
std::vector<CharacterAltCurrency> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterAltCurrency entry{};
entry.char_id = atoi(row[0]);
entry.currency_id = atoi(row[1]);
entry.amount = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterAltCurrency> GetWhere(std::string where_filter)
{
std::vector<CharacterAltCurrency> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterAltCurrency entry{};
entry.char_id = atoi(row[0]);
entry.currency_id = atoi(row[1]);
entry.amount = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_ALT_CURRENCY_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"aa_id",
"aa_value",
"charges",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_alternate_abilities");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterAlternateAbilities NewEntity()
{
CharacterAlternateAbilities entry{};
entry.id = 0;
entry.aa_id = 0;
entry.aa_value = 0;
entry.charges = 0;
return entry;
}
static CharacterAlternateAbilities GetCharacterAlternateAbilitiesEntry(
const std::vector<CharacterAlternateAbilities> &character_alternate_abilitiess,
int character_alternate_abilities_id
)
{
for (auto &character_alternate_abilities : character_alternate_abilitiess) {
if (character_alternate_abilities.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<std::string> 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<std::string> 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<CharacterAlternateAbilities> character_alternate_abilities_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_alternate_abilities_entry: character_alternate_abilities_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_alternate_abilities_entry.aa_value));
insert_values.push_back(std::to_string(character_alternate_abilities_entry.charges));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterAlternateAbilities> All()
{
std::vector<CharacterAlternateAbilities> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterAlternateAbilities entry{};
entry.id = atoi(row[0]);
entry.aa_id = atoi(row[1]);
entry.aa_value = atoi(row[2]);
entry.charges = atoi(row[3]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterAlternateAbilities> GetWhere(std::string where_filter)
{
std::vector<CharacterAlternateAbilities> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterAlternateAbilities entry{};
entry.id = atoi(row[0]);
entry.aa_id = atoi(row[1]);
entry.aa_value = atoi(row[2]);
entry.charges = atoi(row[3]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_ALTERNATE_ABILITIES_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"slot",
"spell_id",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_auras");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterAuras NewEntity()
{
CharacterAuras entry{};
entry.id = 0;
entry.slot = 0;
entry.spell_id = 0;
return entry;
}
static CharacterAuras GetCharacterAurasEntry(
const std::vector<CharacterAuras> &character_aurass,
int character_auras_id
)
{
for (auto &character_auras : character_aurass) {
if (character_auras.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<std::string> 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<std::string> 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<CharacterAuras> character_auras_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_auras_entry: character_auras_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_auras_entry.spell_id));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterAuras> All()
{
std::vector<CharacterAuras> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterAuras entry{};
entry.id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.spell_id = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterAuras> GetWhere(std::string where_filter)
{
std::vector<CharacterAuras> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterAuras entry{};
entry.id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.spell_id = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_AURAS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"bandolier_id",
"bandolier_slot",
"item_id",
"icon",
"bandolier_name",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_bandolier");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterBandolier NewEntity()
{
CharacterBandolier entry{};
entry.id = 0;
entry.bandolier_id = 0;
entry.bandolier_slot = 0;
entry.item_id = 0;
entry.icon = 0;
entry.bandolier_name = "0";
return entry;
}
static CharacterBandolier GetCharacterBandolierEntry(
const std::vector<CharacterBandolier> &character_bandoliers,
int character_bandolier_id
)
{
for (auto &character_bandolier : character_bandoliers) {
if (character_bandolier.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<std::string> 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<std::string> 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<CharacterBandolier> character_bandolier_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_bandolier_entry: character_bandolier_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_bandolier_entry.item_id));
insert_values.push_back(std::to_string(character_bandolier_entry.icon));
insert_values.push_back("'" + EscapeString(character_bandolier_entry.bandolier_name) + "'");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterBandolier> All()
{
std::vector<CharacterBandolier> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterBandolier entry{};
entry.id = atoi(row[0]);
entry.bandolier_id = atoi(row[1]);
entry.bandolier_slot = atoi(row[2]);
entry.item_id = atoi(row[3]);
entry.icon = atoi(row[4]);
entry.bandolier_name = row[5] ? row[5] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterBandolier> GetWhere(std::string where_filter)
{
std::vector<CharacterBandolier> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterBandolier entry{};
entry.id = atoi(row[0]);
entry.bandolier_id = atoi(row[1]);
entry.bandolier_slot = atoi(row[2]);
entry.item_id = atoi(row[3]);
entry.icon = atoi(row[4]);
entry.bandolier_name = row[5] ? row[5] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_BANDOLIER_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"slot",
"zone_id",
"instance_id",
"x",
"y",
"z",
"heading",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_bind");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterBind NewEntity()
{
CharacterBind entry{};
entry.id = 0;
entry.slot = 0;
entry.zone_id = 0;
entry.instance_id = 0;
entry.x = 0;
entry.y = 0;
entry.z = 0;
entry.heading = 0;
return entry;
}
static CharacterBind GetCharacterBindEntry(
const std::vector<CharacterBind> &character_binds,
int character_bind_id
)
{
for (auto &character_bind : character_binds) {
if (character_bind.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<std::string> 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<std::string> 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<CharacterBind> character_bind_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_bind_entry: character_bind_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_bind_entry.zone_id));
insert_values.push_back(std::to_string(character_bind_entry.instance_id));
insert_values.push_back(std::to_string(character_bind_entry.x));
insert_values.push_back(std::to_string(character_bind_entry.y));
insert_values.push_back(std::to_string(character_bind_entry.z));
insert_values.push_back(std::to_string(character_bind_entry.heading));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterBind> All()
{
std::vector<CharacterBind> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterBind entry{};
entry.id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.zone_id = atoi(row[2]);
entry.instance_id = atoi(row[3]);
entry.x = 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<CharacterBind> GetWhere(std::string where_filter)
{
std::vector<CharacterBind> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterBind entry{};
entry.id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.zone_id = atoi(row[2]);
entry.instance_id = atoi(row[3]);
entry.x = 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

View File

@ -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<std::string> Columns()
{
return {
"character_id",
"slot_id",
"spell_id",
"caster_level",
"caster_name",
"ticsremaining",
"counters",
"numhits",
"melee_rune",
"magic_rune",
"persistent",
"dot_rune",
"caston_x",
"caston_y",
"caston_z",
"ExtraDIChance",
"instrument_mod",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_buffs");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterBuffs NewEntity()
{
CharacterBuffs entry{};
entry.character_id = 0;
entry.slot_id = 0;
entry.spell_id = 0;
entry.caster_level = 0;
entry.caster_name = "";
entry.ticsremaining = 0;
entry.counters = 0;
entry.numhits = 0;
entry.melee_rune = 0;
entry.magic_rune = 0;
entry.persistent = 0;
entry.dot_rune = 0;
entry.caston_x = 0;
entry.caston_y = 0;
entry.caston_z = 0;
entry.ExtraDIChance = 0;
entry.instrument_mod = 10;
return entry;
}
static CharacterBuffs GetCharacterBuffsEntry(
const std::vector<CharacterBuffs> &character_buffss,
int character_buffs_id
)
{
for (auto &character_buffs : character_buffss) {
if (character_buffs.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<std::string> 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<std::string> 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<CharacterBuffs> character_buffs_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_buffs_entry: character_buffs_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_buffs_entry.spell_id));
insert_values.push_back(std::to_string(character_buffs_entry.caster_level));
insert_values.push_back("'" + EscapeString(character_buffs_entry.caster_name) + "'");
insert_values.push_back(std::to_string(character_buffs_entry.ticsremaining));
insert_values.push_back(std::to_string(character_buffs_entry.counters));
insert_values.push_back(std::to_string(character_buffs_entry.numhits));
insert_values.push_back(std::to_string(character_buffs_entry.melee_rune));
insert_values.push_back(std::to_string(character_buffs_entry.magic_rune));
insert_values.push_back(std::to_string(character_buffs_entry.persistent));
insert_values.push_back(std::to_string(character_buffs_entry.dot_rune));
insert_values.push_back(std::to_string(character_buffs_entry.caston_x));
insert_values.push_back(std::to_string(character_buffs_entry.caston_y));
insert_values.push_back(std::to_string(character_buffs_entry.caston_z));
insert_values.push_back(std::to_string(character_buffs_entry.ExtraDIChance));
insert_values.push_back(std::to_string(character_buffs_entry.instrument_mod));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterBuffs> All()
{
std::vector<CharacterBuffs> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterBuffs entry{};
entry.character_id = atoi(row[0]);
entry.slot_id = atoi(row[1]);
entry.spell_id = atoi(row[2]);
entry.caster_level = atoi(row[3]);
entry.caster_name = row[4] ? row[4] : "";
entry.ticsremaining = atoi(row[5]);
entry.counters = atoi(row[6]);
entry.numhits = atoi(row[7]);
entry.melee_rune = atoi(row[8]);
entry.magic_rune = atoi(row[9]);
entry.persistent = atoi(row[10]);
entry.dot_rune = atoi(row[11]);
entry.caston_x = atoi(row[12]);
entry.caston_y = atoi(row[13]);
entry.caston_z = atoi(row[14]);
entry.ExtraDIChance = atoi(row[15]);
entry.instrument_mod = atoi(row[16]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterBuffs> GetWhere(std::string where_filter)
{
std::vector<CharacterBuffs> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterBuffs entry{};
entry.character_id = atoi(row[0]);
entry.slot_id = atoi(row[1]);
entry.spell_id = atoi(row[2]);
entry.caster_level = atoi(row[3]);
entry.caster_name = row[4] ? row[4] : "";
entry.ticsremaining = atoi(row[5]);
entry.counters = atoi(row[6]);
entry.numhits = atoi(row[7]);
entry.melee_rune = atoi(row[8]);
entry.magic_rune = atoi(row[9]);
entry.persistent = atoi(row[10]);
entry.dot_rune = atoi(row[11]);
entry.caston_x = atoi(row[12]);
entry.caston_y = atoi(row[13]);
entry.caston_z = atoi(row[14]);
entry.ExtraDIChance = atoi(row[15]);
entry.instrument_mod = atoi(row[16]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_BUFFS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"corpse_id",
"equip_slot",
"item_id",
"charges",
"aug_1",
"aug_2",
"aug_3",
"aug_4",
"aug_5",
"aug_6",
"attuned",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_corpse_items");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterCorpseItems NewEntity()
{
CharacterCorpseItems entry{};
entry.corpse_id = 0;
entry.equip_slot = 0;
entry.item_id = 0;
entry.charges = 0;
entry.aug_1 = 0;
entry.aug_2 = 0;
entry.aug_3 = 0;
entry.aug_4 = 0;
entry.aug_5 = 0;
entry.aug_6 = 0;
entry.attuned = 0;
return entry;
}
static CharacterCorpseItems GetCharacterCorpseItemsEntry(
const std::vector<CharacterCorpseItems> &character_corpse_itemss,
int character_corpse_items_id
)
{
for (auto &character_corpse_items : character_corpse_itemss) {
if (character_corpse_items.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<std::string> 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<std::string> 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<CharacterCorpseItems> character_corpse_items_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_corpse_items_entry: character_corpse_items_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_corpse_items_entry.item_id));
insert_values.push_back(std::to_string(character_corpse_items_entry.charges));
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_1));
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_2));
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_3));
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_4));
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_5));
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_6));
insert_values.push_back(std::to_string(character_corpse_items_entry.attuned));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterCorpseItems> All()
{
std::vector<CharacterCorpseItems> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterCorpseItems entry{};
entry.corpse_id = atoi(row[0]);
entry.equip_slot = atoi(row[1]);
entry.item_id = atoi(row[2]);
entry.charges = atoi(row[3]);
entry.aug_1 = atoi(row[4]);
entry.aug_2 = atoi(row[5]);
entry.aug_3 = atoi(row[6]);
entry.aug_4 = atoi(row[7]);
entry.aug_5 = atoi(row[8]);
entry.aug_6 = atoi(row[9]);
entry.attuned = atoi(row[10]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterCorpseItems> GetWhere(std::string where_filter)
{
std::vector<CharacterCorpseItems> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterCorpseItems entry{};
entry.corpse_id = atoi(row[0]);
entry.equip_slot = atoi(row[1]);
entry.item_id = atoi(row[2]);
entry.charges = atoi(row[3]);
entry.aug_1 = atoi(row[4]);
entry.aug_2 = atoi(row[5]);
entry.aug_3 = atoi(row[6]);
entry.aug_4 = atoi(row[7]);
entry.aug_5 = atoi(row[8]);
entry.aug_6 = atoi(row[9]);
entry.attuned = atoi(row[10]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_CORPSE_ITEMS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"charid",
"charname",
"zone_id",
"instance_id",
"x",
"y",
"z",
"heading",
"time_of_death",
"guild_consent_id",
"is_rezzed",
"is_buried",
"was_at_graveyard",
"is_locked",
"exp",
"size",
"level",
"race",
"gender",
"class",
"deity",
"texture",
"helm_texture",
"copper",
"silver",
"gold",
"platinum",
"hair_color",
"beard_color",
"eye_color_1",
"eye_color_2",
"hair_style",
"face",
"beard",
"drakkin_heritage",
"drakkin_tattoo",
"drakkin_details",
"wc_1",
"wc_2",
"wc_3",
"wc_4",
"wc_5",
"wc_6",
"wc_7",
"wc_8",
"wc_9",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_corpses");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterCorpses NewEntity()
{
CharacterCorpses entry{};
entry.id = 0;
entry.charid = 0;
entry.charname = "";
entry.zone_id = 0;
entry.instance_id = 0;
entry.x = 0;
entry.y = 0;
entry.z = 0;
entry.heading = 0;
entry.time_of_death = "0000-00-00 00:00:00";
entry.guild_consent_id = 0;
entry.is_rezzed = 0;
entry.is_buried = 0;
entry.was_at_graveyard = 0;
entry.is_locked = 0;
entry.exp = 0;
entry.size = 0;
entry.level = 0;
entry.race = 0;
entry.gender = 0;
entry.class = 0;
entry.deity = 0;
entry.texture = 0;
entry.helm_texture = 0;
entry.copper = 0;
entry.silver = 0;
entry.gold = 0;
entry.platinum = 0;
entry.hair_color = 0;
entry.beard_color = 0;
entry.eye_color_1 = 0;
entry.eye_color_2 = 0;
entry.hair_style = 0;
entry.face = 0;
entry.beard = 0;
entry.drakkin_heritage = 0;
entry.drakkin_tattoo = 0;
entry.drakkin_details = 0;
entry.wc_1 = 0;
entry.wc_2 = 0;
entry.wc_3 = 0;
entry.wc_4 = 0;
entry.wc_5 = 0;
entry.wc_6 = 0;
entry.wc_7 = 0;
entry.wc_8 = 0;
entry.wc_9 = 0;
return entry;
}
static CharacterCorpses GetCharacterCorpsesEntry(
const std::vector<CharacterCorpses> &character_corpsess,
int character_corpses_id
)
{
for (auto &character_corpses : character_corpsess) {
if (character_corpses.id == character_corpses_id) {
return character_corpses;
}
}
return NewEntity();
}
static CharacterCorpses FindOne(
int character_corpses_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
character_corpses_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterCorpses entry{};
entry.id = atoi(row[0]);
entry.charid = atoi(row[1]);
entry.charname = row[2] ? row[2] : "";
entry.zone_id = atoi(row[3]);
entry.instance_id = atoi(row[4]);
entry.x = 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<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(character_corpses_entry.charid));
update_values.push_back(columns[2] + " = '" + EscapeString(character_corpses_entry.charname) + "'");
update_values.push_back(columns[3] + " = " + std::to_string(character_corpses_entry.zone_id));
update_values.push_back(columns[4] + " = " + std::to_string(character_corpses_entry.instance_id));
update_values.push_back(columns[5] + " = " + std::to_string(character_corpses_entry.x));
update_values.push_back(columns[6] + " = " + std::to_string(character_corpses_entry.y));
update_values.push_back(columns[7] + " = " + std::to_string(character_corpses_entry.z));
update_values.push_back(columns[8] + " = " + std::to_string(character_corpses_entry.heading));
update_values.push_back(columns[9] + " = '" + EscapeString(character_corpses_entry.time_of_death) + "'");
update_values.push_back(columns[10] + " = " + std::to_string(character_corpses_entry.guild_consent_id));
update_values.push_back(columns[11] + " = " + std::to_string(character_corpses_entry.is_rezzed));
update_values.push_back(columns[12] + " = " + std::to_string(character_corpses_entry.is_buried));
update_values.push_back(columns[13] + " = " + std::to_string(character_corpses_entry.was_at_graveyard));
update_values.push_back(columns[14] + " = " + std::to_string(character_corpses_entry.is_locked));
update_values.push_back(columns[15] + " = " + std::to_string(character_corpses_entry.exp));
update_values.push_back(columns[16] + " = " + std::to_string(character_corpses_entry.size));
update_values.push_back(columns[17] + " = " + std::to_string(character_corpses_entry.level));
update_values.push_back(columns[18] + " = " + std::to_string(character_corpses_entry.race));
update_values.push_back(columns[19] + " = " + std::to_string(character_corpses_entry.gender));
update_values.push_back(columns[20] + " = " + std::to_string(character_corpses_entry.class));
update_values.push_back(columns[21] + " = " + std::to_string(character_corpses_entry.deity));
update_values.push_back(columns[22] + " = " + std::to_string(character_corpses_entry.texture));
update_values.push_back(columns[23] + " = " + std::to_string(character_corpses_entry.helm_texture));
update_values.push_back(columns[24] + " = " + std::to_string(character_corpses_entry.copper));
update_values.push_back(columns[25] + " = " + std::to_string(character_corpses_entry.silver));
update_values.push_back(columns[26] + " = " + std::to_string(character_corpses_entry.gold));
update_values.push_back(columns[27] + " = " + std::to_string(character_corpses_entry.platinum));
update_values.push_back(columns[28] + " = " + std::to_string(character_corpses_entry.hair_color));
update_values.push_back(columns[29] + " = " + std::to_string(character_corpses_entry.beard_color));
update_values.push_back(columns[30] + " = " + std::to_string(character_corpses_entry.eye_color_1));
update_values.push_back(columns[31] + " = " + std::to_string(character_corpses_entry.eye_color_2));
update_values.push_back(columns[32] + " = " + std::to_string(character_corpses_entry.hair_style));
update_values.push_back(columns[33] + " = " + std::to_string(character_corpses_entry.face));
update_values.push_back(columns[34] + " = " + std::to_string(character_corpses_entry.beard));
update_values.push_back(columns[35] + " = " + std::to_string(character_corpses_entry.drakkin_heritage));
update_values.push_back(columns[36] + " = " + std::to_string(character_corpses_entry.drakkin_tattoo));
update_values.push_back(columns[37] + " = " + std::to_string(character_corpses_entry.drakkin_details));
update_values.push_back(columns[38] + " = " + std::to_string(character_corpses_entry.wc_1));
update_values.push_back(columns[39] + " = " + std::to_string(character_corpses_entry.wc_2));
update_values.push_back(columns[40] + " = " + std::to_string(character_corpses_entry.wc_3));
update_values.push_back(columns[41] + " = " + std::to_string(character_corpses_entry.wc_4));
update_values.push_back(columns[42] + " = " + std::to_string(character_corpses_entry.wc_5));
update_values.push_back(columns[43] + " = " + std::to_string(character_corpses_entry.wc_6));
update_values.push_back(columns[44] + " = " + std::to_string(character_corpses_entry.wc_7));
update_values.push_back(columns[45] + " = " + std::to_string(character_corpses_entry.wc_8));
update_values.push_back(columns[46] + " = " + std::to_string(character_corpses_entry.wc_9));
auto results = database.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
character_corpses_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static CharacterCorpses InsertOne(
CharacterCorpses character_corpses_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_corpses_entry.charid));
insert_values.push_back("'" + EscapeString(character_corpses_entry.charname) + "'");
insert_values.push_back(std::to_string(character_corpses_entry.zone_id));
insert_values.push_back(std::to_string(character_corpses_entry.instance_id));
insert_values.push_back(std::to_string(character_corpses_entry.x));
insert_values.push_back(std::to_string(character_corpses_entry.y));
insert_values.push_back(std::to_string(character_corpses_entry.z));
insert_values.push_back(std::to_string(character_corpses_entry.heading));
insert_values.push_back("'" + EscapeString(character_corpses_entry.time_of_death) + "'");
insert_values.push_back(std::to_string(character_corpses_entry.guild_consent_id));
insert_values.push_back(std::to_string(character_corpses_entry.is_rezzed));
insert_values.push_back(std::to_string(character_corpses_entry.is_buried));
insert_values.push_back(std::to_string(character_corpses_entry.was_at_graveyard));
insert_values.push_back(std::to_string(character_corpses_entry.is_locked));
insert_values.push_back(std::to_string(character_corpses_entry.exp));
insert_values.push_back(std::to_string(character_corpses_entry.size));
insert_values.push_back(std::to_string(character_corpses_entry.level));
insert_values.push_back(std::to_string(character_corpses_entry.race));
insert_values.push_back(std::to_string(character_corpses_entry.gender));
insert_values.push_back(std::to_string(character_corpses_entry.class));
insert_values.push_back(std::to_string(character_corpses_entry.deity));
insert_values.push_back(std::to_string(character_corpses_entry.texture));
insert_values.push_back(std::to_string(character_corpses_entry.helm_texture));
insert_values.push_back(std::to_string(character_corpses_entry.copper));
insert_values.push_back(std::to_string(character_corpses_entry.silver));
insert_values.push_back(std::to_string(character_corpses_entry.gold));
insert_values.push_back(std::to_string(character_corpses_entry.platinum));
insert_values.push_back(std::to_string(character_corpses_entry.hair_color));
insert_values.push_back(std::to_string(character_corpses_entry.beard_color));
insert_values.push_back(std::to_string(character_corpses_entry.eye_color_1));
insert_values.push_back(std::to_string(character_corpses_entry.eye_color_2));
insert_values.push_back(std::to_string(character_corpses_entry.hair_style));
insert_values.push_back(std::to_string(character_corpses_entry.face));
insert_values.push_back(std::to_string(character_corpses_entry.beard));
insert_values.push_back(std::to_string(character_corpses_entry.drakkin_heritage));
insert_values.push_back(std::to_string(character_corpses_entry.drakkin_tattoo));
insert_values.push_back(std::to_string(character_corpses_entry.drakkin_details));
insert_values.push_back(std::to_string(character_corpses_entry.wc_1));
insert_values.push_back(std::to_string(character_corpses_entry.wc_2));
insert_values.push_back(std::to_string(character_corpses_entry.wc_3));
insert_values.push_back(std::to_string(character_corpses_entry.wc_4));
insert_values.push_back(std::to_string(character_corpses_entry.wc_5));
insert_values.push_back(std::to_string(character_corpses_entry.wc_6));
insert_values.push_back(std::to_string(character_corpses_entry.wc_7));
insert_values.push_back(std::to_string(character_corpses_entry.wc_8));
insert_values.push_back(std::to_string(character_corpses_entry.wc_9));
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
character_corpses_entry.id = results.LastInsertedID();
return character_corpses_entry;
}
character_corpses_entry = NewEntity();
return character_corpses_entry;
}
static int InsertMany(
std::vector<CharacterCorpses> character_corpses_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_corpses_entry: character_corpses_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_corpses_entry.charid));
insert_values.push_back("'" + EscapeString(character_corpses_entry.charname) + "'");
insert_values.push_back(std::to_string(character_corpses_entry.zone_id));
insert_values.push_back(std::to_string(character_corpses_entry.instance_id));
insert_values.push_back(std::to_string(character_corpses_entry.x));
insert_values.push_back(std::to_string(character_corpses_entry.y));
insert_values.push_back(std::to_string(character_corpses_entry.z));
insert_values.push_back(std::to_string(character_corpses_entry.heading));
insert_values.push_back("'" + EscapeString(character_corpses_entry.time_of_death) + "'");
insert_values.push_back(std::to_string(character_corpses_entry.guild_consent_id));
insert_values.push_back(std::to_string(character_corpses_entry.is_rezzed));
insert_values.push_back(std::to_string(character_corpses_entry.is_buried));
insert_values.push_back(std::to_string(character_corpses_entry.was_at_graveyard));
insert_values.push_back(std::to_string(character_corpses_entry.is_locked));
insert_values.push_back(std::to_string(character_corpses_entry.exp));
insert_values.push_back(std::to_string(character_corpses_entry.size));
insert_values.push_back(std::to_string(character_corpses_entry.level));
insert_values.push_back(std::to_string(character_corpses_entry.race));
insert_values.push_back(std::to_string(character_corpses_entry.gender));
insert_values.push_back(std::to_string(character_corpses_entry.class));
insert_values.push_back(std::to_string(character_corpses_entry.deity));
insert_values.push_back(std::to_string(character_corpses_entry.texture));
insert_values.push_back(std::to_string(character_corpses_entry.helm_texture));
insert_values.push_back(std::to_string(character_corpses_entry.copper));
insert_values.push_back(std::to_string(character_corpses_entry.silver));
insert_values.push_back(std::to_string(character_corpses_entry.gold));
insert_values.push_back(std::to_string(character_corpses_entry.platinum));
insert_values.push_back(std::to_string(character_corpses_entry.hair_color));
insert_values.push_back(std::to_string(character_corpses_entry.beard_color));
insert_values.push_back(std::to_string(character_corpses_entry.eye_color_1));
insert_values.push_back(std::to_string(character_corpses_entry.eye_color_2));
insert_values.push_back(std::to_string(character_corpses_entry.hair_style));
insert_values.push_back(std::to_string(character_corpses_entry.face));
insert_values.push_back(std::to_string(character_corpses_entry.beard));
insert_values.push_back(std::to_string(character_corpses_entry.drakkin_heritage));
insert_values.push_back(std::to_string(character_corpses_entry.drakkin_tattoo));
insert_values.push_back(std::to_string(character_corpses_entry.drakkin_details));
insert_values.push_back(std::to_string(character_corpses_entry.wc_1));
insert_values.push_back(std::to_string(character_corpses_entry.wc_2));
insert_values.push_back(std::to_string(character_corpses_entry.wc_3));
insert_values.push_back(std::to_string(character_corpses_entry.wc_4));
insert_values.push_back(std::to_string(character_corpses_entry.wc_5));
insert_values.push_back(std::to_string(character_corpses_entry.wc_6));
insert_values.push_back(std::to_string(character_corpses_entry.wc_7));
insert_values.push_back(std::to_string(character_corpses_entry.wc_8));
insert_values.push_back(std::to_string(character_corpses_entry.wc_9));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterCorpses> All()
{
std::vector<CharacterCorpses> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterCorpses entry{};
entry.id = atoi(row[0]);
entry.charid = atoi(row[1]);
entry.charname = row[2] ? row[2] : "";
entry.zone_id = atoi(row[3]);
entry.instance_id = atoi(row[4]);
entry.x = 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<CharacterCorpses> GetWhere(std::string where_filter)
{
std::vector<CharacterCorpses> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterCorpses entry{};
entry.id = atoi(row[0]);
entry.charid = atoi(row[1]);
entry.charname = row[2] ? row[2] : "";
entry.zone_id = atoi(row[3]);
entry.instance_id = atoi(row[4]);
entry.x = 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

View File

@ -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<std::string> Columns()
{
return {
"id",
"platinum",
"gold",
"silver",
"copper",
"platinum_bank",
"gold_bank",
"silver_bank",
"copper_bank",
"platinum_cursor",
"gold_cursor",
"silver_cursor",
"copper_cursor",
"radiant_crystals",
"career_radiant_crystals",
"ebon_crystals",
"career_ebon_crystals",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_currency");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterCurrency NewEntity()
{
CharacterCurrency entry{};
entry.id = 0;
entry.platinum = 0;
entry.gold = 0;
entry.silver = 0;
entry.copper = 0;
entry.platinum_bank = 0;
entry.gold_bank = 0;
entry.silver_bank = 0;
entry.copper_bank = 0;
entry.platinum_cursor = 0;
entry.gold_cursor = 0;
entry.silver_cursor = 0;
entry.copper_cursor = 0;
entry.radiant_crystals = 0;
entry.career_radiant_crystals = 0;
entry.ebon_crystals = 0;
entry.career_ebon_crystals = 0;
return entry;
}
static CharacterCurrency GetCharacterCurrencyEntry(
const std::vector<CharacterCurrency> &character_currencys,
int character_currency_id
)
{
for (auto &character_currency : character_currencys) {
if (character_currency.id == character_currency_id) {
return character_currency;
}
}
return NewEntity();
}
static CharacterCurrency FindOne(
int character_currency_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
character_currency_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterCurrency entry{};
entry.id = atoi(row[0]);
entry.platinum = atoi(row[1]);
entry.gold = atoi(row[2]);
entry.silver = atoi(row[3]);
entry.copper = atoi(row[4]);
entry.platinum_bank = atoi(row[5]);
entry.gold_bank = atoi(row[6]);
entry.silver_bank = atoi(row[7]);
entry.copper_bank = atoi(row[8]);
entry.platinum_cursor = atoi(row[9]);
entry.gold_cursor = atoi(row[10]);
entry.silver_cursor = atoi(row[11]);
entry.copper_cursor = atoi(row[12]);
entry.radiant_crystals = atoi(row[13]);
entry.career_radiant_crystals = atoi(row[14]);
entry.ebon_crystals = atoi(row[15]);
entry.career_ebon_crystals = atoi(row[16]);
return entry;
}
return NewEntity();
}
static int DeleteOne(
int character_currency_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
character_currency_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
CharacterCurrency character_currency_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(character_currency_entry.platinum));
update_values.push_back(columns[2] + " = " + std::to_string(character_currency_entry.gold));
update_values.push_back(columns[3] + " = " + std::to_string(character_currency_entry.silver));
update_values.push_back(columns[4] + " = " + std::to_string(character_currency_entry.copper));
update_values.push_back(columns[5] + " = " + std::to_string(character_currency_entry.platinum_bank));
update_values.push_back(columns[6] + " = " + std::to_string(character_currency_entry.gold_bank));
update_values.push_back(columns[7] + " = " + std::to_string(character_currency_entry.silver_bank));
update_values.push_back(columns[8] + " = " + std::to_string(character_currency_entry.copper_bank));
update_values.push_back(columns[9] + " = " + std::to_string(character_currency_entry.platinum_cursor));
update_values.push_back(columns[10] + " = " + std::to_string(character_currency_entry.gold_cursor));
update_values.push_back(columns[11] + " = " + std::to_string(character_currency_entry.silver_cursor));
update_values.push_back(columns[12] + " = " + std::to_string(character_currency_entry.copper_cursor));
update_values.push_back(columns[13] + " = " + std::to_string(character_currency_entry.radiant_crystals));
update_values.push_back(columns[14] + " = " + std::to_string(character_currency_entry.career_radiant_crystals));
update_values.push_back(columns[15] + " = " + std::to_string(character_currency_entry.ebon_crystals));
update_values.push_back(columns[16] + " = " + std::to_string(character_currency_entry.career_ebon_crystals));
auto results = database.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
character_currency_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static CharacterCurrency InsertOne(
CharacterCurrency character_currency_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_currency_entry.platinum));
insert_values.push_back(std::to_string(character_currency_entry.gold));
insert_values.push_back(std::to_string(character_currency_entry.silver));
insert_values.push_back(std::to_string(character_currency_entry.copper));
insert_values.push_back(std::to_string(character_currency_entry.platinum_bank));
insert_values.push_back(std::to_string(character_currency_entry.gold_bank));
insert_values.push_back(std::to_string(character_currency_entry.silver_bank));
insert_values.push_back(std::to_string(character_currency_entry.copper_bank));
insert_values.push_back(std::to_string(character_currency_entry.platinum_cursor));
insert_values.push_back(std::to_string(character_currency_entry.gold_cursor));
insert_values.push_back(std::to_string(character_currency_entry.silver_cursor));
insert_values.push_back(std::to_string(character_currency_entry.copper_cursor));
insert_values.push_back(std::to_string(character_currency_entry.radiant_crystals));
insert_values.push_back(std::to_string(character_currency_entry.career_radiant_crystals));
insert_values.push_back(std::to_string(character_currency_entry.ebon_crystals));
insert_values.push_back(std::to_string(character_currency_entry.career_ebon_crystals));
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
character_currency_entry.id = results.LastInsertedID();
return character_currency_entry;
}
character_currency_entry = NewEntity();
return character_currency_entry;
}
static int InsertMany(
std::vector<CharacterCurrency> character_currency_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_currency_entry: character_currency_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_currency_entry.platinum));
insert_values.push_back(std::to_string(character_currency_entry.gold));
insert_values.push_back(std::to_string(character_currency_entry.silver));
insert_values.push_back(std::to_string(character_currency_entry.copper));
insert_values.push_back(std::to_string(character_currency_entry.platinum_bank));
insert_values.push_back(std::to_string(character_currency_entry.gold_bank));
insert_values.push_back(std::to_string(character_currency_entry.silver_bank));
insert_values.push_back(std::to_string(character_currency_entry.copper_bank));
insert_values.push_back(std::to_string(character_currency_entry.platinum_cursor));
insert_values.push_back(std::to_string(character_currency_entry.gold_cursor));
insert_values.push_back(std::to_string(character_currency_entry.silver_cursor));
insert_values.push_back(std::to_string(character_currency_entry.copper_cursor));
insert_values.push_back(std::to_string(character_currency_entry.radiant_crystals));
insert_values.push_back(std::to_string(character_currency_entry.career_radiant_crystals));
insert_values.push_back(std::to_string(character_currency_entry.ebon_crystals));
insert_values.push_back(std::to_string(character_currency_entry.career_ebon_crystals));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterCurrency> All()
{
std::vector<CharacterCurrency> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterCurrency entry{};
entry.id = atoi(row[0]);
entry.platinum = atoi(row[1]);
entry.gold = atoi(row[2]);
entry.silver = atoi(row[3]);
entry.copper = atoi(row[4]);
entry.platinum_bank = atoi(row[5]);
entry.gold_bank = atoi(row[6]);
entry.silver_bank = atoi(row[7]);
entry.copper_bank = atoi(row[8]);
entry.platinum_cursor = atoi(row[9]);
entry.gold_cursor = atoi(row[10]);
entry.silver_cursor = atoi(row[11]);
entry.copper_cursor = atoi(row[12]);
entry.radiant_crystals = atoi(row[13]);
entry.career_radiant_crystals = atoi(row[14]);
entry.ebon_crystals = atoi(row[15]);
entry.career_ebon_crystals = atoi(row[16]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterCurrency> GetWhere(std::string where_filter)
{
std::vector<CharacterCurrency> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterCurrency entry{};
entry.id = atoi(row[0]);
entry.platinum = atoi(row[1]);
entry.gold = atoi(row[2]);
entry.silver = atoi(row[3]);
entry.copper = atoi(row[4]);
entry.platinum_bank = atoi(row[5]);
entry.gold_bank = atoi(row[6]);
entry.silver_bank = atoi(row[7]);
entry.copper_bank = atoi(row[8]);
entry.platinum_cursor = atoi(row[9]);
entry.gold_cursor = atoi(row[10]);
entry.silver_cursor = atoi(row[11]);
entry.copper_cursor = atoi(row[12]);
entry.radiant_crystals = atoi(row[13]);
entry.career_radiant_crystals = atoi(row[14]);
entry.ebon_crystals = atoi(row[15]);
entry.career_ebon_crystals = atoi(row[16]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_CURRENCY_REPOSITORY_H

File diff suppressed because it is too large Load Diff

View File

@ -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<std::string> Columns()
{
return {
"id",
"slot_id",
"disc_id",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_disciplines");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterDisciplines NewEntity()
{
CharacterDisciplines entry{};
entry.id = 0;
entry.slot_id = 0;
entry.disc_id = 0;
return entry;
}
static CharacterDisciplines GetCharacterDisciplinesEntry(
const std::vector<CharacterDisciplines> &character_discipliness,
int character_disciplines_id
)
{
for (auto &character_disciplines : character_discipliness) {
if (character_disciplines.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<std::string> 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<std::string> 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<CharacterDisciplines> character_disciplines_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_disciplines_entry: character_disciplines_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_disciplines_entry.disc_id));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterDisciplines> All()
{
std::vector<CharacterDisciplines> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterDisciplines entry{};
entry.id = atoi(row[0]);
entry.slot_id = atoi(row[1]);
entry.disc_id = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterDisciplines> GetWhere(std::string where_filter)
{
std::vector<CharacterDisciplines> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterDisciplines entry{};
entry.id = atoi(row[0]);
entry.slot_id = atoi(row[1]);
entry.disc_id = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_DISCIPLINES_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"inspect_message",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_inspect_messages");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterInspectMessages NewEntity()
{
CharacterInspectMessages entry{};
entry.id = 0;
entry.inspect_message = "";
return entry;
}
static CharacterInspectMessages GetCharacterInspectMessagesEntry(
const std::vector<CharacterInspectMessages> &character_inspect_messagess,
int character_inspect_messages_id
)
{
for (auto &character_inspect_messages : character_inspect_messagess) {
if (character_inspect_messages.id == character_inspect_messages_id) {
return character_inspect_messages;
}
}
return NewEntity();
}
static CharacterInspectMessages FindOne(
int character_inspect_messages_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
character_inspect_messages_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterInspectMessages entry{};
entry.id = atoi(row[0]);
entry.inspect_message = row[1] ? row[1] : "";
return entry;
}
return NewEntity();
}
static int DeleteOne(
int character_inspect_messages_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
character_inspect_messages_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
CharacterInspectMessages character_inspect_messages_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + EscapeString(character_inspect_messages_entry.inspect_message) + "'");
auto results = database.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
character_inspect_messages_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static CharacterInspectMessages InsertOne(
CharacterInspectMessages character_inspect_messages_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(character_inspect_messages_entry.inspect_message) + "'");
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
character_inspect_messages_entry.id = results.LastInsertedID();
return character_inspect_messages_entry;
}
character_inspect_messages_entry = NewEntity();
return character_inspect_messages_entry;
}
static int InsertMany(
std::vector<CharacterInspectMessages> character_inspect_messages_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_inspect_messages_entry: character_inspect_messages_entries) {
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(character_inspect_messages_entry.inspect_message) + "'");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterInspectMessages> All()
{
std::vector<CharacterInspectMessages> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterInspectMessages entry{};
entry.id = atoi(row[0]);
entry.inspect_message = row[1] ? row[1] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterInspectMessages> GetWhere(std::string where_filter)
{
std::vector<CharacterInspectMessages> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterInspectMessages entry{};
entry.id = atoi(row[0]);
entry.inspect_message = row[1] ? row[1] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_INSPECT_MESSAGES_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"recast_type",
"timestamp",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_item_recast");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterItemRecast NewEntity()
{
CharacterItemRecast entry{};
entry.id = 0;
entry.recast_type = 0;
entry.timestamp = 0;
return entry;
}
static CharacterItemRecast GetCharacterItemRecastEntry(
const std::vector<CharacterItemRecast> &character_item_recasts,
int character_item_recast_id
)
{
for (auto &character_item_recast : character_item_recasts) {
if (character_item_recast.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<std::string> 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<std::string> 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<CharacterItemRecast> character_item_recast_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_item_recast_entry: character_item_recast_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_item_recast_entry.timestamp));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterItemRecast> All()
{
std::vector<CharacterItemRecast> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterItemRecast entry{};
entry.id = atoi(row[0]);
entry.recast_type = atoi(row[1]);
entry.timestamp = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterItemRecast> GetWhere(std::string where_filter)
{
std::vector<CharacterItemRecast> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterItemRecast entry{};
entry.id = atoi(row[0]);
entry.recast_type = atoi(row[1]);
entry.timestamp = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_ITEM_RECAST_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"lang_id",
"value",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_languages");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterLanguages NewEntity()
{
CharacterLanguages entry{};
entry.id = 0;
entry.lang_id = 0;
entry.value = 0;
return entry;
}
static CharacterLanguages GetCharacterLanguagesEntry(
const std::vector<CharacterLanguages> &character_languagess,
int character_languages_id
)
{
for (auto &character_languages : character_languagess) {
if (character_languages.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<std::string> 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<std::string> 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<CharacterLanguages> character_languages_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_languages_entry: character_languages_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_languages_entry.value));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterLanguages> All()
{
std::vector<CharacterLanguages> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterLanguages entry{};
entry.id = atoi(row[0]);
entry.lang_id = atoi(row[1]);
entry.value = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterLanguages> GetWhere(std::string where_filter)
{
std::vector<CharacterLanguages> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterLanguages entry{};
entry.id = atoi(row[0]);
entry.lang_id = atoi(row[1]);
entry.value = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_LANGUAGES_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"slot",
"rank",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_leadership_abilities");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterLeadershipAbilities NewEntity()
{
CharacterLeadershipAbilities entry{};
entry.id = 0;
entry.slot = 0;
entry.rank = 0;
return entry;
}
static CharacterLeadershipAbilities GetCharacterLeadershipAbilitiesEntry(
const std::vector<CharacterLeadershipAbilities> &character_leadership_abilitiess,
int character_leadership_abilities_id
)
{
for (auto &character_leadership_abilities : character_leadership_abilitiess) {
if (character_leadership_abilities.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<std::string> 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<std::string> 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<CharacterLeadershipAbilities> character_leadership_abilities_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_leadership_abilities_entry: character_leadership_abilities_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_leadership_abilities_entry.rank));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterLeadershipAbilities> All()
{
std::vector<CharacterLeadershipAbilities> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterLeadershipAbilities entry{};
entry.id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.rank = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterLeadershipAbilities> GetWhere(std::string where_filter)
{
std::vector<CharacterLeadershipAbilities> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterLeadershipAbilities entry{};
entry.id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.rank = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_LEADERSHIP_ABILITIES_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"slot",
"blue",
"green",
"red",
"use_tint",
"color",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_material");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterMaterial NewEntity()
{
CharacterMaterial entry{};
entry.id = 0;
entry.slot = 0;
entry.blue = 0;
entry.green = 0;
entry.red = 0;
entry.use_tint = 0;
entry.color = 0;
return entry;
}
static CharacterMaterial GetCharacterMaterialEntry(
const std::vector<CharacterMaterial> &character_materials,
int character_material_id
)
{
for (auto &character_material : character_materials) {
if (character_material.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<std::string> 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<std::string> 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<CharacterMaterial> character_material_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_material_entry: character_material_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_material_entry.blue));
insert_values.push_back(std::to_string(character_material_entry.green));
insert_values.push_back(std::to_string(character_material_entry.red));
insert_values.push_back(std::to_string(character_material_entry.use_tint));
insert_values.push_back(std::to_string(character_material_entry.color));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterMaterial> All()
{
std::vector<CharacterMaterial> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterMaterial entry{};
entry.id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.blue = atoi(row[2]);
entry.green = atoi(row[3]);
entry.red = atoi(row[4]);
entry.use_tint = atoi(row[5]);
entry.color = atoi(row[6]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterMaterial> GetWhere(std::string where_filter)
{
std::vector<CharacterMaterial> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterMaterial entry{};
entry.id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.blue = atoi(row[2]);
entry.green = atoi(row[3]);
entry.red = atoi(row[4]);
entry.use_tint = atoi(row[5]);
entry.color = atoi(row[6]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_MATERIAL_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"slot_id",
"spell_id",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_memmed_spells");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterMemmedSpells NewEntity()
{
CharacterMemmedSpells entry{};
entry.id = 0;
entry.slot_id = 0;
entry.spell_id = 0;
return entry;
}
static CharacterMemmedSpells GetCharacterMemmedSpellsEntry(
const std::vector<CharacterMemmedSpells> &character_memmed_spellss,
int character_memmed_spells_id
)
{
for (auto &character_memmed_spells : character_memmed_spellss) {
if (character_memmed_spells.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<std::string> 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<std::string> 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<CharacterMemmedSpells> character_memmed_spells_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_memmed_spells_entry: character_memmed_spells_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_memmed_spells_entry.spell_id));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterMemmedSpells> All()
{
std::vector<CharacterMemmedSpells> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterMemmedSpells entry{};
entry.id = atoi(row[0]);
entry.slot_id = atoi(row[1]);
entry.spell_id = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterMemmedSpells> GetWhere(std::string where_filter)
{
std::vector<CharacterMemmedSpells> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterMemmedSpells entry{};
entry.id = atoi(row[0]);
entry.slot_id = atoi(row[1]);
entry.spell_id = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_MEMMED_SPELLS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"char_id",
"pet",
"slot",
"spell_id",
"caster_level",
"castername",
"ticsremaining",
"counters",
"numhits",
"rune",
"instrument_mod",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_pet_buffs");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterPetBuffs NewEntity()
{
CharacterPetBuffs entry{};
entry.char_id = 0;
entry.pet = 0;
entry.slot = 0;
entry.spell_id = 0;
entry.caster_level = 0;
entry.castername = "";
entry.ticsremaining = 0;
entry.counters = 0;
entry.numhits = 0;
entry.rune = 0;
entry.instrument_mod = 10;
return entry;
}
static CharacterPetBuffs GetCharacterPetBuffsEntry(
const std::vector<CharacterPetBuffs> &character_pet_buffss,
int character_pet_buffs_id
)
{
for (auto &character_pet_buffs : character_pet_buffss) {
if (character_pet_buffs.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<std::string> 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<std::string> 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<CharacterPetBuffs> character_pet_buffs_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_pet_buffs_entry: character_pet_buffs_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_pet_buffs_entry.spell_id));
insert_values.push_back(std::to_string(character_pet_buffs_entry.caster_level));
insert_values.push_back("'" + EscapeString(character_pet_buffs_entry.castername) + "'");
insert_values.push_back(std::to_string(character_pet_buffs_entry.ticsremaining));
insert_values.push_back(std::to_string(character_pet_buffs_entry.counters));
insert_values.push_back(std::to_string(character_pet_buffs_entry.numhits));
insert_values.push_back(std::to_string(character_pet_buffs_entry.rune));
insert_values.push_back(std::to_string(character_pet_buffs_entry.instrument_mod));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterPetBuffs> All()
{
std::vector<CharacterPetBuffs> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterPetBuffs entry{};
entry.char_id = atoi(row[0]);
entry.pet = atoi(row[1]);
entry.slot = atoi(row[2]);
entry.spell_id = atoi(row[3]);
entry.caster_level = atoi(row[4]);
entry.castername = row[5] ? row[5] : "";
entry.ticsremaining = atoi(row[6]);
entry.counters = atoi(row[7]);
entry.numhits = atoi(row[8]);
entry.rune = atoi(row[9]);
entry.instrument_mod = atoi(row[10]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterPetBuffs> GetWhere(std::string where_filter)
{
std::vector<CharacterPetBuffs> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterPetBuffs entry{};
entry.char_id = atoi(row[0]);
entry.pet = atoi(row[1]);
entry.slot = atoi(row[2]);
entry.spell_id = atoi(row[3]);
entry.caster_level = atoi(row[4]);
entry.castername = row[5] ? row[5] : "";
entry.ticsremaining = atoi(row[6]);
entry.counters = atoi(row[7]);
entry.numhits = atoi(row[8]);
entry.rune = atoi(row[9]);
entry.instrument_mod = atoi(row[10]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_PET_BUFFS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"char_id",
"pet",
"petname",
"petpower",
"spell_id",
"hp",
"mana",
"size",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_pet_info");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterPetInfo NewEntity()
{
CharacterPetInfo entry{};
entry.char_id = 0;
entry.pet = 0;
entry.petname = "";
entry.petpower = 0;
entry.spell_id = 0;
entry.hp = 0;
entry.mana = 0;
entry.size = 0;
return entry;
}
static CharacterPetInfo GetCharacterPetInfoEntry(
const std::vector<CharacterPetInfo> &character_pet_infos,
int character_pet_info_id
)
{
for (auto &character_pet_info : character_pet_infos) {
if (character_pet_info.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<std::string> 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<std::string> 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<CharacterPetInfo> character_pet_info_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_pet_info_entry: character_pet_info_entries) {
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(character_pet_info_entry.petname) + "'");
insert_values.push_back(std::to_string(character_pet_info_entry.petpower));
insert_values.push_back(std::to_string(character_pet_info_entry.spell_id));
insert_values.push_back(std::to_string(character_pet_info_entry.hp));
insert_values.push_back(std::to_string(character_pet_info_entry.mana));
insert_values.push_back(std::to_string(character_pet_info_entry.size));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterPetInfo> All()
{
std::vector<CharacterPetInfo> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterPetInfo entry{};
entry.char_id = atoi(row[0]);
entry.pet = atoi(row[1]);
entry.petname = row[2] ? row[2] : "";
entry.petpower = atoi(row[3]);
entry.spell_id = atoi(row[4]);
entry.hp = atoi(row[5]);
entry.mana = atoi(row[6]);
entry.size = atof(row[7]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterPetInfo> GetWhere(std::string where_filter)
{
std::vector<CharacterPetInfo> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterPetInfo entry{};
entry.char_id = atoi(row[0]);
entry.pet = atoi(row[1]);
entry.petname = row[2] ? row[2] : "";
entry.petpower = atoi(row[3]);
entry.spell_id = atoi(row[4]);
entry.hp = atoi(row[5]);
entry.mana = atoi(row[6]);
entry.size = 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

View File

@ -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<std::string> Columns()
{
return {
"char_id",
"pet",
"slot",
"item_id",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_pet_inventory");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterPetInventory NewEntity()
{
CharacterPetInventory entry{};
entry.char_id = 0;
entry.pet = 0;
entry.slot = 0;
entry.item_id = 0;
return entry;
}
static CharacterPetInventory GetCharacterPetInventoryEntry(
const std::vector<CharacterPetInventory> &character_pet_inventorys,
int character_pet_inventory_id
)
{
for (auto &character_pet_inventory : character_pet_inventorys) {
if (character_pet_inventory.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<std::string> 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<std::string> 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<CharacterPetInventory> character_pet_inventory_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_pet_inventory_entry: character_pet_inventory_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_pet_inventory_entry.item_id));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterPetInventory> All()
{
std::vector<CharacterPetInventory> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterPetInventory entry{};
entry.char_id = atoi(row[0]);
entry.pet = atoi(row[1]);
entry.slot = atoi(row[2]);
entry.item_id = atoi(row[3]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterPetInventory> GetWhere(std::string where_filter)
{
std::vector<CharacterPetInventory> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterPetInventory entry{};
entry.char_id = atoi(row[0]);
entry.pet = atoi(row[1]);
entry.slot = atoi(row[2]);
entry.item_id = atoi(row[3]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_PET_INVENTORY_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"potion_id",
"item_id",
"icon",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_potionbelt");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterPotionbelt NewEntity()
{
CharacterPotionbelt entry{};
entry.id = 0;
entry.potion_id = 0;
entry.item_id = 0;
entry.icon = 0;
return entry;
}
static CharacterPotionbelt GetCharacterPotionbeltEntry(
const std::vector<CharacterPotionbelt> &character_potionbelts,
int character_potionbelt_id
)
{
for (auto &character_potionbelt : character_potionbelts) {
if (character_potionbelt.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<std::string> 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<std::string> 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<CharacterPotionbelt> character_potionbelt_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_potionbelt_entry: character_potionbelt_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_potionbelt_entry.item_id));
insert_values.push_back(std::to_string(character_potionbelt_entry.icon));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterPotionbelt> All()
{
std::vector<CharacterPotionbelt> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterPotionbelt entry{};
entry.id = atoi(row[0]);
entry.potion_id = atoi(row[1]);
entry.item_id = atoi(row[2]);
entry.icon = atoi(row[3]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterPotionbelt> GetWhere(std::string where_filter)
{
std::vector<CharacterPotionbelt> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterPotionbelt entry{};
entry.id = atoi(row[0]);
entry.potion_id = atoi(row[1]);
entry.item_id = atoi(row[2]);
entry.icon = atoi(row[3]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_POTIONBELT_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"skill_id",
"value",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_skills");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterSkills NewEntity()
{
CharacterSkills entry{};
entry.id = 0;
entry.skill_id = 0;
entry.value = 0;
return entry;
}
static CharacterSkills GetCharacterSkillsEntry(
const std::vector<CharacterSkills> &character_skillss,
int character_skills_id
)
{
for (auto &character_skills : character_skillss) {
if (character_skills.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<std::string> 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<std::string> 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<CharacterSkills> character_skills_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_skills_entry: character_skills_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_skills_entry.value));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterSkills> All()
{
std::vector<CharacterSkills> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterSkills entry{};
entry.id = atoi(row[0]);
entry.skill_id = atoi(row[1]);
entry.value = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterSkills> GetWhere(std::string where_filter)
{
std::vector<CharacterSkills> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterSkills entry{};
entry.id = atoi(row[0]);
entry.skill_id = atoi(row[1]);
entry.value = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_SKILLS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"slot_id",
"spell_id",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_spells");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterSpells NewEntity()
{
CharacterSpells entry{};
entry.id = 0;
entry.slot_id = 0;
entry.spell_id = 0;
return entry;
}
static CharacterSpells GetCharacterSpellsEntry(
const std::vector<CharacterSpells> &character_spellss,
int character_spells_id
)
{
for (auto &character_spells : character_spellss) {
if (character_spells.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<std::string> 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<std::string> 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<CharacterSpells> character_spells_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_spells_entry: character_spells_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_spells_entry.spell_id));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterSpells> All()
{
std::vector<CharacterSpells> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterSpells entry{};
entry.id = atoi(row[0]);
entry.slot_id = atoi(row[1]);
entry.spell_id = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterSpells> GetWhere(std::string where_filter)
{
std::vector<CharacterSpells> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterSpells entry{};
entry.id = atoi(row[0]);
entry.slot_id = atoi(row[1]);
entry.spell_id = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_SPELLS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"charid",
"taskid",
"slot",
"type",
"acceptedtime",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_tasks");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CharacterTasks NewEntity()
{
CharacterTasks entry{};
entry.charid = 0;
entry.taskid = 0;
entry.slot = 0;
entry.type = 0;
entry.acceptedtime = 0;
return entry;
}
static CharacterTasks GetCharacterTasksEntry(
const std::vector<CharacterTasks> &character_taskss,
int character_tasks_id
)
{
for (auto &character_tasks : character_taskss) {
if (character_tasks.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<std::string> 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<std::string> 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<CharacterTasks> character_tasks_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_tasks_entry: character_tasks_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(character_tasks_entry.slot));
insert_values.push_back(std::to_string(character_tasks_entry.type));
insert_values.push_back(std::to_string(character_tasks_entry.acceptedtime));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterTasks> All()
{
std::vector<CharacterTasks> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterTasks entry{};
entry.charid = atoi(row[0]);
entry.taskid = atoi(row[1]);
entry.slot = atoi(row[2]);
entry.type = atoi(row[3]);
entry.acceptedtime = atoi(row[4]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterTasks> GetWhere(std::string where_filter)
{
std::vector<CharacterTasks> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterTasks entry{};
entry.charid = atoi(row[0]);
entry.taskid = atoi(row[1]);
entry.slot = atoi(row[2]);
entry.type = atoi(row[3]);
entry.acceptedtime = atoi(row[4]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_CHARACTER_TASKS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"tier",
"tribute",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("character_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<CharacterTribute> &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<std::string> 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<std::string> 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<CharacterTribute> character_tribute_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_tribute_entry: character_tribute_entries) {
std::vector<std::string> 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<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterTribute> All()
{
std::vector<CharacterTribute> 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<CharacterTribute> GetWhere(std::string where_filter)
{
std::vector<CharacterTribute> 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

View File

@ -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<std::string> Columns()
{
return {
"name",
"owner",
"password",
"minstatus",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("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<Chatchannels> &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<std::string> 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<std::string> 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> chatchannels_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &chatchannels_entry: chatchannels_entries) {
std::vector<std::string> 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<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Chatchannels> All()
{
std::vector<Chatchannels> 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<Chatchannels> GetWhere(std::string where_filter)
{
std::vector<Chatchannels> 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

View File

@ -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<std::string> Columns()
{
return {
"command",
"access",
"aliases",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("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<CommandSettings> &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<std::string> 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<std::string> 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<CommandSettings> command_settings_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &command_settings_entry: command_settings_entries) {
std::vector<std::string> 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<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CommandSettings> All()
{
std::vector<CommandSettings> 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<CommandSettings> GetWhere(std::string where_filter)
{
std::vector<CommandSettings> 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

View File

@ -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<std::string> Columns()
{
return {
"charid",
"completedtime",
"taskid",
"activityid",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("completed_tasks");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static CompletedTasks NewEntity()
{
CompletedTasks entry{};
entry.charid = 0;
entry.completedtime = 0;
entry.taskid = 0;
entry.activityid = 0;
return entry;
}
static CompletedTasks GetCompletedTasksEntry(
const std::vector<CompletedTasks> &completed_taskss,
int completed_tasks_id
)
{
for (auto &completed_tasks : completed_taskss) {
if (completed_tasks.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<std::string> 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<std::string> 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<CompletedTasks> completed_tasks_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &completed_tasks_entry: completed_tasks_entries) {
std::vector<std::string> insert_values;
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CompletedTasks> All()
{
std::vector<CompletedTasks> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CompletedTasks entry{};
entry.charid = atoi(row[0]);
entry.completedtime = atoi(row[1]);
entry.taskid = atoi(row[2]);
entry.activityid = atoi(row[3]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CompletedTasks> GetWhere(std::string where_filter)
{
std::vector<CompletedTasks> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CompletedTasks entry{};
entry.charid = atoi(row[0]);
entry.completedtime = atoi(row[1]);
entry.taskid = atoi(row[2]);
entry.activityid = atoi(row[3]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_COMPLETED_TASKS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"key",
"value",
"expires",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("data_buckets");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static DataBuckets NewEntity()
{
DataBuckets entry{};
entry.id = 0;
entry.key = "";
entry.value = "";
entry.expires = 0;
return entry;
}
static DataBuckets GetDataBucketsEntry(
const std::vector<DataBuckets> &data_bucketss,
int data_buckets_id
)
{
for (auto &data_buckets : data_bucketss) {
if (data_buckets.id == data_buckets_id) {
return data_buckets;
}
}
return NewEntity();
}
static DataBuckets FindOne(
int data_buckets_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
data_buckets_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
DataBuckets entry{};
entry.id = atoi(row[0]);
entry.key = row[1] ? row[1] : "";
entry.value = row[2] ? row[2] : "";
entry.expires = atoi(row[3]);
return entry;
}
return NewEntity();
}
static int DeleteOne(
int data_buckets_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
data_buckets_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
DataBuckets data_buckets_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + EscapeString(data_buckets_entry.key) + "'");
update_values.push_back(columns[2] + " = '" + EscapeString(data_buckets_entry.value) + "'");
update_values.push_back(columns[3] + " = " + std::to_string(data_buckets_entry.expires));
auto results = database.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
data_buckets_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static DataBuckets InsertOne(
DataBuckets data_buckets_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(data_buckets_entry.key) + "'");
insert_values.push_back("'" + EscapeString(data_buckets_entry.value) + "'");
insert_values.push_back(std::to_string(data_buckets_entry.expires));
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
data_buckets_entry.id = results.LastInsertedID();
return data_buckets_entry;
}
data_buckets_entry = NewEntity();
return data_buckets_entry;
}
static int InsertMany(
std::vector<DataBuckets> data_buckets_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &data_buckets_entry: data_buckets_entries) {
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(data_buckets_entry.key) + "'");
insert_values.push_back("'" + EscapeString(data_buckets_entry.value) + "'");
insert_values.push_back(std::to_string(data_buckets_entry.expires));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<DataBuckets> All()
{
std::vector<DataBuckets> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
DataBuckets entry{};
entry.id = atoi(row[0]);
entry.key = row[1] ? row[1] : "";
entry.value = row[2] ? row[2] : "";
entry.expires = atoi(row[3]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<DataBuckets> GetWhere(std::string where_filter)
{
std::vector<DataBuckets> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
DataBuckets entry{};
entry.id = atoi(row[0]);
entry.key = row[1] ? row[1] : "";
entry.value = row[2] ? row[2] : "";
entry.expires = atoi(row[3]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_DATA_BUCKETS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"type",
"value",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("db_str");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static DbStr NewEntity()
{
DbStr entry{};
entry.id = 0;
entry.type = 0;
entry.value = "";
return entry;
}
static DbStr GetDbStrEntry(
const std::vector<DbStr> &db_strs,
int db_str_id
)
{
for (auto &db_str : db_strs) {
if (db_str.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<std::string> 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<std::string> 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<DbStr> db_str_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &db_str_entry: db_str_entries) {
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(db_str_entry.value) + "'");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<DbStr> All()
{
std::vector<DbStr> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
DbStr entry{};
entry.id = atoi(row[0]);
entry.type = atoi(row[1]);
entry.value = row[2] ? row[2] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<DbStr> GetWhere(std::string where_filter)
{
std::vector<DbStr> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
DbStr entry{};
entry.id = atoi(row[0]);
entry.type = atoi(row[1]);
entry.value = row[2] ? row[2] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_DB_STR_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"item_id",
"char_name",
"discovered_date",
"account_status",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("discovered_items");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static DiscoveredItems NewEntity()
{
DiscoveredItems entry{};
entry.item_id = 0;
entry.char_name = "";
entry.discovered_date = 0;
entry.account_status = 0;
return entry;
}
static DiscoveredItems GetDiscoveredItemsEntry(
const std::vector<DiscoveredItems> &discovered_itemss,
int discovered_items_id
)
{
for (auto &discovered_items : discovered_itemss) {
if (discovered_items.item_id == discovered_items_id) {
return discovered_items;
}
}
return NewEntity();
}
static DiscoveredItems FindOne(
int discovered_items_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
discovered_items_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
DiscoveredItems entry{};
entry.item_id = atoi(row[0]);
entry.char_name = row[1] ? row[1] : "";
entry.discovered_date = atoi(row[2]);
entry.account_status = atoi(row[3]);
return entry;
}
return NewEntity();
}
static int DeleteOne(
int discovered_items_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
discovered_items_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
DiscoveredItems discovered_items_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + EscapeString(discovered_items_entry.char_name) + "'");
update_values.push_back(columns[2] + " = " + std::to_string(discovered_items_entry.discovered_date));
update_values.push_back(columns[3] + " = " + std::to_string(discovered_items_entry.account_status));
auto results = database.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
discovered_items_entry.item_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static DiscoveredItems InsertOne(
DiscoveredItems discovered_items_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back("'" + 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<DiscoveredItems> discovered_items_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &discovered_items_entry: discovered_items_entries) {
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(discovered_items_entry.char_name) + "'");
insert_values.push_back(std::to_string(discovered_items_entry.discovered_date));
insert_values.push_back(std::to_string(discovered_items_entry.account_status));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<DiscoveredItems> All()
{
std::vector<DiscoveredItems> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
DiscoveredItems entry{};
entry.item_id = atoi(row[0]);
entry.char_name = row[1] ? row[1] : "";
entry.discovered_date = atoi(row[2]);
entry.account_status = atoi(row[3]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<DiscoveredItems> GetWhere(std::string where_filter)
{
std::vector<DiscoveredItems> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
DiscoveredItems entry{};
entry.item_id = atoi(row[0]);
entry.char_name = row[1] ? row[1] : "";
entry.discovered_date = atoi(row[2]);
entry.account_status = atoi(row[3]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_DISCOVERED_ITEMS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"doorid",
"zone",
"version",
"name",
"pos_y",
"pos_x",
"pos_z",
"heading",
"opentype",
"guild",
"lockpick",
"keyitem",
"nokeyring",
"triggerdoor",
"triggertype",
"disable_timer",
"doorisopen",
"door_param",
"dest_zone",
"dest_instance",
"dest_x",
"dest_y",
"dest_z",
"dest_heading",
"invert_state",
"incline",
"size",
"buffer",
"client_version_mask",
"is_ldon_door",
"min_expansion",
"max_expansion",
"content_flags",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("doors");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static Doors NewEntity()
{
Doors entry{};
entry.id = 0;
entry.doorid = 0;
entry.zone = "";
entry.version = 0;
entry.name = "";
entry.pos_y = 0;
entry.pos_x = 0;
entry.pos_z = 0;
entry.heading = 0;
entry.opentype = 0;
entry.guild = 0;
entry.lockpick = 0;
entry.keyitem = 0;
entry.nokeyring = 0;
entry.triggerdoor = 0;
entry.triggertype = 0;
entry.disable_timer = 0;
entry.doorisopen = 0;
entry.door_param = 0;
entry.dest_zone = "NONE";
entry.dest_instance = 0;
entry.dest_x = 0;
entry.dest_y = 0;
entry.dest_z = 0;
entry.dest_heading = 0;
entry.invert_state = 0;
entry.incline = 0;
entry.size = 100;
entry.buffer = 0;
entry.client_version_mask = 4294967295;
entry.is_ldon_door = 0;
entry.min_expansion = 0;
entry.max_expansion = 0;
entry.content_flags = "";
return entry;
}
static Doors GetDoorsEntry(
const std::vector<Doors> &doorss,
int doors_id
)
{
for (auto &doors : doorss) {
if (doors.id == doors_id) {
return doors;
}
}
return NewEntity();
}
static Doors FindOne(
int doors_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
doors_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
Doors entry{};
entry.id = atoi(row[0]);
entry.doorid = atoi(row[1]);
entry.zone = row[2] ? row[2] : "";
entry.version = atoi(row[3]);
entry.name = row[4] ? row[4] : "";
entry.pos_y = 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<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(doors_entry.doorid));
update_values.push_back(columns[2] + " = '" + EscapeString(doors_entry.zone) + "'");
update_values.push_back(columns[3] + " = " + std::to_string(doors_entry.version));
update_values.push_back(columns[4] + " = '" + EscapeString(doors_entry.name) + "'");
update_values.push_back(columns[5] + " = " + std::to_string(doors_entry.pos_y));
update_values.push_back(columns[6] + " = " + std::to_string(doors_entry.pos_x));
update_values.push_back(columns[7] + " = " + std::to_string(doors_entry.pos_z));
update_values.push_back(columns[8] + " = " + std::to_string(doors_entry.heading));
update_values.push_back(columns[9] + " = " + std::to_string(doors_entry.opentype));
update_values.push_back(columns[10] + " = " + std::to_string(doors_entry.guild));
update_values.push_back(columns[11] + " = " + std::to_string(doors_entry.lockpick));
update_values.push_back(columns[12] + " = " + std::to_string(doors_entry.keyitem));
update_values.push_back(columns[13] + " = " + std::to_string(doors_entry.nokeyring));
update_values.push_back(columns[14] + " = " + std::to_string(doors_entry.triggerdoor));
update_values.push_back(columns[15] + " = " + std::to_string(doors_entry.triggertype));
update_values.push_back(columns[16] + " = " + std::to_string(doors_entry.disable_timer));
update_values.push_back(columns[17] + " = " + std::to_string(doors_entry.doorisopen));
update_values.push_back(columns[18] + " = " + std::to_string(doors_entry.door_param));
update_values.push_back(columns[19] + " = '" + EscapeString(doors_entry.dest_zone) + "'");
update_values.push_back(columns[20] + " = " + std::to_string(doors_entry.dest_instance));
update_values.push_back(columns[21] + " = " + std::to_string(doors_entry.dest_x));
update_values.push_back(columns[22] + " = " + std::to_string(doors_entry.dest_y));
update_values.push_back(columns[23] + " = " + std::to_string(doors_entry.dest_z));
update_values.push_back(columns[24] + " = " + std::to_string(doors_entry.dest_heading));
update_values.push_back(columns[25] + " = " + std::to_string(doors_entry.invert_state));
update_values.push_back(columns[26] + " = " + std::to_string(doors_entry.incline));
update_values.push_back(columns[27] + " = " + std::to_string(doors_entry.size));
update_values.push_back(columns[28] + " = " + std::to_string(doors_entry.buffer));
update_values.push_back(columns[29] + " = " + std::to_string(doors_entry.client_version_mask));
update_values.push_back(columns[30] + " = " + std::to_string(doors_entry.is_ldon_door));
update_values.push_back(columns[31] + " = " + std::to_string(doors_entry.min_expansion));
update_values.push_back(columns[32] + " = " + std::to_string(doors_entry.max_expansion));
update_values.push_back(columns[33] + " = '" + EscapeString(doors_entry.content_flags) + "'");
auto results = content_db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
doors_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static Doors InsertOne(
Doors doors_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(doors_entry.doorid));
insert_values.push_back("'" + EscapeString(doors_entry.zone) + "'");
insert_values.push_back(std::to_string(doors_entry.version));
insert_values.push_back("'" + EscapeString(doors_entry.name) + "'");
insert_values.push_back(std::to_string(doors_entry.pos_y));
insert_values.push_back(std::to_string(doors_entry.pos_x));
insert_values.push_back(std::to_string(doors_entry.pos_z));
insert_values.push_back(std::to_string(doors_entry.heading));
insert_values.push_back(std::to_string(doors_entry.opentype));
insert_values.push_back(std::to_string(doors_entry.guild));
insert_values.push_back(std::to_string(doors_entry.lockpick));
insert_values.push_back(std::to_string(doors_entry.keyitem));
insert_values.push_back(std::to_string(doors_entry.nokeyring));
insert_values.push_back(std::to_string(doors_entry.triggerdoor));
insert_values.push_back(std::to_string(doors_entry.triggertype));
insert_values.push_back(std::to_string(doors_entry.disable_timer));
insert_values.push_back(std::to_string(doors_entry.doorisopen));
insert_values.push_back(std::to_string(doors_entry.door_param));
insert_values.push_back("'" + EscapeString(doors_entry.dest_zone) + "'");
insert_values.push_back(std::to_string(doors_entry.dest_instance));
insert_values.push_back(std::to_string(doors_entry.dest_x));
insert_values.push_back(std::to_string(doors_entry.dest_y));
insert_values.push_back(std::to_string(doors_entry.dest_z));
insert_values.push_back(std::to_string(doors_entry.dest_heading));
insert_values.push_back(std::to_string(doors_entry.invert_state));
insert_values.push_back(std::to_string(doors_entry.incline));
insert_values.push_back(std::to_string(doors_entry.size));
insert_values.push_back(std::to_string(doors_entry.buffer));
insert_values.push_back(std::to_string(doors_entry.client_version_mask));
insert_values.push_back(std::to_string(doors_entry.is_ldon_door));
insert_values.push_back(std::to_string(doors_entry.min_expansion));
insert_values.push_back(std::to_string(doors_entry.max_expansion));
insert_values.push_back("'" + EscapeString(doors_entry.content_flags) + "'");
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
doors_entry.id = results.LastInsertedID();
return doors_entry;
}
doors_entry = NewEntity();
return doors_entry;
}
static int InsertMany(
std::vector<Doors> doors_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &doors_entry: doors_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(doors_entry.doorid));
insert_values.push_back("'" + EscapeString(doors_entry.zone) + "'");
insert_values.push_back(std::to_string(doors_entry.version));
insert_values.push_back("'" + EscapeString(doors_entry.name) + "'");
insert_values.push_back(std::to_string(doors_entry.pos_y));
insert_values.push_back(std::to_string(doors_entry.pos_x));
insert_values.push_back(std::to_string(doors_entry.pos_z));
insert_values.push_back(std::to_string(doors_entry.heading));
insert_values.push_back(std::to_string(doors_entry.opentype));
insert_values.push_back(std::to_string(doors_entry.guild));
insert_values.push_back(std::to_string(doors_entry.lockpick));
insert_values.push_back(std::to_string(doors_entry.keyitem));
insert_values.push_back(std::to_string(doors_entry.nokeyring));
insert_values.push_back(std::to_string(doors_entry.triggerdoor));
insert_values.push_back(std::to_string(doors_entry.triggertype));
insert_values.push_back(std::to_string(doors_entry.disable_timer));
insert_values.push_back(std::to_string(doors_entry.doorisopen));
insert_values.push_back(std::to_string(doors_entry.door_param));
insert_values.push_back("'" + EscapeString(doors_entry.dest_zone) + "'");
insert_values.push_back(std::to_string(doors_entry.dest_instance));
insert_values.push_back(std::to_string(doors_entry.dest_x));
insert_values.push_back(std::to_string(doors_entry.dest_y));
insert_values.push_back(std::to_string(doors_entry.dest_z));
insert_values.push_back(std::to_string(doors_entry.dest_heading));
insert_values.push_back(std::to_string(doors_entry.invert_state));
insert_values.push_back(std::to_string(doors_entry.incline));
insert_values.push_back(std::to_string(doors_entry.size));
insert_values.push_back(std::to_string(doors_entry.buffer));
insert_values.push_back(std::to_string(doors_entry.client_version_mask));
insert_values.push_back(std::to_string(doors_entry.is_ldon_door));
insert_values.push_back(std::to_string(doors_entry.min_expansion));
insert_values.push_back(std::to_string(doors_entry.max_expansion));
insert_values.push_back("'" + EscapeString(doors_entry.content_flags) + "'");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Doors> All()
{
std::vector<Doors> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Doors entry{};
entry.id = atoi(row[0]);
entry.doorid = atoi(row[1]);
entry.zone = row[2] ? row[2] : "";
entry.version = atoi(row[3]);
entry.name = row[4] ? row[4] : "";
entry.pos_y = 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<Doors> GetWhere(std::string where_filter)
{
std::vector<Doors> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Doors entry{};
entry.id = atoi(row[0]);
entry.doorid = atoi(row[1]);
entry.zone = row[2] ? row[2] : "";
entry.version = atoi(row[3]);
entry.name = row[4] ? row[4] : "";
entry.pos_y = 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

View File

@ -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<std::string> Columns()
{
return {
"id",
"accountname",
"accountid",
"status",
"charname",
"target",
"time",
"descriptiontype",
"description",
"event_nid",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("eventlog");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static Eventlog NewEntity()
{
Eventlog entry{};
entry.id = 0;
entry.accountname = "";
entry.accountid = 0;
entry.status = 0;
entry.charname = "";
entry.target = "None";
entry.time = current_timestamp();
entry.descriptiontype = "";
entry.description = "";
entry.event_nid = 0;
return entry;
}
static Eventlog GetEventlogEntry(
const std::vector<Eventlog> &eventlogs,
int eventlog_id
)
{
for (auto &eventlog : eventlogs) {
if (eventlog.id == eventlog_id) {
return eventlog;
}
}
return NewEntity();
}
static Eventlog FindOne(
int eventlog_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
eventlog_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
Eventlog entry{};
entry.id = atoi(row[0]);
entry.accountname = row[1] ? row[1] : "";
entry.accountid = atoi(row[2]);
entry.status = atoi(row[3]);
entry.charname = row[4] ? row[4] : "";
entry.target = row[5] ? row[5] : "";
entry.time = row[6] ? row[6] : "";
entry.descriptiontype = row[7] ? row[7] : "";
entry.description = row[8] ? row[8] : "";
entry.event_nid = atoi(row[9]);
return entry;
}
return NewEntity();
}
static int DeleteOne(
int eventlog_id
)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
eventlog_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Eventlog eventlog_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + EscapeString(eventlog_entry.accountname) + "'");
update_values.push_back(columns[2] + " = " + std::to_string(eventlog_entry.accountid));
update_values.push_back(columns[3] + " = " + std::to_string(eventlog_entry.status));
update_values.push_back(columns[4] + " = '" + EscapeString(eventlog_entry.charname) + "'");
update_values.push_back(columns[5] + " = '" + EscapeString(eventlog_entry.target) + "'");
update_values.push_back(columns[6] + " = '" + EscapeString(eventlog_entry.time) + "'");
update_values.push_back(columns[7] + " = '" + EscapeString(eventlog_entry.descriptiontype) + "'");
update_values.push_back(columns[8] + " = '" + EscapeString(eventlog_entry.description) + "'");
update_values.push_back(columns[9] + " = " + std::to_string(eventlog_entry.event_nid));
auto results = database.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
eventlog_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static Eventlog InsertOne(
Eventlog eventlog_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(eventlog_entry.accountname) + "'");
insert_values.push_back(std::to_string(eventlog_entry.accountid));
insert_values.push_back(std::to_string(eventlog_entry.status));
insert_values.push_back("'" + EscapeString(eventlog_entry.charname) + "'");
insert_values.push_back("'" + EscapeString(eventlog_entry.target) + "'");
insert_values.push_back("'" + EscapeString(eventlog_entry.time) + "'");
insert_values.push_back("'" + EscapeString(eventlog_entry.descriptiontype) + "'");
insert_values.push_back("'" + EscapeString(eventlog_entry.description) + "'");
insert_values.push_back(std::to_string(eventlog_entry.event_nid));
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
eventlog_entry.id = results.LastInsertedID();
return eventlog_entry;
}
eventlog_entry = NewEntity();
return eventlog_entry;
}
static int InsertMany(
std::vector<Eventlog> eventlog_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &eventlog_entry: eventlog_entries) {
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(eventlog_entry.accountname) + "'");
insert_values.push_back(std::to_string(eventlog_entry.accountid));
insert_values.push_back(std::to_string(eventlog_entry.status));
insert_values.push_back("'" + EscapeString(eventlog_entry.charname) + "'");
insert_values.push_back("'" + EscapeString(eventlog_entry.target) + "'");
insert_values.push_back("'" + EscapeString(eventlog_entry.time) + "'");
insert_values.push_back("'" + EscapeString(eventlog_entry.descriptiontype) + "'");
insert_values.push_back("'" + EscapeString(eventlog_entry.description) + "'");
insert_values.push_back(std::to_string(eventlog_entry.event_nid));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Eventlog> All()
{
std::vector<Eventlog> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Eventlog entry{};
entry.id = atoi(row[0]);
entry.accountname = row[1] ? row[1] : "";
entry.accountid = atoi(row[2]);
entry.status = atoi(row[3]);
entry.charname = row[4] ? row[4] : "";
entry.target = row[5] ? row[5] : "";
entry.time = row[6] ? row[6] : "";
entry.descriptiontype = row[7] ? row[7] : "";
entry.description = row[8] ? row[8] : "";
entry.event_nid = atoi(row[9]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<Eventlog> GetWhere(std::string where_filter)
{
std::vector<Eventlog> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Eventlog entry{};
entry.id = atoi(row[0]);
entry.accountname = row[1] ? row[1] : "";
entry.accountid = atoi(row[2]);
entry.status = atoi(row[3]);
entry.charname = row[4] ? row[4] : "";
entry.target = row[5] ? row[5] : "";
entry.time = row[6] ? row[6] : "";
entry.descriptiontype = row[7] ? row[7] : "";
entry.description = row[8] ? row[8] : "";
entry.event_nid = atoi(row[9]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_EVENTLOG_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"client_faction_id",
"min",
"max",
"unk_hero1",
"unk_hero2",
"unk_hero3",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("faction_base_data");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static FactionBaseData NewEntity()
{
FactionBaseData entry{};
entry.client_faction_id = 0;
entry.min = -2000;
entry.max = 2000;
entry.unk_hero1 = 0;
entry.unk_hero2 = 0;
entry.unk_hero3 = 0;
return entry;
}
static FactionBaseData GetFactionBaseDataEntry(
const std::vector<FactionBaseData> &faction_base_datas,
int faction_base_data_id
)
{
for (auto &faction_base_data : faction_base_datas) {
if (faction_base_data.client_faction_id == faction_base_data_id) {
return faction_base_data;
}
}
return NewEntity();
}
static FactionBaseData FindOne(
int faction_base_data_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
faction_base_data_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
FactionBaseData entry{};
entry.client_faction_id = atoi(row[0]);
entry.min = atoi(row[1]);
entry.max = atoi(row[2]);
entry.unk_hero1 = atoi(row[3]);
entry.unk_hero2 = atoi(row[4]);
entry.unk_hero3 = atoi(row[5]);
return entry;
}
return NewEntity();
}
static int DeleteOne(
int faction_base_data_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
faction_base_data_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
FactionBaseData faction_base_data_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(faction_base_data_entry.min));
update_values.push_back(columns[2] + " = " + std::to_string(faction_base_data_entry.max));
update_values.push_back(columns[3] + " = " + std::to_string(faction_base_data_entry.unk_hero1));
update_values.push_back(columns[4] + " = " + std::to_string(faction_base_data_entry.unk_hero2));
update_values.push_back(columns[5] + " = " + std::to_string(faction_base_data_entry.unk_hero3));
auto results = content_db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
faction_base_data_entry.client_faction_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static FactionBaseData InsertOne(
FactionBaseData faction_base_data_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(faction_base_data_entry.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<FactionBaseData> faction_base_data_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &faction_base_data_entry: faction_base_data_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(faction_base_data_entry.min));
insert_values.push_back(std::to_string(faction_base_data_entry.max));
insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero1));
insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero2));
insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero3));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<FactionBaseData> All()
{
std::vector<FactionBaseData> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
FactionBaseData entry{};
entry.client_faction_id = atoi(row[0]);
entry.min = atoi(row[1]);
entry.max = atoi(row[2]);
entry.unk_hero1 = atoi(row[3]);
entry.unk_hero2 = atoi(row[4]);
entry.unk_hero3 = atoi(row[5]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<FactionBaseData> GetWhere(std::string where_filter)
{
std::vector<FactionBaseData> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
FactionBaseData entry{};
entry.client_faction_id = atoi(row[0]);
entry.min = atoi(row[1]);
entry.max = atoi(row[2]);
entry.unk_hero1 = atoi(row[3]);
entry.unk_hero2 = atoi(row[4]);
entry.unk_hero3 = atoi(row[5]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_FACTION_BASE_DATA_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"faction_id",
"mod",
"mod_name",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("faction_list_mod");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static FactionListMod NewEntity()
{
FactionListMod entry{};
entry.id = 0;
entry.faction_id = 0;
entry.mod = 0;
entry.mod_name = "";
return entry;
}
static FactionListMod GetFactionListModEntry(
const std::vector<FactionListMod> &faction_list_mods,
int faction_list_mod_id
)
{
for (auto &faction_list_mod : faction_list_mods) {
if (faction_list_mod.id == faction_list_mod_id) {
return faction_list_mod;
}
}
return NewEntity();
}
static FactionListMod FindOne(
int faction_list_mod_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
faction_list_mod_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
FactionListMod entry{};
entry.id = atoi(row[0]);
entry.faction_id = atoi(row[1]);
entry.mod = atoi(row[2]);
entry.mod_name = row[3] ? row[3] : "";
return entry;
}
return NewEntity();
}
static int DeleteOne(
int faction_list_mod_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
faction_list_mod_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
FactionListMod faction_list_mod_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(faction_list_mod_entry.faction_id));
update_values.push_back(columns[2] + " = " + std::to_string(faction_list_mod_entry.mod));
update_values.push_back(columns[3] + " = '" + EscapeString(faction_list_mod_entry.mod_name) + "'");
auto results = content_db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
faction_list_mod_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static FactionListMod InsertOne(
FactionListMod faction_list_mod_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(faction_list_mod_entry.faction_id));
insert_values.push_back(std::to_string(faction_list_mod_entry.mod));
insert_values.push_back("'" + EscapeString(faction_list_mod_entry.mod_name) + "'");
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
faction_list_mod_entry.id = results.LastInsertedID();
return faction_list_mod_entry;
}
faction_list_mod_entry = NewEntity();
return faction_list_mod_entry;
}
static int InsertMany(
std::vector<FactionListMod> faction_list_mod_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &faction_list_mod_entry: faction_list_mod_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(faction_list_mod_entry.faction_id));
insert_values.push_back(std::to_string(faction_list_mod_entry.mod));
insert_values.push_back("'" + EscapeString(faction_list_mod_entry.mod_name) + "'");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<FactionListMod> All()
{
std::vector<FactionListMod> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
FactionListMod entry{};
entry.id = atoi(row[0]);
entry.faction_id = atoi(row[1]);
entry.mod = atoi(row[2]);
entry.mod_name = row[3] ? row[3] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<FactionListMod> GetWhere(std::string where_filter)
{
std::vector<FactionListMod> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
FactionListMod entry{};
entry.id = atoi(row[0]);
entry.faction_id = atoi(row[1]);
entry.mod = atoi(row[2]);
entry.mod_name = row[3] ? row[3] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_FACTION_LIST_MOD_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"name",
"base",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("faction_list");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static FactionList NewEntity()
{
FactionList entry{};
entry.id = 0;
entry.name = "";
entry.base = 0;
return entry;
}
static FactionList GetFactionListEntry(
const std::vector<FactionList> &faction_lists,
int faction_list_id
)
{
for (auto &faction_list : faction_lists) {
if (faction_list.id == faction_list_id) {
return faction_list;
}
}
return NewEntity();
}
static FactionList FindOne(
int faction_list_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
faction_list_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
FactionList entry{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.base = atoi(row[2]);
return entry;
}
return NewEntity();
}
static int DeleteOne(
int faction_list_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
faction_list_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
FactionList faction_list_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + EscapeString(faction_list_entry.name) + "'");
update_values.push_back(columns[2] + " = " + std::to_string(faction_list_entry.base));
auto results = content_db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
faction_list_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static FactionList InsertOne(
FactionList faction_list_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(faction_list_entry.name) + "'");
insert_values.push_back(std::to_string(faction_list_entry.base));
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
faction_list_entry.id = results.LastInsertedID();
return faction_list_entry;
}
faction_list_entry = NewEntity();
return faction_list_entry;
}
static int InsertMany(
std::vector<FactionList> faction_list_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &faction_list_entry: faction_list_entries) {
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(faction_list_entry.name) + "'");
insert_values.push_back(std::to_string(faction_list_entry.base));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<FactionList> All()
{
std::vector<FactionList> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
FactionList entry{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.base = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<FactionList> GetWhere(std::string where_filter)
{
std::vector<FactionList> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
FactionList entry{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.base = atoi(row[2]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_FACTION_LIST_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"char_id",
"faction_id",
"current_value",
"temp",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("faction_values");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static FactionValues NewEntity()
{
FactionValues entry{};
entry.char_id = 0;
entry.faction_id = 0;
entry.current_value = 0;
entry.temp = 0;
return entry;
}
static FactionValues GetFactionValuesEntry(
const std::vector<FactionValues> &faction_valuess,
int faction_values_id
)
{
for (auto &faction_values : faction_valuess) {
if (faction_values.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<std::string> 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<std::string> 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<FactionValues> faction_values_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &faction_values_entry: faction_values_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(faction_values_entry.current_value));
insert_values.push_back(std::to_string(faction_values_entry.temp));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<FactionValues> All()
{
std::vector<FactionValues> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
FactionValues entry{};
entry.char_id = atoi(row[0]);
entry.faction_id = atoi(row[1]);
entry.current_value = atoi(row[2]);
entry.temp = atoi(row[3]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<FactionValues> GetWhere(std::string where_filter)
{
std::vector<FactionValues> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
FactionValues entry{};
entry.char_id = atoi(row[0]);
entry.faction_id = atoi(row[1]);
entry.current_value = atoi(row[2]);
entry.temp = atoi(row[3]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_FACTION_VALUES_REPOSITORY_H

View File

@ -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<std::string> 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<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("fishing");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static Fishing NewEntity()
{
Fishing entry{};
entry.id = 0;
entry.zoneid = 0;
entry.Itemid = 0;
entry.skill_level = 0;
entry.chance = 0;
entry.npc_id = 0;
entry.npc_chance = 0;
entry.min_expansion = 0;
entry.max_expansion = 0;
entry.content_flags = "";
return entry;
}
static Fishing GetFishingEntry(
const std::vector<Fishing> &fishings,
int fishing_id
)
{
for (auto &fishing : fishings) {
if (fishing.id == fishing_id) {
return fishing;
}
}
return NewEntity();
}
static Fishing FindOne(
int fishing_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
fishing_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
Fishing entry{};
entry.id = atoi(row[0]);
entry.zoneid = atoi(row[1]);
entry.Itemid = atoi(row[2]);
entry.skill_level = atoi(row[3]);
entry.chance = atoi(row[4]);
entry.npc_id = atoi(row[5]);
entry.npc_chance = atoi(row[6]);
entry.min_expansion = atoi(row[7]);
entry.max_expansion = atoi(row[8]);
entry.content_flags = row[9] ? row[9] : "";
return entry;
}
return NewEntity();
}
static int DeleteOne(
int fishing_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
fishing_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Fishing fishing_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(fishing_entry.zoneid));
update_values.push_back(columns[2] + " = " + std::to_string(fishing_entry.Itemid));
update_values.push_back(columns[3] + " = " + std::to_string(fishing_entry.skill_level));
update_values.push_back(columns[4] + " = " + std::to_string(fishing_entry.chance));
update_values.push_back(columns[5] + " = " + std::to_string(fishing_entry.npc_id));
update_values.push_back(columns[6] + " = " + std::to_string(fishing_entry.npc_chance));
update_values.push_back(columns[7] + " = " + std::to_string(fishing_entry.min_expansion));
update_values.push_back(columns[8] + " = " + std::to_string(fishing_entry.max_expansion));
update_values.push_back(columns[9] + " = '" + EscapeString(fishing_entry.content_flags) + "'");
auto results = content_db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
fishing_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static Fishing InsertOne(
Fishing fishing_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(fishing_entry.zoneid));
insert_values.push_back(std::to_string(fishing_entry.Itemid));
insert_values.push_back(std::to_string(fishing_entry.skill_level));
insert_values.push_back(std::to_string(fishing_entry.chance));
insert_values.push_back(std::to_string(fishing_entry.npc_id));
insert_values.push_back(std::to_string(fishing_entry.npc_chance));
insert_values.push_back(std::to_string(fishing_entry.min_expansion));
insert_values.push_back(std::to_string(fishing_entry.max_expansion));
insert_values.push_back("'" + EscapeString(fishing_entry.content_flags) + "'");
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
fishing_entry.id = results.LastInsertedID();
return fishing_entry;
}
fishing_entry = NewEntity();
return fishing_entry;
}
static int InsertMany(
std::vector<Fishing> fishing_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &fishing_entry: fishing_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(fishing_entry.zoneid));
insert_values.push_back(std::to_string(fishing_entry.Itemid));
insert_values.push_back(std::to_string(fishing_entry.skill_level));
insert_values.push_back(std::to_string(fishing_entry.chance));
insert_values.push_back(std::to_string(fishing_entry.npc_id));
insert_values.push_back(std::to_string(fishing_entry.npc_chance));
insert_values.push_back(std::to_string(fishing_entry.min_expansion));
insert_values.push_back(std::to_string(fishing_entry.max_expansion));
insert_values.push_back("'" + EscapeString(fishing_entry.content_flags) + "'");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Fishing> All()
{
std::vector<Fishing> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Fishing entry{};
entry.id = atoi(row[0]);
entry.zoneid = atoi(row[1]);
entry.Itemid = atoi(row[2]);
entry.skill_level = atoi(row[3]);
entry.chance = atoi(row[4]);
entry.npc_id = atoi(row[5]);
entry.npc_chance = atoi(row[6]);
entry.min_expansion = atoi(row[7]);
entry.max_expansion = atoi(row[8]);
entry.content_flags = row[9] ? row[9] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<Fishing> GetWhere(std::string where_filter)
{
std::vector<Fishing> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Fishing entry{};
entry.id = atoi(row[0]);
entry.zoneid = atoi(row[1]);
entry.Itemid = atoi(row[2]);
entry.skill_level = atoi(row[3]);
entry.chance = atoi(row[4]);
entry.npc_id = atoi(row[5]);
entry.npc_chance = atoi(row[6]);
entry.min_expansion = atoi(row[7]);
entry.max_expansion = atoi(row[8]);
entry.content_flags = row[9] ? row[9] : "";
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

View File

@ -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<std::string> 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<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("forage");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static Forage NewEntity()
{
Forage entry{};
entry.id = 0;
entry.zoneid = 0;
entry.Itemid = 0;
entry.level = 0;
entry.chance = 0;
entry.min_expansion = 0;
entry.max_expansion = 0;
entry.content_flags = "";
return entry;
}
static Forage GetForageEntry(
const std::vector<Forage> &forages,
int forage_id
)
{
for (auto &forage : forages) {
if (forage.id == forage_id) {
return forage;
}
}
return NewEntity();
}
static Forage FindOne(
int forage_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
forage_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
Forage entry{};
entry.id = atoi(row[0]);
entry.zoneid = atoi(row[1]);
entry.Itemid = atoi(row[2]);
entry.level = atoi(row[3]);
entry.chance = atoi(row[4]);
entry.min_expansion = atoi(row[5]);
entry.max_expansion = atoi(row[6]);
entry.content_flags = row[7] ? row[7] : "";
return entry;
}
return NewEntity();
}
static int DeleteOne(
int forage_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
forage_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Forage forage_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(forage_entry.zoneid));
update_values.push_back(columns[2] + " = " + std::to_string(forage_entry.Itemid));
update_values.push_back(columns[3] + " = " + std::to_string(forage_entry.level));
update_values.push_back(columns[4] + " = " + std::to_string(forage_entry.chance));
update_values.push_back(columns[5] + " = " + std::to_string(forage_entry.min_expansion));
update_values.push_back(columns[6] + " = " + std::to_string(forage_entry.max_expansion));
update_values.push_back(columns[7] + " = '" + EscapeString(forage_entry.content_flags) + "'");
auto results = content_db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
forage_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static Forage InsertOne(
Forage forage_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(forage_entry.zoneid));
insert_values.push_back(std::to_string(forage_entry.Itemid));
insert_values.push_back(std::to_string(forage_entry.level));
insert_values.push_back(std::to_string(forage_entry.chance));
insert_values.push_back(std::to_string(forage_entry.min_expansion));
insert_values.push_back(std::to_string(forage_entry.max_expansion));
insert_values.push_back("'" + EscapeString(forage_entry.content_flags) + "'");
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
forage_entry.id = results.LastInsertedID();
return forage_entry;
}
forage_entry = NewEntity();
return forage_entry;
}
static int InsertMany(
std::vector<Forage> forage_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &forage_entry: forage_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(forage_entry.zoneid));
insert_values.push_back(std::to_string(forage_entry.Itemid));
insert_values.push_back(std::to_string(forage_entry.level));
insert_values.push_back(std::to_string(forage_entry.chance));
insert_values.push_back(std::to_string(forage_entry.min_expansion));
insert_values.push_back(std::to_string(forage_entry.max_expansion));
insert_values.push_back("'" + EscapeString(forage_entry.content_flags) + "'");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Forage> All()
{
std::vector<Forage> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Forage entry{};
entry.id = atoi(row[0]);
entry.zoneid = atoi(row[1]);
entry.Itemid = atoi(row[2]);
entry.level = atoi(row[3]);
entry.chance = atoi(row[4]);
entry.min_expansion = atoi(row[5]);
entry.max_expansion = atoi(row[6]);
entry.content_flags = row[7] ? row[7] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<Forage> GetWhere(std::string where_filter)
{
std::vector<Forage> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Forage entry{};
entry.id = atoi(row[0]);
entry.zoneid = atoi(row[1]);
entry.Itemid = atoi(row[2]);
entry.level = atoi(row[3]);
entry.chance = atoi(row[4]);
entry.min_expansion = atoi(row[5]);
entry.max_expansion = atoi(row[6]);
entry.content_flags = row[7] ? row[7] : "";
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

View File

@ -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<std::string> Columns()
{
return {
"charid",
"type",
"name",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("friends");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static Friends NewEntity()
{
Friends entry{};
entry.charid = 0;
entry.type = 1;
entry.name = "";
return entry;
}
static Friends GetFriendsEntry(
const std::vector<Friends> &friendss,
int friends_id
)
{
for (auto &friends : friendss) {
if (friends.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<std::string> 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<std::string> 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> friends_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &friends_entry: friends_entries) {
std::vector<std::string> insert_values;
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Friends> All()
{
std::vector<Friends> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Friends entry{};
entry.charid = atoi(row[0]);
entry.type = atoi(row[1]);
entry.name = row[2] ? row[2] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<Friends> GetWhere(std::string where_filter)
{
std::vector<Friends> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Friends entry{};
entry.charid = atoi(row[0]);
entry.type = atoi(row[1]);
entry.name = row[2] ? row[2] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_FRIENDS_REPOSITORY_H

View File

@ -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<std::string> Columns()
{
return {
"id",
"description",
"loottable_id",
"enabled",
"min_level",
"max_level",
"rare",
"raid",
"race",
"class",
"bodytype",
"zone",
"hot_zone",
"min_expansion",
"max_expansion",
"content_flags",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("global_loot");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
);
}
static GlobalLoot NewEntity()
{
GlobalLoot entry{};
entry.id = 0;
entry.description = "";
entry.loottable_id = 0;
entry.enabled = 1;
entry.min_level = 0;
entry.max_level = 0;
entry.rare = 0;
entry.raid = 0;
entry.race = "";
entry.class = "";
entry.bodytype = "";
entry.zone = "";
entry.hot_zone = 0;
entry.min_expansion = 0;
entry.max_expansion = 0;
entry.content_flags = "";
return entry;
}
static GlobalLoot GetGlobalLootEntry(
const std::vector<GlobalLoot> &global_loots,
int global_loot_id
)
{
for (auto &global_loot : global_loots) {
if (global_loot.id == global_loot_id) {
return global_loot;
}
}
return NewEntity();
}
static GlobalLoot FindOne(
int global_loot_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
global_loot_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
GlobalLoot entry{};
entry.id = atoi(row[0]);
entry.description = row[1] ? row[1] : "";
entry.loottable_id = atoi(row[2]);
entry.enabled = atoi(row[3]);
entry.min_level = atoi(row[4]);
entry.max_level = atoi(row[5]);
entry.rare = atoi(row[6]);
entry.raid = atoi(row[7]);
entry.race = row[8] ? row[8] : "";
entry.class = row[9] ? row[9] : "";
entry.bodytype = row[10] ? row[10] : "";
entry.zone = row[11] ? row[11] : "";
entry.hot_zone = atoi(row[12]);
entry.min_expansion = atoi(row[13]);
entry.max_expansion = atoi(row[14]);
entry.content_flags = row[15] ? row[15] : "";
return entry;
}
return NewEntity();
}
static int DeleteOne(
int global_loot_id
)
{
auto results = content_db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
global_loot_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
GlobalLoot global_loot_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + EscapeString(global_loot_entry.description) + "'");
update_values.push_back(columns[2] + " = " + std::to_string(global_loot_entry.loottable_id));
update_values.push_back(columns[3] + " = " + std::to_string(global_loot_entry.enabled));
update_values.push_back(columns[4] + " = " + std::to_string(global_loot_entry.min_level));
update_values.push_back(columns[5] + " = " + std::to_string(global_loot_entry.max_level));
update_values.push_back(columns[6] + " = " + std::to_string(global_loot_entry.rare));
update_values.push_back(columns[7] + " = " + std::to_string(global_loot_entry.raid));
update_values.push_back(columns[8] + " = '" + EscapeString(global_loot_entry.race) + "'");
update_values.push_back(columns[9] + " = '" + EscapeString(global_loot_entry.class) + "'");
update_values.push_back(columns[10] + " = '" + EscapeString(global_loot_entry.bodytype) + "'");
update_values.push_back(columns[11] + " = '" + EscapeString(global_loot_entry.zone) + "'");
update_values.push_back(columns[12] + " = " + std::to_string(global_loot_entry.hot_zone));
update_values.push_back(columns[13] + " = " + std::to_string(global_loot_entry.min_expansion));
update_values.push_back(columns[14] + " = " + std::to_string(global_loot_entry.max_expansion));
update_values.push_back(columns[15] + " = '" + EscapeString(global_loot_entry.content_flags) + "'");
auto results = content_db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
global_loot_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static GlobalLoot InsertOne(
GlobalLoot global_loot_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(global_loot_entry.description) + "'");
insert_values.push_back(std::to_string(global_loot_entry.loottable_id));
insert_values.push_back(std::to_string(global_loot_entry.enabled));
insert_values.push_back(std::to_string(global_loot_entry.min_level));
insert_values.push_back(std::to_string(global_loot_entry.max_level));
insert_values.push_back(std::to_string(global_loot_entry.rare));
insert_values.push_back(std::to_string(global_loot_entry.raid));
insert_values.push_back("'" + EscapeString(global_loot_entry.race) + "'");
insert_values.push_back("'" + EscapeString(global_loot_entry.class) + "'");
insert_values.push_back("'" + EscapeString(global_loot_entry.bodytype) + "'");
insert_values.push_back("'" + EscapeString(global_loot_entry.zone) + "'");
insert_values.push_back(std::to_string(global_loot_entry.hot_zone));
insert_values.push_back(std::to_string(global_loot_entry.min_expansion));
insert_values.push_back(std::to_string(global_loot_entry.max_expansion));
insert_values.push_back("'" + EscapeString(global_loot_entry.content_flags) + "'");
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
global_loot_entry.id = results.LastInsertedID();
return global_loot_entry;
}
global_loot_entry = NewEntity();
return global_loot_entry;
}
static int InsertMany(
std::vector<GlobalLoot> global_loot_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &global_loot_entry: global_loot_entries) {
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(global_loot_entry.description) + "'");
insert_values.push_back(std::to_string(global_loot_entry.loottable_id));
insert_values.push_back(std::to_string(global_loot_entry.enabled));
insert_values.push_back(std::to_string(global_loot_entry.min_level));
insert_values.push_back(std::to_string(global_loot_entry.max_level));
insert_values.push_back(std::to_string(global_loot_entry.rare));
insert_values.push_back(std::to_string(global_loot_entry.raid));
insert_values.push_back("'" + EscapeString(global_loot_entry.race) + "'");
insert_values.push_back("'" + EscapeString(global_loot_entry.class) + "'");
insert_values.push_back("'" + EscapeString(global_loot_entry.bodytype) + "'");
insert_values.push_back("'" + EscapeString(global_loot_entry.zone) + "'");
insert_values.push_back(std::to_string(global_loot_entry.hot_zone));
insert_values.push_back(std::to_string(global_loot_entry.min_expansion));
insert_values.push_back(std::to_string(global_loot_entry.max_expansion));
insert_values.push_back("'" + EscapeString(global_loot_entry.content_flags) + "'");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<GlobalLoot> All()
{
std::vector<GlobalLoot> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
GlobalLoot entry{};
entry.id = atoi(row[0]);
entry.description = row[1] ? row[1] : "";
entry.loottable_id = atoi(row[2]);
entry.enabled = atoi(row[3]);
entry.min_level = atoi(row[4]);
entry.max_level = atoi(row[5]);
entry.rare = atoi(row[6]);
entry.raid = atoi(row[7]);
entry.race = row[8] ? row[8] : "";
entry.class = row[9] ? row[9] : "";
entry.bodytype = row[10] ? row[10] : "";
entry.zone = row[11] ? row[11] : "";
entry.hot_zone = atoi(row[12]);
entry.min_expansion = atoi(row[13]);
entry.max_expansion = atoi(row[14]);
entry.content_flags = row[15] ? row[15] : "";
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<GlobalLoot> GetWhere(std::string where_filter)
{
std::vector<GlobalLoot> all_entries;
auto results = content_db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
GlobalLoot entry{};
entry.id = atoi(row[0]);
entry.description = row[1] ? row[1] : "";
entry.loottable_id = atoi(row[2]);
entry.enabled = atoi(row[3]);
entry.min_level = atoi(row[4]);
entry.max_level = atoi(row[5]);
entry.rare = atoi(row[6]);
entry.raid = atoi(row[7]);
entry.race = row[8] ? row[8] : "";
entry.class = row[9] ? row[9] : "";
entry.bodytype = row[10] ? row[10] : "";
entry.zone = row[11] ? row[11] : "";
entry.hot_zone = atoi(row[12]);
entry.min_expansion = atoi(row[13]);
entry.max_expansion = atoi(row[14]);
entry.content_flags = row[15] ? row[15] : "";
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

View File

@ -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<std::string> Columns()
{
return {
"name",
"account_id",
"ip_address",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("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<GmIps> &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<std::string> 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<std::string> 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<GmIps> gm_ips_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &gm_ips_entry: gm_ips_entries) {
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(gm_ips_entry.name) + "'");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<GmIps> All()
{
std::vector<GmIps> 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<GmIps> GetWhere(std::string where_filter)
{
std::vector<GmIps> 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

View File

@ -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<std::string> Columns()
{
return {
"listid",
"entry",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("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<Goallists> &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<std::string> 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<std::string> 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> goallists_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &goallists_entry: goallists_entries) {
std::vector<std::string> insert_values;
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Goallists> All()
{
std::vector<Goallists> 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<Goallists> GetWhere(std::string where_filter)
{
std::vector<Goallists> 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

View File

@ -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<std::string> Columns()
{
return {
"id",
"zone_id",
"x",
"y",
"z",
"heading",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("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<Graveyard> &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<std::string> 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<std::string> 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> graveyard_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &graveyard_entry: graveyard_entries) {
std::vector<std::string> 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<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Graveyard> All()
{
std::vector<Graveyard> 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<Graveyard> GetWhere(std::string where_filter)
{
std::vector<Graveyard> 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

View File

@ -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<std::string> 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<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("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<GridEntries> &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<std::string> 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<std::string> 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<GridEntries> grid_entries_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &grid_entries_entry: grid_entries_entries) {
std::vector<std::string> 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<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<GridEntries> All()
{
std::vector<GridEntries> 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<GridEntries> GetWhere(std::string where_filter)
{
std::vector<GridEntries> 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

View File

@ -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<std::string> Columns()
{
return {
"id",
"zoneid",
"type",
"type2",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("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<Grid> &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<std::string> 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<std::string> 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> grid_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &grid_entry: grid_entries) {
std::vector<std::string> 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<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Grid> All()
{
std::vector<Grid> 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<Grid> GetWhere(std::string where_filter)
{
std::vector<Grid> 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

View File

@ -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<std::string> 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<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("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<GroundSpawns> &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<std::string> 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<std::string> 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<GroundSpawns> ground_spawns_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &ground_spawns_entry: ground_spawns_entries) {
std::vector<std::string> 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<std::string> insert_values;
auto results = content_db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<GroundSpawns> All()
{
std::vector<GroundSpawns> 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<GroundSpawns> GetWhere(std::string where_filter)
{
std::vector<GroundSpawns> 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

View File

@ -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<std::string> Columns()
{
return {
"groupid",
"charid",
"name",
"ismerc",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("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<GroupId> &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<std::string> 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<std::string> 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<GroupId> group_id_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &group_id_entry: group_id_entries) {
std::vector<std::string> insert_values;
insert_values.push_back("'" + EscapeString(group_id_entry.name) + "'");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<GroupId> All()
{
std::vector<GroupId> 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<GroupId> GetWhere(std::string where_filter)
{
std::vector<GroupId> 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

View File

@ -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<std::string> 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<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("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<GroupLeaders> &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<std::string> 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<std::string> 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<GroupLeaders> group_leaders_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &group_leaders_entry: group_leaders_entries) {
std::vector<std::string> 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<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<GroupLeaders> All()
{
std::vector<GroupLeaders> 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<GroupLeaders> GetWhere(std::string where_filter)
{
std::vector<GroupLeaders> 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

View File

@ -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<std::string> 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<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("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<GuildMembers> &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<std::string> 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<std::string> 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<GuildMembers> guild_members_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &guild_members_entry: guild_members_entries) {
std::vector<std::string> 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<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<GuildMembers> All()
{
std::vector<GuildMembers> 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<GuildMembers> GetWhere(std::string where_filter)
{
std::vector<GuildMembers> 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

View File

@ -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<std::string> 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<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("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<GuildRanks> &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<std::string> 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<std::string> 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<GuildRanks> guild_ranks_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &guild_ranks_entry: guild_ranks_entries) {
std::vector<std::string> 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<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<GuildRanks> All()
{
std::vector<GuildRanks> 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<GuildRanks> GetWhere(std::string where_filter)
{
std::vector<GuildRanks> 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

View File

@ -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<std::string> Columns()
{
return {
"guild1",
"guild2",
"relation",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
{
std::vector<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("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<GuildRelations> &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<std::string> 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<std::string> 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<GuildRelations> guild_relations_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &guild_relations_entry: guild_relations_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(guild_relations_entry.relation));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<GuildRelations> All()
{
std::vector<GuildRelations> 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<GuildRelations> GetWhere(std::string where_filter)
{
std::vector<GuildRelations> 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

View File

@ -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<std::string> 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<std::string> insert_columns;
for (auto &column : Columns()) {
if (column == PrimaryKey()) {
continue;
}
insert_columns.push_back(column);
}
return std::string(implode(", ", insert_columns));
}
static std::string TableName()
{
return std::string("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<Guilds> &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<std::string> 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<std::string> 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> guilds_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &guilds_entry: guilds_entries) {
std::vector<std::string> 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<std::string> insert_values;
auto results = database.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Guilds> All()
{
std::vector<Guilds> 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<Guilds> GetWhere(std::string where_filter)
{
std::vector<Guilds> 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

Some files were not shown because too many files have changed in this diff Show More