mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 09:31:30 +00:00
[Mercs] Add Mercenary Support (#2745)
* [Mercs] Add Mercenary Support # Notes - Adds `--merc-tables` support to database dumper. - Adds Mercenary-based repositories. - Adds required SQL `2023_01_15_merc_data.sql` to insert the tables for those who don't already have them. - Adds optional SQL `2023_01_15_merc_liaisons.sql` to change NPCs to the Mercenary Liaison class optionally. * Inline. * Trim tables_to_dump output Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
parent
bd29f1c5bb
commit
fbb36a3e75
@ -118,109 +118,53 @@ std::string DatabaseDumpService::GetBaseMySQLDumpCommand()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
std::string DatabaseDumpService::GetPlayerTablesList()
|
std::string DatabaseDumpService::GetPlayerTablesList()
|
||||||
{
|
{
|
||||||
std::string tables_list;
|
return Strings::Join(DatabaseSchema::GetPlayerTables(), " ");
|
||||||
std::vector<std::string> tables = DatabaseSchema::GetPlayerTables();
|
|
||||||
for (const auto &table : tables) {
|
|
||||||
tables_list += table + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
return Strings::Trim(tables_list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
std::string DatabaseDumpService::GetBotTablesList()
|
std::string DatabaseDumpService::GetBotTablesList()
|
||||||
{
|
{
|
||||||
std::string tables_list;
|
return Strings::Join(DatabaseSchema::GetBotTables(), " ");
|
||||||
std::vector<std::string> tables = DatabaseSchema::GetBotTables();
|
}
|
||||||
for (const auto &table : tables) {
|
|
||||||
tables_list += table + " ";
|
std::string DatabaseDumpService::GetMercTablesList()
|
||||||
}
|
{
|
||||||
|
return Strings::Join(DatabaseSchema::GetMercTables(), " ");
|
||||||
return Strings::Trim(tables_list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
std::string DatabaseDumpService::GetLoginTableList()
|
std::string DatabaseDumpService::GetLoginTableList()
|
||||||
{
|
{
|
||||||
std::string tables_list;
|
return Strings::Join(DatabaseSchema::GetLoginTables(), " ");
|
||||||
std::vector<std::string> tables = DatabaseSchema::GetLoginTables();
|
|
||||||
for (const auto &table : tables) {
|
|
||||||
tables_list += table + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
return Strings::Trim(tables_list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
std::string DatabaseDumpService::GetQueryServTables()
|
std::string DatabaseDumpService::GetQueryServTables()
|
||||||
{
|
{
|
||||||
std::string tables_list;
|
return Strings::Join(DatabaseSchema::GetQueryServerTables(), " ");
|
||||||
std::vector<std::string> tables = DatabaseSchema::GetQueryServerTables();
|
|
||||||
for (const auto &table : tables) {
|
|
||||||
tables_list += table + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
return Strings::Trim(tables_list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
std::string DatabaseDumpService::GetSystemTablesList()
|
std::string DatabaseDumpService::GetSystemTablesList()
|
||||||
{
|
{
|
||||||
std::string tables_list;
|
auto system_tables = DatabaseSchema::GetServerTables();
|
||||||
|
auto version_tables = DatabaseSchema::GetVersionTables();
|
||||||
|
|
||||||
std::vector<std::string> tables = DatabaseSchema::GetServerTables();
|
system_tables.insert(
|
||||||
for (const auto &table : tables) {
|
std::end(system_tables),
|
||||||
tables_list += table + " ";
|
std::begin(version_tables),
|
||||||
}
|
std::end(version_tables)
|
||||||
|
);
|
||||||
|
|
||||||
tables = DatabaseSchema::GetVersionTables();
|
return Strings::Join(system_tables, " ");
|
||||||
for (const auto &table : tables) {
|
|
||||||
tables_list += table + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
return Strings::Trim(tables_list);
|
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
std::string DatabaseDumpService::GetStateTablesList()
|
std::string DatabaseDumpService::GetStateTablesList()
|
||||||
{
|
{
|
||||||
std::string tables_list;
|
return Strings::Join(DatabaseSchema::GetStateTables(), " ");
|
||||||
|
|
||||||
std::vector<std::string> tables = DatabaseSchema::GetStateTables();
|
|
||||||
for (const auto &table : tables) {
|
|
||||||
tables_list += table + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
return Strings::Trim(tables_list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
std::string DatabaseDumpService::GetContentTablesList()
|
std::string DatabaseDumpService::GetContentTablesList()
|
||||||
{
|
{
|
||||||
std::string tables_list;
|
return Strings::Join(DatabaseSchema::GetContentTables(), " ");
|
||||||
|
|
||||||
std::vector<std::string> tables = DatabaseSchema::GetContentTables();
|
|
||||||
for (const auto &table : tables) {
|
|
||||||
tables_list += table + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
return Strings::Trim(tables_list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -306,6 +250,11 @@ void DatabaseDumpService::Dump()
|
|||||||
dump_descriptor += "-bots";
|
dump_descriptor += "-bots";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsDumpMercTables()) {
|
||||||
|
tables_to_dump += GetMercTablesList() + " ";
|
||||||
|
dump_descriptor += "-mercs";
|
||||||
|
}
|
||||||
|
|
||||||
if (IsDumpSystemTables()) {
|
if (IsDumpSystemTables()) {
|
||||||
tables_to_dump += GetSystemTablesList() + " ";
|
tables_to_dump += GetSystemTablesList() + " ";
|
||||||
dump_descriptor += "-system";
|
dump_descriptor += "-system";
|
||||||
@ -375,7 +324,7 @@ void DatabaseDumpService::Dump()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!tables_to_dump.empty()) {
|
if (!tables_to_dump.empty()) {
|
||||||
LogInfo("Dumping Tables [{}]", tables_to_dump);
|
LogInfo("Dumping Tables [{}]", Strings::Trim(tables_to_dump));
|
||||||
}
|
}
|
||||||
|
|
||||||
LogInfo("Database dump created at [{}.sql]", GetDumpFileNameWithPath());
|
LogInfo("Database dump created at [{}.sql]", GetDumpFileNameWithPath());
|
||||||
@ -576,3 +525,13 @@ void DatabaseDumpService::SetDumpBotTables(bool dump_bot_tables)
|
|||||||
{
|
{
|
||||||
DatabaseDumpService::dump_bot_tables = dump_bot_tables;
|
DatabaseDumpService::dump_bot_tables = dump_bot_tables;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DatabaseDumpService::IsDumpMercTables() const
|
||||||
|
{
|
||||||
|
return dump_merc_tables;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatabaseDumpService::SetDumpMercTables(bool dump_merc_tables)
|
||||||
|
{
|
||||||
|
DatabaseDumpService::dump_merc_tables = dump_merc_tables;
|
||||||
|
}
|
||||||
|
|||||||
@ -55,6 +55,8 @@ public:
|
|||||||
void SetDumpStateTables(bool dump_state_tables);
|
void SetDumpStateTables(bool dump_state_tables);
|
||||||
bool IsDumpBotTables() const;
|
bool IsDumpBotTables() const;
|
||||||
void SetDumpBotTables(bool dump_bot_tables);
|
void SetDumpBotTables(bool dump_bot_tables);
|
||||||
|
bool IsDumpMercTables() const;
|
||||||
|
void SetDumpMercTables(bool dump_bot_tables);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool dump_all_tables = false;
|
bool dump_all_tables = false;
|
||||||
@ -70,6 +72,7 @@ private:
|
|||||||
bool dump_output_to_console = false;
|
bool dump_output_to_console = false;
|
||||||
bool dump_drop_table_syntax_only = false;
|
bool dump_drop_table_syntax_only = false;
|
||||||
bool dump_bot_tables = false;
|
bool dump_bot_tables = false;
|
||||||
|
bool dump_merc_tables = false;
|
||||||
std::string dump_path;
|
std::string dump_path;
|
||||||
std::string dump_file_name;
|
std::string dump_file_name;
|
||||||
|
|
||||||
@ -78,6 +81,7 @@ private:
|
|||||||
std::string GetBaseMySQLDumpCommand();
|
std::string GetBaseMySQLDumpCommand();
|
||||||
std::string GetPlayerTablesList();
|
std::string GetPlayerTablesList();
|
||||||
std::string GetBotTablesList();
|
std::string GetBotTablesList();
|
||||||
|
std::string GetMercTablesList();
|
||||||
std::string GetSystemTablesList();
|
std::string GetSystemTablesList();
|
||||||
std::string GetStateTablesList();
|
std::string GetStateTablesList();
|
||||||
std::string GetContentTablesList();
|
std::string GetContentTablesList();
|
||||||
|
|||||||
@ -332,7 +332,9 @@ namespace DatabaseSchema {
|
|||||||
"ip_exemptions",
|
"ip_exemptions",
|
||||||
"item_tick",
|
"item_tick",
|
||||||
"lfguild",
|
"lfguild",
|
||||||
|
"merc_buffs",
|
||||||
"merchantlist_temp",
|
"merchantlist_temp",
|
||||||
|
"mercs",
|
||||||
"object_contents",
|
"object_contents",
|
||||||
"raid_details",
|
"raid_details",
|
||||||
"raid_leaders",
|
"raid_leaders",
|
||||||
@ -412,6 +414,27 @@ namespace DatabaseSchema {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> GetMercTables()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_armorinfo",
|
||||||
|
"merc_inventory",
|
||||||
|
"merc_merchant_entries",
|
||||||
|
"merc_merchant_template_entries",
|
||||||
|
"merc_merchant_templates",
|
||||||
|
"merc_name_types",
|
||||||
|
"merc_npc_types",
|
||||||
|
"merc_spell_list_entries",
|
||||||
|
"merc_spell_lists",
|
||||||
|
"merc_stance_entries",
|
||||||
|
"merc_stats",
|
||||||
|
"merc_subtypes",
|
||||||
|
"merc_templates",
|
||||||
|
"merc_types",
|
||||||
|
"merc_weaponinfo"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //EQEMU_DATABASE_SCHEMA_H
|
#endif //EQEMU_DATABASE_SCHEMA_H
|
||||||
|
|||||||
414
common/repositories/base/base_merc_armorinfo_repository.h
Normal file
414
common/repositories/base/base_merc_armorinfo_repository.h
Normal file
@ -0,0 +1,414 @@
|
|||||||
|
/**
|
||||||
|
* DO NOT MODIFY THIS FILE
|
||||||
|
*
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to the repository extending the base.
|
||||||
|
* Any modifications to base repositories are to be made by the generator only
|
||||||
|
*
|
||||||
|
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||||
|
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_MERC_ARMORINFO_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_MERC_ARMORINFO_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../strings.h"
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
|
class BaseMercArmorinfoRepository {
|
||||||
|
public:
|
||||||
|
struct MercArmorinfo {
|
||||||
|
int32_t id;
|
||||||
|
uint32_t merc_npc_type_id;
|
||||||
|
uint8_t minlevel;
|
||||||
|
uint8_t maxlevel;
|
||||||
|
uint8_t texture;
|
||||||
|
uint8_t helmtexture;
|
||||||
|
uint32_t armortint_id;
|
||||||
|
uint8_t armortint_red;
|
||||||
|
uint8_t armortint_green;
|
||||||
|
uint8_t armortint_blue;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"merc_npc_type_id",
|
||||||
|
"minlevel",
|
||||||
|
"maxlevel",
|
||||||
|
"texture",
|
||||||
|
"helmtexture",
|
||||||
|
"armortint_id",
|
||||||
|
"armortint_red",
|
||||||
|
"armortint_green",
|
||||||
|
"armortint_blue",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> SelectColumns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"merc_npc_type_id",
|
||||||
|
"minlevel",
|
||||||
|
"maxlevel",
|
||||||
|
"texture",
|
||||||
|
"helmtexture",
|
||||||
|
"armortint_id",
|
||||||
|
"armortint_red",
|
||||||
|
"armortint_green",
|
||||||
|
"armortint_blue",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string SelectColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", SelectColumns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("merc_armorinfo");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
SelectColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
ColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercArmorinfo NewEntity()
|
||||||
|
{
|
||||||
|
MercArmorinfo e{};
|
||||||
|
|
||||||
|
e.id = 0;
|
||||||
|
e.merc_npc_type_id = 0;
|
||||||
|
e.minlevel = 1;
|
||||||
|
e.maxlevel = 255;
|
||||||
|
e.texture = 0;
|
||||||
|
e.helmtexture = 0;
|
||||||
|
e.armortint_id = 0;
|
||||||
|
e.armortint_red = 0;
|
||||||
|
e.armortint_green = 0;
|
||||||
|
e.armortint_blue = 0;
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercArmorinfo GetMercArmorinfo(
|
||||||
|
const std::vector<MercArmorinfo> &merc_armorinfos,
|
||||||
|
int merc_armorinfo_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &merc_armorinfo : merc_armorinfos) {
|
||||||
|
if (merc_armorinfo.id == merc_armorinfo_id) {
|
||||||
|
return merc_armorinfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercArmorinfo FindOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_armorinfo_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {} = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_armorinfo_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
MercArmorinfo e{};
|
||||||
|
|
||||||
|
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||||
|
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.minlevel = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.maxlevel = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.texture = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
|
||||||
|
e.helmtexture = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
|
||||||
|
e.armortint_id = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
|
||||||
|
e.armortint_red = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
|
||||||
|
e.armortint_green = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
|
||||||
|
e.armortint_blue = static_cast<uint8_t>(strtoul(row[9], nullptr, 10));
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_armorinfo_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_armorinfo_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Database& db,
|
||||||
|
const MercArmorinfo &e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
v.push_back(columns[1] + " = " + std::to_string(e.merc_npc_type_id));
|
||||||
|
v.push_back(columns[2] + " = " + std::to_string(e.minlevel));
|
||||||
|
v.push_back(columns[3] + " = " + std::to_string(e.maxlevel));
|
||||||
|
v.push_back(columns[4] + " = " + std::to_string(e.texture));
|
||||||
|
v.push_back(columns[5] + " = " + std::to_string(e.helmtexture));
|
||||||
|
v.push_back(columns[6] + " = " + std::to_string(e.armortint_id));
|
||||||
|
v.push_back(columns[7] + " = " + std::to_string(e.armortint_red));
|
||||||
|
v.push_back(columns[8] + " = " + std::to_string(e.armortint_green));
|
||||||
|
v.push_back(columns[9] + " = " + std::to_string(e.armortint_blue));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
Strings::Implode(", ", v),
|
||||||
|
PrimaryKey(),
|
||||||
|
e.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercArmorinfo InsertOne(
|
||||||
|
Database& db,
|
||||||
|
MercArmorinfo e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.id));
|
||||||
|
v.push_back(std::to_string(e.merc_npc_type_id));
|
||||||
|
v.push_back(std::to_string(e.minlevel));
|
||||||
|
v.push_back(std::to_string(e.maxlevel));
|
||||||
|
v.push_back(std::to_string(e.texture));
|
||||||
|
v.push_back(std::to_string(e.helmtexture));
|
||||||
|
v.push_back(std::to_string(e.armortint_id));
|
||||||
|
v.push_back(std::to_string(e.armortint_red));
|
||||||
|
v.push_back(std::to_string(e.armortint_green));
|
||||||
|
v.push_back(std::to_string(e.armortint_blue));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
e.id = results.LastInsertedID();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
e = NewEntity();
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
Database& db,
|
||||||
|
const std::vector<MercArmorinfo> &entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &e: entries) {
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.id));
|
||||||
|
v.push_back(std::to_string(e.merc_npc_type_id));
|
||||||
|
v.push_back(std::to_string(e.minlevel));
|
||||||
|
v.push_back(std::to_string(e.maxlevel));
|
||||||
|
v.push_back(std::to_string(e.texture));
|
||||||
|
v.push_back(std::to_string(e.helmtexture));
|
||||||
|
v.push_back(std::to_string(e.armortint_id));
|
||||||
|
v.push_back(std::to_string(e.armortint_red));
|
||||||
|
v.push_back(std::to_string(e.armortint_green));
|
||||||
|
v.push_back(std::to_string(e.armortint_blue));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercArmorinfo> All(Database& db)
|
||||||
|
{
|
||||||
|
std::vector<MercArmorinfo> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercArmorinfo e{};
|
||||||
|
|
||||||
|
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||||
|
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.minlevel = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.maxlevel = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.texture = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
|
||||||
|
e.helmtexture = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
|
||||||
|
e.armortint_id = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
|
||||||
|
e.armortint_red = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
|
||||||
|
e.armortint_green = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
|
||||||
|
e.armortint_blue = static_cast<uint8_t>(strtoul(row[9], nullptr, 10));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercArmorinfo> GetWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
std::vector<MercArmorinfo> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercArmorinfo e{};
|
||||||
|
|
||||||
|
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||||
|
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.minlevel = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.maxlevel = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.texture = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
|
||||||
|
e.helmtexture = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
|
||||||
|
e.armortint_id = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
|
||||||
|
e.armortint_red = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
|
||||||
|
e.armortint_green = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
|
||||||
|
e.armortint_blue = static_cast<uint8_t>(strtoul(row[9], nullptr, 10));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 GetMaxId(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COALESCE(MAX({}), 0) FROM {}",
|
||||||
|
PrimaryKey(),
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 Count(Database& db, const std::string &where_filter = "")
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COUNT(*) FROM {} {}",
|
||||||
|
TableName(),
|
||||||
|
(where_filter.empty() ? "" : "WHERE " + where_filter)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_MERC_ARMORINFO_REPOSITORY_H
|
||||||
504
common/repositories/base/base_merc_buffs_repository.h
Normal file
504
common/repositories/base/base_merc_buffs_repository.h
Normal file
@ -0,0 +1,504 @@
|
|||||||
|
/**
|
||||||
|
* DO NOT MODIFY THIS FILE
|
||||||
|
*
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to the repository extending the base.
|
||||||
|
* Any modifications to base repositories are to be made by the generator only
|
||||||
|
*
|
||||||
|
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||||
|
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_MERC_BUFFS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_MERC_BUFFS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../strings.h"
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
|
class BaseMercBuffsRepository {
|
||||||
|
public:
|
||||||
|
struct MercBuffs {
|
||||||
|
uint32_t MercBuffId;
|
||||||
|
uint32_t MercId;
|
||||||
|
uint32_t SpellId;
|
||||||
|
uint32_t CasterLevel;
|
||||||
|
uint32_t DurationFormula;
|
||||||
|
int32_t TicsRemaining;
|
||||||
|
uint32_t PoisonCounters;
|
||||||
|
uint32_t DiseaseCounters;
|
||||||
|
uint32_t CurseCounters;
|
||||||
|
uint32_t CorruptionCounters;
|
||||||
|
uint32_t HitCount;
|
||||||
|
uint32_t MeleeRune;
|
||||||
|
uint32_t MagicRune;
|
||||||
|
int32_t dot_rune;
|
||||||
|
int32_t caston_x;
|
||||||
|
int8_t Persistent;
|
||||||
|
int32_t caston_y;
|
||||||
|
int32_t caston_z;
|
||||||
|
int32_t ExtraDIChance;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("MercBuffId");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"MercBuffId",
|
||||||
|
"MercId",
|
||||||
|
"SpellId",
|
||||||
|
"CasterLevel",
|
||||||
|
"DurationFormula",
|
||||||
|
"TicsRemaining",
|
||||||
|
"PoisonCounters",
|
||||||
|
"DiseaseCounters",
|
||||||
|
"CurseCounters",
|
||||||
|
"CorruptionCounters",
|
||||||
|
"HitCount",
|
||||||
|
"MeleeRune",
|
||||||
|
"MagicRune",
|
||||||
|
"dot_rune",
|
||||||
|
"caston_x",
|
||||||
|
"Persistent",
|
||||||
|
"caston_y",
|
||||||
|
"caston_z",
|
||||||
|
"ExtraDIChance",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> SelectColumns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"MercBuffId",
|
||||||
|
"MercId",
|
||||||
|
"SpellId",
|
||||||
|
"CasterLevel",
|
||||||
|
"DurationFormula",
|
||||||
|
"TicsRemaining",
|
||||||
|
"PoisonCounters",
|
||||||
|
"DiseaseCounters",
|
||||||
|
"CurseCounters",
|
||||||
|
"CorruptionCounters",
|
||||||
|
"HitCount",
|
||||||
|
"MeleeRune",
|
||||||
|
"MagicRune",
|
||||||
|
"dot_rune",
|
||||||
|
"caston_x",
|
||||||
|
"Persistent",
|
||||||
|
"caston_y",
|
||||||
|
"caston_z",
|
||||||
|
"ExtraDIChance",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string SelectColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", SelectColumns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("merc_buffs");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
SelectColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
ColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercBuffs NewEntity()
|
||||||
|
{
|
||||||
|
MercBuffs e{};
|
||||||
|
|
||||||
|
e.MercBuffId = 0;
|
||||||
|
e.MercId = 0;
|
||||||
|
e.SpellId = 0;
|
||||||
|
e.CasterLevel = 0;
|
||||||
|
e.DurationFormula = 0;
|
||||||
|
e.TicsRemaining = 0;
|
||||||
|
e.PoisonCounters = 0;
|
||||||
|
e.DiseaseCounters = 0;
|
||||||
|
e.CurseCounters = 0;
|
||||||
|
e.CorruptionCounters = 0;
|
||||||
|
e.HitCount = 0;
|
||||||
|
e.MeleeRune = 0;
|
||||||
|
e.MagicRune = 0;
|
||||||
|
e.dot_rune = 0;
|
||||||
|
e.caston_x = 0;
|
||||||
|
e.Persistent = 0;
|
||||||
|
e.caston_y = 0;
|
||||||
|
e.caston_z = 0;
|
||||||
|
e.ExtraDIChance = 0;
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercBuffs GetMercBuffs(
|
||||||
|
const std::vector<MercBuffs> &merc_buffss,
|
||||||
|
int merc_buffs_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &merc_buffs : merc_buffss) {
|
||||||
|
if (merc_buffs.MercBuffId == merc_buffs_id) {
|
||||||
|
return merc_buffs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercBuffs FindOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_buffs_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {} = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_buffs_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
MercBuffs e{};
|
||||||
|
|
||||||
|
e.MercBuffId = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.MercId = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.SpellId = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.CasterLevel = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.DurationFormula = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
|
||||||
|
e.TicsRemaining = static_cast<int32_t>(atoi(row[5]));
|
||||||
|
e.PoisonCounters = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
|
||||||
|
e.DiseaseCounters = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
|
||||||
|
e.CurseCounters = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
|
||||||
|
e.CorruptionCounters = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
|
||||||
|
e.HitCount = static_cast<uint32_t>(strtoul(row[10], nullptr, 10));
|
||||||
|
e.MeleeRune = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
|
||||||
|
e.MagicRune = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
|
||||||
|
e.dot_rune = static_cast<int32_t>(atoi(row[13]));
|
||||||
|
e.caston_x = static_cast<int32_t>(atoi(row[14]));
|
||||||
|
e.Persistent = static_cast<int8_t>(atoi(row[15]));
|
||||||
|
e.caston_y = static_cast<int32_t>(atoi(row[16]));
|
||||||
|
e.caston_z = static_cast<int32_t>(atoi(row[17]));
|
||||||
|
e.ExtraDIChance = static_cast<int32_t>(atoi(row[18]));
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_buffs_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_buffs_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Database& db,
|
||||||
|
const MercBuffs &e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
v.push_back(columns[1] + " = " + std::to_string(e.MercId));
|
||||||
|
v.push_back(columns[2] + " = " + std::to_string(e.SpellId));
|
||||||
|
v.push_back(columns[3] + " = " + std::to_string(e.CasterLevel));
|
||||||
|
v.push_back(columns[4] + " = " + std::to_string(e.DurationFormula));
|
||||||
|
v.push_back(columns[5] + " = " + std::to_string(e.TicsRemaining));
|
||||||
|
v.push_back(columns[6] + " = " + std::to_string(e.PoisonCounters));
|
||||||
|
v.push_back(columns[7] + " = " + std::to_string(e.DiseaseCounters));
|
||||||
|
v.push_back(columns[8] + " = " + std::to_string(e.CurseCounters));
|
||||||
|
v.push_back(columns[9] + " = " + std::to_string(e.CorruptionCounters));
|
||||||
|
v.push_back(columns[10] + " = " + std::to_string(e.HitCount));
|
||||||
|
v.push_back(columns[11] + " = " + std::to_string(e.MeleeRune));
|
||||||
|
v.push_back(columns[12] + " = " + std::to_string(e.MagicRune));
|
||||||
|
v.push_back(columns[13] + " = " + std::to_string(e.dot_rune));
|
||||||
|
v.push_back(columns[14] + " = " + std::to_string(e.caston_x));
|
||||||
|
v.push_back(columns[15] + " = " + std::to_string(e.Persistent));
|
||||||
|
v.push_back(columns[16] + " = " + std::to_string(e.caston_y));
|
||||||
|
v.push_back(columns[17] + " = " + std::to_string(e.caston_z));
|
||||||
|
v.push_back(columns[18] + " = " + std::to_string(e.ExtraDIChance));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
Strings::Implode(", ", v),
|
||||||
|
PrimaryKey(),
|
||||||
|
e.MercBuffId
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercBuffs InsertOne(
|
||||||
|
Database& db,
|
||||||
|
MercBuffs e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.MercBuffId));
|
||||||
|
v.push_back(std::to_string(e.MercId));
|
||||||
|
v.push_back(std::to_string(e.SpellId));
|
||||||
|
v.push_back(std::to_string(e.CasterLevel));
|
||||||
|
v.push_back(std::to_string(e.DurationFormula));
|
||||||
|
v.push_back(std::to_string(e.TicsRemaining));
|
||||||
|
v.push_back(std::to_string(e.PoisonCounters));
|
||||||
|
v.push_back(std::to_string(e.DiseaseCounters));
|
||||||
|
v.push_back(std::to_string(e.CurseCounters));
|
||||||
|
v.push_back(std::to_string(e.CorruptionCounters));
|
||||||
|
v.push_back(std::to_string(e.HitCount));
|
||||||
|
v.push_back(std::to_string(e.MeleeRune));
|
||||||
|
v.push_back(std::to_string(e.MagicRune));
|
||||||
|
v.push_back(std::to_string(e.dot_rune));
|
||||||
|
v.push_back(std::to_string(e.caston_x));
|
||||||
|
v.push_back(std::to_string(e.Persistent));
|
||||||
|
v.push_back(std::to_string(e.caston_y));
|
||||||
|
v.push_back(std::to_string(e.caston_z));
|
||||||
|
v.push_back(std::to_string(e.ExtraDIChance));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
e.MercBuffId = results.LastInsertedID();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
e = NewEntity();
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
Database& db,
|
||||||
|
const std::vector<MercBuffs> &entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &e: entries) {
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.MercBuffId));
|
||||||
|
v.push_back(std::to_string(e.MercId));
|
||||||
|
v.push_back(std::to_string(e.SpellId));
|
||||||
|
v.push_back(std::to_string(e.CasterLevel));
|
||||||
|
v.push_back(std::to_string(e.DurationFormula));
|
||||||
|
v.push_back(std::to_string(e.TicsRemaining));
|
||||||
|
v.push_back(std::to_string(e.PoisonCounters));
|
||||||
|
v.push_back(std::to_string(e.DiseaseCounters));
|
||||||
|
v.push_back(std::to_string(e.CurseCounters));
|
||||||
|
v.push_back(std::to_string(e.CorruptionCounters));
|
||||||
|
v.push_back(std::to_string(e.HitCount));
|
||||||
|
v.push_back(std::to_string(e.MeleeRune));
|
||||||
|
v.push_back(std::to_string(e.MagicRune));
|
||||||
|
v.push_back(std::to_string(e.dot_rune));
|
||||||
|
v.push_back(std::to_string(e.caston_x));
|
||||||
|
v.push_back(std::to_string(e.Persistent));
|
||||||
|
v.push_back(std::to_string(e.caston_y));
|
||||||
|
v.push_back(std::to_string(e.caston_z));
|
||||||
|
v.push_back(std::to_string(e.ExtraDIChance));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercBuffs> All(Database& db)
|
||||||
|
{
|
||||||
|
std::vector<MercBuffs> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercBuffs e{};
|
||||||
|
|
||||||
|
e.MercBuffId = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.MercId = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.SpellId = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.CasterLevel = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.DurationFormula = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
|
||||||
|
e.TicsRemaining = static_cast<int32_t>(atoi(row[5]));
|
||||||
|
e.PoisonCounters = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
|
||||||
|
e.DiseaseCounters = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
|
||||||
|
e.CurseCounters = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
|
||||||
|
e.CorruptionCounters = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
|
||||||
|
e.HitCount = static_cast<uint32_t>(strtoul(row[10], nullptr, 10));
|
||||||
|
e.MeleeRune = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
|
||||||
|
e.MagicRune = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
|
||||||
|
e.dot_rune = static_cast<int32_t>(atoi(row[13]));
|
||||||
|
e.caston_x = static_cast<int32_t>(atoi(row[14]));
|
||||||
|
e.Persistent = static_cast<int8_t>(atoi(row[15]));
|
||||||
|
e.caston_y = static_cast<int32_t>(atoi(row[16]));
|
||||||
|
e.caston_z = static_cast<int32_t>(atoi(row[17]));
|
||||||
|
e.ExtraDIChance = static_cast<int32_t>(atoi(row[18]));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercBuffs> GetWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
std::vector<MercBuffs> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercBuffs e{};
|
||||||
|
|
||||||
|
e.MercBuffId = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.MercId = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.SpellId = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.CasterLevel = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.DurationFormula = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
|
||||||
|
e.TicsRemaining = static_cast<int32_t>(atoi(row[5]));
|
||||||
|
e.PoisonCounters = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
|
||||||
|
e.DiseaseCounters = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
|
||||||
|
e.CurseCounters = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
|
||||||
|
e.CorruptionCounters = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
|
||||||
|
e.HitCount = static_cast<uint32_t>(strtoul(row[10], nullptr, 10));
|
||||||
|
e.MeleeRune = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
|
||||||
|
e.MagicRune = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
|
||||||
|
e.dot_rune = static_cast<int32_t>(atoi(row[13]));
|
||||||
|
e.caston_x = static_cast<int32_t>(atoi(row[14]));
|
||||||
|
e.Persistent = static_cast<int8_t>(atoi(row[15]));
|
||||||
|
e.caston_y = static_cast<int32_t>(atoi(row[16]));
|
||||||
|
e.caston_z = static_cast<int32_t>(atoi(row[17]));
|
||||||
|
e.ExtraDIChance = static_cast<int32_t>(atoi(row[18]));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 GetMaxId(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COALESCE(MAX({}), 0) FROM {}",
|
||||||
|
PrimaryKey(),
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 Count(Database& db, const std::string &where_filter = "")
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COUNT(*) FROM {} {}",
|
||||||
|
TableName(),
|
||||||
|
(where_filter.empty() ? "" : "WHERE " + where_filter)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_MERC_BUFFS_REPOSITORY_H
|
||||||
364
common/repositories/base/base_merc_inventory_repository.h
Normal file
364
common/repositories/base/base_merc_inventory_repository.h
Normal file
@ -0,0 +1,364 @@
|
|||||||
|
/**
|
||||||
|
* DO NOT MODIFY THIS FILE
|
||||||
|
*
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to the repository extending the base.
|
||||||
|
* Any modifications to base repositories are to be made by the generator only
|
||||||
|
*
|
||||||
|
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||||
|
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_MERC_INVENTORY_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_MERC_INVENTORY_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../strings.h"
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
|
class BaseMercInventoryRepository {
|
||||||
|
public:
|
||||||
|
struct MercInventory {
|
||||||
|
uint32_t merc_inventory_id;
|
||||||
|
uint32_t merc_subtype_id;
|
||||||
|
uint32_t item_id;
|
||||||
|
uint32_t min_level;
|
||||||
|
uint32_t max_level;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("merc_inventory_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_inventory_id",
|
||||||
|
"merc_subtype_id",
|
||||||
|
"item_id",
|
||||||
|
"min_level",
|
||||||
|
"max_level",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> SelectColumns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_inventory_id",
|
||||||
|
"merc_subtype_id",
|
||||||
|
"item_id",
|
||||||
|
"min_level",
|
||||||
|
"max_level",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string SelectColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", SelectColumns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("merc_inventory");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
SelectColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
ColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercInventory NewEntity()
|
||||||
|
{
|
||||||
|
MercInventory e{};
|
||||||
|
|
||||||
|
e.merc_inventory_id = 0;
|
||||||
|
e.merc_subtype_id = 0;
|
||||||
|
e.item_id = 0;
|
||||||
|
e.min_level = 0;
|
||||||
|
e.max_level = 0;
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercInventory GetMercInventory(
|
||||||
|
const std::vector<MercInventory> &merc_inventorys,
|
||||||
|
int merc_inventory_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &merc_inventory : merc_inventorys) {
|
||||||
|
if (merc_inventory.merc_inventory_id == merc_inventory_id) {
|
||||||
|
return merc_inventory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercInventory FindOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_inventory_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {} = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_inventory_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
MercInventory e{};
|
||||||
|
|
||||||
|
e.merc_inventory_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.merc_subtype_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.item_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.min_level = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.max_level = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_inventory_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_inventory_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Database& db,
|
||||||
|
const MercInventory &e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
v.push_back(columns[1] + " = " + std::to_string(e.merc_subtype_id));
|
||||||
|
v.push_back(columns[2] + " = " + std::to_string(e.item_id));
|
||||||
|
v.push_back(columns[3] + " = " + std::to_string(e.min_level));
|
||||||
|
v.push_back(columns[4] + " = " + std::to_string(e.max_level));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
Strings::Implode(", ", v),
|
||||||
|
PrimaryKey(),
|
||||||
|
e.merc_inventory_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercInventory InsertOne(
|
||||||
|
Database& db,
|
||||||
|
MercInventory e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_inventory_id));
|
||||||
|
v.push_back(std::to_string(e.merc_subtype_id));
|
||||||
|
v.push_back(std::to_string(e.item_id));
|
||||||
|
v.push_back(std::to_string(e.min_level));
|
||||||
|
v.push_back(std::to_string(e.max_level));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
e.merc_inventory_id = results.LastInsertedID();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
e = NewEntity();
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
Database& db,
|
||||||
|
const std::vector<MercInventory> &entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &e: entries) {
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_inventory_id));
|
||||||
|
v.push_back(std::to_string(e.merc_subtype_id));
|
||||||
|
v.push_back(std::to_string(e.item_id));
|
||||||
|
v.push_back(std::to_string(e.min_level));
|
||||||
|
v.push_back(std::to_string(e.max_level));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercInventory> All(Database& db)
|
||||||
|
{
|
||||||
|
std::vector<MercInventory> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercInventory e{};
|
||||||
|
|
||||||
|
e.merc_inventory_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.merc_subtype_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.item_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.min_level = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.max_level = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercInventory> GetWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
std::vector<MercInventory> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercInventory e{};
|
||||||
|
|
||||||
|
e.merc_inventory_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.merc_subtype_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.item_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.min_level = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.max_level = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 GetMaxId(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COALESCE(MAX({}), 0) FROM {}",
|
||||||
|
PrimaryKey(),
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 Count(Database& db, const std::string &where_filter = "")
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COUNT(*) FROM {} {}",
|
||||||
|
TableName(),
|
||||||
|
(where_filter.empty() ? "" : "WHERE " + where_filter)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_MERC_INVENTORY_REPOSITORY_H
|
||||||
344
common/repositories/base/base_merc_merchant_entries_repository.h
Normal file
344
common/repositories/base/base_merc_merchant_entries_repository.h
Normal file
@ -0,0 +1,344 @@
|
|||||||
|
/**
|
||||||
|
* DO NOT MODIFY THIS FILE
|
||||||
|
*
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to the repository extending the base.
|
||||||
|
* Any modifications to base repositories are to be made by the generator only
|
||||||
|
*
|
||||||
|
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||||
|
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_MERC_MERCHANT_ENTRIES_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_MERC_MERCHANT_ENTRIES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../strings.h"
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
|
class BaseMercMerchantEntriesRepository {
|
||||||
|
public:
|
||||||
|
struct MercMerchantEntries {
|
||||||
|
uint32_t merc_merchant_entry_id;
|
||||||
|
uint32_t merc_merchant_template_id;
|
||||||
|
uint32_t merchant_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("merc_merchant_entry_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_merchant_entry_id",
|
||||||
|
"merc_merchant_template_id",
|
||||||
|
"merchant_id",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> SelectColumns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_merchant_entry_id",
|
||||||
|
"merc_merchant_template_id",
|
||||||
|
"merchant_id",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string SelectColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", SelectColumns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("merc_merchant_entries");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
SelectColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
ColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercMerchantEntries NewEntity()
|
||||||
|
{
|
||||||
|
MercMerchantEntries e{};
|
||||||
|
|
||||||
|
e.merc_merchant_entry_id = 0;
|
||||||
|
e.merc_merchant_template_id = 0;
|
||||||
|
e.merchant_id = 0;
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercMerchantEntries GetMercMerchantEntries(
|
||||||
|
const std::vector<MercMerchantEntries> &merc_merchant_entriess,
|
||||||
|
int merc_merchant_entries_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &merc_merchant_entries : merc_merchant_entriess) {
|
||||||
|
if (merc_merchant_entries.merc_merchant_entry_id == merc_merchant_entries_id) {
|
||||||
|
return merc_merchant_entries;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercMerchantEntries FindOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_merchant_entries_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {} = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_merchant_entries_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
MercMerchantEntries e{};
|
||||||
|
|
||||||
|
e.merc_merchant_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.merc_merchant_template_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.merchant_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_merchant_entries_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_merchant_entries_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Database& db,
|
||||||
|
const MercMerchantEntries &e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
v.push_back(columns[1] + " = " + std::to_string(e.merc_merchant_template_id));
|
||||||
|
v.push_back(columns[2] + " = " + std::to_string(e.merchant_id));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
Strings::Implode(", ", v),
|
||||||
|
PrimaryKey(),
|
||||||
|
e.merc_merchant_entry_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercMerchantEntries InsertOne(
|
||||||
|
Database& db,
|
||||||
|
MercMerchantEntries e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_merchant_entry_id));
|
||||||
|
v.push_back(std::to_string(e.merc_merchant_template_id));
|
||||||
|
v.push_back(std::to_string(e.merchant_id));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
e.merc_merchant_entry_id = results.LastInsertedID();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
e = NewEntity();
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
Database& db,
|
||||||
|
const std::vector<MercMerchantEntries> &entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &e: entries) {
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_merchant_entry_id));
|
||||||
|
v.push_back(std::to_string(e.merc_merchant_template_id));
|
||||||
|
v.push_back(std::to_string(e.merchant_id));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercMerchantEntries> All(Database& db)
|
||||||
|
{
|
||||||
|
std::vector<MercMerchantEntries> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercMerchantEntries e{};
|
||||||
|
|
||||||
|
e.merc_merchant_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.merc_merchant_template_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.merchant_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercMerchantEntries> GetWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
std::vector<MercMerchantEntries> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercMerchantEntries e{};
|
||||||
|
|
||||||
|
e.merc_merchant_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.merc_merchant_template_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.merchant_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 GetMaxId(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COALESCE(MAX({}), 0) FROM {}",
|
||||||
|
PrimaryKey(),
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 Count(Database& db, const std::string &where_filter = "")
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COUNT(*) FROM {} {}",
|
||||||
|
TableName(),
|
||||||
|
(where_filter.empty() ? "" : "WHERE " + where_filter)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_MERC_MERCHANT_ENTRIES_REPOSITORY_H
|
||||||
@ -0,0 +1,344 @@
|
|||||||
|
/**
|
||||||
|
* DO NOT MODIFY THIS FILE
|
||||||
|
*
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to the repository extending the base.
|
||||||
|
* Any modifications to base repositories are to be made by the generator only
|
||||||
|
*
|
||||||
|
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||||
|
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_MERC_MERCHANT_TEMPLATE_ENTRIES_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_MERC_MERCHANT_TEMPLATE_ENTRIES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../strings.h"
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
|
class BaseMercMerchantTemplateEntriesRepository {
|
||||||
|
public:
|
||||||
|
struct MercMerchantTemplateEntries {
|
||||||
|
uint32_t merc_merchant_template_entry_id;
|
||||||
|
uint32_t merc_merchant_template_id;
|
||||||
|
uint32_t merc_template_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("merc_merchant_template_entry_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_merchant_template_entry_id",
|
||||||
|
"merc_merchant_template_id",
|
||||||
|
"merc_template_id",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> SelectColumns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_merchant_template_entry_id",
|
||||||
|
"merc_merchant_template_id",
|
||||||
|
"merc_template_id",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string SelectColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", SelectColumns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("merc_merchant_template_entries");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
SelectColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
ColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercMerchantTemplateEntries NewEntity()
|
||||||
|
{
|
||||||
|
MercMerchantTemplateEntries e{};
|
||||||
|
|
||||||
|
e.merc_merchant_template_entry_id = 0;
|
||||||
|
e.merc_merchant_template_id = 0;
|
||||||
|
e.merc_template_id = 0;
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercMerchantTemplateEntries GetMercMerchantTemplateEntries(
|
||||||
|
const std::vector<MercMerchantTemplateEntries> &merc_merchant_template_entriess,
|
||||||
|
int merc_merchant_template_entries_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &merc_merchant_template_entries : merc_merchant_template_entriess) {
|
||||||
|
if (merc_merchant_template_entries.merc_merchant_template_entry_id == merc_merchant_template_entries_id) {
|
||||||
|
return merc_merchant_template_entries;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercMerchantTemplateEntries FindOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_merchant_template_entries_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {} = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_merchant_template_entries_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
MercMerchantTemplateEntries e{};
|
||||||
|
|
||||||
|
e.merc_merchant_template_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.merc_merchant_template_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.merc_template_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_merchant_template_entries_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_merchant_template_entries_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Database& db,
|
||||||
|
const MercMerchantTemplateEntries &e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
v.push_back(columns[1] + " = " + std::to_string(e.merc_merchant_template_id));
|
||||||
|
v.push_back(columns[2] + " = " + std::to_string(e.merc_template_id));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
Strings::Implode(", ", v),
|
||||||
|
PrimaryKey(),
|
||||||
|
e.merc_merchant_template_entry_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercMerchantTemplateEntries InsertOne(
|
||||||
|
Database& db,
|
||||||
|
MercMerchantTemplateEntries e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_merchant_template_entry_id));
|
||||||
|
v.push_back(std::to_string(e.merc_merchant_template_id));
|
||||||
|
v.push_back(std::to_string(e.merc_template_id));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
e.merc_merchant_template_entry_id = results.LastInsertedID();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
e = NewEntity();
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
Database& db,
|
||||||
|
const std::vector<MercMerchantTemplateEntries> &entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &e: entries) {
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_merchant_template_entry_id));
|
||||||
|
v.push_back(std::to_string(e.merc_merchant_template_id));
|
||||||
|
v.push_back(std::to_string(e.merc_template_id));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercMerchantTemplateEntries> All(Database& db)
|
||||||
|
{
|
||||||
|
std::vector<MercMerchantTemplateEntries> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercMerchantTemplateEntries e{};
|
||||||
|
|
||||||
|
e.merc_merchant_template_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.merc_merchant_template_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.merc_template_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercMerchantTemplateEntries> GetWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
std::vector<MercMerchantTemplateEntries> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercMerchantTemplateEntries e{};
|
||||||
|
|
||||||
|
e.merc_merchant_template_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.merc_merchant_template_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.merc_template_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 GetMaxId(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COALESCE(MAX({}), 0) FROM {}",
|
||||||
|
PrimaryKey(),
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 Count(Database& db, const std::string &where_filter = "")
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COUNT(*) FROM {} {}",
|
||||||
|
TableName(),
|
||||||
|
(where_filter.empty() ? "" : "WHERE " + where_filter)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_MERC_MERCHANT_TEMPLATE_ENTRIES_REPOSITORY_H
|
||||||
@ -0,0 +1,344 @@
|
|||||||
|
/**
|
||||||
|
* DO NOT MODIFY THIS FILE
|
||||||
|
*
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to the repository extending the base.
|
||||||
|
* Any modifications to base repositories are to be made by the generator only
|
||||||
|
*
|
||||||
|
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||||
|
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_MERC_MERCHANT_TEMPLATES_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_MERC_MERCHANT_TEMPLATES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../strings.h"
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
|
class BaseMercMerchantTemplatesRepository {
|
||||||
|
public:
|
||||||
|
struct MercMerchantTemplates {
|
||||||
|
uint32_t merc_merchant_template_id;
|
||||||
|
std::string name;
|
||||||
|
std::string qglobal;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("merc_merchant_template_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_merchant_template_id",
|
||||||
|
"name",
|
||||||
|
"qglobal",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> SelectColumns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_merchant_template_id",
|
||||||
|
"name",
|
||||||
|
"qglobal",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string SelectColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", SelectColumns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("merc_merchant_templates");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
SelectColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
ColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercMerchantTemplates NewEntity()
|
||||||
|
{
|
||||||
|
MercMerchantTemplates e{};
|
||||||
|
|
||||||
|
e.merc_merchant_template_id = 0;
|
||||||
|
e.name = "";
|
||||||
|
e.qglobal = "";
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercMerchantTemplates GetMercMerchantTemplates(
|
||||||
|
const std::vector<MercMerchantTemplates> &merc_merchant_templatess,
|
||||||
|
int merc_merchant_templates_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &merc_merchant_templates : merc_merchant_templatess) {
|
||||||
|
if (merc_merchant_templates.merc_merchant_template_id == merc_merchant_templates_id) {
|
||||||
|
return merc_merchant_templates;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercMerchantTemplates FindOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_merchant_templates_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {} = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_merchant_templates_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
MercMerchantTemplates e{};
|
||||||
|
|
||||||
|
e.merc_merchant_template_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.name = row[1] ? row[1] : "";
|
||||||
|
e.qglobal = row[2] ? row[2] : "";
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_merchant_templates_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_merchant_templates_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Database& db,
|
||||||
|
const MercMerchantTemplates &e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'");
|
||||||
|
v.push_back(columns[2] + " = '" + Strings::Escape(e.qglobal) + "'");
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
Strings::Implode(", ", v),
|
||||||
|
PrimaryKey(),
|
||||||
|
e.merc_merchant_template_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercMerchantTemplates InsertOne(
|
||||||
|
Database& db,
|
||||||
|
MercMerchantTemplates e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_merchant_template_id));
|
||||||
|
v.push_back("'" + Strings::Escape(e.name) + "'");
|
||||||
|
v.push_back("'" + Strings::Escape(e.qglobal) + "'");
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
e.merc_merchant_template_id = results.LastInsertedID();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
e = NewEntity();
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
Database& db,
|
||||||
|
const std::vector<MercMerchantTemplates> &entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &e: entries) {
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_merchant_template_id));
|
||||||
|
v.push_back("'" + Strings::Escape(e.name) + "'");
|
||||||
|
v.push_back("'" + Strings::Escape(e.qglobal) + "'");
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercMerchantTemplates> All(Database& db)
|
||||||
|
{
|
||||||
|
std::vector<MercMerchantTemplates> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercMerchantTemplates e{};
|
||||||
|
|
||||||
|
e.merc_merchant_template_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.name = row[1] ? row[1] : "";
|
||||||
|
e.qglobal = row[2] ? row[2] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercMerchantTemplates> GetWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
std::vector<MercMerchantTemplates> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercMerchantTemplates e{};
|
||||||
|
|
||||||
|
e.merc_merchant_template_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.name = row[1] ? row[1] : "";
|
||||||
|
e.qglobal = row[2] ? row[2] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 GetMaxId(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COALESCE(MAX({}), 0) FROM {}",
|
||||||
|
PrimaryKey(),
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 Count(Database& db, const std::string &where_filter = "")
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COUNT(*) FROM {} {}",
|
||||||
|
TableName(),
|
||||||
|
(where_filter.empty() ? "" : "WHERE " + where_filter)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_MERC_MERCHANT_TEMPLATES_REPOSITORY_H
|
||||||
355
common/repositories/base/base_merc_name_types_repository.h
Normal file
355
common/repositories/base/base_merc_name_types_repository.h
Normal file
@ -0,0 +1,355 @@
|
|||||||
|
/**
|
||||||
|
* DO NOT MODIFY THIS FILE
|
||||||
|
*
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to the repository extending the base.
|
||||||
|
* Any modifications to base repositories are to be made by the generator only
|
||||||
|
*
|
||||||
|
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||||
|
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_MERC_NAME_TYPES_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_MERC_NAME_TYPES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../strings.h"
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
|
class BaseMercNameTypesRepository {
|
||||||
|
public:
|
||||||
|
struct MercNameTypes {
|
||||||
|
uint32_t name_type_id;
|
||||||
|
uint32_t class_id;
|
||||||
|
std::string prefix;
|
||||||
|
std::string suffix;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("name_type_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"name_type_id",
|
||||||
|
"class_id",
|
||||||
|
"prefix",
|
||||||
|
"suffix",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> SelectColumns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"name_type_id",
|
||||||
|
"class_id",
|
||||||
|
"prefix",
|
||||||
|
"suffix",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string SelectColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", SelectColumns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("merc_name_types");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
SelectColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
ColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercNameTypes NewEntity()
|
||||||
|
{
|
||||||
|
MercNameTypes e{};
|
||||||
|
|
||||||
|
e.name_type_id = 0;
|
||||||
|
e.class_id = 0;
|
||||||
|
e.prefix = "";
|
||||||
|
e.suffix = "";
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercNameTypes GetMercNameTypes(
|
||||||
|
const std::vector<MercNameTypes> &merc_name_typess,
|
||||||
|
int merc_name_types_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &merc_name_types : merc_name_typess) {
|
||||||
|
if (merc_name_types.name_type_id == merc_name_types_id) {
|
||||||
|
return merc_name_types;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercNameTypes FindOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_name_types_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {} = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_name_types_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
MercNameTypes e{};
|
||||||
|
|
||||||
|
e.name_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.prefix = row[2] ? row[2] : "";
|
||||||
|
e.suffix = row[3] ? row[3] : "";
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_name_types_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_name_types_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Database& db,
|
||||||
|
const MercNameTypes &e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
v.push_back(columns[0] + " = " + std::to_string(e.name_type_id));
|
||||||
|
v.push_back(columns[1] + " = " + std::to_string(e.class_id));
|
||||||
|
v.push_back(columns[2] + " = '" + Strings::Escape(e.prefix) + "'");
|
||||||
|
v.push_back(columns[3] + " = '" + Strings::Escape(e.suffix) + "'");
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
Strings::Implode(", ", v),
|
||||||
|
PrimaryKey(),
|
||||||
|
e.name_type_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercNameTypes InsertOne(
|
||||||
|
Database& db,
|
||||||
|
MercNameTypes e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.name_type_id));
|
||||||
|
v.push_back(std::to_string(e.class_id));
|
||||||
|
v.push_back("'" + Strings::Escape(e.prefix) + "'");
|
||||||
|
v.push_back("'" + Strings::Escape(e.suffix) + "'");
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
e.name_type_id = results.LastInsertedID();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
e = NewEntity();
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
Database& db,
|
||||||
|
const std::vector<MercNameTypes> &entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &e: entries) {
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.name_type_id));
|
||||||
|
v.push_back(std::to_string(e.class_id));
|
||||||
|
v.push_back("'" + Strings::Escape(e.prefix) + "'");
|
||||||
|
v.push_back("'" + Strings::Escape(e.suffix) + "'");
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercNameTypes> All(Database& db)
|
||||||
|
{
|
||||||
|
std::vector<MercNameTypes> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercNameTypes e{};
|
||||||
|
|
||||||
|
e.name_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.prefix = row[2] ? row[2] : "";
|
||||||
|
e.suffix = row[3] ? row[3] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercNameTypes> GetWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
std::vector<MercNameTypes> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercNameTypes e{};
|
||||||
|
|
||||||
|
e.name_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.prefix = row[2] ? row[2] : "";
|
||||||
|
e.suffix = row[3] ? row[3] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 GetMaxId(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COALESCE(MAX({}), 0) FROM {}",
|
||||||
|
PrimaryKey(),
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 Count(Database& db, const std::string &where_filter = "")
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COUNT(*) FROM {} {}",
|
||||||
|
TableName(),
|
||||||
|
(where_filter.empty() ? "" : "WHERE " + where_filter)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_MERC_NAME_TYPES_REPOSITORY_H
|
||||||
364
common/repositories/base/base_merc_npc_types_repository.h
Normal file
364
common/repositories/base/base_merc_npc_types_repository.h
Normal file
@ -0,0 +1,364 @@
|
|||||||
|
/**
|
||||||
|
* DO NOT MODIFY THIS FILE
|
||||||
|
*
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to the repository extending the base.
|
||||||
|
* Any modifications to base repositories are to be made by the generator only
|
||||||
|
*
|
||||||
|
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||||
|
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_MERC_NPC_TYPES_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_MERC_NPC_TYPES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../strings.h"
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
|
class BaseMercNpcTypesRepository {
|
||||||
|
public:
|
||||||
|
struct MercNpcTypes {
|
||||||
|
uint32_t merc_npc_type_id;
|
||||||
|
uint8_t proficiency_id;
|
||||||
|
uint8_t tier_id;
|
||||||
|
uint32_t class_id;
|
||||||
|
std::string name;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("merc_npc_type_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_npc_type_id",
|
||||||
|
"proficiency_id",
|
||||||
|
"tier_id",
|
||||||
|
"class_id",
|
||||||
|
"name",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> SelectColumns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_npc_type_id",
|
||||||
|
"proficiency_id",
|
||||||
|
"tier_id",
|
||||||
|
"class_id",
|
||||||
|
"name",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string SelectColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", SelectColumns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("merc_npc_types");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
SelectColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
ColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercNpcTypes NewEntity()
|
||||||
|
{
|
||||||
|
MercNpcTypes e{};
|
||||||
|
|
||||||
|
e.merc_npc_type_id = 0;
|
||||||
|
e.proficiency_id = 0;
|
||||||
|
e.tier_id = 0;
|
||||||
|
e.class_id = 0;
|
||||||
|
e.name = "";
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercNpcTypes GetMercNpcTypes(
|
||||||
|
const std::vector<MercNpcTypes> &merc_npc_typess,
|
||||||
|
int merc_npc_types_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &merc_npc_types : merc_npc_typess) {
|
||||||
|
if (merc_npc_types.merc_npc_type_id == merc_npc_types_id) {
|
||||||
|
return merc_npc_types;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercNpcTypes FindOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_npc_types_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {} = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_npc_types_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
MercNpcTypes e{};
|
||||||
|
|
||||||
|
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.proficiency_id = static_cast<uint8_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.tier_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.class_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.name = row[4] ? row[4] : "";
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_npc_types_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_npc_types_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Database& db,
|
||||||
|
const MercNpcTypes &e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
v.push_back(columns[1] + " = " + std::to_string(e.proficiency_id));
|
||||||
|
v.push_back(columns[2] + " = " + std::to_string(e.tier_id));
|
||||||
|
v.push_back(columns[3] + " = " + std::to_string(e.class_id));
|
||||||
|
v.push_back(columns[4] + " = '" + Strings::Escape(e.name) + "'");
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
Strings::Implode(", ", v),
|
||||||
|
PrimaryKey(),
|
||||||
|
e.merc_npc_type_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercNpcTypes InsertOne(
|
||||||
|
Database& db,
|
||||||
|
MercNpcTypes e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_npc_type_id));
|
||||||
|
v.push_back(std::to_string(e.proficiency_id));
|
||||||
|
v.push_back(std::to_string(e.tier_id));
|
||||||
|
v.push_back(std::to_string(e.class_id));
|
||||||
|
v.push_back("'" + Strings::Escape(e.name) + "'");
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
e.merc_npc_type_id = results.LastInsertedID();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
e = NewEntity();
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
Database& db,
|
||||||
|
const std::vector<MercNpcTypes> &entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &e: entries) {
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_npc_type_id));
|
||||||
|
v.push_back(std::to_string(e.proficiency_id));
|
||||||
|
v.push_back(std::to_string(e.tier_id));
|
||||||
|
v.push_back(std::to_string(e.class_id));
|
||||||
|
v.push_back("'" + Strings::Escape(e.name) + "'");
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercNpcTypes> All(Database& db)
|
||||||
|
{
|
||||||
|
std::vector<MercNpcTypes> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercNpcTypes e{};
|
||||||
|
|
||||||
|
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.proficiency_id = static_cast<uint8_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.tier_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.class_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.name = row[4] ? row[4] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercNpcTypes> GetWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
std::vector<MercNpcTypes> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercNpcTypes e{};
|
||||||
|
|
||||||
|
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.proficiency_id = static_cast<uint8_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.tier_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.class_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.name = row[4] ? row[4] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 GetMaxId(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COALESCE(MAX({}), 0) FROM {}",
|
||||||
|
PrimaryKey(),
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 Count(Database& db, const std::string &where_filter = "")
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COUNT(*) FROM {} {}",
|
||||||
|
TableName(),
|
||||||
|
(where_filter.empty() ? "" : "WHERE " + where_filter)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_MERC_NPC_TYPES_REPOSITORY_H
|
||||||
@ -0,0 +1,404 @@
|
|||||||
|
/**
|
||||||
|
* DO NOT MODIFY THIS FILE
|
||||||
|
*
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to the repository extending the base.
|
||||||
|
* Any modifications to base repositories are to be made by the generator only
|
||||||
|
*
|
||||||
|
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||||
|
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_MERC_SPELL_LIST_ENTRIES_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_MERC_SPELL_LIST_ENTRIES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../strings.h"
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
|
class BaseMercSpellListEntriesRepository {
|
||||||
|
public:
|
||||||
|
struct MercSpellListEntries {
|
||||||
|
uint32_t merc_spell_list_entry_id;
|
||||||
|
uint32_t merc_spell_list_id;
|
||||||
|
uint32_t spell_id;
|
||||||
|
uint32_t spell_type;
|
||||||
|
uint8_t stance_id;
|
||||||
|
uint8_t minlevel;
|
||||||
|
uint8_t maxlevel;
|
||||||
|
int8_t slot;
|
||||||
|
uint8_t procChance;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("merc_spell_list_entry_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_spell_list_entry_id",
|
||||||
|
"merc_spell_list_id",
|
||||||
|
"spell_id",
|
||||||
|
"spell_type",
|
||||||
|
"stance_id",
|
||||||
|
"minlevel",
|
||||||
|
"maxlevel",
|
||||||
|
"slot",
|
||||||
|
"procChance",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> SelectColumns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_spell_list_entry_id",
|
||||||
|
"merc_spell_list_id",
|
||||||
|
"spell_id",
|
||||||
|
"spell_type",
|
||||||
|
"stance_id",
|
||||||
|
"minlevel",
|
||||||
|
"maxlevel",
|
||||||
|
"slot",
|
||||||
|
"procChance",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string SelectColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", SelectColumns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("merc_spell_list_entries");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
SelectColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
ColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercSpellListEntries NewEntity()
|
||||||
|
{
|
||||||
|
MercSpellListEntries e{};
|
||||||
|
|
||||||
|
e.merc_spell_list_entry_id = 0;
|
||||||
|
e.merc_spell_list_id = 0;
|
||||||
|
e.spell_id = 0;
|
||||||
|
e.spell_type = 0;
|
||||||
|
e.stance_id = 0;
|
||||||
|
e.minlevel = 1;
|
||||||
|
e.maxlevel = 255;
|
||||||
|
e.slot = -1;
|
||||||
|
e.procChance = 0;
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercSpellListEntries GetMercSpellListEntries(
|
||||||
|
const std::vector<MercSpellListEntries> &merc_spell_list_entriess,
|
||||||
|
int merc_spell_list_entries_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &merc_spell_list_entries : merc_spell_list_entriess) {
|
||||||
|
if (merc_spell_list_entries.merc_spell_list_entry_id == merc_spell_list_entries_id) {
|
||||||
|
return merc_spell_list_entries;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercSpellListEntries FindOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_spell_list_entries_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {} = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_spell_list_entries_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
MercSpellListEntries e{};
|
||||||
|
|
||||||
|
e.merc_spell_list_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.merc_spell_list_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.spell_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.spell_type = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.stance_id = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
|
||||||
|
e.minlevel = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
|
||||||
|
e.maxlevel = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
|
||||||
|
e.slot = static_cast<int8_t>(atoi(row[7]));
|
||||||
|
e.procChance = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_spell_list_entries_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_spell_list_entries_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Database& db,
|
||||||
|
const MercSpellListEntries &e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
v.push_back(columns[1] + " = " + std::to_string(e.merc_spell_list_id));
|
||||||
|
v.push_back(columns[2] + " = " + std::to_string(e.spell_id));
|
||||||
|
v.push_back(columns[3] + " = " + std::to_string(e.spell_type));
|
||||||
|
v.push_back(columns[4] + " = " + std::to_string(e.stance_id));
|
||||||
|
v.push_back(columns[5] + " = " + std::to_string(e.minlevel));
|
||||||
|
v.push_back(columns[6] + " = " + std::to_string(e.maxlevel));
|
||||||
|
v.push_back(columns[7] + " = " + std::to_string(e.slot));
|
||||||
|
v.push_back(columns[8] + " = " + std::to_string(e.procChance));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
Strings::Implode(", ", v),
|
||||||
|
PrimaryKey(),
|
||||||
|
e.merc_spell_list_entry_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercSpellListEntries InsertOne(
|
||||||
|
Database& db,
|
||||||
|
MercSpellListEntries e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_spell_list_entry_id));
|
||||||
|
v.push_back(std::to_string(e.merc_spell_list_id));
|
||||||
|
v.push_back(std::to_string(e.spell_id));
|
||||||
|
v.push_back(std::to_string(e.spell_type));
|
||||||
|
v.push_back(std::to_string(e.stance_id));
|
||||||
|
v.push_back(std::to_string(e.minlevel));
|
||||||
|
v.push_back(std::to_string(e.maxlevel));
|
||||||
|
v.push_back(std::to_string(e.slot));
|
||||||
|
v.push_back(std::to_string(e.procChance));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
e.merc_spell_list_entry_id = results.LastInsertedID();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
e = NewEntity();
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
Database& db,
|
||||||
|
const std::vector<MercSpellListEntries> &entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &e: entries) {
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_spell_list_entry_id));
|
||||||
|
v.push_back(std::to_string(e.merc_spell_list_id));
|
||||||
|
v.push_back(std::to_string(e.spell_id));
|
||||||
|
v.push_back(std::to_string(e.spell_type));
|
||||||
|
v.push_back(std::to_string(e.stance_id));
|
||||||
|
v.push_back(std::to_string(e.minlevel));
|
||||||
|
v.push_back(std::to_string(e.maxlevel));
|
||||||
|
v.push_back(std::to_string(e.slot));
|
||||||
|
v.push_back(std::to_string(e.procChance));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercSpellListEntries> All(Database& db)
|
||||||
|
{
|
||||||
|
std::vector<MercSpellListEntries> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercSpellListEntries e{};
|
||||||
|
|
||||||
|
e.merc_spell_list_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.merc_spell_list_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.spell_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.spell_type = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.stance_id = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
|
||||||
|
e.minlevel = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
|
||||||
|
e.maxlevel = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
|
||||||
|
e.slot = static_cast<int8_t>(atoi(row[7]));
|
||||||
|
e.procChance = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercSpellListEntries> GetWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
std::vector<MercSpellListEntries> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercSpellListEntries e{};
|
||||||
|
|
||||||
|
e.merc_spell_list_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.merc_spell_list_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.spell_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.spell_type = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.stance_id = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
|
||||||
|
e.minlevel = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
|
||||||
|
e.maxlevel = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
|
||||||
|
e.slot = static_cast<int8_t>(atoi(row[7]));
|
||||||
|
e.procChance = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 GetMaxId(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COALESCE(MAX({}), 0) FROM {}",
|
||||||
|
PrimaryKey(),
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 Count(Database& db, const std::string &where_filter = "")
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COUNT(*) FROM {} {}",
|
||||||
|
TableName(),
|
||||||
|
(where_filter.empty() ? "" : "WHERE " + where_filter)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_MERC_SPELL_LIST_ENTRIES_REPOSITORY_H
|
||||||
354
common/repositories/base/base_merc_spell_lists_repository.h
Normal file
354
common/repositories/base/base_merc_spell_lists_repository.h
Normal file
@ -0,0 +1,354 @@
|
|||||||
|
/**
|
||||||
|
* DO NOT MODIFY THIS FILE
|
||||||
|
*
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to the repository extending the base.
|
||||||
|
* Any modifications to base repositories are to be made by the generator only
|
||||||
|
*
|
||||||
|
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||||
|
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_MERC_SPELL_LISTS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_MERC_SPELL_LISTS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../strings.h"
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
|
class BaseMercSpellListsRepository {
|
||||||
|
public:
|
||||||
|
struct MercSpellLists {
|
||||||
|
uint32_t merc_spell_list_id;
|
||||||
|
uint32_t class_id;
|
||||||
|
uint8_t proficiency_id;
|
||||||
|
std::string name;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("merc_spell_list_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_spell_list_id",
|
||||||
|
"class_id",
|
||||||
|
"proficiency_id",
|
||||||
|
"name",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> SelectColumns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_spell_list_id",
|
||||||
|
"class_id",
|
||||||
|
"proficiency_id",
|
||||||
|
"name",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string SelectColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", SelectColumns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("merc_spell_lists");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
SelectColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
ColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercSpellLists NewEntity()
|
||||||
|
{
|
||||||
|
MercSpellLists e{};
|
||||||
|
|
||||||
|
e.merc_spell_list_id = 0;
|
||||||
|
e.class_id = 0;
|
||||||
|
e.proficiency_id = 0;
|
||||||
|
e.name = "";
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercSpellLists GetMercSpellLists(
|
||||||
|
const std::vector<MercSpellLists> &merc_spell_listss,
|
||||||
|
int merc_spell_lists_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &merc_spell_lists : merc_spell_listss) {
|
||||||
|
if (merc_spell_lists.merc_spell_list_id == merc_spell_lists_id) {
|
||||||
|
return merc_spell_lists;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercSpellLists FindOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_spell_lists_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {} = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_spell_lists_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
MercSpellLists e{};
|
||||||
|
|
||||||
|
e.merc_spell_list_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.proficiency_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.name = row[3] ? row[3] : "";
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_spell_lists_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_spell_lists_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Database& db,
|
||||||
|
const MercSpellLists &e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
v.push_back(columns[1] + " = " + std::to_string(e.class_id));
|
||||||
|
v.push_back(columns[2] + " = " + std::to_string(e.proficiency_id));
|
||||||
|
v.push_back(columns[3] + " = '" + Strings::Escape(e.name) + "'");
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
Strings::Implode(", ", v),
|
||||||
|
PrimaryKey(),
|
||||||
|
e.merc_spell_list_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercSpellLists InsertOne(
|
||||||
|
Database& db,
|
||||||
|
MercSpellLists e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_spell_list_id));
|
||||||
|
v.push_back(std::to_string(e.class_id));
|
||||||
|
v.push_back(std::to_string(e.proficiency_id));
|
||||||
|
v.push_back("'" + Strings::Escape(e.name) + "'");
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
e.merc_spell_list_id = results.LastInsertedID();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
e = NewEntity();
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
Database& db,
|
||||||
|
const std::vector<MercSpellLists> &entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &e: entries) {
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_spell_list_id));
|
||||||
|
v.push_back(std::to_string(e.class_id));
|
||||||
|
v.push_back(std::to_string(e.proficiency_id));
|
||||||
|
v.push_back("'" + Strings::Escape(e.name) + "'");
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercSpellLists> All(Database& db)
|
||||||
|
{
|
||||||
|
std::vector<MercSpellLists> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercSpellLists e{};
|
||||||
|
|
||||||
|
e.merc_spell_list_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.proficiency_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.name = row[3] ? row[3] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercSpellLists> GetWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
std::vector<MercSpellLists> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercSpellLists e{};
|
||||||
|
|
||||||
|
e.merc_spell_list_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.proficiency_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.name = row[3] ? row[3] : "";
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 GetMaxId(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COALESCE(MAX({}), 0) FROM {}",
|
||||||
|
PrimaryKey(),
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 Count(Database& db, const std::string &where_filter = "")
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COUNT(*) FROM {} {}",
|
||||||
|
TableName(),
|
||||||
|
(where_filter.empty() ? "" : "WHERE " + where_filter)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_MERC_SPELL_LISTS_REPOSITORY_H
|
||||||
364
common/repositories/base/base_merc_stance_entries_repository.h
Normal file
364
common/repositories/base/base_merc_stance_entries_repository.h
Normal file
@ -0,0 +1,364 @@
|
|||||||
|
/**
|
||||||
|
* DO NOT MODIFY THIS FILE
|
||||||
|
*
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to the repository extending the base.
|
||||||
|
* Any modifications to base repositories are to be made by the generator only
|
||||||
|
*
|
||||||
|
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||||
|
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_MERC_STANCE_ENTRIES_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_MERC_STANCE_ENTRIES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../strings.h"
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
|
class BaseMercStanceEntriesRepository {
|
||||||
|
public:
|
||||||
|
struct MercStanceEntries {
|
||||||
|
uint32_t merc_stance_entry_id;
|
||||||
|
uint32_t class_id;
|
||||||
|
uint8_t proficiency_id;
|
||||||
|
uint8_t stance_id;
|
||||||
|
int8_t isdefault;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("merc_stance_entry_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_stance_entry_id",
|
||||||
|
"class_id",
|
||||||
|
"proficiency_id",
|
||||||
|
"stance_id",
|
||||||
|
"isdefault",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> SelectColumns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_stance_entry_id",
|
||||||
|
"class_id",
|
||||||
|
"proficiency_id",
|
||||||
|
"stance_id",
|
||||||
|
"isdefault",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string SelectColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", SelectColumns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("merc_stance_entries");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
SelectColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
ColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercStanceEntries NewEntity()
|
||||||
|
{
|
||||||
|
MercStanceEntries e{};
|
||||||
|
|
||||||
|
e.merc_stance_entry_id = 0;
|
||||||
|
e.class_id = 0;
|
||||||
|
e.proficiency_id = 0;
|
||||||
|
e.stance_id = 0;
|
||||||
|
e.isdefault = 0;
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercStanceEntries GetMercStanceEntries(
|
||||||
|
const std::vector<MercStanceEntries> &merc_stance_entriess,
|
||||||
|
int merc_stance_entries_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &merc_stance_entries : merc_stance_entriess) {
|
||||||
|
if (merc_stance_entries.merc_stance_entry_id == merc_stance_entries_id) {
|
||||||
|
return merc_stance_entries;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercStanceEntries FindOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_stance_entries_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {} = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_stance_entries_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
MercStanceEntries e{};
|
||||||
|
|
||||||
|
e.merc_stance_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.proficiency_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.stance_id = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.isdefault = static_cast<int8_t>(atoi(row[4]));
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_stance_entries_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_stance_entries_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Database& db,
|
||||||
|
const MercStanceEntries &e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
v.push_back(columns[1] + " = " + std::to_string(e.class_id));
|
||||||
|
v.push_back(columns[2] + " = " + std::to_string(e.proficiency_id));
|
||||||
|
v.push_back(columns[3] + " = " + std::to_string(e.stance_id));
|
||||||
|
v.push_back(columns[4] + " = " + std::to_string(e.isdefault));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
Strings::Implode(", ", v),
|
||||||
|
PrimaryKey(),
|
||||||
|
e.merc_stance_entry_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercStanceEntries InsertOne(
|
||||||
|
Database& db,
|
||||||
|
MercStanceEntries e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_stance_entry_id));
|
||||||
|
v.push_back(std::to_string(e.class_id));
|
||||||
|
v.push_back(std::to_string(e.proficiency_id));
|
||||||
|
v.push_back(std::to_string(e.stance_id));
|
||||||
|
v.push_back(std::to_string(e.isdefault));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
e.merc_stance_entry_id = results.LastInsertedID();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
e = NewEntity();
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
Database& db,
|
||||||
|
const std::vector<MercStanceEntries> &entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &e: entries) {
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_stance_entry_id));
|
||||||
|
v.push_back(std::to_string(e.class_id));
|
||||||
|
v.push_back(std::to_string(e.proficiency_id));
|
||||||
|
v.push_back(std::to_string(e.stance_id));
|
||||||
|
v.push_back(std::to_string(e.isdefault));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercStanceEntries> All(Database& db)
|
||||||
|
{
|
||||||
|
std::vector<MercStanceEntries> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercStanceEntries e{};
|
||||||
|
|
||||||
|
e.merc_stance_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.proficiency_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.stance_id = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.isdefault = static_cast<int8_t>(atoi(row[4]));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercStanceEntries> GetWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
std::vector<MercStanceEntries> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercStanceEntries e{};
|
||||||
|
|
||||||
|
e.merc_stance_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.proficiency_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.stance_id = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.isdefault = static_cast<int8_t>(atoi(row[4]));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 GetMaxId(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COALESCE(MAX({}), 0) FROM {}",
|
||||||
|
PrimaryKey(),
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 Count(Database& db, const std::string &where_filter = "")
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COUNT(*) FROM {} {}",
|
||||||
|
TableName(),
|
||||||
|
(where_filter.empty() ? "" : "WHERE " + where_filter)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_MERC_STANCE_ENTRIES_REPOSITORY_H
|
||||||
645
common/repositories/base/base_merc_stats_repository.h
Normal file
645
common/repositories/base/base_merc_stats_repository.h
Normal file
@ -0,0 +1,645 @@
|
|||||||
|
/**
|
||||||
|
* DO NOT MODIFY THIS FILE
|
||||||
|
*
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to the repository extending the base.
|
||||||
|
* Any modifications to base repositories are to be made by the generator only
|
||||||
|
*
|
||||||
|
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||||
|
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_MERC_STATS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_MERC_STATS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../strings.h"
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
|
class BaseMercStatsRepository {
|
||||||
|
public:
|
||||||
|
struct MercStats {
|
||||||
|
uint32_t merc_npc_type_id;
|
||||||
|
uint8_t clientlevel;
|
||||||
|
uint8_t level;
|
||||||
|
int32_t hp;
|
||||||
|
int32_t mana;
|
||||||
|
int16_t AC;
|
||||||
|
int32_t ATK;
|
||||||
|
uint32_t STR;
|
||||||
|
uint32_t STA;
|
||||||
|
uint32_t DEX;
|
||||||
|
uint32_t AGI;
|
||||||
|
uint32_t _INT;
|
||||||
|
uint32_t WIS;
|
||||||
|
uint32_t CHA;
|
||||||
|
int16_t MR;
|
||||||
|
int16_t CR;
|
||||||
|
int16_t DR;
|
||||||
|
int16_t FR;
|
||||||
|
int16_t PR;
|
||||||
|
int16_t Corrup;
|
||||||
|
uint32_t mindmg;
|
||||||
|
uint32_t maxdmg;
|
||||||
|
int16_t attack_count;
|
||||||
|
int8_t attack_speed;
|
||||||
|
uint8_t attack_delay;
|
||||||
|
std::string special_abilities;
|
||||||
|
int32_t Accuracy;
|
||||||
|
uint32_t hp_regen_rate;
|
||||||
|
uint32_t mana_regen_rate;
|
||||||
|
float runspeed;
|
||||||
|
int32_t statscale;
|
||||||
|
float spellscale;
|
||||||
|
float healscale;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("merc_npc_type_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_npc_type_id",
|
||||||
|
"clientlevel",
|
||||||
|
"level",
|
||||||
|
"hp",
|
||||||
|
"mana",
|
||||||
|
"AC",
|
||||||
|
"ATK",
|
||||||
|
"STR",
|
||||||
|
"STA",
|
||||||
|
"DEX",
|
||||||
|
"AGI",
|
||||||
|
"_INT",
|
||||||
|
"WIS",
|
||||||
|
"CHA",
|
||||||
|
"MR",
|
||||||
|
"CR",
|
||||||
|
"DR",
|
||||||
|
"FR",
|
||||||
|
"PR",
|
||||||
|
"Corrup",
|
||||||
|
"mindmg",
|
||||||
|
"maxdmg",
|
||||||
|
"attack_count",
|
||||||
|
"attack_speed",
|
||||||
|
"attack_delay",
|
||||||
|
"special_abilities",
|
||||||
|
"Accuracy",
|
||||||
|
"hp_regen_rate",
|
||||||
|
"mana_regen_rate",
|
||||||
|
"runspeed",
|
||||||
|
"statscale",
|
||||||
|
"spellscale",
|
||||||
|
"healscale",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> SelectColumns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_npc_type_id",
|
||||||
|
"clientlevel",
|
||||||
|
"level",
|
||||||
|
"hp",
|
||||||
|
"mana",
|
||||||
|
"AC",
|
||||||
|
"ATK",
|
||||||
|
"STR",
|
||||||
|
"STA",
|
||||||
|
"DEX",
|
||||||
|
"AGI",
|
||||||
|
"_INT",
|
||||||
|
"WIS",
|
||||||
|
"CHA",
|
||||||
|
"MR",
|
||||||
|
"CR",
|
||||||
|
"DR",
|
||||||
|
"FR",
|
||||||
|
"PR",
|
||||||
|
"Corrup",
|
||||||
|
"mindmg",
|
||||||
|
"maxdmg",
|
||||||
|
"attack_count",
|
||||||
|
"attack_speed",
|
||||||
|
"attack_delay",
|
||||||
|
"special_abilities",
|
||||||
|
"Accuracy",
|
||||||
|
"hp_regen_rate",
|
||||||
|
"mana_regen_rate",
|
||||||
|
"runspeed",
|
||||||
|
"statscale",
|
||||||
|
"spellscale",
|
||||||
|
"healscale",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string SelectColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", SelectColumns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("merc_stats");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
SelectColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
ColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercStats NewEntity()
|
||||||
|
{
|
||||||
|
MercStats e{};
|
||||||
|
|
||||||
|
e.merc_npc_type_id = 0;
|
||||||
|
e.clientlevel = 1;
|
||||||
|
e.level = 1;
|
||||||
|
e.hp = 1;
|
||||||
|
e.mana = 0;
|
||||||
|
e.AC = 1;
|
||||||
|
e.ATK = 1;
|
||||||
|
e.STR = 75;
|
||||||
|
e.STA = 75;
|
||||||
|
e.DEX = 75;
|
||||||
|
e.AGI = 75;
|
||||||
|
e._INT = 80;
|
||||||
|
e.WIS = 80;
|
||||||
|
e.CHA = 75;
|
||||||
|
e.MR = 15;
|
||||||
|
e.CR = 15;
|
||||||
|
e.DR = 15;
|
||||||
|
e.FR = 15;
|
||||||
|
e.PR = 15;
|
||||||
|
e.Corrup = 15;
|
||||||
|
e.mindmg = 1;
|
||||||
|
e.maxdmg = 1;
|
||||||
|
e.attack_count = 0;
|
||||||
|
e.attack_speed = 0;
|
||||||
|
e.attack_delay = 30;
|
||||||
|
e.special_abilities = "";
|
||||||
|
e.Accuracy = 0;
|
||||||
|
e.hp_regen_rate = 1;
|
||||||
|
e.mana_regen_rate = 1;
|
||||||
|
e.runspeed = 0;
|
||||||
|
e.statscale = 100;
|
||||||
|
e.spellscale = 100;
|
||||||
|
e.healscale = 100;
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercStats GetMercStats(
|
||||||
|
const std::vector<MercStats> &merc_statss,
|
||||||
|
int merc_stats_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &merc_stats : merc_statss) {
|
||||||
|
if (merc_stats.merc_npc_type_id == merc_stats_id) {
|
||||||
|
return merc_stats;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercStats FindOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_stats_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {} = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_stats_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
MercStats e{};
|
||||||
|
|
||||||
|
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.clientlevel = static_cast<uint8_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.level = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.hp = static_cast<int32_t>(atoi(row[3]));
|
||||||
|
e.mana = static_cast<int32_t>(atoi(row[4]));
|
||||||
|
e.AC = static_cast<int16_t>(atoi(row[5]));
|
||||||
|
e.ATK = static_cast<int32_t>(atoi(row[6]));
|
||||||
|
e.STR = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
|
||||||
|
e.STA = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
|
||||||
|
e.DEX = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
|
||||||
|
e.AGI = static_cast<uint32_t>(strtoul(row[10], nullptr, 10));
|
||||||
|
e._INT = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
|
||||||
|
e.WIS = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
|
||||||
|
e.CHA = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
|
||||||
|
e.MR = static_cast<int16_t>(atoi(row[14]));
|
||||||
|
e.CR = static_cast<int16_t>(atoi(row[15]));
|
||||||
|
e.DR = static_cast<int16_t>(atoi(row[16]));
|
||||||
|
e.FR = static_cast<int16_t>(atoi(row[17]));
|
||||||
|
e.PR = static_cast<int16_t>(atoi(row[18]));
|
||||||
|
e.Corrup = static_cast<int16_t>(atoi(row[19]));
|
||||||
|
e.mindmg = static_cast<uint32_t>(strtoul(row[20], nullptr, 10));
|
||||||
|
e.maxdmg = static_cast<uint32_t>(strtoul(row[21], nullptr, 10));
|
||||||
|
e.attack_count = static_cast<int16_t>(atoi(row[22]));
|
||||||
|
e.attack_speed = static_cast<int8_t>(atoi(row[23]));
|
||||||
|
e.attack_delay = static_cast<uint8_t>(strtoul(row[24], nullptr, 10));
|
||||||
|
e.special_abilities = row[25] ? row[25] : "";
|
||||||
|
e.Accuracy = static_cast<int32_t>(atoi(row[26]));
|
||||||
|
e.hp_regen_rate = static_cast<uint32_t>(strtoul(row[27], nullptr, 10));
|
||||||
|
e.mana_regen_rate = static_cast<uint32_t>(strtoul(row[28], nullptr, 10));
|
||||||
|
e.runspeed = strtof(row[29], nullptr);
|
||||||
|
e.statscale = static_cast<int32_t>(atoi(row[30]));
|
||||||
|
e.spellscale = strtof(row[31], nullptr);
|
||||||
|
e.healscale = strtof(row[32], nullptr);
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_stats_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_stats_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Database& db,
|
||||||
|
const MercStats &e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
v.push_back(columns[0] + " = " + std::to_string(e.merc_npc_type_id));
|
||||||
|
v.push_back(columns[1] + " = " + std::to_string(e.clientlevel));
|
||||||
|
v.push_back(columns[2] + " = " + std::to_string(e.level));
|
||||||
|
v.push_back(columns[3] + " = " + std::to_string(e.hp));
|
||||||
|
v.push_back(columns[4] + " = " + std::to_string(e.mana));
|
||||||
|
v.push_back(columns[5] + " = " + std::to_string(e.AC));
|
||||||
|
v.push_back(columns[6] + " = " + std::to_string(e.ATK));
|
||||||
|
v.push_back(columns[7] + " = " + std::to_string(e.STR));
|
||||||
|
v.push_back(columns[8] + " = " + std::to_string(e.STA));
|
||||||
|
v.push_back(columns[9] + " = " + std::to_string(e.DEX));
|
||||||
|
v.push_back(columns[10] + " = " + std::to_string(e.AGI));
|
||||||
|
v.push_back(columns[11] + " = " + std::to_string(e._INT));
|
||||||
|
v.push_back(columns[12] + " = " + std::to_string(e.WIS));
|
||||||
|
v.push_back(columns[13] + " = " + std::to_string(e.CHA));
|
||||||
|
v.push_back(columns[14] + " = " + std::to_string(e.MR));
|
||||||
|
v.push_back(columns[15] + " = " + std::to_string(e.CR));
|
||||||
|
v.push_back(columns[16] + " = " + std::to_string(e.DR));
|
||||||
|
v.push_back(columns[17] + " = " + std::to_string(e.FR));
|
||||||
|
v.push_back(columns[18] + " = " + std::to_string(e.PR));
|
||||||
|
v.push_back(columns[19] + " = " + std::to_string(e.Corrup));
|
||||||
|
v.push_back(columns[20] + " = " + std::to_string(e.mindmg));
|
||||||
|
v.push_back(columns[21] + " = " + std::to_string(e.maxdmg));
|
||||||
|
v.push_back(columns[22] + " = " + std::to_string(e.attack_count));
|
||||||
|
v.push_back(columns[23] + " = " + std::to_string(e.attack_speed));
|
||||||
|
v.push_back(columns[24] + " = " + std::to_string(e.attack_delay));
|
||||||
|
v.push_back(columns[25] + " = '" + Strings::Escape(e.special_abilities) + "'");
|
||||||
|
v.push_back(columns[26] + " = " + std::to_string(e.Accuracy));
|
||||||
|
v.push_back(columns[27] + " = " + std::to_string(e.hp_regen_rate));
|
||||||
|
v.push_back(columns[28] + " = " + std::to_string(e.mana_regen_rate));
|
||||||
|
v.push_back(columns[29] + " = " + std::to_string(e.runspeed));
|
||||||
|
v.push_back(columns[30] + " = " + std::to_string(e.statscale));
|
||||||
|
v.push_back(columns[31] + " = " + std::to_string(e.spellscale));
|
||||||
|
v.push_back(columns[32] + " = " + std::to_string(e.healscale));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
Strings::Implode(", ", v),
|
||||||
|
PrimaryKey(),
|
||||||
|
e.merc_npc_type_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercStats InsertOne(
|
||||||
|
Database& db,
|
||||||
|
MercStats e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_npc_type_id));
|
||||||
|
v.push_back(std::to_string(e.clientlevel));
|
||||||
|
v.push_back(std::to_string(e.level));
|
||||||
|
v.push_back(std::to_string(e.hp));
|
||||||
|
v.push_back(std::to_string(e.mana));
|
||||||
|
v.push_back(std::to_string(e.AC));
|
||||||
|
v.push_back(std::to_string(e.ATK));
|
||||||
|
v.push_back(std::to_string(e.STR));
|
||||||
|
v.push_back(std::to_string(e.STA));
|
||||||
|
v.push_back(std::to_string(e.DEX));
|
||||||
|
v.push_back(std::to_string(e.AGI));
|
||||||
|
v.push_back(std::to_string(e._INT));
|
||||||
|
v.push_back(std::to_string(e.WIS));
|
||||||
|
v.push_back(std::to_string(e.CHA));
|
||||||
|
v.push_back(std::to_string(e.MR));
|
||||||
|
v.push_back(std::to_string(e.CR));
|
||||||
|
v.push_back(std::to_string(e.DR));
|
||||||
|
v.push_back(std::to_string(e.FR));
|
||||||
|
v.push_back(std::to_string(e.PR));
|
||||||
|
v.push_back(std::to_string(e.Corrup));
|
||||||
|
v.push_back(std::to_string(e.mindmg));
|
||||||
|
v.push_back(std::to_string(e.maxdmg));
|
||||||
|
v.push_back(std::to_string(e.attack_count));
|
||||||
|
v.push_back(std::to_string(e.attack_speed));
|
||||||
|
v.push_back(std::to_string(e.attack_delay));
|
||||||
|
v.push_back("'" + Strings::Escape(e.special_abilities) + "'");
|
||||||
|
v.push_back(std::to_string(e.Accuracy));
|
||||||
|
v.push_back(std::to_string(e.hp_regen_rate));
|
||||||
|
v.push_back(std::to_string(e.mana_regen_rate));
|
||||||
|
v.push_back(std::to_string(e.runspeed));
|
||||||
|
v.push_back(std::to_string(e.statscale));
|
||||||
|
v.push_back(std::to_string(e.spellscale));
|
||||||
|
v.push_back(std::to_string(e.healscale));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
e.merc_npc_type_id = results.LastInsertedID();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
e = NewEntity();
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
Database& db,
|
||||||
|
const std::vector<MercStats> &entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &e: entries) {
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_npc_type_id));
|
||||||
|
v.push_back(std::to_string(e.clientlevel));
|
||||||
|
v.push_back(std::to_string(e.level));
|
||||||
|
v.push_back(std::to_string(e.hp));
|
||||||
|
v.push_back(std::to_string(e.mana));
|
||||||
|
v.push_back(std::to_string(e.AC));
|
||||||
|
v.push_back(std::to_string(e.ATK));
|
||||||
|
v.push_back(std::to_string(e.STR));
|
||||||
|
v.push_back(std::to_string(e.STA));
|
||||||
|
v.push_back(std::to_string(e.DEX));
|
||||||
|
v.push_back(std::to_string(e.AGI));
|
||||||
|
v.push_back(std::to_string(e._INT));
|
||||||
|
v.push_back(std::to_string(e.WIS));
|
||||||
|
v.push_back(std::to_string(e.CHA));
|
||||||
|
v.push_back(std::to_string(e.MR));
|
||||||
|
v.push_back(std::to_string(e.CR));
|
||||||
|
v.push_back(std::to_string(e.DR));
|
||||||
|
v.push_back(std::to_string(e.FR));
|
||||||
|
v.push_back(std::to_string(e.PR));
|
||||||
|
v.push_back(std::to_string(e.Corrup));
|
||||||
|
v.push_back(std::to_string(e.mindmg));
|
||||||
|
v.push_back(std::to_string(e.maxdmg));
|
||||||
|
v.push_back(std::to_string(e.attack_count));
|
||||||
|
v.push_back(std::to_string(e.attack_speed));
|
||||||
|
v.push_back(std::to_string(e.attack_delay));
|
||||||
|
v.push_back("'" + Strings::Escape(e.special_abilities) + "'");
|
||||||
|
v.push_back(std::to_string(e.Accuracy));
|
||||||
|
v.push_back(std::to_string(e.hp_regen_rate));
|
||||||
|
v.push_back(std::to_string(e.mana_regen_rate));
|
||||||
|
v.push_back(std::to_string(e.runspeed));
|
||||||
|
v.push_back(std::to_string(e.statscale));
|
||||||
|
v.push_back(std::to_string(e.spellscale));
|
||||||
|
v.push_back(std::to_string(e.healscale));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercStats> All(Database& db)
|
||||||
|
{
|
||||||
|
std::vector<MercStats> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercStats e{};
|
||||||
|
|
||||||
|
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.clientlevel = static_cast<uint8_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.level = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.hp = static_cast<int32_t>(atoi(row[3]));
|
||||||
|
e.mana = static_cast<int32_t>(atoi(row[4]));
|
||||||
|
e.AC = static_cast<int16_t>(atoi(row[5]));
|
||||||
|
e.ATK = static_cast<int32_t>(atoi(row[6]));
|
||||||
|
e.STR = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
|
||||||
|
e.STA = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
|
||||||
|
e.DEX = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
|
||||||
|
e.AGI = static_cast<uint32_t>(strtoul(row[10], nullptr, 10));
|
||||||
|
e._INT = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
|
||||||
|
e.WIS = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
|
||||||
|
e.CHA = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
|
||||||
|
e.MR = static_cast<int16_t>(atoi(row[14]));
|
||||||
|
e.CR = static_cast<int16_t>(atoi(row[15]));
|
||||||
|
e.DR = static_cast<int16_t>(atoi(row[16]));
|
||||||
|
e.FR = static_cast<int16_t>(atoi(row[17]));
|
||||||
|
e.PR = static_cast<int16_t>(atoi(row[18]));
|
||||||
|
e.Corrup = static_cast<int16_t>(atoi(row[19]));
|
||||||
|
e.mindmg = static_cast<uint32_t>(strtoul(row[20], nullptr, 10));
|
||||||
|
e.maxdmg = static_cast<uint32_t>(strtoul(row[21], nullptr, 10));
|
||||||
|
e.attack_count = static_cast<int16_t>(atoi(row[22]));
|
||||||
|
e.attack_speed = static_cast<int8_t>(atoi(row[23]));
|
||||||
|
e.attack_delay = static_cast<uint8_t>(strtoul(row[24], nullptr, 10));
|
||||||
|
e.special_abilities = row[25] ? row[25] : "";
|
||||||
|
e.Accuracy = static_cast<int32_t>(atoi(row[26]));
|
||||||
|
e.hp_regen_rate = static_cast<uint32_t>(strtoul(row[27], nullptr, 10));
|
||||||
|
e.mana_regen_rate = static_cast<uint32_t>(strtoul(row[28], nullptr, 10));
|
||||||
|
e.runspeed = strtof(row[29], nullptr);
|
||||||
|
e.statscale = static_cast<int32_t>(atoi(row[30]));
|
||||||
|
e.spellscale = strtof(row[31], nullptr);
|
||||||
|
e.healscale = strtof(row[32], nullptr);
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercStats> GetWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
std::vector<MercStats> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercStats e{};
|
||||||
|
|
||||||
|
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.clientlevel = static_cast<uint8_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.level = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.hp = static_cast<int32_t>(atoi(row[3]));
|
||||||
|
e.mana = static_cast<int32_t>(atoi(row[4]));
|
||||||
|
e.AC = static_cast<int16_t>(atoi(row[5]));
|
||||||
|
e.ATK = static_cast<int32_t>(atoi(row[6]));
|
||||||
|
e.STR = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
|
||||||
|
e.STA = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
|
||||||
|
e.DEX = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
|
||||||
|
e.AGI = static_cast<uint32_t>(strtoul(row[10], nullptr, 10));
|
||||||
|
e._INT = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
|
||||||
|
e.WIS = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
|
||||||
|
e.CHA = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
|
||||||
|
e.MR = static_cast<int16_t>(atoi(row[14]));
|
||||||
|
e.CR = static_cast<int16_t>(atoi(row[15]));
|
||||||
|
e.DR = static_cast<int16_t>(atoi(row[16]));
|
||||||
|
e.FR = static_cast<int16_t>(atoi(row[17]));
|
||||||
|
e.PR = static_cast<int16_t>(atoi(row[18]));
|
||||||
|
e.Corrup = static_cast<int16_t>(atoi(row[19]));
|
||||||
|
e.mindmg = static_cast<uint32_t>(strtoul(row[20], nullptr, 10));
|
||||||
|
e.maxdmg = static_cast<uint32_t>(strtoul(row[21], nullptr, 10));
|
||||||
|
e.attack_count = static_cast<int16_t>(atoi(row[22]));
|
||||||
|
e.attack_speed = static_cast<int8_t>(atoi(row[23]));
|
||||||
|
e.attack_delay = static_cast<uint8_t>(strtoul(row[24], nullptr, 10));
|
||||||
|
e.special_abilities = row[25] ? row[25] : "";
|
||||||
|
e.Accuracy = static_cast<int32_t>(atoi(row[26]));
|
||||||
|
e.hp_regen_rate = static_cast<uint32_t>(strtoul(row[27], nullptr, 10));
|
||||||
|
e.mana_regen_rate = static_cast<uint32_t>(strtoul(row[28], nullptr, 10));
|
||||||
|
e.runspeed = strtof(row[29], nullptr);
|
||||||
|
e.statscale = static_cast<int32_t>(atoi(row[30]));
|
||||||
|
e.spellscale = strtof(row[31], nullptr);
|
||||||
|
e.healscale = strtof(row[32], nullptr);
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 GetMaxId(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COALESCE(MAX({}), 0) FROM {}",
|
||||||
|
PrimaryKey(),
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 Count(Database& db, const std::string &where_filter = "")
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COUNT(*) FROM {} {}",
|
||||||
|
TableName(),
|
||||||
|
(where_filter.empty() ? "" : "WHERE " + where_filter)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_MERC_STATS_REPOSITORY_H
|
||||||
354
common/repositories/base/base_merc_subtypes_repository.h
Normal file
354
common/repositories/base/base_merc_subtypes_repository.h
Normal file
@ -0,0 +1,354 @@
|
|||||||
|
/**
|
||||||
|
* DO NOT MODIFY THIS FILE
|
||||||
|
*
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to the repository extending the base.
|
||||||
|
* Any modifications to base repositories are to be made by the generator only
|
||||||
|
*
|
||||||
|
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||||
|
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_MERC_SUBTYPES_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_MERC_SUBTYPES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../strings.h"
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
|
class BaseMercSubtypesRepository {
|
||||||
|
public:
|
||||||
|
struct MercSubtypes {
|
||||||
|
uint32_t merc_subtype_id;
|
||||||
|
uint32_t class_id;
|
||||||
|
uint8_t tier_id;
|
||||||
|
uint8_t confidence_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("merc_subtype_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_subtype_id",
|
||||||
|
"class_id",
|
||||||
|
"tier_id",
|
||||||
|
"confidence_id",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> SelectColumns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_subtype_id",
|
||||||
|
"class_id",
|
||||||
|
"tier_id",
|
||||||
|
"confidence_id",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string SelectColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", SelectColumns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("merc_subtypes");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
SelectColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
ColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercSubtypes NewEntity()
|
||||||
|
{
|
||||||
|
MercSubtypes e{};
|
||||||
|
|
||||||
|
e.merc_subtype_id = 0;
|
||||||
|
e.class_id = 0;
|
||||||
|
e.tier_id = 0;
|
||||||
|
e.confidence_id = 0;
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercSubtypes GetMercSubtypes(
|
||||||
|
const std::vector<MercSubtypes> &merc_subtypess,
|
||||||
|
int merc_subtypes_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &merc_subtypes : merc_subtypess) {
|
||||||
|
if (merc_subtypes.merc_subtype_id == merc_subtypes_id) {
|
||||||
|
return merc_subtypes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercSubtypes FindOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_subtypes_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {} = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_subtypes_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
MercSubtypes e{};
|
||||||
|
|
||||||
|
e.merc_subtype_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.tier_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.confidence_id = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_subtypes_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_subtypes_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Database& db,
|
||||||
|
const MercSubtypes &e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
v.push_back(columns[1] + " = " + std::to_string(e.class_id));
|
||||||
|
v.push_back(columns[2] + " = " + std::to_string(e.tier_id));
|
||||||
|
v.push_back(columns[3] + " = " + std::to_string(e.confidence_id));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
Strings::Implode(", ", v),
|
||||||
|
PrimaryKey(),
|
||||||
|
e.merc_subtype_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercSubtypes InsertOne(
|
||||||
|
Database& db,
|
||||||
|
MercSubtypes e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_subtype_id));
|
||||||
|
v.push_back(std::to_string(e.class_id));
|
||||||
|
v.push_back(std::to_string(e.tier_id));
|
||||||
|
v.push_back(std::to_string(e.confidence_id));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
e.merc_subtype_id = results.LastInsertedID();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
e = NewEntity();
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
Database& db,
|
||||||
|
const std::vector<MercSubtypes> &entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &e: entries) {
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_subtype_id));
|
||||||
|
v.push_back(std::to_string(e.class_id));
|
||||||
|
v.push_back(std::to_string(e.tier_id));
|
||||||
|
v.push_back(std::to_string(e.confidence_id));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercSubtypes> All(Database& db)
|
||||||
|
{
|
||||||
|
std::vector<MercSubtypes> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercSubtypes e{};
|
||||||
|
|
||||||
|
e.merc_subtype_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.tier_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.confidence_id = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercSubtypes> GetWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
std::vector<MercSubtypes> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercSubtypes e{};
|
||||||
|
|
||||||
|
e.merc_subtype_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.tier_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.confidence_id = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 GetMaxId(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COALESCE(MAX({}), 0) FROM {}",
|
||||||
|
PrimaryKey(),
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 Count(Database& db, const std::string &where_filter = "")
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COUNT(*) FROM {} {}",
|
||||||
|
TableName(),
|
||||||
|
(where_filter.empty() ? "" : "WHERE " + where_filter)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_MERC_SUBTYPES_REPOSITORY_H
|
||||||
384
common/repositories/base/base_merc_templates_repository.h
Normal file
384
common/repositories/base/base_merc_templates_repository.h
Normal file
@ -0,0 +1,384 @@
|
|||||||
|
/**
|
||||||
|
* DO NOT MODIFY THIS FILE
|
||||||
|
*
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to the repository extending the base.
|
||||||
|
* Any modifications to base repositories are to be made by the generator only
|
||||||
|
*
|
||||||
|
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||||
|
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_MERC_TEMPLATES_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_MERC_TEMPLATES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../strings.h"
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
|
class BaseMercTemplatesRepository {
|
||||||
|
public:
|
||||||
|
struct MercTemplates {
|
||||||
|
uint32_t merc_template_id;
|
||||||
|
uint32_t merc_type_id;
|
||||||
|
uint32_t merc_subtype_id;
|
||||||
|
uint32_t merc_npc_type_id;
|
||||||
|
std::string dbstring;
|
||||||
|
int8_t name_type_id;
|
||||||
|
uint32_t clientversion;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("merc_template_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_template_id",
|
||||||
|
"merc_type_id",
|
||||||
|
"merc_subtype_id",
|
||||||
|
"merc_npc_type_id",
|
||||||
|
"dbstring",
|
||||||
|
"name_type_id",
|
||||||
|
"clientversion",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> SelectColumns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_template_id",
|
||||||
|
"merc_type_id",
|
||||||
|
"merc_subtype_id",
|
||||||
|
"merc_npc_type_id",
|
||||||
|
"dbstring",
|
||||||
|
"name_type_id",
|
||||||
|
"clientversion",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string SelectColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", SelectColumns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("merc_templates");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
SelectColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
ColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercTemplates NewEntity()
|
||||||
|
{
|
||||||
|
MercTemplates e{};
|
||||||
|
|
||||||
|
e.merc_template_id = 0;
|
||||||
|
e.merc_type_id = 0;
|
||||||
|
e.merc_subtype_id = 0;
|
||||||
|
e.merc_npc_type_id = 0;
|
||||||
|
e.dbstring = "";
|
||||||
|
e.name_type_id = 0;
|
||||||
|
e.clientversion = 0;
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercTemplates GetMercTemplates(
|
||||||
|
const std::vector<MercTemplates> &merc_templatess,
|
||||||
|
int merc_templates_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &merc_templates : merc_templatess) {
|
||||||
|
if (merc_templates.merc_template_id == merc_templates_id) {
|
||||||
|
return merc_templates;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercTemplates FindOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_templates_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {} = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_templates_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
MercTemplates e{};
|
||||||
|
|
||||||
|
e.merc_template_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.merc_type_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.merc_subtype_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.dbstring = row[4] ? row[4] : "";
|
||||||
|
e.name_type_id = static_cast<int8_t>(atoi(row[5]));
|
||||||
|
e.clientversion = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_templates_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_templates_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Database& db,
|
||||||
|
const MercTemplates &e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
v.push_back(columns[1] + " = " + std::to_string(e.merc_type_id));
|
||||||
|
v.push_back(columns[2] + " = " + std::to_string(e.merc_subtype_id));
|
||||||
|
v.push_back(columns[3] + " = " + std::to_string(e.merc_npc_type_id));
|
||||||
|
v.push_back(columns[4] + " = '" + Strings::Escape(e.dbstring) + "'");
|
||||||
|
v.push_back(columns[5] + " = " + std::to_string(e.name_type_id));
|
||||||
|
v.push_back(columns[6] + " = " + std::to_string(e.clientversion));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
Strings::Implode(", ", v),
|
||||||
|
PrimaryKey(),
|
||||||
|
e.merc_template_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercTemplates InsertOne(
|
||||||
|
Database& db,
|
||||||
|
MercTemplates e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_template_id));
|
||||||
|
v.push_back(std::to_string(e.merc_type_id));
|
||||||
|
v.push_back(std::to_string(e.merc_subtype_id));
|
||||||
|
v.push_back(std::to_string(e.merc_npc_type_id));
|
||||||
|
v.push_back("'" + Strings::Escape(e.dbstring) + "'");
|
||||||
|
v.push_back(std::to_string(e.name_type_id));
|
||||||
|
v.push_back(std::to_string(e.clientversion));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
e.merc_template_id = results.LastInsertedID();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
e = NewEntity();
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
Database& db,
|
||||||
|
const std::vector<MercTemplates> &entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &e: entries) {
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_template_id));
|
||||||
|
v.push_back(std::to_string(e.merc_type_id));
|
||||||
|
v.push_back(std::to_string(e.merc_subtype_id));
|
||||||
|
v.push_back(std::to_string(e.merc_npc_type_id));
|
||||||
|
v.push_back("'" + Strings::Escape(e.dbstring) + "'");
|
||||||
|
v.push_back(std::to_string(e.name_type_id));
|
||||||
|
v.push_back(std::to_string(e.clientversion));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercTemplates> All(Database& db)
|
||||||
|
{
|
||||||
|
std::vector<MercTemplates> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercTemplates e{};
|
||||||
|
|
||||||
|
e.merc_template_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.merc_type_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.merc_subtype_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.dbstring = row[4] ? row[4] : "";
|
||||||
|
e.name_type_id = static_cast<int8_t>(atoi(row[5]));
|
||||||
|
e.clientversion = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercTemplates> GetWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
std::vector<MercTemplates> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercTemplates e{};
|
||||||
|
|
||||||
|
e.merc_template_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.merc_type_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.merc_subtype_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.dbstring = row[4] ? row[4] : "";
|
||||||
|
e.name_type_id = static_cast<int8_t>(atoi(row[5]));
|
||||||
|
e.clientversion = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 GetMaxId(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COALESCE(MAX({}), 0) FROM {}",
|
||||||
|
PrimaryKey(),
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 Count(Database& db, const std::string &where_filter = "")
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COUNT(*) FROM {} {}",
|
||||||
|
TableName(),
|
||||||
|
(where_filter.empty() ? "" : "WHERE " + where_filter)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_MERC_TEMPLATES_REPOSITORY_H
|
||||||
364
common/repositories/base/base_merc_types_repository.h
Normal file
364
common/repositories/base/base_merc_types_repository.h
Normal file
@ -0,0 +1,364 @@
|
|||||||
|
/**
|
||||||
|
* DO NOT MODIFY THIS FILE
|
||||||
|
*
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to the repository extending the base.
|
||||||
|
* Any modifications to base repositories are to be made by the generator only
|
||||||
|
*
|
||||||
|
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||||
|
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_MERC_TYPES_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_MERC_TYPES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../strings.h"
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
|
class BaseMercTypesRepository {
|
||||||
|
public:
|
||||||
|
struct MercTypes {
|
||||||
|
uint32_t merc_type_id;
|
||||||
|
uint32_t race_id;
|
||||||
|
uint8_t proficiency_id;
|
||||||
|
std::string dbstring;
|
||||||
|
uint32_t clientversion;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("merc_type_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_type_id",
|
||||||
|
"race_id",
|
||||||
|
"proficiency_id",
|
||||||
|
"dbstring",
|
||||||
|
"clientversion",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> SelectColumns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"merc_type_id",
|
||||||
|
"race_id",
|
||||||
|
"proficiency_id",
|
||||||
|
"dbstring",
|
||||||
|
"clientversion",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string SelectColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", SelectColumns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("merc_types");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
SelectColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
ColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercTypes NewEntity()
|
||||||
|
{
|
||||||
|
MercTypes e{};
|
||||||
|
|
||||||
|
e.merc_type_id = 0;
|
||||||
|
e.race_id = 0;
|
||||||
|
e.proficiency_id = 0;
|
||||||
|
e.dbstring = "";
|
||||||
|
e.clientversion = 0;
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercTypes GetMercTypes(
|
||||||
|
const std::vector<MercTypes> &merc_typess,
|
||||||
|
int merc_types_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &merc_types : merc_typess) {
|
||||||
|
if (merc_types.merc_type_id == merc_types_id) {
|
||||||
|
return merc_types;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercTypes FindOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_types_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {} = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_types_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
MercTypes e{};
|
||||||
|
|
||||||
|
e.merc_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.race_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.proficiency_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.dbstring = row[3] ? row[3] : "";
|
||||||
|
e.clientversion = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_types_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_types_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Database& db,
|
||||||
|
const MercTypes &e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
v.push_back(columns[1] + " = " + std::to_string(e.race_id));
|
||||||
|
v.push_back(columns[2] + " = " + std::to_string(e.proficiency_id));
|
||||||
|
v.push_back(columns[3] + " = '" + Strings::Escape(e.dbstring) + "'");
|
||||||
|
v.push_back(columns[4] + " = " + std::to_string(e.clientversion));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
Strings::Implode(", ", v),
|
||||||
|
PrimaryKey(),
|
||||||
|
e.merc_type_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercTypes InsertOne(
|
||||||
|
Database& db,
|
||||||
|
MercTypes e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_type_id));
|
||||||
|
v.push_back(std::to_string(e.race_id));
|
||||||
|
v.push_back(std::to_string(e.proficiency_id));
|
||||||
|
v.push_back("'" + Strings::Escape(e.dbstring) + "'");
|
||||||
|
v.push_back(std::to_string(e.clientversion));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
e.merc_type_id = results.LastInsertedID();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
e = NewEntity();
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
Database& db,
|
||||||
|
const std::vector<MercTypes> &entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &e: entries) {
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.merc_type_id));
|
||||||
|
v.push_back(std::to_string(e.race_id));
|
||||||
|
v.push_back(std::to_string(e.proficiency_id));
|
||||||
|
v.push_back("'" + Strings::Escape(e.dbstring) + "'");
|
||||||
|
v.push_back(std::to_string(e.clientversion));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercTypes> All(Database& db)
|
||||||
|
{
|
||||||
|
std::vector<MercTypes> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercTypes e{};
|
||||||
|
|
||||||
|
e.merc_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.race_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.proficiency_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.dbstring = row[3] ? row[3] : "";
|
||||||
|
e.clientversion = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercTypes> GetWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
std::vector<MercTypes> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercTypes e{};
|
||||||
|
|
||||||
|
e.merc_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.race_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.proficiency_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.dbstring = row[3] ? row[3] : "";
|
||||||
|
e.clientversion = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 GetMaxId(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COALESCE(MAX({}), 0) FROM {}",
|
||||||
|
PrimaryKey(),
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 Count(Database& db, const std::string &where_filter = "")
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COUNT(*) FROM {} {}",
|
||||||
|
TableName(),
|
||||||
|
(where_filter.empty() ? "" : "WHERE " + where_filter)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_MERC_TYPES_REPOSITORY_H
|
||||||
394
common/repositories/base/base_merc_weaponinfo_repository.h
Normal file
394
common/repositories/base/base_merc_weaponinfo_repository.h
Normal file
@ -0,0 +1,394 @@
|
|||||||
|
/**
|
||||||
|
* DO NOT MODIFY THIS FILE
|
||||||
|
*
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to the repository extending the base.
|
||||||
|
* Any modifications to base repositories are to be made by the generator only
|
||||||
|
*
|
||||||
|
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||||
|
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_MERC_WEAPONINFO_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_MERC_WEAPONINFO_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../strings.h"
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
|
class BaseMercWeaponinfoRepository {
|
||||||
|
public:
|
||||||
|
struct MercWeaponinfo {
|
||||||
|
int32_t id;
|
||||||
|
int32_t merc_npc_type_id;
|
||||||
|
uint8_t minlevel;
|
||||||
|
uint8_t maxlevel;
|
||||||
|
int32_t d_melee_texture1;
|
||||||
|
int32_t d_melee_texture2;
|
||||||
|
uint8_t prim_melee_type;
|
||||||
|
uint8_t sec_melee_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"merc_npc_type_id",
|
||||||
|
"minlevel",
|
||||||
|
"maxlevel",
|
||||||
|
"d_melee_texture1",
|
||||||
|
"d_melee_texture2",
|
||||||
|
"prim_melee_type",
|
||||||
|
"sec_melee_type",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> SelectColumns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"id",
|
||||||
|
"merc_npc_type_id",
|
||||||
|
"minlevel",
|
||||||
|
"maxlevel",
|
||||||
|
"d_melee_texture1",
|
||||||
|
"d_melee_texture2",
|
||||||
|
"prim_melee_type",
|
||||||
|
"sec_melee_type",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string SelectColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", SelectColumns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("merc_weaponinfo");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
SelectColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
ColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercWeaponinfo NewEntity()
|
||||||
|
{
|
||||||
|
MercWeaponinfo e{};
|
||||||
|
|
||||||
|
e.id = 0;
|
||||||
|
e.merc_npc_type_id = 0;
|
||||||
|
e.minlevel = 0;
|
||||||
|
e.maxlevel = 0;
|
||||||
|
e.d_melee_texture1 = 0;
|
||||||
|
e.d_melee_texture2 = 0;
|
||||||
|
e.prim_melee_type = 28;
|
||||||
|
e.sec_melee_type = 28;
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercWeaponinfo GetMercWeaponinfo(
|
||||||
|
const std::vector<MercWeaponinfo> &merc_weaponinfos,
|
||||||
|
int merc_weaponinfo_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &merc_weaponinfo : merc_weaponinfos) {
|
||||||
|
if (merc_weaponinfo.id == merc_weaponinfo_id) {
|
||||||
|
return merc_weaponinfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercWeaponinfo FindOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_weaponinfo_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {} = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_weaponinfo_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
MercWeaponinfo e{};
|
||||||
|
|
||||||
|
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||||
|
e.merc_npc_type_id = static_cast<int32_t>(atoi(row[1]));
|
||||||
|
e.minlevel = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.maxlevel = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.d_melee_texture1 = static_cast<int32_t>(atoi(row[4]));
|
||||||
|
e.d_melee_texture2 = static_cast<int32_t>(atoi(row[5]));
|
||||||
|
e.prim_melee_type = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
|
||||||
|
e.sec_melee_type = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
Database& db,
|
||||||
|
int merc_weaponinfo_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
merc_weaponinfo_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Database& db,
|
||||||
|
const MercWeaponinfo &e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
v.push_back(columns[1] + " = " + std::to_string(e.merc_npc_type_id));
|
||||||
|
v.push_back(columns[2] + " = " + std::to_string(e.minlevel));
|
||||||
|
v.push_back(columns[3] + " = " + std::to_string(e.maxlevel));
|
||||||
|
v.push_back(columns[4] + " = " + std::to_string(e.d_melee_texture1));
|
||||||
|
v.push_back(columns[5] + " = " + std::to_string(e.d_melee_texture2));
|
||||||
|
v.push_back(columns[6] + " = " + std::to_string(e.prim_melee_type));
|
||||||
|
v.push_back(columns[7] + " = " + std::to_string(e.sec_melee_type));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
Strings::Implode(", ", v),
|
||||||
|
PrimaryKey(),
|
||||||
|
e.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MercWeaponinfo InsertOne(
|
||||||
|
Database& db,
|
||||||
|
MercWeaponinfo e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.id));
|
||||||
|
v.push_back(std::to_string(e.merc_npc_type_id));
|
||||||
|
v.push_back(std::to_string(e.minlevel));
|
||||||
|
v.push_back(std::to_string(e.maxlevel));
|
||||||
|
v.push_back(std::to_string(e.d_melee_texture1));
|
||||||
|
v.push_back(std::to_string(e.d_melee_texture2));
|
||||||
|
v.push_back(std::to_string(e.prim_melee_type));
|
||||||
|
v.push_back(std::to_string(e.sec_melee_type));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
e.id = results.LastInsertedID();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
e = NewEntity();
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
Database& db,
|
||||||
|
const std::vector<MercWeaponinfo> &entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &e: entries) {
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.id));
|
||||||
|
v.push_back(std::to_string(e.merc_npc_type_id));
|
||||||
|
v.push_back(std::to_string(e.minlevel));
|
||||||
|
v.push_back(std::to_string(e.maxlevel));
|
||||||
|
v.push_back(std::to_string(e.d_melee_texture1));
|
||||||
|
v.push_back(std::to_string(e.d_melee_texture2));
|
||||||
|
v.push_back(std::to_string(e.prim_melee_type));
|
||||||
|
v.push_back(std::to_string(e.sec_melee_type));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercWeaponinfo> All(Database& db)
|
||||||
|
{
|
||||||
|
std::vector<MercWeaponinfo> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercWeaponinfo e{};
|
||||||
|
|
||||||
|
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||||
|
e.merc_npc_type_id = static_cast<int32_t>(atoi(row[1]));
|
||||||
|
e.minlevel = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.maxlevel = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.d_melee_texture1 = static_cast<int32_t>(atoi(row[4]));
|
||||||
|
e.d_melee_texture2 = static_cast<int32_t>(atoi(row[5]));
|
||||||
|
e.prim_melee_type = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
|
||||||
|
e.sec_melee_type = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<MercWeaponinfo> GetWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
std::vector<MercWeaponinfo> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
MercWeaponinfo e{};
|
||||||
|
|
||||||
|
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||||
|
e.merc_npc_type_id = static_cast<int32_t>(atoi(row[1]));
|
||||||
|
e.minlevel = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.maxlevel = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
|
||||||
|
e.d_melee_texture1 = static_cast<int32_t>(atoi(row[4]));
|
||||||
|
e.d_melee_texture2 = static_cast<int32_t>(atoi(row[5]));
|
||||||
|
e.prim_melee_type = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
|
||||||
|
e.sec_melee_type = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 GetMaxId(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COALESCE(MAX({}), 0) FROM {}",
|
||||||
|
PrimaryKey(),
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 Count(Database& db, const std::string &where_filter = "")
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COUNT(*) FROM {} {}",
|
||||||
|
TableName(),
|
||||||
|
(where_filter.empty() ? "" : "WHERE " + where_filter)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_MERC_WEAPONINFO_REPOSITORY_H
|
||||||
554
common/repositories/base/base_mercs_repository.h
Normal file
554
common/repositories/base/base_mercs_repository.h
Normal file
@ -0,0 +1,554 @@
|
|||||||
|
/**
|
||||||
|
* DO NOT MODIFY THIS FILE
|
||||||
|
*
|
||||||
|
* This repository was automatically generated and is NOT to be modified directly.
|
||||||
|
* Any repository modifications are meant to be made to the repository extending the base.
|
||||||
|
* Any modifications to base repositories are to be made by the generator only
|
||||||
|
*
|
||||||
|
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||||
|
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EQEMU_BASE_MERCS_REPOSITORY_H
|
||||||
|
#define EQEMU_BASE_MERCS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../../database.h"
|
||||||
|
#include "../../strings.h"
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
|
||||||
|
class BaseMercsRepository {
|
||||||
|
public:
|
||||||
|
struct Mercs {
|
||||||
|
uint32_t MercID;
|
||||||
|
uint32_t OwnerCharacterID;
|
||||||
|
uint8_t Slot;
|
||||||
|
std::string Name;
|
||||||
|
uint32_t TemplateID;
|
||||||
|
uint32_t SuspendedTime;
|
||||||
|
uint8_t IsSuspended;
|
||||||
|
uint32_t TimerRemaining;
|
||||||
|
uint8_t Gender;
|
||||||
|
float MercSize;
|
||||||
|
uint8_t StanceID;
|
||||||
|
uint32_t HP;
|
||||||
|
uint32_t Mana;
|
||||||
|
uint32_t Endurance;
|
||||||
|
uint32_t Face;
|
||||||
|
uint32_t LuclinHairStyle;
|
||||||
|
uint32_t LuclinHairColor;
|
||||||
|
uint32_t LuclinEyeColor;
|
||||||
|
uint32_t LuclinEyeColor2;
|
||||||
|
uint32_t LuclinBeardColor;
|
||||||
|
uint32_t LuclinBeard;
|
||||||
|
uint32_t DrakkinHeritage;
|
||||||
|
uint32_t DrakkinTattoo;
|
||||||
|
uint32_t DrakkinDetails;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string PrimaryKey()
|
||||||
|
{
|
||||||
|
return std::string("MercID");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> Columns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"MercID",
|
||||||
|
"OwnerCharacterID",
|
||||||
|
"Slot",
|
||||||
|
"Name",
|
||||||
|
"TemplateID",
|
||||||
|
"SuspendedTime",
|
||||||
|
"IsSuspended",
|
||||||
|
"TimerRemaining",
|
||||||
|
"Gender",
|
||||||
|
"MercSize",
|
||||||
|
"StanceID",
|
||||||
|
"HP",
|
||||||
|
"Mana",
|
||||||
|
"Endurance",
|
||||||
|
"Face",
|
||||||
|
"LuclinHairStyle",
|
||||||
|
"LuclinHairColor",
|
||||||
|
"LuclinEyeColor",
|
||||||
|
"LuclinEyeColor2",
|
||||||
|
"LuclinBeardColor",
|
||||||
|
"LuclinBeard",
|
||||||
|
"DrakkinHeritage",
|
||||||
|
"DrakkinTattoo",
|
||||||
|
"DrakkinDetails",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::string> SelectColumns()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
"MercID",
|
||||||
|
"OwnerCharacterID",
|
||||||
|
"Slot",
|
||||||
|
"Name",
|
||||||
|
"TemplateID",
|
||||||
|
"SuspendedTime",
|
||||||
|
"IsSuspended",
|
||||||
|
"TimerRemaining",
|
||||||
|
"Gender",
|
||||||
|
"MercSize",
|
||||||
|
"StanceID",
|
||||||
|
"HP",
|
||||||
|
"Mana",
|
||||||
|
"Endurance",
|
||||||
|
"Face",
|
||||||
|
"LuclinHairStyle",
|
||||||
|
"LuclinHairColor",
|
||||||
|
"LuclinEyeColor",
|
||||||
|
"LuclinEyeColor2",
|
||||||
|
"LuclinBeardColor",
|
||||||
|
"LuclinBeard",
|
||||||
|
"DrakkinHeritage",
|
||||||
|
"DrakkinTattoo",
|
||||||
|
"DrakkinDetails",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string ColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", Columns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string SelectColumnsRaw()
|
||||||
|
{
|
||||||
|
return std::string(Strings::Implode(", ", SelectColumns()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string TableName()
|
||||||
|
{
|
||||||
|
return std::string("mercs");
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseSelect()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"SELECT {} FROM {}",
|
||||||
|
SelectColumnsRaw(),
|
||||||
|
TableName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string BaseInsert()
|
||||||
|
{
|
||||||
|
return fmt::format(
|
||||||
|
"INSERT INTO {} ({}) ",
|
||||||
|
TableName(),
|
||||||
|
ColumnsRaw()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Mercs NewEntity()
|
||||||
|
{
|
||||||
|
Mercs e{};
|
||||||
|
|
||||||
|
e.MercID = 0;
|
||||||
|
e.OwnerCharacterID = 0;
|
||||||
|
e.Slot = 0;
|
||||||
|
e.Name = "";
|
||||||
|
e.TemplateID = 0;
|
||||||
|
e.SuspendedTime = 0;
|
||||||
|
e.IsSuspended = 0;
|
||||||
|
e.TimerRemaining = 0;
|
||||||
|
e.Gender = 0;
|
||||||
|
e.MercSize = 5;
|
||||||
|
e.StanceID = 0;
|
||||||
|
e.HP = 0;
|
||||||
|
e.Mana = 0;
|
||||||
|
e.Endurance = 0;
|
||||||
|
e.Face = 1;
|
||||||
|
e.LuclinHairStyle = 1;
|
||||||
|
e.LuclinHairColor = 1;
|
||||||
|
e.LuclinEyeColor = 1;
|
||||||
|
e.LuclinEyeColor2 = 1;
|
||||||
|
e.LuclinBeardColor = 1;
|
||||||
|
e.LuclinBeard = 0;
|
||||||
|
e.DrakkinHeritage = 0;
|
||||||
|
e.DrakkinTattoo = 0;
|
||||||
|
e.DrakkinDetails = 0;
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Mercs GetMercs(
|
||||||
|
const std::vector<Mercs> &mercss,
|
||||||
|
int mercs_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (auto &mercs : mercss) {
|
||||||
|
if (mercs.MercID == mercs_id) {
|
||||||
|
return mercs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Mercs FindOne(
|
||||||
|
Database& db,
|
||||||
|
int mercs_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {} = {} LIMIT 1",
|
||||||
|
BaseSelect(),
|
||||||
|
PrimaryKey(),
|
||||||
|
mercs_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
if (results.RowCount() == 1) {
|
||||||
|
Mercs e{};
|
||||||
|
|
||||||
|
e.MercID = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.OwnerCharacterID = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.Slot = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.Name = row[3] ? row[3] : "";
|
||||||
|
e.TemplateID = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
|
||||||
|
e.SuspendedTime = static_cast<uint32_t>(strtoul(row[5], nullptr, 10));
|
||||||
|
e.IsSuspended = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
|
||||||
|
e.TimerRemaining = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
|
||||||
|
e.Gender = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
|
||||||
|
e.MercSize = strtof(row[9], nullptr);
|
||||||
|
e.StanceID = static_cast<uint8_t>(strtoul(row[10], nullptr, 10));
|
||||||
|
e.HP = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
|
||||||
|
e.Mana = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
|
||||||
|
e.Endurance = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
|
||||||
|
e.Face = static_cast<uint32_t>(strtoul(row[14], nullptr, 10));
|
||||||
|
e.LuclinHairStyle = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
|
||||||
|
e.LuclinHairColor = static_cast<uint32_t>(strtoul(row[16], nullptr, 10));
|
||||||
|
e.LuclinEyeColor = static_cast<uint32_t>(strtoul(row[17], nullptr, 10));
|
||||||
|
e.LuclinEyeColor2 = static_cast<uint32_t>(strtoul(row[18], nullptr, 10));
|
||||||
|
e.LuclinBeardColor = static_cast<uint32_t>(strtoul(row[19], nullptr, 10));
|
||||||
|
e.LuclinBeard = static_cast<uint32_t>(strtoul(row[20], nullptr, 10));
|
||||||
|
e.DrakkinHeritage = static_cast<uint32_t>(strtoul(row[21], nullptr, 10));
|
||||||
|
e.DrakkinTattoo = static_cast<uint32_t>(strtoul(row[22], nullptr, 10));
|
||||||
|
e.DrakkinDetails = static_cast<uint32_t>(strtoul(row[23], nullptr, 10));
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteOne(
|
||||||
|
Database& db,
|
||||||
|
int mercs_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
PrimaryKey(),
|
||||||
|
mercs_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int UpdateOne(
|
||||||
|
Database& db,
|
||||||
|
const Mercs &e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto columns = Columns();
|
||||||
|
|
||||||
|
v.push_back(columns[1] + " = " + std::to_string(e.OwnerCharacterID));
|
||||||
|
v.push_back(columns[2] + " = " + std::to_string(e.Slot));
|
||||||
|
v.push_back(columns[3] + " = '" + Strings::Escape(e.Name) + "'");
|
||||||
|
v.push_back(columns[4] + " = " + std::to_string(e.TemplateID));
|
||||||
|
v.push_back(columns[5] + " = " + std::to_string(e.SuspendedTime));
|
||||||
|
v.push_back(columns[6] + " = " + std::to_string(e.IsSuspended));
|
||||||
|
v.push_back(columns[7] + " = " + std::to_string(e.TimerRemaining));
|
||||||
|
v.push_back(columns[8] + " = " + std::to_string(e.Gender));
|
||||||
|
v.push_back(columns[9] + " = " + std::to_string(e.MercSize));
|
||||||
|
v.push_back(columns[10] + " = " + std::to_string(e.StanceID));
|
||||||
|
v.push_back(columns[11] + " = " + std::to_string(e.HP));
|
||||||
|
v.push_back(columns[12] + " = " + std::to_string(e.Mana));
|
||||||
|
v.push_back(columns[13] + " = " + std::to_string(e.Endurance));
|
||||||
|
v.push_back(columns[14] + " = " + std::to_string(e.Face));
|
||||||
|
v.push_back(columns[15] + " = " + std::to_string(e.LuclinHairStyle));
|
||||||
|
v.push_back(columns[16] + " = " + std::to_string(e.LuclinHairColor));
|
||||||
|
v.push_back(columns[17] + " = " + std::to_string(e.LuclinEyeColor));
|
||||||
|
v.push_back(columns[18] + " = " + std::to_string(e.LuclinEyeColor2));
|
||||||
|
v.push_back(columns[19] + " = " + std::to_string(e.LuclinBeardColor));
|
||||||
|
v.push_back(columns[20] + " = " + std::to_string(e.LuclinBeard));
|
||||||
|
v.push_back(columns[21] + " = " + std::to_string(e.DrakkinHeritage));
|
||||||
|
v.push_back(columns[22] + " = " + std::to_string(e.DrakkinTattoo));
|
||||||
|
v.push_back(columns[23] + " = " + std::to_string(e.DrakkinDetails));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"UPDATE {} SET {} WHERE {} = {}",
|
||||||
|
TableName(),
|
||||||
|
Strings::Implode(", ", v),
|
||||||
|
PrimaryKey(),
|
||||||
|
e.MercID
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Mercs InsertOne(
|
||||||
|
Database& db,
|
||||||
|
Mercs e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.MercID));
|
||||||
|
v.push_back(std::to_string(e.OwnerCharacterID));
|
||||||
|
v.push_back(std::to_string(e.Slot));
|
||||||
|
v.push_back("'" + Strings::Escape(e.Name) + "'");
|
||||||
|
v.push_back(std::to_string(e.TemplateID));
|
||||||
|
v.push_back(std::to_string(e.SuspendedTime));
|
||||||
|
v.push_back(std::to_string(e.IsSuspended));
|
||||||
|
v.push_back(std::to_string(e.TimerRemaining));
|
||||||
|
v.push_back(std::to_string(e.Gender));
|
||||||
|
v.push_back(std::to_string(e.MercSize));
|
||||||
|
v.push_back(std::to_string(e.StanceID));
|
||||||
|
v.push_back(std::to_string(e.HP));
|
||||||
|
v.push_back(std::to_string(e.Mana));
|
||||||
|
v.push_back(std::to_string(e.Endurance));
|
||||||
|
v.push_back(std::to_string(e.Face));
|
||||||
|
v.push_back(std::to_string(e.LuclinHairStyle));
|
||||||
|
v.push_back(std::to_string(e.LuclinHairColor));
|
||||||
|
v.push_back(std::to_string(e.LuclinEyeColor));
|
||||||
|
v.push_back(std::to_string(e.LuclinEyeColor2));
|
||||||
|
v.push_back(std::to_string(e.LuclinBeardColor));
|
||||||
|
v.push_back(std::to_string(e.LuclinBeard));
|
||||||
|
v.push_back(std::to_string(e.DrakkinHeritage));
|
||||||
|
v.push_back(std::to_string(e.DrakkinTattoo));
|
||||||
|
v.push_back(std::to_string(e.DrakkinDetails));
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES ({})",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", v)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.Success()) {
|
||||||
|
e.MercID = results.LastInsertedID();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
e = NewEntity();
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int InsertMany(
|
||||||
|
Database& db,
|
||||||
|
const std::vector<Mercs> &entries
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<std::string> insert_chunks;
|
||||||
|
|
||||||
|
for (auto &e: entries) {
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
v.push_back(std::to_string(e.MercID));
|
||||||
|
v.push_back(std::to_string(e.OwnerCharacterID));
|
||||||
|
v.push_back(std::to_string(e.Slot));
|
||||||
|
v.push_back("'" + Strings::Escape(e.Name) + "'");
|
||||||
|
v.push_back(std::to_string(e.TemplateID));
|
||||||
|
v.push_back(std::to_string(e.SuspendedTime));
|
||||||
|
v.push_back(std::to_string(e.IsSuspended));
|
||||||
|
v.push_back(std::to_string(e.TimerRemaining));
|
||||||
|
v.push_back(std::to_string(e.Gender));
|
||||||
|
v.push_back(std::to_string(e.MercSize));
|
||||||
|
v.push_back(std::to_string(e.StanceID));
|
||||||
|
v.push_back(std::to_string(e.HP));
|
||||||
|
v.push_back(std::to_string(e.Mana));
|
||||||
|
v.push_back(std::to_string(e.Endurance));
|
||||||
|
v.push_back(std::to_string(e.Face));
|
||||||
|
v.push_back(std::to_string(e.LuclinHairStyle));
|
||||||
|
v.push_back(std::to_string(e.LuclinHairColor));
|
||||||
|
v.push_back(std::to_string(e.LuclinEyeColor));
|
||||||
|
v.push_back(std::to_string(e.LuclinEyeColor2));
|
||||||
|
v.push_back(std::to_string(e.LuclinBeardColor));
|
||||||
|
v.push_back(std::to_string(e.LuclinBeard));
|
||||||
|
v.push_back(std::to_string(e.DrakkinHeritage));
|
||||||
|
v.push_back(std::to_string(e.DrakkinTattoo));
|
||||||
|
v.push_back(std::to_string(e.DrakkinDetails));
|
||||||
|
|
||||||
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} VALUES {}",
|
||||||
|
BaseInsert(),
|
||||||
|
Strings::Implode(",", insert_chunks)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Mercs> All(Database& db)
|
||||||
|
{
|
||||||
|
std::vector<Mercs> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{}",
|
||||||
|
BaseSelect()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Mercs e{};
|
||||||
|
|
||||||
|
e.MercID = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.OwnerCharacterID = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.Slot = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.Name = row[3] ? row[3] : "";
|
||||||
|
e.TemplateID = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
|
||||||
|
e.SuspendedTime = static_cast<uint32_t>(strtoul(row[5], nullptr, 10));
|
||||||
|
e.IsSuspended = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
|
||||||
|
e.TimerRemaining = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
|
||||||
|
e.Gender = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
|
||||||
|
e.MercSize = strtof(row[9], nullptr);
|
||||||
|
e.StanceID = static_cast<uint8_t>(strtoul(row[10], nullptr, 10));
|
||||||
|
e.HP = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
|
||||||
|
e.Mana = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
|
||||||
|
e.Endurance = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
|
||||||
|
e.Face = static_cast<uint32_t>(strtoul(row[14], nullptr, 10));
|
||||||
|
e.LuclinHairStyle = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
|
||||||
|
e.LuclinHairColor = static_cast<uint32_t>(strtoul(row[16], nullptr, 10));
|
||||||
|
e.LuclinEyeColor = static_cast<uint32_t>(strtoul(row[17], nullptr, 10));
|
||||||
|
e.LuclinEyeColor2 = static_cast<uint32_t>(strtoul(row[18], nullptr, 10));
|
||||||
|
e.LuclinBeardColor = static_cast<uint32_t>(strtoul(row[19], nullptr, 10));
|
||||||
|
e.LuclinBeard = static_cast<uint32_t>(strtoul(row[20], nullptr, 10));
|
||||||
|
e.DrakkinHeritage = static_cast<uint32_t>(strtoul(row[21], nullptr, 10));
|
||||||
|
e.DrakkinTattoo = static_cast<uint32_t>(strtoul(row[22], nullptr, 10));
|
||||||
|
e.DrakkinDetails = static_cast<uint32_t>(strtoul(row[23], nullptr, 10));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<Mercs> GetWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
std::vector<Mercs> all_entries;
|
||||||
|
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"{} WHERE {}",
|
||||||
|
BaseSelect(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
all_entries.reserve(results.RowCount());
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Mercs e{};
|
||||||
|
|
||||||
|
e.MercID = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
|
||||||
|
e.OwnerCharacterID = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
|
||||||
|
e.Slot = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
|
||||||
|
e.Name = row[3] ? row[3] : "";
|
||||||
|
e.TemplateID = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
|
||||||
|
e.SuspendedTime = static_cast<uint32_t>(strtoul(row[5], nullptr, 10));
|
||||||
|
e.IsSuspended = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
|
||||||
|
e.TimerRemaining = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
|
||||||
|
e.Gender = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
|
||||||
|
e.MercSize = strtof(row[9], nullptr);
|
||||||
|
e.StanceID = static_cast<uint8_t>(strtoul(row[10], nullptr, 10));
|
||||||
|
e.HP = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
|
||||||
|
e.Mana = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
|
||||||
|
e.Endurance = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
|
||||||
|
e.Face = static_cast<uint32_t>(strtoul(row[14], nullptr, 10));
|
||||||
|
e.LuclinHairStyle = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
|
||||||
|
e.LuclinHairColor = static_cast<uint32_t>(strtoul(row[16], nullptr, 10));
|
||||||
|
e.LuclinEyeColor = static_cast<uint32_t>(strtoul(row[17], nullptr, 10));
|
||||||
|
e.LuclinEyeColor2 = static_cast<uint32_t>(strtoul(row[18], nullptr, 10));
|
||||||
|
e.LuclinBeardColor = static_cast<uint32_t>(strtoul(row[19], nullptr, 10));
|
||||||
|
e.LuclinBeard = static_cast<uint32_t>(strtoul(row[20], nullptr, 10));
|
||||||
|
e.DrakkinHeritage = static_cast<uint32_t>(strtoul(row[21], nullptr, 10));
|
||||||
|
e.DrakkinTattoo = static_cast<uint32_t>(strtoul(row[22], nullptr, 10));
|
||||||
|
e.DrakkinDetails = static_cast<uint32_t>(strtoul(row[23], nullptr, 10));
|
||||||
|
|
||||||
|
all_entries.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeleteWhere(Database& db, const std::string &where_filter)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"DELETE FROM {} WHERE {}",
|
||||||
|
TableName(),
|
||||||
|
where_filter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Truncate(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"TRUNCATE TABLE {}",
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() ? results.RowsAffected() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 GetMaxId(Database& db)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COALESCE(MAX({}), 0) FROM {}",
|
||||||
|
PrimaryKey(),
|
||||||
|
TableName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64 Count(Database& db, const std::string &where_filter = "")
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COUNT(*) FROM {} {}",
|
||||||
|
TableName(),
|
||||||
|
(where_filter.empty() ? "" : "WHERE " + where_filter)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_BASE_MERCS_REPOSITORY_H
|
||||||
50
common/repositories/merc_armorinfo_repository.h
Normal file
50
common/repositories/merc_armorinfo_repository.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef EQEMU_MERC_ARMORINFO_REPOSITORY_H
|
||||||
|
#define EQEMU_MERC_ARMORINFO_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../strings.h"
|
||||||
|
#include "base/base_merc_armorinfo_repository.h"
|
||||||
|
|
||||||
|
class MercArmorinfoRepository: public BaseMercArmorinfoRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* MercArmorinfoRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* MercArmorinfoRepository::GetWhereNeverExpires()
|
||||||
|
* MercArmorinfoRepository::GetWhereXAndY()
|
||||||
|
* MercArmorinfoRepository::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_MERC_ARMORINFO_REPOSITORY_H
|
||||||
50
common/repositories/merc_buffs_repository.h
Normal file
50
common/repositories/merc_buffs_repository.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef EQEMU_MERC_BUFFS_REPOSITORY_H
|
||||||
|
#define EQEMU_MERC_BUFFS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../strings.h"
|
||||||
|
#include "base/base_merc_buffs_repository.h"
|
||||||
|
|
||||||
|
class MercBuffsRepository: public BaseMercBuffsRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* MercBuffsRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* MercBuffsRepository::GetWhereNeverExpires()
|
||||||
|
* MercBuffsRepository::GetWhereXAndY()
|
||||||
|
* MercBuffsRepository::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_MERC_BUFFS_REPOSITORY_H
|
||||||
50
common/repositories/merc_inventory_repository.h
Normal file
50
common/repositories/merc_inventory_repository.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef EQEMU_MERC_INVENTORY_REPOSITORY_H
|
||||||
|
#define EQEMU_MERC_INVENTORY_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../strings.h"
|
||||||
|
#include "base/base_merc_inventory_repository.h"
|
||||||
|
|
||||||
|
class MercInventoryRepository: public BaseMercInventoryRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* MercInventoryRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* MercInventoryRepository::GetWhereNeverExpires()
|
||||||
|
* MercInventoryRepository::GetWhereXAndY()
|
||||||
|
* MercInventoryRepository::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_MERC_INVENTORY_REPOSITORY_H
|
||||||
50
common/repositories/merc_merchant_entries_repository.h
Normal file
50
common/repositories/merc_merchant_entries_repository.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef EQEMU_MERC_MERCHANT_ENTRIES_REPOSITORY_H
|
||||||
|
#define EQEMU_MERC_MERCHANT_ENTRIES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../strings.h"
|
||||||
|
#include "base/base_merc_merchant_entries_repository.h"
|
||||||
|
|
||||||
|
class MercMerchantEntriesRepository: public BaseMercMerchantEntriesRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* MercMerchantEntriesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* MercMerchantEntriesRepository::GetWhereNeverExpires()
|
||||||
|
* MercMerchantEntriesRepository::GetWhereXAndY()
|
||||||
|
* MercMerchantEntriesRepository::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_MERC_MERCHANT_ENTRIES_REPOSITORY_H
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef EQEMU_MERC_MERCHANT_TEMPLATE_ENTRIES_REPOSITORY_H
|
||||||
|
#define EQEMU_MERC_MERCHANT_TEMPLATE_ENTRIES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../strings.h"
|
||||||
|
#include "base/base_merc_merchant_template_entries_repository.h"
|
||||||
|
|
||||||
|
class MercMerchantTemplateEntriesRepository: public BaseMercMerchantTemplateEntriesRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* MercMerchantTemplateEntriesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* MercMerchantTemplateEntriesRepository::GetWhereNeverExpires()
|
||||||
|
* MercMerchantTemplateEntriesRepository::GetWhereXAndY()
|
||||||
|
* MercMerchantTemplateEntriesRepository::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_MERC_MERCHANT_TEMPLATE_ENTRIES_REPOSITORY_H
|
||||||
50
common/repositories/merc_merchant_templates_repository.h
Normal file
50
common/repositories/merc_merchant_templates_repository.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef EQEMU_MERC_MERCHANT_TEMPLATES_REPOSITORY_H
|
||||||
|
#define EQEMU_MERC_MERCHANT_TEMPLATES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../strings.h"
|
||||||
|
#include "base/base_merc_merchant_templates_repository.h"
|
||||||
|
|
||||||
|
class MercMerchantTemplatesRepository: public BaseMercMerchantTemplatesRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* MercMerchantTemplatesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* MercMerchantTemplatesRepository::GetWhereNeverExpires()
|
||||||
|
* MercMerchantTemplatesRepository::GetWhereXAndY()
|
||||||
|
* MercMerchantTemplatesRepository::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_MERC_MERCHANT_TEMPLATES_REPOSITORY_H
|
||||||
50
common/repositories/merc_name_types_repository.h
Normal file
50
common/repositories/merc_name_types_repository.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef EQEMU_MERC_NAME_TYPES_REPOSITORY_H
|
||||||
|
#define EQEMU_MERC_NAME_TYPES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../strings.h"
|
||||||
|
#include "base/base_merc_name_types_repository.h"
|
||||||
|
|
||||||
|
class MercNameTypesRepository: public BaseMercNameTypesRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* MercNameTypesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* MercNameTypesRepository::GetWhereNeverExpires()
|
||||||
|
* MercNameTypesRepository::GetWhereXAndY()
|
||||||
|
* MercNameTypesRepository::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_MERC_NAME_TYPES_REPOSITORY_H
|
||||||
50
common/repositories/merc_npc_types_repository.h
Normal file
50
common/repositories/merc_npc_types_repository.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef EQEMU_MERC_NPC_TYPES_REPOSITORY_H
|
||||||
|
#define EQEMU_MERC_NPC_TYPES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../strings.h"
|
||||||
|
#include "base/base_merc_npc_types_repository.h"
|
||||||
|
|
||||||
|
class MercNpcTypesRepository: public BaseMercNpcTypesRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* MercNpcTypesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* MercNpcTypesRepository::GetWhereNeverExpires()
|
||||||
|
* MercNpcTypesRepository::GetWhereXAndY()
|
||||||
|
* MercNpcTypesRepository::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_MERC_NPC_TYPES_REPOSITORY_H
|
||||||
50
common/repositories/merc_spell_list_entries_repository.h
Normal file
50
common/repositories/merc_spell_list_entries_repository.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef EQEMU_MERC_SPELL_LIST_ENTRIES_REPOSITORY_H
|
||||||
|
#define EQEMU_MERC_SPELL_LIST_ENTRIES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../strings.h"
|
||||||
|
#include "base/base_merc_spell_list_entries_repository.h"
|
||||||
|
|
||||||
|
class MercSpellListEntriesRepository: public BaseMercSpellListEntriesRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* MercSpellListEntriesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* MercSpellListEntriesRepository::GetWhereNeverExpires()
|
||||||
|
* MercSpellListEntriesRepository::GetWhereXAndY()
|
||||||
|
* MercSpellListEntriesRepository::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_MERC_SPELL_LIST_ENTRIES_REPOSITORY_H
|
||||||
50
common/repositories/merc_spell_lists_repository.h
Normal file
50
common/repositories/merc_spell_lists_repository.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef EQEMU_MERC_SPELL_LISTS_REPOSITORY_H
|
||||||
|
#define EQEMU_MERC_SPELL_LISTS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../strings.h"
|
||||||
|
#include "base/base_merc_spell_lists_repository.h"
|
||||||
|
|
||||||
|
class MercSpellListsRepository: public BaseMercSpellListsRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* MercSpellListsRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* MercSpellListsRepository::GetWhereNeverExpires()
|
||||||
|
* MercSpellListsRepository::GetWhereXAndY()
|
||||||
|
* MercSpellListsRepository::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_MERC_SPELL_LISTS_REPOSITORY_H
|
||||||
50
common/repositories/merc_stance_entries_repository.h
Normal file
50
common/repositories/merc_stance_entries_repository.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef EQEMU_MERC_STANCE_ENTRIES_REPOSITORY_H
|
||||||
|
#define EQEMU_MERC_STANCE_ENTRIES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../strings.h"
|
||||||
|
#include "base/base_merc_stance_entries_repository.h"
|
||||||
|
|
||||||
|
class MercStanceEntriesRepository: public BaseMercStanceEntriesRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* MercStanceEntriesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* MercStanceEntriesRepository::GetWhereNeverExpires()
|
||||||
|
* MercStanceEntriesRepository::GetWhereXAndY()
|
||||||
|
* MercStanceEntriesRepository::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_MERC_STANCE_ENTRIES_REPOSITORY_H
|
||||||
50
common/repositories/merc_stats_repository.h
Normal file
50
common/repositories/merc_stats_repository.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef EQEMU_MERC_STATS_REPOSITORY_H
|
||||||
|
#define EQEMU_MERC_STATS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../strings.h"
|
||||||
|
#include "base/base_merc_stats_repository.h"
|
||||||
|
|
||||||
|
class MercStatsRepository: public BaseMercStatsRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* MercStatsRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* MercStatsRepository::GetWhereNeverExpires()
|
||||||
|
* MercStatsRepository::GetWhereXAndY()
|
||||||
|
* MercStatsRepository::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_MERC_STATS_REPOSITORY_H
|
||||||
50
common/repositories/merc_subtypes_repository.h
Normal file
50
common/repositories/merc_subtypes_repository.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef EQEMU_MERC_SUBTYPES_REPOSITORY_H
|
||||||
|
#define EQEMU_MERC_SUBTYPES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../strings.h"
|
||||||
|
#include "base/base_merc_subtypes_repository.h"
|
||||||
|
|
||||||
|
class MercSubtypesRepository: public BaseMercSubtypesRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* MercSubtypesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* MercSubtypesRepository::GetWhereNeverExpires()
|
||||||
|
* MercSubtypesRepository::GetWhereXAndY()
|
||||||
|
* MercSubtypesRepository::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_MERC_SUBTYPES_REPOSITORY_H
|
||||||
50
common/repositories/merc_templates_repository.h
Normal file
50
common/repositories/merc_templates_repository.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef EQEMU_MERC_TEMPLATES_REPOSITORY_H
|
||||||
|
#define EQEMU_MERC_TEMPLATES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../strings.h"
|
||||||
|
#include "base/base_merc_templates_repository.h"
|
||||||
|
|
||||||
|
class MercTemplatesRepository: public BaseMercTemplatesRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* MercTemplatesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* MercTemplatesRepository::GetWhereNeverExpires()
|
||||||
|
* MercTemplatesRepository::GetWhereXAndY()
|
||||||
|
* MercTemplatesRepository::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_MERC_TEMPLATES_REPOSITORY_H
|
||||||
50
common/repositories/merc_types_repository.h
Normal file
50
common/repositories/merc_types_repository.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef EQEMU_MERC_TYPES_REPOSITORY_H
|
||||||
|
#define EQEMU_MERC_TYPES_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../strings.h"
|
||||||
|
#include "base/base_merc_types_repository.h"
|
||||||
|
|
||||||
|
class MercTypesRepository: public BaseMercTypesRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* MercTypesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* MercTypesRepository::GetWhereNeverExpires()
|
||||||
|
* MercTypesRepository::GetWhereXAndY()
|
||||||
|
* MercTypesRepository::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_MERC_TYPES_REPOSITORY_H
|
||||||
50
common/repositories/merc_weaponinfo_repository.h
Normal file
50
common/repositories/merc_weaponinfo_repository.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef EQEMU_MERC_WEAPONINFO_REPOSITORY_H
|
||||||
|
#define EQEMU_MERC_WEAPONINFO_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../strings.h"
|
||||||
|
#include "base/base_merc_weaponinfo_repository.h"
|
||||||
|
|
||||||
|
class MercWeaponinfoRepository: public BaseMercWeaponinfoRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* MercWeaponinfoRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* MercWeaponinfoRepository::GetWhereNeverExpires()
|
||||||
|
* MercWeaponinfoRepository::GetWhereXAndY()
|
||||||
|
* MercWeaponinfoRepository::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_MERC_WEAPONINFO_REPOSITORY_H
|
||||||
50
common/repositories/mercs_repository.h
Normal file
50
common/repositories/mercs_repository.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef EQEMU_MERCS_REPOSITORY_H
|
||||||
|
#define EQEMU_MERCS_REPOSITORY_H
|
||||||
|
|
||||||
|
#include "../database.h"
|
||||||
|
#include "../strings.h"
|
||||||
|
#include "base/base_mercs_repository.h"
|
||||||
|
|
||||||
|
class MercsRepository: public BaseMercsRepository {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file was auto generated and can be modified and extended upon
|
||||||
|
*
|
||||||
|
* Base repository methods are automatically
|
||||||
|
* generated in the "base" version of this repository. The base repository
|
||||||
|
* is immutable and to be left untouched, while methods in this class
|
||||||
|
* are used as extension methods for more specific persistence-layer
|
||||||
|
* accessors or mutators.
|
||||||
|
*
|
||||||
|
* Base Methods (Subject to be expanded upon in time)
|
||||||
|
*
|
||||||
|
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||||
|
*
|
||||||
|
* InsertOne
|
||||||
|
* UpdateOne
|
||||||
|
* DeleteOne
|
||||||
|
* FindOne
|
||||||
|
* GetWhere(std::string where_filter)
|
||||||
|
* DeleteWhere(std::string where_filter)
|
||||||
|
* InsertMany
|
||||||
|
* All
|
||||||
|
*
|
||||||
|
* Example custom methods in a repository
|
||||||
|
*
|
||||||
|
* MercsRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||||
|
* MercsRepository::GetWhereNeverExpires()
|
||||||
|
* MercsRepository::GetWhereXAndY()
|
||||||
|
* MercsRepository::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_MERCS_REPOSITORY_H
|
||||||
@ -34,7 +34,7 @@
|
|||||||
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
|
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define CURRENT_BINARY_DATABASE_VERSION 9215
|
#define CURRENT_BINARY_DATABASE_VERSION 9216
|
||||||
|
|
||||||
#ifdef BOTS
|
#ifdef BOTS
|
||||||
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9035
|
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9035
|
||||||
|
|||||||
@ -469,6 +469,7 @@
|
|||||||
9213|2022_12_24_npc_keeps_sold_items.sql|SHOW COLUMNS FROM `npc_types` LIKE 'keeps_sold_items'|empty|
|
9213|2022_12_24_npc_keeps_sold_items.sql|SHOW COLUMNS FROM `npc_types` LIKE 'keeps_sold_items'|empty|
|
||||||
9214|2022_12_24_character_exp_toggle.sql|SHOW COLUMNS FROM `character_data` LIKE 'exp_enabled'|empty|
|
9214|2022_12_24_character_exp_toggle.sql|SHOW COLUMNS FROM `character_data` LIKE 'exp_enabled'|empty|
|
||||||
9215|2023_01_08_zone_max_level.sql|SHOW COLUMNS FROM `zone` LIKE 'max_level'|empty|
|
9215|2023_01_08_zone_max_level.sql|SHOW COLUMNS FROM `zone` LIKE 'max_level'|empty|
|
||||||
|
9216|2023_01_15_merc_data.sql|SHOW TABLES LIKE 'mercs'|empty|
|
||||||
|
|
||||||
# Upgrade conditions:
|
# Upgrade conditions:
|
||||||
# This won't be needed after this system is implemented, but it is used database that are not
|
# This won't be needed after this system is implemented, but it is used database that are not
|
||||||
|
|||||||
3
utils/sql/git/optional/2023_01_15_merc_liaisons.sql
Normal file
3
utils/sql/git/optional/2023_01_15_merc_liaisons.sql
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
UPDATE `npc_types`
|
||||||
|
SET `class` = 71
|
||||||
|
WHERE `lastname` LIKE '%Mercenary Liaison';
|
||||||
7069
utils/sql/git/required/2023_01_15_merc_data.sql
Normal file
7069
utils/sql/git/required/2023_01_15_merc_data.sql
Normal file
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,7 @@ void WorldserverCLI::DatabaseDump(int argc, char **argv, argh::parser &cmd, std:
|
|||||||
"--login-tables",
|
"--login-tables",
|
||||||
"--player-tables",
|
"--player-tables",
|
||||||
"--bot-tables",
|
"--bot-tables",
|
||||||
|
"--merc-tables",
|
||||||
"--state-tables",
|
"--state-tables",
|
||||||
"--system-tables",
|
"--system-tables",
|
||||||
"--query-serv-tables",
|
"--query-serv-tables",
|
||||||
@ -42,6 +43,7 @@ void WorldserverCLI::DatabaseDump(int argc, char **argv, argh::parser &cmd, std:
|
|||||||
s->SetDumpLoginServerTables(cmd[{"--login-tables"}] || dump_all);
|
s->SetDumpLoginServerTables(cmd[{"--login-tables"}] || dump_all);
|
||||||
s->SetDumpPlayerTables(cmd[{"--player-tables"}] || dump_all);
|
s->SetDumpPlayerTables(cmd[{"--player-tables"}] || dump_all);
|
||||||
s->SetDumpBotTables(cmd[{"--bot-tables"}] || dump_all);
|
s->SetDumpBotTables(cmd[{"--bot-tables"}] || dump_all);
|
||||||
|
s->SetDumpMercTables(cmd[{"--merc-tables"}] || dump_all);
|
||||||
s->SetDumpStateTables(cmd[{"--state-tables"}] || dump_all);
|
s->SetDumpStateTables(cmd[{"--state-tables"}] || dump_all);
|
||||||
s->SetDumpSystemTables(cmd[{"--system-tables"}] || dump_all);
|
s->SetDumpSystemTables(cmd[{"--system-tables"}] || dump_all);
|
||||||
s->SetDumpQueryServerTables(cmd[{"--query-serv-tables"}] || dump_all);
|
s->SetDumpQueryServerTables(cmd[{"--query-serv-tables"}] || dump_all);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user