[Repositories] Add GetMaxId, Count (#2371)

* [Repositories] Add GetMaxId, Count

* Update cmake with repositories, regenerate extended repos

* Remove license from files

* Simplify receivers

* Receiver simplify remaining

* Simplify receivers final

* Pass params by const reference

* Modernize grid tables

* Remove guild members since it doesn't conform as a generatable table

* PR comment
This commit is contained in:
Chris Miles
2022-08-13 18:40:56 -05:00
committed by GitHub
parent b79e1947f1
commit 79285b1002
374 changed files with 26837 additions and 26020 deletions
+744 -735
View File
File diff suppressed because it is too large Load Diff
@@ -1,23 +1,3 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef EQEMU_AA_ABILITY_REPOSITORY_H
#define EQEMU_AA_ABILITY_REPOSITORY_H
@@ -1,23 +1,3 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef EQEMU_AA_RANK_EFFECTS_REPOSITORY_H
#define EQEMU_AA_RANK_EFFECTS_REPOSITORY_H
@@ -1,23 +1,3 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef EQEMU_AA_RANK_PREREQS_REPOSITORY_H
#define EQEMU_AA_RANK_PREREQS_REPOSITORY_H
-20
View File
@@ -1,23 +1,3 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef EQEMU_AA_RANKS_REPOSITORY_H
#define EQEMU_AA_RANKS_REPOSITORY_H
@@ -1,23 +1,3 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef EQEMU_ACCOUNT_FLAGS_REPOSITORY_H
#define EQEMU_ACCOUNT_FLAGS_REPOSITORY_H
@@ -1,23 +1,3 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef EQEMU_ACCOUNT_IP_REPOSITORY_H
#define EQEMU_ACCOUNT_IP_REPOSITORY_H
-20
View File
@@ -1,23 +1,3 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef EQEMU_ACCOUNT_REPOSITORY_H
#define EQEMU_ACCOUNT_REPOSITORY_H
@@ -1,23 +1,3 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef EQEMU_ACCOUNT_REWARDS_REPOSITORY_H
#define EQEMU_ACCOUNT_REWARDS_REPOSITORY_H
@@ -1,23 +1,3 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef EQEMU_ADVENTURE_DETAILS_REPOSITORY_H
#define EQEMU_ADVENTURE_DETAILS_REPOSITORY_H
@@ -1,23 +1,3 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef EQEMU_ADVENTURE_MEMBERS_REPOSITORY_H
#define EQEMU_ADVENTURE_MEMBERS_REPOSITORY_H
@@ -1,23 +1,3 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef EQEMU_ADVENTURE_STATS_REPOSITORY_H
#define EQEMU_ADVENTURE_STATS_REPOSITORY_H
@@ -1,23 +1,3 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef EQEMU_ADVENTURE_TEMPLATE_ENTRY_FLAVOR_REPOSITORY_H
#define EQEMU_ADVENTURE_TEMPLATE_ENTRY_FLAVOR_REPOSITORY_H
@@ -1,23 +1,3 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef EQEMU_ADVENTURE_TEMPLATE_ENTRY_REPOSITORY_H
#define EQEMU_ADVENTURE_TEMPLATE_ENTRY_REPOSITORY_H
@@ -1,23 +1,3 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef EQEMU_ADVENTURE_TEMPLATE_REPOSITORY_H
#define EQEMU_ADVENTURE_TEMPLATE_REPOSITORY_H
@@ -1,23 +1,3 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef EQEMU_ALTERNATE_CURRENCY_REPOSITORY_H
#define EQEMU_ALTERNATE_CURRENCY_REPOSITORY_H
-20
View File
@@ -1,23 +1,3 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef EQEMU_AURAS_REPOSITORY_H
#define EQEMU_AURAS_REPOSITORY_H
@@ -115,27 +115,27 @@ public:
static AaAbility NewEntity()
{
AaAbility entry{};
AaAbility e{};
entry.id = 0;
entry.name = "";
entry.category = -1;
entry.classes = 131070;
entry.races = 65535;
entry.drakkin_heritage = 127;
entry.deities = 131071;
entry.status = 0;
entry.type = 0;
entry.charges = 0;
entry.grant_only = 0;
entry.first_rank_id = -1;
entry.enabled = 1;
entry.reset_on_death = 0;
e.id = 0;
e.name = "";
e.category = -1;
e.classes = 131070;
e.races = 65535;
e.drakkin_heritage = 127;
e.deities = 131071;
e.status = 0;
e.type = 0;
e.charges = 0;
e.grant_only = 0;
e.first_rank_id = -1;
e.enabled = 1;
e.reset_on_death = 0;
return entry;
return e;
}
static AaAbility GetAaAbilityEntry(
static AaAbility GetAaAbility(
const std::vector<AaAbility> &aa_abilitys,
int aa_ability_id
)
@@ -164,24 +164,24 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
AaAbility entry{};
AaAbility e{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.category = atoi(row[2]);
entry.classes = atoi(row[3]);
entry.races = atoi(row[4]);
entry.drakkin_heritage = atoi(row[5]);
entry.deities = atoi(row[6]);
entry.status = atoi(row[7]);
entry.type = atoi(row[8]);
entry.charges = atoi(row[9]);
entry.grant_only = atoi(row[10]);
entry.first_rank_id = atoi(row[11]);
entry.enabled = atoi(row[12]);
entry.reset_on_death = atoi(row[13]);
e.id = atoi(row[0]);
e.name = row[1] ? row[1] : "";
e.category = atoi(row[2]);
e.classes = atoi(row[3]);
e.races = atoi(row[4]);
e.drakkin_heritage = atoi(row[5]);
e.deities = atoi(row[6]);
e.status = atoi(row[7]);
e.type = atoi(row[8]);
e.charges = atoi(row[9]);
e.grant_only = atoi(row[10]);
e.first_rank_id = atoi(row[11]);
e.enabled = atoi(row[12]);
e.reset_on_death = atoi(row[13]);
return entry;
return e;
}
return NewEntity();
@@ -206,35 +206,35 @@ public:
static int UpdateOne(
Database& db,
AaAbility aa_ability_entry
const AaAbility &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(aa_ability_entry.id));
update_values.push_back(columns[1] + " = '" + Strings::Escape(aa_ability_entry.name) + "'");
update_values.push_back(columns[2] + " = " + std::to_string(aa_ability_entry.category));
update_values.push_back(columns[3] + " = " + std::to_string(aa_ability_entry.classes));
update_values.push_back(columns[4] + " = " + std::to_string(aa_ability_entry.races));
update_values.push_back(columns[5] + " = " + std::to_string(aa_ability_entry.drakkin_heritage));
update_values.push_back(columns[6] + " = " + std::to_string(aa_ability_entry.deities));
update_values.push_back(columns[7] + " = " + std::to_string(aa_ability_entry.status));
update_values.push_back(columns[8] + " = " + std::to_string(aa_ability_entry.type));
update_values.push_back(columns[9] + " = " + std::to_string(aa_ability_entry.charges));
update_values.push_back(columns[10] + " = " + std::to_string(aa_ability_entry.grant_only));
update_values.push_back(columns[11] + " = " + std::to_string(aa_ability_entry.first_rank_id));
update_values.push_back(columns[12] + " = " + std::to_string(aa_ability_entry.enabled));
update_values.push_back(columns[13] + " = " + std::to_string(aa_ability_entry.reset_on_death));
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'");
v.push_back(columns[2] + " = " + std::to_string(e.category));
v.push_back(columns[3] + " = " + std::to_string(e.classes));
v.push_back(columns[4] + " = " + std::to_string(e.races));
v.push_back(columns[5] + " = " + std::to_string(e.drakkin_heritage));
v.push_back(columns[6] + " = " + std::to_string(e.deities));
v.push_back(columns[7] + " = " + std::to_string(e.status));
v.push_back(columns[8] + " = " + std::to_string(e.type));
v.push_back(columns[9] + " = " + std::to_string(e.charges));
v.push_back(columns[10] + " = " + std::to_string(e.grant_only));
v.push_back(columns[11] + " = " + std::to_string(e.first_rank_id));
v.push_back(columns[12] + " = " + std::to_string(e.enabled));
v.push_back(columns[13] + " = " + std::to_string(e.reset_on_death));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
aa_ability_entry.id
e.id
)
);
@@ -243,73 +243,73 @@ public:
static AaAbility InsertOne(
Database& db,
AaAbility aa_ability_entry
AaAbility e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(aa_ability_entry.id));
insert_values.push_back("'" + Strings::Escape(aa_ability_entry.name) + "'");
insert_values.push_back(std::to_string(aa_ability_entry.category));
insert_values.push_back(std::to_string(aa_ability_entry.classes));
insert_values.push_back(std::to_string(aa_ability_entry.races));
insert_values.push_back(std::to_string(aa_ability_entry.drakkin_heritage));
insert_values.push_back(std::to_string(aa_ability_entry.deities));
insert_values.push_back(std::to_string(aa_ability_entry.status));
insert_values.push_back(std::to_string(aa_ability_entry.type));
insert_values.push_back(std::to_string(aa_ability_entry.charges));
insert_values.push_back(std::to_string(aa_ability_entry.grant_only));
insert_values.push_back(std::to_string(aa_ability_entry.first_rank_id));
insert_values.push_back(std::to_string(aa_ability_entry.enabled));
insert_values.push_back(std::to_string(aa_ability_entry.reset_on_death));
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back(std::to_string(e.category));
v.push_back(std::to_string(e.classes));
v.push_back(std::to_string(e.races));
v.push_back(std::to_string(e.drakkin_heritage));
v.push_back(std::to_string(e.deities));
v.push_back(std::to_string(e.status));
v.push_back(std::to_string(e.type));
v.push_back(std::to_string(e.charges));
v.push_back(std::to_string(e.grant_only));
v.push_back(std::to_string(e.first_rank_id));
v.push_back(std::to_string(e.enabled));
v.push_back(std::to_string(e.reset_on_death));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
aa_ability_entry.id = results.LastInsertedID();
return aa_ability_entry;
e.id = results.LastInsertedID();
return e;
}
aa_ability_entry = NewEntity();
e = NewEntity();
return aa_ability_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<AaAbility> aa_ability_entries
const std::vector<AaAbility> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &aa_ability_entry: aa_ability_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(aa_ability_entry.id));
insert_values.push_back("'" + Strings::Escape(aa_ability_entry.name) + "'");
insert_values.push_back(std::to_string(aa_ability_entry.category));
insert_values.push_back(std::to_string(aa_ability_entry.classes));
insert_values.push_back(std::to_string(aa_ability_entry.races));
insert_values.push_back(std::to_string(aa_ability_entry.drakkin_heritage));
insert_values.push_back(std::to_string(aa_ability_entry.deities));
insert_values.push_back(std::to_string(aa_ability_entry.status));
insert_values.push_back(std::to_string(aa_ability_entry.type));
insert_values.push_back(std::to_string(aa_ability_entry.charges));
insert_values.push_back(std::to_string(aa_ability_entry.grant_only));
insert_values.push_back(std::to_string(aa_ability_entry.first_rank_id));
insert_values.push_back(std::to_string(aa_ability_entry.enabled));
insert_values.push_back(std::to_string(aa_ability_entry.reset_on_death));
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back(std::to_string(e.category));
v.push_back(std::to_string(e.classes));
v.push_back(std::to_string(e.races));
v.push_back(std::to_string(e.drakkin_heritage));
v.push_back(std::to_string(e.deities));
v.push_back(std::to_string(e.status));
v.push_back(std::to_string(e.type));
v.push_back(std::to_string(e.charges));
v.push_back(std::to_string(e.grant_only));
v.push_back(std::to_string(e.first_rank_id));
v.push_back(std::to_string(e.enabled));
v.push_back(std::to_string(e.reset_on_death));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -336,30 +336,30 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AaAbility entry{};
AaAbility e{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.category = atoi(row[2]);
entry.classes = atoi(row[3]);
entry.races = atoi(row[4]);
entry.drakkin_heritage = atoi(row[5]);
entry.deities = atoi(row[6]);
entry.status = atoi(row[7]);
entry.type = atoi(row[8]);
entry.charges = atoi(row[9]);
entry.grant_only = atoi(row[10]);
entry.first_rank_id = atoi(row[11]);
entry.enabled = atoi(row[12]);
entry.reset_on_death = atoi(row[13]);
e.id = atoi(row[0]);
e.name = row[1] ? row[1] : "";
e.category = atoi(row[2]);
e.classes = atoi(row[3]);
e.races = atoi(row[4]);
e.drakkin_heritage = atoi(row[5]);
e.deities = atoi(row[6]);
e.status = atoi(row[7]);
e.type = atoi(row[8]);
e.charges = atoi(row[9]);
e.grant_only = atoi(row[10]);
e.first_rank_id = atoi(row[11]);
e.enabled = atoi(row[12]);
e.reset_on_death = atoi(row[13]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AaAbility> GetWhere(Database& db, std::string where_filter)
static std::vector<AaAbility> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AaAbility> all_entries;
@@ -374,30 +374,30 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AaAbility entry{};
AaAbility e{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.category = atoi(row[2]);
entry.classes = atoi(row[3]);
entry.races = atoi(row[4]);
entry.drakkin_heritage = atoi(row[5]);
entry.deities = atoi(row[6]);
entry.status = atoi(row[7]);
entry.type = atoi(row[8]);
entry.charges = atoi(row[9]);
entry.grant_only = atoi(row[10]);
entry.first_rank_id = atoi(row[11]);
entry.enabled = atoi(row[12]);
entry.reset_on_death = atoi(row[13]);
e.id = atoi(row[0]);
e.name = row[1] ? row[1] : "";
e.category = atoi(row[2]);
e.classes = atoi(row[3]);
e.races = atoi(row[4]);
e.drakkin_heritage = atoi(row[5]);
e.deities = atoi(row[6]);
e.status = atoi(row[7]);
e.type = atoi(row[8]);
e.charges = atoi(row[9]);
e.grant_only = atoi(row[10]);
e.first_rank_id = atoi(row[11]);
e.enabled = atoi(row[12]);
e.reset_on_death = atoi(row[13]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -422,6 +422,32 @@ public:
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_AA_ABILITY_REPOSITORY_H
@@ -88,18 +88,18 @@ public:
static AaRankEffects NewEntity()
{
AaRankEffects entry{};
AaRankEffects e{};
entry.rank_id = 0;
entry.slot = 1;
entry.effect_id = 0;
entry.base1 = 0;
entry.base2 = 0;
e.rank_id = 0;
e.slot = 1;
e.effect_id = 0;
e.base1 = 0;
e.base2 = 0;
return entry;
return e;
}
static AaRankEffects GetAaRankEffectsEntry(
static AaRankEffects GetAaRankEffects(
const std::vector<AaRankEffects> &aa_rank_effectss,
int aa_rank_effects_id
)
@@ -128,15 +128,15 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
AaRankEffects entry{};
AaRankEffects e{};
entry.rank_id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.effect_id = atoi(row[2]);
entry.base1 = atoi(row[3]);
entry.base2 = atoi(row[4]);
e.rank_id = atoi(row[0]);
e.slot = atoi(row[1]);
e.effect_id = atoi(row[2]);
e.base1 = atoi(row[3]);
e.base2 = atoi(row[4]);
return entry;
return e;
}
return NewEntity();
@@ -161,26 +161,26 @@ public:
static int UpdateOne(
Database& db,
AaRankEffects aa_rank_effects_entry
const AaRankEffects &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(aa_rank_effects_entry.rank_id));
update_values.push_back(columns[1] + " = " + std::to_string(aa_rank_effects_entry.slot));
update_values.push_back(columns[2] + " = " + std::to_string(aa_rank_effects_entry.effect_id));
update_values.push_back(columns[3] + " = " + std::to_string(aa_rank_effects_entry.base1));
update_values.push_back(columns[4] + " = " + std::to_string(aa_rank_effects_entry.base2));
v.push_back(columns[0] + " = " + std::to_string(e.rank_id));
v.push_back(columns[1] + " = " + std::to_string(e.slot));
v.push_back(columns[2] + " = " + std::to_string(e.effect_id));
v.push_back(columns[3] + " = " + std::to_string(e.base1));
v.push_back(columns[4] + " = " + std::to_string(e.base2));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
aa_rank_effects_entry.rank_id
e.rank_id
)
);
@@ -189,55 +189,55 @@ public:
static AaRankEffects InsertOne(
Database& db,
AaRankEffects aa_rank_effects_entry
AaRankEffects e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(aa_rank_effects_entry.rank_id));
insert_values.push_back(std::to_string(aa_rank_effects_entry.slot));
insert_values.push_back(std::to_string(aa_rank_effects_entry.effect_id));
insert_values.push_back(std::to_string(aa_rank_effects_entry.base1));
insert_values.push_back(std::to_string(aa_rank_effects_entry.base2));
v.push_back(std::to_string(e.rank_id));
v.push_back(std::to_string(e.slot));
v.push_back(std::to_string(e.effect_id));
v.push_back(std::to_string(e.base1));
v.push_back(std::to_string(e.base2));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
aa_rank_effects_entry.rank_id = results.LastInsertedID();
return aa_rank_effects_entry;
e.rank_id = results.LastInsertedID();
return e;
}
aa_rank_effects_entry = NewEntity();
e = NewEntity();
return aa_rank_effects_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<AaRankEffects> aa_rank_effects_entries
const std::vector<AaRankEffects> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &aa_rank_effects_entry: aa_rank_effects_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(aa_rank_effects_entry.rank_id));
insert_values.push_back(std::to_string(aa_rank_effects_entry.slot));
insert_values.push_back(std::to_string(aa_rank_effects_entry.effect_id));
insert_values.push_back(std::to_string(aa_rank_effects_entry.base1));
insert_values.push_back(std::to_string(aa_rank_effects_entry.base2));
v.push_back(std::to_string(e.rank_id));
v.push_back(std::to_string(e.slot));
v.push_back(std::to_string(e.effect_id));
v.push_back(std::to_string(e.base1));
v.push_back(std::to_string(e.base2));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -264,21 +264,21 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AaRankEffects entry{};
AaRankEffects e{};
entry.rank_id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.effect_id = atoi(row[2]);
entry.base1 = atoi(row[3]);
entry.base2 = atoi(row[4]);
e.rank_id = atoi(row[0]);
e.slot = atoi(row[1]);
e.effect_id = atoi(row[2]);
e.base1 = atoi(row[3]);
e.base2 = atoi(row[4]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AaRankEffects> GetWhere(Database& db, std::string where_filter)
static std::vector<AaRankEffects> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AaRankEffects> all_entries;
@@ -293,21 +293,21 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AaRankEffects entry{};
AaRankEffects e{};
entry.rank_id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.effect_id = atoi(row[2]);
entry.base1 = atoi(row[3]);
entry.base2 = atoi(row[4]);
e.rank_id = atoi(row[0]);
e.slot = atoi(row[1]);
e.effect_id = atoi(row[2]);
e.base1 = atoi(row[3]);
e.base2 = atoi(row[4]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -332,6 +332,32 @@ public:
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_AA_RANK_EFFECTS_REPOSITORY_H
@@ -82,16 +82,16 @@ public:
static AaRankPrereqs NewEntity()
{
AaRankPrereqs entry{};
AaRankPrereqs e{};
entry.rank_id = 0;
entry.aa_id = 0;
entry.points = 0;
e.rank_id = 0;
e.aa_id = 0;
e.points = 0;
return entry;
return e;
}
static AaRankPrereqs GetAaRankPrereqsEntry(
static AaRankPrereqs GetAaRankPrereqs(
const std::vector<AaRankPrereqs> &aa_rank_prereqss,
int aa_rank_prereqs_id
)
@@ -120,13 +120,13 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
AaRankPrereqs entry{};
AaRankPrereqs e{};
entry.rank_id = atoi(row[0]);
entry.aa_id = atoi(row[1]);
entry.points = atoi(row[2]);
e.rank_id = atoi(row[0]);
e.aa_id = atoi(row[1]);
e.points = atoi(row[2]);
return entry;
return e;
}
return NewEntity();
@@ -151,24 +151,24 @@ public:
static int UpdateOne(
Database& db,
AaRankPrereqs aa_rank_prereqs_entry
const AaRankPrereqs &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(aa_rank_prereqs_entry.rank_id));
update_values.push_back(columns[1] + " = " + std::to_string(aa_rank_prereqs_entry.aa_id));
update_values.push_back(columns[2] + " = " + std::to_string(aa_rank_prereqs_entry.points));
v.push_back(columns[0] + " = " + std::to_string(e.rank_id));
v.push_back(columns[1] + " = " + std::to_string(e.aa_id));
v.push_back(columns[2] + " = " + std::to_string(e.points));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
aa_rank_prereqs_entry.rank_id
e.rank_id
)
);
@@ -177,51 +177,51 @@ public:
static AaRankPrereqs InsertOne(
Database& db,
AaRankPrereqs aa_rank_prereqs_entry
AaRankPrereqs e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(aa_rank_prereqs_entry.rank_id));
insert_values.push_back(std::to_string(aa_rank_prereqs_entry.aa_id));
insert_values.push_back(std::to_string(aa_rank_prereqs_entry.points));
v.push_back(std::to_string(e.rank_id));
v.push_back(std::to_string(e.aa_id));
v.push_back(std::to_string(e.points));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
aa_rank_prereqs_entry.rank_id = results.LastInsertedID();
return aa_rank_prereqs_entry;
e.rank_id = results.LastInsertedID();
return e;
}
aa_rank_prereqs_entry = NewEntity();
e = NewEntity();
return aa_rank_prereqs_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<AaRankPrereqs> aa_rank_prereqs_entries
const std::vector<AaRankPrereqs> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &aa_rank_prereqs_entry: aa_rank_prereqs_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(aa_rank_prereqs_entry.rank_id));
insert_values.push_back(std::to_string(aa_rank_prereqs_entry.aa_id));
insert_values.push_back(std::to_string(aa_rank_prereqs_entry.points));
v.push_back(std::to_string(e.rank_id));
v.push_back(std::to_string(e.aa_id));
v.push_back(std::to_string(e.points));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -248,19 +248,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AaRankPrereqs entry{};
AaRankPrereqs e{};
entry.rank_id = atoi(row[0]);
entry.aa_id = atoi(row[1]);
entry.points = atoi(row[2]);
e.rank_id = atoi(row[0]);
e.aa_id = atoi(row[1]);
e.points = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AaRankPrereqs> GetWhere(Database& db, std::string where_filter)
static std::vector<AaRankPrereqs> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AaRankPrereqs> all_entries;
@@ -275,19 +275,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AaRankPrereqs entry{};
AaRankPrereqs e{};
entry.rank_id = atoi(row[0]);
entry.aa_id = atoi(row[1]);
entry.points = atoi(row[2]);
e.rank_id = atoi(row[0]);
e.aa_id = atoi(row[1]);
e.points = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -312,6 +312,32 @@ public:
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_AA_RANK_PREREQS_REPOSITORY_H
@@ -112,26 +112,26 @@ public:
static AaRanks NewEntity()
{
AaRanks entry{};
AaRanks e{};
entry.id = 0;
entry.upper_hotkey_sid = -1;
entry.lower_hotkey_sid = -1;
entry.title_sid = -1;
entry.desc_sid = -1;
entry.cost = 1;
entry.level_req = 51;
entry.spell = -1;
entry.spell_type = 0;
entry.recast_time = 0;
entry.expansion = 0;
entry.prev_id = -1;
entry.next_id = -1;
e.id = 0;
e.upper_hotkey_sid = -1;
e.lower_hotkey_sid = -1;
e.title_sid = -1;
e.desc_sid = -1;
e.cost = 1;
e.level_req = 51;
e.spell = -1;
e.spell_type = 0;
e.recast_time = 0;
e.expansion = 0;
e.prev_id = -1;
e.next_id = -1;
return entry;
return e;
}
static AaRanks GetAaRanksEntry(
static AaRanks GetAaRanks(
const std::vector<AaRanks> &aa_rankss,
int aa_ranks_id
)
@@ -160,23 +160,23 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
AaRanks entry{};
AaRanks e{};
entry.id = atoi(row[0]);
entry.upper_hotkey_sid = atoi(row[1]);
entry.lower_hotkey_sid = atoi(row[2]);
entry.title_sid = atoi(row[3]);
entry.desc_sid = atoi(row[4]);
entry.cost = atoi(row[5]);
entry.level_req = atoi(row[6]);
entry.spell = atoi(row[7]);
entry.spell_type = atoi(row[8]);
entry.recast_time = atoi(row[9]);
entry.expansion = atoi(row[10]);
entry.prev_id = atoi(row[11]);
entry.next_id = atoi(row[12]);
e.id = atoi(row[0]);
e.upper_hotkey_sid = atoi(row[1]);
e.lower_hotkey_sid = atoi(row[2]);
e.title_sid = atoi(row[3]);
e.desc_sid = atoi(row[4]);
e.cost = atoi(row[5]);
e.level_req = atoi(row[6]);
e.spell = atoi(row[7]);
e.spell_type = atoi(row[8]);
e.recast_time = atoi(row[9]);
e.expansion = atoi(row[10]);
e.prev_id = atoi(row[11]);
e.next_id = atoi(row[12]);
return entry;
return e;
}
return NewEntity();
@@ -201,34 +201,34 @@ public:
static int UpdateOne(
Database& db,
AaRanks aa_ranks_entry
const AaRanks &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(aa_ranks_entry.id));
update_values.push_back(columns[1] + " = " + std::to_string(aa_ranks_entry.upper_hotkey_sid));
update_values.push_back(columns[2] + " = " + std::to_string(aa_ranks_entry.lower_hotkey_sid));
update_values.push_back(columns[3] + " = " + std::to_string(aa_ranks_entry.title_sid));
update_values.push_back(columns[4] + " = " + std::to_string(aa_ranks_entry.desc_sid));
update_values.push_back(columns[5] + " = " + std::to_string(aa_ranks_entry.cost));
update_values.push_back(columns[6] + " = " + std::to_string(aa_ranks_entry.level_req));
update_values.push_back(columns[7] + " = " + std::to_string(aa_ranks_entry.spell));
update_values.push_back(columns[8] + " = " + std::to_string(aa_ranks_entry.spell_type));
update_values.push_back(columns[9] + " = " + std::to_string(aa_ranks_entry.recast_time));
update_values.push_back(columns[10] + " = " + std::to_string(aa_ranks_entry.expansion));
update_values.push_back(columns[11] + " = " + std::to_string(aa_ranks_entry.prev_id));
update_values.push_back(columns[12] + " = " + std::to_string(aa_ranks_entry.next_id));
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = " + std::to_string(e.upper_hotkey_sid));
v.push_back(columns[2] + " = " + std::to_string(e.lower_hotkey_sid));
v.push_back(columns[3] + " = " + std::to_string(e.title_sid));
v.push_back(columns[4] + " = " + std::to_string(e.desc_sid));
v.push_back(columns[5] + " = " + std::to_string(e.cost));
v.push_back(columns[6] + " = " + std::to_string(e.level_req));
v.push_back(columns[7] + " = " + std::to_string(e.spell));
v.push_back(columns[8] + " = " + std::to_string(e.spell_type));
v.push_back(columns[9] + " = " + std::to_string(e.recast_time));
v.push_back(columns[10] + " = " + std::to_string(e.expansion));
v.push_back(columns[11] + " = " + std::to_string(e.prev_id));
v.push_back(columns[12] + " = " + std::to_string(e.next_id));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
aa_ranks_entry.id
e.id
)
);
@@ -237,71 +237,71 @@ public:
static AaRanks InsertOne(
Database& db,
AaRanks aa_ranks_entry
AaRanks e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(aa_ranks_entry.id));
insert_values.push_back(std::to_string(aa_ranks_entry.upper_hotkey_sid));
insert_values.push_back(std::to_string(aa_ranks_entry.lower_hotkey_sid));
insert_values.push_back(std::to_string(aa_ranks_entry.title_sid));
insert_values.push_back(std::to_string(aa_ranks_entry.desc_sid));
insert_values.push_back(std::to_string(aa_ranks_entry.cost));
insert_values.push_back(std::to_string(aa_ranks_entry.level_req));
insert_values.push_back(std::to_string(aa_ranks_entry.spell));
insert_values.push_back(std::to_string(aa_ranks_entry.spell_type));
insert_values.push_back(std::to_string(aa_ranks_entry.recast_time));
insert_values.push_back(std::to_string(aa_ranks_entry.expansion));
insert_values.push_back(std::to_string(aa_ranks_entry.prev_id));
insert_values.push_back(std::to_string(aa_ranks_entry.next_id));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.upper_hotkey_sid));
v.push_back(std::to_string(e.lower_hotkey_sid));
v.push_back(std::to_string(e.title_sid));
v.push_back(std::to_string(e.desc_sid));
v.push_back(std::to_string(e.cost));
v.push_back(std::to_string(e.level_req));
v.push_back(std::to_string(e.spell));
v.push_back(std::to_string(e.spell_type));
v.push_back(std::to_string(e.recast_time));
v.push_back(std::to_string(e.expansion));
v.push_back(std::to_string(e.prev_id));
v.push_back(std::to_string(e.next_id));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
aa_ranks_entry.id = results.LastInsertedID();
return aa_ranks_entry;
e.id = results.LastInsertedID();
return e;
}
aa_ranks_entry = NewEntity();
e = NewEntity();
return aa_ranks_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<AaRanks> aa_ranks_entries
const std::vector<AaRanks> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &aa_ranks_entry: aa_ranks_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(aa_ranks_entry.id));
insert_values.push_back(std::to_string(aa_ranks_entry.upper_hotkey_sid));
insert_values.push_back(std::to_string(aa_ranks_entry.lower_hotkey_sid));
insert_values.push_back(std::to_string(aa_ranks_entry.title_sid));
insert_values.push_back(std::to_string(aa_ranks_entry.desc_sid));
insert_values.push_back(std::to_string(aa_ranks_entry.cost));
insert_values.push_back(std::to_string(aa_ranks_entry.level_req));
insert_values.push_back(std::to_string(aa_ranks_entry.spell));
insert_values.push_back(std::to_string(aa_ranks_entry.spell_type));
insert_values.push_back(std::to_string(aa_ranks_entry.recast_time));
insert_values.push_back(std::to_string(aa_ranks_entry.expansion));
insert_values.push_back(std::to_string(aa_ranks_entry.prev_id));
insert_values.push_back(std::to_string(aa_ranks_entry.next_id));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.upper_hotkey_sid));
v.push_back(std::to_string(e.lower_hotkey_sid));
v.push_back(std::to_string(e.title_sid));
v.push_back(std::to_string(e.desc_sid));
v.push_back(std::to_string(e.cost));
v.push_back(std::to_string(e.level_req));
v.push_back(std::to_string(e.spell));
v.push_back(std::to_string(e.spell_type));
v.push_back(std::to_string(e.recast_time));
v.push_back(std::to_string(e.expansion));
v.push_back(std::to_string(e.prev_id));
v.push_back(std::to_string(e.next_id));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -328,29 +328,29 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AaRanks entry{};
AaRanks e{};
entry.id = atoi(row[0]);
entry.upper_hotkey_sid = atoi(row[1]);
entry.lower_hotkey_sid = atoi(row[2]);
entry.title_sid = atoi(row[3]);
entry.desc_sid = atoi(row[4]);
entry.cost = atoi(row[5]);
entry.level_req = atoi(row[6]);
entry.spell = atoi(row[7]);
entry.spell_type = atoi(row[8]);
entry.recast_time = atoi(row[9]);
entry.expansion = atoi(row[10]);
entry.prev_id = atoi(row[11]);
entry.next_id = atoi(row[12]);
e.id = atoi(row[0]);
e.upper_hotkey_sid = atoi(row[1]);
e.lower_hotkey_sid = atoi(row[2]);
e.title_sid = atoi(row[3]);
e.desc_sid = atoi(row[4]);
e.cost = atoi(row[5]);
e.level_req = atoi(row[6]);
e.spell = atoi(row[7]);
e.spell_type = atoi(row[8]);
e.recast_time = atoi(row[9]);
e.expansion = atoi(row[10]);
e.prev_id = atoi(row[11]);
e.next_id = atoi(row[12]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AaRanks> GetWhere(Database& db, std::string where_filter)
static std::vector<AaRanks> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AaRanks> all_entries;
@@ -365,29 +365,29 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AaRanks entry{};
AaRanks e{};
entry.id = atoi(row[0]);
entry.upper_hotkey_sid = atoi(row[1]);
entry.lower_hotkey_sid = atoi(row[2]);
entry.title_sid = atoi(row[3]);
entry.desc_sid = atoi(row[4]);
entry.cost = atoi(row[5]);
entry.level_req = atoi(row[6]);
entry.spell = atoi(row[7]);
entry.spell_type = atoi(row[8]);
entry.recast_time = atoi(row[9]);
entry.expansion = atoi(row[10]);
entry.prev_id = atoi(row[11]);
entry.next_id = atoi(row[12]);
e.id = atoi(row[0]);
e.upper_hotkey_sid = atoi(row[1]);
e.lower_hotkey_sid = atoi(row[2]);
e.title_sid = atoi(row[3]);
e.desc_sid = atoi(row[4]);
e.cost = atoi(row[5]);
e.level_req = atoi(row[6]);
e.spell = atoi(row[7]);
e.spell_type = atoi(row[8]);
e.recast_time = atoi(row[9]);
e.expansion = atoi(row[10]);
e.prev_id = atoi(row[11]);
e.next_id = atoi(row[12]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -412,6 +412,32 @@ public:
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_AA_RANKS_REPOSITORY_H
@@ -82,16 +82,16 @@ public:
static AccountFlags NewEntity()
{
AccountFlags entry{};
AccountFlags e{};
entry.p_accid = 0;
entry.p_flag = "";
entry.p_value = "";
e.p_accid = 0;
e.p_flag = "";
e.p_value = "";
return entry;
return e;
}
static AccountFlags GetAccountFlagsEntry(
static AccountFlags GetAccountFlags(
const std::vector<AccountFlags> &account_flagss,
int account_flags_id
)
@@ -120,13 +120,13 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
AccountFlags entry{};
AccountFlags e{};
entry.p_accid = atoi(row[0]);
entry.p_flag = row[1] ? row[1] : "";
entry.p_value = row[2] ? row[2] : "";
e.p_accid = atoi(row[0]);
e.p_flag = row[1] ? row[1] : "";
e.p_value = row[2] ? row[2] : "";
return entry;
return e;
}
return NewEntity();
@@ -151,24 +151,24 @@ public:
static int UpdateOne(
Database& db,
AccountFlags account_flags_entry
const AccountFlags &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(account_flags_entry.p_accid));
update_values.push_back(columns[1] + " = '" + Strings::Escape(account_flags_entry.p_flag) + "'");
update_values.push_back(columns[2] + " = '" + Strings::Escape(account_flags_entry.p_value) + "'");
v.push_back(columns[0] + " = " + std::to_string(e.p_accid));
v.push_back(columns[1] + " = '" + Strings::Escape(e.p_flag) + "'");
v.push_back(columns[2] + " = '" + Strings::Escape(e.p_value) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
account_flags_entry.p_accid
e.p_accid
)
);
@@ -177,51 +177,51 @@ public:
static AccountFlags InsertOne(
Database& db,
AccountFlags account_flags_entry
AccountFlags e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(account_flags_entry.p_accid));
insert_values.push_back("'" + Strings::Escape(account_flags_entry.p_flag) + "'");
insert_values.push_back("'" + Strings::Escape(account_flags_entry.p_value) + "'");
v.push_back(std::to_string(e.p_accid));
v.push_back("'" + Strings::Escape(e.p_flag) + "'");
v.push_back("'" + Strings::Escape(e.p_value) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
account_flags_entry.p_accid = results.LastInsertedID();
return account_flags_entry;
e.p_accid = results.LastInsertedID();
return e;
}
account_flags_entry = NewEntity();
e = NewEntity();
return account_flags_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<AccountFlags> account_flags_entries
const std::vector<AccountFlags> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &account_flags_entry: account_flags_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(account_flags_entry.p_accid));
insert_values.push_back("'" + Strings::Escape(account_flags_entry.p_flag) + "'");
insert_values.push_back("'" + Strings::Escape(account_flags_entry.p_value) + "'");
v.push_back(std::to_string(e.p_accid));
v.push_back("'" + Strings::Escape(e.p_flag) + "'");
v.push_back("'" + Strings::Escape(e.p_value) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -248,19 +248,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AccountFlags entry{};
AccountFlags e{};
entry.p_accid = atoi(row[0]);
entry.p_flag = row[1] ? row[1] : "";
entry.p_value = row[2] ? row[2] : "";
e.p_accid = atoi(row[0]);
e.p_flag = row[1] ? row[1] : "";
e.p_value = row[2] ? row[2] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AccountFlags> GetWhere(Database& db, std::string where_filter)
static std::vector<AccountFlags> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AccountFlags> all_entries;
@@ -275,19 +275,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AccountFlags entry{};
AccountFlags e{};
entry.p_accid = atoi(row[0]);
entry.p_flag = row[1] ? row[1] : "";
entry.p_value = row[2] ? row[2] : "";
e.p_accid = atoi(row[0]);
e.p_flag = row[1] ? row[1] : "";
e.p_value = row[2] ? row[2] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -312,6 +312,32 @@ public:
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_ACCOUNT_FLAGS_REPOSITORY_H
@@ -85,17 +85,17 @@ public:
static AccountIp NewEntity()
{
AccountIp entry{};
AccountIp e{};
entry.accid = 0;
entry.ip = "";
entry.count = 1;
entry.lastused = std::time(nullptr);
e.accid = 0;
e.ip = "";
e.count = 1;
e.lastused = std::time(nullptr);
return entry;
return e;
}
static AccountIp GetAccountIpEntry(
static AccountIp GetAccountIp(
const std::vector<AccountIp> &account_ips,
int account_ip_id
)
@@ -124,14 +124,14 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
AccountIp entry{};
AccountIp e{};
entry.accid = atoi(row[0]);
entry.ip = row[1] ? row[1] : "";
entry.count = atoi(row[2]);
entry.lastused = row[3] ? row[3] : "";
e.accid = atoi(row[0]);
e.ip = row[1] ? row[1] : "";
e.count = atoi(row[2]);
e.lastused = row[3] ? row[3] : "";
return entry;
return e;
}
return NewEntity();
@@ -156,25 +156,25 @@ public:
static int UpdateOne(
Database& db,
AccountIp account_ip_entry
const AccountIp &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(account_ip_entry.accid));
update_values.push_back(columns[1] + " = '" + Strings::Escape(account_ip_entry.ip) + "'");
update_values.push_back(columns[2] + " = " + std::to_string(account_ip_entry.count));
update_values.push_back(columns[3] + " = '" + Strings::Escape(account_ip_entry.lastused) + "'");
v.push_back(columns[0] + " = " + std::to_string(e.accid));
v.push_back(columns[1] + " = '" + Strings::Escape(e.ip) + "'");
v.push_back(columns[2] + " = " + std::to_string(e.count));
v.push_back(columns[3] + " = '" + Strings::Escape(e.lastused) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
account_ip_entry.accid
e.accid
)
);
@@ -183,53 +183,53 @@ public:
static AccountIp InsertOne(
Database& db,
AccountIp account_ip_entry
AccountIp e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(account_ip_entry.accid));
insert_values.push_back("'" + Strings::Escape(account_ip_entry.ip) + "'");
insert_values.push_back(std::to_string(account_ip_entry.count));
insert_values.push_back("'" + Strings::Escape(account_ip_entry.lastused) + "'");
v.push_back(std::to_string(e.accid));
v.push_back("'" + Strings::Escape(e.ip) + "'");
v.push_back(std::to_string(e.count));
v.push_back("'" + Strings::Escape(e.lastused) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
account_ip_entry.accid = results.LastInsertedID();
return account_ip_entry;
e.accid = results.LastInsertedID();
return e;
}
account_ip_entry = NewEntity();
e = NewEntity();
return account_ip_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<AccountIp> account_ip_entries
const std::vector<AccountIp> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &account_ip_entry: account_ip_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(account_ip_entry.accid));
insert_values.push_back("'" + Strings::Escape(account_ip_entry.ip) + "'");
insert_values.push_back(std::to_string(account_ip_entry.count));
insert_values.push_back("'" + Strings::Escape(account_ip_entry.lastused) + "'");
v.push_back(std::to_string(e.accid));
v.push_back("'" + Strings::Escape(e.ip) + "'");
v.push_back(std::to_string(e.count));
v.push_back("'" + Strings::Escape(e.lastused) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -256,20 +256,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AccountIp entry{};
AccountIp e{};
entry.accid = atoi(row[0]);
entry.ip = row[1] ? row[1] : "";
entry.count = atoi(row[2]);
entry.lastused = row[3] ? row[3] : "";
e.accid = atoi(row[0]);
e.ip = row[1] ? row[1] : "";
e.count = atoi(row[2]);
e.lastused = row[3] ? row[3] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AccountIp> GetWhere(Database& db, std::string where_filter)
static std::vector<AccountIp> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AccountIp> all_entries;
@@ -284,20 +284,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AccountIp entry{};
AccountIp e{};
entry.accid = atoi(row[0]);
entry.ip = row[1] ? row[1] : "";
entry.count = atoi(row[2]);
entry.lastused = row[3] ? row[3] : "";
e.accid = atoi(row[0]);
e.ip = row[1] ? row[1] : "";
e.count = atoi(row[2]);
e.lastused = row[3] ? row[3] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -322,6 +322,32 @@ public:
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_ACCOUNT_IP_REPOSITORY_H
+220 -194
View File
@@ -145,37 +145,37 @@ public:
static Account NewEntity()
{
Account entry{};
Account e{};
entry.id = 0;
entry.name = "";
entry.charname = "";
entry.sharedplat = 0;
entry.password = "";
entry.status = 0;
entry.ls_id = "eqemu";
entry.lsaccount_id = 0;
entry.gmspeed = 0;
entry.invulnerable = 0;
entry.flymode = 0;
entry.ignore_tells = 0;
entry.revoked = 0;
entry.karma = 0;
entry.minilogin_ip = "";
entry.hideme = 0;
entry.rulesflag = 0;
entry.suspendeduntil = 0;
entry.time_creation = 0;
entry.ban_reason = "";
entry.suspend_reason = "";
entry.crc_eqgame = "";
entry.crc_skillcaps = "";
entry.crc_basedata = "";
e.id = 0;
e.name = "";
e.charname = "";
e.sharedplat = 0;
e.password = "";
e.status = 0;
e.ls_id = "eqemu";
e.lsaccount_id = 0;
e.gmspeed = 0;
e.invulnerable = 0;
e.flymode = 0;
e.ignore_tells = 0;
e.revoked = 0;
e.karma = 0;
e.minilogin_ip = "";
e.hideme = 0;
e.rulesflag = 0;
e.suspendeduntil = 0;
e.time_creation = 0;
e.ban_reason = "";
e.suspend_reason = "";
e.crc_eqgame = "";
e.crc_skillcaps = "";
e.crc_basedata = "";
return entry;
return e;
}
static Account GetAccountEntry(
static Account GetAccount(
const std::vector<Account> &accounts,
int account_id
)
@@ -204,34 +204,34 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
Account entry{};
Account e{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.charname = row[2] ? row[2] : "";
entry.sharedplat = atoi(row[3]);
entry.password = row[4] ? row[4] : "";
entry.status = atoi(row[5]);
entry.ls_id = row[6] ? row[6] : "";
entry.lsaccount_id = atoi(row[7]);
entry.gmspeed = atoi(row[8]);
entry.invulnerable = atoi(row[9]);
entry.flymode = atoi(row[10]);
entry.ignore_tells = atoi(row[11]);
entry.revoked = atoi(row[12]);
entry.karma = atoi(row[13]);
entry.minilogin_ip = row[14] ? row[14] : "";
entry.hideme = atoi(row[15]);
entry.rulesflag = atoi(row[16]);
entry.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
entry.time_creation = atoi(row[18]);
entry.ban_reason = row[19] ? row[19] : "";
entry.suspend_reason = row[20] ? row[20] : "";
entry.crc_eqgame = row[21] ? row[21] : "";
entry.crc_skillcaps = row[22] ? row[22] : "";
entry.crc_basedata = row[23] ? row[23] : "";
e.id = atoi(row[0]);
e.name = row[1] ? row[1] : "";
e.charname = row[2] ? row[2] : "";
e.sharedplat = atoi(row[3]);
e.password = row[4] ? row[4] : "";
e.status = atoi(row[5]);
e.ls_id = row[6] ? row[6] : "";
e.lsaccount_id = atoi(row[7]);
e.gmspeed = atoi(row[8]);
e.invulnerable = atoi(row[9]);
e.flymode = atoi(row[10]);
e.ignore_tells = atoi(row[11]);
e.revoked = atoi(row[12]);
e.karma = atoi(row[13]);
e.minilogin_ip = row[14] ? row[14] : "";
e.hideme = atoi(row[15]);
e.rulesflag = atoi(row[16]);
e.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
e.time_creation = atoi(row[18]);
e.ban_reason = row[19] ? row[19] : "";
e.suspend_reason = row[20] ? row[20] : "";
e.crc_eqgame = row[21] ? row[21] : "";
e.crc_skillcaps = row[22] ? row[22] : "";
e.crc_basedata = row[23] ? row[23] : "";
return entry;
return e;
}
return NewEntity();
@@ -256,44 +256,44 @@ public:
static int UpdateOne(
Database& db,
Account account_entry
const Account &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + Strings::Escape(account_entry.name) + "'");
update_values.push_back(columns[2] + " = '" + Strings::Escape(account_entry.charname) + "'");
update_values.push_back(columns[3] + " = " + std::to_string(account_entry.sharedplat));
update_values.push_back(columns[4] + " = '" + Strings::Escape(account_entry.password) + "'");
update_values.push_back(columns[5] + " = " + std::to_string(account_entry.status));
update_values.push_back(columns[6] + " = '" + Strings::Escape(account_entry.ls_id) + "'");
update_values.push_back(columns[7] + " = " + std::to_string(account_entry.lsaccount_id));
update_values.push_back(columns[8] + " = " + std::to_string(account_entry.gmspeed));
update_values.push_back(columns[9] + " = " + std::to_string(account_entry.invulnerable));
update_values.push_back(columns[10] + " = " + std::to_string(account_entry.flymode));
update_values.push_back(columns[11] + " = " + std::to_string(account_entry.ignore_tells));
update_values.push_back(columns[12] + " = " + std::to_string(account_entry.revoked));
update_values.push_back(columns[13] + " = " + std::to_string(account_entry.karma));
update_values.push_back(columns[14] + " = '" + Strings::Escape(account_entry.minilogin_ip) + "'");
update_values.push_back(columns[15] + " = " + std::to_string(account_entry.hideme));
update_values.push_back(columns[16] + " = " + std::to_string(account_entry.rulesflag));
update_values.push_back(columns[17] + " = FROM_UNIXTIME(" + (account_entry.suspendeduntil > 0 ? std::to_string(account_entry.suspendeduntil) : "null") + ")");
update_values.push_back(columns[18] + " = " + std::to_string(account_entry.time_creation));
update_values.push_back(columns[19] + " = '" + Strings::Escape(account_entry.ban_reason) + "'");
update_values.push_back(columns[20] + " = '" + Strings::Escape(account_entry.suspend_reason) + "'");
update_values.push_back(columns[21] + " = '" + Strings::Escape(account_entry.crc_eqgame) + "'");
update_values.push_back(columns[22] + " = '" + Strings::Escape(account_entry.crc_skillcaps) + "'");
update_values.push_back(columns[23] + " = '" + Strings::Escape(account_entry.crc_basedata) + "'");
v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'");
v.push_back(columns[2] + " = '" + Strings::Escape(e.charname) + "'");
v.push_back(columns[3] + " = " + std::to_string(e.sharedplat));
v.push_back(columns[4] + " = '" + Strings::Escape(e.password) + "'");
v.push_back(columns[5] + " = " + std::to_string(e.status));
v.push_back(columns[6] + " = '" + Strings::Escape(e.ls_id) + "'");
v.push_back(columns[7] + " = " + std::to_string(e.lsaccount_id));
v.push_back(columns[8] + " = " + std::to_string(e.gmspeed));
v.push_back(columns[9] + " = " + std::to_string(e.invulnerable));
v.push_back(columns[10] + " = " + std::to_string(e.flymode));
v.push_back(columns[11] + " = " + std::to_string(e.ignore_tells));
v.push_back(columns[12] + " = " + std::to_string(e.revoked));
v.push_back(columns[13] + " = " + std::to_string(e.karma));
v.push_back(columns[14] + " = '" + Strings::Escape(e.minilogin_ip) + "'");
v.push_back(columns[15] + " = " + std::to_string(e.hideme));
v.push_back(columns[16] + " = " + std::to_string(e.rulesflag));
v.push_back(columns[17] + " = FROM_UNIXTIME(" + (e.suspendeduntil > 0 ? std::to_string(e.suspendeduntil) : "null") + ")");
v.push_back(columns[18] + " = " + std::to_string(e.time_creation));
v.push_back(columns[19] + " = '" + Strings::Escape(e.ban_reason) + "'");
v.push_back(columns[20] + " = '" + Strings::Escape(e.suspend_reason) + "'");
v.push_back(columns[21] + " = '" + Strings::Escape(e.crc_eqgame) + "'");
v.push_back(columns[22] + " = '" + Strings::Escape(e.crc_skillcaps) + "'");
v.push_back(columns[23] + " = '" + Strings::Escape(e.crc_basedata) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
account_entry.id
e.id
)
);
@@ -302,93 +302,93 @@ public:
static Account InsertOne(
Database& db,
Account account_entry
Account e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(account_entry.id));
insert_values.push_back("'" + Strings::Escape(account_entry.name) + "'");
insert_values.push_back("'" + Strings::Escape(account_entry.charname) + "'");
insert_values.push_back(std::to_string(account_entry.sharedplat));
insert_values.push_back("'" + Strings::Escape(account_entry.password) + "'");
insert_values.push_back(std::to_string(account_entry.status));
insert_values.push_back("'" + Strings::Escape(account_entry.ls_id) + "'");
insert_values.push_back(std::to_string(account_entry.lsaccount_id));
insert_values.push_back(std::to_string(account_entry.gmspeed));
insert_values.push_back(std::to_string(account_entry.invulnerable));
insert_values.push_back(std::to_string(account_entry.flymode));
insert_values.push_back(std::to_string(account_entry.ignore_tells));
insert_values.push_back(std::to_string(account_entry.revoked));
insert_values.push_back(std::to_string(account_entry.karma));
insert_values.push_back("'" + Strings::Escape(account_entry.minilogin_ip) + "'");
insert_values.push_back(std::to_string(account_entry.hideme));
insert_values.push_back(std::to_string(account_entry.rulesflag));
insert_values.push_back("FROM_UNIXTIME(" + (account_entry.suspendeduntil > 0 ? std::to_string(account_entry.suspendeduntil) : "null") + ")");
insert_values.push_back(std::to_string(account_entry.time_creation));
insert_values.push_back("'" + Strings::Escape(account_entry.ban_reason) + "'");
insert_values.push_back("'" + Strings::Escape(account_entry.suspend_reason) + "'");
insert_values.push_back("'" + Strings::Escape(account_entry.crc_eqgame) + "'");
insert_values.push_back("'" + Strings::Escape(account_entry.crc_skillcaps) + "'");
insert_values.push_back("'" + Strings::Escape(account_entry.crc_basedata) + "'");
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back("'" + Strings::Escape(e.charname) + "'");
v.push_back(std::to_string(e.sharedplat));
v.push_back("'" + Strings::Escape(e.password) + "'");
v.push_back(std::to_string(e.status));
v.push_back("'" + Strings::Escape(e.ls_id) + "'");
v.push_back(std::to_string(e.lsaccount_id));
v.push_back(std::to_string(e.gmspeed));
v.push_back(std::to_string(e.invulnerable));
v.push_back(std::to_string(e.flymode));
v.push_back(std::to_string(e.ignore_tells));
v.push_back(std::to_string(e.revoked));
v.push_back(std::to_string(e.karma));
v.push_back("'" + Strings::Escape(e.minilogin_ip) + "'");
v.push_back(std::to_string(e.hideme));
v.push_back(std::to_string(e.rulesflag));
v.push_back("FROM_UNIXTIME(" + (e.suspendeduntil > 0 ? std::to_string(e.suspendeduntil) : "null") + ")");
v.push_back(std::to_string(e.time_creation));
v.push_back("'" + Strings::Escape(e.ban_reason) + "'");
v.push_back("'" + Strings::Escape(e.suspend_reason) + "'");
v.push_back("'" + Strings::Escape(e.crc_eqgame) + "'");
v.push_back("'" + Strings::Escape(e.crc_skillcaps) + "'");
v.push_back("'" + Strings::Escape(e.crc_basedata) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
account_entry.id = results.LastInsertedID();
return account_entry;
e.id = results.LastInsertedID();
return e;
}
account_entry = NewEntity();
e = NewEntity();
return account_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<Account> account_entries
const std::vector<Account> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &account_entry: account_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(account_entry.id));
insert_values.push_back("'" + Strings::Escape(account_entry.name) + "'");
insert_values.push_back("'" + Strings::Escape(account_entry.charname) + "'");
insert_values.push_back(std::to_string(account_entry.sharedplat));
insert_values.push_back("'" + Strings::Escape(account_entry.password) + "'");
insert_values.push_back(std::to_string(account_entry.status));
insert_values.push_back("'" + Strings::Escape(account_entry.ls_id) + "'");
insert_values.push_back(std::to_string(account_entry.lsaccount_id));
insert_values.push_back(std::to_string(account_entry.gmspeed));
insert_values.push_back(std::to_string(account_entry.invulnerable));
insert_values.push_back(std::to_string(account_entry.flymode));
insert_values.push_back(std::to_string(account_entry.ignore_tells));
insert_values.push_back(std::to_string(account_entry.revoked));
insert_values.push_back(std::to_string(account_entry.karma));
insert_values.push_back("'" + Strings::Escape(account_entry.minilogin_ip) + "'");
insert_values.push_back(std::to_string(account_entry.hideme));
insert_values.push_back(std::to_string(account_entry.rulesflag));
insert_values.push_back("FROM_UNIXTIME(" + (account_entry.suspendeduntil > 0 ? std::to_string(account_entry.suspendeduntil) : "null") + ")");
insert_values.push_back(std::to_string(account_entry.time_creation));
insert_values.push_back("'" + Strings::Escape(account_entry.ban_reason) + "'");
insert_values.push_back("'" + Strings::Escape(account_entry.suspend_reason) + "'");
insert_values.push_back("'" + Strings::Escape(account_entry.crc_eqgame) + "'");
insert_values.push_back("'" + Strings::Escape(account_entry.crc_skillcaps) + "'");
insert_values.push_back("'" + Strings::Escape(account_entry.crc_basedata) + "'");
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back("'" + Strings::Escape(e.charname) + "'");
v.push_back(std::to_string(e.sharedplat));
v.push_back("'" + Strings::Escape(e.password) + "'");
v.push_back(std::to_string(e.status));
v.push_back("'" + Strings::Escape(e.ls_id) + "'");
v.push_back(std::to_string(e.lsaccount_id));
v.push_back(std::to_string(e.gmspeed));
v.push_back(std::to_string(e.invulnerable));
v.push_back(std::to_string(e.flymode));
v.push_back(std::to_string(e.ignore_tells));
v.push_back(std::to_string(e.revoked));
v.push_back(std::to_string(e.karma));
v.push_back("'" + Strings::Escape(e.minilogin_ip) + "'");
v.push_back(std::to_string(e.hideme));
v.push_back(std::to_string(e.rulesflag));
v.push_back("FROM_UNIXTIME(" + (e.suspendeduntil > 0 ? std::to_string(e.suspendeduntil) : "null") + ")");
v.push_back(std::to_string(e.time_creation));
v.push_back("'" + Strings::Escape(e.ban_reason) + "'");
v.push_back("'" + Strings::Escape(e.suspend_reason) + "'");
v.push_back("'" + Strings::Escape(e.crc_eqgame) + "'");
v.push_back("'" + Strings::Escape(e.crc_skillcaps) + "'");
v.push_back("'" + Strings::Escape(e.crc_basedata) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -415,40 +415,40 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Account entry{};
Account e{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.charname = row[2] ? row[2] : "";
entry.sharedplat = atoi(row[3]);
entry.password = row[4] ? row[4] : "";
entry.status = atoi(row[5]);
entry.ls_id = row[6] ? row[6] : "";
entry.lsaccount_id = atoi(row[7]);
entry.gmspeed = atoi(row[8]);
entry.invulnerable = atoi(row[9]);
entry.flymode = atoi(row[10]);
entry.ignore_tells = atoi(row[11]);
entry.revoked = atoi(row[12]);
entry.karma = atoi(row[13]);
entry.minilogin_ip = row[14] ? row[14] : "";
entry.hideme = atoi(row[15]);
entry.rulesflag = atoi(row[16]);
entry.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
entry.time_creation = atoi(row[18]);
entry.ban_reason = row[19] ? row[19] : "";
entry.suspend_reason = row[20] ? row[20] : "";
entry.crc_eqgame = row[21] ? row[21] : "";
entry.crc_skillcaps = row[22] ? row[22] : "";
entry.crc_basedata = row[23] ? row[23] : "";
e.id = atoi(row[0]);
e.name = row[1] ? row[1] : "";
e.charname = row[2] ? row[2] : "";
e.sharedplat = atoi(row[3]);
e.password = row[4] ? row[4] : "";
e.status = atoi(row[5]);
e.ls_id = row[6] ? row[6] : "";
e.lsaccount_id = atoi(row[7]);
e.gmspeed = atoi(row[8]);
e.invulnerable = atoi(row[9]);
e.flymode = atoi(row[10]);
e.ignore_tells = atoi(row[11]);
e.revoked = atoi(row[12]);
e.karma = atoi(row[13]);
e.minilogin_ip = row[14] ? row[14] : "";
e.hideme = atoi(row[15]);
e.rulesflag = atoi(row[16]);
e.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
e.time_creation = atoi(row[18]);
e.ban_reason = row[19] ? row[19] : "";
e.suspend_reason = row[20] ? row[20] : "";
e.crc_eqgame = row[21] ? row[21] : "";
e.crc_skillcaps = row[22] ? row[22] : "";
e.crc_basedata = row[23] ? row[23] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<Account> GetWhere(Database& db, std::string where_filter)
static std::vector<Account> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<Account> all_entries;
@@ -463,40 +463,40 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Account entry{};
Account e{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.charname = row[2] ? row[2] : "";
entry.sharedplat = atoi(row[3]);
entry.password = row[4] ? row[4] : "";
entry.status = atoi(row[5]);
entry.ls_id = row[6] ? row[6] : "";
entry.lsaccount_id = atoi(row[7]);
entry.gmspeed = atoi(row[8]);
entry.invulnerable = atoi(row[9]);
entry.flymode = atoi(row[10]);
entry.ignore_tells = atoi(row[11]);
entry.revoked = atoi(row[12]);
entry.karma = atoi(row[13]);
entry.minilogin_ip = row[14] ? row[14] : "";
entry.hideme = atoi(row[15]);
entry.rulesflag = atoi(row[16]);
entry.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
entry.time_creation = atoi(row[18]);
entry.ban_reason = row[19] ? row[19] : "";
entry.suspend_reason = row[20] ? row[20] : "";
entry.crc_eqgame = row[21] ? row[21] : "";
entry.crc_skillcaps = row[22] ? row[22] : "";
entry.crc_basedata = row[23] ? row[23] : "";
e.id = atoi(row[0]);
e.name = row[1] ? row[1] : "";
e.charname = row[2] ? row[2] : "";
e.sharedplat = atoi(row[3]);
e.password = row[4] ? row[4] : "";
e.status = atoi(row[5]);
e.ls_id = row[6] ? row[6] : "";
e.lsaccount_id = atoi(row[7]);
e.gmspeed = atoi(row[8]);
e.invulnerable = atoi(row[9]);
e.flymode = atoi(row[10]);
e.ignore_tells = atoi(row[11]);
e.revoked = atoi(row[12]);
e.karma = atoi(row[13]);
e.minilogin_ip = row[14] ? row[14] : "";
e.hideme = atoi(row[15]);
e.rulesflag = atoi(row[16]);
e.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
e.time_creation = atoi(row[18]);
e.ban_reason = row[19] ? row[19] : "";
e.suspend_reason = row[20] ? row[20] : "";
e.crc_eqgame = row[21] ? row[21] : "";
e.crc_skillcaps = row[22] ? row[22] : "";
e.crc_basedata = row[23] ? row[23] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -521,6 +521,32 @@ public:
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_ACCOUNT_REPOSITORY_H
@@ -82,16 +82,16 @@ public:
static AccountRewards NewEntity()
{
AccountRewards entry{};
AccountRewards e{};
entry.account_id = 0;
entry.reward_id = 0;
entry.amount = 0;
e.account_id = 0;
e.reward_id = 0;
e.amount = 0;
return entry;
return e;
}
static AccountRewards GetAccountRewardsEntry(
static AccountRewards GetAccountRewards(
const std::vector<AccountRewards> &account_rewardss,
int account_rewards_id
)
@@ -120,13 +120,13 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
AccountRewards entry{};
AccountRewards e{};
entry.account_id = atoi(row[0]);
entry.reward_id = atoi(row[1]);
entry.amount = atoi(row[2]);
e.account_id = atoi(row[0]);
e.reward_id = atoi(row[1]);
e.amount = atoi(row[2]);
return entry;
return e;
}
return NewEntity();
@@ -151,24 +151,24 @@ public:
static int UpdateOne(
Database& db,
AccountRewards account_rewards_entry
const AccountRewards &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(account_rewards_entry.account_id));
update_values.push_back(columns[1] + " = " + std::to_string(account_rewards_entry.reward_id));
update_values.push_back(columns[2] + " = " + std::to_string(account_rewards_entry.amount));
v.push_back(columns[0] + " = " + std::to_string(e.account_id));
v.push_back(columns[1] + " = " + std::to_string(e.reward_id));
v.push_back(columns[2] + " = " + std::to_string(e.amount));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
account_rewards_entry.account_id
e.account_id
)
);
@@ -177,51 +177,51 @@ public:
static AccountRewards InsertOne(
Database& db,
AccountRewards account_rewards_entry
AccountRewards e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(account_rewards_entry.account_id));
insert_values.push_back(std::to_string(account_rewards_entry.reward_id));
insert_values.push_back(std::to_string(account_rewards_entry.amount));
v.push_back(std::to_string(e.account_id));
v.push_back(std::to_string(e.reward_id));
v.push_back(std::to_string(e.amount));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
account_rewards_entry.account_id = results.LastInsertedID();
return account_rewards_entry;
e.account_id = results.LastInsertedID();
return e;
}
account_rewards_entry = NewEntity();
e = NewEntity();
return account_rewards_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<AccountRewards> account_rewards_entries
const std::vector<AccountRewards> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &account_rewards_entry: account_rewards_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(account_rewards_entry.account_id));
insert_values.push_back(std::to_string(account_rewards_entry.reward_id));
insert_values.push_back(std::to_string(account_rewards_entry.amount));
v.push_back(std::to_string(e.account_id));
v.push_back(std::to_string(e.reward_id));
v.push_back(std::to_string(e.amount));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -248,19 +248,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AccountRewards entry{};
AccountRewards e{};
entry.account_id = atoi(row[0]);
entry.reward_id = atoi(row[1]);
entry.amount = atoi(row[2]);
e.account_id = atoi(row[0]);
e.reward_id = atoi(row[1]);
e.amount = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AccountRewards> GetWhere(Database& db, std::string where_filter)
static std::vector<AccountRewards> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AccountRewards> all_entries;
@@ -275,19 +275,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AccountRewards entry{};
AccountRewards e{};
entry.account_id = atoi(row[0]);
entry.reward_id = atoi(row[1]);
entry.amount = atoi(row[2]);
e.account_id = atoi(row[0]);
e.reward_id = atoi(row[1]);
e.amount = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -312,6 +312,32 @@ public:
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_ACCOUNT_REWARDS_REPOSITORY_H
@@ -100,22 +100,22 @@ public:
static AdventureDetails NewEntity()
{
AdventureDetails entry{};
AdventureDetails e{};
entry.id = 0;
entry.adventure_id = 0;
entry.instance_id = -1;
entry.count = 0;
entry.assassinate_count = 0;
entry.status = 0;
entry.time_created = 0;
entry.time_zoned = 0;
entry.time_completed = 0;
e.id = 0;
e.adventure_id = 0;
e.instance_id = -1;
e.count = 0;
e.assassinate_count = 0;
e.status = 0;
e.time_created = 0;
e.time_zoned = 0;
e.time_completed = 0;
return entry;
return e;
}
static AdventureDetails GetAdventureDetailsEntry(
static AdventureDetails GetAdventureDetails(
const std::vector<AdventureDetails> &adventure_detailss,
int adventure_details_id
)
@@ -144,19 +144,19 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
AdventureDetails entry{};
AdventureDetails e{};
entry.id = atoi(row[0]);
entry.adventure_id = atoi(row[1]);
entry.instance_id = atoi(row[2]);
entry.count = atoi(row[3]);
entry.assassinate_count = atoi(row[4]);
entry.status = atoi(row[5]);
entry.time_created = atoi(row[6]);
entry.time_zoned = atoi(row[7]);
entry.time_completed = atoi(row[8]);
e.id = atoi(row[0]);
e.adventure_id = atoi(row[1]);
e.instance_id = atoi(row[2]);
e.count = atoi(row[3]);
e.assassinate_count = atoi(row[4]);
e.status = atoi(row[5]);
e.time_created = atoi(row[6]);
e.time_zoned = atoi(row[7]);
e.time_completed = atoi(row[8]);
return entry;
return e;
}
return NewEntity();
@@ -181,29 +181,29 @@ public:
static int UpdateOne(
Database& db,
AdventureDetails adventure_details_entry
const AdventureDetails &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(adventure_details_entry.adventure_id));
update_values.push_back(columns[2] + " = " + std::to_string(adventure_details_entry.instance_id));
update_values.push_back(columns[3] + " = " + std::to_string(adventure_details_entry.count));
update_values.push_back(columns[4] + " = " + std::to_string(adventure_details_entry.assassinate_count));
update_values.push_back(columns[5] + " = " + std::to_string(adventure_details_entry.status));
update_values.push_back(columns[6] + " = " + std::to_string(adventure_details_entry.time_created));
update_values.push_back(columns[7] + " = " + std::to_string(adventure_details_entry.time_zoned));
update_values.push_back(columns[8] + " = " + std::to_string(adventure_details_entry.time_completed));
v.push_back(columns[1] + " = " + std::to_string(e.adventure_id));
v.push_back(columns[2] + " = " + std::to_string(e.instance_id));
v.push_back(columns[3] + " = " + std::to_string(e.count));
v.push_back(columns[4] + " = " + std::to_string(e.assassinate_count));
v.push_back(columns[5] + " = " + std::to_string(e.status));
v.push_back(columns[6] + " = " + std::to_string(e.time_created));
v.push_back(columns[7] + " = " + std::to_string(e.time_zoned));
v.push_back(columns[8] + " = " + std::to_string(e.time_completed));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
adventure_details_entry.id
e.id
)
);
@@ -212,63 +212,63 @@ public:
static AdventureDetails InsertOne(
Database& db,
AdventureDetails adventure_details_entry
AdventureDetails e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(adventure_details_entry.id));
insert_values.push_back(std::to_string(adventure_details_entry.adventure_id));
insert_values.push_back(std::to_string(adventure_details_entry.instance_id));
insert_values.push_back(std::to_string(adventure_details_entry.count));
insert_values.push_back(std::to_string(adventure_details_entry.assassinate_count));
insert_values.push_back(std::to_string(adventure_details_entry.status));
insert_values.push_back(std::to_string(adventure_details_entry.time_created));
insert_values.push_back(std::to_string(adventure_details_entry.time_zoned));
insert_values.push_back(std::to_string(adventure_details_entry.time_completed));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.adventure_id));
v.push_back(std::to_string(e.instance_id));
v.push_back(std::to_string(e.count));
v.push_back(std::to_string(e.assassinate_count));
v.push_back(std::to_string(e.status));
v.push_back(std::to_string(e.time_created));
v.push_back(std::to_string(e.time_zoned));
v.push_back(std::to_string(e.time_completed));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
adventure_details_entry.id = results.LastInsertedID();
return adventure_details_entry;
e.id = results.LastInsertedID();
return e;
}
adventure_details_entry = NewEntity();
e = NewEntity();
return adventure_details_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<AdventureDetails> adventure_details_entries
const std::vector<AdventureDetails> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &adventure_details_entry: adventure_details_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(adventure_details_entry.id));
insert_values.push_back(std::to_string(adventure_details_entry.adventure_id));
insert_values.push_back(std::to_string(adventure_details_entry.instance_id));
insert_values.push_back(std::to_string(adventure_details_entry.count));
insert_values.push_back(std::to_string(adventure_details_entry.assassinate_count));
insert_values.push_back(std::to_string(adventure_details_entry.status));
insert_values.push_back(std::to_string(adventure_details_entry.time_created));
insert_values.push_back(std::to_string(adventure_details_entry.time_zoned));
insert_values.push_back(std::to_string(adventure_details_entry.time_completed));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.adventure_id));
v.push_back(std::to_string(e.instance_id));
v.push_back(std::to_string(e.count));
v.push_back(std::to_string(e.assassinate_count));
v.push_back(std::to_string(e.status));
v.push_back(std::to_string(e.time_created));
v.push_back(std::to_string(e.time_zoned));
v.push_back(std::to_string(e.time_completed));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -295,25 +295,25 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureDetails entry{};
AdventureDetails e{};
entry.id = atoi(row[0]);
entry.adventure_id = atoi(row[1]);
entry.instance_id = atoi(row[2]);
entry.count = atoi(row[3]);
entry.assassinate_count = atoi(row[4]);
entry.status = atoi(row[5]);
entry.time_created = atoi(row[6]);
entry.time_zoned = atoi(row[7]);
entry.time_completed = atoi(row[8]);
e.id = atoi(row[0]);
e.adventure_id = atoi(row[1]);
e.instance_id = atoi(row[2]);
e.count = atoi(row[3]);
e.assassinate_count = atoi(row[4]);
e.status = atoi(row[5]);
e.time_created = atoi(row[6]);
e.time_zoned = atoi(row[7]);
e.time_completed = atoi(row[8]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AdventureDetails> GetWhere(Database& db, std::string where_filter)
static std::vector<AdventureDetails> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AdventureDetails> all_entries;
@@ -328,25 +328,25 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureDetails entry{};
AdventureDetails e{};
entry.id = atoi(row[0]);
entry.adventure_id = atoi(row[1]);
entry.instance_id = atoi(row[2]);
entry.count = atoi(row[3]);
entry.assassinate_count = atoi(row[4]);
entry.status = atoi(row[5]);
entry.time_created = atoi(row[6]);
entry.time_zoned = atoi(row[7]);
entry.time_completed = atoi(row[8]);
e.id = atoi(row[0]);
e.adventure_id = atoi(row[1]);
e.instance_id = atoi(row[2]);
e.count = atoi(row[3]);
e.assassinate_count = atoi(row[4]);
e.status = atoi(row[5]);
e.time_created = atoi(row[6]);
e.time_zoned = atoi(row[7]);
e.time_completed = atoi(row[8]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -371,6 +371,32 @@ public:
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_ADVENTURE_DETAILS_REPOSITORY_H
@@ -79,15 +79,15 @@ public:
static AdventureMembers NewEntity()
{
AdventureMembers entry{};
AdventureMembers e{};
entry.id = 0;
entry.charid = 0;
e.id = 0;
e.charid = 0;
return entry;
return e;
}
static AdventureMembers GetAdventureMembersEntry(
static AdventureMembers GetAdventureMembers(
const std::vector<AdventureMembers> &adventure_memberss,
int adventure_members_id
)
@@ -116,12 +116,12 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
AdventureMembers entry{};
AdventureMembers e{};
entry.id = atoi(row[0]);
entry.charid = atoi(row[1]);
e.id = atoi(row[0]);
e.charid = atoi(row[1]);
return entry;
return e;
}
return NewEntity();
@@ -146,23 +146,23 @@ public:
static int UpdateOne(
Database& db,
AdventureMembers adventure_members_entry
const AdventureMembers &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(adventure_members_entry.id));
update_values.push_back(columns[1] + " = " + std::to_string(adventure_members_entry.charid));
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = " + std::to_string(e.charid));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
adventure_members_entry.charid
e.charid
)
);
@@ -171,49 +171,49 @@ public:
static AdventureMembers InsertOne(
Database& db,
AdventureMembers adventure_members_entry
AdventureMembers e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(adventure_members_entry.id));
insert_values.push_back(std::to_string(adventure_members_entry.charid));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.charid));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
adventure_members_entry.charid = results.LastInsertedID();
return adventure_members_entry;
e.charid = results.LastInsertedID();
return e;
}
adventure_members_entry = NewEntity();
e = NewEntity();
return adventure_members_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<AdventureMembers> adventure_members_entries
const std::vector<AdventureMembers> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &adventure_members_entry: adventure_members_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(adventure_members_entry.id));
insert_values.push_back(std::to_string(adventure_members_entry.charid));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.charid));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -240,18 +240,18 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureMembers entry{};
AdventureMembers e{};
entry.id = atoi(row[0]);
entry.charid = atoi(row[1]);
e.id = atoi(row[0]);
e.charid = atoi(row[1]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AdventureMembers> GetWhere(Database& db, std::string where_filter)
static std::vector<AdventureMembers> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AdventureMembers> all_entries;
@@ -266,18 +266,18 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureMembers entry{};
AdventureMembers e{};
entry.id = atoi(row[0]);
entry.charid = atoi(row[1]);
e.id = atoi(row[0]);
e.charid = atoi(row[1]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -302,6 +302,32 @@ public:
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_ADVENTURE_MEMBERS_REPOSITORY_H
@@ -106,24 +106,24 @@ public:
static AdventureStats NewEntity()
{
AdventureStats entry{};
AdventureStats e{};
entry.player_id = 0;
entry.guk_wins = 0;
entry.mir_wins = 0;
entry.mmc_wins = 0;
entry.ruj_wins = 0;
entry.tak_wins = 0;
entry.guk_losses = 0;
entry.mir_losses = 0;
entry.mmc_losses = 0;
entry.ruj_losses = 0;
entry.tak_losses = 0;
e.player_id = 0;
e.guk_wins = 0;
e.mir_wins = 0;
e.mmc_wins = 0;
e.ruj_wins = 0;
e.tak_wins = 0;
e.guk_losses = 0;
e.mir_losses = 0;
e.mmc_losses = 0;
e.ruj_losses = 0;
e.tak_losses = 0;
return entry;
return e;
}
static AdventureStats GetAdventureStatsEntry(
static AdventureStats GetAdventureStats(
const std::vector<AdventureStats> &adventure_statss,
int adventure_stats_id
)
@@ -152,21 +152,21 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
AdventureStats entry{};
AdventureStats e{};
entry.player_id = atoi(row[0]);
entry.guk_wins = atoi(row[1]);
entry.mir_wins = atoi(row[2]);
entry.mmc_wins = atoi(row[3]);
entry.ruj_wins = atoi(row[4]);
entry.tak_wins = atoi(row[5]);
entry.guk_losses = atoi(row[6]);
entry.mir_losses = atoi(row[7]);
entry.mmc_losses = atoi(row[8]);
entry.ruj_losses = atoi(row[9]);
entry.tak_losses = atoi(row[10]);
e.player_id = atoi(row[0]);
e.guk_wins = atoi(row[1]);
e.mir_wins = atoi(row[2]);
e.mmc_wins = atoi(row[3]);
e.ruj_wins = atoi(row[4]);
e.tak_wins = atoi(row[5]);
e.guk_losses = atoi(row[6]);
e.mir_losses = atoi(row[7]);
e.mmc_losses = atoi(row[8]);
e.ruj_losses = atoi(row[9]);
e.tak_losses = atoi(row[10]);
return entry;
return e;
}
return NewEntity();
@@ -191,32 +191,32 @@ public:
static int UpdateOne(
Database& db,
AdventureStats adventure_stats_entry
const AdventureStats &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(adventure_stats_entry.player_id));
update_values.push_back(columns[1] + " = " + std::to_string(adventure_stats_entry.guk_wins));
update_values.push_back(columns[2] + " = " + std::to_string(adventure_stats_entry.mir_wins));
update_values.push_back(columns[3] + " = " + std::to_string(adventure_stats_entry.mmc_wins));
update_values.push_back(columns[4] + " = " + std::to_string(adventure_stats_entry.ruj_wins));
update_values.push_back(columns[5] + " = " + std::to_string(adventure_stats_entry.tak_wins));
update_values.push_back(columns[6] + " = " + std::to_string(adventure_stats_entry.guk_losses));
update_values.push_back(columns[7] + " = " + std::to_string(adventure_stats_entry.mir_losses));
update_values.push_back(columns[8] + " = " + std::to_string(adventure_stats_entry.mmc_losses));
update_values.push_back(columns[9] + " = " + std::to_string(adventure_stats_entry.ruj_losses));
update_values.push_back(columns[10] + " = " + std::to_string(adventure_stats_entry.tak_losses));
v.push_back(columns[0] + " = " + std::to_string(e.player_id));
v.push_back(columns[1] + " = " + std::to_string(e.guk_wins));
v.push_back(columns[2] + " = " + std::to_string(e.mir_wins));
v.push_back(columns[3] + " = " + std::to_string(e.mmc_wins));
v.push_back(columns[4] + " = " + std::to_string(e.ruj_wins));
v.push_back(columns[5] + " = " + std::to_string(e.tak_wins));
v.push_back(columns[6] + " = " + std::to_string(e.guk_losses));
v.push_back(columns[7] + " = " + std::to_string(e.mir_losses));
v.push_back(columns[8] + " = " + std::to_string(e.mmc_losses));
v.push_back(columns[9] + " = " + std::to_string(e.ruj_losses));
v.push_back(columns[10] + " = " + std::to_string(e.tak_losses));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
adventure_stats_entry.player_id
e.player_id
)
);
@@ -225,67 +225,67 @@ public:
static AdventureStats InsertOne(
Database& db,
AdventureStats adventure_stats_entry
AdventureStats e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(adventure_stats_entry.player_id));
insert_values.push_back(std::to_string(adventure_stats_entry.guk_wins));
insert_values.push_back(std::to_string(adventure_stats_entry.mir_wins));
insert_values.push_back(std::to_string(adventure_stats_entry.mmc_wins));
insert_values.push_back(std::to_string(adventure_stats_entry.ruj_wins));
insert_values.push_back(std::to_string(adventure_stats_entry.tak_wins));
insert_values.push_back(std::to_string(adventure_stats_entry.guk_losses));
insert_values.push_back(std::to_string(adventure_stats_entry.mir_losses));
insert_values.push_back(std::to_string(adventure_stats_entry.mmc_losses));
insert_values.push_back(std::to_string(adventure_stats_entry.ruj_losses));
insert_values.push_back(std::to_string(adventure_stats_entry.tak_losses));
v.push_back(std::to_string(e.player_id));
v.push_back(std::to_string(e.guk_wins));
v.push_back(std::to_string(e.mir_wins));
v.push_back(std::to_string(e.mmc_wins));
v.push_back(std::to_string(e.ruj_wins));
v.push_back(std::to_string(e.tak_wins));
v.push_back(std::to_string(e.guk_losses));
v.push_back(std::to_string(e.mir_losses));
v.push_back(std::to_string(e.mmc_losses));
v.push_back(std::to_string(e.ruj_losses));
v.push_back(std::to_string(e.tak_losses));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
adventure_stats_entry.player_id = results.LastInsertedID();
return adventure_stats_entry;
e.player_id = results.LastInsertedID();
return e;
}
adventure_stats_entry = NewEntity();
e = NewEntity();
return adventure_stats_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<AdventureStats> adventure_stats_entries
const std::vector<AdventureStats> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &adventure_stats_entry: adventure_stats_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(adventure_stats_entry.player_id));
insert_values.push_back(std::to_string(adventure_stats_entry.guk_wins));
insert_values.push_back(std::to_string(adventure_stats_entry.mir_wins));
insert_values.push_back(std::to_string(adventure_stats_entry.mmc_wins));
insert_values.push_back(std::to_string(adventure_stats_entry.ruj_wins));
insert_values.push_back(std::to_string(adventure_stats_entry.tak_wins));
insert_values.push_back(std::to_string(adventure_stats_entry.guk_losses));
insert_values.push_back(std::to_string(adventure_stats_entry.mir_losses));
insert_values.push_back(std::to_string(adventure_stats_entry.mmc_losses));
insert_values.push_back(std::to_string(adventure_stats_entry.ruj_losses));
insert_values.push_back(std::to_string(adventure_stats_entry.tak_losses));
v.push_back(std::to_string(e.player_id));
v.push_back(std::to_string(e.guk_wins));
v.push_back(std::to_string(e.mir_wins));
v.push_back(std::to_string(e.mmc_wins));
v.push_back(std::to_string(e.ruj_wins));
v.push_back(std::to_string(e.tak_wins));
v.push_back(std::to_string(e.guk_losses));
v.push_back(std::to_string(e.mir_losses));
v.push_back(std::to_string(e.mmc_losses));
v.push_back(std::to_string(e.ruj_losses));
v.push_back(std::to_string(e.tak_losses));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -312,27 +312,27 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureStats entry{};
AdventureStats e{};
entry.player_id = atoi(row[0]);
entry.guk_wins = atoi(row[1]);
entry.mir_wins = atoi(row[2]);
entry.mmc_wins = atoi(row[3]);
entry.ruj_wins = atoi(row[4]);
entry.tak_wins = atoi(row[5]);
entry.guk_losses = atoi(row[6]);
entry.mir_losses = atoi(row[7]);
entry.mmc_losses = atoi(row[8]);
entry.ruj_losses = atoi(row[9]);
entry.tak_losses = atoi(row[10]);
e.player_id = atoi(row[0]);
e.guk_wins = atoi(row[1]);
e.mir_wins = atoi(row[2]);
e.mmc_wins = atoi(row[3]);
e.ruj_wins = atoi(row[4]);
e.tak_wins = atoi(row[5]);
e.guk_losses = atoi(row[6]);
e.mir_losses = atoi(row[7]);
e.mmc_losses = atoi(row[8]);
e.ruj_losses = atoi(row[9]);
e.tak_losses = atoi(row[10]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AdventureStats> GetWhere(Database& db, std::string where_filter)
static std::vector<AdventureStats> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AdventureStats> all_entries;
@@ -347,27 +347,27 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureStats entry{};
AdventureStats e{};
entry.player_id = atoi(row[0]);
entry.guk_wins = atoi(row[1]);
entry.mir_wins = atoi(row[2]);
entry.mmc_wins = atoi(row[3]);
entry.ruj_wins = atoi(row[4]);
entry.tak_wins = atoi(row[5]);
entry.guk_losses = atoi(row[6]);
entry.mir_losses = atoi(row[7]);
entry.mmc_losses = atoi(row[8]);
entry.ruj_losses = atoi(row[9]);
entry.tak_losses = atoi(row[10]);
e.player_id = atoi(row[0]);
e.guk_wins = atoi(row[1]);
e.mir_wins = atoi(row[2]);
e.mmc_wins = atoi(row[3]);
e.ruj_wins = atoi(row[4]);
e.tak_wins = atoi(row[5]);
e.guk_losses = atoi(row[6]);
e.mir_losses = atoi(row[7]);
e.mmc_losses = atoi(row[8]);
e.ruj_losses = atoi(row[9]);
e.tak_losses = atoi(row[10]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -392,6 +392,32 @@ public:
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_ADVENTURE_STATS_REPOSITORY_H
@@ -79,15 +79,15 @@ public:
static AdventureTemplateEntryFlavor NewEntity()
{
AdventureTemplateEntryFlavor entry{};
AdventureTemplateEntryFlavor e{};
entry.id = 0;
entry.text = "";
e.id = 0;
e.text = "";
return entry;
return e;
}
static AdventureTemplateEntryFlavor GetAdventureTemplateEntryFlavorEntry(
static AdventureTemplateEntryFlavor GetAdventureTemplateEntryFlavor(
const std::vector<AdventureTemplateEntryFlavor> &adventure_template_entry_flavors,
int adventure_template_entry_flavor_id
)
@@ -116,12 +116,12 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
AdventureTemplateEntryFlavor entry{};
AdventureTemplateEntryFlavor e{};
entry.id = atoi(row[0]);
entry.text = row[1] ? row[1] : "";
e.id = atoi(row[0]);
e.text = row[1] ? row[1] : "";
return entry;
return e;
}
return NewEntity();
@@ -146,23 +146,23 @@ public:
static int UpdateOne(
Database& db,
AdventureTemplateEntryFlavor adventure_template_entry_flavor_entry
const AdventureTemplateEntryFlavor &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(adventure_template_entry_flavor_entry.id));
update_values.push_back(columns[1] + " = '" + Strings::Escape(adventure_template_entry_flavor_entry.text) + "'");
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = '" + Strings::Escape(e.text) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
adventure_template_entry_flavor_entry.id
e.id
)
);
@@ -171,49 +171,49 @@ public:
static AdventureTemplateEntryFlavor InsertOne(
Database& db,
AdventureTemplateEntryFlavor adventure_template_entry_flavor_entry
AdventureTemplateEntryFlavor e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(adventure_template_entry_flavor_entry.id));
insert_values.push_back("'" + Strings::Escape(adventure_template_entry_flavor_entry.text) + "'");
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.text) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
adventure_template_entry_flavor_entry.id = results.LastInsertedID();
return adventure_template_entry_flavor_entry;
e.id = results.LastInsertedID();
return e;
}
adventure_template_entry_flavor_entry = NewEntity();
e = NewEntity();
return adventure_template_entry_flavor_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<AdventureTemplateEntryFlavor> adventure_template_entry_flavor_entries
const std::vector<AdventureTemplateEntryFlavor> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &adventure_template_entry_flavor_entry: adventure_template_entry_flavor_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(adventure_template_entry_flavor_entry.id));
insert_values.push_back("'" + Strings::Escape(adventure_template_entry_flavor_entry.text) + "'");
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.text) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -240,18 +240,18 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureTemplateEntryFlavor entry{};
AdventureTemplateEntryFlavor e{};
entry.id = atoi(row[0]);
entry.text = row[1] ? row[1] : "";
e.id = atoi(row[0]);
e.text = row[1] ? row[1] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AdventureTemplateEntryFlavor> GetWhere(Database& db, std::string where_filter)
static std::vector<AdventureTemplateEntryFlavor> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AdventureTemplateEntryFlavor> all_entries;
@@ -266,18 +266,18 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureTemplateEntryFlavor entry{};
AdventureTemplateEntryFlavor e{};
entry.id = atoi(row[0]);
entry.text = row[1] ? row[1] : "";
e.id = atoi(row[0]);
e.text = row[1] ? row[1] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -302,6 +302,32 @@ public:
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_ADVENTURE_TEMPLATE_ENTRY_FLAVOR_REPOSITORY_H
@@ -79,15 +79,15 @@ public:
static AdventureTemplateEntry NewEntity()
{
AdventureTemplateEntry entry{};
AdventureTemplateEntry e{};
entry.id = 0;
entry.template_id = 0;
e.id = 0;
e.template_id = 0;
return entry;
return e;
}
static AdventureTemplateEntry GetAdventureTemplateEntryEntry(
static AdventureTemplateEntry GetAdventureTemplateEntry(
const std::vector<AdventureTemplateEntry> &adventure_template_entrys,
int adventure_template_entry_id
)
@@ -116,12 +116,12 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
AdventureTemplateEntry entry{};
AdventureTemplateEntry e{};
entry.id = atoi(row[0]);
entry.template_id = atoi(row[1]);
e.id = atoi(row[0]);
e.template_id = atoi(row[1]);
return entry;
return e;
}
return NewEntity();
@@ -146,23 +146,23 @@ public:
static int UpdateOne(
Database& db,
AdventureTemplateEntry adventure_template_entry_entry
const AdventureTemplateEntry &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(adventure_template_entry_entry.id));
update_values.push_back(columns[1] + " = " + std::to_string(adventure_template_entry_entry.template_id));
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = " + std::to_string(e.template_id));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
adventure_template_entry_entry.id
e.id
)
);
@@ -171,49 +171,49 @@ public:
static AdventureTemplateEntry InsertOne(
Database& db,
AdventureTemplateEntry adventure_template_entry_entry
AdventureTemplateEntry e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(adventure_template_entry_entry.id));
insert_values.push_back(std::to_string(adventure_template_entry_entry.template_id));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.template_id));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
adventure_template_entry_entry.id = results.LastInsertedID();
return adventure_template_entry_entry;
e.id = results.LastInsertedID();
return e;
}
adventure_template_entry_entry = NewEntity();
e = NewEntity();
return adventure_template_entry_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<AdventureTemplateEntry> adventure_template_entry_entries
const std::vector<AdventureTemplateEntry> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &adventure_template_entry_entry: adventure_template_entry_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(adventure_template_entry_entry.id));
insert_values.push_back(std::to_string(adventure_template_entry_entry.template_id));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.template_id));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -240,18 +240,18 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureTemplateEntry entry{};
AdventureTemplateEntry e{};
entry.id = atoi(row[0]);
entry.template_id = atoi(row[1]);
e.id = atoi(row[0]);
e.template_id = atoi(row[1]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AdventureTemplateEntry> GetWhere(Database& db, std::string where_filter)
static std::vector<AdventureTemplateEntry> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AdventureTemplateEntry> all_entries;
@@ -266,18 +266,18 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureTemplateEntry entry{};
AdventureTemplateEntry e{};
entry.id = atoi(row[0]);
entry.template_id = atoi(row[1]);
e.id = atoi(row[0]);
e.template_id = atoi(row[1]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -302,6 +302,32 @@ public:
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_ADVENTURE_TEMPLATE_ENTRY_REPOSITORY_H
@@ -172,46 +172,46 @@ public:
static AdventureTemplate NewEntity()
{
AdventureTemplate entry{};
AdventureTemplate e{};
entry.id = 0;
entry.zone = "";
entry.zone_version = 0;
entry.is_hard = 0;
entry.is_raid = 0;
entry.min_level = 1;
entry.max_level = 65;
entry.type = 0;
entry.type_data = 0;
entry.type_count = 0;
entry.assa_x = 0;
entry.assa_y = 0;
entry.assa_z = 0;
entry.assa_h = 0;
entry.text = "";
entry.duration = 7200;
entry.zone_in_time = 1800;
entry.win_points = 0;
entry.lose_points = 0;
entry.theme = 1;
entry.zone_in_zone_id = 0;
entry.zone_in_x = 0;
entry.zone_in_y = 0;
entry.zone_in_object_id = 0;
entry.dest_x = 0;
entry.dest_y = 0;
entry.dest_z = 0;
entry.dest_h = 0;
entry.graveyard_zone_id = 0;
entry.graveyard_x = 0;
entry.graveyard_y = 0;
entry.graveyard_z = 0;
entry.graveyard_radius = 0;
e.id = 0;
e.zone = "";
e.zone_version = 0;
e.is_hard = 0;
e.is_raid = 0;
e.min_level = 1;
e.max_level = 65;
e.type = 0;
e.type_data = 0;
e.type_count = 0;
e.assa_x = 0;
e.assa_y = 0;
e.assa_z = 0;
e.assa_h = 0;
e.text = "";
e.duration = 7200;
e.zone_in_time = 1800;
e.win_points = 0;
e.lose_points = 0;
e.theme = 1;
e.zone_in_zone_id = 0;
e.zone_in_x = 0;
e.zone_in_y = 0;
e.zone_in_object_id = 0;
e.dest_x = 0;
e.dest_y = 0;
e.dest_z = 0;
e.dest_h = 0;
e.graveyard_zone_id = 0;
e.graveyard_x = 0;
e.graveyard_y = 0;
e.graveyard_z = 0;
e.graveyard_radius = 0;
return entry;
return e;
}
static AdventureTemplate GetAdventureTemplateEntry(
static AdventureTemplate GetAdventureTemplate(
const std::vector<AdventureTemplate> &adventure_templates,
int adventure_template_id
)
@@ -240,43 +240,43 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
AdventureTemplate entry{};
AdventureTemplate e{};
entry.id = atoi(row[0]);
entry.zone = row[1] ? row[1] : "";
entry.zone_version = atoi(row[2]);
entry.is_hard = atoi(row[3]);
entry.is_raid = atoi(row[4]);
entry.min_level = atoi(row[5]);
entry.max_level = atoi(row[6]);
entry.type = atoi(row[7]);
entry.type_data = atoi(row[8]);
entry.type_count = atoi(row[9]);
entry.assa_x = static_cast<float>(atof(row[10]));
entry.assa_y = static_cast<float>(atof(row[11]));
entry.assa_z = static_cast<float>(atof(row[12]));
entry.assa_h = static_cast<float>(atof(row[13]));
entry.text = row[14] ? row[14] : "";
entry.duration = atoi(row[15]);
entry.zone_in_time = atoi(row[16]);
entry.win_points = atoi(row[17]);
entry.lose_points = atoi(row[18]);
entry.theme = atoi(row[19]);
entry.zone_in_zone_id = atoi(row[20]);
entry.zone_in_x = static_cast<float>(atof(row[21]));
entry.zone_in_y = static_cast<float>(atof(row[22]));
entry.zone_in_object_id = atoi(row[23]);
entry.dest_x = static_cast<float>(atof(row[24]));
entry.dest_y = static_cast<float>(atof(row[25]));
entry.dest_z = static_cast<float>(atof(row[26]));
entry.dest_h = static_cast<float>(atof(row[27]));
entry.graveyard_zone_id = atoi(row[28]);
entry.graveyard_x = static_cast<float>(atof(row[29]));
entry.graveyard_y = static_cast<float>(atof(row[30]));
entry.graveyard_z = static_cast<float>(atof(row[31]));
entry.graveyard_radius = static_cast<float>(atof(row[32]));
e.id = atoi(row[0]);
e.zone = row[1] ? row[1] : "";
e.zone_version = atoi(row[2]);
e.is_hard = atoi(row[3]);
e.is_raid = atoi(row[4]);
e.min_level = atoi(row[5]);
e.max_level = atoi(row[6]);
e.type = atoi(row[7]);
e.type_data = atoi(row[8]);
e.type_count = atoi(row[9]);
e.assa_x = static_cast<float>(atof(row[10]));
e.assa_y = static_cast<float>(atof(row[11]));
e.assa_z = static_cast<float>(atof(row[12]));
e.assa_h = static_cast<float>(atof(row[13]));
e.text = row[14] ? row[14] : "";
e.duration = atoi(row[15]);
e.zone_in_time = atoi(row[16]);
e.win_points = atoi(row[17]);
e.lose_points = atoi(row[18]);
e.theme = atoi(row[19]);
e.zone_in_zone_id = atoi(row[20]);
e.zone_in_x = static_cast<float>(atof(row[21]));
e.zone_in_y = static_cast<float>(atof(row[22]));
e.zone_in_object_id = atoi(row[23]);
e.dest_x = static_cast<float>(atof(row[24]));
e.dest_y = static_cast<float>(atof(row[25]));
e.dest_z = static_cast<float>(atof(row[26]));
e.dest_h = static_cast<float>(atof(row[27]));
e.graveyard_zone_id = atoi(row[28]);
e.graveyard_x = static_cast<float>(atof(row[29]));
e.graveyard_y = static_cast<float>(atof(row[30]));
e.graveyard_z = static_cast<float>(atof(row[31]));
e.graveyard_radius = static_cast<float>(atof(row[32]));
return entry;
return e;
}
return NewEntity();
@@ -301,54 +301,54 @@ public:
static int UpdateOne(
Database& db,
AdventureTemplate adventure_template_entry
const AdventureTemplate &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(adventure_template_entry.id));
update_values.push_back(columns[1] + " = '" + Strings::Escape(adventure_template_entry.zone) + "'");
update_values.push_back(columns[2] + " = " + std::to_string(adventure_template_entry.zone_version));
update_values.push_back(columns[3] + " = " + std::to_string(adventure_template_entry.is_hard));
update_values.push_back(columns[4] + " = " + std::to_string(adventure_template_entry.is_raid));
update_values.push_back(columns[5] + " = " + std::to_string(adventure_template_entry.min_level));
update_values.push_back(columns[6] + " = " + std::to_string(adventure_template_entry.max_level));
update_values.push_back(columns[7] + " = " + std::to_string(adventure_template_entry.type));
update_values.push_back(columns[8] + " = " + std::to_string(adventure_template_entry.type_data));
update_values.push_back(columns[9] + " = " + std::to_string(adventure_template_entry.type_count));
update_values.push_back(columns[10] + " = " + std::to_string(adventure_template_entry.assa_x));
update_values.push_back(columns[11] + " = " + std::to_string(adventure_template_entry.assa_y));
update_values.push_back(columns[12] + " = " + std::to_string(adventure_template_entry.assa_z));
update_values.push_back(columns[13] + " = " + std::to_string(adventure_template_entry.assa_h));
update_values.push_back(columns[14] + " = '" + Strings::Escape(adventure_template_entry.text) + "'");
update_values.push_back(columns[15] + " = " + std::to_string(adventure_template_entry.duration));
update_values.push_back(columns[16] + " = " + std::to_string(adventure_template_entry.zone_in_time));
update_values.push_back(columns[17] + " = " + std::to_string(adventure_template_entry.win_points));
update_values.push_back(columns[18] + " = " + std::to_string(adventure_template_entry.lose_points));
update_values.push_back(columns[19] + " = " + std::to_string(adventure_template_entry.theme));
update_values.push_back(columns[20] + " = " + std::to_string(adventure_template_entry.zone_in_zone_id));
update_values.push_back(columns[21] + " = " + std::to_string(adventure_template_entry.zone_in_x));
update_values.push_back(columns[22] + " = " + std::to_string(adventure_template_entry.zone_in_y));
update_values.push_back(columns[23] + " = " + std::to_string(adventure_template_entry.zone_in_object_id));
update_values.push_back(columns[24] + " = " + std::to_string(adventure_template_entry.dest_x));
update_values.push_back(columns[25] + " = " + std::to_string(adventure_template_entry.dest_y));
update_values.push_back(columns[26] + " = " + std::to_string(adventure_template_entry.dest_z));
update_values.push_back(columns[27] + " = " + std::to_string(adventure_template_entry.dest_h));
update_values.push_back(columns[28] + " = " + std::to_string(adventure_template_entry.graveyard_zone_id));
update_values.push_back(columns[29] + " = " + std::to_string(adventure_template_entry.graveyard_x));
update_values.push_back(columns[30] + " = " + std::to_string(adventure_template_entry.graveyard_y));
update_values.push_back(columns[31] + " = " + std::to_string(adventure_template_entry.graveyard_z));
update_values.push_back(columns[32] + " = " + std::to_string(adventure_template_entry.graveyard_radius));
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = '" + Strings::Escape(e.zone) + "'");
v.push_back(columns[2] + " = " + std::to_string(e.zone_version));
v.push_back(columns[3] + " = " + std::to_string(e.is_hard));
v.push_back(columns[4] + " = " + std::to_string(e.is_raid));
v.push_back(columns[5] + " = " + std::to_string(e.min_level));
v.push_back(columns[6] + " = " + std::to_string(e.max_level));
v.push_back(columns[7] + " = " + std::to_string(e.type));
v.push_back(columns[8] + " = " + std::to_string(e.type_data));
v.push_back(columns[9] + " = " + std::to_string(e.type_count));
v.push_back(columns[10] + " = " + std::to_string(e.assa_x));
v.push_back(columns[11] + " = " + std::to_string(e.assa_y));
v.push_back(columns[12] + " = " + std::to_string(e.assa_z));
v.push_back(columns[13] + " = " + std::to_string(e.assa_h));
v.push_back(columns[14] + " = '" + Strings::Escape(e.text) + "'");
v.push_back(columns[15] + " = " + std::to_string(e.duration));
v.push_back(columns[16] + " = " + std::to_string(e.zone_in_time));
v.push_back(columns[17] + " = " + std::to_string(e.win_points));
v.push_back(columns[18] + " = " + std::to_string(e.lose_points));
v.push_back(columns[19] + " = " + std::to_string(e.theme));
v.push_back(columns[20] + " = " + std::to_string(e.zone_in_zone_id));
v.push_back(columns[21] + " = " + std::to_string(e.zone_in_x));
v.push_back(columns[22] + " = " + std::to_string(e.zone_in_y));
v.push_back(columns[23] + " = " + std::to_string(e.zone_in_object_id));
v.push_back(columns[24] + " = " + std::to_string(e.dest_x));
v.push_back(columns[25] + " = " + std::to_string(e.dest_y));
v.push_back(columns[26] + " = " + std::to_string(e.dest_z));
v.push_back(columns[27] + " = " + std::to_string(e.dest_h));
v.push_back(columns[28] + " = " + std::to_string(e.graveyard_zone_id));
v.push_back(columns[29] + " = " + std::to_string(e.graveyard_x));
v.push_back(columns[30] + " = " + std::to_string(e.graveyard_y));
v.push_back(columns[31] + " = " + std::to_string(e.graveyard_z));
v.push_back(columns[32] + " = " + std::to_string(e.graveyard_radius));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
adventure_template_entry.id
e.id
)
);
@@ -357,111 +357,111 @@ public:
static AdventureTemplate InsertOne(
Database& db,
AdventureTemplate adventure_template_entry
AdventureTemplate e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(adventure_template_entry.id));
insert_values.push_back("'" + Strings::Escape(adventure_template_entry.zone) + "'");
insert_values.push_back(std::to_string(adventure_template_entry.zone_version));
insert_values.push_back(std::to_string(adventure_template_entry.is_hard));
insert_values.push_back(std::to_string(adventure_template_entry.is_raid));
insert_values.push_back(std::to_string(adventure_template_entry.min_level));
insert_values.push_back(std::to_string(adventure_template_entry.max_level));
insert_values.push_back(std::to_string(adventure_template_entry.type));
insert_values.push_back(std::to_string(adventure_template_entry.type_data));
insert_values.push_back(std::to_string(adventure_template_entry.type_count));
insert_values.push_back(std::to_string(adventure_template_entry.assa_x));
insert_values.push_back(std::to_string(adventure_template_entry.assa_y));
insert_values.push_back(std::to_string(adventure_template_entry.assa_z));
insert_values.push_back(std::to_string(adventure_template_entry.assa_h));
insert_values.push_back("'" + Strings::Escape(adventure_template_entry.text) + "'");
insert_values.push_back(std::to_string(adventure_template_entry.duration));
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_time));
insert_values.push_back(std::to_string(adventure_template_entry.win_points));
insert_values.push_back(std::to_string(adventure_template_entry.lose_points));
insert_values.push_back(std::to_string(adventure_template_entry.theme));
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_zone_id));
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_x));
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_y));
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_object_id));
insert_values.push_back(std::to_string(adventure_template_entry.dest_x));
insert_values.push_back(std::to_string(adventure_template_entry.dest_y));
insert_values.push_back(std::to_string(adventure_template_entry.dest_z));
insert_values.push_back(std::to_string(adventure_template_entry.dest_h));
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_zone_id));
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_x));
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_y));
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_z));
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_radius));
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.zone) + "'");
v.push_back(std::to_string(e.zone_version));
v.push_back(std::to_string(e.is_hard));
v.push_back(std::to_string(e.is_raid));
v.push_back(std::to_string(e.min_level));
v.push_back(std::to_string(e.max_level));
v.push_back(std::to_string(e.type));
v.push_back(std::to_string(e.type_data));
v.push_back(std::to_string(e.type_count));
v.push_back(std::to_string(e.assa_x));
v.push_back(std::to_string(e.assa_y));
v.push_back(std::to_string(e.assa_z));
v.push_back(std::to_string(e.assa_h));
v.push_back("'" + Strings::Escape(e.text) + "'");
v.push_back(std::to_string(e.duration));
v.push_back(std::to_string(e.zone_in_time));
v.push_back(std::to_string(e.win_points));
v.push_back(std::to_string(e.lose_points));
v.push_back(std::to_string(e.theme));
v.push_back(std::to_string(e.zone_in_zone_id));
v.push_back(std::to_string(e.zone_in_x));
v.push_back(std::to_string(e.zone_in_y));
v.push_back(std::to_string(e.zone_in_object_id));
v.push_back(std::to_string(e.dest_x));
v.push_back(std::to_string(e.dest_y));
v.push_back(std::to_string(e.dest_z));
v.push_back(std::to_string(e.dest_h));
v.push_back(std::to_string(e.graveyard_zone_id));
v.push_back(std::to_string(e.graveyard_x));
v.push_back(std::to_string(e.graveyard_y));
v.push_back(std::to_string(e.graveyard_z));
v.push_back(std::to_string(e.graveyard_radius));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
adventure_template_entry.id = results.LastInsertedID();
return adventure_template_entry;
e.id = results.LastInsertedID();
return e;
}
adventure_template_entry = NewEntity();
e = NewEntity();
return adventure_template_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<AdventureTemplate> adventure_template_entries
const std::vector<AdventureTemplate> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &adventure_template_entry: adventure_template_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(adventure_template_entry.id));
insert_values.push_back("'" + Strings::Escape(adventure_template_entry.zone) + "'");
insert_values.push_back(std::to_string(adventure_template_entry.zone_version));
insert_values.push_back(std::to_string(adventure_template_entry.is_hard));
insert_values.push_back(std::to_string(adventure_template_entry.is_raid));
insert_values.push_back(std::to_string(adventure_template_entry.min_level));
insert_values.push_back(std::to_string(adventure_template_entry.max_level));
insert_values.push_back(std::to_string(adventure_template_entry.type));
insert_values.push_back(std::to_string(adventure_template_entry.type_data));
insert_values.push_back(std::to_string(adventure_template_entry.type_count));
insert_values.push_back(std::to_string(adventure_template_entry.assa_x));
insert_values.push_back(std::to_string(adventure_template_entry.assa_y));
insert_values.push_back(std::to_string(adventure_template_entry.assa_z));
insert_values.push_back(std::to_string(adventure_template_entry.assa_h));
insert_values.push_back("'" + Strings::Escape(adventure_template_entry.text) + "'");
insert_values.push_back(std::to_string(adventure_template_entry.duration));
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_time));
insert_values.push_back(std::to_string(adventure_template_entry.win_points));
insert_values.push_back(std::to_string(adventure_template_entry.lose_points));
insert_values.push_back(std::to_string(adventure_template_entry.theme));
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_zone_id));
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_x));
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_y));
insert_values.push_back(std::to_string(adventure_template_entry.zone_in_object_id));
insert_values.push_back(std::to_string(adventure_template_entry.dest_x));
insert_values.push_back(std::to_string(adventure_template_entry.dest_y));
insert_values.push_back(std::to_string(adventure_template_entry.dest_z));
insert_values.push_back(std::to_string(adventure_template_entry.dest_h));
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_zone_id));
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_x));
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_y));
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_z));
insert_values.push_back(std::to_string(adventure_template_entry.graveyard_radius));
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.zone) + "'");
v.push_back(std::to_string(e.zone_version));
v.push_back(std::to_string(e.is_hard));
v.push_back(std::to_string(e.is_raid));
v.push_back(std::to_string(e.min_level));
v.push_back(std::to_string(e.max_level));
v.push_back(std::to_string(e.type));
v.push_back(std::to_string(e.type_data));
v.push_back(std::to_string(e.type_count));
v.push_back(std::to_string(e.assa_x));
v.push_back(std::to_string(e.assa_y));
v.push_back(std::to_string(e.assa_z));
v.push_back(std::to_string(e.assa_h));
v.push_back("'" + Strings::Escape(e.text) + "'");
v.push_back(std::to_string(e.duration));
v.push_back(std::to_string(e.zone_in_time));
v.push_back(std::to_string(e.win_points));
v.push_back(std::to_string(e.lose_points));
v.push_back(std::to_string(e.theme));
v.push_back(std::to_string(e.zone_in_zone_id));
v.push_back(std::to_string(e.zone_in_x));
v.push_back(std::to_string(e.zone_in_y));
v.push_back(std::to_string(e.zone_in_object_id));
v.push_back(std::to_string(e.dest_x));
v.push_back(std::to_string(e.dest_y));
v.push_back(std::to_string(e.dest_z));
v.push_back(std::to_string(e.dest_h));
v.push_back(std::to_string(e.graveyard_zone_id));
v.push_back(std::to_string(e.graveyard_x));
v.push_back(std::to_string(e.graveyard_y));
v.push_back(std::to_string(e.graveyard_z));
v.push_back(std::to_string(e.graveyard_radius));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -488,49 +488,49 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureTemplate entry{};
AdventureTemplate e{};
entry.id = atoi(row[0]);
entry.zone = row[1] ? row[1] : "";
entry.zone_version = atoi(row[2]);
entry.is_hard = atoi(row[3]);
entry.is_raid = atoi(row[4]);
entry.min_level = atoi(row[5]);
entry.max_level = atoi(row[6]);
entry.type = atoi(row[7]);
entry.type_data = atoi(row[8]);
entry.type_count = atoi(row[9]);
entry.assa_x = static_cast<float>(atof(row[10]));
entry.assa_y = static_cast<float>(atof(row[11]));
entry.assa_z = static_cast<float>(atof(row[12]));
entry.assa_h = static_cast<float>(atof(row[13]));
entry.text = row[14] ? row[14] : "";
entry.duration = atoi(row[15]);
entry.zone_in_time = atoi(row[16]);
entry.win_points = atoi(row[17]);
entry.lose_points = atoi(row[18]);
entry.theme = atoi(row[19]);
entry.zone_in_zone_id = atoi(row[20]);
entry.zone_in_x = static_cast<float>(atof(row[21]));
entry.zone_in_y = static_cast<float>(atof(row[22]));
entry.zone_in_object_id = atoi(row[23]);
entry.dest_x = static_cast<float>(atof(row[24]));
entry.dest_y = static_cast<float>(atof(row[25]));
entry.dest_z = static_cast<float>(atof(row[26]));
entry.dest_h = static_cast<float>(atof(row[27]));
entry.graveyard_zone_id = atoi(row[28]);
entry.graveyard_x = static_cast<float>(atof(row[29]));
entry.graveyard_y = static_cast<float>(atof(row[30]));
entry.graveyard_z = static_cast<float>(atof(row[31]));
entry.graveyard_radius = static_cast<float>(atof(row[32]));
e.id = atoi(row[0]);
e.zone = row[1] ? row[1] : "";
e.zone_version = atoi(row[2]);
e.is_hard = atoi(row[3]);
e.is_raid = atoi(row[4]);
e.min_level = atoi(row[5]);
e.max_level = atoi(row[6]);
e.type = atoi(row[7]);
e.type_data = atoi(row[8]);
e.type_count = atoi(row[9]);
e.assa_x = static_cast<float>(atof(row[10]));
e.assa_y = static_cast<float>(atof(row[11]));
e.assa_z = static_cast<float>(atof(row[12]));
e.assa_h = static_cast<float>(atof(row[13]));
e.text = row[14] ? row[14] : "";
e.duration = atoi(row[15]);
e.zone_in_time = atoi(row[16]);
e.win_points = atoi(row[17]);
e.lose_points = atoi(row[18]);
e.theme = atoi(row[19]);
e.zone_in_zone_id = atoi(row[20]);
e.zone_in_x = static_cast<float>(atof(row[21]));
e.zone_in_y = static_cast<float>(atof(row[22]));
e.zone_in_object_id = atoi(row[23]);
e.dest_x = static_cast<float>(atof(row[24]));
e.dest_y = static_cast<float>(atof(row[25]));
e.dest_z = static_cast<float>(atof(row[26]));
e.dest_h = static_cast<float>(atof(row[27]));
e.graveyard_zone_id = atoi(row[28]);
e.graveyard_x = static_cast<float>(atof(row[29]));
e.graveyard_y = static_cast<float>(atof(row[30]));
e.graveyard_z = static_cast<float>(atof(row[31]));
e.graveyard_radius = static_cast<float>(atof(row[32]));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AdventureTemplate> GetWhere(Database& db, std::string where_filter)
static std::vector<AdventureTemplate> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AdventureTemplate> all_entries;
@@ -545,49 +545,49 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AdventureTemplate entry{};
AdventureTemplate e{};
entry.id = atoi(row[0]);
entry.zone = row[1] ? row[1] : "";
entry.zone_version = atoi(row[2]);
entry.is_hard = atoi(row[3]);
entry.is_raid = atoi(row[4]);
entry.min_level = atoi(row[5]);
entry.max_level = atoi(row[6]);
entry.type = atoi(row[7]);
entry.type_data = atoi(row[8]);
entry.type_count = atoi(row[9]);
entry.assa_x = static_cast<float>(atof(row[10]));
entry.assa_y = static_cast<float>(atof(row[11]));
entry.assa_z = static_cast<float>(atof(row[12]));
entry.assa_h = static_cast<float>(atof(row[13]));
entry.text = row[14] ? row[14] : "";
entry.duration = atoi(row[15]);
entry.zone_in_time = atoi(row[16]);
entry.win_points = atoi(row[17]);
entry.lose_points = atoi(row[18]);
entry.theme = atoi(row[19]);
entry.zone_in_zone_id = atoi(row[20]);
entry.zone_in_x = static_cast<float>(atof(row[21]));
entry.zone_in_y = static_cast<float>(atof(row[22]));
entry.zone_in_object_id = atoi(row[23]);
entry.dest_x = static_cast<float>(atof(row[24]));
entry.dest_y = static_cast<float>(atof(row[25]));
entry.dest_z = static_cast<float>(atof(row[26]));
entry.dest_h = static_cast<float>(atof(row[27]));
entry.graveyard_zone_id = atoi(row[28]);
entry.graveyard_x = static_cast<float>(atof(row[29]));
entry.graveyard_y = static_cast<float>(atof(row[30]));
entry.graveyard_z = static_cast<float>(atof(row[31]));
entry.graveyard_radius = static_cast<float>(atof(row[32]));
e.id = atoi(row[0]);
e.zone = row[1] ? row[1] : "";
e.zone_version = atoi(row[2]);
e.is_hard = atoi(row[3]);
e.is_raid = atoi(row[4]);
e.min_level = atoi(row[5]);
e.max_level = atoi(row[6]);
e.type = atoi(row[7]);
e.type_data = atoi(row[8]);
e.type_count = atoi(row[9]);
e.assa_x = static_cast<float>(atof(row[10]));
e.assa_y = static_cast<float>(atof(row[11]));
e.assa_z = static_cast<float>(atof(row[12]));
e.assa_h = static_cast<float>(atof(row[13]));
e.text = row[14] ? row[14] : "";
e.duration = atoi(row[15]);
e.zone_in_time = atoi(row[16]);
e.win_points = atoi(row[17]);
e.lose_points = atoi(row[18]);
e.theme = atoi(row[19]);
e.zone_in_zone_id = atoi(row[20]);
e.zone_in_x = static_cast<float>(atof(row[21]));
e.zone_in_y = static_cast<float>(atof(row[22]));
e.zone_in_object_id = atoi(row[23]);
e.dest_x = static_cast<float>(atof(row[24]));
e.dest_y = static_cast<float>(atof(row[25]));
e.dest_z = static_cast<float>(atof(row[26]));
e.dest_h = static_cast<float>(atof(row[27]));
e.graveyard_zone_id = atoi(row[28]);
e.graveyard_x = static_cast<float>(atof(row[29]));
e.graveyard_y = static_cast<float>(atof(row[30]));
e.graveyard_z = static_cast<float>(atof(row[31]));
e.graveyard_radius = static_cast<float>(atof(row[32]));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -612,6 +612,32 @@ public:
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_ADVENTURE_TEMPLATE_REPOSITORY_H
@@ -79,15 +79,15 @@ public:
static AlternateCurrency NewEntity()
{
AlternateCurrency entry{};
AlternateCurrency e{};
entry.id = 0;
entry.item_id = 0;
e.id = 0;
e.item_id = 0;
return entry;
return e;
}
static AlternateCurrency GetAlternateCurrencyEntry(
static AlternateCurrency GetAlternateCurrency(
const std::vector<AlternateCurrency> &alternate_currencys,
int alternate_currency_id
)
@@ -116,12 +116,12 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
AlternateCurrency entry{};
AlternateCurrency e{};
entry.id = atoi(row[0]);
entry.item_id = atoi(row[1]);
e.id = atoi(row[0]);
e.item_id = atoi(row[1]);
return entry;
return e;
}
return NewEntity();
@@ -146,23 +146,23 @@ public:
static int UpdateOne(
Database& db,
AlternateCurrency alternate_currency_entry
const AlternateCurrency &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(alternate_currency_entry.id));
update_values.push_back(columns[1] + " = " + std::to_string(alternate_currency_entry.item_id));
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = " + std::to_string(e.item_id));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
alternate_currency_entry.id
e.id
)
);
@@ -171,49 +171,49 @@ public:
static AlternateCurrency InsertOne(
Database& db,
AlternateCurrency alternate_currency_entry
AlternateCurrency e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(alternate_currency_entry.id));
insert_values.push_back(std::to_string(alternate_currency_entry.item_id));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.item_id));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
alternate_currency_entry.id = results.LastInsertedID();
return alternate_currency_entry;
e.id = results.LastInsertedID();
return e;
}
alternate_currency_entry = NewEntity();
e = NewEntity();
return alternate_currency_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<AlternateCurrency> alternate_currency_entries
const std::vector<AlternateCurrency> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &alternate_currency_entry: alternate_currency_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(alternate_currency_entry.id));
insert_values.push_back(std::to_string(alternate_currency_entry.item_id));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.item_id));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -240,18 +240,18 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AlternateCurrency entry{};
AlternateCurrency e{};
entry.id = atoi(row[0]);
entry.item_id = atoi(row[1]);
e.id = atoi(row[0]);
e.item_id = atoi(row[1]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AlternateCurrency> GetWhere(Database& db, std::string where_filter)
static std::vector<AlternateCurrency> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AlternateCurrency> all_entries;
@@ -266,18 +266,18 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
AlternateCurrency entry{};
AlternateCurrency e{};
entry.id = atoi(row[0]);
entry.item_id = atoi(row[1]);
e.id = atoi(row[0]);
e.item_id = atoi(row[1]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -302,6 +302,32 @@ public:
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_ALTERNATE_CURRENCY_REPOSITORY_H
+130 -104
View File
@@ -106,24 +106,24 @@ public:
static Auras NewEntity()
{
Auras entry{};
Auras e{};
entry.type = 0;
entry.npc_type = 0;
entry.name = "";
entry.spell_id = 0;
entry.distance = 60;
entry.aura_type = 1;
entry.spawn_type = 0;
entry.movement = 0;
entry.duration = 5400;
entry.icon = -1;
entry.cast_time = 0;
e.type = 0;
e.npc_type = 0;
e.name = "";
e.spell_id = 0;
e.distance = 60;
e.aura_type = 1;
e.spawn_type = 0;
e.movement = 0;
e.duration = 5400;
e.icon = -1;
e.cast_time = 0;
return entry;
return e;
}
static Auras GetAurasEntry(
static Auras GetAuras(
const std::vector<Auras> &aurass,
int auras_id
)
@@ -152,21 +152,21 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
Auras entry{};
Auras e{};
entry.type = atoi(row[0]);
entry.npc_type = atoi(row[1]);
entry.name = row[2] ? row[2] : "";
entry.spell_id = atoi(row[3]);
entry.distance = atoi(row[4]);
entry.aura_type = atoi(row[5]);
entry.spawn_type = atoi(row[6]);
entry.movement = atoi(row[7]);
entry.duration = atoi(row[8]);
entry.icon = atoi(row[9]);
entry.cast_time = atoi(row[10]);
e.type = atoi(row[0]);
e.npc_type = atoi(row[1]);
e.name = row[2] ? row[2] : "";
e.spell_id = atoi(row[3]);
e.distance = atoi(row[4]);
e.aura_type = atoi(row[5]);
e.spawn_type = atoi(row[6]);
e.movement = atoi(row[7]);
e.duration = atoi(row[8]);
e.icon = atoi(row[9]);
e.cast_time = atoi(row[10]);
return entry;
return e;
}
return NewEntity();
@@ -191,32 +191,32 @@ public:
static int UpdateOne(
Database& db,
Auras auras_entry
const Auras &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(auras_entry.type));
update_values.push_back(columns[1] + " = " + std::to_string(auras_entry.npc_type));
update_values.push_back(columns[2] + " = '" + Strings::Escape(auras_entry.name) + "'");
update_values.push_back(columns[3] + " = " + std::to_string(auras_entry.spell_id));
update_values.push_back(columns[4] + " = " + std::to_string(auras_entry.distance));
update_values.push_back(columns[5] + " = " + std::to_string(auras_entry.aura_type));
update_values.push_back(columns[6] + " = " + std::to_string(auras_entry.spawn_type));
update_values.push_back(columns[7] + " = " + std::to_string(auras_entry.movement));
update_values.push_back(columns[8] + " = " + std::to_string(auras_entry.duration));
update_values.push_back(columns[9] + " = " + std::to_string(auras_entry.icon));
update_values.push_back(columns[10] + " = " + std::to_string(auras_entry.cast_time));
v.push_back(columns[0] + " = " + std::to_string(e.type));
v.push_back(columns[1] + " = " + std::to_string(e.npc_type));
v.push_back(columns[2] + " = '" + Strings::Escape(e.name) + "'");
v.push_back(columns[3] + " = " + std::to_string(e.spell_id));
v.push_back(columns[4] + " = " + std::to_string(e.distance));
v.push_back(columns[5] + " = " + std::to_string(e.aura_type));
v.push_back(columns[6] + " = " + std::to_string(e.spawn_type));
v.push_back(columns[7] + " = " + std::to_string(e.movement));
v.push_back(columns[8] + " = " + std::to_string(e.duration));
v.push_back(columns[9] + " = " + std::to_string(e.icon));
v.push_back(columns[10] + " = " + std::to_string(e.cast_time));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
auras_entry.type
e.type
)
);
@@ -225,67 +225,67 @@ public:
static Auras InsertOne(
Database& db,
Auras auras_entry
Auras e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(auras_entry.type));
insert_values.push_back(std::to_string(auras_entry.npc_type));
insert_values.push_back("'" + Strings::Escape(auras_entry.name) + "'");
insert_values.push_back(std::to_string(auras_entry.spell_id));
insert_values.push_back(std::to_string(auras_entry.distance));
insert_values.push_back(std::to_string(auras_entry.aura_type));
insert_values.push_back(std::to_string(auras_entry.spawn_type));
insert_values.push_back(std::to_string(auras_entry.movement));
insert_values.push_back(std::to_string(auras_entry.duration));
insert_values.push_back(std::to_string(auras_entry.icon));
insert_values.push_back(std::to_string(auras_entry.cast_time));
v.push_back(std::to_string(e.type));
v.push_back(std::to_string(e.npc_type));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.distance));
v.push_back(std::to_string(e.aura_type));
v.push_back(std::to_string(e.spawn_type));
v.push_back(std::to_string(e.movement));
v.push_back(std::to_string(e.duration));
v.push_back(std::to_string(e.icon));
v.push_back(std::to_string(e.cast_time));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
auras_entry.type = results.LastInsertedID();
return auras_entry;
e.type = results.LastInsertedID();
return e;
}
auras_entry = NewEntity();
e = NewEntity();
return auras_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<Auras> auras_entries
const std::vector<Auras> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &auras_entry: auras_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(auras_entry.type));
insert_values.push_back(std::to_string(auras_entry.npc_type));
insert_values.push_back("'" + Strings::Escape(auras_entry.name) + "'");
insert_values.push_back(std::to_string(auras_entry.spell_id));
insert_values.push_back(std::to_string(auras_entry.distance));
insert_values.push_back(std::to_string(auras_entry.aura_type));
insert_values.push_back(std::to_string(auras_entry.spawn_type));
insert_values.push_back(std::to_string(auras_entry.movement));
insert_values.push_back(std::to_string(auras_entry.duration));
insert_values.push_back(std::to_string(auras_entry.icon));
insert_values.push_back(std::to_string(auras_entry.cast_time));
v.push_back(std::to_string(e.type));
v.push_back(std::to_string(e.npc_type));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.distance));
v.push_back(std::to_string(e.aura_type));
v.push_back(std::to_string(e.spawn_type));
v.push_back(std::to_string(e.movement));
v.push_back(std::to_string(e.duration));
v.push_back(std::to_string(e.icon));
v.push_back(std::to_string(e.cast_time));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -312,27 +312,27 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Auras entry{};
Auras e{};
entry.type = atoi(row[0]);
entry.npc_type = atoi(row[1]);
entry.name = row[2] ? row[2] : "";
entry.spell_id = atoi(row[3]);
entry.distance = atoi(row[4]);
entry.aura_type = atoi(row[5]);
entry.spawn_type = atoi(row[6]);
entry.movement = atoi(row[7]);
entry.duration = atoi(row[8]);
entry.icon = atoi(row[9]);
entry.cast_time = atoi(row[10]);
e.type = atoi(row[0]);
e.npc_type = atoi(row[1]);
e.name = row[2] ? row[2] : "";
e.spell_id = atoi(row[3]);
e.distance = atoi(row[4]);
e.aura_type = atoi(row[5]);
e.spawn_type = atoi(row[6]);
e.movement = atoi(row[7]);
e.duration = atoi(row[8]);
e.icon = atoi(row[9]);
e.cast_time = atoi(row[10]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<Auras> GetWhere(Database& db, std::string where_filter)
static std::vector<Auras> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<Auras> all_entries;
@@ -347,27 +347,27 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Auras entry{};
Auras e{};
entry.type = atoi(row[0]);
entry.npc_type = atoi(row[1]);
entry.name = row[2] ? row[2] : "";
entry.spell_id = atoi(row[3]);
entry.distance = atoi(row[4]);
entry.aura_type = atoi(row[5]);
entry.spawn_type = atoi(row[6]);
entry.movement = atoi(row[7]);
entry.duration = atoi(row[8]);
entry.icon = atoi(row[9]);
entry.cast_time = atoi(row[10]);
e.type = atoi(row[0]);
e.npc_type = atoi(row[1]);
e.name = row[2] ? row[2] : "";
e.spell_id = atoi(row[3]);
e.distance = atoi(row[4]);
e.aura_type = atoi(row[5]);
e.spawn_type = atoi(row[6]);
e.movement = atoi(row[7]);
e.duration = atoi(row[8]);
e.icon = atoi(row[9]);
e.cast_time = atoi(row[10]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -392,6 +392,32 @@ public:
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_AURAS_REPOSITORY_H
@@ -103,23 +103,23 @@ public:
static BaseData NewEntity()
{
BaseData entry{};
BaseData e{};
entry.level = 0;
entry.class_ = 0;
entry.hp = 0;
entry.mana = 0;
entry.end = 0;
entry.unk1 = 0;
entry.unk2 = 0;
entry.hp_fac = 0;
entry.mana_fac = 0;
entry.end_fac = 0;
e.level = 0;
e.class_ = 0;
e.hp = 0;
e.mana = 0;
e.end = 0;
e.unk1 = 0;
e.unk2 = 0;
e.hp_fac = 0;
e.mana_fac = 0;
e.end_fac = 0;
return entry;
return e;
}
static BaseData GetBaseDataEntry(
static BaseData GetBaseData(
const std::vector<BaseData> &base_datas,
int base_data_id
)
@@ -148,20 +148,20 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
BaseData entry{};
BaseData e{};
entry.level = atoi(row[0]);
entry.class_ = atoi(row[1]);
entry.hp = static_cast<float>(atof(row[2]));
entry.mana = static_cast<float>(atof(row[3]));
entry.end = static_cast<float>(atof(row[4]));
entry.unk1 = static_cast<float>(atof(row[5]));
entry.unk2 = static_cast<float>(atof(row[6]));
entry.hp_fac = static_cast<float>(atof(row[7]));
entry.mana_fac = static_cast<float>(atof(row[8]));
entry.end_fac = static_cast<float>(atof(row[9]));
e.level = atoi(row[0]);
e.class_ = atoi(row[1]);
e.hp = static_cast<float>(atof(row[2]));
e.mana = static_cast<float>(atof(row[3]));
e.end = static_cast<float>(atof(row[4]));
e.unk1 = static_cast<float>(atof(row[5]));
e.unk2 = static_cast<float>(atof(row[6]));
e.hp_fac = static_cast<float>(atof(row[7]));
e.mana_fac = static_cast<float>(atof(row[8]));
e.end_fac = static_cast<float>(atof(row[9]));
return entry;
return e;
}
return NewEntity();
@@ -186,31 +186,31 @@ public:
static int UpdateOne(
Database& db,
BaseData base_data_entry
const BaseData &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(base_data_entry.level));
update_values.push_back(columns[1] + " = " + std::to_string(base_data_entry.class_));
update_values.push_back(columns[2] + " = " + std::to_string(base_data_entry.hp));
update_values.push_back(columns[3] + " = " + std::to_string(base_data_entry.mana));
update_values.push_back(columns[4] + " = " + std::to_string(base_data_entry.end));
update_values.push_back(columns[5] + " = " + std::to_string(base_data_entry.unk1));
update_values.push_back(columns[6] + " = " + std::to_string(base_data_entry.unk2));
update_values.push_back(columns[7] + " = " + std::to_string(base_data_entry.hp_fac));
update_values.push_back(columns[8] + " = " + std::to_string(base_data_entry.mana_fac));
update_values.push_back(columns[9] + " = " + std::to_string(base_data_entry.end_fac));
v.push_back(columns[0] + " = " + std::to_string(e.level));
v.push_back(columns[1] + " = " + std::to_string(e.class_));
v.push_back(columns[2] + " = " + std::to_string(e.hp));
v.push_back(columns[3] + " = " + std::to_string(e.mana));
v.push_back(columns[4] + " = " + std::to_string(e.end));
v.push_back(columns[5] + " = " + std::to_string(e.unk1));
v.push_back(columns[6] + " = " + std::to_string(e.unk2));
v.push_back(columns[7] + " = " + std::to_string(e.hp_fac));
v.push_back(columns[8] + " = " + std::to_string(e.mana_fac));
v.push_back(columns[9] + " = " + std::to_string(e.end_fac));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
base_data_entry.level
e.level
)
);
@@ -219,65 +219,65 @@ public:
static BaseData InsertOne(
Database& db,
BaseData base_data_entry
BaseData e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(base_data_entry.level));
insert_values.push_back(std::to_string(base_data_entry.class_));
insert_values.push_back(std::to_string(base_data_entry.hp));
insert_values.push_back(std::to_string(base_data_entry.mana));
insert_values.push_back(std::to_string(base_data_entry.end));
insert_values.push_back(std::to_string(base_data_entry.unk1));
insert_values.push_back(std::to_string(base_data_entry.unk2));
insert_values.push_back(std::to_string(base_data_entry.hp_fac));
insert_values.push_back(std::to_string(base_data_entry.mana_fac));
insert_values.push_back(std::to_string(base_data_entry.end_fac));
v.push_back(std::to_string(e.level));
v.push_back(std::to_string(e.class_));
v.push_back(std::to_string(e.hp));
v.push_back(std::to_string(e.mana));
v.push_back(std::to_string(e.end));
v.push_back(std::to_string(e.unk1));
v.push_back(std::to_string(e.unk2));
v.push_back(std::to_string(e.hp_fac));
v.push_back(std::to_string(e.mana_fac));
v.push_back(std::to_string(e.end_fac));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
base_data_entry.level = results.LastInsertedID();
return base_data_entry;
e.level = results.LastInsertedID();
return e;
}
base_data_entry = NewEntity();
e = NewEntity();
return base_data_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<BaseData> base_data_entries
const std::vector<BaseData> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &base_data_entry: base_data_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(base_data_entry.level));
insert_values.push_back(std::to_string(base_data_entry.class_));
insert_values.push_back(std::to_string(base_data_entry.hp));
insert_values.push_back(std::to_string(base_data_entry.mana));
insert_values.push_back(std::to_string(base_data_entry.end));
insert_values.push_back(std::to_string(base_data_entry.unk1));
insert_values.push_back(std::to_string(base_data_entry.unk2));
insert_values.push_back(std::to_string(base_data_entry.hp_fac));
insert_values.push_back(std::to_string(base_data_entry.mana_fac));
insert_values.push_back(std::to_string(base_data_entry.end_fac));
v.push_back(std::to_string(e.level));
v.push_back(std::to_string(e.class_));
v.push_back(std::to_string(e.hp));
v.push_back(std::to_string(e.mana));
v.push_back(std::to_string(e.end));
v.push_back(std::to_string(e.unk1));
v.push_back(std::to_string(e.unk2));
v.push_back(std::to_string(e.hp_fac));
v.push_back(std::to_string(e.mana_fac));
v.push_back(std::to_string(e.end_fac));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -304,26 +304,26 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
BaseData entry{};
BaseData e{};
entry.level = atoi(row[0]);
entry.class_ = atoi(row[1]);
entry.hp = static_cast<float>(atof(row[2]));
entry.mana = static_cast<float>(atof(row[3]));
entry.end = static_cast<float>(atof(row[4]));
entry.unk1 = static_cast<float>(atof(row[5]));
entry.unk2 = static_cast<float>(atof(row[6]));
entry.hp_fac = static_cast<float>(atof(row[7]));
entry.mana_fac = static_cast<float>(atof(row[8]));
entry.end_fac = static_cast<float>(atof(row[9]));
e.level = atoi(row[0]);
e.class_ = atoi(row[1]);
e.hp = static_cast<float>(atof(row[2]));
e.mana = static_cast<float>(atof(row[3]));
e.end = static_cast<float>(atof(row[4]));
e.unk1 = static_cast<float>(atof(row[5]));
e.unk2 = static_cast<float>(atof(row[6]));
e.hp_fac = static_cast<float>(atof(row[7]));
e.mana_fac = static_cast<float>(atof(row[8]));
e.end_fac = static_cast<float>(atof(row[9]));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<BaseData> GetWhere(Database& db, std::string where_filter)
static std::vector<BaseData> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<BaseData> all_entries;
@@ -338,26 +338,26 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
BaseData entry{};
BaseData e{};
entry.level = atoi(row[0]);
entry.class_ = atoi(row[1]);
entry.hp = static_cast<float>(atof(row[2]));
entry.mana = static_cast<float>(atof(row[3]));
entry.end = static_cast<float>(atof(row[4]));
entry.unk1 = static_cast<float>(atof(row[5]));
entry.unk2 = static_cast<float>(atof(row[6]));
entry.hp_fac = static_cast<float>(atof(row[7]));
entry.mana_fac = static_cast<float>(atof(row[8]));
entry.end_fac = static_cast<float>(atof(row[9]));
e.level = atoi(row[0]);
e.class_ = atoi(row[1]);
e.hp = static_cast<float>(atof(row[2]));
e.mana = static_cast<float>(atof(row[3]));
e.end = static_cast<float>(atof(row[4]));
e.unk1 = static_cast<float>(atof(row[5]));
e.unk2 = static_cast<float>(atof(row[6]));
e.hp_fac = static_cast<float>(atof(row[7]));
e.mana_fac = static_cast<float>(atof(row[8]));
e.end_fac = static_cast<float>(atof(row[9]));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -382,6 +382,32 @@ public:
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_BASE_DATA_REPOSITORY_H
@@ -109,25 +109,25 @@ public:
static BlockedSpells NewEntity()
{
BlockedSpells entry{};
BlockedSpells e{};
entry.id = 0;
entry.spellid = 0;
entry.type = 0;
entry.zoneid = 0;
entry.x = 0;
entry.y = 0;
entry.z = 0;
entry.x_diff = 0;
entry.y_diff = 0;
entry.z_diff = 0;
entry.message = "";
entry.description = "";
e.id = 0;
e.spellid = 0;
e.type = 0;
e.zoneid = 0;
e.x = 0;
e.y = 0;
e.z = 0;
e.x_diff = 0;
e.y_diff = 0;
e.z_diff = 0;
e.message = "";
e.description = "";
return entry;
return e;
}
static BlockedSpells GetBlockedSpellsEntry(
static BlockedSpells GetBlockedSpells(
const std::vector<BlockedSpells> &blocked_spellss,
int blocked_spells_id
)
@@ -156,22 +156,22 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
BlockedSpells entry{};
BlockedSpells e{};
entry.id = atoi(row[0]);
entry.spellid = atoi(row[1]);
entry.type = atoi(row[2]);
entry.zoneid = atoi(row[3]);
entry.x = static_cast<float>(atof(row[4]));
entry.y = static_cast<float>(atof(row[5]));
entry.z = static_cast<float>(atof(row[6]));
entry.x_diff = static_cast<float>(atof(row[7]));
entry.y_diff = static_cast<float>(atof(row[8]));
entry.z_diff = static_cast<float>(atof(row[9]));
entry.message = row[10] ? row[10] : "";
entry.description = row[11] ? row[11] : "";
e.id = atoi(row[0]);
e.spellid = atoi(row[1]);
e.type = atoi(row[2]);
e.zoneid = atoi(row[3]);
e.x = static_cast<float>(atof(row[4]));
e.y = static_cast<float>(atof(row[5]));
e.z = static_cast<float>(atof(row[6]));
e.x_diff = static_cast<float>(atof(row[7]));
e.y_diff = static_cast<float>(atof(row[8]));
e.z_diff = static_cast<float>(atof(row[9]));
e.message = row[10] ? row[10] : "";
e.description = row[11] ? row[11] : "";
return entry;
return e;
}
return NewEntity();
@@ -196,32 +196,32 @@ public:
static int UpdateOne(
Database& db,
BlockedSpells blocked_spells_entry
const BlockedSpells &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(blocked_spells_entry.spellid));
update_values.push_back(columns[2] + " = " + std::to_string(blocked_spells_entry.type));
update_values.push_back(columns[3] + " = " + std::to_string(blocked_spells_entry.zoneid));
update_values.push_back(columns[4] + " = " + std::to_string(blocked_spells_entry.x));
update_values.push_back(columns[5] + " = " + std::to_string(blocked_spells_entry.y));
update_values.push_back(columns[6] + " = " + std::to_string(blocked_spells_entry.z));
update_values.push_back(columns[7] + " = " + std::to_string(blocked_spells_entry.x_diff));
update_values.push_back(columns[8] + " = " + std::to_string(blocked_spells_entry.y_diff));
update_values.push_back(columns[9] + " = " + std::to_string(blocked_spells_entry.z_diff));
update_values.push_back(columns[10] + " = '" + Strings::Escape(blocked_spells_entry.message) + "'");
update_values.push_back(columns[11] + " = '" + Strings::Escape(blocked_spells_entry.description) + "'");
v.push_back(columns[1] + " = " + std::to_string(e.spellid));
v.push_back(columns[2] + " = " + std::to_string(e.type));
v.push_back(columns[3] + " = " + std::to_string(e.zoneid));
v.push_back(columns[4] + " = " + std::to_string(e.x));
v.push_back(columns[5] + " = " + std::to_string(e.y));
v.push_back(columns[6] + " = " + std::to_string(e.z));
v.push_back(columns[7] + " = " + std::to_string(e.x_diff));
v.push_back(columns[8] + " = " + std::to_string(e.y_diff));
v.push_back(columns[9] + " = " + std::to_string(e.z_diff));
v.push_back(columns[10] + " = '" + Strings::Escape(e.message) + "'");
v.push_back(columns[11] + " = '" + Strings::Escape(e.description) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
blocked_spells_entry.id
e.id
)
);
@@ -230,69 +230,69 @@ public:
static BlockedSpells InsertOne(
Database& db,
BlockedSpells blocked_spells_entry
BlockedSpells e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(blocked_spells_entry.id));
insert_values.push_back(std::to_string(blocked_spells_entry.spellid));
insert_values.push_back(std::to_string(blocked_spells_entry.type));
insert_values.push_back(std::to_string(blocked_spells_entry.zoneid));
insert_values.push_back(std::to_string(blocked_spells_entry.x));
insert_values.push_back(std::to_string(blocked_spells_entry.y));
insert_values.push_back(std::to_string(blocked_spells_entry.z));
insert_values.push_back(std::to_string(blocked_spells_entry.x_diff));
insert_values.push_back(std::to_string(blocked_spells_entry.y_diff));
insert_values.push_back(std::to_string(blocked_spells_entry.z_diff));
insert_values.push_back("'" + Strings::Escape(blocked_spells_entry.message) + "'");
insert_values.push_back("'" + Strings::Escape(blocked_spells_entry.description) + "'");
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.spellid));
v.push_back(std::to_string(e.type));
v.push_back(std::to_string(e.zoneid));
v.push_back(std::to_string(e.x));
v.push_back(std::to_string(e.y));
v.push_back(std::to_string(e.z));
v.push_back(std::to_string(e.x_diff));
v.push_back(std::to_string(e.y_diff));
v.push_back(std::to_string(e.z_diff));
v.push_back("'" + Strings::Escape(e.message) + "'");
v.push_back("'" + Strings::Escape(e.description) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
blocked_spells_entry.id = results.LastInsertedID();
return blocked_spells_entry;
e.id = results.LastInsertedID();
return e;
}
blocked_spells_entry = NewEntity();
e = NewEntity();
return blocked_spells_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<BlockedSpells> blocked_spells_entries
const std::vector<BlockedSpells> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &blocked_spells_entry: blocked_spells_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(blocked_spells_entry.id));
insert_values.push_back(std::to_string(blocked_spells_entry.spellid));
insert_values.push_back(std::to_string(blocked_spells_entry.type));
insert_values.push_back(std::to_string(blocked_spells_entry.zoneid));
insert_values.push_back(std::to_string(blocked_spells_entry.x));
insert_values.push_back(std::to_string(blocked_spells_entry.y));
insert_values.push_back(std::to_string(blocked_spells_entry.z));
insert_values.push_back(std::to_string(blocked_spells_entry.x_diff));
insert_values.push_back(std::to_string(blocked_spells_entry.y_diff));
insert_values.push_back(std::to_string(blocked_spells_entry.z_diff));
insert_values.push_back("'" + Strings::Escape(blocked_spells_entry.message) + "'");
insert_values.push_back("'" + Strings::Escape(blocked_spells_entry.description) + "'");
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.spellid));
v.push_back(std::to_string(e.type));
v.push_back(std::to_string(e.zoneid));
v.push_back(std::to_string(e.x));
v.push_back(std::to_string(e.y));
v.push_back(std::to_string(e.z));
v.push_back(std::to_string(e.x_diff));
v.push_back(std::to_string(e.y_diff));
v.push_back(std::to_string(e.z_diff));
v.push_back("'" + Strings::Escape(e.message) + "'");
v.push_back("'" + Strings::Escape(e.description) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -319,28 +319,28 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
BlockedSpells entry{};
BlockedSpells e{};
entry.id = atoi(row[0]);
entry.spellid = atoi(row[1]);
entry.type = atoi(row[2]);
entry.zoneid = atoi(row[3]);
entry.x = static_cast<float>(atof(row[4]));
entry.y = static_cast<float>(atof(row[5]));
entry.z = static_cast<float>(atof(row[6]));
entry.x_diff = static_cast<float>(atof(row[7]));
entry.y_diff = static_cast<float>(atof(row[8]));
entry.z_diff = static_cast<float>(atof(row[9]));
entry.message = row[10] ? row[10] : "";
entry.description = row[11] ? row[11] : "";
e.id = atoi(row[0]);
e.spellid = atoi(row[1]);
e.type = atoi(row[2]);
e.zoneid = atoi(row[3]);
e.x = static_cast<float>(atof(row[4]));
e.y = static_cast<float>(atof(row[5]));
e.z = static_cast<float>(atof(row[6]));
e.x_diff = static_cast<float>(atof(row[7]));
e.y_diff = static_cast<float>(atof(row[8]));
e.z_diff = static_cast<float>(atof(row[9]));
e.message = row[10] ? row[10] : "";
e.description = row[11] ? row[11] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<BlockedSpells> GetWhere(Database& db, std::string where_filter)
static std::vector<BlockedSpells> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<BlockedSpells> all_entries;
@@ -355,28 +355,28 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
BlockedSpells entry{};
BlockedSpells e{};
entry.id = atoi(row[0]);
entry.spellid = atoi(row[1]);
entry.type = atoi(row[2]);
entry.zoneid = atoi(row[3]);
entry.x = static_cast<float>(atof(row[4]));
entry.y = static_cast<float>(atof(row[5]));
entry.z = static_cast<float>(atof(row[6]));
entry.x_diff = static_cast<float>(atof(row[7]));
entry.y_diff = static_cast<float>(atof(row[8]));
entry.z_diff = static_cast<float>(atof(row[9]));
entry.message = row[10] ? row[10] : "";
entry.description = row[11] ? row[11] : "";
e.id = atoi(row[0]);
e.spellid = atoi(row[1]);
e.type = atoi(row[2]);
e.zoneid = atoi(row[3]);
e.x = static_cast<float>(atof(row[4]));
e.y = static_cast<float>(atof(row[5]));
e.z = static_cast<float>(atof(row[6]));
e.x_diff = static_cast<float>(atof(row[7]));
e.y_diff = static_cast<float>(atof(row[8]));
e.z_diff = static_cast<float>(atof(row[9]));
e.message = row[10] ? row[10] : "";
e.description = row[11] ? row[11] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -401,6 +401,32 @@ public:
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_BLOCKED_SPELLS_REPOSITORY_H
@@ -85,17 +85,17 @@ public:
static Books NewEntity()
{
Books entry{};
Books e{};
entry.id = 0;
entry.name = "";
entry.txtfile = "";
entry.language = 0;
e.id = 0;
e.name = "";
e.txtfile = "";
e.language = 0;
return entry;
return e;
}
static Books GetBooksEntry(
static Books GetBooks(
const std::vector<Books> &bookss,
int books_id
)
@@ -124,14 +124,14 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
Books entry{};
Books e{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.txtfile = row[2] ? row[2] : "";
entry.language = atoi(row[3]);
e.id = atoi(row[0]);
e.name = row[1] ? row[1] : "";
e.txtfile = row[2] ? row[2] : "";
e.language = atoi(row[3]);
return entry;
return e;
}
return NewEntity();
@@ -156,24 +156,24 @@ public:
static int UpdateOne(
Database& db,
Books books_entry
const Books &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + Strings::Escape(books_entry.name) + "'");
update_values.push_back(columns[2] + " = '" + Strings::Escape(books_entry.txtfile) + "'");
update_values.push_back(columns[3] + " = " + std::to_string(books_entry.language));
v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'");
v.push_back(columns[2] + " = '" + Strings::Escape(e.txtfile) + "'");
v.push_back(columns[3] + " = " + std::to_string(e.language));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
books_entry.id
e.id
)
);
@@ -182,53 +182,53 @@ public:
static Books InsertOne(
Database& db,
Books books_entry
Books e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(books_entry.id));
insert_values.push_back("'" + Strings::Escape(books_entry.name) + "'");
insert_values.push_back("'" + Strings::Escape(books_entry.txtfile) + "'");
insert_values.push_back(std::to_string(books_entry.language));
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back("'" + Strings::Escape(e.txtfile) + "'");
v.push_back(std::to_string(e.language));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
books_entry.id = results.LastInsertedID();
return books_entry;
e.id = results.LastInsertedID();
return e;
}
books_entry = NewEntity();
e = NewEntity();
return books_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<Books> books_entries
const std::vector<Books> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &books_entry: books_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(books_entry.id));
insert_values.push_back("'" + Strings::Escape(books_entry.name) + "'");
insert_values.push_back("'" + Strings::Escape(books_entry.txtfile) + "'");
insert_values.push_back(std::to_string(books_entry.language));
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back("'" + Strings::Escape(e.txtfile) + "'");
v.push_back(std::to_string(e.language));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -255,20 +255,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Books entry{};
Books e{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.txtfile = row[2] ? row[2] : "";
entry.language = atoi(row[3]);
e.id = atoi(row[0]);
e.name = row[1] ? row[1] : "";
e.txtfile = row[2] ? row[2] : "";
e.language = atoi(row[3]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<Books> GetWhere(Database& db, std::string where_filter)
static std::vector<Books> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<Books> all_entries;
@@ -283,20 +283,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Books entry{};
Books e{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.txtfile = row[2] ? row[2] : "";
entry.language = atoi(row[3]);
e.id = atoi(row[0]);
e.name = row[1] ? row[1] : "";
e.txtfile = row[2] ? row[2] : "";
e.language = atoi(row[3]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -321,6 +321,32 @@ public:
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_BOOKS_REPOSITORY_H
@@ -169,45 +169,45 @@ public:
static BugReports NewEntity()
{
BugReports entry{};
BugReports e{};
entry.id = 0;
entry.zone = "Unknown";
entry.client_version_id = 0;
entry.client_version_name = "Unknown";
entry.account_id = 0;
entry.character_id = 0;
entry.character_name = "Unknown";
entry.reporter_spoof = 1;
entry.category_id = 0;
entry.category_name = "Other";
entry.reporter_name = "Unknown";
entry.ui_path = "Unknown";
entry.pos_x = 0;
entry.pos_y = 0;
entry.pos_z = 0;
entry.heading = 0;
entry.time_played = 0;
entry.target_id = 0;
entry.target_name = "Unknown";
entry.optional_info_mask = 0;
entry._can_duplicate = 0;
entry._crash_bug = 0;
entry._target_info = 0;
entry._character_flags = 0;
entry._unknown_value = 0;
entry.bug_report = "";
entry.system_info = "";
entry.report_datetime = std::time(nullptr);
entry.bug_status = 0;
entry.last_review = std::time(nullptr);
entry.last_reviewer = "None";
entry.reviewer_notes = "";
e.id = 0;
e.zone = "Unknown";
e.client_version_id = 0;
e.client_version_name = "Unknown";
e.account_id = 0;
e.character_id = 0;
e.character_name = "Unknown";
e.reporter_spoof = 1;
e.category_id = 0;
e.category_name = "Other";
e.reporter_name = "Unknown";
e.ui_path = "Unknown";
e.pos_x = 0;
e.pos_y = 0;
e.pos_z = 0;
e.heading = 0;
e.time_played = 0;
e.target_id = 0;
e.target_name = "Unknown";
e.optional_info_mask = 0;
e._can_duplicate = 0;
e._crash_bug = 0;
e._target_info = 0;
e._character_flags = 0;
e._unknown_value = 0;
e.bug_report = "";
e.system_info = "";
e.report_datetime = std::time(nullptr);
e.bug_status = 0;
e.last_review = std::time(nullptr);
e.last_reviewer = "None";
e.reviewer_notes = "";
return entry;
return e;
}
static BugReports GetBugReportsEntry(
static BugReports GetBugReports(
const std::vector<BugReports> &bug_reportss,
int bug_reports_id
)
@@ -236,42 +236,42 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
BugReports entry{};
BugReports e{};
entry.id = atoi(row[0]);
entry.zone = row[1] ? row[1] : "";
entry.client_version_id = atoi(row[2]);
entry.client_version_name = row[3] ? row[3] : "";
entry.account_id = atoi(row[4]);
entry.character_id = atoi(row[5]);
entry.character_name = row[6] ? row[6] : "";
entry.reporter_spoof = atoi(row[7]);
entry.category_id = atoi(row[8]);
entry.category_name = row[9] ? row[9] : "";
entry.reporter_name = row[10] ? row[10] : "";
entry.ui_path = row[11] ? row[11] : "";
entry.pos_x = static_cast<float>(atof(row[12]));
entry.pos_y = static_cast<float>(atof(row[13]));
entry.pos_z = static_cast<float>(atof(row[14]));
entry.heading = atoi(row[15]);
entry.time_played = atoi(row[16]);
entry.target_id = atoi(row[17]);
entry.target_name = row[18] ? row[18] : "";
entry.optional_info_mask = atoi(row[19]);
entry._can_duplicate = atoi(row[20]);
entry._crash_bug = atoi(row[21]);
entry._target_info = atoi(row[22]);
entry._character_flags = atoi(row[23]);
entry._unknown_value = atoi(row[24]);
entry.bug_report = row[25] ? row[25] : "";
entry.system_info = row[26] ? row[26] : "";
entry.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10);
entry.bug_status = atoi(row[28]);
entry.last_review = strtoll(row[29] ? row[29] : "-1", nullptr, 10);
entry.last_reviewer = row[30] ? row[30] : "";
entry.reviewer_notes = row[31] ? row[31] : "";
e.id = atoi(row[0]);
e.zone = row[1] ? row[1] : "";
e.client_version_id = atoi(row[2]);
e.client_version_name = row[3] ? row[3] : "";
e.account_id = atoi(row[4]);
e.character_id = atoi(row[5]);
e.character_name = row[6] ? row[6] : "";
e.reporter_spoof = atoi(row[7]);
e.category_id = atoi(row[8]);
e.category_name = row[9] ? row[9] : "";
e.reporter_name = row[10] ? row[10] : "";
e.ui_path = row[11] ? row[11] : "";
e.pos_x = static_cast<float>(atof(row[12]));
e.pos_y = static_cast<float>(atof(row[13]));
e.pos_z = static_cast<float>(atof(row[14]));
e.heading = atoi(row[15]);
e.time_played = atoi(row[16]);
e.target_id = atoi(row[17]);
e.target_name = row[18] ? row[18] : "";
e.optional_info_mask = atoi(row[19]);
e._can_duplicate = atoi(row[20]);
e._crash_bug = atoi(row[21]);
e._target_info = atoi(row[22]);
e._character_flags = atoi(row[23]);
e._unknown_value = atoi(row[24]);
e.bug_report = row[25] ? row[25] : "";
e.system_info = row[26] ? row[26] : "";
e.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10);
e.bug_status = atoi(row[28]);
e.last_review = strtoll(row[29] ? row[29] : "-1", nullptr, 10);
e.last_reviewer = row[30] ? row[30] : "";
e.reviewer_notes = row[31] ? row[31] : "";
return entry;
return e;
}
return NewEntity();
@@ -296,52 +296,52 @@ public:
static int UpdateOne(
Database& db,
BugReports bug_reports_entry
const BugReports &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + Strings::Escape(bug_reports_entry.zone) + "'");
update_values.push_back(columns[2] + " = " + std::to_string(bug_reports_entry.client_version_id));
update_values.push_back(columns[3] + " = '" + Strings::Escape(bug_reports_entry.client_version_name) + "'");
update_values.push_back(columns[4] + " = " + std::to_string(bug_reports_entry.account_id));
update_values.push_back(columns[5] + " = " + std::to_string(bug_reports_entry.character_id));
update_values.push_back(columns[6] + " = '" + Strings::Escape(bug_reports_entry.character_name) + "'");
update_values.push_back(columns[7] + " = " + std::to_string(bug_reports_entry.reporter_spoof));
update_values.push_back(columns[8] + " = " + std::to_string(bug_reports_entry.category_id));
update_values.push_back(columns[9] + " = '" + Strings::Escape(bug_reports_entry.category_name) + "'");
update_values.push_back(columns[10] + " = '" + Strings::Escape(bug_reports_entry.reporter_name) + "'");
update_values.push_back(columns[11] + " = '" + Strings::Escape(bug_reports_entry.ui_path) + "'");
update_values.push_back(columns[12] + " = " + std::to_string(bug_reports_entry.pos_x));
update_values.push_back(columns[13] + " = " + std::to_string(bug_reports_entry.pos_y));
update_values.push_back(columns[14] + " = " + std::to_string(bug_reports_entry.pos_z));
update_values.push_back(columns[15] + " = " + std::to_string(bug_reports_entry.heading));
update_values.push_back(columns[16] + " = " + std::to_string(bug_reports_entry.time_played));
update_values.push_back(columns[17] + " = " + std::to_string(bug_reports_entry.target_id));
update_values.push_back(columns[18] + " = '" + Strings::Escape(bug_reports_entry.target_name) + "'");
update_values.push_back(columns[19] + " = " + std::to_string(bug_reports_entry.optional_info_mask));
update_values.push_back(columns[20] + " = " + std::to_string(bug_reports_entry._can_duplicate));
update_values.push_back(columns[21] + " = " + std::to_string(bug_reports_entry._crash_bug));
update_values.push_back(columns[22] + " = " + std::to_string(bug_reports_entry._target_info));
update_values.push_back(columns[23] + " = " + std::to_string(bug_reports_entry._character_flags));
update_values.push_back(columns[24] + " = " + std::to_string(bug_reports_entry._unknown_value));
update_values.push_back(columns[25] + " = '" + Strings::Escape(bug_reports_entry.bug_report) + "'");
update_values.push_back(columns[26] + " = '" + Strings::Escape(bug_reports_entry.system_info) + "'");
update_values.push_back(columns[27] + " = FROM_UNIXTIME(" + (bug_reports_entry.report_datetime > 0 ? std::to_string(bug_reports_entry.report_datetime) : "null") + ")");
update_values.push_back(columns[28] + " = " + std::to_string(bug_reports_entry.bug_status));
update_values.push_back(columns[29] + " = FROM_UNIXTIME(" + (bug_reports_entry.last_review > 0 ? std::to_string(bug_reports_entry.last_review) : "null") + ")");
update_values.push_back(columns[30] + " = '" + Strings::Escape(bug_reports_entry.last_reviewer) + "'");
update_values.push_back(columns[31] + " = '" + Strings::Escape(bug_reports_entry.reviewer_notes) + "'");
v.push_back(columns[1] + " = '" + Strings::Escape(e.zone) + "'");
v.push_back(columns[2] + " = " + std::to_string(e.client_version_id));
v.push_back(columns[3] + " = '" + Strings::Escape(e.client_version_name) + "'");
v.push_back(columns[4] + " = " + std::to_string(e.account_id));
v.push_back(columns[5] + " = " + std::to_string(e.character_id));
v.push_back(columns[6] + " = '" + Strings::Escape(e.character_name) + "'");
v.push_back(columns[7] + " = " + std::to_string(e.reporter_spoof));
v.push_back(columns[8] + " = " + std::to_string(e.category_id));
v.push_back(columns[9] + " = '" + Strings::Escape(e.category_name) + "'");
v.push_back(columns[10] + " = '" + Strings::Escape(e.reporter_name) + "'");
v.push_back(columns[11] + " = '" + Strings::Escape(e.ui_path) + "'");
v.push_back(columns[12] + " = " + std::to_string(e.pos_x));
v.push_back(columns[13] + " = " + std::to_string(e.pos_y));
v.push_back(columns[14] + " = " + std::to_string(e.pos_z));
v.push_back(columns[15] + " = " + std::to_string(e.heading));
v.push_back(columns[16] + " = " + std::to_string(e.time_played));
v.push_back(columns[17] + " = " + std::to_string(e.target_id));
v.push_back(columns[18] + " = '" + Strings::Escape(e.target_name) + "'");
v.push_back(columns[19] + " = " + std::to_string(e.optional_info_mask));
v.push_back(columns[20] + " = " + std::to_string(e._can_duplicate));
v.push_back(columns[21] + " = " + std::to_string(e._crash_bug));
v.push_back(columns[22] + " = " + std::to_string(e._target_info));
v.push_back(columns[23] + " = " + std::to_string(e._character_flags));
v.push_back(columns[24] + " = " + std::to_string(e._unknown_value));
v.push_back(columns[25] + " = '" + Strings::Escape(e.bug_report) + "'");
v.push_back(columns[26] + " = '" + Strings::Escape(e.system_info) + "'");
v.push_back(columns[27] + " = FROM_UNIXTIME(" + (e.report_datetime > 0 ? std::to_string(e.report_datetime) : "null") + ")");
v.push_back(columns[28] + " = " + std::to_string(e.bug_status));
v.push_back(columns[29] + " = FROM_UNIXTIME(" + (e.last_review > 0 ? std::to_string(e.last_review) : "null") + ")");
v.push_back(columns[30] + " = '" + Strings::Escape(e.last_reviewer) + "'");
v.push_back(columns[31] + " = '" + Strings::Escape(e.reviewer_notes) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
bug_reports_entry.id
e.id
)
);
@@ -350,109 +350,109 @@ public:
static BugReports InsertOne(
Database& db,
BugReports bug_reports_entry
BugReports e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(bug_reports_entry.id));
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.zone) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.client_version_id));
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.client_version_name) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.account_id));
insert_values.push_back(std::to_string(bug_reports_entry.character_id));
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.character_name) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.reporter_spoof));
insert_values.push_back(std::to_string(bug_reports_entry.category_id));
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.category_name) + "'");
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.reporter_name) + "'");
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.ui_path) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.pos_x));
insert_values.push_back(std::to_string(bug_reports_entry.pos_y));
insert_values.push_back(std::to_string(bug_reports_entry.pos_z));
insert_values.push_back(std::to_string(bug_reports_entry.heading));
insert_values.push_back(std::to_string(bug_reports_entry.time_played));
insert_values.push_back(std::to_string(bug_reports_entry.target_id));
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.target_name) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.optional_info_mask));
insert_values.push_back(std::to_string(bug_reports_entry._can_duplicate));
insert_values.push_back(std::to_string(bug_reports_entry._crash_bug));
insert_values.push_back(std::to_string(bug_reports_entry._target_info));
insert_values.push_back(std::to_string(bug_reports_entry._character_flags));
insert_values.push_back(std::to_string(bug_reports_entry._unknown_value));
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.bug_report) + "'");
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.system_info) + "'");
insert_values.push_back("FROM_UNIXTIME(" + (bug_reports_entry.report_datetime > 0 ? std::to_string(bug_reports_entry.report_datetime) : "null") + ")");
insert_values.push_back(std::to_string(bug_reports_entry.bug_status));
insert_values.push_back("FROM_UNIXTIME(" + (bug_reports_entry.last_review > 0 ? std::to_string(bug_reports_entry.last_review) : "null") + ")");
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.last_reviewer) + "'");
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.reviewer_notes) + "'");
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.zone) + "'");
v.push_back(std::to_string(e.client_version_id));
v.push_back("'" + Strings::Escape(e.client_version_name) + "'");
v.push_back(std::to_string(e.account_id));
v.push_back(std::to_string(e.character_id));
v.push_back("'" + Strings::Escape(e.character_name) + "'");
v.push_back(std::to_string(e.reporter_spoof));
v.push_back(std::to_string(e.category_id));
v.push_back("'" + Strings::Escape(e.category_name) + "'");
v.push_back("'" + Strings::Escape(e.reporter_name) + "'");
v.push_back("'" + Strings::Escape(e.ui_path) + "'");
v.push_back(std::to_string(e.pos_x));
v.push_back(std::to_string(e.pos_y));
v.push_back(std::to_string(e.pos_z));
v.push_back(std::to_string(e.heading));
v.push_back(std::to_string(e.time_played));
v.push_back(std::to_string(e.target_id));
v.push_back("'" + Strings::Escape(e.target_name) + "'");
v.push_back(std::to_string(e.optional_info_mask));
v.push_back(std::to_string(e._can_duplicate));
v.push_back(std::to_string(e._crash_bug));
v.push_back(std::to_string(e._target_info));
v.push_back(std::to_string(e._character_flags));
v.push_back(std::to_string(e._unknown_value));
v.push_back("'" + Strings::Escape(e.bug_report) + "'");
v.push_back("'" + Strings::Escape(e.system_info) + "'");
v.push_back("FROM_UNIXTIME(" + (e.report_datetime > 0 ? std::to_string(e.report_datetime) : "null") + ")");
v.push_back(std::to_string(e.bug_status));
v.push_back("FROM_UNIXTIME(" + (e.last_review > 0 ? std::to_string(e.last_review) : "null") + ")");
v.push_back("'" + Strings::Escape(e.last_reviewer) + "'");
v.push_back("'" + Strings::Escape(e.reviewer_notes) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
bug_reports_entry.id = results.LastInsertedID();
return bug_reports_entry;
e.id = results.LastInsertedID();
return e;
}
bug_reports_entry = NewEntity();
e = NewEntity();
return bug_reports_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<BugReports> bug_reports_entries
const std::vector<BugReports> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &bug_reports_entry: bug_reports_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(bug_reports_entry.id));
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.zone) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.client_version_id));
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.client_version_name) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.account_id));
insert_values.push_back(std::to_string(bug_reports_entry.character_id));
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.character_name) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.reporter_spoof));
insert_values.push_back(std::to_string(bug_reports_entry.category_id));
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.category_name) + "'");
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.reporter_name) + "'");
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.ui_path) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.pos_x));
insert_values.push_back(std::to_string(bug_reports_entry.pos_y));
insert_values.push_back(std::to_string(bug_reports_entry.pos_z));
insert_values.push_back(std::to_string(bug_reports_entry.heading));
insert_values.push_back(std::to_string(bug_reports_entry.time_played));
insert_values.push_back(std::to_string(bug_reports_entry.target_id));
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.target_name) + "'");
insert_values.push_back(std::to_string(bug_reports_entry.optional_info_mask));
insert_values.push_back(std::to_string(bug_reports_entry._can_duplicate));
insert_values.push_back(std::to_string(bug_reports_entry._crash_bug));
insert_values.push_back(std::to_string(bug_reports_entry._target_info));
insert_values.push_back(std::to_string(bug_reports_entry._character_flags));
insert_values.push_back(std::to_string(bug_reports_entry._unknown_value));
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.bug_report) + "'");
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.system_info) + "'");
insert_values.push_back("FROM_UNIXTIME(" + (bug_reports_entry.report_datetime > 0 ? std::to_string(bug_reports_entry.report_datetime) : "null") + ")");
insert_values.push_back(std::to_string(bug_reports_entry.bug_status));
insert_values.push_back("FROM_UNIXTIME(" + (bug_reports_entry.last_review > 0 ? std::to_string(bug_reports_entry.last_review) : "null") + ")");
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.last_reviewer) + "'");
insert_values.push_back("'" + Strings::Escape(bug_reports_entry.reviewer_notes) + "'");
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.zone) + "'");
v.push_back(std::to_string(e.client_version_id));
v.push_back("'" + Strings::Escape(e.client_version_name) + "'");
v.push_back(std::to_string(e.account_id));
v.push_back(std::to_string(e.character_id));
v.push_back("'" + Strings::Escape(e.character_name) + "'");
v.push_back(std::to_string(e.reporter_spoof));
v.push_back(std::to_string(e.category_id));
v.push_back("'" + Strings::Escape(e.category_name) + "'");
v.push_back("'" + Strings::Escape(e.reporter_name) + "'");
v.push_back("'" + Strings::Escape(e.ui_path) + "'");
v.push_back(std::to_string(e.pos_x));
v.push_back(std::to_string(e.pos_y));
v.push_back(std::to_string(e.pos_z));
v.push_back(std::to_string(e.heading));
v.push_back(std::to_string(e.time_played));
v.push_back(std::to_string(e.target_id));
v.push_back("'" + Strings::Escape(e.target_name) + "'");
v.push_back(std::to_string(e.optional_info_mask));
v.push_back(std::to_string(e._can_duplicate));
v.push_back(std::to_string(e._crash_bug));
v.push_back(std::to_string(e._target_info));
v.push_back(std::to_string(e._character_flags));
v.push_back(std::to_string(e._unknown_value));
v.push_back("'" + Strings::Escape(e.bug_report) + "'");
v.push_back("'" + Strings::Escape(e.system_info) + "'");
v.push_back("FROM_UNIXTIME(" + (e.report_datetime > 0 ? std::to_string(e.report_datetime) : "null") + ")");
v.push_back(std::to_string(e.bug_status));
v.push_back("FROM_UNIXTIME(" + (e.last_review > 0 ? std::to_string(e.last_review) : "null") + ")");
v.push_back("'" + Strings::Escape(e.last_reviewer) + "'");
v.push_back("'" + Strings::Escape(e.reviewer_notes) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -479,48 +479,48 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
BugReports entry{};
BugReports e{};
entry.id = atoi(row[0]);
entry.zone = row[1] ? row[1] : "";
entry.client_version_id = atoi(row[2]);
entry.client_version_name = row[3] ? row[3] : "";
entry.account_id = atoi(row[4]);
entry.character_id = atoi(row[5]);
entry.character_name = row[6] ? row[6] : "";
entry.reporter_spoof = atoi(row[7]);
entry.category_id = atoi(row[8]);
entry.category_name = row[9] ? row[9] : "";
entry.reporter_name = row[10] ? row[10] : "";
entry.ui_path = row[11] ? row[11] : "";
entry.pos_x = static_cast<float>(atof(row[12]));
entry.pos_y = static_cast<float>(atof(row[13]));
entry.pos_z = static_cast<float>(atof(row[14]));
entry.heading = atoi(row[15]);
entry.time_played = atoi(row[16]);
entry.target_id = atoi(row[17]);
entry.target_name = row[18] ? row[18] : "";
entry.optional_info_mask = atoi(row[19]);
entry._can_duplicate = atoi(row[20]);
entry._crash_bug = atoi(row[21]);
entry._target_info = atoi(row[22]);
entry._character_flags = atoi(row[23]);
entry._unknown_value = atoi(row[24]);
entry.bug_report = row[25] ? row[25] : "";
entry.system_info = row[26] ? row[26] : "";
entry.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10);
entry.bug_status = atoi(row[28]);
entry.last_review = strtoll(row[29] ? row[29] : "-1", nullptr, 10);
entry.last_reviewer = row[30] ? row[30] : "";
entry.reviewer_notes = row[31] ? row[31] : "";
e.id = atoi(row[0]);
e.zone = row[1] ? row[1] : "";
e.client_version_id = atoi(row[2]);
e.client_version_name = row[3] ? row[3] : "";
e.account_id = atoi(row[4]);
e.character_id = atoi(row[5]);
e.character_name = row[6] ? row[6] : "";
e.reporter_spoof = atoi(row[7]);
e.category_id = atoi(row[8]);
e.category_name = row[9] ? row[9] : "";
e.reporter_name = row[10] ? row[10] : "";
e.ui_path = row[11] ? row[11] : "";
e.pos_x = static_cast<float>(atof(row[12]));
e.pos_y = static_cast<float>(atof(row[13]));
e.pos_z = static_cast<float>(atof(row[14]));
e.heading = atoi(row[15]);
e.time_played = atoi(row[16]);
e.target_id = atoi(row[17]);
e.target_name = row[18] ? row[18] : "";
e.optional_info_mask = atoi(row[19]);
e._can_duplicate = atoi(row[20]);
e._crash_bug = atoi(row[21]);
e._target_info = atoi(row[22]);
e._character_flags = atoi(row[23]);
e._unknown_value = atoi(row[24]);
e.bug_report = row[25] ? row[25] : "";
e.system_info = row[26] ? row[26] : "";
e.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10);
e.bug_status = atoi(row[28]);
e.last_review = strtoll(row[29] ? row[29] : "-1", nullptr, 10);
e.last_reviewer = row[30] ? row[30] : "";
e.reviewer_notes = row[31] ? row[31] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<BugReports> GetWhere(Database& db, std::string where_filter)
static std::vector<BugReports> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<BugReports> all_entries;
@@ -535,48 +535,48 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
BugReports entry{};
BugReports e{};
entry.id = atoi(row[0]);
entry.zone = row[1] ? row[1] : "";
entry.client_version_id = atoi(row[2]);
entry.client_version_name = row[3] ? row[3] : "";
entry.account_id = atoi(row[4]);
entry.character_id = atoi(row[5]);
entry.character_name = row[6] ? row[6] : "";
entry.reporter_spoof = atoi(row[7]);
entry.category_id = atoi(row[8]);
entry.category_name = row[9] ? row[9] : "";
entry.reporter_name = row[10] ? row[10] : "";
entry.ui_path = row[11] ? row[11] : "";
entry.pos_x = static_cast<float>(atof(row[12]));
entry.pos_y = static_cast<float>(atof(row[13]));
entry.pos_z = static_cast<float>(atof(row[14]));
entry.heading = atoi(row[15]);
entry.time_played = atoi(row[16]);
entry.target_id = atoi(row[17]);
entry.target_name = row[18] ? row[18] : "";
entry.optional_info_mask = atoi(row[19]);
entry._can_duplicate = atoi(row[20]);
entry._crash_bug = atoi(row[21]);
entry._target_info = atoi(row[22]);
entry._character_flags = atoi(row[23]);
entry._unknown_value = atoi(row[24]);
entry.bug_report = row[25] ? row[25] : "";
entry.system_info = row[26] ? row[26] : "";
entry.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10);
entry.bug_status = atoi(row[28]);
entry.last_review = strtoll(row[29] ? row[29] : "-1", nullptr, 10);
entry.last_reviewer = row[30] ? row[30] : "";
entry.reviewer_notes = row[31] ? row[31] : "";
e.id = atoi(row[0]);
e.zone = row[1] ? row[1] : "";
e.client_version_id = atoi(row[2]);
e.client_version_name = row[3] ? row[3] : "";
e.account_id = atoi(row[4]);
e.character_id = atoi(row[5]);
e.character_name = row[6] ? row[6] : "";
e.reporter_spoof = atoi(row[7]);
e.category_id = atoi(row[8]);
e.category_name = row[9] ? row[9] : "";
e.reporter_name = row[10] ? row[10] : "";
e.ui_path = row[11] ? row[11] : "";
e.pos_x = static_cast<float>(atof(row[12]));
e.pos_y = static_cast<float>(atof(row[13]));
e.pos_z = static_cast<float>(atof(row[14]));
e.heading = atoi(row[15]);
e.time_played = atoi(row[16]);
e.target_id = atoi(row[17]);
e.target_name = row[18] ? row[18] : "";
e.optional_info_mask = atoi(row[19]);
e._can_duplicate = atoi(row[20]);
e._crash_bug = atoi(row[21]);
e._target_info = atoi(row[22]);
e._character_flags = atoi(row[23]);
e._unknown_value = atoi(row[24]);
e.bug_report = row[25] ? row[25] : "";
e.system_info = row[26] ? row[26] : "";
e.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10);
e.bug_status = atoi(row[28]);
e.last_review = strtoll(row[29] ? row[29] : "-1", nullptr, 10);
e.last_reviewer = row[30] ? row[30] : "";
e.reviewer_notes = row[31] ? row[31] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -601,6 +601,32 @@ public:
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_BUG_REPORTS_REPOSITORY_H
+143 -117
View File
@@ -112,26 +112,26 @@ public:
static Bugs NewEntity()
{
Bugs entry{};
Bugs e{};
entry.id = 0;
entry.zone = "";
entry.name = "";
entry.ui = "";
entry.x = 0;
entry.y = 0;
entry.z = 0;
entry.type = "";
entry.flag = 0;
entry.target = "";
entry.bug = "";
entry.date = 0;
entry.status = 0;
e.id = 0;
e.zone = "";
e.name = "";
e.ui = "";
e.x = 0;
e.y = 0;
e.z = 0;
e.type = "";
e.flag = 0;
e.target = "";
e.bug = "";
e.date = 0;
e.status = 0;
return entry;
return e;
}
static Bugs GetBugsEntry(
static Bugs GetBugs(
const std::vector<Bugs> &bugss,
int bugs_id
)
@@ -160,23 +160,23 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
Bugs entry{};
Bugs e{};
entry.id = atoi(row[0]);
entry.zone = row[1] ? row[1] : "";
entry.name = row[2] ? row[2] : "";
entry.ui = row[3] ? row[3] : "";
entry.x = static_cast<float>(atof(row[4]));
entry.y = static_cast<float>(atof(row[5]));
entry.z = static_cast<float>(atof(row[6]));
entry.type = row[7] ? row[7] : "";
entry.flag = atoi(row[8]);
entry.target = row[9] ? row[9] : "";
entry.bug = row[10] ? row[10] : "";
entry.date = row[11] ? row[11] : "";
entry.status = atoi(row[12]);
e.id = atoi(row[0]);
e.zone = row[1] ? row[1] : "";
e.name = row[2] ? row[2] : "";
e.ui = row[3] ? row[3] : "";
e.x = static_cast<float>(atof(row[4]));
e.y = static_cast<float>(atof(row[5]));
e.z = static_cast<float>(atof(row[6]));
e.type = row[7] ? row[7] : "";
e.flag = atoi(row[8]);
e.target = row[9] ? row[9] : "";
e.bug = row[10] ? row[10] : "";
e.date = row[11] ? row[11] : "";
e.status = atoi(row[12]);
return entry;
return e;
}
return NewEntity();
@@ -201,33 +201,33 @@ public:
static int UpdateOne(
Database& db,
Bugs bugs_entry
const Bugs &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + Strings::Escape(bugs_entry.zone) + "'");
update_values.push_back(columns[2] + " = '" + Strings::Escape(bugs_entry.name) + "'");
update_values.push_back(columns[3] + " = '" + Strings::Escape(bugs_entry.ui) + "'");
update_values.push_back(columns[4] + " = " + std::to_string(bugs_entry.x));
update_values.push_back(columns[5] + " = " + std::to_string(bugs_entry.y));
update_values.push_back(columns[6] + " = " + std::to_string(bugs_entry.z));
update_values.push_back(columns[7] + " = '" + Strings::Escape(bugs_entry.type) + "'");
update_values.push_back(columns[8] + " = " + std::to_string(bugs_entry.flag));
update_values.push_back(columns[9] + " = '" + Strings::Escape(bugs_entry.target) + "'");
update_values.push_back(columns[10] + " = '" + Strings::Escape(bugs_entry.bug) + "'");
update_values.push_back(columns[11] + " = '" + Strings::Escape(bugs_entry.date) + "'");
update_values.push_back(columns[12] + " = " + std::to_string(bugs_entry.status));
v.push_back(columns[1] + " = '" + Strings::Escape(e.zone) + "'");
v.push_back(columns[2] + " = '" + Strings::Escape(e.name) + "'");
v.push_back(columns[3] + " = '" + Strings::Escape(e.ui) + "'");
v.push_back(columns[4] + " = " + std::to_string(e.x));
v.push_back(columns[5] + " = " + std::to_string(e.y));
v.push_back(columns[6] + " = " + std::to_string(e.z));
v.push_back(columns[7] + " = '" + Strings::Escape(e.type) + "'");
v.push_back(columns[8] + " = " + std::to_string(e.flag));
v.push_back(columns[9] + " = '" + Strings::Escape(e.target) + "'");
v.push_back(columns[10] + " = '" + Strings::Escape(e.bug) + "'");
v.push_back(columns[11] + " = '" + Strings::Escape(e.date) + "'");
v.push_back(columns[12] + " = " + std::to_string(e.status));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
bugs_entry.id
e.id
)
);
@@ -236,71 +236,71 @@ public:
static Bugs InsertOne(
Database& db,
Bugs bugs_entry
Bugs e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(bugs_entry.id));
insert_values.push_back("'" + Strings::Escape(bugs_entry.zone) + "'");
insert_values.push_back("'" + Strings::Escape(bugs_entry.name) + "'");
insert_values.push_back("'" + Strings::Escape(bugs_entry.ui) + "'");
insert_values.push_back(std::to_string(bugs_entry.x));
insert_values.push_back(std::to_string(bugs_entry.y));
insert_values.push_back(std::to_string(bugs_entry.z));
insert_values.push_back("'" + Strings::Escape(bugs_entry.type) + "'");
insert_values.push_back(std::to_string(bugs_entry.flag));
insert_values.push_back("'" + Strings::Escape(bugs_entry.target) + "'");
insert_values.push_back("'" + Strings::Escape(bugs_entry.bug) + "'");
insert_values.push_back("'" + Strings::Escape(bugs_entry.date) + "'");
insert_values.push_back(std::to_string(bugs_entry.status));
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.zone) + "'");
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back("'" + Strings::Escape(e.ui) + "'");
v.push_back(std::to_string(e.x));
v.push_back(std::to_string(e.y));
v.push_back(std::to_string(e.z));
v.push_back("'" + Strings::Escape(e.type) + "'");
v.push_back(std::to_string(e.flag));
v.push_back("'" + Strings::Escape(e.target) + "'");
v.push_back("'" + Strings::Escape(e.bug) + "'");
v.push_back("'" + Strings::Escape(e.date) + "'");
v.push_back(std::to_string(e.status));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
bugs_entry.id = results.LastInsertedID();
return bugs_entry;
e.id = results.LastInsertedID();
return e;
}
bugs_entry = NewEntity();
e = NewEntity();
return bugs_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<Bugs> bugs_entries
const std::vector<Bugs> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &bugs_entry: bugs_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(bugs_entry.id));
insert_values.push_back("'" + Strings::Escape(bugs_entry.zone) + "'");
insert_values.push_back("'" + Strings::Escape(bugs_entry.name) + "'");
insert_values.push_back("'" + Strings::Escape(bugs_entry.ui) + "'");
insert_values.push_back(std::to_string(bugs_entry.x));
insert_values.push_back(std::to_string(bugs_entry.y));
insert_values.push_back(std::to_string(bugs_entry.z));
insert_values.push_back("'" + Strings::Escape(bugs_entry.type) + "'");
insert_values.push_back(std::to_string(bugs_entry.flag));
insert_values.push_back("'" + Strings::Escape(bugs_entry.target) + "'");
insert_values.push_back("'" + Strings::Escape(bugs_entry.bug) + "'");
insert_values.push_back("'" + Strings::Escape(bugs_entry.date) + "'");
insert_values.push_back(std::to_string(bugs_entry.status));
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.zone) + "'");
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back("'" + Strings::Escape(e.ui) + "'");
v.push_back(std::to_string(e.x));
v.push_back(std::to_string(e.y));
v.push_back(std::to_string(e.z));
v.push_back("'" + Strings::Escape(e.type) + "'");
v.push_back(std::to_string(e.flag));
v.push_back("'" + Strings::Escape(e.target) + "'");
v.push_back("'" + Strings::Escape(e.bug) + "'");
v.push_back("'" + Strings::Escape(e.date) + "'");
v.push_back(std::to_string(e.status));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -327,29 +327,29 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Bugs entry{};
Bugs e{};
entry.id = atoi(row[0]);
entry.zone = row[1] ? row[1] : "";
entry.name = row[2] ? row[2] : "";
entry.ui = row[3] ? row[3] : "";
entry.x = static_cast<float>(atof(row[4]));
entry.y = static_cast<float>(atof(row[5]));
entry.z = static_cast<float>(atof(row[6]));
entry.type = row[7] ? row[7] : "";
entry.flag = atoi(row[8]);
entry.target = row[9] ? row[9] : "";
entry.bug = row[10] ? row[10] : "";
entry.date = row[11] ? row[11] : "";
entry.status = atoi(row[12]);
e.id = atoi(row[0]);
e.zone = row[1] ? row[1] : "";
e.name = row[2] ? row[2] : "";
e.ui = row[3] ? row[3] : "";
e.x = static_cast<float>(atof(row[4]));
e.y = static_cast<float>(atof(row[5]));
e.z = static_cast<float>(atof(row[6]));
e.type = row[7] ? row[7] : "";
e.flag = atoi(row[8]);
e.target = row[9] ? row[9] : "";
e.bug = row[10] ? row[10] : "";
e.date = row[11] ? row[11] : "";
e.status = atoi(row[12]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<Bugs> GetWhere(Database& db, std::string where_filter)
static std::vector<Bugs> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<Bugs> all_entries;
@@ -364,29 +364,29 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Bugs entry{};
Bugs e{};
entry.id = atoi(row[0]);
entry.zone = row[1] ? row[1] : "";
entry.name = row[2] ? row[2] : "";
entry.ui = row[3] ? row[3] : "";
entry.x = static_cast<float>(atof(row[4]));
entry.y = static_cast<float>(atof(row[5]));
entry.z = static_cast<float>(atof(row[6]));
entry.type = row[7] ? row[7] : "";
entry.flag = atoi(row[8]);
entry.target = row[9] ? row[9] : "";
entry.bug = row[10] ? row[10] : "";
entry.date = row[11] ? row[11] : "";
entry.status = atoi(row[12]);
e.id = atoi(row[0]);
e.zone = row[1] ? row[1] : "";
e.name = row[2] ? row[2] : "";
e.ui = row[3] ? row[3] : "";
e.x = static_cast<float>(atof(row[4]));
e.y = static_cast<float>(atof(row[5]));
e.z = static_cast<float>(atof(row[6]));
e.type = row[7] ? row[7] : "";
e.flag = atoi(row[8]);
e.target = row[9] ? row[9] : "";
e.bug = row[10] ? row[10] : "";
e.date = row[11] ? row[11] : "";
e.status = atoi(row[12]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -411,6 +411,32 @@ public:
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_BUGS_REPOSITORY_H
@@ -91,19 +91,19 @@ public:
static Buyer NewEntity()
{
Buyer entry{};
Buyer e{};
entry.charid = 0;
entry.buyslot = 0;
entry.itemid = 0;
entry.itemname = "";
entry.quantity = 0;
entry.price = 0;
e.charid = 0;
e.buyslot = 0;
e.itemid = 0;
e.itemname = "";
e.quantity = 0;
e.price = 0;
return entry;
return e;
}
static Buyer GetBuyerEntry(
static Buyer GetBuyer(
const std::vector<Buyer> &buyers,
int buyer_id
)
@@ -132,16 +132,16 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
Buyer entry{};
Buyer e{};
entry.charid = atoi(row[0]);
entry.buyslot = atoi(row[1]);
entry.itemid = atoi(row[2]);
entry.itemname = row[3] ? row[3] : "";
entry.quantity = atoi(row[4]);
entry.price = atoi(row[5]);
e.charid = atoi(row[0]);
e.buyslot = atoi(row[1]);
e.itemid = atoi(row[2]);
e.itemname = row[3] ? row[3] : "";
e.quantity = atoi(row[4]);
e.price = atoi(row[5]);
return entry;
return e;
}
return NewEntity();
@@ -166,27 +166,27 @@ public:
static int UpdateOne(
Database& db,
Buyer buyer_entry
const Buyer &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(buyer_entry.charid));
update_values.push_back(columns[1] + " = " + std::to_string(buyer_entry.buyslot));
update_values.push_back(columns[2] + " = " + std::to_string(buyer_entry.itemid));
update_values.push_back(columns[3] + " = '" + Strings::Escape(buyer_entry.itemname) + "'");
update_values.push_back(columns[4] + " = " + std::to_string(buyer_entry.quantity));
update_values.push_back(columns[5] + " = " + std::to_string(buyer_entry.price));
v.push_back(columns[0] + " = " + std::to_string(e.charid));
v.push_back(columns[1] + " = " + std::to_string(e.buyslot));
v.push_back(columns[2] + " = " + std::to_string(e.itemid));
v.push_back(columns[3] + " = '" + Strings::Escape(e.itemname) + "'");
v.push_back(columns[4] + " = " + std::to_string(e.quantity));
v.push_back(columns[5] + " = " + std::to_string(e.price));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
buyer_entry.charid
e.charid
)
);
@@ -195,57 +195,57 @@ public:
static Buyer InsertOne(
Database& db,
Buyer buyer_entry
Buyer e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(buyer_entry.charid));
insert_values.push_back(std::to_string(buyer_entry.buyslot));
insert_values.push_back(std::to_string(buyer_entry.itemid));
insert_values.push_back("'" + Strings::Escape(buyer_entry.itemname) + "'");
insert_values.push_back(std::to_string(buyer_entry.quantity));
insert_values.push_back(std::to_string(buyer_entry.price));
v.push_back(std::to_string(e.charid));
v.push_back(std::to_string(e.buyslot));
v.push_back(std::to_string(e.itemid));
v.push_back("'" + Strings::Escape(e.itemname) + "'");
v.push_back(std::to_string(e.quantity));
v.push_back(std::to_string(e.price));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
buyer_entry.charid = results.LastInsertedID();
return buyer_entry;
e.charid = results.LastInsertedID();
return e;
}
buyer_entry = NewEntity();
e = NewEntity();
return buyer_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<Buyer> buyer_entries
const std::vector<Buyer> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &buyer_entry: buyer_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(buyer_entry.charid));
insert_values.push_back(std::to_string(buyer_entry.buyslot));
insert_values.push_back(std::to_string(buyer_entry.itemid));
insert_values.push_back("'" + Strings::Escape(buyer_entry.itemname) + "'");
insert_values.push_back(std::to_string(buyer_entry.quantity));
insert_values.push_back(std::to_string(buyer_entry.price));
v.push_back(std::to_string(e.charid));
v.push_back(std::to_string(e.buyslot));
v.push_back(std::to_string(e.itemid));
v.push_back("'" + Strings::Escape(e.itemname) + "'");
v.push_back(std::to_string(e.quantity));
v.push_back(std::to_string(e.price));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -272,22 +272,22 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Buyer entry{};
Buyer e{};
entry.charid = atoi(row[0]);
entry.buyslot = atoi(row[1]);
entry.itemid = atoi(row[2]);
entry.itemname = row[3] ? row[3] : "";
entry.quantity = atoi(row[4]);
entry.price = atoi(row[5]);
e.charid = atoi(row[0]);
e.buyslot = atoi(row[1]);
e.itemid = atoi(row[2]);
e.itemname = row[3] ? row[3] : "";
e.quantity = atoi(row[4]);
e.price = atoi(row[5]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<Buyer> GetWhere(Database& db, std::string where_filter)
static std::vector<Buyer> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<Buyer> all_entries;
@@ -302,22 +302,22 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Buyer entry{};
Buyer e{};
entry.charid = atoi(row[0]);
entry.buyslot = atoi(row[1]);
entry.itemid = atoi(row[2]);
entry.itemname = row[3] ? row[3] : "";
entry.quantity = atoi(row[4]);
entry.price = atoi(row[5]);
e.charid = atoi(row[0]);
e.buyslot = atoi(row[1]);
e.itemid = atoi(row[2]);
e.itemname = row[3] ? row[3] : "";
e.quantity = atoi(row[4]);
e.price = atoi(row[5]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -342,6 +342,32 @@ public:
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_BUYER_REPOSITORY_H
@@ -91,19 +91,19 @@ public:
static CharCreateCombinations NewEntity()
{
CharCreateCombinations entry{};
CharCreateCombinations e{};
entry.allocation_id = 0;
entry.race = 0;
entry.class_ = 0;
entry.deity = 0;
entry.start_zone = 0;
entry.expansions_req = 0;
e.allocation_id = 0;
e.race = 0;
e.class_ = 0;
e.deity = 0;
e.start_zone = 0;
e.expansions_req = 0;
return entry;
return e;
}
static CharCreateCombinations GetCharCreateCombinationsEntry(
static CharCreateCombinations GetCharCreateCombinations(
const std::vector<CharCreateCombinations> &char_create_combinationss,
int char_create_combinations_id
)
@@ -132,16 +132,16 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharCreateCombinations entry{};
CharCreateCombinations e{};
entry.allocation_id = atoi(row[0]);
entry.race = atoi(row[1]);
entry.class_ = atoi(row[2]);
entry.deity = atoi(row[3]);
entry.start_zone = atoi(row[4]);
entry.expansions_req = atoi(row[5]);
e.allocation_id = atoi(row[0]);
e.race = atoi(row[1]);
e.class_ = atoi(row[2]);
e.deity = atoi(row[3]);
e.start_zone = atoi(row[4]);
e.expansions_req = atoi(row[5]);
return entry;
return e;
}
return NewEntity();
@@ -166,27 +166,27 @@ public:
static int UpdateOne(
Database& db,
CharCreateCombinations char_create_combinations_entry
const CharCreateCombinations &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(char_create_combinations_entry.allocation_id));
update_values.push_back(columns[1] + " = " + std::to_string(char_create_combinations_entry.race));
update_values.push_back(columns[2] + " = " + std::to_string(char_create_combinations_entry.class_));
update_values.push_back(columns[3] + " = " + std::to_string(char_create_combinations_entry.deity));
update_values.push_back(columns[4] + " = " + std::to_string(char_create_combinations_entry.start_zone));
update_values.push_back(columns[5] + " = " + std::to_string(char_create_combinations_entry.expansions_req));
v.push_back(columns[0] + " = " + std::to_string(e.allocation_id));
v.push_back(columns[1] + " = " + std::to_string(e.race));
v.push_back(columns[2] + " = " + std::to_string(e.class_));
v.push_back(columns[3] + " = " + std::to_string(e.deity));
v.push_back(columns[4] + " = " + std::to_string(e.start_zone));
v.push_back(columns[5] + " = " + std::to_string(e.expansions_req));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
char_create_combinations_entry.race
e.race
)
);
@@ -195,57 +195,57 @@ public:
static CharCreateCombinations InsertOne(
Database& db,
CharCreateCombinations char_create_combinations_entry
CharCreateCombinations e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(char_create_combinations_entry.allocation_id));
insert_values.push_back(std::to_string(char_create_combinations_entry.race));
insert_values.push_back(std::to_string(char_create_combinations_entry.class_));
insert_values.push_back(std::to_string(char_create_combinations_entry.deity));
insert_values.push_back(std::to_string(char_create_combinations_entry.start_zone));
insert_values.push_back(std::to_string(char_create_combinations_entry.expansions_req));
v.push_back(std::to_string(e.allocation_id));
v.push_back(std::to_string(e.race));
v.push_back(std::to_string(e.class_));
v.push_back(std::to_string(e.deity));
v.push_back(std::to_string(e.start_zone));
v.push_back(std::to_string(e.expansions_req));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
char_create_combinations_entry.race = results.LastInsertedID();
return char_create_combinations_entry;
e.race = results.LastInsertedID();
return e;
}
char_create_combinations_entry = NewEntity();
e = NewEntity();
return char_create_combinations_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharCreateCombinations> char_create_combinations_entries
const std::vector<CharCreateCombinations> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &char_create_combinations_entry: char_create_combinations_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(char_create_combinations_entry.allocation_id));
insert_values.push_back(std::to_string(char_create_combinations_entry.race));
insert_values.push_back(std::to_string(char_create_combinations_entry.class_));
insert_values.push_back(std::to_string(char_create_combinations_entry.deity));
insert_values.push_back(std::to_string(char_create_combinations_entry.start_zone));
insert_values.push_back(std::to_string(char_create_combinations_entry.expansions_req));
v.push_back(std::to_string(e.allocation_id));
v.push_back(std::to_string(e.race));
v.push_back(std::to_string(e.class_));
v.push_back(std::to_string(e.deity));
v.push_back(std::to_string(e.start_zone));
v.push_back(std::to_string(e.expansions_req));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -272,22 +272,22 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharCreateCombinations entry{};
CharCreateCombinations e{};
entry.allocation_id = atoi(row[0]);
entry.race = atoi(row[1]);
entry.class_ = atoi(row[2]);
entry.deity = atoi(row[3]);
entry.start_zone = atoi(row[4]);
entry.expansions_req = atoi(row[5]);
e.allocation_id = atoi(row[0]);
e.race = atoi(row[1]);
e.class_ = atoi(row[2]);
e.deity = atoi(row[3]);
e.start_zone = atoi(row[4]);
e.expansions_req = atoi(row[5]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharCreateCombinations> GetWhere(Database& db, std::string where_filter)
static std::vector<CharCreateCombinations> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharCreateCombinations> all_entries;
@@ -302,22 +302,22 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharCreateCombinations entry{};
CharCreateCombinations e{};
entry.allocation_id = atoi(row[0]);
entry.race = atoi(row[1]);
entry.class_ = atoi(row[2]);
entry.deity = atoi(row[3]);
entry.start_zone = atoi(row[4]);
entry.expansions_req = atoi(row[5]);
e.allocation_id = atoi(row[0]);
e.race = atoi(row[1]);
e.class_ = atoi(row[2]);
e.deity = atoi(row[3]);
e.start_zone = atoi(row[4]);
e.expansions_req = atoi(row[5]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -342,6 +342,32 @@ public:
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_CHAR_CREATE_COMBINATIONS_REPOSITORY_H
@@ -118,28 +118,28 @@ public:
static CharCreatePointAllocations NewEntity()
{
CharCreatePointAllocations entry{};
CharCreatePointAllocations e{};
entry.id = 0;
entry.base_str = 0;
entry.base_sta = 0;
entry.base_dex = 0;
entry.base_agi = 0;
entry.base_int = 0;
entry.base_wis = 0;
entry.base_cha = 0;
entry.alloc_str = 0;
entry.alloc_sta = 0;
entry.alloc_dex = 0;
entry.alloc_agi = 0;
entry.alloc_int = 0;
entry.alloc_wis = 0;
entry.alloc_cha = 0;
e.id = 0;
e.base_str = 0;
e.base_sta = 0;
e.base_dex = 0;
e.base_agi = 0;
e.base_int = 0;
e.base_wis = 0;
e.base_cha = 0;
e.alloc_str = 0;
e.alloc_sta = 0;
e.alloc_dex = 0;
e.alloc_agi = 0;
e.alloc_int = 0;
e.alloc_wis = 0;
e.alloc_cha = 0;
return entry;
return e;
}
static CharCreatePointAllocations GetCharCreatePointAllocationsEntry(
static CharCreatePointAllocations GetCharCreatePointAllocations(
const std::vector<CharCreatePointAllocations> &char_create_point_allocationss,
int char_create_point_allocations_id
)
@@ -168,25 +168,25 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharCreatePointAllocations entry{};
CharCreatePointAllocations e{};
entry.id = atoi(row[0]);
entry.base_str = atoi(row[1]);
entry.base_sta = atoi(row[2]);
entry.base_dex = atoi(row[3]);
entry.base_agi = atoi(row[4]);
entry.base_int = atoi(row[5]);
entry.base_wis = atoi(row[6]);
entry.base_cha = atoi(row[7]);
entry.alloc_str = atoi(row[8]);
entry.alloc_sta = atoi(row[9]);
entry.alloc_dex = atoi(row[10]);
entry.alloc_agi = atoi(row[11]);
entry.alloc_int = atoi(row[12]);
entry.alloc_wis = atoi(row[13]);
entry.alloc_cha = atoi(row[14]);
e.id = atoi(row[0]);
e.base_str = atoi(row[1]);
e.base_sta = atoi(row[2]);
e.base_dex = atoi(row[3]);
e.base_agi = atoi(row[4]);
e.base_int = atoi(row[5]);
e.base_wis = atoi(row[6]);
e.base_cha = atoi(row[7]);
e.alloc_str = atoi(row[8]);
e.alloc_sta = atoi(row[9]);
e.alloc_dex = atoi(row[10]);
e.alloc_agi = atoi(row[11]);
e.alloc_int = atoi(row[12]);
e.alloc_wis = atoi(row[13]);
e.alloc_cha = atoi(row[14]);
return entry;
return e;
}
return NewEntity();
@@ -211,36 +211,36 @@ public:
static int UpdateOne(
Database& db,
CharCreatePointAllocations char_create_point_allocations_entry
const CharCreatePointAllocations &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(char_create_point_allocations_entry.id));
update_values.push_back(columns[1] + " = " + std::to_string(char_create_point_allocations_entry.base_str));
update_values.push_back(columns[2] + " = " + std::to_string(char_create_point_allocations_entry.base_sta));
update_values.push_back(columns[3] + " = " + std::to_string(char_create_point_allocations_entry.base_dex));
update_values.push_back(columns[4] + " = " + std::to_string(char_create_point_allocations_entry.base_agi));
update_values.push_back(columns[5] + " = " + std::to_string(char_create_point_allocations_entry.base_int));
update_values.push_back(columns[6] + " = " + std::to_string(char_create_point_allocations_entry.base_wis));
update_values.push_back(columns[7] + " = " + std::to_string(char_create_point_allocations_entry.base_cha));
update_values.push_back(columns[8] + " = " + std::to_string(char_create_point_allocations_entry.alloc_str));
update_values.push_back(columns[9] + " = " + std::to_string(char_create_point_allocations_entry.alloc_sta));
update_values.push_back(columns[10] + " = " + std::to_string(char_create_point_allocations_entry.alloc_dex));
update_values.push_back(columns[11] + " = " + std::to_string(char_create_point_allocations_entry.alloc_agi));
update_values.push_back(columns[12] + " = " + std::to_string(char_create_point_allocations_entry.alloc_int));
update_values.push_back(columns[13] + " = " + std::to_string(char_create_point_allocations_entry.alloc_wis));
update_values.push_back(columns[14] + " = " + std::to_string(char_create_point_allocations_entry.alloc_cha));
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = " + std::to_string(e.base_str));
v.push_back(columns[2] + " = " + std::to_string(e.base_sta));
v.push_back(columns[3] + " = " + std::to_string(e.base_dex));
v.push_back(columns[4] + " = " + std::to_string(e.base_agi));
v.push_back(columns[5] + " = " + std::to_string(e.base_int));
v.push_back(columns[6] + " = " + std::to_string(e.base_wis));
v.push_back(columns[7] + " = " + std::to_string(e.base_cha));
v.push_back(columns[8] + " = " + std::to_string(e.alloc_str));
v.push_back(columns[9] + " = " + std::to_string(e.alloc_sta));
v.push_back(columns[10] + " = " + std::to_string(e.alloc_dex));
v.push_back(columns[11] + " = " + std::to_string(e.alloc_agi));
v.push_back(columns[12] + " = " + std::to_string(e.alloc_int));
v.push_back(columns[13] + " = " + std::to_string(e.alloc_wis));
v.push_back(columns[14] + " = " + std::to_string(e.alloc_cha));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
char_create_point_allocations_entry.id
e.id
)
);
@@ -249,75 +249,75 @@ public:
static CharCreatePointAllocations InsertOne(
Database& db,
CharCreatePointAllocations char_create_point_allocations_entry
CharCreatePointAllocations e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(char_create_point_allocations_entry.id));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_str));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_sta));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_dex));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_agi));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_int));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_wis));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_cha));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_str));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_sta));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_dex));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_agi));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_int));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_wis));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_cha));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.base_str));
v.push_back(std::to_string(e.base_sta));
v.push_back(std::to_string(e.base_dex));
v.push_back(std::to_string(e.base_agi));
v.push_back(std::to_string(e.base_int));
v.push_back(std::to_string(e.base_wis));
v.push_back(std::to_string(e.base_cha));
v.push_back(std::to_string(e.alloc_str));
v.push_back(std::to_string(e.alloc_sta));
v.push_back(std::to_string(e.alloc_dex));
v.push_back(std::to_string(e.alloc_agi));
v.push_back(std::to_string(e.alloc_int));
v.push_back(std::to_string(e.alloc_wis));
v.push_back(std::to_string(e.alloc_cha));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
char_create_point_allocations_entry.id = results.LastInsertedID();
return char_create_point_allocations_entry;
e.id = results.LastInsertedID();
return e;
}
char_create_point_allocations_entry = NewEntity();
e = NewEntity();
return char_create_point_allocations_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharCreatePointAllocations> char_create_point_allocations_entries
const std::vector<CharCreatePointAllocations> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &char_create_point_allocations_entry: char_create_point_allocations_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(char_create_point_allocations_entry.id));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_str));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_sta));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_dex));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_agi));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_int));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_wis));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_cha));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_str));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_sta));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_dex));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_agi));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_int));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_wis));
insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_cha));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.base_str));
v.push_back(std::to_string(e.base_sta));
v.push_back(std::to_string(e.base_dex));
v.push_back(std::to_string(e.base_agi));
v.push_back(std::to_string(e.base_int));
v.push_back(std::to_string(e.base_wis));
v.push_back(std::to_string(e.base_cha));
v.push_back(std::to_string(e.alloc_str));
v.push_back(std::to_string(e.alloc_sta));
v.push_back(std::to_string(e.alloc_dex));
v.push_back(std::to_string(e.alloc_agi));
v.push_back(std::to_string(e.alloc_int));
v.push_back(std::to_string(e.alloc_wis));
v.push_back(std::to_string(e.alloc_cha));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -344,31 +344,31 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharCreatePointAllocations entry{};
CharCreatePointAllocations e{};
entry.id = atoi(row[0]);
entry.base_str = atoi(row[1]);
entry.base_sta = atoi(row[2]);
entry.base_dex = atoi(row[3]);
entry.base_agi = atoi(row[4]);
entry.base_int = atoi(row[5]);
entry.base_wis = atoi(row[6]);
entry.base_cha = atoi(row[7]);
entry.alloc_str = atoi(row[8]);
entry.alloc_sta = atoi(row[9]);
entry.alloc_dex = atoi(row[10]);
entry.alloc_agi = atoi(row[11]);
entry.alloc_int = atoi(row[12]);
entry.alloc_wis = atoi(row[13]);
entry.alloc_cha = atoi(row[14]);
e.id = atoi(row[0]);
e.base_str = atoi(row[1]);
e.base_sta = atoi(row[2]);
e.base_dex = atoi(row[3]);
e.base_agi = atoi(row[4]);
e.base_int = atoi(row[5]);
e.base_wis = atoi(row[6]);
e.base_cha = atoi(row[7]);
e.alloc_str = atoi(row[8]);
e.alloc_sta = atoi(row[9]);
e.alloc_dex = atoi(row[10]);
e.alloc_agi = atoi(row[11]);
e.alloc_int = atoi(row[12]);
e.alloc_wis = atoi(row[13]);
e.alloc_cha = atoi(row[14]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharCreatePointAllocations> GetWhere(Database& db, std::string where_filter)
static std::vector<CharCreatePointAllocations> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharCreatePointAllocations> all_entries;
@@ -383,31 +383,31 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharCreatePointAllocations entry{};
CharCreatePointAllocations e{};
entry.id = atoi(row[0]);
entry.base_str = atoi(row[1]);
entry.base_sta = atoi(row[2]);
entry.base_dex = atoi(row[3]);
entry.base_agi = atoi(row[4]);
entry.base_int = atoi(row[5]);
entry.base_wis = atoi(row[6]);
entry.base_cha = atoi(row[7]);
entry.alloc_str = atoi(row[8]);
entry.alloc_sta = atoi(row[9]);
entry.alloc_dex = atoi(row[10]);
entry.alloc_agi = atoi(row[11]);
entry.alloc_int = atoi(row[12]);
entry.alloc_wis = atoi(row[13]);
entry.alloc_cha = atoi(row[14]);
e.id = atoi(row[0]);
e.base_str = atoi(row[1]);
e.base_sta = atoi(row[2]);
e.base_dex = atoi(row[3]);
e.base_agi = atoi(row[4]);
e.base_int = atoi(row[5]);
e.base_wis = atoi(row[6]);
e.base_cha = atoi(row[7]);
e.alloc_str = atoi(row[8]);
e.alloc_sta = atoi(row[9]);
e.alloc_dex = atoi(row[10]);
e.alloc_agi = atoi(row[11]);
e.alloc_int = atoi(row[12]);
e.alloc_wis = atoi(row[13]);
e.alloc_cha = atoi(row[14]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -432,6 +432,32 @@ public:
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_CHAR_CREATE_POINT_ALLOCATIONS_REPOSITORY_H
@@ -82,16 +82,16 @@ public:
static CharRecipeList NewEntity()
{
CharRecipeList entry{};
CharRecipeList e{};
entry.char_id = 0;
entry.recipe_id = 0;
entry.madecount = 0;
e.char_id = 0;
e.recipe_id = 0;
e.madecount = 0;
return entry;
return e;
}
static CharRecipeList GetCharRecipeListEntry(
static CharRecipeList GetCharRecipeList(
const std::vector<CharRecipeList> &char_recipe_lists,
int char_recipe_list_id
)
@@ -120,13 +120,13 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharRecipeList entry{};
CharRecipeList e{};
entry.char_id = atoi(row[0]);
entry.recipe_id = atoi(row[1]);
entry.madecount = atoi(row[2]);
e.char_id = atoi(row[0]);
e.recipe_id = atoi(row[1]);
e.madecount = atoi(row[2]);
return entry;
return e;
}
return NewEntity();
@@ -151,24 +151,24 @@ public:
static int UpdateOne(
Database& db,
CharRecipeList char_recipe_list_entry
const CharRecipeList &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(char_recipe_list_entry.char_id));
update_values.push_back(columns[1] + " = " + std::to_string(char_recipe_list_entry.recipe_id));
update_values.push_back(columns[2] + " = " + std::to_string(char_recipe_list_entry.madecount));
v.push_back(columns[0] + " = " + std::to_string(e.char_id));
v.push_back(columns[1] + " = " + std::to_string(e.recipe_id));
v.push_back(columns[2] + " = " + std::to_string(e.madecount));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
char_recipe_list_entry.char_id
e.char_id
)
);
@@ -177,51 +177,51 @@ public:
static CharRecipeList InsertOne(
Database& db,
CharRecipeList char_recipe_list_entry
CharRecipeList e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(char_recipe_list_entry.char_id));
insert_values.push_back(std::to_string(char_recipe_list_entry.recipe_id));
insert_values.push_back(std::to_string(char_recipe_list_entry.madecount));
v.push_back(std::to_string(e.char_id));
v.push_back(std::to_string(e.recipe_id));
v.push_back(std::to_string(e.madecount));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
char_recipe_list_entry.char_id = results.LastInsertedID();
return char_recipe_list_entry;
e.char_id = results.LastInsertedID();
return e;
}
char_recipe_list_entry = NewEntity();
e = NewEntity();
return char_recipe_list_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharRecipeList> char_recipe_list_entries
const std::vector<CharRecipeList> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &char_recipe_list_entry: char_recipe_list_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(char_recipe_list_entry.char_id));
insert_values.push_back(std::to_string(char_recipe_list_entry.recipe_id));
insert_values.push_back(std::to_string(char_recipe_list_entry.madecount));
v.push_back(std::to_string(e.char_id));
v.push_back(std::to_string(e.recipe_id));
v.push_back(std::to_string(e.madecount));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -248,19 +248,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharRecipeList entry{};
CharRecipeList e{};
entry.char_id = atoi(row[0]);
entry.recipe_id = atoi(row[1]);
entry.madecount = atoi(row[2]);
e.char_id = atoi(row[0]);
e.recipe_id = atoi(row[1]);
e.madecount = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharRecipeList> GetWhere(Database& db, std::string where_filter)
static std::vector<CharRecipeList> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharRecipeList> all_entries;
@@ -275,19 +275,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharRecipeList entry{};
CharRecipeList e{};
entry.char_id = atoi(row[0]);
entry.recipe_id = atoi(row[1]);
entry.madecount = atoi(row[2]);
e.char_id = atoi(row[0]);
e.recipe_id = atoi(row[1]);
e.madecount = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -312,6 +312,32 @@ public:
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_CHAR_RECIPE_LIST_REPOSITORY_H
@@ -88,18 +88,18 @@ public:
static CharacterActivities NewEntity()
{
CharacterActivities entry{};
CharacterActivities e{};
entry.charid = 0;
entry.taskid = 0;
entry.activityid = 0;
entry.donecount = 0;
entry.completed = 0;
e.charid = 0;
e.taskid = 0;
e.activityid = 0;
e.donecount = 0;
e.completed = 0;
return entry;
return e;
}
static CharacterActivities GetCharacterActivitiesEntry(
static CharacterActivities GetCharacterActivities(
const std::vector<CharacterActivities> &character_activitiess,
int character_activities_id
)
@@ -128,15 +128,15 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterActivities entry{};
CharacterActivities e{};
entry.charid = atoi(row[0]);
entry.taskid = atoi(row[1]);
entry.activityid = atoi(row[2]);
entry.donecount = atoi(row[3]);
entry.completed = atoi(row[4]);
e.charid = atoi(row[0]);
e.taskid = atoi(row[1]);
e.activityid = atoi(row[2]);
e.donecount = atoi(row[3]);
e.completed = atoi(row[4]);
return entry;
return e;
}
return NewEntity();
@@ -161,26 +161,26 @@ public:
static int UpdateOne(
Database& db,
CharacterActivities character_activities_entry
const CharacterActivities &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(character_activities_entry.charid));
update_values.push_back(columns[1] + " = " + std::to_string(character_activities_entry.taskid));
update_values.push_back(columns[2] + " = " + std::to_string(character_activities_entry.activityid));
update_values.push_back(columns[3] + " = " + std::to_string(character_activities_entry.donecount));
update_values.push_back(columns[4] + " = " + std::to_string(character_activities_entry.completed));
v.push_back(columns[0] + " = " + std::to_string(e.charid));
v.push_back(columns[1] + " = " + std::to_string(e.taskid));
v.push_back(columns[2] + " = " + std::to_string(e.activityid));
v.push_back(columns[3] + " = " + std::to_string(e.donecount));
v.push_back(columns[4] + " = " + std::to_string(e.completed));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_activities_entry.charid
e.charid
)
);
@@ -189,55 +189,55 @@ public:
static CharacterActivities InsertOne(
Database& db,
CharacterActivities character_activities_entry
CharacterActivities e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_activities_entry.charid));
insert_values.push_back(std::to_string(character_activities_entry.taskid));
insert_values.push_back(std::to_string(character_activities_entry.activityid));
insert_values.push_back(std::to_string(character_activities_entry.donecount));
insert_values.push_back(std::to_string(character_activities_entry.completed));
v.push_back(std::to_string(e.charid));
v.push_back(std::to_string(e.taskid));
v.push_back(std::to_string(e.activityid));
v.push_back(std::to_string(e.donecount));
v.push_back(std::to_string(e.completed));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_activities_entry.charid = results.LastInsertedID();
return character_activities_entry;
e.charid = results.LastInsertedID();
return e;
}
character_activities_entry = NewEntity();
e = NewEntity();
return character_activities_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterActivities> character_activities_entries
const std::vector<CharacterActivities> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_activities_entry: character_activities_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_activities_entry.charid));
insert_values.push_back(std::to_string(character_activities_entry.taskid));
insert_values.push_back(std::to_string(character_activities_entry.activityid));
insert_values.push_back(std::to_string(character_activities_entry.donecount));
insert_values.push_back(std::to_string(character_activities_entry.completed));
v.push_back(std::to_string(e.charid));
v.push_back(std::to_string(e.taskid));
v.push_back(std::to_string(e.activityid));
v.push_back(std::to_string(e.donecount));
v.push_back(std::to_string(e.completed));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -264,21 +264,21 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterActivities entry{};
CharacterActivities e{};
entry.charid = atoi(row[0]);
entry.taskid = atoi(row[1]);
entry.activityid = atoi(row[2]);
entry.donecount = atoi(row[3]);
entry.completed = atoi(row[4]);
e.charid = atoi(row[0]);
e.taskid = atoi(row[1]);
e.activityid = atoi(row[2]);
e.donecount = atoi(row[3]);
e.completed = atoi(row[4]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterActivities> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterActivities> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterActivities> all_entries;
@@ -293,21 +293,21 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterActivities entry{};
CharacterActivities e{};
entry.charid = atoi(row[0]);
entry.taskid = atoi(row[1]);
entry.activityid = atoi(row[2]);
entry.donecount = atoi(row[3]);
entry.completed = atoi(row[4]);
e.charid = atoi(row[0]);
e.taskid = atoi(row[1]);
e.activityid = atoi(row[2]);
e.donecount = atoi(row[3]);
e.completed = atoi(row[4]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -332,6 +332,32 @@ public:
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_CHARACTER_ACTIVITIES_REPOSITORY_H
@@ -82,16 +82,16 @@ public:
static CharacterAltCurrency NewEntity()
{
CharacterAltCurrency entry{};
CharacterAltCurrency e{};
entry.char_id = 0;
entry.currency_id = 0;
entry.amount = 0;
e.char_id = 0;
e.currency_id = 0;
e.amount = 0;
return entry;
return e;
}
static CharacterAltCurrency GetCharacterAltCurrencyEntry(
static CharacterAltCurrency GetCharacterAltCurrency(
const std::vector<CharacterAltCurrency> &character_alt_currencys,
int character_alt_currency_id
)
@@ -120,13 +120,13 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterAltCurrency entry{};
CharacterAltCurrency e{};
entry.char_id = atoi(row[0]);
entry.currency_id = atoi(row[1]);
entry.amount = atoi(row[2]);
e.char_id = atoi(row[0]);
e.currency_id = atoi(row[1]);
e.amount = atoi(row[2]);
return entry;
return e;
}
return NewEntity();
@@ -151,24 +151,24 @@ public:
static int UpdateOne(
Database& db,
CharacterAltCurrency character_alt_currency_entry
const CharacterAltCurrency &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(character_alt_currency_entry.char_id));
update_values.push_back(columns[1] + " = " + std::to_string(character_alt_currency_entry.currency_id));
update_values.push_back(columns[2] + " = " + std::to_string(character_alt_currency_entry.amount));
v.push_back(columns[0] + " = " + std::to_string(e.char_id));
v.push_back(columns[1] + " = " + std::to_string(e.currency_id));
v.push_back(columns[2] + " = " + std::to_string(e.amount));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_alt_currency_entry.char_id
e.char_id
)
);
@@ -177,51 +177,51 @@ public:
static CharacterAltCurrency InsertOne(
Database& db,
CharacterAltCurrency character_alt_currency_entry
CharacterAltCurrency e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_alt_currency_entry.char_id));
insert_values.push_back(std::to_string(character_alt_currency_entry.currency_id));
insert_values.push_back(std::to_string(character_alt_currency_entry.amount));
v.push_back(std::to_string(e.char_id));
v.push_back(std::to_string(e.currency_id));
v.push_back(std::to_string(e.amount));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_alt_currency_entry.char_id = results.LastInsertedID();
return character_alt_currency_entry;
e.char_id = results.LastInsertedID();
return e;
}
character_alt_currency_entry = NewEntity();
e = NewEntity();
return character_alt_currency_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterAltCurrency> character_alt_currency_entries
const std::vector<CharacterAltCurrency> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_alt_currency_entry: character_alt_currency_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_alt_currency_entry.char_id));
insert_values.push_back(std::to_string(character_alt_currency_entry.currency_id));
insert_values.push_back(std::to_string(character_alt_currency_entry.amount));
v.push_back(std::to_string(e.char_id));
v.push_back(std::to_string(e.currency_id));
v.push_back(std::to_string(e.amount));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -248,19 +248,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterAltCurrency entry{};
CharacterAltCurrency e{};
entry.char_id = atoi(row[0]);
entry.currency_id = atoi(row[1]);
entry.amount = atoi(row[2]);
e.char_id = atoi(row[0]);
e.currency_id = atoi(row[1]);
e.amount = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterAltCurrency> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterAltCurrency> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterAltCurrency> all_entries;
@@ -275,19 +275,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterAltCurrency entry{};
CharacterAltCurrency e{};
entry.char_id = atoi(row[0]);
entry.currency_id = atoi(row[1]);
entry.amount = atoi(row[2]);
e.char_id = atoi(row[0]);
e.currency_id = atoi(row[1]);
e.amount = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -312,6 +312,32 @@ public:
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_CHARACTER_ALT_CURRENCY_REPOSITORY_H
@@ -85,17 +85,17 @@ public:
static CharacterAlternateAbilities NewEntity()
{
CharacterAlternateAbilities entry{};
CharacterAlternateAbilities e{};
entry.id = 0;
entry.aa_id = 0;
entry.aa_value = 0;
entry.charges = 0;
e.id = 0;
e.aa_id = 0;
e.aa_value = 0;
e.charges = 0;
return entry;
return e;
}
static CharacterAlternateAbilities GetCharacterAlternateAbilitiesEntry(
static CharacterAlternateAbilities GetCharacterAlternateAbilities(
const std::vector<CharacterAlternateAbilities> &character_alternate_abilitiess,
int character_alternate_abilities_id
)
@@ -124,14 +124,14 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterAlternateAbilities entry{};
CharacterAlternateAbilities e{};
entry.id = atoi(row[0]);
entry.aa_id = atoi(row[1]);
entry.aa_value = atoi(row[2]);
entry.charges = atoi(row[3]);
e.id = atoi(row[0]);
e.aa_id = atoi(row[1]);
e.aa_value = atoi(row[2]);
e.charges = atoi(row[3]);
return entry;
return e;
}
return NewEntity();
@@ -156,25 +156,25 @@ public:
static int UpdateOne(
Database& db,
CharacterAlternateAbilities character_alternate_abilities_entry
const CharacterAlternateAbilities &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(character_alternate_abilities_entry.id));
update_values.push_back(columns[1] + " = " + std::to_string(character_alternate_abilities_entry.aa_id));
update_values.push_back(columns[2] + " = " + std::to_string(character_alternate_abilities_entry.aa_value));
update_values.push_back(columns[3] + " = " + std::to_string(character_alternate_abilities_entry.charges));
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = " + std::to_string(e.aa_id));
v.push_back(columns[2] + " = " + std::to_string(e.aa_value));
v.push_back(columns[3] + " = " + std::to_string(e.charges));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_alternate_abilities_entry.id
e.id
)
);
@@ -183,53 +183,53 @@ public:
static CharacterAlternateAbilities InsertOne(
Database& db,
CharacterAlternateAbilities character_alternate_abilities_entry
CharacterAlternateAbilities e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_alternate_abilities_entry.id));
insert_values.push_back(std::to_string(character_alternate_abilities_entry.aa_id));
insert_values.push_back(std::to_string(character_alternate_abilities_entry.aa_value));
insert_values.push_back(std::to_string(character_alternate_abilities_entry.charges));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.aa_id));
v.push_back(std::to_string(e.aa_value));
v.push_back(std::to_string(e.charges));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_alternate_abilities_entry.id = results.LastInsertedID();
return character_alternate_abilities_entry;
e.id = results.LastInsertedID();
return e;
}
character_alternate_abilities_entry = NewEntity();
e = NewEntity();
return character_alternate_abilities_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterAlternateAbilities> character_alternate_abilities_entries
const std::vector<CharacterAlternateAbilities> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_alternate_abilities_entry: character_alternate_abilities_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_alternate_abilities_entry.id));
insert_values.push_back(std::to_string(character_alternate_abilities_entry.aa_id));
insert_values.push_back(std::to_string(character_alternate_abilities_entry.aa_value));
insert_values.push_back(std::to_string(character_alternate_abilities_entry.charges));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.aa_id));
v.push_back(std::to_string(e.aa_value));
v.push_back(std::to_string(e.charges));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -256,20 +256,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterAlternateAbilities entry{};
CharacterAlternateAbilities e{};
entry.id = atoi(row[0]);
entry.aa_id = atoi(row[1]);
entry.aa_value = atoi(row[2]);
entry.charges = atoi(row[3]);
e.id = atoi(row[0]);
e.aa_id = atoi(row[1]);
e.aa_value = atoi(row[2]);
e.charges = atoi(row[3]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterAlternateAbilities> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterAlternateAbilities> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterAlternateAbilities> all_entries;
@@ -284,20 +284,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterAlternateAbilities entry{};
CharacterAlternateAbilities e{};
entry.id = atoi(row[0]);
entry.aa_id = atoi(row[1]);
entry.aa_value = atoi(row[2]);
entry.charges = atoi(row[3]);
e.id = atoi(row[0]);
e.aa_id = atoi(row[1]);
e.aa_value = atoi(row[2]);
e.charges = atoi(row[3]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -322,6 +322,32 @@ public:
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_CHARACTER_ALTERNATE_ABILITIES_REPOSITORY_H
@@ -82,16 +82,16 @@ public:
static CharacterAuras NewEntity()
{
CharacterAuras entry{};
CharacterAuras e{};
entry.id = 0;
entry.slot = 0;
entry.spell_id = 0;
e.id = 0;
e.slot = 0;
e.spell_id = 0;
return entry;
return e;
}
static CharacterAuras GetCharacterAurasEntry(
static CharacterAuras GetCharacterAuras(
const std::vector<CharacterAuras> &character_aurass,
int character_auras_id
)
@@ -120,13 +120,13 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterAuras entry{};
CharacterAuras e{};
entry.id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.spell_id = atoi(row[2]);
e.id = atoi(row[0]);
e.slot = atoi(row[1]);
e.spell_id = atoi(row[2]);
return entry;
return e;
}
return NewEntity();
@@ -151,24 +151,24 @@ public:
static int UpdateOne(
Database& db,
CharacterAuras character_auras_entry
const CharacterAuras &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(character_auras_entry.id));
update_values.push_back(columns[1] + " = " + std::to_string(character_auras_entry.slot));
update_values.push_back(columns[2] + " = " + std::to_string(character_auras_entry.spell_id));
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = " + std::to_string(e.slot));
v.push_back(columns[2] + " = " + std::to_string(e.spell_id));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_auras_entry.id
e.id
)
);
@@ -177,51 +177,51 @@ public:
static CharacterAuras InsertOne(
Database& db,
CharacterAuras character_auras_entry
CharacterAuras e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_auras_entry.id));
insert_values.push_back(std::to_string(character_auras_entry.slot));
insert_values.push_back(std::to_string(character_auras_entry.spell_id));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.slot));
v.push_back(std::to_string(e.spell_id));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_auras_entry.id = results.LastInsertedID();
return character_auras_entry;
e.id = results.LastInsertedID();
return e;
}
character_auras_entry = NewEntity();
e = NewEntity();
return character_auras_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterAuras> character_auras_entries
const std::vector<CharacterAuras> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_auras_entry: character_auras_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_auras_entry.id));
insert_values.push_back(std::to_string(character_auras_entry.slot));
insert_values.push_back(std::to_string(character_auras_entry.spell_id));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.slot));
v.push_back(std::to_string(e.spell_id));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -248,19 +248,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterAuras entry{};
CharacterAuras e{};
entry.id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.spell_id = atoi(row[2]);
e.id = atoi(row[0]);
e.slot = atoi(row[1]);
e.spell_id = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterAuras> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterAuras> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterAuras> all_entries;
@@ -275,19 +275,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterAuras entry{};
CharacterAuras e{};
entry.id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.spell_id = atoi(row[2]);
e.id = atoi(row[0]);
e.slot = atoi(row[1]);
e.spell_id = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -312,6 +312,32 @@ public:
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_CHARACTER_AURAS_REPOSITORY_H
@@ -91,19 +91,19 @@ public:
static CharacterBandolier NewEntity()
{
CharacterBandolier entry{};
CharacterBandolier e{};
entry.id = 0;
entry.bandolier_id = 0;
entry.bandolier_slot = 0;
entry.item_id = 0;
entry.icon = 0;
entry.bandolier_name = "0";
e.id = 0;
e.bandolier_id = 0;
e.bandolier_slot = 0;
e.item_id = 0;
e.icon = 0;
e.bandolier_name = "0";
return entry;
return e;
}
static CharacterBandolier GetCharacterBandolierEntry(
static CharacterBandolier GetCharacterBandolier(
const std::vector<CharacterBandolier> &character_bandoliers,
int character_bandolier_id
)
@@ -132,16 +132,16 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterBandolier entry{};
CharacterBandolier e{};
entry.id = atoi(row[0]);
entry.bandolier_id = atoi(row[1]);
entry.bandolier_slot = atoi(row[2]);
entry.item_id = atoi(row[3]);
entry.icon = atoi(row[4]);
entry.bandolier_name = row[5] ? row[5] : "";
e.id = atoi(row[0]);
e.bandolier_id = atoi(row[1]);
e.bandolier_slot = atoi(row[2]);
e.item_id = atoi(row[3]);
e.icon = atoi(row[4]);
e.bandolier_name = row[5] ? row[5] : "";
return entry;
return e;
}
return NewEntity();
@@ -166,27 +166,27 @@ public:
static int UpdateOne(
Database& db,
CharacterBandolier character_bandolier_entry
const CharacterBandolier &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(character_bandolier_entry.id));
update_values.push_back(columns[1] + " = " + std::to_string(character_bandolier_entry.bandolier_id));
update_values.push_back(columns[2] + " = " + std::to_string(character_bandolier_entry.bandolier_slot));
update_values.push_back(columns[3] + " = " + std::to_string(character_bandolier_entry.item_id));
update_values.push_back(columns[4] + " = " + std::to_string(character_bandolier_entry.icon));
update_values.push_back(columns[5] + " = '" + Strings::Escape(character_bandolier_entry.bandolier_name) + "'");
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = " + std::to_string(e.bandolier_id));
v.push_back(columns[2] + " = " + std::to_string(e.bandolier_slot));
v.push_back(columns[3] + " = " + std::to_string(e.item_id));
v.push_back(columns[4] + " = " + std::to_string(e.icon));
v.push_back(columns[5] + " = '" + Strings::Escape(e.bandolier_name) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_bandolier_entry.id
e.id
)
);
@@ -195,57 +195,57 @@ public:
static CharacterBandolier InsertOne(
Database& db,
CharacterBandolier character_bandolier_entry
CharacterBandolier e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_bandolier_entry.id));
insert_values.push_back(std::to_string(character_bandolier_entry.bandolier_id));
insert_values.push_back(std::to_string(character_bandolier_entry.bandolier_slot));
insert_values.push_back(std::to_string(character_bandolier_entry.item_id));
insert_values.push_back(std::to_string(character_bandolier_entry.icon));
insert_values.push_back("'" + Strings::Escape(character_bandolier_entry.bandolier_name) + "'");
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.bandolier_id));
v.push_back(std::to_string(e.bandolier_slot));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.icon));
v.push_back("'" + Strings::Escape(e.bandolier_name) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_bandolier_entry.id = results.LastInsertedID();
return character_bandolier_entry;
e.id = results.LastInsertedID();
return e;
}
character_bandolier_entry = NewEntity();
e = NewEntity();
return character_bandolier_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterBandolier> character_bandolier_entries
const std::vector<CharacterBandolier> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_bandolier_entry: character_bandolier_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_bandolier_entry.id));
insert_values.push_back(std::to_string(character_bandolier_entry.bandolier_id));
insert_values.push_back(std::to_string(character_bandolier_entry.bandolier_slot));
insert_values.push_back(std::to_string(character_bandolier_entry.item_id));
insert_values.push_back(std::to_string(character_bandolier_entry.icon));
insert_values.push_back("'" + Strings::Escape(character_bandolier_entry.bandolier_name) + "'");
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.bandolier_id));
v.push_back(std::to_string(e.bandolier_slot));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.icon));
v.push_back("'" + Strings::Escape(e.bandolier_name) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -272,22 +272,22 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterBandolier entry{};
CharacterBandolier e{};
entry.id = atoi(row[0]);
entry.bandolier_id = atoi(row[1]);
entry.bandolier_slot = atoi(row[2]);
entry.item_id = atoi(row[3]);
entry.icon = atoi(row[4]);
entry.bandolier_name = row[5] ? row[5] : "";
e.id = atoi(row[0]);
e.bandolier_id = atoi(row[1]);
e.bandolier_slot = atoi(row[2]);
e.item_id = atoi(row[3]);
e.icon = atoi(row[4]);
e.bandolier_name = row[5] ? row[5] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterBandolier> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterBandolier> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterBandolier> all_entries;
@@ -302,22 +302,22 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterBandolier entry{};
CharacterBandolier e{};
entry.id = atoi(row[0]);
entry.bandolier_id = atoi(row[1]);
entry.bandolier_slot = atoi(row[2]);
entry.item_id = atoi(row[3]);
entry.icon = atoi(row[4]);
entry.bandolier_name = row[5] ? row[5] : "";
e.id = atoi(row[0]);
e.bandolier_id = atoi(row[1]);
e.bandolier_slot = atoi(row[2]);
e.item_id = atoi(row[3]);
e.icon = atoi(row[4]);
e.bandolier_name = row[5] ? row[5] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -342,6 +342,32 @@ public:
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_CHARACTER_BANDOLIER_REPOSITORY_H
@@ -97,21 +97,21 @@ public:
static CharacterBind NewEntity()
{
CharacterBind entry{};
CharacterBind e{};
entry.id = 0;
entry.slot = 0;
entry.zone_id = 0;
entry.instance_id = 0;
entry.x = 0;
entry.y = 0;
entry.z = 0;
entry.heading = 0;
e.id = 0;
e.slot = 0;
e.zone_id = 0;
e.instance_id = 0;
e.x = 0;
e.y = 0;
e.z = 0;
e.heading = 0;
return entry;
return e;
}
static CharacterBind GetCharacterBindEntry(
static CharacterBind GetCharacterBind(
const std::vector<CharacterBind> &character_binds,
int character_bind_id
)
@@ -140,18 +140,18 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterBind entry{};
CharacterBind e{};
entry.id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.zone_id = atoi(row[2]);
entry.instance_id = atoi(row[3]);
entry.x = static_cast<float>(atof(row[4]));
entry.y = static_cast<float>(atof(row[5]));
entry.z = static_cast<float>(atof(row[6]));
entry.heading = static_cast<float>(atof(row[7]));
e.id = atoi(row[0]);
e.slot = atoi(row[1]);
e.zone_id = atoi(row[2]);
e.instance_id = atoi(row[3]);
e.x = static_cast<float>(atof(row[4]));
e.y = static_cast<float>(atof(row[5]));
e.z = static_cast<float>(atof(row[6]));
e.heading = static_cast<float>(atof(row[7]));
return entry;
return e;
}
return NewEntity();
@@ -176,28 +176,28 @@ public:
static int UpdateOne(
Database& db,
CharacterBind character_bind_entry
const CharacterBind &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(character_bind_entry.slot));
update_values.push_back(columns[2] + " = " + std::to_string(character_bind_entry.zone_id));
update_values.push_back(columns[3] + " = " + std::to_string(character_bind_entry.instance_id));
update_values.push_back(columns[4] + " = " + std::to_string(character_bind_entry.x));
update_values.push_back(columns[5] + " = " + std::to_string(character_bind_entry.y));
update_values.push_back(columns[6] + " = " + std::to_string(character_bind_entry.z));
update_values.push_back(columns[7] + " = " + std::to_string(character_bind_entry.heading));
v.push_back(columns[1] + " = " + std::to_string(e.slot));
v.push_back(columns[2] + " = " + std::to_string(e.zone_id));
v.push_back(columns[3] + " = " + std::to_string(e.instance_id));
v.push_back(columns[4] + " = " + std::to_string(e.x));
v.push_back(columns[5] + " = " + std::to_string(e.y));
v.push_back(columns[6] + " = " + std::to_string(e.z));
v.push_back(columns[7] + " = " + std::to_string(e.heading));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_bind_entry.id
e.id
)
);
@@ -206,61 +206,61 @@ public:
static CharacterBind InsertOne(
Database& db,
CharacterBind character_bind_entry
CharacterBind e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_bind_entry.id));
insert_values.push_back(std::to_string(character_bind_entry.slot));
insert_values.push_back(std::to_string(character_bind_entry.zone_id));
insert_values.push_back(std::to_string(character_bind_entry.instance_id));
insert_values.push_back(std::to_string(character_bind_entry.x));
insert_values.push_back(std::to_string(character_bind_entry.y));
insert_values.push_back(std::to_string(character_bind_entry.z));
insert_values.push_back(std::to_string(character_bind_entry.heading));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.slot));
v.push_back(std::to_string(e.zone_id));
v.push_back(std::to_string(e.instance_id));
v.push_back(std::to_string(e.x));
v.push_back(std::to_string(e.y));
v.push_back(std::to_string(e.z));
v.push_back(std::to_string(e.heading));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_bind_entry.id = results.LastInsertedID();
return character_bind_entry;
e.id = results.LastInsertedID();
return e;
}
character_bind_entry = NewEntity();
e = NewEntity();
return character_bind_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterBind> character_bind_entries
const std::vector<CharacterBind> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_bind_entry: character_bind_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_bind_entry.id));
insert_values.push_back(std::to_string(character_bind_entry.slot));
insert_values.push_back(std::to_string(character_bind_entry.zone_id));
insert_values.push_back(std::to_string(character_bind_entry.instance_id));
insert_values.push_back(std::to_string(character_bind_entry.x));
insert_values.push_back(std::to_string(character_bind_entry.y));
insert_values.push_back(std::to_string(character_bind_entry.z));
insert_values.push_back(std::to_string(character_bind_entry.heading));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.slot));
v.push_back(std::to_string(e.zone_id));
v.push_back(std::to_string(e.instance_id));
v.push_back(std::to_string(e.x));
v.push_back(std::to_string(e.y));
v.push_back(std::to_string(e.z));
v.push_back(std::to_string(e.heading));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -287,24 +287,24 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterBind entry{};
CharacterBind e{};
entry.id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.zone_id = atoi(row[2]);
entry.instance_id = atoi(row[3]);
entry.x = static_cast<float>(atof(row[4]));
entry.y = static_cast<float>(atof(row[5]));
entry.z = static_cast<float>(atof(row[6]));
entry.heading = static_cast<float>(atof(row[7]));
e.id = atoi(row[0]);
e.slot = atoi(row[1]);
e.zone_id = atoi(row[2]);
e.instance_id = atoi(row[3]);
e.x = static_cast<float>(atof(row[4]));
e.y = static_cast<float>(atof(row[5]));
e.z = static_cast<float>(atof(row[6]));
e.heading = static_cast<float>(atof(row[7]));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterBind> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterBind> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterBind> all_entries;
@@ -319,24 +319,24 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterBind entry{};
CharacterBind e{};
entry.id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.zone_id = atoi(row[2]);
entry.instance_id = atoi(row[3]);
entry.x = static_cast<float>(atof(row[4]));
entry.y = static_cast<float>(atof(row[5]));
entry.z = static_cast<float>(atof(row[6]));
entry.heading = static_cast<float>(atof(row[7]));
e.id = atoi(row[0]);
e.slot = atoi(row[1]);
e.zone_id = atoi(row[2]);
e.instance_id = atoi(row[3]);
e.x = static_cast<float>(atof(row[4]));
e.y = static_cast<float>(atof(row[5]));
e.z = static_cast<float>(atof(row[6]));
e.heading = static_cast<float>(atof(row[7]));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -361,6 +361,32 @@ public:
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_CHARACTER_BIND_REPOSITORY_H
@@ -124,30 +124,30 @@ public:
static CharacterBuffs NewEntity()
{
CharacterBuffs entry{};
CharacterBuffs e{};
entry.character_id = 0;
entry.slot_id = 0;
entry.spell_id = 0;
entry.caster_level = 0;
entry.caster_name = "";
entry.ticsremaining = 0;
entry.counters = 0;
entry.numhits = 0;
entry.melee_rune = 0;
entry.magic_rune = 0;
entry.persistent = 0;
entry.dot_rune = 0;
entry.caston_x = 0;
entry.caston_y = 0;
entry.caston_z = 0;
entry.ExtraDIChance = 0;
entry.instrument_mod = 10;
e.character_id = 0;
e.slot_id = 0;
e.spell_id = 0;
e.caster_level = 0;
e.caster_name = "";
e.ticsremaining = 0;
e.counters = 0;
e.numhits = 0;
e.melee_rune = 0;
e.magic_rune = 0;
e.persistent = 0;
e.dot_rune = 0;
e.caston_x = 0;
e.caston_y = 0;
e.caston_z = 0;
e.ExtraDIChance = 0;
e.instrument_mod = 10;
return entry;
return e;
}
static CharacterBuffs GetCharacterBuffsEntry(
static CharacterBuffs GetCharacterBuffs(
const std::vector<CharacterBuffs> &character_buffss,
int character_buffs_id
)
@@ -176,27 +176,27 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterBuffs entry{};
CharacterBuffs e{};
entry.character_id = atoi(row[0]);
entry.slot_id = atoi(row[1]);
entry.spell_id = atoi(row[2]);
entry.caster_level = atoi(row[3]);
entry.caster_name = row[4] ? row[4] : "";
entry.ticsremaining = atoi(row[5]);
entry.counters = atoi(row[6]);
entry.numhits = atoi(row[7]);
entry.melee_rune = atoi(row[8]);
entry.magic_rune = atoi(row[9]);
entry.persistent = atoi(row[10]);
entry.dot_rune = atoi(row[11]);
entry.caston_x = atoi(row[12]);
entry.caston_y = atoi(row[13]);
entry.caston_z = atoi(row[14]);
entry.ExtraDIChance = atoi(row[15]);
entry.instrument_mod = atoi(row[16]);
e.character_id = atoi(row[0]);
e.slot_id = atoi(row[1]);
e.spell_id = atoi(row[2]);
e.caster_level = atoi(row[3]);
e.caster_name = row[4] ? row[4] : "";
e.ticsremaining = atoi(row[5]);
e.counters = atoi(row[6]);
e.numhits = atoi(row[7]);
e.melee_rune = atoi(row[8]);
e.magic_rune = atoi(row[9]);
e.persistent = atoi(row[10]);
e.dot_rune = atoi(row[11]);
e.caston_x = atoi(row[12]);
e.caston_y = atoi(row[13]);
e.caston_z = atoi(row[14]);
e.ExtraDIChance = atoi(row[15]);
e.instrument_mod = atoi(row[16]);
return entry;
return e;
}
return NewEntity();
@@ -221,38 +221,38 @@ public:
static int UpdateOne(
Database& db,
CharacterBuffs character_buffs_entry
const CharacterBuffs &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(character_buffs_entry.character_id));
update_values.push_back(columns[1] + " = " + std::to_string(character_buffs_entry.slot_id));
update_values.push_back(columns[2] + " = " + std::to_string(character_buffs_entry.spell_id));
update_values.push_back(columns[3] + " = " + std::to_string(character_buffs_entry.caster_level));
update_values.push_back(columns[4] + " = '" + Strings::Escape(character_buffs_entry.caster_name) + "'");
update_values.push_back(columns[5] + " = " + std::to_string(character_buffs_entry.ticsremaining));
update_values.push_back(columns[6] + " = " + std::to_string(character_buffs_entry.counters));
update_values.push_back(columns[7] + " = " + std::to_string(character_buffs_entry.numhits));
update_values.push_back(columns[8] + " = " + std::to_string(character_buffs_entry.melee_rune));
update_values.push_back(columns[9] + " = " + std::to_string(character_buffs_entry.magic_rune));
update_values.push_back(columns[10] + " = " + std::to_string(character_buffs_entry.persistent));
update_values.push_back(columns[11] + " = " + std::to_string(character_buffs_entry.dot_rune));
update_values.push_back(columns[12] + " = " + std::to_string(character_buffs_entry.caston_x));
update_values.push_back(columns[13] + " = " + std::to_string(character_buffs_entry.caston_y));
update_values.push_back(columns[14] + " = " + std::to_string(character_buffs_entry.caston_z));
update_values.push_back(columns[15] + " = " + std::to_string(character_buffs_entry.ExtraDIChance));
update_values.push_back(columns[16] + " = " + std::to_string(character_buffs_entry.instrument_mod));
v.push_back(columns[0] + " = " + std::to_string(e.character_id));
v.push_back(columns[1] + " = " + std::to_string(e.slot_id));
v.push_back(columns[2] + " = " + std::to_string(e.spell_id));
v.push_back(columns[3] + " = " + std::to_string(e.caster_level));
v.push_back(columns[4] + " = '" + Strings::Escape(e.caster_name) + "'");
v.push_back(columns[5] + " = " + std::to_string(e.ticsremaining));
v.push_back(columns[6] + " = " + std::to_string(e.counters));
v.push_back(columns[7] + " = " + std::to_string(e.numhits));
v.push_back(columns[8] + " = " + std::to_string(e.melee_rune));
v.push_back(columns[9] + " = " + std::to_string(e.magic_rune));
v.push_back(columns[10] + " = " + std::to_string(e.persistent));
v.push_back(columns[11] + " = " + std::to_string(e.dot_rune));
v.push_back(columns[12] + " = " + std::to_string(e.caston_x));
v.push_back(columns[13] + " = " + std::to_string(e.caston_y));
v.push_back(columns[14] + " = " + std::to_string(e.caston_z));
v.push_back(columns[15] + " = " + std::to_string(e.ExtraDIChance));
v.push_back(columns[16] + " = " + std::to_string(e.instrument_mod));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_buffs_entry.character_id
e.character_id
)
);
@@ -261,79 +261,79 @@ public:
static CharacterBuffs InsertOne(
Database& db,
CharacterBuffs character_buffs_entry
CharacterBuffs e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_buffs_entry.character_id));
insert_values.push_back(std::to_string(character_buffs_entry.slot_id));
insert_values.push_back(std::to_string(character_buffs_entry.spell_id));
insert_values.push_back(std::to_string(character_buffs_entry.caster_level));
insert_values.push_back("'" + Strings::Escape(character_buffs_entry.caster_name) + "'");
insert_values.push_back(std::to_string(character_buffs_entry.ticsremaining));
insert_values.push_back(std::to_string(character_buffs_entry.counters));
insert_values.push_back(std::to_string(character_buffs_entry.numhits));
insert_values.push_back(std::to_string(character_buffs_entry.melee_rune));
insert_values.push_back(std::to_string(character_buffs_entry.magic_rune));
insert_values.push_back(std::to_string(character_buffs_entry.persistent));
insert_values.push_back(std::to_string(character_buffs_entry.dot_rune));
insert_values.push_back(std::to_string(character_buffs_entry.caston_x));
insert_values.push_back(std::to_string(character_buffs_entry.caston_y));
insert_values.push_back(std::to_string(character_buffs_entry.caston_z));
insert_values.push_back(std::to_string(character_buffs_entry.ExtraDIChance));
insert_values.push_back(std::to_string(character_buffs_entry.instrument_mod));
v.push_back(std::to_string(e.character_id));
v.push_back(std::to_string(e.slot_id));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.caster_level));
v.push_back("'" + Strings::Escape(e.caster_name) + "'");
v.push_back(std::to_string(e.ticsremaining));
v.push_back(std::to_string(e.counters));
v.push_back(std::to_string(e.numhits));
v.push_back(std::to_string(e.melee_rune));
v.push_back(std::to_string(e.magic_rune));
v.push_back(std::to_string(e.persistent));
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.caston_y));
v.push_back(std::to_string(e.caston_z));
v.push_back(std::to_string(e.ExtraDIChance));
v.push_back(std::to_string(e.instrument_mod));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_buffs_entry.character_id = results.LastInsertedID();
return character_buffs_entry;
e.character_id = results.LastInsertedID();
return e;
}
character_buffs_entry = NewEntity();
e = NewEntity();
return character_buffs_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterBuffs> character_buffs_entries
const std::vector<CharacterBuffs> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_buffs_entry: character_buffs_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_buffs_entry.character_id));
insert_values.push_back(std::to_string(character_buffs_entry.slot_id));
insert_values.push_back(std::to_string(character_buffs_entry.spell_id));
insert_values.push_back(std::to_string(character_buffs_entry.caster_level));
insert_values.push_back("'" + Strings::Escape(character_buffs_entry.caster_name) + "'");
insert_values.push_back(std::to_string(character_buffs_entry.ticsremaining));
insert_values.push_back(std::to_string(character_buffs_entry.counters));
insert_values.push_back(std::to_string(character_buffs_entry.numhits));
insert_values.push_back(std::to_string(character_buffs_entry.melee_rune));
insert_values.push_back(std::to_string(character_buffs_entry.magic_rune));
insert_values.push_back(std::to_string(character_buffs_entry.persistent));
insert_values.push_back(std::to_string(character_buffs_entry.dot_rune));
insert_values.push_back(std::to_string(character_buffs_entry.caston_x));
insert_values.push_back(std::to_string(character_buffs_entry.caston_y));
insert_values.push_back(std::to_string(character_buffs_entry.caston_z));
insert_values.push_back(std::to_string(character_buffs_entry.ExtraDIChance));
insert_values.push_back(std::to_string(character_buffs_entry.instrument_mod));
v.push_back(std::to_string(e.character_id));
v.push_back(std::to_string(e.slot_id));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.caster_level));
v.push_back("'" + Strings::Escape(e.caster_name) + "'");
v.push_back(std::to_string(e.ticsremaining));
v.push_back(std::to_string(e.counters));
v.push_back(std::to_string(e.numhits));
v.push_back(std::to_string(e.melee_rune));
v.push_back(std::to_string(e.magic_rune));
v.push_back(std::to_string(e.persistent));
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.caston_y));
v.push_back(std::to_string(e.caston_z));
v.push_back(std::to_string(e.ExtraDIChance));
v.push_back(std::to_string(e.instrument_mod));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -360,33 +360,33 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterBuffs entry{};
CharacterBuffs e{};
entry.character_id = atoi(row[0]);
entry.slot_id = atoi(row[1]);
entry.spell_id = atoi(row[2]);
entry.caster_level = atoi(row[3]);
entry.caster_name = row[4] ? row[4] : "";
entry.ticsremaining = atoi(row[5]);
entry.counters = atoi(row[6]);
entry.numhits = atoi(row[7]);
entry.melee_rune = atoi(row[8]);
entry.magic_rune = atoi(row[9]);
entry.persistent = atoi(row[10]);
entry.dot_rune = atoi(row[11]);
entry.caston_x = atoi(row[12]);
entry.caston_y = atoi(row[13]);
entry.caston_z = atoi(row[14]);
entry.ExtraDIChance = atoi(row[15]);
entry.instrument_mod = atoi(row[16]);
e.character_id = atoi(row[0]);
e.slot_id = atoi(row[1]);
e.spell_id = atoi(row[2]);
e.caster_level = atoi(row[3]);
e.caster_name = row[4] ? row[4] : "";
e.ticsremaining = atoi(row[5]);
e.counters = atoi(row[6]);
e.numhits = atoi(row[7]);
e.melee_rune = atoi(row[8]);
e.magic_rune = atoi(row[9]);
e.persistent = atoi(row[10]);
e.dot_rune = atoi(row[11]);
e.caston_x = atoi(row[12]);
e.caston_y = atoi(row[13]);
e.caston_z = atoi(row[14]);
e.ExtraDIChance = atoi(row[15]);
e.instrument_mod = atoi(row[16]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterBuffs> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterBuffs> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterBuffs> all_entries;
@@ -401,33 +401,33 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterBuffs entry{};
CharacterBuffs e{};
entry.character_id = atoi(row[0]);
entry.slot_id = atoi(row[1]);
entry.spell_id = atoi(row[2]);
entry.caster_level = atoi(row[3]);
entry.caster_name = row[4] ? row[4] : "";
entry.ticsremaining = atoi(row[5]);
entry.counters = atoi(row[6]);
entry.numhits = atoi(row[7]);
entry.melee_rune = atoi(row[8]);
entry.magic_rune = atoi(row[9]);
entry.persistent = atoi(row[10]);
entry.dot_rune = atoi(row[11]);
entry.caston_x = atoi(row[12]);
entry.caston_y = atoi(row[13]);
entry.caston_z = atoi(row[14]);
entry.ExtraDIChance = atoi(row[15]);
entry.instrument_mod = atoi(row[16]);
e.character_id = atoi(row[0]);
e.slot_id = atoi(row[1]);
e.spell_id = atoi(row[2]);
e.caster_level = atoi(row[3]);
e.caster_name = row[4] ? row[4] : "";
e.ticsremaining = atoi(row[5]);
e.counters = atoi(row[6]);
e.numhits = atoi(row[7]);
e.melee_rune = atoi(row[8]);
e.magic_rune = atoi(row[9]);
e.persistent = atoi(row[10]);
e.dot_rune = atoi(row[11]);
e.caston_x = atoi(row[12]);
e.caston_y = atoi(row[13]);
e.caston_z = atoi(row[14]);
e.ExtraDIChance = atoi(row[15]);
e.instrument_mod = atoi(row[16]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -452,6 +452,32 @@ public:
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_CHARACTER_BUFFS_REPOSITORY_H
@@ -106,24 +106,24 @@ public:
static CharacterCorpseItems NewEntity()
{
CharacterCorpseItems entry{};
CharacterCorpseItems e{};
entry.corpse_id = 0;
entry.equip_slot = 0;
entry.item_id = 0;
entry.charges = 0;
entry.aug_1 = 0;
entry.aug_2 = 0;
entry.aug_3 = 0;
entry.aug_4 = 0;
entry.aug_5 = 0;
entry.aug_6 = 0;
entry.attuned = 0;
e.corpse_id = 0;
e.equip_slot = 0;
e.item_id = 0;
e.charges = 0;
e.aug_1 = 0;
e.aug_2 = 0;
e.aug_3 = 0;
e.aug_4 = 0;
e.aug_5 = 0;
e.aug_6 = 0;
e.attuned = 0;
return entry;
return e;
}
static CharacterCorpseItems GetCharacterCorpseItemsEntry(
static CharacterCorpseItems GetCharacterCorpseItems(
const std::vector<CharacterCorpseItems> &character_corpse_itemss,
int character_corpse_items_id
)
@@ -152,21 +152,21 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterCorpseItems entry{};
CharacterCorpseItems e{};
entry.corpse_id = atoi(row[0]);
entry.equip_slot = atoi(row[1]);
entry.item_id = atoi(row[2]);
entry.charges = atoi(row[3]);
entry.aug_1 = atoi(row[4]);
entry.aug_2 = atoi(row[5]);
entry.aug_3 = atoi(row[6]);
entry.aug_4 = atoi(row[7]);
entry.aug_5 = atoi(row[8]);
entry.aug_6 = atoi(row[9]);
entry.attuned = atoi(row[10]);
e.corpse_id = atoi(row[0]);
e.equip_slot = atoi(row[1]);
e.item_id = atoi(row[2]);
e.charges = atoi(row[3]);
e.aug_1 = atoi(row[4]);
e.aug_2 = atoi(row[5]);
e.aug_3 = atoi(row[6]);
e.aug_4 = atoi(row[7]);
e.aug_5 = atoi(row[8]);
e.aug_6 = atoi(row[9]);
e.attuned = atoi(row[10]);
return entry;
return e;
}
return NewEntity();
@@ -191,32 +191,32 @@ public:
static int UpdateOne(
Database& db,
CharacterCorpseItems character_corpse_items_entry
const CharacterCorpseItems &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(character_corpse_items_entry.corpse_id));
update_values.push_back(columns[1] + " = " + std::to_string(character_corpse_items_entry.equip_slot));
update_values.push_back(columns[2] + " = " + std::to_string(character_corpse_items_entry.item_id));
update_values.push_back(columns[3] + " = " + std::to_string(character_corpse_items_entry.charges));
update_values.push_back(columns[4] + " = " + std::to_string(character_corpse_items_entry.aug_1));
update_values.push_back(columns[5] + " = " + std::to_string(character_corpse_items_entry.aug_2));
update_values.push_back(columns[6] + " = " + std::to_string(character_corpse_items_entry.aug_3));
update_values.push_back(columns[7] + " = " + std::to_string(character_corpse_items_entry.aug_4));
update_values.push_back(columns[8] + " = " + std::to_string(character_corpse_items_entry.aug_5));
update_values.push_back(columns[9] + " = " + std::to_string(character_corpse_items_entry.aug_6));
update_values.push_back(columns[10] + " = " + std::to_string(character_corpse_items_entry.attuned));
v.push_back(columns[0] + " = " + std::to_string(e.corpse_id));
v.push_back(columns[1] + " = " + std::to_string(e.equip_slot));
v.push_back(columns[2] + " = " + std::to_string(e.item_id));
v.push_back(columns[3] + " = " + std::to_string(e.charges));
v.push_back(columns[4] + " = " + std::to_string(e.aug_1));
v.push_back(columns[5] + " = " + std::to_string(e.aug_2));
v.push_back(columns[6] + " = " + std::to_string(e.aug_3));
v.push_back(columns[7] + " = " + std::to_string(e.aug_4));
v.push_back(columns[8] + " = " + std::to_string(e.aug_5));
v.push_back(columns[9] + " = " + std::to_string(e.aug_6));
v.push_back(columns[10] + " = " + std::to_string(e.attuned));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_corpse_items_entry.corpse_id
e.corpse_id
)
);
@@ -225,67 +225,67 @@ public:
static CharacterCorpseItems InsertOne(
Database& db,
CharacterCorpseItems character_corpse_items_entry
CharacterCorpseItems e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_corpse_items_entry.corpse_id));
insert_values.push_back(std::to_string(character_corpse_items_entry.equip_slot));
insert_values.push_back(std::to_string(character_corpse_items_entry.item_id));
insert_values.push_back(std::to_string(character_corpse_items_entry.charges));
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_1));
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_2));
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_3));
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_4));
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_5));
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_6));
insert_values.push_back(std::to_string(character_corpse_items_entry.attuned));
v.push_back(std::to_string(e.corpse_id));
v.push_back(std::to_string(e.equip_slot));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.charges));
v.push_back(std::to_string(e.aug_1));
v.push_back(std::to_string(e.aug_2));
v.push_back(std::to_string(e.aug_3));
v.push_back(std::to_string(e.aug_4));
v.push_back(std::to_string(e.aug_5));
v.push_back(std::to_string(e.aug_6));
v.push_back(std::to_string(e.attuned));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_corpse_items_entry.corpse_id = results.LastInsertedID();
return character_corpse_items_entry;
e.corpse_id = results.LastInsertedID();
return e;
}
character_corpse_items_entry = NewEntity();
e = NewEntity();
return character_corpse_items_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterCorpseItems> character_corpse_items_entries
const std::vector<CharacterCorpseItems> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_corpse_items_entry: character_corpse_items_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_corpse_items_entry.corpse_id));
insert_values.push_back(std::to_string(character_corpse_items_entry.equip_slot));
insert_values.push_back(std::to_string(character_corpse_items_entry.item_id));
insert_values.push_back(std::to_string(character_corpse_items_entry.charges));
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_1));
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_2));
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_3));
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_4));
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_5));
insert_values.push_back(std::to_string(character_corpse_items_entry.aug_6));
insert_values.push_back(std::to_string(character_corpse_items_entry.attuned));
v.push_back(std::to_string(e.corpse_id));
v.push_back(std::to_string(e.equip_slot));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.charges));
v.push_back(std::to_string(e.aug_1));
v.push_back(std::to_string(e.aug_2));
v.push_back(std::to_string(e.aug_3));
v.push_back(std::to_string(e.aug_4));
v.push_back(std::to_string(e.aug_5));
v.push_back(std::to_string(e.aug_6));
v.push_back(std::to_string(e.attuned));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -312,27 +312,27 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterCorpseItems entry{};
CharacterCorpseItems e{};
entry.corpse_id = atoi(row[0]);
entry.equip_slot = atoi(row[1]);
entry.item_id = atoi(row[2]);
entry.charges = atoi(row[3]);
entry.aug_1 = atoi(row[4]);
entry.aug_2 = atoi(row[5]);
entry.aug_3 = atoi(row[6]);
entry.aug_4 = atoi(row[7]);
entry.aug_5 = atoi(row[8]);
entry.aug_6 = atoi(row[9]);
entry.attuned = atoi(row[10]);
e.corpse_id = atoi(row[0]);
e.equip_slot = atoi(row[1]);
e.item_id = atoi(row[2]);
e.charges = atoi(row[3]);
e.aug_1 = atoi(row[4]);
e.aug_2 = atoi(row[5]);
e.aug_3 = atoi(row[6]);
e.aug_4 = atoi(row[7]);
e.aug_5 = atoi(row[8]);
e.aug_6 = atoi(row[9]);
e.attuned = atoi(row[10]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterCorpseItems> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterCorpseItems> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterCorpseItems> all_entries;
@@ -347,27 +347,27 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterCorpseItems entry{};
CharacterCorpseItems e{};
entry.corpse_id = atoi(row[0]);
entry.equip_slot = atoi(row[1]);
entry.item_id = atoi(row[2]);
entry.charges = atoi(row[3]);
entry.aug_1 = atoi(row[4]);
entry.aug_2 = atoi(row[5]);
entry.aug_3 = atoi(row[6]);
entry.aug_4 = atoi(row[7]);
entry.aug_5 = atoi(row[8]);
entry.aug_6 = atoi(row[9]);
entry.attuned = atoi(row[10]);
e.corpse_id = atoi(row[0]);
e.equip_slot = atoi(row[1]);
e.item_id = atoi(row[2]);
e.charges = atoi(row[3]);
e.aug_1 = atoi(row[4]);
e.aug_2 = atoi(row[5]);
e.aug_3 = atoi(row[6]);
e.aug_4 = atoi(row[7]);
e.aug_5 = atoi(row[8]);
e.aug_6 = atoi(row[9]);
e.attuned = atoi(row[10]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -392,6 +392,32 @@ public:
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_CHARACTER_CORPSE_ITEMS_REPOSITORY_H
@@ -214,60 +214,60 @@ public:
static CharacterCorpses NewEntity()
{
CharacterCorpses entry{};
CharacterCorpses e{};
entry.id = 0;
entry.charid = 0;
entry.charname = "";
entry.zone_id = 0;
entry.instance_id = 0;
entry.x = 0;
entry.y = 0;
entry.z = 0;
entry.heading = 0;
entry.time_of_death = 0;
entry.guild_consent_id = 0;
entry.is_rezzed = 0;
entry.is_buried = 0;
entry.was_at_graveyard = 0;
entry.is_locked = 0;
entry.exp = 0;
entry.size = 0;
entry.level = 0;
entry.race = 0;
entry.gender = 0;
entry.class_ = 0;
entry.deity = 0;
entry.texture = 0;
entry.helm_texture = 0;
entry.copper = 0;
entry.silver = 0;
entry.gold = 0;
entry.platinum = 0;
entry.hair_color = 0;
entry.beard_color = 0;
entry.eye_color_1 = 0;
entry.eye_color_2 = 0;
entry.hair_style = 0;
entry.face = 0;
entry.beard = 0;
entry.drakkin_heritage = 0;
entry.drakkin_tattoo = 0;
entry.drakkin_details = 0;
entry.wc_1 = 0;
entry.wc_2 = 0;
entry.wc_3 = 0;
entry.wc_4 = 0;
entry.wc_5 = 0;
entry.wc_6 = 0;
entry.wc_7 = 0;
entry.wc_8 = 0;
entry.wc_9 = 0;
e.id = 0;
e.charid = 0;
e.charname = "";
e.zone_id = 0;
e.instance_id = 0;
e.x = 0;
e.y = 0;
e.z = 0;
e.heading = 0;
e.time_of_death = 0;
e.guild_consent_id = 0;
e.is_rezzed = 0;
e.is_buried = 0;
e.was_at_graveyard = 0;
e.is_locked = 0;
e.exp = 0;
e.size = 0;
e.level = 0;
e.race = 0;
e.gender = 0;
e.class_ = 0;
e.deity = 0;
e.texture = 0;
e.helm_texture = 0;
e.copper = 0;
e.silver = 0;
e.gold = 0;
e.platinum = 0;
e.hair_color = 0;
e.beard_color = 0;
e.eye_color_1 = 0;
e.eye_color_2 = 0;
e.hair_style = 0;
e.face = 0;
e.beard = 0;
e.drakkin_heritage = 0;
e.drakkin_tattoo = 0;
e.drakkin_details = 0;
e.wc_1 = 0;
e.wc_2 = 0;
e.wc_3 = 0;
e.wc_4 = 0;
e.wc_5 = 0;
e.wc_6 = 0;
e.wc_7 = 0;
e.wc_8 = 0;
e.wc_9 = 0;
return entry;
return e;
}
static CharacterCorpses GetCharacterCorpsesEntry(
static CharacterCorpses GetCharacterCorpses(
const std::vector<CharacterCorpses> &character_corpsess,
int character_corpses_id
)
@@ -296,57 +296,57 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterCorpses entry{};
CharacterCorpses e{};
entry.id = atoi(row[0]);
entry.charid = atoi(row[1]);
entry.charname = row[2] ? row[2] : "";
entry.zone_id = atoi(row[3]);
entry.instance_id = atoi(row[4]);
entry.x = static_cast<float>(atof(row[5]));
entry.y = static_cast<float>(atof(row[6]));
entry.z = static_cast<float>(atof(row[7]));
entry.heading = static_cast<float>(atof(row[8]));
entry.time_of_death = strtoll(row[9] ? row[9] : "-1", nullptr, 10);
entry.guild_consent_id = atoi(row[10]);
entry.is_rezzed = atoi(row[11]);
entry.is_buried = atoi(row[12]);
entry.was_at_graveyard = atoi(row[13]);
entry.is_locked = atoi(row[14]);
entry.exp = atoi(row[15]);
entry.size = atoi(row[16]);
entry.level = atoi(row[17]);
entry.race = atoi(row[18]);
entry.gender = atoi(row[19]);
entry.class_ = atoi(row[20]);
entry.deity = atoi(row[21]);
entry.texture = atoi(row[22]);
entry.helm_texture = atoi(row[23]);
entry.copper = atoi(row[24]);
entry.silver = atoi(row[25]);
entry.gold = atoi(row[26]);
entry.platinum = atoi(row[27]);
entry.hair_color = atoi(row[28]);
entry.beard_color = atoi(row[29]);
entry.eye_color_1 = atoi(row[30]);
entry.eye_color_2 = atoi(row[31]);
entry.hair_style = atoi(row[32]);
entry.face = atoi(row[33]);
entry.beard = atoi(row[34]);
entry.drakkin_heritage = atoi(row[35]);
entry.drakkin_tattoo = atoi(row[36]);
entry.drakkin_details = atoi(row[37]);
entry.wc_1 = atoi(row[38]);
entry.wc_2 = atoi(row[39]);
entry.wc_3 = atoi(row[40]);
entry.wc_4 = atoi(row[41]);
entry.wc_5 = atoi(row[42]);
entry.wc_6 = atoi(row[43]);
entry.wc_7 = atoi(row[44]);
entry.wc_8 = atoi(row[45]);
entry.wc_9 = atoi(row[46]);
e.id = atoi(row[0]);
e.charid = atoi(row[1]);
e.charname = row[2] ? row[2] : "";
e.zone_id = atoi(row[3]);
e.instance_id = atoi(row[4]);
e.x = static_cast<float>(atof(row[5]));
e.y = static_cast<float>(atof(row[6]));
e.z = static_cast<float>(atof(row[7]));
e.heading = static_cast<float>(atof(row[8]));
e.time_of_death = strtoll(row[9] ? row[9] : "-1", nullptr, 10);
e.guild_consent_id = atoi(row[10]);
e.is_rezzed = atoi(row[11]);
e.is_buried = atoi(row[12]);
e.was_at_graveyard = atoi(row[13]);
e.is_locked = atoi(row[14]);
e.exp = atoi(row[15]);
e.size = atoi(row[16]);
e.level = atoi(row[17]);
e.race = atoi(row[18]);
e.gender = atoi(row[19]);
e.class_ = atoi(row[20]);
e.deity = atoi(row[21]);
e.texture = atoi(row[22]);
e.helm_texture = atoi(row[23]);
e.copper = atoi(row[24]);
e.silver = atoi(row[25]);
e.gold = atoi(row[26]);
e.platinum = atoi(row[27]);
e.hair_color = atoi(row[28]);
e.beard_color = atoi(row[29]);
e.eye_color_1 = atoi(row[30]);
e.eye_color_2 = atoi(row[31]);
e.hair_style = atoi(row[32]);
e.face = atoi(row[33]);
e.beard = atoi(row[34]);
e.drakkin_heritage = atoi(row[35]);
e.drakkin_tattoo = atoi(row[36]);
e.drakkin_details = atoi(row[37]);
e.wc_1 = atoi(row[38]);
e.wc_2 = atoi(row[39]);
e.wc_3 = atoi(row[40]);
e.wc_4 = atoi(row[41]);
e.wc_5 = atoi(row[42]);
e.wc_6 = atoi(row[43]);
e.wc_7 = atoi(row[44]);
e.wc_8 = atoi(row[45]);
e.wc_9 = atoi(row[46]);
return entry;
return e;
}
return NewEntity();
@@ -371,67 +371,67 @@ public:
static int UpdateOne(
Database& db,
CharacterCorpses character_corpses_entry
const CharacterCorpses &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(character_corpses_entry.charid));
update_values.push_back(columns[2] + " = '" + Strings::Escape(character_corpses_entry.charname) + "'");
update_values.push_back(columns[3] + " = " + std::to_string(character_corpses_entry.zone_id));
update_values.push_back(columns[4] + " = " + std::to_string(character_corpses_entry.instance_id));
update_values.push_back(columns[5] + " = " + std::to_string(character_corpses_entry.x));
update_values.push_back(columns[6] + " = " + std::to_string(character_corpses_entry.y));
update_values.push_back(columns[7] + " = " + std::to_string(character_corpses_entry.z));
update_values.push_back(columns[8] + " = " + std::to_string(character_corpses_entry.heading));
update_values.push_back(columns[9] + " = FROM_UNIXTIME(" + (character_corpses_entry.time_of_death > 0 ? std::to_string(character_corpses_entry.time_of_death) : "null") + ")");
update_values.push_back(columns[10] + " = " + std::to_string(character_corpses_entry.guild_consent_id));
update_values.push_back(columns[11] + " = " + std::to_string(character_corpses_entry.is_rezzed));
update_values.push_back(columns[12] + " = " + std::to_string(character_corpses_entry.is_buried));
update_values.push_back(columns[13] + " = " + std::to_string(character_corpses_entry.was_at_graveyard));
update_values.push_back(columns[14] + " = " + std::to_string(character_corpses_entry.is_locked));
update_values.push_back(columns[15] + " = " + std::to_string(character_corpses_entry.exp));
update_values.push_back(columns[16] + " = " + std::to_string(character_corpses_entry.size));
update_values.push_back(columns[17] + " = " + std::to_string(character_corpses_entry.level));
update_values.push_back(columns[18] + " = " + std::to_string(character_corpses_entry.race));
update_values.push_back(columns[19] + " = " + std::to_string(character_corpses_entry.gender));
update_values.push_back(columns[20] + " = " + std::to_string(character_corpses_entry.class_));
update_values.push_back(columns[21] + " = " + std::to_string(character_corpses_entry.deity));
update_values.push_back(columns[22] + " = " + std::to_string(character_corpses_entry.texture));
update_values.push_back(columns[23] + " = " + std::to_string(character_corpses_entry.helm_texture));
update_values.push_back(columns[24] + " = " + std::to_string(character_corpses_entry.copper));
update_values.push_back(columns[25] + " = " + std::to_string(character_corpses_entry.silver));
update_values.push_back(columns[26] + " = " + std::to_string(character_corpses_entry.gold));
update_values.push_back(columns[27] + " = " + std::to_string(character_corpses_entry.platinum));
update_values.push_back(columns[28] + " = " + std::to_string(character_corpses_entry.hair_color));
update_values.push_back(columns[29] + " = " + std::to_string(character_corpses_entry.beard_color));
update_values.push_back(columns[30] + " = " + std::to_string(character_corpses_entry.eye_color_1));
update_values.push_back(columns[31] + " = " + std::to_string(character_corpses_entry.eye_color_2));
update_values.push_back(columns[32] + " = " + std::to_string(character_corpses_entry.hair_style));
update_values.push_back(columns[33] + " = " + std::to_string(character_corpses_entry.face));
update_values.push_back(columns[34] + " = " + std::to_string(character_corpses_entry.beard));
update_values.push_back(columns[35] + " = " + std::to_string(character_corpses_entry.drakkin_heritage));
update_values.push_back(columns[36] + " = " + std::to_string(character_corpses_entry.drakkin_tattoo));
update_values.push_back(columns[37] + " = " + std::to_string(character_corpses_entry.drakkin_details));
update_values.push_back(columns[38] + " = " + std::to_string(character_corpses_entry.wc_1));
update_values.push_back(columns[39] + " = " + std::to_string(character_corpses_entry.wc_2));
update_values.push_back(columns[40] + " = " + std::to_string(character_corpses_entry.wc_3));
update_values.push_back(columns[41] + " = " + std::to_string(character_corpses_entry.wc_4));
update_values.push_back(columns[42] + " = " + std::to_string(character_corpses_entry.wc_5));
update_values.push_back(columns[43] + " = " + std::to_string(character_corpses_entry.wc_6));
update_values.push_back(columns[44] + " = " + std::to_string(character_corpses_entry.wc_7));
update_values.push_back(columns[45] + " = " + std::to_string(character_corpses_entry.wc_8));
update_values.push_back(columns[46] + " = " + std::to_string(character_corpses_entry.wc_9));
v.push_back(columns[1] + " = " + std::to_string(e.charid));
v.push_back(columns[2] + " = '" + Strings::Escape(e.charname) + "'");
v.push_back(columns[3] + " = " + std::to_string(e.zone_id));
v.push_back(columns[4] + " = " + std::to_string(e.instance_id));
v.push_back(columns[5] + " = " + std::to_string(e.x));
v.push_back(columns[6] + " = " + std::to_string(e.y));
v.push_back(columns[7] + " = " + std::to_string(e.z));
v.push_back(columns[8] + " = " + std::to_string(e.heading));
v.push_back(columns[9] + " = FROM_UNIXTIME(" + (e.time_of_death > 0 ? std::to_string(e.time_of_death) : "null") + ")");
v.push_back(columns[10] + " = " + std::to_string(e.guild_consent_id));
v.push_back(columns[11] + " = " + std::to_string(e.is_rezzed));
v.push_back(columns[12] + " = " + std::to_string(e.is_buried));
v.push_back(columns[13] + " = " + std::to_string(e.was_at_graveyard));
v.push_back(columns[14] + " = " + std::to_string(e.is_locked));
v.push_back(columns[15] + " = " + std::to_string(e.exp));
v.push_back(columns[16] + " = " + std::to_string(e.size));
v.push_back(columns[17] + " = " + std::to_string(e.level));
v.push_back(columns[18] + " = " + std::to_string(e.race));
v.push_back(columns[19] + " = " + std::to_string(e.gender));
v.push_back(columns[20] + " = " + std::to_string(e.class_));
v.push_back(columns[21] + " = " + std::to_string(e.deity));
v.push_back(columns[22] + " = " + std::to_string(e.texture));
v.push_back(columns[23] + " = " + std::to_string(e.helm_texture));
v.push_back(columns[24] + " = " + std::to_string(e.copper));
v.push_back(columns[25] + " = " + std::to_string(e.silver));
v.push_back(columns[26] + " = " + std::to_string(e.gold));
v.push_back(columns[27] + " = " + std::to_string(e.platinum));
v.push_back(columns[28] + " = " + std::to_string(e.hair_color));
v.push_back(columns[29] + " = " + std::to_string(e.beard_color));
v.push_back(columns[30] + " = " + std::to_string(e.eye_color_1));
v.push_back(columns[31] + " = " + std::to_string(e.eye_color_2));
v.push_back(columns[32] + " = " + std::to_string(e.hair_style));
v.push_back(columns[33] + " = " + std::to_string(e.face));
v.push_back(columns[34] + " = " + std::to_string(e.beard));
v.push_back(columns[35] + " = " + std::to_string(e.drakkin_heritage));
v.push_back(columns[36] + " = " + std::to_string(e.drakkin_tattoo));
v.push_back(columns[37] + " = " + std::to_string(e.drakkin_details));
v.push_back(columns[38] + " = " + std::to_string(e.wc_1));
v.push_back(columns[39] + " = " + std::to_string(e.wc_2));
v.push_back(columns[40] + " = " + std::to_string(e.wc_3));
v.push_back(columns[41] + " = " + std::to_string(e.wc_4));
v.push_back(columns[42] + " = " + std::to_string(e.wc_5));
v.push_back(columns[43] + " = " + std::to_string(e.wc_6));
v.push_back(columns[44] + " = " + std::to_string(e.wc_7));
v.push_back(columns[45] + " = " + std::to_string(e.wc_8));
v.push_back(columns[46] + " = " + std::to_string(e.wc_9));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_corpses_entry.id
e.id
)
);
@@ -440,139 +440,139 @@ public:
static CharacterCorpses InsertOne(
Database& db,
CharacterCorpses character_corpses_entry
CharacterCorpses e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_corpses_entry.id));
insert_values.push_back(std::to_string(character_corpses_entry.charid));
insert_values.push_back("'" + Strings::Escape(character_corpses_entry.charname) + "'");
insert_values.push_back(std::to_string(character_corpses_entry.zone_id));
insert_values.push_back(std::to_string(character_corpses_entry.instance_id));
insert_values.push_back(std::to_string(character_corpses_entry.x));
insert_values.push_back(std::to_string(character_corpses_entry.y));
insert_values.push_back(std::to_string(character_corpses_entry.z));
insert_values.push_back(std::to_string(character_corpses_entry.heading));
insert_values.push_back("FROM_UNIXTIME(" + (character_corpses_entry.time_of_death > 0 ? std::to_string(character_corpses_entry.time_of_death) : "null") + ")");
insert_values.push_back(std::to_string(character_corpses_entry.guild_consent_id));
insert_values.push_back(std::to_string(character_corpses_entry.is_rezzed));
insert_values.push_back(std::to_string(character_corpses_entry.is_buried));
insert_values.push_back(std::to_string(character_corpses_entry.was_at_graveyard));
insert_values.push_back(std::to_string(character_corpses_entry.is_locked));
insert_values.push_back(std::to_string(character_corpses_entry.exp));
insert_values.push_back(std::to_string(character_corpses_entry.size));
insert_values.push_back(std::to_string(character_corpses_entry.level));
insert_values.push_back(std::to_string(character_corpses_entry.race));
insert_values.push_back(std::to_string(character_corpses_entry.gender));
insert_values.push_back(std::to_string(character_corpses_entry.class_));
insert_values.push_back(std::to_string(character_corpses_entry.deity));
insert_values.push_back(std::to_string(character_corpses_entry.texture));
insert_values.push_back(std::to_string(character_corpses_entry.helm_texture));
insert_values.push_back(std::to_string(character_corpses_entry.copper));
insert_values.push_back(std::to_string(character_corpses_entry.silver));
insert_values.push_back(std::to_string(character_corpses_entry.gold));
insert_values.push_back(std::to_string(character_corpses_entry.platinum));
insert_values.push_back(std::to_string(character_corpses_entry.hair_color));
insert_values.push_back(std::to_string(character_corpses_entry.beard_color));
insert_values.push_back(std::to_string(character_corpses_entry.eye_color_1));
insert_values.push_back(std::to_string(character_corpses_entry.eye_color_2));
insert_values.push_back(std::to_string(character_corpses_entry.hair_style));
insert_values.push_back(std::to_string(character_corpses_entry.face));
insert_values.push_back(std::to_string(character_corpses_entry.beard));
insert_values.push_back(std::to_string(character_corpses_entry.drakkin_heritage));
insert_values.push_back(std::to_string(character_corpses_entry.drakkin_tattoo));
insert_values.push_back(std::to_string(character_corpses_entry.drakkin_details));
insert_values.push_back(std::to_string(character_corpses_entry.wc_1));
insert_values.push_back(std::to_string(character_corpses_entry.wc_2));
insert_values.push_back(std::to_string(character_corpses_entry.wc_3));
insert_values.push_back(std::to_string(character_corpses_entry.wc_4));
insert_values.push_back(std::to_string(character_corpses_entry.wc_5));
insert_values.push_back(std::to_string(character_corpses_entry.wc_6));
insert_values.push_back(std::to_string(character_corpses_entry.wc_7));
insert_values.push_back(std::to_string(character_corpses_entry.wc_8));
insert_values.push_back(std::to_string(character_corpses_entry.wc_9));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.charid));
v.push_back("'" + Strings::Escape(e.charname) + "'");
v.push_back(std::to_string(e.zone_id));
v.push_back(std::to_string(e.instance_id));
v.push_back(std::to_string(e.x));
v.push_back(std::to_string(e.y));
v.push_back(std::to_string(e.z));
v.push_back(std::to_string(e.heading));
v.push_back("FROM_UNIXTIME(" + (e.time_of_death > 0 ? std::to_string(e.time_of_death) : "null") + ")");
v.push_back(std::to_string(e.guild_consent_id));
v.push_back(std::to_string(e.is_rezzed));
v.push_back(std::to_string(e.is_buried));
v.push_back(std::to_string(e.was_at_graveyard));
v.push_back(std::to_string(e.is_locked));
v.push_back(std::to_string(e.exp));
v.push_back(std::to_string(e.size));
v.push_back(std::to_string(e.level));
v.push_back(std::to_string(e.race));
v.push_back(std::to_string(e.gender));
v.push_back(std::to_string(e.class_));
v.push_back(std::to_string(e.deity));
v.push_back(std::to_string(e.texture));
v.push_back(std::to_string(e.helm_texture));
v.push_back(std::to_string(e.copper));
v.push_back(std::to_string(e.silver));
v.push_back(std::to_string(e.gold));
v.push_back(std::to_string(e.platinum));
v.push_back(std::to_string(e.hair_color));
v.push_back(std::to_string(e.beard_color));
v.push_back(std::to_string(e.eye_color_1));
v.push_back(std::to_string(e.eye_color_2));
v.push_back(std::to_string(e.hair_style));
v.push_back(std::to_string(e.face));
v.push_back(std::to_string(e.beard));
v.push_back(std::to_string(e.drakkin_heritage));
v.push_back(std::to_string(e.drakkin_tattoo));
v.push_back(std::to_string(e.drakkin_details));
v.push_back(std::to_string(e.wc_1));
v.push_back(std::to_string(e.wc_2));
v.push_back(std::to_string(e.wc_3));
v.push_back(std::to_string(e.wc_4));
v.push_back(std::to_string(e.wc_5));
v.push_back(std::to_string(e.wc_6));
v.push_back(std::to_string(e.wc_7));
v.push_back(std::to_string(e.wc_8));
v.push_back(std::to_string(e.wc_9));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_corpses_entry.id = results.LastInsertedID();
return character_corpses_entry;
e.id = results.LastInsertedID();
return e;
}
character_corpses_entry = NewEntity();
e = NewEntity();
return character_corpses_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterCorpses> character_corpses_entries
const std::vector<CharacterCorpses> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_corpses_entry: character_corpses_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_corpses_entry.id));
insert_values.push_back(std::to_string(character_corpses_entry.charid));
insert_values.push_back("'" + Strings::Escape(character_corpses_entry.charname) + "'");
insert_values.push_back(std::to_string(character_corpses_entry.zone_id));
insert_values.push_back(std::to_string(character_corpses_entry.instance_id));
insert_values.push_back(std::to_string(character_corpses_entry.x));
insert_values.push_back(std::to_string(character_corpses_entry.y));
insert_values.push_back(std::to_string(character_corpses_entry.z));
insert_values.push_back(std::to_string(character_corpses_entry.heading));
insert_values.push_back("FROM_UNIXTIME(" + (character_corpses_entry.time_of_death > 0 ? std::to_string(character_corpses_entry.time_of_death) : "null") + ")");
insert_values.push_back(std::to_string(character_corpses_entry.guild_consent_id));
insert_values.push_back(std::to_string(character_corpses_entry.is_rezzed));
insert_values.push_back(std::to_string(character_corpses_entry.is_buried));
insert_values.push_back(std::to_string(character_corpses_entry.was_at_graveyard));
insert_values.push_back(std::to_string(character_corpses_entry.is_locked));
insert_values.push_back(std::to_string(character_corpses_entry.exp));
insert_values.push_back(std::to_string(character_corpses_entry.size));
insert_values.push_back(std::to_string(character_corpses_entry.level));
insert_values.push_back(std::to_string(character_corpses_entry.race));
insert_values.push_back(std::to_string(character_corpses_entry.gender));
insert_values.push_back(std::to_string(character_corpses_entry.class_));
insert_values.push_back(std::to_string(character_corpses_entry.deity));
insert_values.push_back(std::to_string(character_corpses_entry.texture));
insert_values.push_back(std::to_string(character_corpses_entry.helm_texture));
insert_values.push_back(std::to_string(character_corpses_entry.copper));
insert_values.push_back(std::to_string(character_corpses_entry.silver));
insert_values.push_back(std::to_string(character_corpses_entry.gold));
insert_values.push_back(std::to_string(character_corpses_entry.platinum));
insert_values.push_back(std::to_string(character_corpses_entry.hair_color));
insert_values.push_back(std::to_string(character_corpses_entry.beard_color));
insert_values.push_back(std::to_string(character_corpses_entry.eye_color_1));
insert_values.push_back(std::to_string(character_corpses_entry.eye_color_2));
insert_values.push_back(std::to_string(character_corpses_entry.hair_style));
insert_values.push_back(std::to_string(character_corpses_entry.face));
insert_values.push_back(std::to_string(character_corpses_entry.beard));
insert_values.push_back(std::to_string(character_corpses_entry.drakkin_heritage));
insert_values.push_back(std::to_string(character_corpses_entry.drakkin_tattoo));
insert_values.push_back(std::to_string(character_corpses_entry.drakkin_details));
insert_values.push_back(std::to_string(character_corpses_entry.wc_1));
insert_values.push_back(std::to_string(character_corpses_entry.wc_2));
insert_values.push_back(std::to_string(character_corpses_entry.wc_3));
insert_values.push_back(std::to_string(character_corpses_entry.wc_4));
insert_values.push_back(std::to_string(character_corpses_entry.wc_5));
insert_values.push_back(std::to_string(character_corpses_entry.wc_6));
insert_values.push_back(std::to_string(character_corpses_entry.wc_7));
insert_values.push_back(std::to_string(character_corpses_entry.wc_8));
insert_values.push_back(std::to_string(character_corpses_entry.wc_9));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.charid));
v.push_back("'" + Strings::Escape(e.charname) + "'");
v.push_back(std::to_string(e.zone_id));
v.push_back(std::to_string(e.instance_id));
v.push_back(std::to_string(e.x));
v.push_back(std::to_string(e.y));
v.push_back(std::to_string(e.z));
v.push_back(std::to_string(e.heading));
v.push_back("FROM_UNIXTIME(" + (e.time_of_death > 0 ? std::to_string(e.time_of_death) : "null") + ")");
v.push_back(std::to_string(e.guild_consent_id));
v.push_back(std::to_string(e.is_rezzed));
v.push_back(std::to_string(e.is_buried));
v.push_back(std::to_string(e.was_at_graveyard));
v.push_back(std::to_string(e.is_locked));
v.push_back(std::to_string(e.exp));
v.push_back(std::to_string(e.size));
v.push_back(std::to_string(e.level));
v.push_back(std::to_string(e.race));
v.push_back(std::to_string(e.gender));
v.push_back(std::to_string(e.class_));
v.push_back(std::to_string(e.deity));
v.push_back(std::to_string(e.texture));
v.push_back(std::to_string(e.helm_texture));
v.push_back(std::to_string(e.copper));
v.push_back(std::to_string(e.silver));
v.push_back(std::to_string(e.gold));
v.push_back(std::to_string(e.platinum));
v.push_back(std::to_string(e.hair_color));
v.push_back(std::to_string(e.beard_color));
v.push_back(std::to_string(e.eye_color_1));
v.push_back(std::to_string(e.eye_color_2));
v.push_back(std::to_string(e.hair_style));
v.push_back(std::to_string(e.face));
v.push_back(std::to_string(e.beard));
v.push_back(std::to_string(e.drakkin_heritage));
v.push_back(std::to_string(e.drakkin_tattoo));
v.push_back(std::to_string(e.drakkin_details));
v.push_back(std::to_string(e.wc_1));
v.push_back(std::to_string(e.wc_2));
v.push_back(std::to_string(e.wc_3));
v.push_back(std::to_string(e.wc_4));
v.push_back(std::to_string(e.wc_5));
v.push_back(std::to_string(e.wc_6));
v.push_back(std::to_string(e.wc_7));
v.push_back(std::to_string(e.wc_8));
v.push_back(std::to_string(e.wc_9));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -599,63 +599,63 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterCorpses entry{};
CharacterCorpses e{};
entry.id = atoi(row[0]);
entry.charid = atoi(row[1]);
entry.charname = row[2] ? row[2] : "";
entry.zone_id = atoi(row[3]);
entry.instance_id = atoi(row[4]);
entry.x = static_cast<float>(atof(row[5]));
entry.y = static_cast<float>(atof(row[6]));
entry.z = static_cast<float>(atof(row[7]));
entry.heading = static_cast<float>(atof(row[8]));
entry.time_of_death = strtoll(row[9] ? row[9] : "-1", nullptr, 10);
entry.guild_consent_id = atoi(row[10]);
entry.is_rezzed = atoi(row[11]);
entry.is_buried = atoi(row[12]);
entry.was_at_graveyard = atoi(row[13]);
entry.is_locked = atoi(row[14]);
entry.exp = atoi(row[15]);
entry.size = atoi(row[16]);
entry.level = atoi(row[17]);
entry.race = atoi(row[18]);
entry.gender = atoi(row[19]);
entry.class_ = atoi(row[20]);
entry.deity = atoi(row[21]);
entry.texture = atoi(row[22]);
entry.helm_texture = atoi(row[23]);
entry.copper = atoi(row[24]);
entry.silver = atoi(row[25]);
entry.gold = atoi(row[26]);
entry.platinum = atoi(row[27]);
entry.hair_color = atoi(row[28]);
entry.beard_color = atoi(row[29]);
entry.eye_color_1 = atoi(row[30]);
entry.eye_color_2 = atoi(row[31]);
entry.hair_style = atoi(row[32]);
entry.face = atoi(row[33]);
entry.beard = atoi(row[34]);
entry.drakkin_heritage = atoi(row[35]);
entry.drakkin_tattoo = atoi(row[36]);
entry.drakkin_details = atoi(row[37]);
entry.wc_1 = atoi(row[38]);
entry.wc_2 = atoi(row[39]);
entry.wc_3 = atoi(row[40]);
entry.wc_4 = atoi(row[41]);
entry.wc_5 = atoi(row[42]);
entry.wc_6 = atoi(row[43]);
entry.wc_7 = atoi(row[44]);
entry.wc_8 = atoi(row[45]);
entry.wc_9 = atoi(row[46]);
e.id = atoi(row[0]);
e.charid = atoi(row[1]);
e.charname = row[2] ? row[2] : "";
e.zone_id = atoi(row[3]);
e.instance_id = atoi(row[4]);
e.x = static_cast<float>(atof(row[5]));
e.y = static_cast<float>(atof(row[6]));
e.z = static_cast<float>(atof(row[7]));
e.heading = static_cast<float>(atof(row[8]));
e.time_of_death = strtoll(row[9] ? row[9] : "-1", nullptr, 10);
e.guild_consent_id = atoi(row[10]);
e.is_rezzed = atoi(row[11]);
e.is_buried = atoi(row[12]);
e.was_at_graveyard = atoi(row[13]);
e.is_locked = atoi(row[14]);
e.exp = atoi(row[15]);
e.size = atoi(row[16]);
e.level = atoi(row[17]);
e.race = atoi(row[18]);
e.gender = atoi(row[19]);
e.class_ = atoi(row[20]);
e.deity = atoi(row[21]);
e.texture = atoi(row[22]);
e.helm_texture = atoi(row[23]);
e.copper = atoi(row[24]);
e.silver = atoi(row[25]);
e.gold = atoi(row[26]);
e.platinum = atoi(row[27]);
e.hair_color = atoi(row[28]);
e.beard_color = atoi(row[29]);
e.eye_color_1 = atoi(row[30]);
e.eye_color_2 = atoi(row[31]);
e.hair_style = atoi(row[32]);
e.face = atoi(row[33]);
e.beard = atoi(row[34]);
e.drakkin_heritage = atoi(row[35]);
e.drakkin_tattoo = atoi(row[36]);
e.drakkin_details = atoi(row[37]);
e.wc_1 = atoi(row[38]);
e.wc_2 = atoi(row[39]);
e.wc_3 = atoi(row[40]);
e.wc_4 = atoi(row[41]);
e.wc_5 = atoi(row[42]);
e.wc_6 = atoi(row[43]);
e.wc_7 = atoi(row[44]);
e.wc_8 = atoi(row[45]);
e.wc_9 = atoi(row[46]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterCorpses> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterCorpses> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterCorpses> all_entries;
@@ -670,63 +670,63 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterCorpses entry{};
CharacterCorpses e{};
entry.id = atoi(row[0]);
entry.charid = atoi(row[1]);
entry.charname = row[2] ? row[2] : "";
entry.zone_id = atoi(row[3]);
entry.instance_id = atoi(row[4]);
entry.x = static_cast<float>(atof(row[5]));
entry.y = static_cast<float>(atof(row[6]));
entry.z = static_cast<float>(atof(row[7]));
entry.heading = static_cast<float>(atof(row[8]));
entry.time_of_death = strtoll(row[9] ? row[9] : "-1", nullptr, 10);
entry.guild_consent_id = atoi(row[10]);
entry.is_rezzed = atoi(row[11]);
entry.is_buried = atoi(row[12]);
entry.was_at_graveyard = atoi(row[13]);
entry.is_locked = atoi(row[14]);
entry.exp = atoi(row[15]);
entry.size = atoi(row[16]);
entry.level = atoi(row[17]);
entry.race = atoi(row[18]);
entry.gender = atoi(row[19]);
entry.class_ = atoi(row[20]);
entry.deity = atoi(row[21]);
entry.texture = atoi(row[22]);
entry.helm_texture = atoi(row[23]);
entry.copper = atoi(row[24]);
entry.silver = atoi(row[25]);
entry.gold = atoi(row[26]);
entry.platinum = atoi(row[27]);
entry.hair_color = atoi(row[28]);
entry.beard_color = atoi(row[29]);
entry.eye_color_1 = atoi(row[30]);
entry.eye_color_2 = atoi(row[31]);
entry.hair_style = atoi(row[32]);
entry.face = atoi(row[33]);
entry.beard = atoi(row[34]);
entry.drakkin_heritage = atoi(row[35]);
entry.drakkin_tattoo = atoi(row[36]);
entry.drakkin_details = atoi(row[37]);
entry.wc_1 = atoi(row[38]);
entry.wc_2 = atoi(row[39]);
entry.wc_3 = atoi(row[40]);
entry.wc_4 = atoi(row[41]);
entry.wc_5 = atoi(row[42]);
entry.wc_6 = atoi(row[43]);
entry.wc_7 = atoi(row[44]);
entry.wc_8 = atoi(row[45]);
entry.wc_9 = atoi(row[46]);
e.id = atoi(row[0]);
e.charid = atoi(row[1]);
e.charname = row[2] ? row[2] : "";
e.zone_id = atoi(row[3]);
e.instance_id = atoi(row[4]);
e.x = static_cast<float>(atof(row[5]));
e.y = static_cast<float>(atof(row[6]));
e.z = static_cast<float>(atof(row[7]));
e.heading = static_cast<float>(atof(row[8]));
e.time_of_death = strtoll(row[9] ? row[9] : "-1", nullptr, 10);
e.guild_consent_id = atoi(row[10]);
e.is_rezzed = atoi(row[11]);
e.is_buried = atoi(row[12]);
e.was_at_graveyard = atoi(row[13]);
e.is_locked = atoi(row[14]);
e.exp = atoi(row[15]);
e.size = atoi(row[16]);
e.level = atoi(row[17]);
e.race = atoi(row[18]);
e.gender = atoi(row[19]);
e.class_ = atoi(row[20]);
e.deity = atoi(row[21]);
e.texture = atoi(row[22]);
e.helm_texture = atoi(row[23]);
e.copper = atoi(row[24]);
e.silver = atoi(row[25]);
e.gold = atoi(row[26]);
e.platinum = atoi(row[27]);
e.hair_color = atoi(row[28]);
e.beard_color = atoi(row[29]);
e.eye_color_1 = atoi(row[30]);
e.eye_color_2 = atoi(row[31]);
e.hair_style = atoi(row[32]);
e.face = atoi(row[33]);
e.beard = atoi(row[34]);
e.drakkin_heritage = atoi(row[35]);
e.drakkin_tattoo = atoi(row[36]);
e.drakkin_details = atoi(row[37]);
e.wc_1 = atoi(row[38]);
e.wc_2 = atoi(row[39]);
e.wc_3 = atoi(row[40]);
e.wc_4 = atoi(row[41]);
e.wc_5 = atoi(row[42]);
e.wc_6 = atoi(row[43]);
e.wc_7 = atoi(row[44]);
e.wc_8 = atoi(row[45]);
e.wc_9 = atoi(row[46]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -751,6 +751,32 @@ public:
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_CHARACTER_CORPSES_REPOSITORY_H
@@ -124,30 +124,30 @@ public:
static CharacterCurrency NewEntity()
{
CharacterCurrency entry{};
CharacterCurrency e{};
entry.id = 0;
entry.platinum = 0;
entry.gold = 0;
entry.silver = 0;
entry.copper = 0;
entry.platinum_bank = 0;
entry.gold_bank = 0;
entry.silver_bank = 0;
entry.copper_bank = 0;
entry.platinum_cursor = 0;
entry.gold_cursor = 0;
entry.silver_cursor = 0;
entry.copper_cursor = 0;
entry.radiant_crystals = 0;
entry.career_radiant_crystals = 0;
entry.ebon_crystals = 0;
entry.career_ebon_crystals = 0;
e.id = 0;
e.platinum = 0;
e.gold = 0;
e.silver = 0;
e.copper = 0;
e.platinum_bank = 0;
e.gold_bank = 0;
e.silver_bank = 0;
e.copper_bank = 0;
e.platinum_cursor = 0;
e.gold_cursor = 0;
e.silver_cursor = 0;
e.copper_cursor = 0;
e.radiant_crystals = 0;
e.career_radiant_crystals = 0;
e.ebon_crystals = 0;
e.career_ebon_crystals = 0;
return entry;
return e;
}
static CharacterCurrency GetCharacterCurrencyEntry(
static CharacterCurrency GetCharacterCurrency(
const std::vector<CharacterCurrency> &character_currencys,
int character_currency_id
)
@@ -176,27 +176,27 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterCurrency entry{};
CharacterCurrency e{};
entry.id = atoi(row[0]);
entry.platinum = atoi(row[1]);
entry.gold = atoi(row[2]);
entry.silver = atoi(row[3]);
entry.copper = atoi(row[4]);
entry.platinum_bank = atoi(row[5]);
entry.gold_bank = atoi(row[6]);
entry.silver_bank = atoi(row[7]);
entry.copper_bank = atoi(row[8]);
entry.platinum_cursor = atoi(row[9]);
entry.gold_cursor = atoi(row[10]);
entry.silver_cursor = atoi(row[11]);
entry.copper_cursor = atoi(row[12]);
entry.radiant_crystals = atoi(row[13]);
entry.career_radiant_crystals = atoi(row[14]);
entry.ebon_crystals = atoi(row[15]);
entry.career_ebon_crystals = atoi(row[16]);
e.id = atoi(row[0]);
e.platinum = atoi(row[1]);
e.gold = atoi(row[2]);
e.silver = atoi(row[3]);
e.copper = atoi(row[4]);
e.platinum_bank = atoi(row[5]);
e.gold_bank = atoi(row[6]);
e.silver_bank = atoi(row[7]);
e.copper_bank = atoi(row[8]);
e.platinum_cursor = atoi(row[9]);
e.gold_cursor = atoi(row[10]);
e.silver_cursor = atoi(row[11]);
e.copper_cursor = atoi(row[12]);
e.radiant_crystals = atoi(row[13]);
e.career_radiant_crystals = atoi(row[14]);
e.ebon_crystals = atoi(row[15]);
e.career_ebon_crystals = atoi(row[16]);
return entry;
return e;
}
return NewEntity();
@@ -221,38 +221,38 @@ public:
static int UpdateOne(
Database& db,
CharacterCurrency character_currency_entry
const CharacterCurrency &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(character_currency_entry.id));
update_values.push_back(columns[1] + " = " + std::to_string(character_currency_entry.platinum));
update_values.push_back(columns[2] + " = " + std::to_string(character_currency_entry.gold));
update_values.push_back(columns[3] + " = " + std::to_string(character_currency_entry.silver));
update_values.push_back(columns[4] + " = " + std::to_string(character_currency_entry.copper));
update_values.push_back(columns[5] + " = " + std::to_string(character_currency_entry.platinum_bank));
update_values.push_back(columns[6] + " = " + std::to_string(character_currency_entry.gold_bank));
update_values.push_back(columns[7] + " = " + std::to_string(character_currency_entry.silver_bank));
update_values.push_back(columns[8] + " = " + std::to_string(character_currency_entry.copper_bank));
update_values.push_back(columns[9] + " = " + std::to_string(character_currency_entry.platinum_cursor));
update_values.push_back(columns[10] + " = " + std::to_string(character_currency_entry.gold_cursor));
update_values.push_back(columns[11] + " = " + std::to_string(character_currency_entry.silver_cursor));
update_values.push_back(columns[12] + " = " + std::to_string(character_currency_entry.copper_cursor));
update_values.push_back(columns[13] + " = " + std::to_string(character_currency_entry.radiant_crystals));
update_values.push_back(columns[14] + " = " + std::to_string(character_currency_entry.career_radiant_crystals));
update_values.push_back(columns[15] + " = " + std::to_string(character_currency_entry.ebon_crystals));
update_values.push_back(columns[16] + " = " + std::to_string(character_currency_entry.career_ebon_crystals));
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = " + std::to_string(e.platinum));
v.push_back(columns[2] + " = " + std::to_string(e.gold));
v.push_back(columns[3] + " = " + std::to_string(e.silver));
v.push_back(columns[4] + " = " + std::to_string(e.copper));
v.push_back(columns[5] + " = " + std::to_string(e.platinum_bank));
v.push_back(columns[6] + " = " + std::to_string(e.gold_bank));
v.push_back(columns[7] + " = " + std::to_string(e.silver_bank));
v.push_back(columns[8] + " = " + std::to_string(e.copper_bank));
v.push_back(columns[9] + " = " + std::to_string(e.platinum_cursor));
v.push_back(columns[10] + " = " + std::to_string(e.gold_cursor));
v.push_back(columns[11] + " = " + std::to_string(e.silver_cursor));
v.push_back(columns[12] + " = " + std::to_string(e.copper_cursor));
v.push_back(columns[13] + " = " + std::to_string(e.radiant_crystals));
v.push_back(columns[14] + " = " + std::to_string(e.career_radiant_crystals));
v.push_back(columns[15] + " = " + std::to_string(e.ebon_crystals));
v.push_back(columns[16] + " = " + std::to_string(e.career_ebon_crystals));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_currency_entry.id
e.id
)
);
@@ -261,79 +261,79 @@ public:
static CharacterCurrency InsertOne(
Database& db,
CharacterCurrency character_currency_entry
CharacterCurrency e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_currency_entry.id));
insert_values.push_back(std::to_string(character_currency_entry.platinum));
insert_values.push_back(std::to_string(character_currency_entry.gold));
insert_values.push_back(std::to_string(character_currency_entry.silver));
insert_values.push_back(std::to_string(character_currency_entry.copper));
insert_values.push_back(std::to_string(character_currency_entry.platinum_bank));
insert_values.push_back(std::to_string(character_currency_entry.gold_bank));
insert_values.push_back(std::to_string(character_currency_entry.silver_bank));
insert_values.push_back(std::to_string(character_currency_entry.copper_bank));
insert_values.push_back(std::to_string(character_currency_entry.platinum_cursor));
insert_values.push_back(std::to_string(character_currency_entry.gold_cursor));
insert_values.push_back(std::to_string(character_currency_entry.silver_cursor));
insert_values.push_back(std::to_string(character_currency_entry.copper_cursor));
insert_values.push_back(std::to_string(character_currency_entry.radiant_crystals));
insert_values.push_back(std::to_string(character_currency_entry.career_radiant_crystals));
insert_values.push_back(std::to_string(character_currency_entry.ebon_crystals));
insert_values.push_back(std::to_string(character_currency_entry.career_ebon_crystals));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.platinum));
v.push_back(std::to_string(e.gold));
v.push_back(std::to_string(e.silver));
v.push_back(std::to_string(e.copper));
v.push_back(std::to_string(e.platinum_bank));
v.push_back(std::to_string(e.gold_bank));
v.push_back(std::to_string(e.silver_bank));
v.push_back(std::to_string(e.copper_bank));
v.push_back(std::to_string(e.platinum_cursor));
v.push_back(std::to_string(e.gold_cursor));
v.push_back(std::to_string(e.silver_cursor));
v.push_back(std::to_string(e.copper_cursor));
v.push_back(std::to_string(e.radiant_crystals));
v.push_back(std::to_string(e.career_radiant_crystals));
v.push_back(std::to_string(e.ebon_crystals));
v.push_back(std::to_string(e.career_ebon_crystals));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_currency_entry.id = results.LastInsertedID();
return character_currency_entry;
e.id = results.LastInsertedID();
return e;
}
character_currency_entry = NewEntity();
e = NewEntity();
return character_currency_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterCurrency> character_currency_entries
const std::vector<CharacterCurrency> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_currency_entry: character_currency_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_currency_entry.id));
insert_values.push_back(std::to_string(character_currency_entry.platinum));
insert_values.push_back(std::to_string(character_currency_entry.gold));
insert_values.push_back(std::to_string(character_currency_entry.silver));
insert_values.push_back(std::to_string(character_currency_entry.copper));
insert_values.push_back(std::to_string(character_currency_entry.platinum_bank));
insert_values.push_back(std::to_string(character_currency_entry.gold_bank));
insert_values.push_back(std::to_string(character_currency_entry.silver_bank));
insert_values.push_back(std::to_string(character_currency_entry.copper_bank));
insert_values.push_back(std::to_string(character_currency_entry.platinum_cursor));
insert_values.push_back(std::to_string(character_currency_entry.gold_cursor));
insert_values.push_back(std::to_string(character_currency_entry.silver_cursor));
insert_values.push_back(std::to_string(character_currency_entry.copper_cursor));
insert_values.push_back(std::to_string(character_currency_entry.radiant_crystals));
insert_values.push_back(std::to_string(character_currency_entry.career_radiant_crystals));
insert_values.push_back(std::to_string(character_currency_entry.ebon_crystals));
insert_values.push_back(std::to_string(character_currency_entry.career_ebon_crystals));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.platinum));
v.push_back(std::to_string(e.gold));
v.push_back(std::to_string(e.silver));
v.push_back(std::to_string(e.copper));
v.push_back(std::to_string(e.platinum_bank));
v.push_back(std::to_string(e.gold_bank));
v.push_back(std::to_string(e.silver_bank));
v.push_back(std::to_string(e.copper_bank));
v.push_back(std::to_string(e.platinum_cursor));
v.push_back(std::to_string(e.gold_cursor));
v.push_back(std::to_string(e.silver_cursor));
v.push_back(std::to_string(e.copper_cursor));
v.push_back(std::to_string(e.radiant_crystals));
v.push_back(std::to_string(e.career_radiant_crystals));
v.push_back(std::to_string(e.ebon_crystals));
v.push_back(std::to_string(e.career_ebon_crystals));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -360,33 +360,33 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterCurrency entry{};
CharacterCurrency e{};
entry.id = atoi(row[0]);
entry.platinum = atoi(row[1]);
entry.gold = atoi(row[2]);
entry.silver = atoi(row[3]);
entry.copper = atoi(row[4]);
entry.platinum_bank = atoi(row[5]);
entry.gold_bank = atoi(row[6]);
entry.silver_bank = atoi(row[7]);
entry.copper_bank = atoi(row[8]);
entry.platinum_cursor = atoi(row[9]);
entry.gold_cursor = atoi(row[10]);
entry.silver_cursor = atoi(row[11]);
entry.copper_cursor = atoi(row[12]);
entry.radiant_crystals = atoi(row[13]);
entry.career_radiant_crystals = atoi(row[14]);
entry.ebon_crystals = atoi(row[15]);
entry.career_ebon_crystals = atoi(row[16]);
e.id = atoi(row[0]);
e.platinum = atoi(row[1]);
e.gold = atoi(row[2]);
e.silver = atoi(row[3]);
e.copper = atoi(row[4]);
e.platinum_bank = atoi(row[5]);
e.gold_bank = atoi(row[6]);
e.silver_bank = atoi(row[7]);
e.copper_bank = atoi(row[8]);
e.platinum_cursor = atoi(row[9]);
e.gold_cursor = atoi(row[10]);
e.silver_cursor = atoi(row[11]);
e.copper_cursor = atoi(row[12]);
e.radiant_crystals = atoi(row[13]);
e.career_radiant_crystals = atoi(row[14]);
e.ebon_crystals = atoi(row[15]);
e.career_ebon_crystals = atoi(row[16]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterCurrency> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterCurrency> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterCurrency> all_entries;
@@ -401,33 +401,33 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterCurrency entry{};
CharacterCurrency e{};
entry.id = atoi(row[0]);
entry.platinum = atoi(row[1]);
entry.gold = atoi(row[2]);
entry.silver = atoi(row[3]);
entry.copper = atoi(row[4]);
entry.platinum_bank = atoi(row[5]);
entry.gold_bank = atoi(row[6]);
entry.silver_bank = atoi(row[7]);
entry.copper_bank = atoi(row[8]);
entry.platinum_cursor = atoi(row[9]);
entry.gold_cursor = atoi(row[10]);
entry.silver_cursor = atoi(row[11]);
entry.copper_cursor = atoi(row[12]);
entry.radiant_crystals = atoi(row[13]);
entry.career_radiant_crystals = atoi(row[14]);
entry.ebon_crystals = atoi(row[15]);
entry.career_ebon_crystals = atoi(row[16]);
e.id = atoi(row[0]);
e.platinum = atoi(row[1]);
e.gold = atoi(row[2]);
e.silver = atoi(row[3]);
e.copper = atoi(row[4]);
e.platinum_bank = atoi(row[5]);
e.gold_bank = atoi(row[6]);
e.silver_bank = atoi(row[7]);
e.copper_bank = atoi(row[8]);
e.platinum_cursor = atoi(row[9]);
e.gold_cursor = atoi(row[10]);
e.silver_cursor = atoi(row[11]);
e.copper_cursor = atoi(row[12]);
e.radiant_crystals = atoi(row[13]);
e.career_radiant_crystals = atoi(row[14]);
e.ebon_crystals = atoi(row[15]);
e.career_ebon_crystals = atoi(row[16]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -452,6 +452,32 @@ public:
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_CHARACTER_CURRENCY_REPOSITORY_H
File diff suppressed because it is too large Load Diff
@@ -82,16 +82,16 @@ public:
static CharacterDisciplines NewEntity()
{
CharacterDisciplines entry{};
CharacterDisciplines e{};
entry.id = 0;
entry.slot_id = 0;
entry.disc_id = 0;
e.id = 0;
e.slot_id = 0;
e.disc_id = 0;
return entry;
return e;
}
static CharacterDisciplines GetCharacterDisciplinesEntry(
static CharacterDisciplines GetCharacterDisciplines(
const std::vector<CharacterDisciplines> &character_discipliness,
int character_disciplines_id
)
@@ -120,13 +120,13 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterDisciplines entry{};
CharacterDisciplines e{};
entry.id = atoi(row[0]);
entry.slot_id = atoi(row[1]);
entry.disc_id = atoi(row[2]);
e.id = atoi(row[0]);
e.slot_id = atoi(row[1]);
e.disc_id = atoi(row[2]);
return entry;
return e;
}
return NewEntity();
@@ -151,24 +151,24 @@ public:
static int UpdateOne(
Database& db,
CharacterDisciplines character_disciplines_entry
const CharacterDisciplines &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(character_disciplines_entry.id));
update_values.push_back(columns[1] + " = " + std::to_string(character_disciplines_entry.slot_id));
update_values.push_back(columns[2] + " = " + std::to_string(character_disciplines_entry.disc_id));
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = " + std::to_string(e.slot_id));
v.push_back(columns[2] + " = " + std::to_string(e.disc_id));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_disciplines_entry.id
e.id
)
);
@@ -177,51 +177,51 @@ public:
static CharacterDisciplines InsertOne(
Database& db,
CharacterDisciplines character_disciplines_entry
CharacterDisciplines e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_disciplines_entry.id));
insert_values.push_back(std::to_string(character_disciplines_entry.slot_id));
insert_values.push_back(std::to_string(character_disciplines_entry.disc_id));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.slot_id));
v.push_back(std::to_string(e.disc_id));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_disciplines_entry.id = results.LastInsertedID();
return character_disciplines_entry;
e.id = results.LastInsertedID();
return e;
}
character_disciplines_entry = NewEntity();
e = NewEntity();
return character_disciplines_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterDisciplines> character_disciplines_entries
const std::vector<CharacterDisciplines> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_disciplines_entry: character_disciplines_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_disciplines_entry.id));
insert_values.push_back(std::to_string(character_disciplines_entry.slot_id));
insert_values.push_back(std::to_string(character_disciplines_entry.disc_id));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.slot_id));
v.push_back(std::to_string(e.disc_id));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -248,19 +248,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterDisciplines entry{};
CharacterDisciplines e{};
entry.id = atoi(row[0]);
entry.slot_id = atoi(row[1]);
entry.disc_id = atoi(row[2]);
e.id = atoi(row[0]);
e.slot_id = atoi(row[1]);
e.disc_id = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterDisciplines> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterDisciplines> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterDisciplines> all_entries;
@@ -275,19 +275,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterDisciplines entry{};
CharacterDisciplines e{};
entry.id = atoi(row[0]);
entry.slot_id = atoi(row[1]);
entry.disc_id = atoi(row[2]);
e.id = atoi(row[0]);
e.slot_id = atoi(row[1]);
e.disc_id = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -312,6 +312,32 @@ public:
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_CHARACTER_DISCIPLINES_REPOSITORY_H
@@ -85,17 +85,17 @@ public:
static CharacterExpModifiers NewEntity()
{
CharacterExpModifiers entry{};
CharacterExpModifiers e{};
entry.character_id = 0;
entry.zone_id = 0;
entry.aa_modifier = 0;
entry.exp_modifier = 0;
e.character_id = 0;
e.zone_id = 0;
e.aa_modifier = 0;
e.exp_modifier = 0;
return entry;
return e;
}
static CharacterExpModifiers GetCharacterExpModifiersEntry(
static CharacterExpModifiers GetCharacterExpModifiers(
const std::vector<CharacterExpModifiers> &character_exp_modifierss,
int character_exp_modifiers_id
)
@@ -124,14 +124,14 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterExpModifiers entry{};
CharacterExpModifiers e{};
entry.character_id = atoi(row[0]);
entry.zone_id = atoi(row[1]);
entry.aa_modifier = static_cast<float>(atof(row[2]));
entry.exp_modifier = static_cast<float>(atof(row[3]));
e.character_id = atoi(row[0]);
e.zone_id = atoi(row[1]);
e.aa_modifier = static_cast<float>(atof(row[2]));
e.exp_modifier = static_cast<float>(atof(row[3]));
return entry;
return e;
}
return NewEntity();
@@ -156,25 +156,25 @@ public:
static int UpdateOne(
Database& db,
CharacterExpModifiers character_exp_modifiers_entry
const CharacterExpModifiers &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(character_exp_modifiers_entry.character_id));
update_values.push_back(columns[1] + " = " + std::to_string(character_exp_modifiers_entry.zone_id));
update_values.push_back(columns[2] + " = " + std::to_string(character_exp_modifiers_entry.aa_modifier));
update_values.push_back(columns[3] + " = " + std::to_string(character_exp_modifiers_entry.exp_modifier));
v.push_back(columns[0] + " = " + std::to_string(e.character_id));
v.push_back(columns[1] + " = " + std::to_string(e.zone_id));
v.push_back(columns[2] + " = " + std::to_string(e.aa_modifier));
v.push_back(columns[3] + " = " + std::to_string(e.exp_modifier));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_exp_modifiers_entry.character_id
e.character_id
)
);
@@ -183,53 +183,53 @@ public:
static CharacterExpModifiers InsertOne(
Database& db,
CharacterExpModifiers character_exp_modifiers_entry
CharacterExpModifiers e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_exp_modifiers_entry.character_id));
insert_values.push_back(std::to_string(character_exp_modifiers_entry.zone_id));
insert_values.push_back(std::to_string(character_exp_modifiers_entry.aa_modifier));
insert_values.push_back(std::to_string(character_exp_modifiers_entry.exp_modifier));
v.push_back(std::to_string(e.character_id));
v.push_back(std::to_string(e.zone_id));
v.push_back(std::to_string(e.aa_modifier));
v.push_back(std::to_string(e.exp_modifier));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_exp_modifiers_entry.character_id = results.LastInsertedID();
return character_exp_modifiers_entry;
e.character_id = results.LastInsertedID();
return e;
}
character_exp_modifiers_entry = NewEntity();
e = NewEntity();
return character_exp_modifiers_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterExpModifiers> character_exp_modifiers_entries
const std::vector<CharacterExpModifiers> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_exp_modifiers_entry: character_exp_modifiers_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_exp_modifiers_entry.character_id));
insert_values.push_back(std::to_string(character_exp_modifiers_entry.zone_id));
insert_values.push_back(std::to_string(character_exp_modifiers_entry.aa_modifier));
insert_values.push_back(std::to_string(character_exp_modifiers_entry.exp_modifier));
v.push_back(std::to_string(e.character_id));
v.push_back(std::to_string(e.zone_id));
v.push_back(std::to_string(e.aa_modifier));
v.push_back(std::to_string(e.exp_modifier));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -256,20 +256,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterExpModifiers entry{};
CharacterExpModifiers e{};
entry.character_id = atoi(row[0]);
entry.zone_id = atoi(row[1]);
entry.aa_modifier = static_cast<float>(atof(row[2]));
entry.exp_modifier = static_cast<float>(atof(row[3]));
e.character_id = atoi(row[0]);
e.zone_id = atoi(row[1]);
e.aa_modifier = static_cast<float>(atof(row[2]));
e.exp_modifier = static_cast<float>(atof(row[3]));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterExpModifiers> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterExpModifiers> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterExpModifiers> all_entries;
@@ -284,20 +284,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterExpModifiers entry{};
CharacterExpModifiers e{};
entry.character_id = atoi(row[0]);
entry.zone_id = atoi(row[1]);
entry.aa_modifier = static_cast<float>(atof(row[2]));
entry.exp_modifier = static_cast<float>(atof(row[3]));
e.character_id = atoi(row[0]);
e.zone_id = atoi(row[1]);
e.aa_modifier = static_cast<float>(atof(row[2]));
e.exp_modifier = static_cast<float>(atof(row[3]));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -322,6 +322,32 @@ public:
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_CHARACTER_EXP_MODIFIERS_REPOSITORY_H
@@ -94,20 +94,20 @@ public:
static CharacterExpeditionLockouts NewEntity()
{
CharacterExpeditionLockouts entry{};
CharacterExpeditionLockouts e{};
entry.id = 0;
entry.character_id = 0;
entry.expedition_name = "";
entry.event_name = "";
entry.expire_time = std::time(nullptr);
entry.duration = 0;
entry.from_expedition_uuid = "";
e.id = 0;
e.character_id = 0;
e.expedition_name = "";
e.event_name = "";
e.expire_time = std::time(nullptr);
e.duration = 0;
e.from_expedition_uuid = "";
return entry;
return e;
}
static CharacterExpeditionLockouts GetCharacterExpeditionLockoutsEntry(
static CharacterExpeditionLockouts GetCharacterExpeditionLockouts(
const std::vector<CharacterExpeditionLockouts> &character_expedition_lockoutss,
int character_expedition_lockouts_id
)
@@ -136,17 +136,17 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterExpeditionLockouts entry{};
CharacterExpeditionLockouts e{};
entry.id = atoi(row[0]);
entry.character_id = atoi(row[1]);
entry.expedition_name = row[2] ? row[2] : "";
entry.event_name = row[3] ? row[3] : "";
entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
entry.duration = atoi(row[5]);
entry.from_expedition_uuid = row[6] ? row[6] : "";
e.id = atoi(row[0]);
e.character_id = atoi(row[1]);
e.expedition_name = row[2] ? row[2] : "";
e.event_name = row[3] ? row[3] : "";
e.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
e.duration = atoi(row[5]);
e.from_expedition_uuid = row[6] ? row[6] : "";
return entry;
return e;
}
return NewEntity();
@@ -171,27 +171,27 @@ public:
static int UpdateOne(
Database& db,
CharacterExpeditionLockouts character_expedition_lockouts_entry
const CharacterExpeditionLockouts &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(character_expedition_lockouts_entry.character_id));
update_values.push_back(columns[2] + " = '" + Strings::Escape(character_expedition_lockouts_entry.expedition_name) + "'");
update_values.push_back(columns[3] + " = '" + Strings::Escape(character_expedition_lockouts_entry.event_name) + "'");
update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (character_expedition_lockouts_entry.expire_time > 0 ? std::to_string(character_expedition_lockouts_entry.expire_time) : "null") + ")");
update_values.push_back(columns[5] + " = " + std::to_string(character_expedition_lockouts_entry.duration));
update_values.push_back(columns[6] + " = '" + Strings::Escape(character_expedition_lockouts_entry.from_expedition_uuid) + "'");
v.push_back(columns[1] + " = " + std::to_string(e.character_id));
v.push_back(columns[2] + " = '" + Strings::Escape(e.expedition_name) + "'");
v.push_back(columns[3] + " = '" + Strings::Escape(e.event_name) + "'");
v.push_back(columns[4] + " = FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")");
v.push_back(columns[5] + " = " + std::to_string(e.duration));
v.push_back(columns[6] + " = '" + Strings::Escape(e.from_expedition_uuid) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_expedition_lockouts_entry.id
e.id
)
);
@@ -200,59 +200,59 @@ public:
static CharacterExpeditionLockouts InsertOne(
Database& db,
CharacterExpeditionLockouts character_expedition_lockouts_entry
CharacterExpeditionLockouts e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_expedition_lockouts_entry.id));
insert_values.push_back(std::to_string(character_expedition_lockouts_entry.character_id));
insert_values.push_back("'" + Strings::Escape(character_expedition_lockouts_entry.expedition_name) + "'");
insert_values.push_back("'" + Strings::Escape(character_expedition_lockouts_entry.event_name) + "'");
insert_values.push_back("FROM_UNIXTIME(" + (character_expedition_lockouts_entry.expire_time > 0 ? std::to_string(character_expedition_lockouts_entry.expire_time) : "null") + ")");
insert_values.push_back(std::to_string(character_expedition_lockouts_entry.duration));
insert_values.push_back("'" + Strings::Escape(character_expedition_lockouts_entry.from_expedition_uuid) + "'");
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.character_id));
v.push_back("'" + Strings::Escape(e.expedition_name) + "'");
v.push_back("'" + Strings::Escape(e.event_name) + "'");
v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")");
v.push_back(std::to_string(e.duration));
v.push_back("'" + Strings::Escape(e.from_expedition_uuid) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_expedition_lockouts_entry.id = results.LastInsertedID();
return character_expedition_lockouts_entry;
e.id = results.LastInsertedID();
return e;
}
character_expedition_lockouts_entry = NewEntity();
e = NewEntity();
return character_expedition_lockouts_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterExpeditionLockouts> character_expedition_lockouts_entries
const std::vector<CharacterExpeditionLockouts> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_expedition_lockouts_entry: character_expedition_lockouts_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_expedition_lockouts_entry.id));
insert_values.push_back(std::to_string(character_expedition_lockouts_entry.character_id));
insert_values.push_back("'" + Strings::Escape(character_expedition_lockouts_entry.expedition_name) + "'");
insert_values.push_back("'" + Strings::Escape(character_expedition_lockouts_entry.event_name) + "'");
insert_values.push_back("FROM_UNIXTIME(" + (character_expedition_lockouts_entry.expire_time > 0 ? std::to_string(character_expedition_lockouts_entry.expire_time) : "null") + ")");
insert_values.push_back(std::to_string(character_expedition_lockouts_entry.duration));
insert_values.push_back("'" + Strings::Escape(character_expedition_lockouts_entry.from_expedition_uuid) + "'");
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.character_id));
v.push_back("'" + Strings::Escape(e.expedition_name) + "'");
v.push_back("'" + Strings::Escape(e.event_name) + "'");
v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")");
v.push_back(std::to_string(e.duration));
v.push_back("'" + Strings::Escape(e.from_expedition_uuid) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -279,23 +279,23 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterExpeditionLockouts entry{};
CharacterExpeditionLockouts e{};
entry.id = atoi(row[0]);
entry.character_id = atoi(row[1]);
entry.expedition_name = row[2] ? row[2] : "";
entry.event_name = row[3] ? row[3] : "";
entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
entry.duration = atoi(row[5]);
entry.from_expedition_uuid = row[6] ? row[6] : "";
e.id = atoi(row[0]);
e.character_id = atoi(row[1]);
e.expedition_name = row[2] ? row[2] : "";
e.event_name = row[3] ? row[3] : "";
e.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
e.duration = atoi(row[5]);
e.from_expedition_uuid = row[6] ? row[6] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterExpeditionLockouts> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterExpeditionLockouts> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterExpeditionLockouts> all_entries;
@@ -310,23 +310,23 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterExpeditionLockouts entry{};
CharacterExpeditionLockouts e{};
entry.id = atoi(row[0]);
entry.character_id = atoi(row[1]);
entry.expedition_name = row[2] ? row[2] : "";
entry.event_name = row[3] ? row[3] : "";
entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
entry.duration = atoi(row[5]);
entry.from_expedition_uuid = row[6] ? row[6] : "";
e.id = atoi(row[0]);
e.character_id = atoi(row[1]);
e.expedition_name = row[2] ? row[2] : "";
e.event_name = row[3] ? row[3] : "";
e.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
e.duration = atoi(row[5]);
e.from_expedition_uuid = row[6] ? row[6] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -351,6 +351,32 @@ public:
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_CHARACTER_EXPEDITION_LOCKOUTS_REPOSITORY_H
@@ -79,15 +79,15 @@ public:
static CharacterInspectMessages NewEntity()
{
CharacterInspectMessages entry{};
CharacterInspectMessages e{};
entry.id = 0;
entry.inspect_message = "";
e.id = 0;
e.inspect_message = "";
return entry;
return e;
}
static CharacterInspectMessages GetCharacterInspectMessagesEntry(
static CharacterInspectMessages GetCharacterInspectMessages(
const std::vector<CharacterInspectMessages> &character_inspect_messagess,
int character_inspect_messages_id
)
@@ -116,12 +116,12 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterInspectMessages entry{};
CharacterInspectMessages e{};
entry.id = atoi(row[0]);
entry.inspect_message = row[1] ? row[1] : "";
e.id = atoi(row[0]);
e.inspect_message = row[1] ? row[1] : "";
return entry;
return e;
}
return NewEntity();
@@ -146,23 +146,23 @@ public:
static int UpdateOne(
Database& db,
CharacterInspectMessages character_inspect_messages_entry
const CharacterInspectMessages &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(character_inspect_messages_entry.id));
update_values.push_back(columns[1] + " = '" + Strings::Escape(character_inspect_messages_entry.inspect_message) + "'");
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = '" + Strings::Escape(e.inspect_message) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_inspect_messages_entry.id
e.id
)
);
@@ -171,49 +171,49 @@ public:
static CharacterInspectMessages InsertOne(
Database& db,
CharacterInspectMessages character_inspect_messages_entry
CharacterInspectMessages e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_inspect_messages_entry.id));
insert_values.push_back("'" + Strings::Escape(character_inspect_messages_entry.inspect_message) + "'");
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.inspect_message) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_inspect_messages_entry.id = results.LastInsertedID();
return character_inspect_messages_entry;
e.id = results.LastInsertedID();
return e;
}
character_inspect_messages_entry = NewEntity();
e = NewEntity();
return character_inspect_messages_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterInspectMessages> character_inspect_messages_entries
const std::vector<CharacterInspectMessages> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_inspect_messages_entry: character_inspect_messages_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_inspect_messages_entry.id));
insert_values.push_back("'" + Strings::Escape(character_inspect_messages_entry.inspect_message) + "'");
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.inspect_message) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -240,18 +240,18 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterInspectMessages entry{};
CharacterInspectMessages e{};
entry.id = atoi(row[0]);
entry.inspect_message = row[1] ? row[1] : "";
e.id = atoi(row[0]);
e.inspect_message = row[1] ? row[1] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterInspectMessages> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterInspectMessages> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterInspectMessages> all_entries;
@@ -266,18 +266,18 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterInspectMessages entry{};
CharacterInspectMessages e{};
entry.id = atoi(row[0]);
entry.inspect_message = row[1] ? row[1] : "";
e.id = atoi(row[0]);
e.inspect_message = row[1] ? row[1] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -302,6 +302,32 @@ public:
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_CHARACTER_INSPECT_MESSAGES_REPOSITORY_H
@@ -100,22 +100,22 @@ public:
static CharacterInstanceSafereturns NewEntity()
{
CharacterInstanceSafereturns entry{};
CharacterInstanceSafereturns e{};
entry.id = 0;
entry.character_id = 0;
entry.instance_zone_id = 0;
entry.instance_id = 0;
entry.safe_zone_id = 0;
entry.safe_x = 0;
entry.safe_y = 0;
entry.safe_z = 0;
entry.safe_heading = 0;
e.id = 0;
e.character_id = 0;
e.instance_zone_id = 0;
e.instance_id = 0;
e.safe_zone_id = 0;
e.safe_x = 0;
e.safe_y = 0;
e.safe_z = 0;
e.safe_heading = 0;
return entry;
return e;
}
static CharacterInstanceSafereturns GetCharacterInstanceSafereturnsEntry(
static CharacterInstanceSafereturns GetCharacterInstanceSafereturns(
const std::vector<CharacterInstanceSafereturns> &character_instance_safereturnss,
int character_instance_safereturns_id
)
@@ -144,19 +144,19 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterInstanceSafereturns entry{};
CharacterInstanceSafereturns e{};
entry.id = atoi(row[0]);
entry.character_id = atoi(row[1]);
entry.instance_zone_id = atoi(row[2]);
entry.instance_id = atoi(row[3]);
entry.safe_zone_id = atoi(row[4]);
entry.safe_x = static_cast<float>(atof(row[5]));
entry.safe_y = static_cast<float>(atof(row[6]));
entry.safe_z = static_cast<float>(atof(row[7]));
entry.safe_heading = static_cast<float>(atof(row[8]));
e.id = atoi(row[0]);
e.character_id = atoi(row[1]);
e.instance_zone_id = atoi(row[2]);
e.instance_id = atoi(row[3]);
e.safe_zone_id = atoi(row[4]);
e.safe_x = static_cast<float>(atof(row[5]));
e.safe_y = static_cast<float>(atof(row[6]));
e.safe_z = static_cast<float>(atof(row[7]));
e.safe_heading = static_cast<float>(atof(row[8]));
return entry;
return e;
}
return NewEntity();
@@ -181,29 +181,29 @@ public:
static int UpdateOne(
Database& db,
CharacterInstanceSafereturns character_instance_safereturns_entry
const CharacterInstanceSafereturns &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(character_instance_safereturns_entry.character_id));
update_values.push_back(columns[2] + " = " + std::to_string(character_instance_safereturns_entry.instance_zone_id));
update_values.push_back(columns[3] + " = " + std::to_string(character_instance_safereturns_entry.instance_id));
update_values.push_back(columns[4] + " = " + std::to_string(character_instance_safereturns_entry.safe_zone_id));
update_values.push_back(columns[5] + " = " + std::to_string(character_instance_safereturns_entry.safe_x));
update_values.push_back(columns[6] + " = " + std::to_string(character_instance_safereturns_entry.safe_y));
update_values.push_back(columns[7] + " = " + std::to_string(character_instance_safereturns_entry.safe_z));
update_values.push_back(columns[8] + " = " + std::to_string(character_instance_safereturns_entry.safe_heading));
v.push_back(columns[1] + " = " + std::to_string(e.character_id));
v.push_back(columns[2] + " = " + std::to_string(e.instance_zone_id));
v.push_back(columns[3] + " = " + std::to_string(e.instance_id));
v.push_back(columns[4] + " = " + std::to_string(e.safe_zone_id));
v.push_back(columns[5] + " = " + std::to_string(e.safe_x));
v.push_back(columns[6] + " = " + std::to_string(e.safe_y));
v.push_back(columns[7] + " = " + std::to_string(e.safe_z));
v.push_back(columns[8] + " = " + std::to_string(e.safe_heading));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_instance_safereturns_entry.id
e.id
)
);
@@ -212,63 +212,63 @@ public:
static CharacterInstanceSafereturns InsertOne(
Database& db,
CharacterInstanceSafereturns character_instance_safereturns_entry
CharacterInstanceSafereturns e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_instance_safereturns_entry.id));
insert_values.push_back(std::to_string(character_instance_safereturns_entry.character_id));
insert_values.push_back(std::to_string(character_instance_safereturns_entry.instance_zone_id));
insert_values.push_back(std::to_string(character_instance_safereturns_entry.instance_id));
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_zone_id));
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_x));
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_y));
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_z));
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_heading));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.character_id));
v.push_back(std::to_string(e.instance_zone_id));
v.push_back(std::to_string(e.instance_id));
v.push_back(std::to_string(e.safe_zone_id));
v.push_back(std::to_string(e.safe_x));
v.push_back(std::to_string(e.safe_y));
v.push_back(std::to_string(e.safe_z));
v.push_back(std::to_string(e.safe_heading));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_instance_safereturns_entry.id = results.LastInsertedID();
return character_instance_safereturns_entry;
e.id = results.LastInsertedID();
return e;
}
character_instance_safereturns_entry = NewEntity();
e = NewEntity();
return character_instance_safereturns_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterInstanceSafereturns> character_instance_safereturns_entries
const std::vector<CharacterInstanceSafereturns> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_instance_safereturns_entry: character_instance_safereturns_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_instance_safereturns_entry.id));
insert_values.push_back(std::to_string(character_instance_safereturns_entry.character_id));
insert_values.push_back(std::to_string(character_instance_safereturns_entry.instance_zone_id));
insert_values.push_back(std::to_string(character_instance_safereturns_entry.instance_id));
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_zone_id));
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_x));
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_y));
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_z));
insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_heading));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.character_id));
v.push_back(std::to_string(e.instance_zone_id));
v.push_back(std::to_string(e.instance_id));
v.push_back(std::to_string(e.safe_zone_id));
v.push_back(std::to_string(e.safe_x));
v.push_back(std::to_string(e.safe_y));
v.push_back(std::to_string(e.safe_z));
v.push_back(std::to_string(e.safe_heading));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -295,25 +295,25 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterInstanceSafereturns entry{};
CharacterInstanceSafereturns e{};
entry.id = atoi(row[0]);
entry.character_id = atoi(row[1]);
entry.instance_zone_id = atoi(row[2]);
entry.instance_id = atoi(row[3]);
entry.safe_zone_id = atoi(row[4]);
entry.safe_x = static_cast<float>(atof(row[5]));
entry.safe_y = static_cast<float>(atof(row[6]));
entry.safe_z = static_cast<float>(atof(row[7]));
entry.safe_heading = static_cast<float>(atof(row[8]));
e.id = atoi(row[0]);
e.character_id = atoi(row[1]);
e.instance_zone_id = atoi(row[2]);
e.instance_id = atoi(row[3]);
e.safe_zone_id = atoi(row[4]);
e.safe_x = static_cast<float>(atof(row[5]));
e.safe_y = static_cast<float>(atof(row[6]));
e.safe_z = static_cast<float>(atof(row[7]));
e.safe_heading = static_cast<float>(atof(row[8]));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterInstanceSafereturns> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterInstanceSafereturns> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterInstanceSafereturns> all_entries;
@@ -328,25 +328,25 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterInstanceSafereturns entry{};
CharacterInstanceSafereturns e{};
entry.id = atoi(row[0]);
entry.character_id = atoi(row[1]);
entry.instance_zone_id = atoi(row[2]);
entry.instance_id = atoi(row[3]);
entry.safe_zone_id = atoi(row[4]);
entry.safe_x = static_cast<float>(atof(row[5]));
entry.safe_y = static_cast<float>(atof(row[6]));
entry.safe_z = static_cast<float>(atof(row[7]));
entry.safe_heading = static_cast<float>(atof(row[8]));
e.id = atoi(row[0]);
e.character_id = atoi(row[1]);
e.instance_zone_id = atoi(row[2]);
e.instance_id = atoi(row[3]);
e.safe_zone_id = atoi(row[4]);
e.safe_x = static_cast<float>(atof(row[5]));
e.safe_y = static_cast<float>(atof(row[6]));
e.safe_z = static_cast<float>(atof(row[7]));
e.safe_heading = static_cast<float>(atof(row[8]));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -371,6 +371,32 @@ public:
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_CHARACTER_INSTANCE_SAFERETURNS_REPOSITORY_H
@@ -82,16 +82,16 @@ public:
static CharacterItemRecast NewEntity()
{
CharacterItemRecast entry{};
CharacterItemRecast e{};
entry.id = 0;
entry.recast_type = 0;
entry.timestamp = 0;
e.id = 0;
e.recast_type = 0;
e.timestamp = 0;
return entry;
return e;
}
static CharacterItemRecast GetCharacterItemRecastEntry(
static CharacterItemRecast GetCharacterItemRecast(
const std::vector<CharacterItemRecast> &character_item_recasts,
int character_item_recast_id
)
@@ -120,13 +120,13 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterItemRecast entry{};
CharacterItemRecast e{};
entry.id = atoi(row[0]);
entry.recast_type = atoi(row[1]);
entry.timestamp = atoi(row[2]);
e.id = atoi(row[0]);
e.recast_type = atoi(row[1]);
e.timestamp = atoi(row[2]);
return entry;
return e;
}
return NewEntity();
@@ -151,24 +151,24 @@ public:
static int UpdateOne(
Database& db,
CharacterItemRecast character_item_recast_entry
const CharacterItemRecast &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(character_item_recast_entry.id));
update_values.push_back(columns[1] + " = " + std::to_string(character_item_recast_entry.recast_type));
update_values.push_back(columns[2] + " = " + std::to_string(character_item_recast_entry.timestamp));
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = " + std::to_string(e.recast_type));
v.push_back(columns[2] + " = " + std::to_string(e.timestamp));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_item_recast_entry.id
e.id
)
);
@@ -177,51 +177,51 @@ public:
static CharacterItemRecast InsertOne(
Database& db,
CharacterItemRecast character_item_recast_entry
CharacterItemRecast e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_item_recast_entry.id));
insert_values.push_back(std::to_string(character_item_recast_entry.recast_type));
insert_values.push_back(std::to_string(character_item_recast_entry.timestamp));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.recast_type));
v.push_back(std::to_string(e.timestamp));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_item_recast_entry.id = results.LastInsertedID();
return character_item_recast_entry;
e.id = results.LastInsertedID();
return e;
}
character_item_recast_entry = NewEntity();
e = NewEntity();
return character_item_recast_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterItemRecast> character_item_recast_entries
const std::vector<CharacterItemRecast> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_item_recast_entry: character_item_recast_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_item_recast_entry.id));
insert_values.push_back(std::to_string(character_item_recast_entry.recast_type));
insert_values.push_back(std::to_string(character_item_recast_entry.timestamp));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.recast_type));
v.push_back(std::to_string(e.timestamp));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -248,19 +248,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterItemRecast entry{};
CharacterItemRecast e{};
entry.id = atoi(row[0]);
entry.recast_type = atoi(row[1]);
entry.timestamp = atoi(row[2]);
e.id = atoi(row[0]);
e.recast_type = atoi(row[1]);
e.timestamp = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterItemRecast> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterItemRecast> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterItemRecast> all_entries;
@@ -275,19 +275,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterItemRecast entry{};
CharacterItemRecast e{};
entry.id = atoi(row[0]);
entry.recast_type = atoi(row[1]);
entry.timestamp = atoi(row[2]);
e.id = atoi(row[0]);
e.recast_type = atoi(row[1]);
e.timestamp = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -312,6 +312,32 @@ public:
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_CHARACTER_ITEM_RECAST_REPOSITORY_H
@@ -82,16 +82,16 @@ public:
static CharacterLanguages NewEntity()
{
CharacterLanguages entry{};
CharacterLanguages e{};
entry.id = 0;
entry.lang_id = 0;
entry.value = 0;
e.id = 0;
e.lang_id = 0;
e.value = 0;
return entry;
return e;
}
static CharacterLanguages GetCharacterLanguagesEntry(
static CharacterLanguages GetCharacterLanguages(
const std::vector<CharacterLanguages> &character_languagess,
int character_languages_id
)
@@ -120,13 +120,13 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterLanguages entry{};
CharacterLanguages e{};
entry.id = atoi(row[0]);
entry.lang_id = atoi(row[1]);
entry.value = atoi(row[2]);
e.id = atoi(row[0]);
e.lang_id = atoi(row[1]);
e.value = atoi(row[2]);
return entry;
return e;
}
return NewEntity();
@@ -151,23 +151,23 @@ public:
static int UpdateOne(
Database& db,
CharacterLanguages character_languages_entry
const CharacterLanguages &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(character_languages_entry.lang_id));
update_values.push_back(columns[2] + " = " + std::to_string(character_languages_entry.value));
v.push_back(columns[1] + " = " + std::to_string(e.lang_id));
v.push_back(columns[2] + " = " + std::to_string(e.value));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_languages_entry.id
e.id
)
);
@@ -176,51 +176,51 @@ public:
static CharacterLanguages InsertOne(
Database& db,
CharacterLanguages character_languages_entry
CharacterLanguages e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_languages_entry.id));
insert_values.push_back(std::to_string(character_languages_entry.lang_id));
insert_values.push_back(std::to_string(character_languages_entry.value));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.lang_id));
v.push_back(std::to_string(e.value));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_languages_entry.id = results.LastInsertedID();
return character_languages_entry;
e.id = results.LastInsertedID();
return e;
}
character_languages_entry = NewEntity();
e = NewEntity();
return character_languages_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterLanguages> character_languages_entries
const std::vector<CharacterLanguages> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_languages_entry: character_languages_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_languages_entry.id));
insert_values.push_back(std::to_string(character_languages_entry.lang_id));
insert_values.push_back(std::to_string(character_languages_entry.value));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.lang_id));
v.push_back(std::to_string(e.value));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -247,19 +247,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterLanguages entry{};
CharacterLanguages e{};
entry.id = atoi(row[0]);
entry.lang_id = atoi(row[1]);
entry.value = atoi(row[2]);
e.id = atoi(row[0]);
e.lang_id = atoi(row[1]);
e.value = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterLanguages> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterLanguages> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterLanguages> all_entries;
@@ -274,19 +274,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterLanguages entry{};
CharacterLanguages e{};
entry.id = atoi(row[0]);
entry.lang_id = atoi(row[1]);
entry.value = atoi(row[2]);
e.id = atoi(row[0]);
e.lang_id = atoi(row[1]);
e.value = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -311,6 +311,32 @@ public:
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_CHARACTER_LANGUAGES_REPOSITORY_H
@@ -82,16 +82,16 @@ public:
static CharacterLeadershipAbilities NewEntity()
{
CharacterLeadershipAbilities entry{};
CharacterLeadershipAbilities e{};
entry.id = 0;
entry.slot = 0;
entry.rank = 0;
e.id = 0;
e.slot = 0;
e.rank = 0;
return entry;
return e;
}
static CharacterLeadershipAbilities GetCharacterLeadershipAbilitiesEntry(
static CharacterLeadershipAbilities GetCharacterLeadershipAbilities(
const std::vector<CharacterLeadershipAbilities> &character_leadership_abilitiess,
int character_leadership_abilities_id
)
@@ -120,13 +120,13 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterLeadershipAbilities entry{};
CharacterLeadershipAbilities e{};
entry.id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.rank = atoi(row[2]);
e.id = atoi(row[0]);
e.slot = atoi(row[1]);
e.rank = atoi(row[2]);
return entry;
return e;
}
return NewEntity();
@@ -151,24 +151,24 @@ public:
static int UpdateOne(
Database& db,
CharacterLeadershipAbilities character_leadership_abilities_entry
const CharacterLeadershipAbilities &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(character_leadership_abilities_entry.id));
update_values.push_back(columns[1] + " = " + std::to_string(character_leadership_abilities_entry.slot));
update_values.push_back(columns[2] + " = " + std::to_string(character_leadership_abilities_entry.rank));
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = " + std::to_string(e.slot));
v.push_back(columns[2] + " = " + std::to_string(e.rank));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_leadership_abilities_entry.id
e.id
)
);
@@ -177,51 +177,51 @@ public:
static CharacterLeadershipAbilities InsertOne(
Database& db,
CharacterLeadershipAbilities character_leadership_abilities_entry
CharacterLeadershipAbilities e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_leadership_abilities_entry.id));
insert_values.push_back(std::to_string(character_leadership_abilities_entry.slot));
insert_values.push_back(std::to_string(character_leadership_abilities_entry.rank));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.slot));
v.push_back(std::to_string(e.rank));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_leadership_abilities_entry.id = results.LastInsertedID();
return character_leadership_abilities_entry;
e.id = results.LastInsertedID();
return e;
}
character_leadership_abilities_entry = NewEntity();
e = NewEntity();
return character_leadership_abilities_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterLeadershipAbilities> character_leadership_abilities_entries
const std::vector<CharacterLeadershipAbilities> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_leadership_abilities_entry: character_leadership_abilities_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_leadership_abilities_entry.id));
insert_values.push_back(std::to_string(character_leadership_abilities_entry.slot));
insert_values.push_back(std::to_string(character_leadership_abilities_entry.rank));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.slot));
v.push_back(std::to_string(e.rank));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -248,19 +248,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterLeadershipAbilities entry{};
CharacterLeadershipAbilities e{};
entry.id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.rank = atoi(row[2]);
e.id = atoi(row[0]);
e.slot = atoi(row[1]);
e.rank = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterLeadershipAbilities> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterLeadershipAbilities> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterLeadershipAbilities> all_entries;
@@ -275,19 +275,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterLeadershipAbilities entry{};
CharacterLeadershipAbilities e{};
entry.id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.rank = atoi(row[2]);
e.id = atoi(row[0]);
e.slot = atoi(row[1]);
e.rank = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -312,6 +312,32 @@ public:
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_CHARACTER_LEADERSHIP_ABILITIES_REPOSITORY_H
@@ -94,20 +94,20 @@ public:
static CharacterMaterial NewEntity()
{
CharacterMaterial entry{};
CharacterMaterial e{};
entry.id = 0;
entry.slot = 0;
entry.blue = 0;
entry.green = 0;
entry.red = 0;
entry.use_tint = 0;
entry.color = 0;
e.id = 0;
e.slot = 0;
e.blue = 0;
e.green = 0;
e.red = 0;
e.use_tint = 0;
e.color = 0;
return entry;
return e;
}
static CharacterMaterial GetCharacterMaterialEntry(
static CharacterMaterial GetCharacterMaterial(
const std::vector<CharacterMaterial> &character_materials,
int character_material_id
)
@@ -136,17 +136,17 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterMaterial entry{};
CharacterMaterial e{};
entry.id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.blue = atoi(row[2]);
entry.green = atoi(row[3]);
entry.red = atoi(row[4]);
entry.use_tint = atoi(row[5]);
entry.color = atoi(row[6]);
e.id = atoi(row[0]);
e.slot = atoi(row[1]);
e.blue = atoi(row[2]);
e.green = atoi(row[3]);
e.red = atoi(row[4]);
e.use_tint = atoi(row[5]);
e.color = atoi(row[6]);
return entry;
return e;
}
return NewEntity();
@@ -171,27 +171,27 @@ public:
static int UpdateOne(
Database& db,
CharacterMaterial character_material_entry
const CharacterMaterial &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(character_material_entry.slot));
update_values.push_back(columns[2] + " = " + std::to_string(character_material_entry.blue));
update_values.push_back(columns[3] + " = " + std::to_string(character_material_entry.green));
update_values.push_back(columns[4] + " = " + std::to_string(character_material_entry.red));
update_values.push_back(columns[5] + " = " + std::to_string(character_material_entry.use_tint));
update_values.push_back(columns[6] + " = " + std::to_string(character_material_entry.color));
v.push_back(columns[1] + " = " + std::to_string(e.slot));
v.push_back(columns[2] + " = " + std::to_string(e.blue));
v.push_back(columns[3] + " = " + std::to_string(e.green));
v.push_back(columns[4] + " = " + std::to_string(e.red));
v.push_back(columns[5] + " = " + std::to_string(e.use_tint));
v.push_back(columns[6] + " = " + std::to_string(e.color));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_material_entry.id
e.id
)
);
@@ -200,59 +200,59 @@ public:
static CharacterMaterial InsertOne(
Database& db,
CharacterMaterial character_material_entry
CharacterMaterial e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_material_entry.id));
insert_values.push_back(std::to_string(character_material_entry.slot));
insert_values.push_back(std::to_string(character_material_entry.blue));
insert_values.push_back(std::to_string(character_material_entry.green));
insert_values.push_back(std::to_string(character_material_entry.red));
insert_values.push_back(std::to_string(character_material_entry.use_tint));
insert_values.push_back(std::to_string(character_material_entry.color));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.slot));
v.push_back(std::to_string(e.blue));
v.push_back(std::to_string(e.green));
v.push_back(std::to_string(e.red));
v.push_back(std::to_string(e.use_tint));
v.push_back(std::to_string(e.color));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_material_entry.id = results.LastInsertedID();
return character_material_entry;
e.id = results.LastInsertedID();
return e;
}
character_material_entry = NewEntity();
e = NewEntity();
return character_material_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterMaterial> character_material_entries
const std::vector<CharacterMaterial> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_material_entry: character_material_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_material_entry.id));
insert_values.push_back(std::to_string(character_material_entry.slot));
insert_values.push_back(std::to_string(character_material_entry.blue));
insert_values.push_back(std::to_string(character_material_entry.green));
insert_values.push_back(std::to_string(character_material_entry.red));
insert_values.push_back(std::to_string(character_material_entry.use_tint));
insert_values.push_back(std::to_string(character_material_entry.color));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.slot));
v.push_back(std::to_string(e.blue));
v.push_back(std::to_string(e.green));
v.push_back(std::to_string(e.red));
v.push_back(std::to_string(e.use_tint));
v.push_back(std::to_string(e.color));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -279,23 +279,23 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterMaterial entry{};
CharacterMaterial e{};
entry.id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.blue = atoi(row[2]);
entry.green = atoi(row[3]);
entry.red = atoi(row[4]);
entry.use_tint = atoi(row[5]);
entry.color = atoi(row[6]);
e.id = atoi(row[0]);
e.slot = atoi(row[1]);
e.blue = atoi(row[2]);
e.green = atoi(row[3]);
e.red = atoi(row[4]);
e.use_tint = atoi(row[5]);
e.color = atoi(row[6]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterMaterial> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterMaterial> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterMaterial> all_entries;
@@ -310,23 +310,23 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterMaterial entry{};
CharacterMaterial e{};
entry.id = atoi(row[0]);
entry.slot = atoi(row[1]);
entry.blue = atoi(row[2]);
entry.green = atoi(row[3]);
entry.red = atoi(row[4]);
entry.use_tint = atoi(row[5]);
entry.color = atoi(row[6]);
e.id = atoi(row[0]);
e.slot = atoi(row[1]);
e.blue = atoi(row[2]);
e.green = atoi(row[3]);
e.red = atoi(row[4]);
e.use_tint = atoi(row[5]);
e.color = atoi(row[6]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -351,6 +351,32 @@ public:
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_CHARACTER_MATERIAL_REPOSITORY_H
@@ -82,16 +82,16 @@ public:
static CharacterMemmedSpells NewEntity()
{
CharacterMemmedSpells entry{};
CharacterMemmedSpells e{};
entry.id = 0;
entry.slot_id = 0;
entry.spell_id = 0;
e.id = 0;
e.slot_id = 0;
e.spell_id = 0;
return entry;
return e;
}
static CharacterMemmedSpells GetCharacterMemmedSpellsEntry(
static CharacterMemmedSpells GetCharacterMemmedSpells(
const std::vector<CharacterMemmedSpells> &character_memmed_spellss,
int character_memmed_spells_id
)
@@ -120,13 +120,13 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterMemmedSpells entry{};
CharacterMemmedSpells e{};
entry.id = atoi(row[0]);
entry.slot_id = atoi(row[1]);
entry.spell_id = atoi(row[2]);
e.id = atoi(row[0]);
e.slot_id = atoi(row[1]);
e.spell_id = atoi(row[2]);
return entry;
return e;
}
return NewEntity();
@@ -151,24 +151,24 @@ public:
static int UpdateOne(
Database& db,
CharacterMemmedSpells character_memmed_spells_entry
const CharacterMemmedSpells &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(character_memmed_spells_entry.id));
update_values.push_back(columns[1] + " = " + std::to_string(character_memmed_spells_entry.slot_id));
update_values.push_back(columns[2] + " = " + std::to_string(character_memmed_spells_entry.spell_id));
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = " + std::to_string(e.slot_id));
v.push_back(columns[2] + " = " + std::to_string(e.spell_id));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_memmed_spells_entry.id
e.id
)
);
@@ -177,51 +177,51 @@ public:
static CharacterMemmedSpells InsertOne(
Database& db,
CharacterMemmedSpells character_memmed_spells_entry
CharacterMemmedSpells e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_memmed_spells_entry.id));
insert_values.push_back(std::to_string(character_memmed_spells_entry.slot_id));
insert_values.push_back(std::to_string(character_memmed_spells_entry.spell_id));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.slot_id));
v.push_back(std::to_string(e.spell_id));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_memmed_spells_entry.id = results.LastInsertedID();
return character_memmed_spells_entry;
e.id = results.LastInsertedID();
return e;
}
character_memmed_spells_entry = NewEntity();
e = NewEntity();
return character_memmed_spells_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterMemmedSpells> character_memmed_spells_entries
const std::vector<CharacterMemmedSpells> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_memmed_spells_entry: character_memmed_spells_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_memmed_spells_entry.id));
insert_values.push_back(std::to_string(character_memmed_spells_entry.slot_id));
insert_values.push_back(std::to_string(character_memmed_spells_entry.spell_id));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.slot_id));
v.push_back(std::to_string(e.spell_id));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -248,19 +248,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterMemmedSpells entry{};
CharacterMemmedSpells e{};
entry.id = atoi(row[0]);
entry.slot_id = atoi(row[1]);
entry.spell_id = atoi(row[2]);
e.id = atoi(row[0]);
e.slot_id = atoi(row[1]);
e.spell_id = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterMemmedSpells> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterMemmedSpells> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterMemmedSpells> all_entries;
@@ -275,19 +275,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterMemmedSpells entry{};
CharacterMemmedSpells e{};
entry.id = atoi(row[0]);
entry.slot_id = atoi(row[1]);
entry.spell_id = atoi(row[2]);
e.id = atoi(row[0]);
e.slot_id = atoi(row[1]);
e.spell_id = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -312,6 +312,32 @@ public:
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_CHARACTER_MEMMED_SPELLS_REPOSITORY_H
@@ -0,0 +1,333 @@
/**
* 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_CHARACTER_PEQZONE_FLAGS_REPOSITORY_H
#define EQEMU_BASE_CHARACTER_PEQZONE_FLAGS_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseCharacterPeqzoneFlagsRepository {
public:
struct CharacterPeqzoneFlags {
int id;
int zone_id;
};
static std::string PrimaryKey()
{
return std::string("id");
}
static std::vector<std::string> Columns()
{
return {
"id",
"zone_id",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"zone_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("character_peqzone_flags");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static CharacterPeqzoneFlags NewEntity()
{
CharacterPeqzoneFlags e{};
e.id = 0;
e.zone_id = 0;
return e;
}
static CharacterPeqzoneFlags GetCharacterPeqzoneFlags(
const std::vector<CharacterPeqzoneFlags> &character_peqzone_flagss,
int character_peqzone_flags_id
)
{
for (auto &character_peqzone_flags : character_peqzone_flagss) {
if (character_peqzone_flags.id == character_peqzone_flags_id) {
return character_peqzone_flags;
}
}
return NewEntity();
}
static CharacterPeqzoneFlags FindOne(
Database& db,
int character_peqzone_flags_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
character_peqzone_flags_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterPeqzoneFlags e{};
e.id = atoi(row[0]);
e.zone_id = atoi(row[1]);
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int character_peqzone_flags_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
character_peqzone_flags_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const CharacterPeqzoneFlags &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = " + std::to_string(e.zone_id));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static CharacterPeqzoneFlags InsertOne(
Database& db,
CharacterPeqzoneFlags e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.zone_id));
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<CharacterPeqzoneFlags> &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.zone_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<CharacterPeqzoneFlags> All(Database& db)
{
std::vector<CharacterPeqzoneFlags> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterPeqzoneFlags e{};
e.id = atoi(row[0]);
e.zone_id = atoi(row[1]);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterPeqzoneFlags> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterPeqzoneFlags> 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) {
CharacterPeqzoneFlags e{};
e.id = atoi(row[0]);
e.zone_id = atoi(row[1]);
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_CHARACTER_PEQZONE_FLAGS_REPOSITORY_H
@@ -106,24 +106,24 @@ public:
static CharacterPetBuffs NewEntity()
{
CharacterPetBuffs entry{};
CharacterPetBuffs e{};
entry.char_id = 0;
entry.pet = 0;
entry.slot = 0;
entry.spell_id = 0;
entry.caster_level = 0;
entry.castername = "";
entry.ticsremaining = 0;
entry.counters = 0;
entry.numhits = 0;
entry.rune = 0;
entry.instrument_mod = 10;
e.char_id = 0;
e.pet = 0;
e.slot = 0;
e.spell_id = 0;
e.caster_level = 0;
e.castername = "";
e.ticsremaining = 0;
e.counters = 0;
e.numhits = 0;
e.rune = 0;
e.instrument_mod = 10;
return entry;
return e;
}
static CharacterPetBuffs GetCharacterPetBuffsEntry(
static CharacterPetBuffs GetCharacterPetBuffs(
const std::vector<CharacterPetBuffs> &character_pet_buffss,
int character_pet_buffs_id
)
@@ -152,21 +152,21 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterPetBuffs entry{};
CharacterPetBuffs e{};
entry.char_id = atoi(row[0]);
entry.pet = atoi(row[1]);
entry.slot = atoi(row[2]);
entry.spell_id = atoi(row[3]);
entry.caster_level = atoi(row[4]);
entry.castername = row[5] ? row[5] : "";
entry.ticsremaining = atoi(row[6]);
entry.counters = atoi(row[7]);
entry.numhits = atoi(row[8]);
entry.rune = atoi(row[9]);
entry.instrument_mod = atoi(row[10]);
e.char_id = atoi(row[0]);
e.pet = atoi(row[1]);
e.slot = atoi(row[2]);
e.spell_id = atoi(row[3]);
e.caster_level = atoi(row[4]);
e.castername = row[5] ? row[5] : "";
e.ticsremaining = atoi(row[6]);
e.counters = atoi(row[7]);
e.numhits = atoi(row[8]);
e.rune = atoi(row[9]);
e.instrument_mod = atoi(row[10]);
return entry;
return e;
}
return NewEntity();
@@ -191,32 +191,32 @@ public:
static int UpdateOne(
Database& db,
CharacterPetBuffs character_pet_buffs_entry
const CharacterPetBuffs &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(character_pet_buffs_entry.char_id));
update_values.push_back(columns[1] + " = " + std::to_string(character_pet_buffs_entry.pet));
update_values.push_back(columns[2] + " = " + std::to_string(character_pet_buffs_entry.slot));
update_values.push_back(columns[3] + " = " + std::to_string(character_pet_buffs_entry.spell_id));
update_values.push_back(columns[4] + " = " + std::to_string(character_pet_buffs_entry.caster_level));
update_values.push_back(columns[5] + " = '" + Strings::Escape(character_pet_buffs_entry.castername) + "'");
update_values.push_back(columns[6] + " = " + std::to_string(character_pet_buffs_entry.ticsremaining));
update_values.push_back(columns[7] + " = " + std::to_string(character_pet_buffs_entry.counters));
update_values.push_back(columns[8] + " = " + std::to_string(character_pet_buffs_entry.numhits));
update_values.push_back(columns[9] + " = " + std::to_string(character_pet_buffs_entry.rune));
update_values.push_back(columns[10] + " = " + std::to_string(character_pet_buffs_entry.instrument_mod));
v.push_back(columns[0] + " = " + std::to_string(e.char_id));
v.push_back(columns[1] + " = " + std::to_string(e.pet));
v.push_back(columns[2] + " = " + std::to_string(e.slot));
v.push_back(columns[3] + " = " + std::to_string(e.spell_id));
v.push_back(columns[4] + " = " + std::to_string(e.caster_level));
v.push_back(columns[5] + " = '" + Strings::Escape(e.castername) + "'");
v.push_back(columns[6] + " = " + std::to_string(e.ticsremaining));
v.push_back(columns[7] + " = " + std::to_string(e.counters));
v.push_back(columns[8] + " = " + std::to_string(e.numhits));
v.push_back(columns[9] + " = " + std::to_string(e.rune));
v.push_back(columns[10] + " = " + std::to_string(e.instrument_mod));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_pet_buffs_entry.char_id
e.char_id
)
);
@@ -225,67 +225,67 @@ public:
static CharacterPetBuffs InsertOne(
Database& db,
CharacterPetBuffs character_pet_buffs_entry
CharacterPetBuffs e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_pet_buffs_entry.char_id));
insert_values.push_back(std::to_string(character_pet_buffs_entry.pet));
insert_values.push_back(std::to_string(character_pet_buffs_entry.slot));
insert_values.push_back(std::to_string(character_pet_buffs_entry.spell_id));
insert_values.push_back(std::to_string(character_pet_buffs_entry.caster_level));
insert_values.push_back("'" + Strings::Escape(character_pet_buffs_entry.castername) + "'");
insert_values.push_back(std::to_string(character_pet_buffs_entry.ticsremaining));
insert_values.push_back(std::to_string(character_pet_buffs_entry.counters));
insert_values.push_back(std::to_string(character_pet_buffs_entry.numhits));
insert_values.push_back(std::to_string(character_pet_buffs_entry.rune));
insert_values.push_back(std::to_string(character_pet_buffs_entry.instrument_mod));
v.push_back(std::to_string(e.char_id));
v.push_back(std::to_string(e.pet));
v.push_back(std::to_string(e.slot));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.caster_level));
v.push_back("'" + Strings::Escape(e.castername) + "'");
v.push_back(std::to_string(e.ticsremaining));
v.push_back(std::to_string(e.counters));
v.push_back(std::to_string(e.numhits));
v.push_back(std::to_string(e.rune));
v.push_back(std::to_string(e.instrument_mod));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_pet_buffs_entry.char_id = results.LastInsertedID();
return character_pet_buffs_entry;
e.char_id = results.LastInsertedID();
return e;
}
character_pet_buffs_entry = NewEntity();
e = NewEntity();
return character_pet_buffs_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterPetBuffs> character_pet_buffs_entries
const std::vector<CharacterPetBuffs> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_pet_buffs_entry: character_pet_buffs_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_pet_buffs_entry.char_id));
insert_values.push_back(std::to_string(character_pet_buffs_entry.pet));
insert_values.push_back(std::to_string(character_pet_buffs_entry.slot));
insert_values.push_back(std::to_string(character_pet_buffs_entry.spell_id));
insert_values.push_back(std::to_string(character_pet_buffs_entry.caster_level));
insert_values.push_back("'" + Strings::Escape(character_pet_buffs_entry.castername) + "'");
insert_values.push_back(std::to_string(character_pet_buffs_entry.ticsremaining));
insert_values.push_back(std::to_string(character_pet_buffs_entry.counters));
insert_values.push_back(std::to_string(character_pet_buffs_entry.numhits));
insert_values.push_back(std::to_string(character_pet_buffs_entry.rune));
insert_values.push_back(std::to_string(character_pet_buffs_entry.instrument_mod));
v.push_back(std::to_string(e.char_id));
v.push_back(std::to_string(e.pet));
v.push_back(std::to_string(e.slot));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.caster_level));
v.push_back("'" + Strings::Escape(e.castername) + "'");
v.push_back(std::to_string(e.ticsremaining));
v.push_back(std::to_string(e.counters));
v.push_back(std::to_string(e.numhits));
v.push_back(std::to_string(e.rune));
v.push_back(std::to_string(e.instrument_mod));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -312,27 +312,27 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterPetBuffs entry{};
CharacterPetBuffs e{};
entry.char_id = atoi(row[0]);
entry.pet = atoi(row[1]);
entry.slot = atoi(row[2]);
entry.spell_id = atoi(row[3]);
entry.caster_level = atoi(row[4]);
entry.castername = row[5] ? row[5] : "";
entry.ticsremaining = atoi(row[6]);
entry.counters = atoi(row[7]);
entry.numhits = atoi(row[8]);
entry.rune = atoi(row[9]);
entry.instrument_mod = atoi(row[10]);
e.char_id = atoi(row[0]);
e.pet = atoi(row[1]);
e.slot = atoi(row[2]);
e.spell_id = atoi(row[3]);
e.caster_level = atoi(row[4]);
e.castername = row[5] ? row[5] : "";
e.ticsremaining = atoi(row[6]);
e.counters = atoi(row[7]);
e.numhits = atoi(row[8]);
e.rune = atoi(row[9]);
e.instrument_mod = atoi(row[10]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterPetBuffs> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterPetBuffs> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterPetBuffs> all_entries;
@@ -347,27 +347,27 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterPetBuffs entry{};
CharacterPetBuffs e{};
entry.char_id = atoi(row[0]);
entry.pet = atoi(row[1]);
entry.slot = atoi(row[2]);
entry.spell_id = atoi(row[3]);
entry.caster_level = atoi(row[4]);
entry.castername = row[5] ? row[5] : "";
entry.ticsremaining = atoi(row[6]);
entry.counters = atoi(row[7]);
entry.numhits = atoi(row[8]);
entry.rune = atoi(row[9]);
entry.instrument_mod = atoi(row[10]);
e.char_id = atoi(row[0]);
e.pet = atoi(row[1]);
e.slot = atoi(row[2]);
e.spell_id = atoi(row[3]);
e.caster_level = atoi(row[4]);
e.castername = row[5] ? row[5] : "";
e.ticsremaining = atoi(row[6]);
e.counters = atoi(row[7]);
e.numhits = atoi(row[8]);
e.rune = atoi(row[9]);
e.instrument_mod = atoi(row[10]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -392,6 +392,32 @@ public:
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_CHARACTER_PET_BUFFS_REPOSITORY_H
@@ -100,22 +100,22 @@ public:
static CharacterPetInfo NewEntity()
{
CharacterPetInfo entry{};
CharacterPetInfo e{};
entry.char_id = 0;
entry.pet = 0;
entry.petname = "";
entry.petpower = 0;
entry.spell_id = 0;
entry.hp = 0;
entry.mana = 0;
entry.size = 0;
entry.taunting = 1;
e.char_id = 0;
e.pet = 0;
e.petname = "";
e.petpower = 0;
e.spell_id = 0;
e.hp = 0;
e.mana = 0;
e.size = 0;
e.taunting = 1;
return entry;
return e;
}
static CharacterPetInfo GetCharacterPetInfoEntry(
static CharacterPetInfo GetCharacterPetInfo(
const std::vector<CharacterPetInfo> &character_pet_infos,
int character_pet_info_id
)
@@ -144,19 +144,19 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterPetInfo entry{};
CharacterPetInfo e{};
entry.char_id = atoi(row[0]);
entry.pet = atoi(row[1]);
entry.petname = row[2] ? row[2] : "";
entry.petpower = atoi(row[3]);
entry.spell_id = atoi(row[4]);
entry.hp = atoi(row[5]);
entry.mana = atoi(row[6]);
entry.size = static_cast<float>(atof(row[7]));
entry.taunting = atoi(row[8]);
e.char_id = atoi(row[0]);
e.pet = atoi(row[1]);
e.petname = row[2] ? row[2] : "";
e.petpower = atoi(row[3]);
e.spell_id = atoi(row[4]);
e.hp = atoi(row[5]);
e.mana = atoi(row[6]);
e.size = static_cast<float>(atof(row[7]));
e.taunting = atoi(row[8]);
return entry;
return e;
}
return NewEntity();
@@ -181,30 +181,30 @@ public:
static int UpdateOne(
Database& db,
CharacterPetInfo character_pet_info_entry
const CharacterPetInfo &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(character_pet_info_entry.char_id));
update_values.push_back(columns[1] + " = " + std::to_string(character_pet_info_entry.pet));
update_values.push_back(columns[2] + " = '" + Strings::Escape(character_pet_info_entry.petname) + "'");
update_values.push_back(columns[3] + " = " + std::to_string(character_pet_info_entry.petpower));
update_values.push_back(columns[4] + " = " + std::to_string(character_pet_info_entry.spell_id));
update_values.push_back(columns[5] + " = " + std::to_string(character_pet_info_entry.hp));
update_values.push_back(columns[6] + " = " + std::to_string(character_pet_info_entry.mana));
update_values.push_back(columns[7] + " = " + std::to_string(character_pet_info_entry.size));
update_values.push_back(columns[8] + " = " + std::to_string(character_pet_info_entry.taunting));
v.push_back(columns[0] + " = " + std::to_string(e.char_id));
v.push_back(columns[1] + " = " + std::to_string(e.pet));
v.push_back(columns[2] + " = '" + Strings::Escape(e.petname) + "'");
v.push_back(columns[3] + " = " + std::to_string(e.petpower));
v.push_back(columns[4] + " = " + std::to_string(e.spell_id));
v.push_back(columns[5] + " = " + std::to_string(e.hp));
v.push_back(columns[6] + " = " + std::to_string(e.mana));
v.push_back(columns[7] + " = " + std::to_string(e.size));
v.push_back(columns[8] + " = " + std::to_string(e.taunting));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_pet_info_entry.char_id
e.char_id
)
);
@@ -213,63 +213,63 @@ public:
static CharacterPetInfo InsertOne(
Database& db,
CharacterPetInfo character_pet_info_entry
CharacterPetInfo e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_pet_info_entry.char_id));
insert_values.push_back(std::to_string(character_pet_info_entry.pet));
insert_values.push_back("'" + Strings::Escape(character_pet_info_entry.petname) + "'");
insert_values.push_back(std::to_string(character_pet_info_entry.petpower));
insert_values.push_back(std::to_string(character_pet_info_entry.spell_id));
insert_values.push_back(std::to_string(character_pet_info_entry.hp));
insert_values.push_back(std::to_string(character_pet_info_entry.mana));
insert_values.push_back(std::to_string(character_pet_info_entry.size));
insert_values.push_back(std::to_string(character_pet_info_entry.taunting));
v.push_back(std::to_string(e.char_id));
v.push_back(std::to_string(e.pet));
v.push_back("'" + Strings::Escape(e.petname) + "'");
v.push_back(std::to_string(e.petpower));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.hp));
v.push_back(std::to_string(e.mana));
v.push_back(std::to_string(e.size));
v.push_back(std::to_string(e.taunting));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_pet_info_entry.char_id = results.LastInsertedID();
return character_pet_info_entry;
e.char_id = results.LastInsertedID();
return e;
}
character_pet_info_entry = NewEntity();
e = NewEntity();
return character_pet_info_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterPetInfo> character_pet_info_entries
const std::vector<CharacterPetInfo> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_pet_info_entry: character_pet_info_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_pet_info_entry.char_id));
insert_values.push_back(std::to_string(character_pet_info_entry.pet));
insert_values.push_back("'" + Strings::Escape(character_pet_info_entry.petname) + "'");
insert_values.push_back(std::to_string(character_pet_info_entry.petpower));
insert_values.push_back(std::to_string(character_pet_info_entry.spell_id));
insert_values.push_back(std::to_string(character_pet_info_entry.hp));
insert_values.push_back(std::to_string(character_pet_info_entry.mana));
insert_values.push_back(std::to_string(character_pet_info_entry.size));
insert_values.push_back(std::to_string(character_pet_info_entry.taunting));
v.push_back(std::to_string(e.char_id));
v.push_back(std::to_string(e.pet));
v.push_back("'" + Strings::Escape(e.petname) + "'");
v.push_back(std::to_string(e.petpower));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.hp));
v.push_back(std::to_string(e.mana));
v.push_back(std::to_string(e.size));
v.push_back(std::to_string(e.taunting));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -296,25 +296,25 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterPetInfo entry{};
CharacterPetInfo e{};
entry.char_id = atoi(row[0]);
entry.pet = atoi(row[1]);
entry.petname = row[2] ? row[2] : "";
entry.petpower = atoi(row[3]);
entry.spell_id = atoi(row[4]);
entry.hp = atoi(row[5]);
entry.mana = atoi(row[6]);
entry.size = static_cast<float>(atof(row[7]));
entry.taunting = atoi(row[8]);
e.char_id = atoi(row[0]);
e.pet = atoi(row[1]);
e.petname = row[2] ? row[2] : "";
e.petpower = atoi(row[3]);
e.spell_id = atoi(row[4]);
e.hp = atoi(row[5]);
e.mana = atoi(row[6]);
e.size = static_cast<float>(atof(row[7]));
e.taunting = atoi(row[8]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterPetInfo> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterPetInfo> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterPetInfo> all_entries;
@@ -329,25 +329,25 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterPetInfo entry{};
CharacterPetInfo e{};
entry.char_id = atoi(row[0]);
entry.pet = atoi(row[1]);
entry.petname = row[2] ? row[2] : "";
entry.petpower = atoi(row[3]);
entry.spell_id = atoi(row[4]);
entry.hp = atoi(row[5]);
entry.mana = atoi(row[6]);
entry.size = static_cast<float>(atof(row[7]));
entry.taunting = atoi(row[8]);
e.char_id = atoi(row[0]);
e.pet = atoi(row[1]);
e.petname = row[2] ? row[2] : "";
e.petpower = atoi(row[3]);
e.spell_id = atoi(row[4]);
e.hp = atoi(row[5]);
e.mana = atoi(row[6]);
e.size = static_cast<float>(atof(row[7]));
e.taunting = atoi(row[8]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -372,6 +372,32 @@ public:
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_CHARACTER_PET_INFO_REPOSITORY_H
@@ -85,17 +85,17 @@ public:
static CharacterPetInventory NewEntity()
{
CharacterPetInventory entry{};
CharacterPetInventory e{};
entry.char_id = 0;
entry.pet = 0;
entry.slot = 0;
entry.item_id = 0;
e.char_id = 0;
e.pet = 0;
e.slot = 0;
e.item_id = 0;
return entry;
return e;
}
static CharacterPetInventory GetCharacterPetInventoryEntry(
static CharacterPetInventory GetCharacterPetInventory(
const std::vector<CharacterPetInventory> &character_pet_inventorys,
int character_pet_inventory_id
)
@@ -124,14 +124,14 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterPetInventory entry{};
CharacterPetInventory e{};
entry.char_id = atoi(row[0]);
entry.pet = atoi(row[1]);
entry.slot = atoi(row[2]);
entry.item_id = atoi(row[3]);
e.char_id = atoi(row[0]);
e.pet = atoi(row[1]);
e.slot = atoi(row[2]);
e.item_id = atoi(row[3]);
return entry;
return e;
}
return NewEntity();
@@ -156,25 +156,25 @@ public:
static int UpdateOne(
Database& db,
CharacterPetInventory character_pet_inventory_entry
const CharacterPetInventory &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(character_pet_inventory_entry.char_id));
update_values.push_back(columns[1] + " = " + std::to_string(character_pet_inventory_entry.pet));
update_values.push_back(columns[2] + " = " + std::to_string(character_pet_inventory_entry.slot));
update_values.push_back(columns[3] + " = " + std::to_string(character_pet_inventory_entry.item_id));
v.push_back(columns[0] + " = " + std::to_string(e.char_id));
v.push_back(columns[1] + " = " + std::to_string(e.pet));
v.push_back(columns[2] + " = " + std::to_string(e.slot));
v.push_back(columns[3] + " = " + std::to_string(e.item_id));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_pet_inventory_entry.char_id
e.char_id
)
);
@@ -183,53 +183,53 @@ public:
static CharacterPetInventory InsertOne(
Database& db,
CharacterPetInventory character_pet_inventory_entry
CharacterPetInventory e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_pet_inventory_entry.char_id));
insert_values.push_back(std::to_string(character_pet_inventory_entry.pet));
insert_values.push_back(std::to_string(character_pet_inventory_entry.slot));
insert_values.push_back(std::to_string(character_pet_inventory_entry.item_id));
v.push_back(std::to_string(e.char_id));
v.push_back(std::to_string(e.pet));
v.push_back(std::to_string(e.slot));
v.push_back(std::to_string(e.item_id));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_pet_inventory_entry.char_id = results.LastInsertedID();
return character_pet_inventory_entry;
e.char_id = results.LastInsertedID();
return e;
}
character_pet_inventory_entry = NewEntity();
e = NewEntity();
return character_pet_inventory_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterPetInventory> character_pet_inventory_entries
const std::vector<CharacterPetInventory> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_pet_inventory_entry: character_pet_inventory_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_pet_inventory_entry.char_id));
insert_values.push_back(std::to_string(character_pet_inventory_entry.pet));
insert_values.push_back(std::to_string(character_pet_inventory_entry.slot));
insert_values.push_back(std::to_string(character_pet_inventory_entry.item_id));
v.push_back(std::to_string(e.char_id));
v.push_back(std::to_string(e.pet));
v.push_back(std::to_string(e.slot));
v.push_back(std::to_string(e.item_id));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -256,20 +256,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterPetInventory entry{};
CharacterPetInventory e{};
entry.char_id = atoi(row[0]);
entry.pet = atoi(row[1]);
entry.slot = atoi(row[2]);
entry.item_id = atoi(row[3]);
e.char_id = atoi(row[0]);
e.pet = atoi(row[1]);
e.slot = atoi(row[2]);
e.item_id = atoi(row[3]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterPetInventory> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterPetInventory> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterPetInventory> all_entries;
@@ -284,20 +284,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterPetInventory entry{};
CharacterPetInventory e{};
entry.char_id = atoi(row[0]);
entry.pet = atoi(row[1]);
entry.slot = atoi(row[2]);
entry.item_id = atoi(row[3]);
e.char_id = atoi(row[0]);
e.pet = atoi(row[1]);
e.slot = atoi(row[2]);
e.item_id = atoi(row[3]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -322,6 +322,32 @@ public:
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_CHARACTER_PET_INVENTORY_REPOSITORY_H
@@ -85,17 +85,17 @@ public:
static CharacterPotionbelt NewEntity()
{
CharacterPotionbelt entry{};
CharacterPotionbelt e{};
entry.id = 0;
entry.potion_id = 0;
entry.item_id = 0;
entry.icon = 0;
e.id = 0;
e.potion_id = 0;
e.item_id = 0;
e.icon = 0;
return entry;
return e;
}
static CharacterPotionbelt GetCharacterPotionbeltEntry(
static CharacterPotionbelt GetCharacterPotionbelt(
const std::vector<CharacterPotionbelt> &character_potionbelts,
int character_potionbelt_id
)
@@ -124,14 +124,14 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterPotionbelt entry{};
CharacterPotionbelt e{};
entry.id = atoi(row[0]);
entry.potion_id = atoi(row[1]);
entry.item_id = atoi(row[2]);
entry.icon = atoi(row[3]);
e.id = atoi(row[0]);
e.potion_id = atoi(row[1]);
e.item_id = atoi(row[2]);
e.icon = atoi(row[3]);
return entry;
return e;
}
return NewEntity();
@@ -156,25 +156,25 @@ public:
static int UpdateOne(
Database& db,
CharacterPotionbelt character_potionbelt_entry
const CharacterPotionbelt &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(character_potionbelt_entry.id));
update_values.push_back(columns[1] + " = " + std::to_string(character_potionbelt_entry.potion_id));
update_values.push_back(columns[2] + " = " + std::to_string(character_potionbelt_entry.item_id));
update_values.push_back(columns[3] + " = " + std::to_string(character_potionbelt_entry.icon));
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = " + std::to_string(e.potion_id));
v.push_back(columns[2] + " = " + std::to_string(e.item_id));
v.push_back(columns[3] + " = " + std::to_string(e.icon));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_potionbelt_entry.id
e.id
)
);
@@ -183,53 +183,53 @@ public:
static CharacterPotionbelt InsertOne(
Database& db,
CharacterPotionbelt character_potionbelt_entry
CharacterPotionbelt e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_potionbelt_entry.id));
insert_values.push_back(std::to_string(character_potionbelt_entry.potion_id));
insert_values.push_back(std::to_string(character_potionbelt_entry.item_id));
insert_values.push_back(std::to_string(character_potionbelt_entry.icon));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.potion_id));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.icon));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_potionbelt_entry.id = results.LastInsertedID();
return character_potionbelt_entry;
e.id = results.LastInsertedID();
return e;
}
character_potionbelt_entry = NewEntity();
e = NewEntity();
return character_potionbelt_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterPotionbelt> character_potionbelt_entries
const std::vector<CharacterPotionbelt> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_potionbelt_entry: character_potionbelt_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_potionbelt_entry.id));
insert_values.push_back(std::to_string(character_potionbelt_entry.potion_id));
insert_values.push_back(std::to_string(character_potionbelt_entry.item_id));
insert_values.push_back(std::to_string(character_potionbelt_entry.icon));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.potion_id));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.icon));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -256,20 +256,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterPotionbelt entry{};
CharacterPotionbelt e{};
entry.id = atoi(row[0]);
entry.potion_id = atoi(row[1]);
entry.item_id = atoi(row[2]);
entry.icon = atoi(row[3]);
e.id = atoi(row[0]);
e.potion_id = atoi(row[1]);
e.item_id = atoi(row[2]);
e.icon = atoi(row[3]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterPotionbelt> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterPotionbelt> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterPotionbelt> all_entries;
@@ -284,20 +284,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterPotionbelt entry{};
CharacterPotionbelt e{};
entry.id = atoi(row[0]);
entry.potion_id = atoi(row[1]);
entry.item_id = atoi(row[2]);
entry.icon = atoi(row[3]);
e.id = atoi(row[0]);
e.potion_id = atoi(row[1]);
e.item_id = atoi(row[2]);
e.icon = atoi(row[3]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -322,6 +322,32 @@ public:
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_CHARACTER_POTIONBELT_REPOSITORY_H
@@ -82,16 +82,16 @@ public:
static CharacterSkills NewEntity()
{
CharacterSkills entry{};
CharacterSkills e{};
entry.id = 0;
entry.skill_id = 0;
entry.value = 0;
e.id = 0;
e.skill_id = 0;
e.value = 0;
return entry;
return e;
}
static CharacterSkills GetCharacterSkillsEntry(
static CharacterSkills GetCharacterSkills(
const std::vector<CharacterSkills> &character_skillss,
int character_skills_id
)
@@ -120,13 +120,13 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterSkills entry{};
CharacterSkills e{};
entry.id = atoi(row[0]);
entry.skill_id = atoi(row[1]);
entry.value = atoi(row[2]);
e.id = atoi(row[0]);
e.skill_id = atoi(row[1]);
e.value = atoi(row[2]);
return entry;
return e;
}
return NewEntity();
@@ -151,23 +151,23 @@ public:
static int UpdateOne(
Database& db,
CharacterSkills character_skills_entry
const CharacterSkills &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(character_skills_entry.skill_id));
update_values.push_back(columns[2] + " = " + std::to_string(character_skills_entry.value));
v.push_back(columns[1] + " = " + std::to_string(e.skill_id));
v.push_back(columns[2] + " = " + std::to_string(e.value));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_skills_entry.id
e.id
)
);
@@ -176,51 +176,51 @@ public:
static CharacterSkills InsertOne(
Database& db,
CharacterSkills character_skills_entry
CharacterSkills e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_skills_entry.id));
insert_values.push_back(std::to_string(character_skills_entry.skill_id));
insert_values.push_back(std::to_string(character_skills_entry.value));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.skill_id));
v.push_back(std::to_string(e.value));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_skills_entry.id = results.LastInsertedID();
return character_skills_entry;
e.id = results.LastInsertedID();
return e;
}
character_skills_entry = NewEntity();
e = NewEntity();
return character_skills_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterSkills> character_skills_entries
const std::vector<CharacterSkills> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_skills_entry: character_skills_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_skills_entry.id));
insert_values.push_back(std::to_string(character_skills_entry.skill_id));
insert_values.push_back(std::to_string(character_skills_entry.value));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.skill_id));
v.push_back(std::to_string(e.value));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -247,19 +247,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterSkills entry{};
CharacterSkills e{};
entry.id = atoi(row[0]);
entry.skill_id = atoi(row[1]);
entry.value = atoi(row[2]);
e.id = atoi(row[0]);
e.skill_id = atoi(row[1]);
e.value = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterSkills> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterSkills> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterSkills> all_entries;
@@ -274,19 +274,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterSkills entry{};
CharacterSkills e{};
entry.id = atoi(row[0]);
entry.skill_id = atoi(row[1]);
entry.value = atoi(row[2]);
e.id = atoi(row[0]);
e.skill_id = atoi(row[1]);
e.value = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -311,6 +311,32 @@ public:
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_CHARACTER_SKILLS_REPOSITORY_H
@@ -82,16 +82,16 @@ public:
static CharacterSpells NewEntity()
{
CharacterSpells entry{};
CharacterSpells e{};
entry.id = 0;
entry.slot_id = 0;
entry.spell_id = 0;
e.id = 0;
e.slot_id = 0;
e.spell_id = 0;
return entry;
return e;
}
static CharacterSpells GetCharacterSpellsEntry(
static CharacterSpells GetCharacterSpells(
const std::vector<CharacterSpells> &character_spellss,
int character_spells_id
)
@@ -120,13 +120,13 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterSpells entry{};
CharacterSpells e{};
entry.id = atoi(row[0]);
entry.slot_id = atoi(row[1]);
entry.spell_id = atoi(row[2]);
e.id = atoi(row[0]);
e.slot_id = atoi(row[1]);
e.spell_id = atoi(row[2]);
return entry;
return e;
}
return NewEntity();
@@ -151,23 +151,23 @@ public:
static int UpdateOne(
Database& db,
CharacterSpells character_spells_entry
const CharacterSpells &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(character_spells_entry.slot_id));
update_values.push_back(columns[2] + " = " + std::to_string(character_spells_entry.spell_id));
v.push_back(columns[1] + " = " + std::to_string(e.slot_id));
v.push_back(columns[2] + " = " + std::to_string(e.spell_id));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_spells_entry.id
e.id
)
);
@@ -176,51 +176,51 @@ public:
static CharacterSpells InsertOne(
Database& db,
CharacterSpells character_spells_entry
CharacterSpells e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_spells_entry.id));
insert_values.push_back(std::to_string(character_spells_entry.slot_id));
insert_values.push_back(std::to_string(character_spells_entry.spell_id));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.slot_id));
v.push_back(std::to_string(e.spell_id));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_spells_entry.id = results.LastInsertedID();
return character_spells_entry;
e.id = results.LastInsertedID();
return e;
}
character_spells_entry = NewEntity();
e = NewEntity();
return character_spells_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterSpells> character_spells_entries
const std::vector<CharacterSpells> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_spells_entry: character_spells_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_spells_entry.id));
insert_values.push_back(std::to_string(character_spells_entry.slot_id));
insert_values.push_back(std::to_string(character_spells_entry.spell_id));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.slot_id));
v.push_back(std::to_string(e.spell_id));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -247,19 +247,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterSpells entry{};
CharacterSpells e{};
entry.id = atoi(row[0]);
entry.slot_id = atoi(row[1]);
entry.spell_id = atoi(row[2]);
e.id = atoi(row[0]);
e.slot_id = atoi(row[1]);
e.spell_id = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterSpells> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterSpells> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterSpells> all_entries;
@@ -274,19 +274,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterSpells entry{};
CharacterSpells e{};
entry.id = atoi(row[0]);
entry.slot_id = atoi(row[1]);
entry.spell_id = atoi(row[2]);
e.id = atoi(row[0]);
e.slot_id = atoi(row[1]);
e.spell_id = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -311,6 +311,32 @@ public:
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_CHARACTER_SPELLS_REPOSITORY_H
@@ -91,19 +91,19 @@ public:
static CharacterTaskTimers NewEntity()
{
CharacterTaskTimers entry{};
CharacterTaskTimers e{};
entry.id = 0;
entry.character_id = 0;
entry.task_id = 0;
entry.timer_type = 0;
entry.timer_group = 0;
entry.expire_time = std::time(nullptr);
e.id = 0;
e.character_id = 0;
e.task_id = 0;
e.timer_type = 0;
e.timer_group = 0;
e.expire_time = std::time(nullptr);
return entry;
return e;
}
static CharacterTaskTimers GetCharacterTaskTimersEntry(
static CharacterTaskTimers GetCharacterTaskTimers(
const std::vector<CharacterTaskTimers> &character_task_timerss,
int character_task_timers_id
)
@@ -132,16 +132,16 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterTaskTimers entry{};
CharacterTaskTimers e{};
entry.id = atoi(row[0]);
entry.character_id = atoi(row[1]);
entry.task_id = atoi(row[2]);
entry.timer_type = atoi(row[3]);
entry.timer_group = atoi(row[4]);
entry.expire_time = strtoll(row[5] ? row[5] : "-1", nullptr, 10);
e.id = atoi(row[0]);
e.character_id = atoi(row[1]);
e.task_id = atoi(row[2]);
e.timer_type = atoi(row[3]);
e.timer_group = atoi(row[4]);
e.expire_time = strtoll(row[5] ? row[5] : "-1", nullptr, 10);
return entry;
return e;
}
return NewEntity();
@@ -166,26 +166,26 @@ public:
static int UpdateOne(
Database& db,
CharacterTaskTimers character_task_timers_entry
const CharacterTaskTimers &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(character_task_timers_entry.character_id));
update_values.push_back(columns[2] + " = " + std::to_string(character_task_timers_entry.task_id));
update_values.push_back(columns[3] + " = " + std::to_string(character_task_timers_entry.timer_type));
update_values.push_back(columns[4] + " = " + std::to_string(character_task_timers_entry.timer_group));
update_values.push_back(columns[5] + " = FROM_UNIXTIME(" + (character_task_timers_entry.expire_time > 0 ? std::to_string(character_task_timers_entry.expire_time) : "null") + ")");
v.push_back(columns[1] + " = " + std::to_string(e.character_id));
v.push_back(columns[2] + " = " + std::to_string(e.task_id));
v.push_back(columns[3] + " = " + std::to_string(e.timer_type));
v.push_back(columns[4] + " = " + std::to_string(e.timer_group));
v.push_back(columns[5] + " = FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_task_timers_entry.id
e.id
)
);
@@ -194,57 +194,57 @@ public:
static CharacterTaskTimers InsertOne(
Database& db,
CharacterTaskTimers character_task_timers_entry
CharacterTaskTimers e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_task_timers_entry.id));
insert_values.push_back(std::to_string(character_task_timers_entry.character_id));
insert_values.push_back(std::to_string(character_task_timers_entry.task_id));
insert_values.push_back(std::to_string(character_task_timers_entry.timer_type));
insert_values.push_back(std::to_string(character_task_timers_entry.timer_group));
insert_values.push_back("FROM_UNIXTIME(" + (character_task_timers_entry.expire_time > 0 ? std::to_string(character_task_timers_entry.expire_time) : "null") + ")");
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.character_id));
v.push_back(std::to_string(e.task_id));
v.push_back(std::to_string(e.timer_type));
v.push_back(std::to_string(e.timer_group));
v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_task_timers_entry.id = results.LastInsertedID();
return character_task_timers_entry;
e.id = results.LastInsertedID();
return e;
}
character_task_timers_entry = NewEntity();
e = NewEntity();
return character_task_timers_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterTaskTimers> character_task_timers_entries
const std::vector<CharacterTaskTimers> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_task_timers_entry: character_task_timers_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_task_timers_entry.id));
insert_values.push_back(std::to_string(character_task_timers_entry.character_id));
insert_values.push_back(std::to_string(character_task_timers_entry.task_id));
insert_values.push_back(std::to_string(character_task_timers_entry.timer_type));
insert_values.push_back(std::to_string(character_task_timers_entry.timer_group));
insert_values.push_back("FROM_UNIXTIME(" + (character_task_timers_entry.expire_time > 0 ? std::to_string(character_task_timers_entry.expire_time) : "null") + ")");
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.character_id));
v.push_back(std::to_string(e.task_id));
v.push_back(std::to_string(e.timer_type));
v.push_back(std::to_string(e.timer_group));
v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -271,22 +271,22 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterTaskTimers entry{};
CharacterTaskTimers e{};
entry.id = atoi(row[0]);
entry.character_id = atoi(row[1]);
entry.task_id = atoi(row[2]);
entry.timer_type = atoi(row[3]);
entry.timer_group = atoi(row[4]);
entry.expire_time = strtoll(row[5] ? row[5] : "-1", nullptr, 10);
e.id = atoi(row[0]);
e.character_id = atoi(row[1]);
e.task_id = atoi(row[2]);
e.timer_type = atoi(row[3]);
e.timer_group = atoi(row[4]);
e.expire_time = strtoll(row[5] ? row[5] : "-1", nullptr, 10);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterTaskTimers> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterTaskTimers> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterTaskTimers> all_entries;
@@ -301,22 +301,22 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterTaskTimers entry{};
CharacterTaskTimers e{};
entry.id = atoi(row[0]);
entry.character_id = atoi(row[1]);
entry.task_id = atoi(row[2]);
entry.timer_type = atoi(row[3]);
entry.timer_group = atoi(row[4]);
entry.expire_time = strtoll(row[5] ? row[5] : "-1", nullptr, 10);
e.id = atoi(row[0]);
e.character_id = atoi(row[1]);
e.task_id = atoi(row[2]);
e.timer_type = atoi(row[3]);
e.timer_group = atoi(row[4]);
e.expire_time = strtoll(row[5] ? row[5] : "-1", nullptr, 10);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -341,6 +341,32 @@ public:
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_CHARACTER_TASK_TIMERS_REPOSITORY_H
@@ -91,19 +91,19 @@ public:
static CharacterTasks NewEntity()
{
CharacterTasks entry{};
CharacterTasks e{};
entry.charid = 0;
entry.taskid = 0;
entry.slot = 0;
entry.type = 0;
entry.acceptedtime = 0;
entry.was_rewarded = 0;
e.charid = 0;
e.taskid = 0;
e.slot = 0;
e.type = 0;
e.acceptedtime = 0;
e.was_rewarded = 0;
return entry;
return e;
}
static CharacterTasks GetCharacterTasksEntry(
static CharacterTasks GetCharacterTasks(
const std::vector<CharacterTasks> &character_taskss,
int character_tasks_id
)
@@ -132,16 +132,16 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterTasks entry{};
CharacterTasks e{};
entry.charid = atoi(row[0]);
entry.taskid = atoi(row[1]);
entry.slot = atoi(row[2]);
entry.type = atoi(row[3]);
entry.acceptedtime = atoi(row[4]);
entry.was_rewarded = atoi(row[5]);
e.charid = atoi(row[0]);
e.taskid = atoi(row[1]);
e.slot = atoi(row[2]);
e.type = atoi(row[3]);
e.acceptedtime = atoi(row[4]);
e.was_rewarded = atoi(row[5]);
return entry;
return e;
}
return NewEntity();
@@ -166,27 +166,27 @@ public:
static int UpdateOne(
Database& db,
CharacterTasks character_tasks_entry
const CharacterTasks &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(character_tasks_entry.charid));
update_values.push_back(columns[1] + " = " + std::to_string(character_tasks_entry.taskid));
update_values.push_back(columns[2] + " = " + std::to_string(character_tasks_entry.slot));
update_values.push_back(columns[3] + " = " + std::to_string(character_tasks_entry.type));
update_values.push_back(columns[4] + " = " + std::to_string(character_tasks_entry.acceptedtime));
update_values.push_back(columns[5] + " = " + std::to_string(character_tasks_entry.was_rewarded));
v.push_back(columns[0] + " = " + std::to_string(e.charid));
v.push_back(columns[1] + " = " + std::to_string(e.taskid));
v.push_back(columns[2] + " = " + std::to_string(e.slot));
v.push_back(columns[3] + " = " + std::to_string(e.type));
v.push_back(columns[4] + " = " + std::to_string(e.acceptedtime));
v.push_back(columns[5] + " = " + std::to_string(e.was_rewarded));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
character_tasks_entry.charid
e.charid
)
);
@@ -195,57 +195,57 @@ public:
static CharacterTasks InsertOne(
Database& db,
CharacterTasks character_tasks_entry
CharacterTasks e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_tasks_entry.charid));
insert_values.push_back(std::to_string(character_tasks_entry.taskid));
insert_values.push_back(std::to_string(character_tasks_entry.slot));
insert_values.push_back(std::to_string(character_tasks_entry.type));
insert_values.push_back(std::to_string(character_tasks_entry.acceptedtime));
insert_values.push_back(std::to_string(character_tasks_entry.was_rewarded));
v.push_back(std::to_string(e.charid));
v.push_back(std::to_string(e.taskid));
v.push_back(std::to_string(e.slot));
v.push_back(std::to_string(e.type));
v.push_back(std::to_string(e.acceptedtime));
v.push_back(std::to_string(e.was_rewarded));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
character_tasks_entry.charid = results.LastInsertedID();
return character_tasks_entry;
e.charid = results.LastInsertedID();
return e;
}
character_tasks_entry = NewEntity();
e = NewEntity();
return character_tasks_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CharacterTasks> character_tasks_entries
const std::vector<CharacterTasks> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_tasks_entry: character_tasks_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(character_tasks_entry.charid));
insert_values.push_back(std::to_string(character_tasks_entry.taskid));
insert_values.push_back(std::to_string(character_tasks_entry.slot));
insert_values.push_back(std::to_string(character_tasks_entry.type));
insert_values.push_back(std::to_string(character_tasks_entry.acceptedtime));
insert_values.push_back(std::to_string(character_tasks_entry.was_rewarded));
v.push_back(std::to_string(e.charid));
v.push_back(std::to_string(e.taskid));
v.push_back(std::to_string(e.slot));
v.push_back(std::to_string(e.type));
v.push_back(std::to_string(e.acceptedtime));
v.push_back(std::to_string(e.was_rewarded));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -272,22 +272,22 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterTasks entry{};
CharacterTasks e{};
entry.charid = atoi(row[0]);
entry.taskid = atoi(row[1]);
entry.slot = atoi(row[2]);
entry.type = atoi(row[3]);
entry.acceptedtime = atoi(row[4]);
entry.was_rewarded = atoi(row[5]);
e.charid = atoi(row[0]);
e.taskid = atoi(row[1]);
e.slot = atoi(row[2]);
e.type = atoi(row[3]);
e.acceptedtime = atoi(row[4]);
e.was_rewarded = atoi(row[5]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CharacterTasks> GetWhere(Database& db, std::string where_filter)
static std::vector<CharacterTasks> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CharacterTasks> all_entries;
@@ -302,22 +302,22 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterTasks entry{};
CharacterTasks e{};
entry.charid = atoi(row[0]);
entry.taskid = atoi(row[1]);
entry.slot = atoi(row[2]);
entry.type = atoi(row[3]);
entry.acceptedtime = atoi(row[4]);
entry.was_rewarded = atoi(row[5]);
e.charid = atoi(row[0]);
e.taskid = atoi(row[1]);
e.slot = atoi(row[2]);
e.type = atoi(row[3]);
e.acceptedtime = atoi(row[4]);
e.was_rewarded = atoi(row[5]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -342,6 +342,32 @@ public:
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_CHARACTER_TASKS_REPOSITORY_H
@@ -88,18 +88,18 @@ public:
static CompletedSharedTaskActivityState NewEntity()
{
CompletedSharedTaskActivityState entry{};
CompletedSharedTaskActivityState e{};
entry.shared_task_id = 0;
entry.activity_id = 0;
entry.done_count = 0;
entry.updated_time = 0;
entry.completed_time = 0;
e.shared_task_id = 0;
e.activity_id = 0;
e.done_count = 0;
e.updated_time = 0;
e.completed_time = 0;
return entry;
return e;
}
static CompletedSharedTaskActivityState GetCompletedSharedTaskActivityStateEntry(
static CompletedSharedTaskActivityState GetCompletedSharedTaskActivityState(
const std::vector<CompletedSharedTaskActivityState> &completed_shared_task_activity_states,
int completed_shared_task_activity_state_id
)
@@ -128,15 +128,15 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CompletedSharedTaskActivityState entry{};
CompletedSharedTaskActivityState e{};
entry.shared_task_id = strtoll(row[0], nullptr, 10);
entry.activity_id = atoi(row[1]);
entry.done_count = atoi(row[2]);
entry.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
entry.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
e.shared_task_id = strtoll(row[0], nullptr, 10);
e.activity_id = atoi(row[1]);
e.done_count = atoi(row[2]);
e.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
e.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
return entry;
return e;
}
return NewEntity();
@@ -161,26 +161,26 @@ public:
static int UpdateOne(
Database& db,
CompletedSharedTaskActivityState completed_shared_task_activity_state_entry
const CompletedSharedTaskActivityState &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(completed_shared_task_activity_state_entry.shared_task_id));
update_values.push_back(columns[1] + " = " + std::to_string(completed_shared_task_activity_state_entry.activity_id));
update_values.push_back(columns[2] + " = " + std::to_string(completed_shared_task_activity_state_entry.done_count));
update_values.push_back(columns[3] + " = FROM_UNIXTIME(" + (completed_shared_task_activity_state_entry.updated_time > 0 ? std::to_string(completed_shared_task_activity_state_entry.updated_time) : "null") + ")");
update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (completed_shared_task_activity_state_entry.completed_time > 0 ? std::to_string(completed_shared_task_activity_state_entry.completed_time) : "null") + ")");
v.push_back(columns[0] + " = " + std::to_string(e.shared_task_id));
v.push_back(columns[1] + " = " + std::to_string(e.activity_id));
v.push_back(columns[2] + " = " + std::to_string(e.done_count));
v.push_back(columns[3] + " = FROM_UNIXTIME(" + (e.updated_time > 0 ? std::to_string(e.updated_time) : "null") + ")");
v.push_back(columns[4] + " = FROM_UNIXTIME(" + (e.completed_time > 0 ? std::to_string(e.completed_time) : "null") + ")");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
completed_shared_task_activity_state_entry.shared_task_id
e.shared_task_id
)
);
@@ -189,55 +189,55 @@ public:
static CompletedSharedTaskActivityState InsertOne(
Database& db,
CompletedSharedTaskActivityState completed_shared_task_activity_state_entry
CompletedSharedTaskActivityState e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(completed_shared_task_activity_state_entry.shared_task_id));
insert_values.push_back(std::to_string(completed_shared_task_activity_state_entry.activity_id));
insert_values.push_back(std::to_string(completed_shared_task_activity_state_entry.done_count));
insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_task_activity_state_entry.updated_time > 0 ? std::to_string(completed_shared_task_activity_state_entry.updated_time) : "null") + ")");
insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_task_activity_state_entry.completed_time > 0 ? std::to_string(completed_shared_task_activity_state_entry.completed_time) : "null") + ")");
v.push_back(std::to_string(e.shared_task_id));
v.push_back(std::to_string(e.activity_id));
v.push_back(std::to_string(e.done_count));
v.push_back("FROM_UNIXTIME(" + (e.updated_time > 0 ? std::to_string(e.updated_time) : "null") + ")");
v.push_back("FROM_UNIXTIME(" + (e.completed_time > 0 ? std::to_string(e.completed_time) : "null") + ")");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
completed_shared_task_activity_state_entry.shared_task_id = results.LastInsertedID();
return completed_shared_task_activity_state_entry;
e.shared_task_id = results.LastInsertedID();
return e;
}
completed_shared_task_activity_state_entry = NewEntity();
e = NewEntity();
return completed_shared_task_activity_state_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CompletedSharedTaskActivityState> completed_shared_task_activity_state_entries
const std::vector<CompletedSharedTaskActivityState> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &completed_shared_task_activity_state_entry: completed_shared_task_activity_state_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(completed_shared_task_activity_state_entry.shared_task_id));
insert_values.push_back(std::to_string(completed_shared_task_activity_state_entry.activity_id));
insert_values.push_back(std::to_string(completed_shared_task_activity_state_entry.done_count));
insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_task_activity_state_entry.updated_time > 0 ? std::to_string(completed_shared_task_activity_state_entry.updated_time) : "null") + ")");
insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_task_activity_state_entry.completed_time > 0 ? std::to_string(completed_shared_task_activity_state_entry.completed_time) : "null") + ")");
v.push_back(std::to_string(e.shared_task_id));
v.push_back(std::to_string(e.activity_id));
v.push_back(std::to_string(e.done_count));
v.push_back("FROM_UNIXTIME(" + (e.updated_time > 0 ? std::to_string(e.updated_time) : "null") + ")");
v.push_back("FROM_UNIXTIME(" + (e.completed_time > 0 ? std::to_string(e.completed_time) : "null") + ")");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -264,21 +264,21 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CompletedSharedTaskActivityState entry{};
CompletedSharedTaskActivityState e{};
entry.shared_task_id = strtoll(row[0], nullptr, 10);
entry.activity_id = atoi(row[1]);
entry.done_count = atoi(row[2]);
entry.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
entry.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
e.shared_task_id = strtoll(row[0], nullptr, 10);
e.activity_id = atoi(row[1]);
e.done_count = atoi(row[2]);
e.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
e.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CompletedSharedTaskActivityState> GetWhere(Database& db, std::string where_filter)
static std::vector<CompletedSharedTaskActivityState> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CompletedSharedTaskActivityState> all_entries;
@@ -293,21 +293,21 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CompletedSharedTaskActivityState entry{};
CompletedSharedTaskActivityState e{};
entry.shared_task_id = strtoll(row[0], nullptr, 10);
entry.activity_id = atoi(row[1]);
entry.done_count = atoi(row[2]);
entry.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
entry.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
e.shared_task_id = strtoll(row[0], nullptr, 10);
e.activity_id = atoi(row[1]);
e.done_count = atoi(row[2]);
e.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
e.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -332,6 +332,32 @@ public:
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_COMPLETED_SHARED_TASK_ACTIVITY_STATE_REPOSITORY_H
@@ -82,16 +82,16 @@ public:
static CompletedSharedTaskMembers NewEntity()
{
CompletedSharedTaskMembers entry{};
CompletedSharedTaskMembers e{};
entry.shared_task_id = 0;
entry.character_id = 0;
entry.is_leader = 0;
e.shared_task_id = 0;
e.character_id = 0;
e.is_leader = 0;
return entry;
return e;
}
static CompletedSharedTaskMembers GetCompletedSharedTaskMembersEntry(
static CompletedSharedTaskMembers GetCompletedSharedTaskMembers(
const std::vector<CompletedSharedTaskMembers> &completed_shared_task_memberss,
int completed_shared_task_members_id
)
@@ -120,13 +120,13 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CompletedSharedTaskMembers entry{};
CompletedSharedTaskMembers e{};
entry.shared_task_id = strtoll(row[0], nullptr, 10);
entry.character_id = strtoll(row[1], nullptr, 10);
entry.is_leader = atoi(row[2]);
e.shared_task_id = strtoll(row[0], nullptr, 10);
e.character_id = strtoll(row[1], nullptr, 10);
e.is_leader = atoi(row[2]);
return entry;
return e;
}
return NewEntity();
@@ -151,24 +151,24 @@ public:
static int UpdateOne(
Database& db,
CompletedSharedTaskMembers completed_shared_task_members_entry
const CompletedSharedTaskMembers &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(completed_shared_task_members_entry.shared_task_id));
update_values.push_back(columns[1] + " = " + std::to_string(completed_shared_task_members_entry.character_id));
update_values.push_back(columns[2] + " = " + std::to_string(completed_shared_task_members_entry.is_leader));
v.push_back(columns[0] + " = " + std::to_string(e.shared_task_id));
v.push_back(columns[1] + " = " + std::to_string(e.character_id));
v.push_back(columns[2] + " = " + std::to_string(e.is_leader));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
completed_shared_task_members_entry.shared_task_id
e.shared_task_id
)
);
@@ -177,51 +177,51 @@ public:
static CompletedSharedTaskMembers InsertOne(
Database& db,
CompletedSharedTaskMembers completed_shared_task_members_entry
CompletedSharedTaskMembers e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(completed_shared_task_members_entry.shared_task_id));
insert_values.push_back(std::to_string(completed_shared_task_members_entry.character_id));
insert_values.push_back(std::to_string(completed_shared_task_members_entry.is_leader));
v.push_back(std::to_string(e.shared_task_id));
v.push_back(std::to_string(e.character_id));
v.push_back(std::to_string(e.is_leader));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
completed_shared_task_members_entry.shared_task_id = results.LastInsertedID();
return completed_shared_task_members_entry;
e.shared_task_id = results.LastInsertedID();
return e;
}
completed_shared_task_members_entry = NewEntity();
e = NewEntity();
return completed_shared_task_members_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CompletedSharedTaskMembers> completed_shared_task_members_entries
const std::vector<CompletedSharedTaskMembers> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &completed_shared_task_members_entry: completed_shared_task_members_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(completed_shared_task_members_entry.shared_task_id));
insert_values.push_back(std::to_string(completed_shared_task_members_entry.character_id));
insert_values.push_back(std::to_string(completed_shared_task_members_entry.is_leader));
v.push_back(std::to_string(e.shared_task_id));
v.push_back(std::to_string(e.character_id));
v.push_back(std::to_string(e.is_leader));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -248,19 +248,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CompletedSharedTaskMembers entry{};
CompletedSharedTaskMembers e{};
entry.shared_task_id = strtoll(row[0], nullptr, 10);
entry.character_id = strtoll(row[1], nullptr, 10);
entry.is_leader = atoi(row[2]);
e.shared_task_id = strtoll(row[0], nullptr, 10);
e.character_id = strtoll(row[1], nullptr, 10);
e.is_leader = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CompletedSharedTaskMembers> GetWhere(Database& db, std::string where_filter)
static std::vector<CompletedSharedTaskMembers> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CompletedSharedTaskMembers> all_entries;
@@ -275,19 +275,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CompletedSharedTaskMembers entry{};
CompletedSharedTaskMembers e{};
entry.shared_task_id = strtoll(row[0], nullptr, 10);
entry.character_id = strtoll(row[1], nullptr, 10);
entry.is_leader = atoi(row[2]);
e.shared_task_id = strtoll(row[0], nullptr, 10);
e.character_id = strtoll(row[1], nullptr, 10);
e.is_leader = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -312,6 +312,32 @@ public:
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_COMPLETED_SHARED_TASK_MEMBERS_REPOSITORY_H
@@ -91,19 +91,19 @@ public:
static CompletedSharedTasks NewEntity()
{
CompletedSharedTasks entry{};
CompletedSharedTasks e{};
entry.id = 0;
entry.task_id = 0;
entry.accepted_time = 0;
entry.expire_time = 0;
entry.completion_time = 0;
entry.is_locked = 0;
e.id = 0;
e.task_id = 0;
e.accepted_time = 0;
e.expire_time = 0;
e.completion_time = 0;
e.is_locked = 0;
return entry;
return e;
}
static CompletedSharedTasks GetCompletedSharedTasksEntry(
static CompletedSharedTasks GetCompletedSharedTasks(
const std::vector<CompletedSharedTasks> &completed_shared_taskss,
int completed_shared_tasks_id
)
@@ -132,16 +132,16 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CompletedSharedTasks entry{};
CompletedSharedTasks e{};
entry.id = strtoll(row[0], nullptr, 10);
entry.task_id = atoi(row[1]);
entry.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10);
entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
entry.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
entry.is_locked = atoi(row[5]);
e.id = strtoll(row[0], nullptr, 10);
e.task_id = atoi(row[1]);
e.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10);
e.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
e.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
e.is_locked = atoi(row[5]);
return entry;
return e;
}
return NewEntity();
@@ -166,27 +166,27 @@ public:
static int UpdateOne(
Database& db,
CompletedSharedTasks completed_shared_tasks_entry
const CompletedSharedTasks &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(completed_shared_tasks_entry.id));
update_values.push_back(columns[1] + " = " + std::to_string(completed_shared_tasks_entry.task_id));
update_values.push_back(columns[2] + " = FROM_UNIXTIME(" + (completed_shared_tasks_entry.accepted_time > 0 ? std::to_string(completed_shared_tasks_entry.accepted_time) : "null") + ")");
update_values.push_back(columns[3] + " = FROM_UNIXTIME(" + (completed_shared_tasks_entry.expire_time > 0 ? std::to_string(completed_shared_tasks_entry.expire_time) : "null") + ")");
update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (completed_shared_tasks_entry.completion_time > 0 ? std::to_string(completed_shared_tasks_entry.completion_time) : "null") + ")");
update_values.push_back(columns[5] + " = " + std::to_string(completed_shared_tasks_entry.is_locked));
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = " + std::to_string(e.task_id));
v.push_back(columns[2] + " = FROM_UNIXTIME(" + (e.accepted_time > 0 ? std::to_string(e.accepted_time) : "null") + ")");
v.push_back(columns[3] + " = FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")");
v.push_back(columns[4] + " = FROM_UNIXTIME(" + (e.completion_time > 0 ? std::to_string(e.completion_time) : "null") + ")");
v.push_back(columns[5] + " = " + std::to_string(e.is_locked));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
completed_shared_tasks_entry.id
e.id
)
);
@@ -195,57 +195,57 @@ public:
static CompletedSharedTasks InsertOne(
Database& db,
CompletedSharedTasks completed_shared_tasks_entry
CompletedSharedTasks e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(completed_shared_tasks_entry.id));
insert_values.push_back(std::to_string(completed_shared_tasks_entry.task_id));
insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_tasks_entry.accepted_time > 0 ? std::to_string(completed_shared_tasks_entry.accepted_time) : "null") + ")");
insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_tasks_entry.expire_time > 0 ? std::to_string(completed_shared_tasks_entry.expire_time) : "null") + ")");
insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_tasks_entry.completion_time > 0 ? std::to_string(completed_shared_tasks_entry.completion_time) : "null") + ")");
insert_values.push_back(std::to_string(completed_shared_tasks_entry.is_locked));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.task_id));
v.push_back("FROM_UNIXTIME(" + (e.accepted_time > 0 ? std::to_string(e.accepted_time) : "null") + ")");
v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")");
v.push_back("FROM_UNIXTIME(" + (e.completion_time > 0 ? std::to_string(e.completion_time) : "null") + ")");
v.push_back(std::to_string(e.is_locked));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
completed_shared_tasks_entry.id = results.LastInsertedID();
return completed_shared_tasks_entry;
e.id = results.LastInsertedID();
return e;
}
completed_shared_tasks_entry = NewEntity();
e = NewEntity();
return completed_shared_tasks_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CompletedSharedTasks> completed_shared_tasks_entries
const std::vector<CompletedSharedTasks> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &completed_shared_tasks_entry: completed_shared_tasks_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(completed_shared_tasks_entry.id));
insert_values.push_back(std::to_string(completed_shared_tasks_entry.task_id));
insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_tasks_entry.accepted_time > 0 ? std::to_string(completed_shared_tasks_entry.accepted_time) : "null") + ")");
insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_tasks_entry.expire_time > 0 ? std::to_string(completed_shared_tasks_entry.expire_time) : "null") + ")");
insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_tasks_entry.completion_time > 0 ? std::to_string(completed_shared_tasks_entry.completion_time) : "null") + ")");
insert_values.push_back(std::to_string(completed_shared_tasks_entry.is_locked));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.task_id));
v.push_back("FROM_UNIXTIME(" + (e.accepted_time > 0 ? std::to_string(e.accepted_time) : "null") + ")");
v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")");
v.push_back("FROM_UNIXTIME(" + (e.completion_time > 0 ? std::to_string(e.completion_time) : "null") + ")");
v.push_back(std::to_string(e.is_locked));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -272,22 +272,22 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CompletedSharedTasks entry{};
CompletedSharedTasks e{};
entry.id = strtoll(row[0], nullptr, 10);
entry.task_id = atoi(row[1]);
entry.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10);
entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
entry.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
entry.is_locked = atoi(row[5]);
e.id = strtoll(row[0], nullptr, 10);
e.task_id = atoi(row[1]);
e.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10);
e.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
e.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
e.is_locked = atoi(row[5]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CompletedSharedTasks> GetWhere(Database& db, std::string where_filter)
static std::vector<CompletedSharedTasks> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CompletedSharedTasks> all_entries;
@@ -302,22 +302,22 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CompletedSharedTasks entry{};
CompletedSharedTasks e{};
entry.id = strtoll(row[0], nullptr, 10);
entry.task_id = atoi(row[1]);
entry.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10);
entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
entry.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
entry.is_locked = atoi(row[5]);
e.id = strtoll(row[0], nullptr, 10);
e.task_id = atoi(row[1]);
e.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10);
e.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
e.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
e.is_locked = atoi(row[5]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -342,6 +342,32 @@ public:
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_COMPLETED_SHARED_TASKS_REPOSITORY_H
@@ -85,17 +85,17 @@ public:
static CompletedTasks NewEntity()
{
CompletedTasks entry{};
CompletedTasks e{};
entry.charid = 0;
entry.completedtime = 0;
entry.taskid = 0;
entry.activityid = 0;
e.charid = 0;
e.completedtime = 0;
e.taskid = 0;
e.activityid = 0;
return entry;
return e;
}
static CompletedTasks GetCompletedTasksEntry(
static CompletedTasks GetCompletedTasks(
const std::vector<CompletedTasks> &completed_taskss,
int completed_tasks_id
)
@@ -124,14 +124,14 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
CompletedTasks entry{};
CompletedTasks e{};
entry.charid = atoi(row[0]);
entry.completedtime = atoi(row[1]);
entry.taskid = atoi(row[2]);
entry.activityid = atoi(row[3]);
e.charid = atoi(row[0]);
e.completedtime = atoi(row[1]);
e.taskid = atoi(row[2]);
e.activityid = atoi(row[3]);
return entry;
return e;
}
return NewEntity();
@@ -156,25 +156,25 @@ public:
static int UpdateOne(
Database& db,
CompletedTasks completed_tasks_entry
const CompletedTasks &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(completed_tasks_entry.charid));
update_values.push_back(columns[1] + " = " + std::to_string(completed_tasks_entry.completedtime));
update_values.push_back(columns[2] + " = " + std::to_string(completed_tasks_entry.taskid));
update_values.push_back(columns[3] + " = " + std::to_string(completed_tasks_entry.activityid));
v.push_back(columns[0] + " = " + std::to_string(e.charid));
v.push_back(columns[1] + " = " + std::to_string(e.completedtime));
v.push_back(columns[2] + " = " + std::to_string(e.taskid));
v.push_back(columns[3] + " = " + std::to_string(e.activityid));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
completed_tasks_entry.charid
e.charid
)
);
@@ -183,53 +183,53 @@ public:
static CompletedTasks InsertOne(
Database& db,
CompletedTasks completed_tasks_entry
CompletedTasks e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(completed_tasks_entry.charid));
insert_values.push_back(std::to_string(completed_tasks_entry.completedtime));
insert_values.push_back(std::to_string(completed_tasks_entry.taskid));
insert_values.push_back(std::to_string(completed_tasks_entry.activityid));
v.push_back(std::to_string(e.charid));
v.push_back(std::to_string(e.completedtime));
v.push_back(std::to_string(e.taskid));
v.push_back(std::to_string(e.activityid));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
completed_tasks_entry.charid = results.LastInsertedID();
return completed_tasks_entry;
e.charid = results.LastInsertedID();
return e;
}
completed_tasks_entry = NewEntity();
e = NewEntity();
return completed_tasks_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<CompletedTasks> completed_tasks_entries
const std::vector<CompletedTasks> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &completed_tasks_entry: completed_tasks_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(completed_tasks_entry.charid));
insert_values.push_back(std::to_string(completed_tasks_entry.completedtime));
insert_values.push_back(std::to_string(completed_tasks_entry.taskid));
insert_values.push_back(std::to_string(completed_tasks_entry.activityid));
v.push_back(std::to_string(e.charid));
v.push_back(std::to_string(e.completedtime));
v.push_back(std::to_string(e.taskid));
v.push_back(std::to_string(e.activityid));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -256,20 +256,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CompletedTasks entry{};
CompletedTasks e{};
entry.charid = atoi(row[0]);
entry.completedtime = atoi(row[1]);
entry.taskid = atoi(row[2]);
entry.activityid = atoi(row[3]);
e.charid = atoi(row[0]);
e.completedtime = atoi(row[1]);
e.taskid = atoi(row[2]);
e.activityid = atoi(row[3]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<CompletedTasks> GetWhere(Database& db, std::string where_filter)
static std::vector<CompletedTasks> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<CompletedTasks> all_entries;
@@ -284,20 +284,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CompletedTasks entry{};
CompletedTasks e{};
entry.charid = atoi(row[0]);
entry.completedtime = atoi(row[1]);
entry.taskid = atoi(row[2]);
entry.activityid = atoi(row[3]);
e.charid = atoi(row[0]);
e.completedtime = atoi(row[1]);
e.taskid = atoi(row[2]);
e.activityid = atoi(row[3]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -322,6 +322,32 @@ public:
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_COMPLETED_TASKS_REPOSITORY_H
@@ -85,17 +85,17 @@ public:
static ContentFlags NewEntity()
{
ContentFlags entry{};
ContentFlags e{};
entry.id = 0;
entry.flag_name = "";
entry.enabled = 0;
entry.notes = "";
e.id = 0;
e.flag_name = "";
e.enabled = 0;
e.notes = "";
return entry;
return e;
}
static ContentFlags GetContentFlagsEntry(
static ContentFlags GetContentFlags(
const std::vector<ContentFlags> &content_flagss,
int content_flags_id
)
@@ -124,14 +124,14 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
ContentFlags entry{};
ContentFlags e{};
entry.id = atoi(row[0]);
entry.flag_name = row[1] ? row[1] : "";
entry.enabled = atoi(row[2]);
entry.notes = row[3] ? row[3] : "";
e.id = atoi(row[0]);
e.flag_name = row[1] ? row[1] : "";
e.enabled = atoi(row[2]);
e.notes = row[3] ? row[3] : "";
return entry;
return e;
}
return NewEntity();
@@ -156,24 +156,24 @@ public:
static int UpdateOne(
Database& db,
ContentFlags content_flags_entry
const ContentFlags &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + Strings::Escape(content_flags_entry.flag_name) + "'");
update_values.push_back(columns[2] + " = " + std::to_string(content_flags_entry.enabled));
update_values.push_back(columns[3] + " = '" + Strings::Escape(content_flags_entry.notes) + "'");
v.push_back(columns[1] + " = '" + Strings::Escape(e.flag_name) + "'");
v.push_back(columns[2] + " = " + std::to_string(e.enabled));
v.push_back(columns[3] + " = '" + Strings::Escape(e.notes) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
content_flags_entry.id
e.id
)
);
@@ -182,53 +182,53 @@ public:
static ContentFlags InsertOne(
Database& db,
ContentFlags content_flags_entry
ContentFlags e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(content_flags_entry.id));
insert_values.push_back("'" + Strings::Escape(content_flags_entry.flag_name) + "'");
insert_values.push_back(std::to_string(content_flags_entry.enabled));
insert_values.push_back("'" + Strings::Escape(content_flags_entry.notes) + "'");
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.flag_name) + "'");
v.push_back(std::to_string(e.enabled));
v.push_back("'" + Strings::Escape(e.notes) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
content_flags_entry.id = results.LastInsertedID();
return content_flags_entry;
e.id = results.LastInsertedID();
return e;
}
content_flags_entry = NewEntity();
e = NewEntity();
return content_flags_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<ContentFlags> content_flags_entries
const std::vector<ContentFlags> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &content_flags_entry: content_flags_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(content_flags_entry.id));
insert_values.push_back("'" + Strings::Escape(content_flags_entry.flag_name) + "'");
insert_values.push_back(std::to_string(content_flags_entry.enabled));
insert_values.push_back("'" + Strings::Escape(content_flags_entry.notes) + "'");
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.flag_name) + "'");
v.push_back(std::to_string(e.enabled));
v.push_back("'" + Strings::Escape(e.notes) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -255,20 +255,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
ContentFlags entry{};
ContentFlags e{};
entry.id = atoi(row[0]);
entry.flag_name = row[1] ? row[1] : "";
entry.enabled = atoi(row[2]);
entry.notes = row[3] ? row[3] : "";
e.id = atoi(row[0]);
e.flag_name = row[1] ? row[1] : "";
e.enabled = atoi(row[2]);
e.notes = row[3] ? row[3] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<ContentFlags> GetWhere(Database& db, std::string where_filter)
static std::vector<ContentFlags> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<ContentFlags> all_entries;
@@ -283,20 +283,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
ContentFlags entry{};
ContentFlags e{};
entry.id = atoi(row[0]);
entry.flag_name = row[1] ? row[1] : "";
entry.enabled = atoi(row[2]);
entry.notes = row[3] ? row[3] : "";
e.id = atoi(row[0]);
e.flag_name = row[1] ? row[1] : "";
e.enabled = atoi(row[2]);
e.notes = row[3] ? row[3] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -321,6 +321,32 @@ public:
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_CONTENT_FLAGS_REPOSITORY_H
@@ -79,15 +79,15 @@ public:
static Damageshieldtypes NewEntity()
{
Damageshieldtypes entry{};
Damageshieldtypes e{};
entry.spellid = 0;
entry.type = 0;
e.spellid = 0;
e.type = 0;
return entry;
return e;
}
static Damageshieldtypes GetDamageshieldtypesEntry(
static Damageshieldtypes GetDamageshieldtypes(
const std::vector<Damageshieldtypes> &damageshieldtypess,
int damageshieldtypes_id
)
@@ -116,12 +116,12 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
Damageshieldtypes entry{};
Damageshieldtypes e{};
entry.spellid = atoi(row[0]);
entry.type = atoi(row[1]);
e.spellid = atoi(row[0]);
e.type = atoi(row[1]);
return entry;
return e;
}
return NewEntity();
@@ -146,23 +146,23 @@ public:
static int UpdateOne(
Database& db,
Damageshieldtypes damageshieldtypes_entry
const Damageshieldtypes &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(damageshieldtypes_entry.spellid));
update_values.push_back(columns[1] + " = " + std::to_string(damageshieldtypes_entry.type));
v.push_back(columns[0] + " = " + std::to_string(e.spellid));
v.push_back(columns[1] + " = " + std::to_string(e.type));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
damageshieldtypes_entry.spellid
e.spellid
)
);
@@ -171,49 +171,49 @@ public:
static Damageshieldtypes InsertOne(
Database& db,
Damageshieldtypes damageshieldtypes_entry
Damageshieldtypes e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(damageshieldtypes_entry.spellid));
insert_values.push_back(std::to_string(damageshieldtypes_entry.type));
v.push_back(std::to_string(e.spellid));
v.push_back(std::to_string(e.type));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
damageshieldtypes_entry.spellid = results.LastInsertedID();
return damageshieldtypes_entry;
e.spellid = results.LastInsertedID();
return e;
}
damageshieldtypes_entry = NewEntity();
e = NewEntity();
return damageshieldtypes_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<Damageshieldtypes> damageshieldtypes_entries
const std::vector<Damageshieldtypes> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &damageshieldtypes_entry: damageshieldtypes_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(damageshieldtypes_entry.spellid));
insert_values.push_back(std::to_string(damageshieldtypes_entry.type));
v.push_back(std::to_string(e.spellid));
v.push_back(std::to_string(e.type));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -240,18 +240,18 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Damageshieldtypes entry{};
Damageshieldtypes e{};
entry.spellid = atoi(row[0]);
entry.type = atoi(row[1]);
e.spellid = atoi(row[0]);
e.type = atoi(row[1]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<Damageshieldtypes> GetWhere(Database& db, std::string where_filter)
static std::vector<Damageshieldtypes> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<Damageshieldtypes> all_entries;
@@ -266,18 +266,18 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Damageshieldtypes entry{};
Damageshieldtypes e{};
entry.spellid = atoi(row[0]);
entry.type = atoi(row[1]);
e.spellid = atoi(row[0]);
e.type = atoi(row[1]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -302,6 +302,32 @@ public:
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_DAMAGESHIELDTYPES_REPOSITORY_H
@@ -85,17 +85,17 @@ public:
static DataBuckets NewEntity()
{
DataBuckets entry{};
DataBuckets e{};
entry.id = 0;
entry.key = "";
entry.value = "";
entry.expires = 0;
e.id = 0;
e.key = "";
e.value = "";
e.expires = 0;
return entry;
return e;
}
static DataBuckets GetDataBucketsEntry(
static DataBuckets GetDataBuckets(
const std::vector<DataBuckets> &data_bucketss,
int data_buckets_id
)
@@ -124,14 +124,14 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
DataBuckets entry{};
DataBuckets e{};
entry.id = strtoll(row[0], nullptr, 10);
entry.key = row[1] ? row[1] : "";
entry.value = row[2] ? row[2] : "";
entry.expires = atoi(row[3]);
e.id = strtoll(row[0], nullptr, 10);
e.key = row[1] ? row[1] : "";
e.value = row[2] ? row[2] : "";
e.expires = atoi(row[3]);
return entry;
return e;
}
return NewEntity();
@@ -156,24 +156,24 @@ public:
static int UpdateOne(
Database& db,
DataBuckets data_buckets_entry
const DataBuckets &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + Strings::Escape(data_buckets_entry.key) + "'");
update_values.push_back(columns[2] + " = '" + Strings::Escape(data_buckets_entry.value) + "'");
update_values.push_back(columns[3] + " = " + std::to_string(data_buckets_entry.expires));
v.push_back(columns[1] + " = '" + Strings::Escape(e.key) + "'");
v.push_back(columns[2] + " = '" + Strings::Escape(e.value) + "'");
v.push_back(columns[3] + " = " + std::to_string(e.expires));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
data_buckets_entry.id
e.id
)
);
@@ -182,53 +182,53 @@ public:
static DataBuckets InsertOne(
Database& db,
DataBuckets data_buckets_entry
DataBuckets e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(data_buckets_entry.id));
insert_values.push_back("'" + Strings::Escape(data_buckets_entry.key) + "'");
insert_values.push_back("'" + Strings::Escape(data_buckets_entry.value) + "'");
insert_values.push_back(std::to_string(data_buckets_entry.expires));
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.key) + "'");
v.push_back("'" + Strings::Escape(e.value) + "'");
v.push_back(std::to_string(e.expires));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
data_buckets_entry.id = results.LastInsertedID();
return data_buckets_entry;
e.id = results.LastInsertedID();
return e;
}
data_buckets_entry = NewEntity();
e = NewEntity();
return data_buckets_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<DataBuckets> data_buckets_entries
const std::vector<DataBuckets> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &data_buckets_entry: data_buckets_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(data_buckets_entry.id));
insert_values.push_back("'" + Strings::Escape(data_buckets_entry.key) + "'");
insert_values.push_back("'" + Strings::Escape(data_buckets_entry.value) + "'");
insert_values.push_back(std::to_string(data_buckets_entry.expires));
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.key) + "'");
v.push_back("'" + Strings::Escape(e.value) + "'");
v.push_back(std::to_string(e.expires));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -255,20 +255,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
DataBuckets entry{};
DataBuckets e{};
entry.id = strtoll(row[0], nullptr, 10);
entry.key = row[1] ? row[1] : "";
entry.value = row[2] ? row[2] : "";
entry.expires = atoi(row[3]);
e.id = strtoll(row[0], nullptr, 10);
e.key = row[1] ? row[1] : "";
e.value = row[2] ? row[2] : "";
e.expires = atoi(row[3]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<DataBuckets> GetWhere(Database& db, std::string where_filter)
static std::vector<DataBuckets> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<DataBuckets> all_entries;
@@ -283,20 +283,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
DataBuckets entry{};
DataBuckets e{};
entry.id = strtoll(row[0], nullptr, 10);
entry.key = row[1] ? row[1] : "";
entry.value = row[2] ? row[2] : "";
entry.expires = atoi(row[3]);
e.id = strtoll(row[0], nullptr, 10);
e.key = row[1] ? row[1] : "";
e.value = row[2] ? row[2] : "";
e.expires = atoi(row[3]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -321,6 +321,32 @@ public:
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_DATA_BUCKETS_REPOSITORY_H
@@ -82,16 +82,16 @@ public:
static DbStr NewEntity()
{
DbStr entry{};
DbStr e{};
entry.id = 0;
entry.type = 0;
entry.value = "";
e.id = 0;
e.type = 0;
e.value = "";
return entry;
return e;
}
static DbStr GetDbStrEntry(
static DbStr GetDbStr(
const std::vector<DbStr> &db_strs,
int db_str_id
)
@@ -120,13 +120,13 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
DbStr entry{};
DbStr e{};
entry.id = atoi(row[0]);
entry.type = atoi(row[1]);
entry.value = row[2] ? row[2] : "";
e.id = atoi(row[0]);
e.type = atoi(row[1]);
e.value = row[2] ? row[2] : "";
return entry;
return e;
}
return NewEntity();
@@ -151,24 +151,24 @@ public:
static int UpdateOne(
Database& db,
DbStr db_str_entry
const DbStr &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(db_str_entry.id));
update_values.push_back(columns[1] + " = " + std::to_string(db_str_entry.type));
update_values.push_back(columns[2] + " = '" + Strings::Escape(db_str_entry.value) + "'");
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = " + std::to_string(e.type));
v.push_back(columns[2] + " = '" + Strings::Escape(e.value) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
db_str_entry.id
e.id
)
);
@@ -177,51 +177,51 @@ public:
static DbStr InsertOne(
Database& db,
DbStr db_str_entry
DbStr e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(db_str_entry.id));
insert_values.push_back(std::to_string(db_str_entry.type));
insert_values.push_back("'" + Strings::Escape(db_str_entry.value) + "'");
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.type));
v.push_back("'" + Strings::Escape(e.value) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
db_str_entry.id = results.LastInsertedID();
return db_str_entry;
e.id = results.LastInsertedID();
return e;
}
db_str_entry = NewEntity();
e = NewEntity();
return db_str_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<DbStr> db_str_entries
const std::vector<DbStr> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &db_str_entry: db_str_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(db_str_entry.id));
insert_values.push_back(std::to_string(db_str_entry.type));
insert_values.push_back("'" + Strings::Escape(db_str_entry.value) + "'");
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.type));
v.push_back("'" + Strings::Escape(e.value) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -248,19 +248,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
DbStr entry{};
DbStr e{};
entry.id = atoi(row[0]);
entry.type = atoi(row[1]);
entry.value = row[2] ? row[2] : "";
e.id = atoi(row[0]);
e.type = atoi(row[1]);
e.value = row[2] ? row[2] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<DbStr> GetWhere(Database& db, std::string where_filter)
static std::vector<DbStr> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<DbStr> all_entries;
@@ -275,19 +275,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
DbStr entry{};
DbStr e{};
entry.id = atoi(row[0]);
entry.type = atoi(row[1]);
entry.value = row[2] ? row[2] : "";
e.id = atoi(row[0]);
e.type = atoi(row[1]);
e.value = row[2] ? row[2] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -312,6 +312,32 @@ public:
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_DB_STR_REPOSITORY_H
@@ -88,18 +88,18 @@ public:
static DiscordWebhooks NewEntity()
{
DiscordWebhooks entry{};
DiscordWebhooks e{};
entry.id = 0;
entry.webhook_name = "";
entry.webhook_url = "";
entry.created_at = 0;
entry.deleted_at = 0;
e.id = 0;
e.webhook_name = "";
e.webhook_url = "";
e.created_at = 0;
e.deleted_at = 0;
return entry;
return e;
}
static DiscordWebhooks GetDiscordWebhooksEntry(
static DiscordWebhooks GetDiscordWebhooks(
const std::vector<DiscordWebhooks> &discord_webhookss,
int discord_webhooks_id
)
@@ -128,15 +128,15 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
DiscordWebhooks entry{};
DiscordWebhooks e{};
entry.id = atoi(row[0]);
entry.webhook_name = row[1] ? row[1] : "";
entry.webhook_url = row[2] ? row[2] : "";
entry.created_at = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
entry.deleted_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
e.id = atoi(row[0]);
e.webhook_name = row[1] ? row[1] : "";
e.webhook_url = row[2] ? row[2] : "";
e.created_at = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
e.deleted_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
return entry;
return e;
}
return NewEntity();
@@ -161,25 +161,25 @@ public:
static int UpdateOne(
Database& db,
DiscordWebhooks discord_webhooks_entry
const DiscordWebhooks &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + Strings::Escape(discord_webhooks_entry.webhook_name) + "'");
update_values.push_back(columns[2] + " = '" + Strings::Escape(discord_webhooks_entry.webhook_url) + "'");
update_values.push_back(columns[3] + " = FROM_UNIXTIME(" + (discord_webhooks_entry.created_at > 0 ? std::to_string(discord_webhooks_entry.created_at) : "null") + ")");
update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (discord_webhooks_entry.deleted_at > 0 ? std::to_string(discord_webhooks_entry.deleted_at) : "null") + ")");
v.push_back(columns[1] + " = '" + Strings::Escape(e.webhook_name) + "'");
v.push_back(columns[2] + " = '" + Strings::Escape(e.webhook_url) + "'");
v.push_back(columns[3] + " = FROM_UNIXTIME(" + (e.created_at > 0 ? std::to_string(e.created_at) : "null") + ")");
v.push_back(columns[4] + " = FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
discord_webhooks_entry.id
e.id
)
);
@@ -188,55 +188,55 @@ public:
static DiscordWebhooks InsertOne(
Database& db,
DiscordWebhooks discord_webhooks_entry
DiscordWebhooks e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(discord_webhooks_entry.id));
insert_values.push_back("'" + Strings::Escape(discord_webhooks_entry.webhook_name) + "'");
insert_values.push_back("'" + Strings::Escape(discord_webhooks_entry.webhook_url) + "'");
insert_values.push_back("FROM_UNIXTIME(" + (discord_webhooks_entry.created_at > 0 ? std::to_string(discord_webhooks_entry.created_at) : "null") + ")");
insert_values.push_back("FROM_UNIXTIME(" + (discord_webhooks_entry.deleted_at > 0 ? std::to_string(discord_webhooks_entry.deleted_at) : "null") + ")");
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.webhook_name) + "'");
v.push_back("'" + Strings::Escape(e.webhook_url) + "'");
v.push_back("FROM_UNIXTIME(" + (e.created_at > 0 ? std::to_string(e.created_at) : "null") + ")");
v.push_back("FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
discord_webhooks_entry.id = results.LastInsertedID();
return discord_webhooks_entry;
e.id = results.LastInsertedID();
return e;
}
discord_webhooks_entry = NewEntity();
e = NewEntity();
return discord_webhooks_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<DiscordWebhooks> discord_webhooks_entries
const std::vector<DiscordWebhooks> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &discord_webhooks_entry: discord_webhooks_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(discord_webhooks_entry.id));
insert_values.push_back("'" + Strings::Escape(discord_webhooks_entry.webhook_name) + "'");
insert_values.push_back("'" + Strings::Escape(discord_webhooks_entry.webhook_url) + "'");
insert_values.push_back("FROM_UNIXTIME(" + (discord_webhooks_entry.created_at > 0 ? std::to_string(discord_webhooks_entry.created_at) : "null") + ")");
insert_values.push_back("FROM_UNIXTIME(" + (discord_webhooks_entry.deleted_at > 0 ? std::to_string(discord_webhooks_entry.deleted_at) : "null") + ")");
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.webhook_name) + "'");
v.push_back("'" + Strings::Escape(e.webhook_url) + "'");
v.push_back("FROM_UNIXTIME(" + (e.created_at > 0 ? std::to_string(e.created_at) : "null") + ")");
v.push_back("FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -263,21 +263,21 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
DiscordWebhooks entry{};
DiscordWebhooks e{};
entry.id = atoi(row[0]);
entry.webhook_name = row[1] ? row[1] : "";
entry.webhook_url = row[2] ? row[2] : "";
entry.created_at = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
entry.deleted_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
e.id = atoi(row[0]);
e.webhook_name = row[1] ? row[1] : "";
e.webhook_url = row[2] ? row[2] : "";
e.created_at = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
e.deleted_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<DiscordWebhooks> GetWhere(Database& db, std::string where_filter)
static std::vector<DiscordWebhooks> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<DiscordWebhooks> all_entries;
@@ -292,21 +292,21 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
DiscordWebhooks entry{};
DiscordWebhooks e{};
entry.id = atoi(row[0]);
entry.webhook_name = row[1] ? row[1] : "";
entry.webhook_url = row[2] ? row[2] : "";
entry.created_at = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
entry.deleted_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
e.id = atoi(row[0]);
e.webhook_name = row[1] ? row[1] : "";
e.webhook_url = row[2] ? row[2] : "";
e.created_at = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
e.deleted_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -331,6 +331,32 @@ public:
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_DISCORD_WEBHOOKS_REPOSITORY_H
@@ -85,17 +85,17 @@ public:
static DiscoveredItems NewEntity()
{
DiscoveredItems entry{};
DiscoveredItems e{};
entry.item_id = 0;
entry.char_name = "";
entry.discovered_date = 0;
entry.account_status = 0;
e.item_id = 0;
e.char_name = "";
e.discovered_date = 0;
e.account_status = 0;
return entry;
return e;
}
static DiscoveredItems GetDiscoveredItemsEntry(
static DiscoveredItems GetDiscoveredItems(
const std::vector<DiscoveredItems> &discovered_itemss,
int discovered_items_id
)
@@ -124,14 +124,14 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
DiscoveredItems entry{};
DiscoveredItems e{};
entry.item_id = atoi(row[0]);
entry.char_name = row[1] ? row[1] : "";
entry.discovered_date = atoi(row[2]);
entry.account_status = atoi(row[3]);
e.item_id = atoi(row[0]);
e.char_name = row[1] ? row[1] : "";
e.discovered_date = atoi(row[2]);
e.account_status = atoi(row[3]);
return entry;
return e;
}
return NewEntity();
@@ -156,25 +156,25 @@ public:
static int UpdateOne(
Database& db,
DiscoveredItems discovered_items_entry
const DiscoveredItems &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(discovered_items_entry.item_id));
update_values.push_back(columns[1] + " = '" + Strings::Escape(discovered_items_entry.char_name) + "'");
update_values.push_back(columns[2] + " = " + std::to_string(discovered_items_entry.discovered_date));
update_values.push_back(columns[3] + " = " + std::to_string(discovered_items_entry.account_status));
v.push_back(columns[0] + " = " + std::to_string(e.item_id));
v.push_back(columns[1] + " = '" + Strings::Escape(e.char_name) + "'");
v.push_back(columns[2] + " = " + std::to_string(e.discovered_date));
v.push_back(columns[3] + " = " + std::to_string(e.account_status));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
discovered_items_entry.item_id
e.item_id
)
);
@@ -183,53 +183,53 @@ public:
static DiscoveredItems InsertOne(
Database& db,
DiscoveredItems discovered_items_entry
DiscoveredItems e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(discovered_items_entry.item_id));
insert_values.push_back("'" + Strings::Escape(discovered_items_entry.char_name) + "'");
insert_values.push_back(std::to_string(discovered_items_entry.discovered_date));
insert_values.push_back(std::to_string(discovered_items_entry.account_status));
v.push_back(std::to_string(e.item_id));
v.push_back("'" + Strings::Escape(e.char_name) + "'");
v.push_back(std::to_string(e.discovered_date));
v.push_back(std::to_string(e.account_status));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
discovered_items_entry.item_id = results.LastInsertedID();
return discovered_items_entry;
e.item_id = results.LastInsertedID();
return e;
}
discovered_items_entry = NewEntity();
e = NewEntity();
return discovered_items_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<DiscoveredItems> discovered_items_entries
const std::vector<DiscoveredItems> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &discovered_items_entry: discovered_items_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(discovered_items_entry.item_id));
insert_values.push_back("'" + Strings::Escape(discovered_items_entry.char_name) + "'");
insert_values.push_back(std::to_string(discovered_items_entry.discovered_date));
insert_values.push_back(std::to_string(discovered_items_entry.account_status));
v.push_back(std::to_string(e.item_id));
v.push_back("'" + Strings::Escape(e.char_name) + "'");
v.push_back(std::to_string(e.discovered_date));
v.push_back(std::to_string(e.account_status));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -256,20 +256,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
DiscoveredItems entry{};
DiscoveredItems e{};
entry.item_id = atoi(row[0]);
entry.char_name = row[1] ? row[1] : "";
entry.discovered_date = atoi(row[2]);
entry.account_status = atoi(row[3]);
e.item_id = atoi(row[0]);
e.char_name = row[1] ? row[1] : "";
e.discovered_date = atoi(row[2]);
e.account_status = atoi(row[3]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<DiscoveredItems> GetWhere(Database& db, std::string where_filter)
static std::vector<DiscoveredItems> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<DiscoveredItems> all_entries;
@@ -284,20 +284,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
DiscoveredItems entry{};
DiscoveredItems e{};
entry.item_id = atoi(row[0]);
entry.char_name = row[1] ? row[1] : "";
entry.discovered_date = atoi(row[2]);
entry.account_status = atoi(row[3]);
e.item_id = atoi(row[0]);
e.char_name = row[1] ? row[1] : "";
e.discovered_date = atoi(row[2]);
e.account_status = atoi(row[3]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -322,6 +322,32 @@ public:
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_DISCOVERED_ITEMS_REPOSITORY_H
+304 -278
View File
@@ -181,49 +181,49 @@ public:
static Doors NewEntity()
{
Doors entry{};
Doors e{};
entry.id = 0;
entry.doorid = 0;
entry.zone = "";
entry.version = 0;
entry.name = "";
entry.pos_y = 0;
entry.pos_x = 0;
entry.pos_z = 0;
entry.heading = 0;
entry.opentype = 0;
entry.guild = 0;
entry.lockpick = 0;
entry.keyitem = 0;
entry.nokeyring = 0;
entry.triggerdoor = 0;
entry.triggertype = 0;
entry.disable_timer = 0;
entry.doorisopen = 0;
entry.door_param = 0;
entry.dest_zone = "NONE";
entry.dest_instance = 0;
entry.dest_x = 0;
entry.dest_y = 0;
entry.dest_z = 0;
entry.dest_heading = 0;
entry.invert_state = 0;
entry.incline = 0;
entry.size = 100;
entry.buffer = 0;
entry.client_version_mask = 4294967295;
entry.is_ldon_door = 0;
entry.dz_switch_id = 0;
entry.min_expansion = -1;
entry.max_expansion = -1;
entry.content_flags = "";
entry.content_flags_disabled = "";
e.id = 0;
e.doorid = 0;
e.zone = "";
e.version = 0;
e.name = "";
e.pos_y = 0;
e.pos_x = 0;
e.pos_z = 0;
e.heading = 0;
e.opentype = 0;
e.guild = 0;
e.lockpick = 0;
e.keyitem = 0;
e.nokeyring = 0;
e.triggerdoor = 0;
e.triggertype = 0;
e.disable_timer = 0;
e.doorisopen = 0;
e.door_param = 0;
e.dest_zone = "NONE";
e.dest_instance = 0;
e.dest_x = 0;
e.dest_y = 0;
e.dest_z = 0;
e.dest_heading = 0;
e.invert_state = 0;
e.incline = 0;
e.size = 100;
e.buffer = 0;
e.client_version_mask = 4294967295;
e.is_ldon_door = 0;
e.dz_switch_id = 0;
e.min_expansion = -1;
e.max_expansion = -1;
e.content_flags = "";
e.content_flags_disabled = "";
return entry;
return e;
}
static Doors GetDoorsEntry(
static Doors GetDoors(
const std::vector<Doors> &doorss,
int doors_id
)
@@ -252,46 +252,46 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
Doors entry{};
Doors e{};
entry.id = atoi(row[0]);
entry.doorid = atoi(row[1]);
entry.zone = row[2] ? row[2] : "";
entry.version = atoi(row[3]);
entry.name = row[4] ? row[4] : "";
entry.pos_y = static_cast<float>(atof(row[5]));
entry.pos_x = static_cast<float>(atof(row[6]));
entry.pos_z = static_cast<float>(atof(row[7]));
entry.heading = static_cast<float>(atof(row[8]));
entry.opentype = atoi(row[9]);
entry.guild = atoi(row[10]);
entry.lockpick = atoi(row[11]);
entry.keyitem = atoi(row[12]);
entry.nokeyring = atoi(row[13]);
entry.triggerdoor = atoi(row[14]);
entry.triggertype = atoi(row[15]);
entry.disable_timer = atoi(row[16]);
entry.doorisopen = atoi(row[17]);
entry.door_param = atoi(row[18]);
entry.dest_zone = row[19] ? row[19] : "";
entry.dest_instance = atoi(row[20]);
entry.dest_x = static_cast<float>(atof(row[21]));
entry.dest_y = static_cast<float>(atof(row[22]));
entry.dest_z = static_cast<float>(atof(row[23]));
entry.dest_heading = static_cast<float>(atof(row[24]));
entry.invert_state = atoi(row[25]);
entry.incline = atoi(row[26]);
entry.size = atoi(row[27]);
entry.buffer = static_cast<float>(atof(row[28]));
entry.client_version_mask = atoi(row[29]);
entry.is_ldon_door = atoi(row[30]);
entry.dz_switch_id = atoi(row[31]);
entry.min_expansion = atoi(row[32]);
entry.max_expansion = atoi(row[33]);
entry.content_flags = row[34] ? row[34] : "";
entry.content_flags_disabled = row[35] ? row[35] : "";
e.id = atoi(row[0]);
e.doorid = atoi(row[1]);
e.zone = row[2] ? row[2] : "";
e.version = atoi(row[3]);
e.name = row[4] ? row[4] : "";
e.pos_y = static_cast<float>(atof(row[5]));
e.pos_x = static_cast<float>(atof(row[6]));
e.pos_z = static_cast<float>(atof(row[7]));
e.heading = static_cast<float>(atof(row[8]));
e.opentype = atoi(row[9]);
e.guild = atoi(row[10]);
e.lockpick = atoi(row[11]);
e.keyitem = atoi(row[12]);
e.nokeyring = atoi(row[13]);
e.triggerdoor = atoi(row[14]);
e.triggertype = atoi(row[15]);
e.disable_timer = atoi(row[16]);
e.doorisopen = atoi(row[17]);
e.door_param = atoi(row[18]);
e.dest_zone = row[19] ? row[19] : "";
e.dest_instance = atoi(row[20]);
e.dest_x = static_cast<float>(atof(row[21]));
e.dest_y = static_cast<float>(atof(row[22]));
e.dest_z = static_cast<float>(atof(row[23]));
e.dest_heading = static_cast<float>(atof(row[24]));
e.invert_state = atoi(row[25]);
e.incline = atoi(row[26]);
e.size = atoi(row[27]);
e.buffer = static_cast<float>(atof(row[28]));
e.client_version_mask = atoi(row[29]);
e.is_ldon_door = atoi(row[30]);
e.dz_switch_id = atoi(row[31]);
e.min_expansion = atoi(row[32]);
e.max_expansion = atoi(row[33]);
e.content_flags = row[34] ? row[34] : "";
e.content_flags_disabled = row[35] ? row[35] : "";
return entry;
return e;
}
return NewEntity();
@@ -316,56 +316,56 @@ public:
static int UpdateOne(
Database& db,
Doors doors_entry
const Doors &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(doors_entry.doorid));
update_values.push_back(columns[2] + " = '" + Strings::Escape(doors_entry.zone) + "'");
update_values.push_back(columns[3] + " = " + std::to_string(doors_entry.version));
update_values.push_back(columns[4] + " = '" + Strings::Escape(doors_entry.name) + "'");
update_values.push_back(columns[5] + " = " + std::to_string(doors_entry.pos_y));
update_values.push_back(columns[6] + " = " + std::to_string(doors_entry.pos_x));
update_values.push_back(columns[7] + " = " + std::to_string(doors_entry.pos_z));
update_values.push_back(columns[8] + " = " + std::to_string(doors_entry.heading));
update_values.push_back(columns[9] + " = " + std::to_string(doors_entry.opentype));
update_values.push_back(columns[10] + " = " + std::to_string(doors_entry.guild));
update_values.push_back(columns[11] + " = " + std::to_string(doors_entry.lockpick));
update_values.push_back(columns[12] + " = " + std::to_string(doors_entry.keyitem));
update_values.push_back(columns[13] + " = " + std::to_string(doors_entry.nokeyring));
update_values.push_back(columns[14] + " = " + std::to_string(doors_entry.triggerdoor));
update_values.push_back(columns[15] + " = " + std::to_string(doors_entry.triggertype));
update_values.push_back(columns[16] + " = " + std::to_string(doors_entry.disable_timer));
update_values.push_back(columns[17] + " = " + std::to_string(doors_entry.doorisopen));
update_values.push_back(columns[18] + " = " + std::to_string(doors_entry.door_param));
update_values.push_back(columns[19] + " = '" + Strings::Escape(doors_entry.dest_zone) + "'");
update_values.push_back(columns[20] + " = " + std::to_string(doors_entry.dest_instance));
update_values.push_back(columns[21] + " = " + std::to_string(doors_entry.dest_x));
update_values.push_back(columns[22] + " = " + std::to_string(doors_entry.dest_y));
update_values.push_back(columns[23] + " = " + std::to_string(doors_entry.dest_z));
update_values.push_back(columns[24] + " = " + std::to_string(doors_entry.dest_heading));
update_values.push_back(columns[25] + " = " + std::to_string(doors_entry.invert_state));
update_values.push_back(columns[26] + " = " + std::to_string(doors_entry.incline));
update_values.push_back(columns[27] + " = " + std::to_string(doors_entry.size));
update_values.push_back(columns[28] + " = " + std::to_string(doors_entry.buffer));
update_values.push_back(columns[29] + " = " + std::to_string(doors_entry.client_version_mask));
update_values.push_back(columns[30] + " = " + std::to_string(doors_entry.is_ldon_door));
update_values.push_back(columns[31] + " = " + std::to_string(doors_entry.dz_switch_id));
update_values.push_back(columns[32] + " = " + std::to_string(doors_entry.min_expansion));
update_values.push_back(columns[33] + " = " + std::to_string(doors_entry.max_expansion));
update_values.push_back(columns[34] + " = '" + Strings::Escape(doors_entry.content_flags) + "'");
update_values.push_back(columns[35] + " = '" + Strings::Escape(doors_entry.content_flags_disabled) + "'");
v.push_back(columns[1] + " = " + std::to_string(e.doorid));
v.push_back(columns[2] + " = '" + Strings::Escape(e.zone) + "'");
v.push_back(columns[3] + " = " + std::to_string(e.version));
v.push_back(columns[4] + " = '" + Strings::Escape(e.name) + "'");
v.push_back(columns[5] + " = " + std::to_string(e.pos_y));
v.push_back(columns[6] + " = " + std::to_string(e.pos_x));
v.push_back(columns[7] + " = " + std::to_string(e.pos_z));
v.push_back(columns[8] + " = " + std::to_string(e.heading));
v.push_back(columns[9] + " = " + std::to_string(e.opentype));
v.push_back(columns[10] + " = " + std::to_string(e.guild));
v.push_back(columns[11] + " = " + std::to_string(e.lockpick));
v.push_back(columns[12] + " = " + std::to_string(e.keyitem));
v.push_back(columns[13] + " = " + std::to_string(e.nokeyring));
v.push_back(columns[14] + " = " + std::to_string(e.triggerdoor));
v.push_back(columns[15] + " = " + std::to_string(e.triggertype));
v.push_back(columns[16] + " = " + std::to_string(e.disable_timer));
v.push_back(columns[17] + " = " + std::to_string(e.doorisopen));
v.push_back(columns[18] + " = " + std::to_string(e.door_param));
v.push_back(columns[19] + " = '" + Strings::Escape(e.dest_zone) + "'");
v.push_back(columns[20] + " = " + std::to_string(e.dest_instance));
v.push_back(columns[21] + " = " + std::to_string(e.dest_x));
v.push_back(columns[22] + " = " + std::to_string(e.dest_y));
v.push_back(columns[23] + " = " + std::to_string(e.dest_z));
v.push_back(columns[24] + " = " + std::to_string(e.dest_heading));
v.push_back(columns[25] + " = " + std::to_string(e.invert_state));
v.push_back(columns[26] + " = " + std::to_string(e.incline));
v.push_back(columns[27] + " = " + std::to_string(e.size));
v.push_back(columns[28] + " = " + std::to_string(e.buffer));
v.push_back(columns[29] + " = " + std::to_string(e.client_version_mask));
v.push_back(columns[30] + " = " + std::to_string(e.is_ldon_door));
v.push_back(columns[31] + " = " + std::to_string(e.dz_switch_id));
v.push_back(columns[32] + " = " + std::to_string(e.min_expansion));
v.push_back(columns[33] + " = " + std::to_string(e.max_expansion));
v.push_back(columns[34] + " = '" + Strings::Escape(e.content_flags) + "'");
v.push_back(columns[35] + " = '" + Strings::Escape(e.content_flags_disabled) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
doors_entry.id
e.id
)
);
@@ -374,117 +374,117 @@ public:
static Doors InsertOne(
Database& db,
Doors doors_entry
Doors e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(doors_entry.id));
insert_values.push_back(std::to_string(doors_entry.doorid));
insert_values.push_back("'" + Strings::Escape(doors_entry.zone) + "'");
insert_values.push_back(std::to_string(doors_entry.version));
insert_values.push_back("'" + Strings::Escape(doors_entry.name) + "'");
insert_values.push_back(std::to_string(doors_entry.pos_y));
insert_values.push_back(std::to_string(doors_entry.pos_x));
insert_values.push_back(std::to_string(doors_entry.pos_z));
insert_values.push_back(std::to_string(doors_entry.heading));
insert_values.push_back(std::to_string(doors_entry.opentype));
insert_values.push_back(std::to_string(doors_entry.guild));
insert_values.push_back(std::to_string(doors_entry.lockpick));
insert_values.push_back(std::to_string(doors_entry.keyitem));
insert_values.push_back(std::to_string(doors_entry.nokeyring));
insert_values.push_back(std::to_string(doors_entry.triggerdoor));
insert_values.push_back(std::to_string(doors_entry.triggertype));
insert_values.push_back(std::to_string(doors_entry.disable_timer));
insert_values.push_back(std::to_string(doors_entry.doorisopen));
insert_values.push_back(std::to_string(doors_entry.door_param));
insert_values.push_back("'" + Strings::Escape(doors_entry.dest_zone) + "'");
insert_values.push_back(std::to_string(doors_entry.dest_instance));
insert_values.push_back(std::to_string(doors_entry.dest_x));
insert_values.push_back(std::to_string(doors_entry.dest_y));
insert_values.push_back(std::to_string(doors_entry.dest_z));
insert_values.push_back(std::to_string(doors_entry.dest_heading));
insert_values.push_back(std::to_string(doors_entry.invert_state));
insert_values.push_back(std::to_string(doors_entry.incline));
insert_values.push_back(std::to_string(doors_entry.size));
insert_values.push_back(std::to_string(doors_entry.buffer));
insert_values.push_back(std::to_string(doors_entry.client_version_mask));
insert_values.push_back(std::to_string(doors_entry.is_ldon_door));
insert_values.push_back(std::to_string(doors_entry.dz_switch_id));
insert_values.push_back(std::to_string(doors_entry.min_expansion));
insert_values.push_back(std::to_string(doors_entry.max_expansion));
insert_values.push_back("'" + Strings::Escape(doors_entry.content_flags) + "'");
insert_values.push_back("'" + Strings::Escape(doors_entry.content_flags_disabled) + "'");
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.doorid));
v.push_back("'" + Strings::Escape(e.zone) + "'");
v.push_back(std::to_string(e.version));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back(std::to_string(e.pos_y));
v.push_back(std::to_string(e.pos_x));
v.push_back(std::to_string(e.pos_z));
v.push_back(std::to_string(e.heading));
v.push_back(std::to_string(e.opentype));
v.push_back(std::to_string(e.guild));
v.push_back(std::to_string(e.lockpick));
v.push_back(std::to_string(e.keyitem));
v.push_back(std::to_string(e.nokeyring));
v.push_back(std::to_string(e.triggerdoor));
v.push_back(std::to_string(e.triggertype));
v.push_back(std::to_string(e.disable_timer));
v.push_back(std::to_string(e.doorisopen));
v.push_back(std::to_string(e.door_param));
v.push_back("'" + Strings::Escape(e.dest_zone) + "'");
v.push_back(std::to_string(e.dest_instance));
v.push_back(std::to_string(e.dest_x));
v.push_back(std::to_string(e.dest_y));
v.push_back(std::to_string(e.dest_z));
v.push_back(std::to_string(e.dest_heading));
v.push_back(std::to_string(e.invert_state));
v.push_back(std::to_string(e.incline));
v.push_back(std::to_string(e.size));
v.push_back(std::to_string(e.buffer));
v.push_back(std::to_string(e.client_version_mask));
v.push_back(std::to_string(e.is_ldon_door));
v.push_back(std::to_string(e.dz_switch_id));
v.push_back(std::to_string(e.min_expansion));
v.push_back(std::to_string(e.max_expansion));
v.push_back("'" + Strings::Escape(e.content_flags) + "'");
v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
doors_entry.id = results.LastInsertedID();
return doors_entry;
e.id = results.LastInsertedID();
return e;
}
doors_entry = NewEntity();
e = NewEntity();
return doors_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<Doors> doors_entries
const std::vector<Doors> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &doors_entry: doors_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(doors_entry.id));
insert_values.push_back(std::to_string(doors_entry.doorid));
insert_values.push_back("'" + Strings::Escape(doors_entry.zone) + "'");
insert_values.push_back(std::to_string(doors_entry.version));
insert_values.push_back("'" + Strings::Escape(doors_entry.name) + "'");
insert_values.push_back(std::to_string(doors_entry.pos_y));
insert_values.push_back(std::to_string(doors_entry.pos_x));
insert_values.push_back(std::to_string(doors_entry.pos_z));
insert_values.push_back(std::to_string(doors_entry.heading));
insert_values.push_back(std::to_string(doors_entry.opentype));
insert_values.push_back(std::to_string(doors_entry.guild));
insert_values.push_back(std::to_string(doors_entry.lockpick));
insert_values.push_back(std::to_string(doors_entry.keyitem));
insert_values.push_back(std::to_string(doors_entry.nokeyring));
insert_values.push_back(std::to_string(doors_entry.triggerdoor));
insert_values.push_back(std::to_string(doors_entry.triggertype));
insert_values.push_back(std::to_string(doors_entry.disable_timer));
insert_values.push_back(std::to_string(doors_entry.doorisopen));
insert_values.push_back(std::to_string(doors_entry.door_param));
insert_values.push_back("'" + Strings::Escape(doors_entry.dest_zone) + "'");
insert_values.push_back(std::to_string(doors_entry.dest_instance));
insert_values.push_back(std::to_string(doors_entry.dest_x));
insert_values.push_back(std::to_string(doors_entry.dest_y));
insert_values.push_back(std::to_string(doors_entry.dest_z));
insert_values.push_back(std::to_string(doors_entry.dest_heading));
insert_values.push_back(std::to_string(doors_entry.invert_state));
insert_values.push_back(std::to_string(doors_entry.incline));
insert_values.push_back(std::to_string(doors_entry.size));
insert_values.push_back(std::to_string(doors_entry.buffer));
insert_values.push_back(std::to_string(doors_entry.client_version_mask));
insert_values.push_back(std::to_string(doors_entry.is_ldon_door));
insert_values.push_back(std::to_string(doors_entry.dz_switch_id));
insert_values.push_back(std::to_string(doors_entry.min_expansion));
insert_values.push_back(std::to_string(doors_entry.max_expansion));
insert_values.push_back("'" + Strings::Escape(doors_entry.content_flags) + "'");
insert_values.push_back("'" + Strings::Escape(doors_entry.content_flags_disabled) + "'");
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.doorid));
v.push_back("'" + Strings::Escape(e.zone) + "'");
v.push_back(std::to_string(e.version));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back(std::to_string(e.pos_y));
v.push_back(std::to_string(e.pos_x));
v.push_back(std::to_string(e.pos_z));
v.push_back(std::to_string(e.heading));
v.push_back(std::to_string(e.opentype));
v.push_back(std::to_string(e.guild));
v.push_back(std::to_string(e.lockpick));
v.push_back(std::to_string(e.keyitem));
v.push_back(std::to_string(e.nokeyring));
v.push_back(std::to_string(e.triggerdoor));
v.push_back(std::to_string(e.triggertype));
v.push_back(std::to_string(e.disable_timer));
v.push_back(std::to_string(e.doorisopen));
v.push_back(std::to_string(e.door_param));
v.push_back("'" + Strings::Escape(e.dest_zone) + "'");
v.push_back(std::to_string(e.dest_instance));
v.push_back(std::to_string(e.dest_x));
v.push_back(std::to_string(e.dest_y));
v.push_back(std::to_string(e.dest_z));
v.push_back(std::to_string(e.dest_heading));
v.push_back(std::to_string(e.invert_state));
v.push_back(std::to_string(e.incline));
v.push_back(std::to_string(e.size));
v.push_back(std::to_string(e.buffer));
v.push_back(std::to_string(e.client_version_mask));
v.push_back(std::to_string(e.is_ldon_door));
v.push_back(std::to_string(e.dz_switch_id));
v.push_back(std::to_string(e.min_expansion));
v.push_back(std::to_string(e.max_expansion));
v.push_back("'" + Strings::Escape(e.content_flags) + "'");
v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -511,52 +511,52 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Doors entry{};
Doors e{};
entry.id = atoi(row[0]);
entry.doorid = atoi(row[1]);
entry.zone = row[2] ? row[2] : "";
entry.version = atoi(row[3]);
entry.name = row[4] ? row[4] : "";
entry.pos_y = static_cast<float>(atof(row[5]));
entry.pos_x = static_cast<float>(atof(row[6]));
entry.pos_z = static_cast<float>(atof(row[7]));
entry.heading = static_cast<float>(atof(row[8]));
entry.opentype = atoi(row[9]);
entry.guild = atoi(row[10]);
entry.lockpick = atoi(row[11]);
entry.keyitem = atoi(row[12]);
entry.nokeyring = atoi(row[13]);
entry.triggerdoor = atoi(row[14]);
entry.triggertype = atoi(row[15]);
entry.disable_timer = atoi(row[16]);
entry.doorisopen = atoi(row[17]);
entry.door_param = atoi(row[18]);
entry.dest_zone = row[19] ? row[19] : "";
entry.dest_instance = atoi(row[20]);
entry.dest_x = static_cast<float>(atof(row[21]));
entry.dest_y = static_cast<float>(atof(row[22]));
entry.dest_z = static_cast<float>(atof(row[23]));
entry.dest_heading = static_cast<float>(atof(row[24]));
entry.invert_state = atoi(row[25]);
entry.incline = atoi(row[26]);
entry.size = atoi(row[27]);
entry.buffer = static_cast<float>(atof(row[28]));
entry.client_version_mask = atoi(row[29]);
entry.is_ldon_door = atoi(row[30]);
entry.dz_switch_id = atoi(row[31]);
entry.min_expansion = atoi(row[32]);
entry.max_expansion = atoi(row[33]);
entry.content_flags = row[34] ? row[34] : "";
entry.content_flags_disabled = row[35] ? row[35] : "";
e.id = atoi(row[0]);
e.doorid = atoi(row[1]);
e.zone = row[2] ? row[2] : "";
e.version = atoi(row[3]);
e.name = row[4] ? row[4] : "";
e.pos_y = static_cast<float>(atof(row[5]));
e.pos_x = static_cast<float>(atof(row[6]));
e.pos_z = static_cast<float>(atof(row[7]));
e.heading = static_cast<float>(atof(row[8]));
e.opentype = atoi(row[9]);
e.guild = atoi(row[10]);
e.lockpick = atoi(row[11]);
e.keyitem = atoi(row[12]);
e.nokeyring = atoi(row[13]);
e.triggerdoor = atoi(row[14]);
e.triggertype = atoi(row[15]);
e.disable_timer = atoi(row[16]);
e.doorisopen = atoi(row[17]);
e.door_param = atoi(row[18]);
e.dest_zone = row[19] ? row[19] : "";
e.dest_instance = atoi(row[20]);
e.dest_x = static_cast<float>(atof(row[21]));
e.dest_y = static_cast<float>(atof(row[22]));
e.dest_z = static_cast<float>(atof(row[23]));
e.dest_heading = static_cast<float>(atof(row[24]));
e.invert_state = atoi(row[25]);
e.incline = atoi(row[26]);
e.size = atoi(row[27]);
e.buffer = static_cast<float>(atof(row[28]));
e.client_version_mask = atoi(row[29]);
e.is_ldon_door = atoi(row[30]);
e.dz_switch_id = atoi(row[31]);
e.min_expansion = atoi(row[32]);
e.max_expansion = atoi(row[33]);
e.content_flags = row[34] ? row[34] : "";
e.content_flags_disabled = row[35] ? row[35] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<Doors> GetWhere(Database& db, std::string where_filter)
static std::vector<Doors> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<Doors> all_entries;
@@ -571,52 +571,52 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Doors entry{};
Doors e{};
entry.id = atoi(row[0]);
entry.doorid = atoi(row[1]);
entry.zone = row[2] ? row[2] : "";
entry.version = atoi(row[3]);
entry.name = row[4] ? row[4] : "";
entry.pos_y = static_cast<float>(atof(row[5]));
entry.pos_x = static_cast<float>(atof(row[6]));
entry.pos_z = static_cast<float>(atof(row[7]));
entry.heading = static_cast<float>(atof(row[8]));
entry.opentype = atoi(row[9]);
entry.guild = atoi(row[10]);
entry.lockpick = atoi(row[11]);
entry.keyitem = atoi(row[12]);
entry.nokeyring = atoi(row[13]);
entry.triggerdoor = atoi(row[14]);
entry.triggertype = atoi(row[15]);
entry.disable_timer = atoi(row[16]);
entry.doorisopen = atoi(row[17]);
entry.door_param = atoi(row[18]);
entry.dest_zone = row[19] ? row[19] : "";
entry.dest_instance = atoi(row[20]);
entry.dest_x = static_cast<float>(atof(row[21]));
entry.dest_y = static_cast<float>(atof(row[22]));
entry.dest_z = static_cast<float>(atof(row[23]));
entry.dest_heading = static_cast<float>(atof(row[24]));
entry.invert_state = atoi(row[25]);
entry.incline = atoi(row[26]);
entry.size = atoi(row[27]);
entry.buffer = static_cast<float>(atof(row[28]));
entry.client_version_mask = atoi(row[29]);
entry.is_ldon_door = atoi(row[30]);
entry.dz_switch_id = atoi(row[31]);
entry.min_expansion = atoi(row[32]);
entry.max_expansion = atoi(row[33]);
entry.content_flags = row[34] ? row[34] : "";
entry.content_flags_disabled = row[35] ? row[35] : "";
e.id = atoi(row[0]);
e.doorid = atoi(row[1]);
e.zone = row[2] ? row[2] : "";
e.version = atoi(row[3]);
e.name = row[4] ? row[4] : "";
e.pos_y = static_cast<float>(atof(row[5]));
e.pos_x = static_cast<float>(atof(row[6]));
e.pos_z = static_cast<float>(atof(row[7]));
e.heading = static_cast<float>(atof(row[8]));
e.opentype = atoi(row[9]);
e.guild = atoi(row[10]);
e.lockpick = atoi(row[11]);
e.keyitem = atoi(row[12]);
e.nokeyring = atoi(row[13]);
e.triggerdoor = atoi(row[14]);
e.triggertype = atoi(row[15]);
e.disable_timer = atoi(row[16]);
e.doorisopen = atoi(row[17]);
e.door_param = atoi(row[18]);
e.dest_zone = row[19] ? row[19] : "";
e.dest_instance = atoi(row[20]);
e.dest_x = static_cast<float>(atof(row[21]));
e.dest_y = static_cast<float>(atof(row[22]));
e.dest_z = static_cast<float>(atof(row[23]));
e.dest_heading = static_cast<float>(atof(row[24]));
e.invert_state = atoi(row[25]);
e.incline = atoi(row[26]);
e.size = atoi(row[27]);
e.buffer = static_cast<float>(atof(row[28]));
e.client_version_mask = atoi(row[29]);
e.is_ldon_door = atoi(row[30]);
e.dz_switch_id = atoi(row[31]);
e.min_expansion = atoi(row[32]);
e.max_expansion = atoi(row[33]);
e.content_flags = row[34] ? row[34] : "";
e.content_flags_disabled = row[35] ? row[35] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -641,6 +641,32 @@ public:
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_DOORS_REPOSITORY_H
@@ -82,16 +82,16 @@ public:
static DynamicZoneMembers NewEntity()
{
DynamicZoneMembers entry{};
DynamicZoneMembers e{};
entry.id = 0;
entry.dynamic_zone_id = 0;
entry.character_id = 0;
e.id = 0;
e.dynamic_zone_id = 0;
e.character_id = 0;
return entry;
return e;
}
static DynamicZoneMembers GetDynamicZoneMembersEntry(
static DynamicZoneMembers GetDynamicZoneMembers(
const std::vector<DynamicZoneMembers> &dynamic_zone_memberss,
int dynamic_zone_members_id
)
@@ -120,13 +120,13 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
DynamicZoneMembers entry{};
DynamicZoneMembers e{};
entry.id = atoi(row[0]);
entry.dynamic_zone_id = atoi(row[1]);
entry.character_id = atoi(row[2]);
e.id = atoi(row[0]);
e.dynamic_zone_id = atoi(row[1]);
e.character_id = atoi(row[2]);
return entry;
return e;
}
return NewEntity();
@@ -151,23 +151,23 @@ public:
static int UpdateOne(
Database& db,
DynamicZoneMembers dynamic_zone_members_entry
const DynamicZoneMembers &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(dynamic_zone_members_entry.dynamic_zone_id));
update_values.push_back(columns[2] + " = " + std::to_string(dynamic_zone_members_entry.character_id));
v.push_back(columns[1] + " = " + std::to_string(e.dynamic_zone_id));
v.push_back(columns[2] + " = " + std::to_string(e.character_id));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
dynamic_zone_members_entry.id
e.id
)
);
@@ -176,51 +176,51 @@ public:
static DynamicZoneMembers InsertOne(
Database& db,
DynamicZoneMembers dynamic_zone_members_entry
DynamicZoneMembers e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(dynamic_zone_members_entry.id));
insert_values.push_back(std::to_string(dynamic_zone_members_entry.dynamic_zone_id));
insert_values.push_back(std::to_string(dynamic_zone_members_entry.character_id));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.dynamic_zone_id));
v.push_back(std::to_string(e.character_id));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
dynamic_zone_members_entry.id = results.LastInsertedID();
return dynamic_zone_members_entry;
e.id = results.LastInsertedID();
return e;
}
dynamic_zone_members_entry = NewEntity();
e = NewEntity();
return dynamic_zone_members_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<DynamicZoneMembers> dynamic_zone_members_entries
const std::vector<DynamicZoneMembers> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &dynamic_zone_members_entry: dynamic_zone_members_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(dynamic_zone_members_entry.id));
insert_values.push_back(std::to_string(dynamic_zone_members_entry.dynamic_zone_id));
insert_values.push_back(std::to_string(dynamic_zone_members_entry.character_id));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.dynamic_zone_id));
v.push_back(std::to_string(e.character_id));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -247,19 +247,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
DynamicZoneMembers entry{};
DynamicZoneMembers e{};
entry.id = atoi(row[0]);
entry.dynamic_zone_id = atoi(row[1]);
entry.character_id = atoi(row[2]);
e.id = atoi(row[0]);
e.dynamic_zone_id = atoi(row[1]);
e.character_id = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<DynamicZoneMembers> GetWhere(Database& db, std::string where_filter)
static std::vector<DynamicZoneMembers> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<DynamicZoneMembers> all_entries;
@@ -274,19 +274,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
DynamicZoneMembers entry{};
DynamicZoneMembers e{};
entry.id = atoi(row[0]);
entry.dynamic_zone_id = atoi(row[1]);
entry.character_id = atoi(row[2]);
e.id = atoi(row[0]);
e.dynamic_zone_id = atoi(row[1]);
e.character_id = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -311,6 +311,32 @@ public:
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_DYNAMIC_ZONE_MEMBERS_REPOSITORY_H
@@ -139,35 +139,35 @@ public:
static DynamicZoneTemplates NewEntity()
{
DynamicZoneTemplates entry{};
DynamicZoneTemplates e{};
entry.id = 0;
entry.zone_id = 0;
entry.zone_version = 0;
entry.name = "";
entry.min_players = 0;
entry.max_players = 0;
entry.duration_seconds = 0;
entry.dz_switch_id = 0;
entry.compass_zone_id = 0;
entry.compass_x = 0;
entry.compass_y = 0;
entry.compass_z = 0;
entry.return_zone_id = 0;
entry.return_x = 0;
entry.return_y = 0;
entry.return_z = 0;
entry.return_h = 0;
entry.override_zone_in = 0;
entry.zone_in_x = 0;
entry.zone_in_y = 0;
entry.zone_in_z = 0;
entry.zone_in_h = 0;
e.id = 0;
e.zone_id = 0;
e.zone_version = 0;
e.name = "";
e.min_players = 0;
e.max_players = 0;
e.duration_seconds = 0;
e.dz_switch_id = 0;
e.compass_zone_id = 0;
e.compass_x = 0;
e.compass_y = 0;
e.compass_z = 0;
e.return_zone_id = 0;
e.return_x = 0;
e.return_y = 0;
e.return_z = 0;
e.return_h = 0;
e.override_zone_in = 0;
e.zone_in_x = 0;
e.zone_in_y = 0;
e.zone_in_z = 0;
e.zone_in_h = 0;
return entry;
return e;
}
static DynamicZoneTemplates GetDynamicZoneTemplatesEntry(
static DynamicZoneTemplates GetDynamicZoneTemplates(
const std::vector<DynamicZoneTemplates> &dynamic_zone_templatess,
int dynamic_zone_templates_id
)
@@ -196,32 +196,32 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
DynamicZoneTemplates entry{};
DynamicZoneTemplates e{};
entry.id = atoi(row[0]);
entry.zone_id = atoi(row[1]);
entry.zone_version = atoi(row[2]);
entry.name = row[3] ? row[3] : "";
entry.min_players = atoi(row[4]);
entry.max_players = atoi(row[5]);
entry.duration_seconds = atoi(row[6]);
entry.dz_switch_id = atoi(row[7]);
entry.compass_zone_id = atoi(row[8]);
entry.compass_x = static_cast<float>(atof(row[9]));
entry.compass_y = static_cast<float>(atof(row[10]));
entry.compass_z = static_cast<float>(atof(row[11]));
entry.return_zone_id = atoi(row[12]);
entry.return_x = static_cast<float>(atof(row[13]));
entry.return_y = static_cast<float>(atof(row[14]));
entry.return_z = static_cast<float>(atof(row[15]));
entry.return_h = static_cast<float>(atof(row[16]));
entry.override_zone_in = atoi(row[17]);
entry.zone_in_x = static_cast<float>(atof(row[18]));
entry.zone_in_y = static_cast<float>(atof(row[19]));
entry.zone_in_z = static_cast<float>(atof(row[20]));
entry.zone_in_h = static_cast<float>(atof(row[21]));
e.id = atoi(row[0]);
e.zone_id = atoi(row[1]);
e.zone_version = atoi(row[2]);
e.name = row[3] ? row[3] : "";
e.min_players = atoi(row[4]);
e.max_players = atoi(row[5]);
e.duration_seconds = atoi(row[6]);
e.dz_switch_id = atoi(row[7]);
e.compass_zone_id = atoi(row[8]);
e.compass_x = static_cast<float>(atof(row[9]));
e.compass_y = static_cast<float>(atof(row[10]));
e.compass_z = static_cast<float>(atof(row[11]));
e.return_zone_id = atoi(row[12]);
e.return_x = static_cast<float>(atof(row[13]));
e.return_y = static_cast<float>(atof(row[14]));
e.return_z = static_cast<float>(atof(row[15]));
e.return_h = static_cast<float>(atof(row[16]));
e.override_zone_in = atoi(row[17]);
e.zone_in_x = static_cast<float>(atof(row[18]));
e.zone_in_y = static_cast<float>(atof(row[19]));
e.zone_in_z = static_cast<float>(atof(row[20]));
e.zone_in_h = static_cast<float>(atof(row[21]));
return entry;
return e;
}
return NewEntity();
@@ -246,42 +246,42 @@ public:
static int UpdateOne(
Database& db,
DynamicZoneTemplates dynamic_zone_templates_entry
const DynamicZoneTemplates &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(dynamic_zone_templates_entry.zone_id));
update_values.push_back(columns[2] + " = " + std::to_string(dynamic_zone_templates_entry.zone_version));
update_values.push_back(columns[3] + " = '" + Strings::Escape(dynamic_zone_templates_entry.name) + "'");
update_values.push_back(columns[4] + " = " + std::to_string(dynamic_zone_templates_entry.min_players));
update_values.push_back(columns[5] + " = " + std::to_string(dynamic_zone_templates_entry.max_players));
update_values.push_back(columns[6] + " = " + std::to_string(dynamic_zone_templates_entry.duration_seconds));
update_values.push_back(columns[7] + " = " + std::to_string(dynamic_zone_templates_entry.dz_switch_id));
update_values.push_back(columns[8] + " = " + std::to_string(dynamic_zone_templates_entry.compass_zone_id));
update_values.push_back(columns[9] + " = " + std::to_string(dynamic_zone_templates_entry.compass_x));
update_values.push_back(columns[10] + " = " + std::to_string(dynamic_zone_templates_entry.compass_y));
update_values.push_back(columns[11] + " = " + std::to_string(dynamic_zone_templates_entry.compass_z));
update_values.push_back(columns[12] + " = " + std::to_string(dynamic_zone_templates_entry.return_zone_id));
update_values.push_back(columns[13] + " = " + std::to_string(dynamic_zone_templates_entry.return_x));
update_values.push_back(columns[14] + " = " + std::to_string(dynamic_zone_templates_entry.return_y));
update_values.push_back(columns[15] + " = " + std::to_string(dynamic_zone_templates_entry.return_z));
update_values.push_back(columns[16] + " = " + std::to_string(dynamic_zone_templates_entry.return_h));
update_values.push_back(columns[17] + " = " + std::to_string(dynamic_zone_templates_entry.override_zone_in));
update_values.push_back(columns[18] + " = " + std::to_string(dynamic_zone_templates_entry.zone_in_x));
update_values.push_back(columns[19] + " = " + std::to_string(dynamic_zone_templates_entry.zone_in_y));
update_values.push_back(columns[20] + " = " + std::to_string(dynamic_zone_templates_entry.zone_in_z));
update_values.push_back(columns[21] + " = " + std::to_string(dynamic_zone_templates_entry.zone_in_h));
v.push_back(columns[1] + " = " + std::to_string(e.zone_id));
v.push_back(columns[2] + " = " + std::to_string(e.zone_version));
v.push_back(columns[3] + " = '" + Strings::Escape(e.name) + "'");
v.push_back(columns[4] + " = " + std::to_string(e.min_players));
v.push_back(columns[5] + " = " + std::to_string(e.max_players));
v.push_back(columns[6] + " = " + std::to_string(e.duration_seconds));
v.push_back(columns[7] + " = " + std::to_string(e.dz_switch_id));
v.push_back(columns[8] + " = " + std::to_string(e.compass_zone_id));
v.push_back(columns[9] + " = " + std::to_string(e.compass_x));
v.push_back(columns[10] + " = " + std::to_string(e.compass_y));
v.push_back(columns[11] + " = " + std::to_string(e.compass_z));
v.push_back(columns[12] + " = " + std::to_string(e.return_zone_id));
v.push_back(columns[13] + " = " + std::to_string(e.return_x));
v.push_back(columns[14] + " = " + std::to_string(e.return_y));
v.push_back(columns[15] + " = " + std::to_string(e.return_z));
v.push_back(columns[16] + " = " + std::to_string(e.return_h));
v.push_back(columns[17] + " = " + std::to_string(e.override_zone_in));
v.push_back(columns[18] + " = " + std::to_string(e.zone_in_x));
v.push_back(columns[19] + " = " + std::to_string(e.zone_in_y));
v.push_back(columns[20] + " = " + std::to_string(e.zone_in_z));
v.push_back(columns[21] + " = " + std::to_string(e.zone_in_h));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
dynamic_zone_templates_entry.id
e.id
)
);
@@ -290,89 +290,89 @@ public:
static DynamicZoneTemplates InsertOne(
Database& db,
DynamicZoneTemplates dynamic_zone_templates_entry
DynamicZoneTemplates e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.id));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_id));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_version));
insert_values.push_back("'" + Strings::Escape(dynamic_zone_templates_entry.name) + "'");
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.min_players));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.max_players));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.duration_seconds));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.dz_switch_id));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_zone_id));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_x));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_y));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_z));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_zone_id));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_x));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_y));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_z));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_h));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.override_zone_in));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_x));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_y));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_z));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_h));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.zone_id));
v.push_back(std::to_string(e.zone_version));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back(std::to_string(e.min_players));
v.push_back(std::to_string(e.max_players));
v.push_back(std::to_string(e.duration_seconds));
v.push_back(std::to_string(e.dz_switch_id));
v.push_back(std::to_string(e.compass_zone_id));
v.push_back(std::to_string(e.compass_x));
v.push_back(std::to_string(e.compass_y));
v.push_back(std::to_string(e.compass_z));
v.push_back(std::to_string(e.return_zone_id));
v.push_back(std::to_string(e.return_x));
v.push_back(std::to_string(e.return_y));
v.push_back(std::to_string(e.return_z));
v.push_back(std::to_string(e.return_h));
v.push_back(std::to_string(e.override_zone_in));
v.push_back(std::to_string(e.zone_in_x));
v.push_back(std::to_string(e.zone_in_y));
v.push_back(std::to_string(e.zone_in_z));
v.push_back(std::to_string(e.zone_in_h));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
dynamic_zone_templates_entry.id = results.LastInsertedID();
return dynamic_zone_templates_entry;
e.id = results.LastInsertedID();
return e;
}
dynamic_zone_templates_entry = NewEntity();
e = NewEntity();
return dynamic_zone_templates_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<DynamicZoneTemplates> dynamic_zone_templates_entries
const std::vector<DynamicZoneTemplates> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &dynamic_zone_templates_entry: dynamic_zone_templates_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.id));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_id));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_version));
insert_values.push_back("'" + Strings::Escape(dynamic_zone_templates_entry.name) + "'");
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.min_players));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.max_players));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.duration_seconds));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.dz_switch_id));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_zone_id));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_x));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_y));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_z));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_zone_id));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_x));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_y));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_z));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_h));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.override_zone_in));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_x));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_y));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_z));
insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_h));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.zone_id));
v.push_back(std::to_string(e.zone_version));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back(std::to_string(e.min_players));
v.push_back(std::to_string(e.max_players));
v.push_back(std::to_string(e.duration_seconds));
v.push_back(std::to_string(e.dz_switch_id));
v.push_back(std::to_string(e.compass_zone_id));
v.push_back(std::to_string(e.compass_x));
v.push_back(std::to_string(e.compass_y));
v.push_back(std::to_string(e.compass_z));
v.push_back(std::to_string(e.return_zone_id));
v.push_back(std::to_string(e.return_x));
v.push_back(std::to_string(e.return_y));
v.push_back(std::to_string(e.return_z));
v.push_back(std::to_string(e.return_h));
v.push_back(std::to_string(e.override_zone_in));
v.push_back(std::to_string(e.zone_in_x));
v.push_back(std::to_string(e.zone_in_y));
v.push_back(std::to_string(e.zone_in_z));
v.push_back(std::to_string(e.zone_in_h));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -399,38 +399,38 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
DynamicZoneTemplates entry{};
DynamicZoneTemplates e{};
entry.id = atoi(row[0]);
entry.zone_id = atoi(row[1]);
entry.zone_version = atoi(row[2]);
entry.name = row[3] ? row[3] : "";
entry.min_players = atoi(row[4]);
entry.max_players = atoi(row[5]);
entry.duration_seconds = atoi(row[6]);
entry.dz_switch_id = atoi(row[7]);
entry.compass_zone_id = atoi(row[8]);
entry.compass_x = static_cast<float>(atof(row[9]));
entry.compass_y = static_cast<float>(atof(row[10]));
entry.compass_z = static_cast<float>(atof(row[11]));
entry.return_zone_id = atoi(row[12]);
entry.return_x = static_cast<float>(atof(row[13]));
entry.return_y = static_cast<float>(atof(row[14]));
entry.return_z = static_cast<float>(atof(row[15]));
entry.return_h = static_cast<float>(atof(row[16]));
entry.override_zone_in = atoi(row[17]);
entry.zone_in_x = static_cast<float>(atof(row[18]));
entry.zone_in_y = static_cast<float>(atof(row[19]));
entry.zone_in_z = static_cast<float>(atof(row[20]));
entry.zone_in_h = static_cast<float>(atof(row[21]));
e.id = atoi(row[0]);
e.zone_id = atoi(row[1]);
e.zone_version = atoi(row[2]);
e.name = row[3] ? row[3] : "";
e.min_players = atoi(row[4]);
e.max_players = atoi(row[5]);
e.duration_seconds = atoi(row[6]);
e.dz_switch_id = atoi(row[7]);
e.compass_zone_id = atoi(row[8]);
e.compass_x = static_cast<float>(atof(row[9]));
e.compass_y = static_cast<float>(atof(row[10]));
e.compass_z = static_cast<float>(atof(row[11]));
e.return_zone_id = atoi(row[12]);
e.return_x = static_cast<float>(atof(row[13]));
e.return_y = static_cast<float>(atof(row[14]));
e.return_z = static_cast<float>(atof(row[15]));
e.return_h = static_cast<float>(atof(row[16]));
e.override_zone_in = atoi(row[17]);
e.zone_in_x = static_cast<float>(atof(row[18]));
e.zone_in_y = static_cast<float>(atof(row[19]));
e.zone_in_z = static_cast<float>(atof(row[20]));
e.zone_in_h = static_cast<float>(atof(row[21]));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<DynamicZoneTemplates> GetWhere(Database& db, std::string where_filter)
static std::vector<DynamicZoneTemplates> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<DynamicZoneTemplates> all_entries;
@@ -445,38 +445,38 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
DynamicZoneTemplates entry{};
DynamicZoneTemplates e{};
entry.id = atoi(row[0]);
entry.zone_id = atoi(row[1]);
entry.zone_version = atoi(row[2]);
entry.name = row[3] ? row[3] : "";
entry.min_players = atoi(row[4]);
entry.max_players = atoi(row[5]);
entry.duration_seconds = atoi(row[6]);
entry.dz_switch_id = atoi(row[7]);
entry.compass_zone_id = atoi(row[8]);
entry.compass_x = static_cast<float>(atof(row[9]));
entry.compass_y = static_cast<float>(atof(row[10]));
entry.compass_z = static_cast<float>(atof(row[11]));
entry.return_zone_id = atoi(row[12]);
entry.return_x = static_cast<float>(atof(row[13]));
entry.return_y = static_cast<float>(atof(row[14]));
entry.return_z = static_cast<float>(atof(row[15]));
entry.return_h = static_cast<float>(atof(row[16]));
entry.override_zone_in = atoi(row[17]);
entry.zone_in_x = static_cast<float>(atof(row[18]));
entry.zone_in_y = static_cast<float>(atof(row[19]));
entry.zone_in_z = static_cast<float>(atof(row[20]));
entry.zone_in_h = static_cast<float>(atof(row[21]));
e.id = atoi(row[0]);
e.zone_id = atoi(row[1]);
e.zone_version = atoi(row[2]);
e.name = row[3] ? row[3] : "";
e.min_players = atoi(row[4]);
e.max_players = atoi(row[5]);
e.duration_seconds = atoi(row[6]);
e.dz_switch_id = atoi(row[7]);
e.compass_zone_id = atoi(row[8]);
e.compass_x = static_cast<float>(atof(row[9]));
e.compass_y = static_cast<float>(atof(row[10]));
e.compass_z = static_cast<float>(atof(row[11]));
e.return_zone_id = atoi(row[12]);
e.return_x = static_cast<float>(atof(row[13]));
e.return_y = static_cast<float>(atof(row[14]));
e.return_z = static_cast<float>(atof(row[15]));
e.return_h = static_cast<float>(atof(row[16]));
e.override_zone_in = atoi(row[17]);
e.zone_in_x = static_cast<float>(atof(row[18]));
e.zone_in_y = static_cast<float>(atof(row[19]));
e.zone_in_z = static_cast<float>(atof(row[20]));
e.zone_in_h = static_cast<float>(atof(row[21]));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -501,6 +501,32 @@ public:
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_DYNAMIC_ZONE_TEMPLATES_REPOSITORY_H
@@ -142,36 +142,36 @@ public:
static DynamicZones NewEntity()
{
DynamicZones entry{};
DynamicZones e{};
entry.id = 0;
entry.instance_id = 0;
entry.type = 0;
entry.uuid = "";
entry.name = "";
entry.leader_id = 0;
entry.min_players = 0;
entry.max_players = 0;
entry.dz_switch_id = 0;
entry.compass_zone_id = 0;
entry.compass_x = 0;
entry.compass_y = 0;
entry.compass_z = 0;
entry.safe_return_zone_id = 0;
entry.safe_return_x = 0;
entry.safe_return_y = 0;
entry.safe_return_z = 0;
entry.safe_return_heading = 0;
entry.zone_in_x = 0;
entry.zone_in_y = 0;
entry.zone_in_z = 0;
entry.zone_in_heading = 0;
entry.has_zone_in = 0;
e.id = 0;
e.instance_id = 0;
e.type = 0;
e.uuid = "";
e.name = "";
e.leader_id = 0;
e.min_players = 0;
e.max_players = 0;
e.dz_switch_id = 0;
e.compass_zone_id = 0;
e.compass_x = 0;
e.compass_y = 0;
e.compass_z = 0;
e.safe_return_zone_id = 0;
e.safe_return_x = 0;
e.safe_return_y = 0;
e.safe_return_z = 0;
e.safe_return_heading = 0;
e.zone_in_x = 0;
e.zone_in_y = 0;
e.zone_in_z = 0;
e.zone_in_heading = 0;
e.has_zone_in = 0;
return entry;
return e;
}
static DynamicZones GetDynamicZonesEntry(
static DynamicZones GetDynamicZones(
const std::vector<DynamicZones> &dynamic_zoness,
int dynamic_zones_id
)
@@ -200,33 +200,33 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
DynamicZones entry{};
DynamicZones e{};
entry.id = atoi(row[0]);
entry.instance_id = atoi(row[1]);
entry.type = atoi(row[2]);
entry.uuid = row[3] ? row[3] : "";
entry.name = row[4] ? row[4] : "";
entry.leader_id = atoi(row[5]);
entry.min_players = atoi(row[6]);
entry.max_players = atoi(row[7]);
entry.dz_switch_id = atoi(row[8]);
entry.compass_zone_id = atoi(row[9]);
entry.compass_x = static_cast<float>(atof(row[10]));
entry.compass_y = static_cast<float>(atof(row[11]));
entry.compass_z = static_cast<float>(atof(row[12]));
entry.safe_return_zone_id = atoi(row[13]);
entry.safe_return_x = static_cast<float>(atof(row[14]));
entry.safe_return_y = static_cast<float>(atof(row[15]));
entry.safe_return_z = static_cast<float>(atof(row[16]));
entry.safe_return_heading = static_cast<float>(atof(row[17]));
entry.zone_in_x = static_cast<float>(atof(row[18]));
entry.zone_in_y = static_cast<float>(atof(row[19]));
entry.zone_in_z = static_cast<float>(atof(row[20]));
entry.zone_in_heading = static_cast<float>(atof(row[21]));
entry.has_zone_in = atoi(row[22]);
e.id = atoi(row[0]);
e.instance_id = atoi(row[1]);
e.type = atoi(row[2]);
e.uuid = row[3] ? row[3] : "";
e.name = row[4] ? row[4] : "";
e.leader_id = atoi(row[5]);
e.min_players = atoi(row[6]);
e.max_players = atoi(row[7]);
e.dz_switch_id = atoi(row[8]);
e.compass_zone_id = atoi(row[9]);
e.compass_x = static_cast<float>(atof(row[10]));
e.compass_y = static_cast<float>(atof(row[11]));
e.compass_z = static_cast<float>(atof(row[12]));
e.safe_return_zone_id = atoi(row[13]);
e.safe_return_x = static_cast<float>(atof(row[14]));
e.safe_return_y = static_cast<float>(atof(row[15]));
e.safe_return_z = static_cast<float>(atof(row[16]));
e.safe_return_heading = static_cast<float>(atof(row[17]));
e.zone_in_x = static_cast<float>(atof(row[18]));
e.zone_in_y = static_cast<float>(atof(row[19]));
e.zone_in_z = static_cast<float>(atof(row[20]));
e.zone_in_heading = static_cast<float>(atof(row[21]));
e.has_zone_in = atoi(row[22]);
return entry;
return e;
}
return NewEntity();
@@ -251,43 +251,43 @@ public:
static int UpdateOne(
Database& db,
DynamicZones dynamic_zones_entry
const DynamicZones &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(dynamic_zones_entry.instance_id));
update_values.push_back(columns[2] + " = " + std::to_string(dynamic_zones_entry.type));
update_values.push_back(columns[3] + " = '" + Strings::Escape(dynamic_zones_entry.uuid) + "'");
update_values.push_back(columns[4] + " = '" + Strings::Escape(dynamic_zones_entry.name) + "'");
update_values.push_back(columns[5] + " = " + std::to_string(dynamic_zones_entry.leader_id));
update_values.push_back(columns[6] + " = " + std::to_string(dynamic_zones_entry.min_players));
update_values.push_back(columns[7] + " = " + std::to_string(dynamic_zones_entry.max_players));
update_values.push_back(columns[8] + " = " + std::to_string(dynamic_zones_entry.dz_switch_id));
update_values.push_back(columns[9] + " = " + std::to_string(dynamic_zones_entry.compass_zone_id));
update_values.push_back(columns[10] + " = " + std::to_string(dynamic_zones_entry.compass_x));
update_values.push_back(columns[11] + " = " + std::to_string(dynamic_zones_entry.compass_y));
update_values.push_back(columns[12] + " = " + std::to_string(dynamic_zones_entry.compass_z));
update_values.push_back(columns[13] + " = " + std::to_string(dynamic_zones_entry.safe_return_zone_id));
update_values.push_back(columns[14] + " = " + std::to_string(dynamic_zones_entry.safe_return_x));
update_values.push_back(columns[15] + " = " + std::to_string(dynamic_zones_entry.safe_return_y));
update_values.push_back(columns[16] + " = " + std::to_string(dynamic_zones_entry.safe_return_z));
update_values.push_back(columns[17] + " = " + std::to_string(dynamic_zones_entry.safe_return_heading));
update_values.push_back(columns[18] + " = " + std::to_string(dynamic_zones_entry.zone_in_x));
update_values.push_back(columns[19] + " = " + std::to_string(dynamic_zones_entry.zone_in_y));
update_values.push_back(columns[20] + " = " + std::to_string(dynamic_zones_entry.zone_in_z));
update_values.push_back(columns[21] + " = " + std::to_string(dynamic_zones_entry.zone_in_heading));
update_values.push_back(columns[22] + " = " + std::to_string(dynamic_zones_entry.has_zone_in));
v.push_back(columns[1] + " = " + std::to_string(e.instance_id));
v.push_back(columns[2] + " = " + std::to_string(e.type));
v.push_back(columns[3] + " = '" + Strings::Escape(e.uuid) + "'");
v.push_back(columns[4] + " = '" + Strings::Escape(e.name) + "'");
v.push_back(columns[5] + " = " + std::to_string(e.leader_id));
v.push_back(columns[6] + " = " + std::to_string(e.min_players));
v.push_back(columns[7] + " = " + std::to_string(e.max_players));
v.push_back(columns[8] + " = " + std::to_string(e.dz_switch_id));
v.push_back(columns[9] + " = " + std::to_string(e.compass_zone_id));
v.push_back(columns[10] + " = " + std::to_string(e.compass_x));
v.push_back(columns[11] + " = " + std::to_string(e.compass_y));
v.push_back(columns[12] + " = " + std::to_string(e.compass_z));
v.push_back(columns[13] + " = " + std::to_string(e.safe_return_zone_id));
v.push_back(columns[14] + " = " + std::to_string(e.safe_return_x));
v.push_back(columns[15] + " = " + std::to_string(e.safe_return_y));
v.push_back(columns[16] + " = " + std::to_string(e.safe_return_z));
v.push_back(columns[17] + " = " + std::to_string(e.safe_return_heading));
v.push_back(columns[18] + " = " + std::to_string(e.zone_in_x));
v.push_back(columns[19] + " = " + std::to_string(e.zone_in_y));
v.push_back(columns[20] + " = " + std::to_string(e.zone_in_z));
v.push_back(columns[21] + " = " + std::to_string(e.zone_in_heading));
v.push_back(columns[22] + " = " + std::to_string(e.has_zone_in));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
dynamic_zones_entry.id
e.id
)
);
@@ -296,91 +296,91 @@ public:
static DynamicZones InsertOne(
Database& db,
DynamicZones dynamic_zones_entry
DynamicZones e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(dynamic_zones_entry.id));
insert_values.push_back(std::to_string(dynamic_zones_entry.instance_id));
insert_values.push_back(std::to_string(dynamic_zones_entry.type));
insert_values.push_back("'" + Strings::Escape(dynamic_zones_entry.uuid) + "'");
insert_values.push_back("'" + Strings::Escape(dynamic_zones_entry.name) + "'");
insert_values.push_back(std::to_string(dynamic_zones_entry.leader_id));
insert_values.push_back(std::to_string(dynamic_zones_entry.min_players));
insert_values.push_back(std::to_string(dynamic_zones_entry.max_players));
insert_values.push_back(std::to_string(dynamic_zones_entry.dz_switch_id));
insert_values.push_back(std::to_string(dynamic_zones_entry.compass_zone_id));
insert_values.push_back(std::to_string(dynamic_zones_entry.compass_x));
insert_values.push_back(std::to_string(dynamic_zones_entry.compass_y));
insert_values.push_back(std::to_string(dynamic_zones_entry.compass_z));
insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_zone_id));
insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_x));
insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_y));
insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_z));
insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_heading));
insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_x));
insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_y));
insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_z));
insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_heading));
insert_values.push_back(std::to_string(dynamic_zones_entry.has_zone_in));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.instance_id));
v.push_back(std::to_string(e.type));
v.push_back("'" + Strings::Escape(e.uuid) + "'");
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back(std::to_string(e.leader_id));
v.push_back(std::to_string(e.min_players));
v.push_back(std::to_string(e.max_players));
v.push_back(std::to_string(e.dz_switch_id));
v.push_back(std::to_string(e.compass_zone_id));
v.push_back(std::to_string(e.compass_x));
v.push_back(std::to_string(e.compass_y));
v.push_back(std::to_string(e.compass_z));
v.push_back(std::to_string(e.safe_return_zone_id));
v.push_back(std::to_string(e.safe_return_x));
v.push_back(std::to_string(e.safe_return_y));
v.push_back(std::to_string(e.safe_return_z));
v.push_back(std::to_string(e.safe_return_heading));
v.push_back(std::to_string(e.zone_in_x));
v.push_back(std::to_string(e.zone_in_y));
v.push_back(std::to_string(e.zone_in_z));
v.push_back(std::to_string(e.zone_in_heading));
v.push_back(std::to_string(e.has_zone_in));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
dynamic_zones_entry.id = results.LastInsertedID();
return dynamic_zones_entry;
e.id = results.LastInsertedID();
return e;
}
dynamic_zones_entry = NewEntity();
e = NewEntity();
return dynamic_zones_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<DynamicZones> dynamic_zones_entries
const std::vector<DynamicZones> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &dynamic_zones_entry: dynamic_zones_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(dynamic_zones_entry.id));
insert_values.push_back(std::to_string(dynamic_zones_entry.instance_id));
insert_values.push_back(std::to_string(dynamic_zones_entry.type));
insert_values.push_back("'" + Strings::Escape(dynamic_zones_entry.uuid) + "'");
insert_values.push_back("'" + Strings::Escape(dynamic_zones_entry.name) + "'");
insert_values.push_back(std::to_string(dynamic_zones_entry.leader_id));
insert_values.push_back(std::to_string(dynamic_zones_entry.min_players));
insert_values.push_back(std::to_string(dynamic_zones_entry.max_players));
insert_values.push_back(std::to_string(dynamic_zones_entry.dz_switch_id));
insert_values.push_back(std::to_string(dynamic_zones_entry.compass_zone_id));
insert_values.push_back(std::to_string(dynamic_zones_entry.compass_x));
insert_values.push_back(std::to_string(dynamic_zones_entry.compass_y));
insert_values.push_back(std::to_string(dynamic_zones_entry.compass_z));
insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_zone_id));
insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_x));
insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_y));
insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_z));
insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_heading));
insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_x));
insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_y));
insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_z));
insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_heading));
insert_values.push_back(std::to_string(dynamic_zones_entry.has_zone_in));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.instance_id));
v.push_back(std::to_string(e.type));
v.push_back("'" + Strings::Escape(e.uuid) + "'");
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back(std::to_string(e.leader_id));
v.push_back(std::to_string(e.min_players));
v.push_back(std::to_string(e.max_players));
v.push_back(std::to_string(e.dz_switch_id));
v.push_back(std::to_string(e.compass_zone_id));
v.push_back(std::to_string(e.compass_x));
v.push_back(std::to_string(e.compass_y));
v.push_back(std::to_string(e.compass_z));
v.push_back(std::to_string(e.safe_return_zone_id));
v.push_back(std::to_string(e.safe_return_x));
v.push_back(std::to_string(e.safe_return_y));
v.push_back(std::to_string(e.safe_return_z));
v.push_back(std::to_string(e.safe_return_heading));
v.push_back(std::to_string(e.zone_in_x));
v.push_back(std::to_string(e.zone_in_y));
v.push_back(std::to_string(e.zone_in_z));
v.push_back(std::to_string(e.zone_in_heading));
v.push_back(std::to_string(e.has_zone_in));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -407,39 +407,39 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
DynamicZones entry{};
DynamicZones e{};
entry.id = atoi(row[0]);
entry.instance_id = atoi(row[1]);
entry.type = atoi(row[2]);
entry.uuid = row[3] ? row[3] : "";
entry.name = row[4] ? row[4] : "";
entry.leader_id = atoi(row[5]);
entry.min_players = atoi(row[6]);
entry.max_players = atoi(row[7]);
entry.dz_switch_id = atoi(row[8]);
entry.compass_zone_id = atoi(row[9]);
entry.compass_x = static_cast<float>(atof(row[10]));
entry.compass_y = static_cast<float>(atof(row[11]));
entry.compass_z = static_cast<float>(atof(row[12]));
entry.safe_return_zone_id = atoi(row[13]);
entry.safe_return_x = static_cast<float>(atof(row[14]));
entry.safe_return_y = static_cast<float>(atof(row[15]));
entry.safe_return_z = static_cast<float>(atof(row[16]));
entry.safe_return_heading = static_cast<float>(atof(row[17]));
entry.zone_in_x = static_cast<float>(atof(row[18]));
entry.zone_in_y = static_cast<float>(atof(row[19]));
entry.zone_in_z = static_cast<float>(atof(row[20]));
entry.zone_in_heading = static_cast<float>(atof(row[21]));
entry.has_zone_in = atoi(row[22]);
e.id = atoi(row[0]);
e.instance_id = atoi(row[1]);
e.type = atoi(row[2]);
e.uuid = row[3] ? row[3] : "";
e.name = row[4] ? row[4] : "";
e.leader_id = atoi(row[5]);
e.min_players = atoi(row[6]);
e.max_players = atoi(row[7]);
e.dz_switch_id = atoi(row[8]);
e.compass_zone_id = atoi(row[9]);
e.compass_x = static_cast<float>(atof(row[10]));
e.compass_y = static_cast<float>(atof(row[11]));
e.compass_z = static_cast<float>(atof(row[12]));
e.safe_return_zone_id = atoi(row[13]);
e.safe_return_x = static_cast<float>(atof(row[14]));
e.safe_return_y = static_cast<float>(atof(row[15]));
e.safe_return_z = static_cast<float>(atof(row[16]));
e.safe_return_heading = static_cast<float>(atof(row[17]));
e.zone_in_x = static_cast<float>(atof(row[18]));
e.zone_in_y = static_cast<float>(atof(row[19]));
e.zone_in_z = static_cast<float>(atof(row[20]));
e.zone_in_heading = static_cast<float>(atof(row[21]));
e.has_zone_in = atoi(row[22]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<DynamicZones> GetWhere(Database& db, std::string where_filter)
static std::vector<DynamicZones> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<DynamicZones> all_entries;
@@ -454,39 +454,39 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
DynamicZones entry{};
DynamicZones e{};
entry.id = atoi(row[0]);
entry.instance_id = atoi(row[1]);
entry.type = atoi(row[2]);
entry.uuid = row[3] ? row[3] : "";
entry.name = row[4] ? row[4] : "";
entry.leader_id = atoi(row[5]);
entry.min_players = atoi(row[6]);
entry.max_players = atoi(row[7]);
entry.dz_switch_id = atoi(row[8]);
entry.compass_zone_id = atoi(row[9]);
entry.compass_x = static_cast<float>(atof(row[10]));
entry.compass_y = static_cast<float>(atof(row[11]));
entry.compass_z = static_cast<float>(atof(row[12]));
entry.safe_return_zone_id = atoi(row[13]);
entry.safe_return_x = static_cast<float>(atof(row[14]));
entry.safe_return_y = static_cast<float>(atof(row[15]));
entry.safe_return_z = static_cast<float>(atof(row[16]));
entry.safe_return_heading = static_cast<float>(atof(row[17]));
entry.zone_in_x = static_cast<float>(atof(row[18]));
entry.zone_in_y = static_cast<float>(atof(row[19]));
entry.zone_in_z = static_cast<float>(atof(row[20]));
entry.zone_in_heading = static_cast<float>(atof(row[21]));
entry.has_zone_in = atoi(row[22]);
e.id = atoi(row[0]);
e.instance_id = atoi(row[1]);
e.type = atoi(row[2]);
e.uuid = row[3] ? row[3] : "";
e.name = row[4] ? row[4] : "";
e.leader_id = atoi(row[5]);
e.min_players = atoi(row[6]);
e.max_players = atoi(row[7]);
e.dz_switch_id = atoi(row[8]);
e.compass_zone_id = atoi(row[9]);
e.compass_x = static_cast<float>(atof(row[10]));
e.compass_y = static_cast<float>(atof(row[11]));
e.compass_z = static_cast<float>(atof(row[12]));
e.safe_return_zone_id = atoi(row[13]);
e.safe_return_x = static_cast<float>(atof(row[14]));
e.safe_return_y = static_cast<float>(atof(row[15]));
e.safe_return_z = static_cast<float>(atof(row[16]));
e.safe_return_heading = static_cast<float>(atof(row[17]));
e.zone_in_x = static_cast<float>(atof(row[18]));
e.zone_in_y = static_cast<float>(atof(row[19]));
e.zone_in_z = static_cast<float>(atof(row[20]));
e.zone_in_heading = static_cast<float>(atof(row[21]));
e.has_zone_in = atoi(row[22]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -511,6 +511,32 @@ public:
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_DYNAMIC_ZONES_REPOSITORY_H
@@ -103,23 +103,23 @@ public:
static Eventlog NewEntity()
{
Eventlog entry{};
Eventlog e{};
entry.id = 0;
entry.accountname = "";
entry.accountid = 0;
entry.status = 0;
entry.charname = "";
entry.target = "None";
entry.time = std::time(nullptr);
entry.descriptiontype = "";
entry.description = "";
entry.event_nid = 0;
e.id = 0;
e.accountname = "";
e.accountid = 0;
e.status = 0;
e.charname = "";
e.target = "None";
e.time = std::time(nullptr);
e.descriptiontype = "";
e.description = "";
e.event_nid = 0;
return entry;
return e;
}
static Eventlog GetEventlogEntry(
static Eventlog GetEventlog(
const std::vector<Eventlog> &eventlogs,
int eventlog_id
)
@@ -148,20 +148,20 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
Eventlog entry{};
Eventlog e{};
entry.id = atoi(row[0]);
entry.accountname = row[1] ? row[1] : "";
entry.accountid = atoi(row[2]);
entry.status = atoi(row[3]);
entry.charname = row[4] ? row[4] : "";
entry.target = row[5] ? row[5] : "";
entry.time = row[6] ? row[6] : "";
entry.descriptiontype = row[7] ? row[7] : "";
entry.description = row[8] ? row[8] : "";
entry.event_nid = atoi(row[9]);
e.id = atoi(row[0]);
e.accountname = row[1] ? row[1] : "";
e.accountid = atoi(row[2]);
e.status = atoi(row[3]);
e.charname = row[4] ? row[4] : "";
e.target = row[5] ? row[5] : "";
e.time = row[6] ? row[6] : "";
e.descriptiontype = row[7] ? row[7] : "";
e.description = row[8] ? row[8] : "";
e.event_nid = atoi(row[9]);
return entry;
return e;
}
return NewEntity();
@@ -186,30 +186,30 @@ public:
static int UpdateOne(
Database& db,
Eventlog eventlog_entry
const Eventlog &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + Strings::Escape(eventlog_entry.accountname) + "'");
update_values.push_back(columns[2] + " = " + std::to_string(eventlog_entry.accountid));
update_values.push_back(columns[3] + " = " + std::to_string(eventlog_entry.status));
update_values.push_back(columns[4] + " = '" + Strings::Escape(eventlog_entry.charname) + "'");
update_values.push_back(columns[5] + " = '" + Strings::Escape(eventlog_entry.target) + "'");
update_values.push_back(columns[6] + " = '" + Strings::Escape(eventlog_entry.time) + "'");
update_values.push_back(columns[7] + " = '" + Strings::Escape(eventlog_entry.descriptiontype) + "'");
update_values.push_back(columns[8] + " = '" + Strings::Escape(eventlog_entry.description) + "'");
update_values.push_back(columns[9] + " = " + std::to_string(eventlog_entry.event_nid));
v.push_back(columns[1] + " = '" + Strings::Escape(e.accountname) + "'");
v.push_back(columns[2] + " = " + std::to_string(e.accountid));
v.push_back(columns[3] + " = " + std::to_string(e.status));
v.push_back(columns[4] + " = '" + Strings::Escape(e.charname) + "'");
v.push_back(columns[5] + " = '" + Strings::Escape(e.target) + "'");
v.push_back(columns[6] + " = '" + Strings::Escape(e.time) + "'");
v.push_back(columns[7] + " = '" + Strings::Escape(e.descriptiontype) + "'");
v.push_back(columns[8] + " = '" + Strings::Escape(e.description) + "'");
v.push_back(columns[9] + " = " + std::to_string(e.event_nid));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
eventlog_entry.id
e.id
)
);
@@ -218,65 +218,65 @@ public:
static Eventlog InsertOne(
Database& db,
Eventlog eventlog_entry
Eventlog e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(eventlog_entry.id));
insert_values.push_back("'" + Strings::Escape(eventlog_entry.accountname) + "'");
insert_values.push_back(std::to_string(eventlog_entry.accountid));
insert_values.push_back(std::to_string(eventlog_entry.status));
insert_values.push_back("'" + Strings::Escape(eventlog_entry.charname) + "'");
insert_values.push_back("'" + Strings::Escape(eventlog_entry.target) + "'");
insert_values.push_back("'" + Strings::Escape(eventlog_entry.time) + "'");
insert_values.push_back("'" + Strings::Escape(eventlog_entry.descriptiontype) + "'");
insert_values.push_back("'" + Strings::Escape(eventlog_entry.description) + "'");
insert_values.push_back(std::to_string(eventlog_entry.event_nid));
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.accountname) + "'");
v.push_back(std::to_string(e.accountid));
v.push_back(std::to_string(e.status));
v.push_back("'" + Strings::Escape(e.charname) + "'");
v.push_back("'" + Strings::Escape(e.target) + "'");
v.push_back("'" + Strings::Escape(e.time) + "'");
v.push_back("'" + Strings::Escape(e.descriptiontype) + "'");
v.push_back("'" + Strings::Escape(e.description) + "'");
v.push_back(std::to_string(e.event_nid));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
eventlog_entry.id = results.LastInsertedID();
return eventlog_entry;
e.id = results.LastInsertedID();
return e;
}
eventlog_entry = NewEntity();
e = NewEntity();
return eventlog_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<Eventlog> eventlog_entries
const std::vector<Eventlog> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &eventlog_entry: eventlog_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(eventlog_entry.id));
insert_values.push_back("'" + Strings::Escape(eventlog_entry.accountname) + "'");
insert_values.push_back(std::to_string(eventlog_entry.accountid));
insert_values.push_back(std::to_string(eventlog_entry.status));
insert_values.push_back("'" + Strings::Escape(eventlog_entry.charname) + "'");
insert_values.push_back("'" + Strings::Escape(eventlog_entry.target) + "'");
insert_values.push_back("'" + Strings::Escape(eventlog_entry.time) + "'");
insert_values.push_back("'" + Strings::Escape(eventlog_entry.descriptiontype) + "'");
insert_values.push_back("'" + Strings::Escape(eventlog_entry.description) + "'");
insert_values.push_back(std::to_string(eventlog_entry.event_nid));
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.accountname) + "'");
v.push_back(std::to_string(e.accountid));
v.push_back(std::to_string(e.status));
v.push_back("'" + Strings::Escape(e.charname) + "'");
v.push_back("'" + Strings::Escape(e.target) + "'");
v.push_back("'" + Strings::Escape(e.time) + "'");
v.push_back("'" + Strings::Escape(e.descriptiontype) + "'");
v.push_back("'" + Strings::Escape(e.description) + "'");
v.push_back(std::to_string(e.event_nid));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -303,26 +303,26 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Eventlog entry{};
Eventlog e{};
entry.id = atoi(row[0]);
entry.accountname = row[1] ? row[1] : "";
entry.accountid = atoi(row[2]);
entry.status = atoi(row[3]);
entry.charname = row[4] ? row[4] : "";
entry.target = row[5] ? row[5] : "";
entry.time = row[6] ? row[6] : "";
entry.descriptiontype = row[7] ? row[7] : "";
entry.description = row[8] ? row[8] : "";
entry.event_nid = atoi(row[9]);
e.id = atoi(row[0]);
e.accountname = row[1] ? row[1] : "";
e.accountid = atoi(row[2]);
e.status = atoi(row[3]);
e.charname = row[4] ? row[4] : "";
e.target = row[5] ? row[5] : "";
e.time = row[6] ? row[6] : "";
e.descriptiontype = row[7] ? row[7] : "";
e.description = row[8] ? row[8] : "";
e.event_nid = atoi(row[9]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<Eventlog> GetWhere(Database& db, std::string where_filter)
static std::vector<Eventlog> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<Eventlog> all_entries;
@@ -337,26 +337,26 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Eventlog entry{};
Eventlog e{};
entry.id = atoi(row[0]);
entry.accountname = row[1] ? row[1] : "";
entry.accountid = atoi(row[2]);
entry.status = atoi(row[3]);
entry.charname = row[4] ? row[4] : "";
entry.target = row[5] ? row[5] : "";
entry.time = row[6] ? row[6] : "";
entry.descriptiontype = row[7] ? row[7] : "";
entry.description = row[8] ? row[8] : "";
entry.event_nid = atoi(row[9]);
e.id = atoi(row[0]);
e.accountname = row[1] ? row[1] : "";
e.accountid = atoi(row[2]);
e.status = atoi(row[3]);
e.charname = row[4] ? row[4] : "";
e.target = row[5] ? row[5] : "";
e.time = row[6] ? row[6] : "";
e.descriptiontype = row[7] ? row[7] : "";
e.description = row[8] ? row[8] : "";
e.event_nid = atoi(row[9]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -381,6 +381,32 @@ public:
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_EVENTLOG_REPOSITORY_H
@@ -91,19 +91,19 @@ public:
static ExpeditionLockouts NewEntity()
{
ExpeditionLockouts entry{};
ExpeditionLockouts e{};
entry.id = 0;
entry.expedition_id = 0;
entry.event_name = "";
entry.expire_time = std::time(nullptr);
entry.duration = 0;
entry.from_expedition_uuid = "";
e.id = 0;
e.expedition_id = 0;
e.event_name = "";
e.expire_time = std::time(nullptr);
e.duration = 0;
e.from_expedition_uuid = "";
return entry;
return e;
}
static ExpeditionLockouts GetExpeditionLockoutsEntry(
static ExpeditionLockouts GetExpeditionLockouts(
const std::vector<ExpeditionLockouts> &expedition_lockoutss,
int expedition_lockouts_id
)
@@ -132,16 +132,16 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
ExpeditionLockouts entry{};
ExpeditionLockouts e{};
entry.id = atoi(row[0]);
entry.expedition_id = atoi(row[1]);
entry.event_name = row[2] ? row[2] : "";
entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
entry.duration = atoi(row[4]);
entry.from_expedition_uuid = row[5] ? row[5] : "";
e.id = atoi(row[0]);
e.expedition_id = atoi(row[1]);
e.event_name = row[2] ? row[2] : "";
e.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
e.duration = atoi(row[4]);
e.from_expedition_uuid = row[5] ? row[5] : "";
return entry;
return e;
}
return NewEntity();
@@ -166,26 +166,26 @@ public:
static int UpdateOne(
Database& db,
ExpeditionLockouts expedition_lockouts_entry
const ExpeditionLockouts &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(expedition_lockouts_entry.expedition_id));
update_values.push_back(columns[2] + " = '" + Strings::Escape(expedition_lockouts_entry.event_name) + "'");
update_values.push_back(columns[3] + " = FROM_UNIXTIME(" + (expedition_lockouts_entry.expire_time > 0 ? std::to_string(expedition_lockouts_entry.expire_time) : "null") + ")");
update_values.push_back(columns[4] + " = " + std::to_string(expedition_lockouts_entry.duration));
update_values.push_back(columns[5] + " = '" + Strings::Escape(expedition_lockouts_entry.from_expedition_uuid) + "'");
v.push_back(columns[1] + " = " + std::to_string(e.expedition_id));
v.push_back(columns[2] + " = '" + Strings::Escape(e.event_name) + "'");
v.push_back(columns[3] + " = FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")");
v.push_back(columns[4] + " = " + std::to_string(e.duration));
v.push_back(columns[5] + " = '" + Strings::Escape(e.from_expedition_uuid) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
expedition_lockouts_entry.id
e.id
)
);
@@ -194,57 +194,57 @@ public:
static ExpeditionLockouts InsertOne(
Database& db,
ExpeditionLockouts expedition_lockouts_entry
ExpeditionLockouts e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(expedition_lockouts_entry.id));
insert_values.push_back(std::to_string(expedition_lockouts_entry.expedition_id));
insert_values.push_back("'" + Strings::Escape(expedition_lockouts_entry.event_name) + "'");
insert_values.push_back("FROM_UNIXTIME(" + (expedition_lockouts_entry.expire_time > 0 ? std::to_string(expedition_lockouts_entry.expire_time) : "null") + ")");
insert_values.push_back(std::to_string(expedition_lockouts_entry.duration));
insert_values.push_back("'" + Strings::Escape(expedition_lockouts_entry.from_expedition_uuid) + "'");
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.expedition_id));
v.push_back("'" + Strings::Escape(e.event_name) + "'");
v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")");
v.push_back(std::to_string(e.duration));
v.push_back("'" + Strings::Escape(e.from_expedition_uuid) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
expedition_lockouts_entry.id = results.LastInsertedID();
return expedition_lockouts_entry;
e.id = results.LastInsertedID();
return e;
}
expedition_lockouts_entry = NewEntity();
e = NewEntity();
return expedition_lockouts_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<ExpeditionLockouts> expedition_lockouts_entries
const std::vector<ExpeditionLockouts> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &expedition_lockouts_entry: expedition_lockouts_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(expedition_lockouts_entry.id));
insert_values.push_back(std::to_string(expedition_lockouts_entry.expedition_id));
insert_values.push_back("'" + Strings::Escape(expedition_lockouts_entry.event_name) + "'");
insert_values.push_back("FROM_UNIXTIME(" + (expedition_lockouts_entry.expire_time > 0 ? std::to_string(expedition_lockouts_entry.expire_time) : "null") + ")");
insert_values.push_back(std::to_string(expedition_lockouts_entry.duration));
insert_values.push_back("'" + Strings::Escape(expedition_lockouts_entry.from_expedition_uuid) + "'");
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.expedition_id));
v.push_back("'" + Strings::Escape(e.event_name) + "'");
v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")");
v.push_back(std::to_string(e.duration));
v.push_back("'" + Strings::Escape(e.from_expedition_uuid) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -271,22 +271,22 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
ExpeditionLockouts entry{};
ExpeditionLockouts e{};
entry.id = atoi(row[0]);
entry.expedition_id = atoi(row[1]);
entry.event_name = row[2] ? row[2] : "";
entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
entry.duration = atoi(row[4]);
entry.from_expedition_uuid = row[5] ? row[5] : "";
e.id = atoi(row[0]);
e.expedition_id = atoi(row[1]);
e.event_name = row[2] ? row[2] : "";
e.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
e.duration = atoi(row[4]);
e.from_expedition_uuid = row[5] ? row[5] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<ExpeditionLockouts> GetWhere(Database& db, std::string where_filter)
static std::vector<ExpeditionLockouts> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<ExpeditionLockouts> all_entries;
@@ -301,22 +301,22 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
ExpeditionLockouts entry{};
ExpeditionLockouts e{};
entry.id = atoi(row[0]);
entry.expedition_id = atoi(row[1]);
entry.event_name = row[2] ? row[2] : "";
entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
entry.duration = atoi(row[4]);
entry.from_expedition_uuid = row[5] ? row[5] : "";
e.id = atoi(row[0]);
e.expedition_id = atoi(row[1]);
e.event_name = row[2] ? row[2] : "";
e.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
e.duration = atoi(row[4]);
e.from_expedition_uuid = row[5] ? row[5] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -341,6 +341,32 @@ public:
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_EXPEDITION_LOCKOUTS_REPOSITORY_H
@@ -85,17 +85,17 @@ public:
static Expeditions NewEntity()
{
Expeditions entry{};
Expeditions e{};
entry.id = 0;
entry.dynamic_zone_id = 0;
entry.add_replay_on_join = 1;
entry.is_locked = 0;
e.id = 0;
e.dynamic_zone_id = 0;
e.add_replay_on_join = 1;
e.is_locked = 0;
return entry;
return e;
}
static Expeditions GetExpeditionsEntry(
static Expeditions GetExpeditions(
const std::vector<Expeditions> &expeditionss,
int expeditions_id
)
@@ -124,14 +124,14 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
Expeditions entry{};
Expeditions e{};
entry.id = atoi(row[0]);
entry.dynamic_zone_id = atoi(row[1]);
entry.add_replay_on_join = atoi(row[2]);
entry.is_locked = atoi(row[3]);
e.id = atoi(row[0]);
e.dynamic_zone_id = atoi(row[1]);
e.add_replay_on_join = atoi(row[2]);
e.is_locked = atoi(row[3]);
return entry;
return e;
}
return NewEntity();
@@ -156,24 +156,24 @@ public:
static int UpdateOne(
Database& db,
Expeditions expeditions_entry
const Expeditions &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(expeditions_entry.dynamic_zone_id));
update_values.push_back(columns[2] + " = " + std::to_string(expeditions_entry.add_replay_on_join));
update_values.push_back(columns[3] + " = " + std::to_string(expeditions_entry.is_locked));
v.push_back(columns[1] + " = " + std::to_string(e.dynamic_zone_id));
v.push_back(columns[2] + " = " + std::to_string(e.add_replay_on_join));
v.push_back(columns[3] + " = " + std::to_string(e.is_locked));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
expeditions_entry.id
e.id
)
);
@@ -182,53 +182,53 @@ public:
static Expeditions InsertOne(
Database& db,
Expeditions expeditions_entry
Expeditions e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(expeditions_entry.id));
insert_values.push_back(std::to_string(expeditions_entry.dynamic_zone_id));
insert_values.push_back(std::to_string(expeditions_entry.add_replay_on_join));
insert_values.push_back(std::to_string(expeditions_entry.is_locked));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.dynamic_zone_id));
v.push_back(std::to_string(e.add_replay_on_join));
v.push_back(std::to_string(e.is_locked));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
expeditions_entry.id = results.LastInsertedID();
return expeditions_entry;
e.id = results.LastInsertedID();
return e;
}
expeditions_entry = NewEntity();
e = NewEntity();
return expeditions_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<Expeditions> expeditions_entries
const std::vector<Expeditions> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &expeditions_entry: expeditions_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(expeditions_entry.id));
insert_values.push_back(std::to_string(expeditions_entry.dynamic_zone_id));
insert_values.push_back(std::to_string(expeditions_entry.add_replay_on_join));
insert_values.push_back(std::to_string(expeditions_entry.is_locked));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.dynamic_zone_id));
v.push_back(std::to_string(e.add_replay_on_join));
v.push_back(std::to_string(e.is_locked));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -255,20 +255,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Expeditions entry{};
Expeditions e{};
entry.id = atoi(row[0]);
entry.dynamic_zone_id = atoi(row[1]);
entry.add_replay_on_join = atoi(row[2]);
entry.is_locked = atoi(row[3]);
e.id = atoi(row[0]);
e.dynamic_zone_id = atoi(row[1]);
e.add_replay_on_join = atoi(row[2]);
e.is_locked = atoi(row[3]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<Expeditions> GetWhere(Database& db, std::string where_filter)
static std::vector<Expeditions> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<Expeditions> all_entries;
@@ -283,20 +283,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Expeditions entry{};
Expeditions e{};
entry.id = atoi(row[0]);
entry.dynamic_zone_id = atoi(row[1]);
entry.add_replay_on_join = atoi(row[2]);
entry.is_locked = atoi(row[3]);
e.id = atoi(row[0]);
e.dynamic_zone_id = atoi(row[1]);
e.add_replay_on_join = atoi(row[2]);
e.is_locked = atoi(row[3]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -321,6 +321,32 @@ public:
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_EXPEDITIONS_REPOSITORY_H
@@ -91,19 +91,19 @@ public:
static FactionBaseData NewEntity()
{
FactionBaseData entry{};
FactionBaseData e{};
entry.client_faction_id = 0;
entry.min = -2000;
entry.max = 2000;
entry.unk_hero1 = 0;
entry.unk_hero2 = 0;
entry.unk_hero3 = 0;
e.client_faction_id = 0;
e.min = -2000;
e.max = 2000;
e.unk_hero1 = 0;
e.unk_hero2 = 0;
e.unk_hero3 = 0;
return entry;
return e;
}
static FactionBaseData GetFactionBaseDataEntry(
static FactionBaseData GetFactionBaseData(
const std::vector<FactionBaseData> &faction_base_datas,
int faction_base_data_id
)
@@ -132,16 +132,16 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
FactionBaseData entry{};
FactionBaseData e{};
entry.client_faction_id = atoi(row[0]);
entry.min = atoi(row[1]);
entry.max = atoi(row[2]);
entry.unk_hero1 = atoi(row[3]);
entry.unk_hero2 = atoi(row[4]);
entry.unk_hero3 = atoi(row[5]);
e.client_faction_id = atoi(row[0]);
e.min = atoi(row[1]);
e.max = atoi(row[2]);
e.unk_hero1 = atoi(row[3]);
e.unk_hero2 = atoi(row[4]);
e.unk_hero3 = atoi(row[5]);
return entry;
return e;
}
return NewEntity();
@@ -166,27 +166,27 @@ public:
static int UpdateOne(
Database& db,
FactionBaseData faction_base_data_entry
const FactionBaseData &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(faction_base_data_entry.client_faction_id));
update_values.push_back(columns[1] + " = " + std::to_string(faction_base_data_entry.min));
update_values.push_back(columns[2] + " = " + std::to_string(faction_base_data_entry.max));
update_values.push_back(columns[3] + " = " + std::to_string(faction_base_data_entry.unk_hero1));
update_values.push_back(columns[4] + " = " + std::to_string(faction_base_data_entry.unk_hero2));
update_values.push_back(columns[5] + " = " + std::to_string(faction_base_data_entry.unk_hero3));
v.push_back(columns[0] + " = " + std::to_string(e.client_faction_id));
v.push_back(columns[1] + " = " + std::to_string(e.min));
v.push_back(columns[2] + " = " + std::to_string(e.max));
v.push_back(columns[3] + " = " + std::to_string(e.unk_hero1));
v.push_back(columns[4] + " = " + std::to_string(e.unk_hero2));
v.push_back(columns[5] + " = " + std::to_string(e.unk_hero3));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
faction_base_data_entry.client_faction_id
e.client_faction_id
)
);
@@ -195,57 +195,57 @@ public:
static FactionBaseData InsertOne(
Database& db,
FactionBaseData faction_base_data_entry
FactionBaseData e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(faction_base_data_entry.client_faction_id));
insert_values.push_back(std::to_string(faction_base_data_entry.min));
insert_values.push_back(std::to_string(faction_base_data_entry.max));
insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero1));
insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero2));
insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero3));
v.push_back(std::to_string(e.client_faction_id));
v.push_back(std::to_string(e.min));
v.push_back(std::to_string(e.max));
v.push_back(std::to_string(e.unk_hero1));
v.push_back(std::to_string(e.unk_hero2));
v.push_back(std::to_string(e.unk_hero3));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
faction_base_data_entry.client_faction_id = results.LastInsertedID();
return faction_base_data_entry;
e.client_faction_id = results.LastInsertedID();
return e;
}
faction_base_data_entry = NewEntity();
e = NewEntity();
return faction_base_data_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<FactionBaseData> faction_base_data_entries
const std::vector<FactionBaseData> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &faction_base_data_entry: faction_base_data_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(faction_base_data_entry.client_faction_id));
insert_values.push_back(std::to_string(faction_base_data_entry.min));
insert_values.push_back(std::to_string(faction_base_data_entry.max));
insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero1));
insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero2));
insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero3));
v.push_back(std::to_string(e.client_faction_id));
v.push_back(std::to_string(e.min));
v.push_back(std::to_string(e.max));
v.push_back(std::to_string(e.unk_hero1));
v.push_back(std::to_string(e.unk_hero2));
v.push_back(std::to_string(e.unk_hero3));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -272,22 +272,22 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
FactionBaseData entry{};
FactionBaseData e{};
entry.client_faction_id = atoi(row[0]);
entry.min = atoi(row[1]);
entry.max = atoi(row[2]);
entry.unk_hero1 = atoi(row[3]);
entry.unk_hero2 = atoi(row[4]);
entry.unk_hero3 = atoi(row[5]);
e.client_faction_id = atoi(row[0]);
e.min = atoi(row[1]);
e.max = atoi(row[2]);
e.unk_hero1 = atoi(row[3]);
e.unk_hero2 = atoi(row[4]);
e.unk_hero3 = atoi(row[5]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<FactionBaseData> GetWhere(Database& db, std::string where_filter)
static std::vector<FactionBaseData> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<FactionBaseData> all_entries;
@@ -302,22 +302,22 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
FactionBaseData entry{};
FactionBaseData e{};
entry.client_faction_id = atoi(row[0]);
entry.min = atoi(row[1]);
entry.max = atoi(row[2]);
entry.unk_hero1 = atoi(row[3]);
entry.unk_hero2 = atoi(row[4]);
entry.unk_hero3 = atoi(row[5]);
e.client_faction_id = atoi(row[0]);
e.min = atoi(row[1]);
e.max = atoi(row[2]);
e.unk_hero1 = atoi(row[3]);
e.unk_hero2 = atoi(row[4]);
e.unk_hero3 = atoi(row[5]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -342,6 +342,32 @@ public:
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_FACTION_BASE_DATA_REPOSITORY_H
@@ -85,17 +85,17 @@ public:
static FactionListMod NewEntity()
{
FactionListMod entry{};
FactionListMod e{};
entry.id = 0;
entry.faction_id = 0;
entry.mod = 0;
entry.mod_name = "";
e.id = 0;
e.faction_id = 0;
e.mod = 0;
e.mod_name = "";
return entry;
return e;
}
static FactionListMod GetFactionListModEntry(
static FactionListMod GetFactionListMod(
const std::vector<FactionListMod> &faction_list_mods,
int faction_list_mod_id
)
@@ -124,14 +124,14 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
FactionListMod entry{};
FactionListMod e{};
entry.id = atoi(row[0]);
entry.faction_id = atoi(row[1]);
entry.mod = atoi(row[2]);
entry.mod_name = row[3] ? row[3] : "";
e.id = atoi(row[0]);
e.faction_id = atoi(row[1]);
e.mod = atoi(row[2]);
e.mod_name = row[3] ? row[3] : "";
return entry;
return e;
}
return NewEntity();
@@ -156,24 +156,24 @@ public:
static int UpdateOne(
Database& db,
FactionListMod faction_list_mod_entry
const FactionListMod &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(faction_list_mod_entry.faction_id));
update_values.push_back(columns[2] + " = " + std::to_string(faction_list_mod_entry.mod));
update_values.push_back(columns[3] + " = '" + Strings::Escape(faction_list_mod_entry.mod_name) + "'");
v.push_back(columns[1] + " = " + std::to_string(e.faction_id));
v.push_back(columns[2] + " = " + std::to_string(e.mod));
v.push_back(columns[3] + " = '" + Strings::Escape(e.mod_name) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
faction_list_mod_entry.id
e.id
)
);
@@ -182,53 +182,53 @@ public:
static FactionListMod InsertOne(
Database& db,
FactionListMod faction_list_mod_entry
FactionListMod e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(faction_list_mod_entry.id));
insert_values.push_back(std::to_string(faction_list_mod_entry.faction_id));
insert_values.push_back(std::to_string(faction_list_mod_entry.mod));
insert_values.push_back("'" + Strings::Escape(faction_list_mod_entry.mod_name) + "'");
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.faction_id));
v.push_back(std::to_string(e.mod));
v.push_back("'" + Strings::Escape(e.mod_name) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
faction_list_mod_entry.id = results.LastInsertedID();
return faction_list_mod_entry;
e.id = results.LastInsertedID();
return e;
}
faction_list_mod_entry = NewEntity();
e = NewEntity();
return faction_list_mod_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<FactionListMod> faction_list_mod_entries
const std::vector<FactionListMod> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &faction_list_mod_entry: faction_list_mod_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(faction_list_mod_entry.id));
insert_values.push_back(std::to_string(faction_list_mod_entry.faction_id));
insert_values.push_back(std::to_string(faction_list_mod_entry.mod));
insert_values.push_back("'" + Strings::Escape(faction_list_mod_entry.mod_name) + "'");
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.faction_id));
v.push_back(std::to_string(e.mod));
v.push_back("'" + Strings::Escape(e.mod_name) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -255,20 +255,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
FactionListMod entry{};
FactionListMod e{};
entry.id = atoi(row[0]);
entry.faction_id = atoi(row[1]);
entry.mod = atoi(row[2]);
entry.mod_name = row[3] ? row[3] : "";
e.id = atoi(row[0]);
e.faction_id = atoi(row[1]);
e.mod = atoi(row[2]);
e.mod_name = row[3] ? row[3] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<FactionListMod> GetWhere(Database& db, std::string where_filter)
static std::vector<FactionListMod> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<FactionListMod> all_entries;
@@ -283,20 +283,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
FactionListMod entry{};
FactionListMod e{};
entry.id = atoi(row[0]);
entry.faction_id = atoi(row[1]);
entry.mod = atoi(row[2]);
entry.mod_name = row[3] ? row[3] : "";
e.id = atoi(row[0]);
e.faction_id = atoi(row[1]);
e.mod = atoi(row[2]);
e.mod_name = row[3] ? row[3] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -321,6 +321,32 @@ public:
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_FACTION_LIST_MOD_REPOSITORY_H
@@ -82,16 +82,16 @@ public:
static FactionList NewEntity()
{
FactionList entry{};
FactionList e{};
entry.id = 0;
entry.name = "";
entry.base = 0;
e.id = 0;
e.name = "";
e.base = 0;
return entry;
return e;
}
static FactionList GetFactionListEntry(
static FactionList GetFactionList(
const std::vector<FactionList> &faction_lists,
int faction_list_id
)
@@ -120,13 +120,13 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
FactionList entry{};
FactionList e{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.base = atoi(row[2]);
e.id = atoi(row[0]);
e.name = row[1] ? row[1] : "";
e.base = atoi(row[2]);
return entry;
return e;
}
return NewEntity();
@@ -151,24 +151,24 @@ public:
static int UpdateOne(
Database& db,
FactionList faction_list_entry
const FactionList &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(faction_list_entry.id));
update_values.push_back(columns[1] + " = '" + Strings::Escape(faction_list_entry.name) + "'");
update_values.push_back(columns[2] + " = " + std::to_string(faction_list_entry.base));
v.push_back(columns[0] + " = " + std::to_string(e.id));
v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'");
v.push_back(columns[2] + " = " + std::to_string(e.base));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
faction_list_entry.id
e.id
)
);
@@ -177,51 +177,51 @@ public:
static FactionList InsertOne(
Database& db,
FactionList faction_list_entry
FactionList e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(faction_list_entry.id));
insert_values.push_back("'" + Strings::Escape(faction_list_entry.name) + "'");
insert_values.push_back(std::to_string(faction_list_entry.base));
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back(std::to_string(e.base));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
faction_list_entry.id = results.LastInsertedID();
return faction_list_entry;
e.id = results.LastInsertedID();
return e;
}
faction_list_entry = NewEntity();
e = NewEntity();
return faction_list_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<FactionList> faction_list_entries
const std::vector<FactionList> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &faction_list_entry: faction_list_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(faction_list_entry.id));
insert_values.push_back("'" + Strings::Escape(faction_list_entry.name) + "'");
insert_values.push_back(std::to_string(faction_list_entry.base));
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back(std::to_string(e.base));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -248,19 +248,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
FactionList entry{};
FactionList e{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.base = atoi(row[2]);
e.id = atoi(row[0]);
e.name = row[1] ? row[1] : "";
e.base = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<FactionList> GetWhere(Database& db, std::string where_filter)
static std::vector<FactionList> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<FactionList> all_entries;
@@ -275,19 +275,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
FactionList entry{};
FactionList e{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.base = atoi(row[2]);
e.id = atoi(row[0]);
e.name = row[1] ? row[1] : "";
e.base = atoi(row[2]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -312,6 +312,32 @@ public:
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_FACTION_LIST_REPOSITORY_H
@@ -85,17 +85,17 @@ public:
static FactionValues NewEntity()
{
FactionValues entry{};
FactionValues e{};
entry.char_id = 0;
entry.faction_id = 0;
entry.current_value = 0;
entry.temp = 0;
e.char_id = 0;
e.faction_id = 0;
e.current_value = 0;
e.temp = 0;
return entry;
return e;
}
static FactionValues GetFactionValuesEntry(
static FactionValues GetFactionValues(
const std::vector<FactionValues> &faction_valuess,
int faction_values_id
)
@@ -124,14 +124,14 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
FactionValues entry{};
FactionValues e{};
entry.char_id = atoi(row[0]);
entry.faction_id = atoi(row[1]);
entry.current_value = atoi(row[2]);
entry.temp = atoi(row[3]);
e.char_id = atoi(row[0]);
e.faction_id = atoi(row[1]);
e.current_value = atoi(row[2]);
e.temp = atoi(row[3]);
return entry;
return e;
}
return NewEntity();
@@ -156,25 +156,25 @@ public:
static int UpdateOne(
Database& db,
FactionValues faction_values_entry
const FactionValues &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(faction_values_entry.char_id));
update_values.push_back(columns[1] + " = " + std::to_string(faction_values_entry.faction_id));
update_values.push_back(columns[2] + " = " + std::to_string(faction_values_entry.current_value));
update_values.push_back(columns[3] + " = " + std::to_string(faction_values_entry.temp));
v.push_back(columns[0] + " = " + std::to_string(e.char_id));
v.push_back(columns[1] + " = " + std::to_string(e.faction_id));
v.push_back(columns[2] + " = " + std::to_string(e.current_value));
v.push_back(columns[3] + " = " + std::to_string(e.temp));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
faction_values_entry.char_id
e.char_id
)
);
@@ -183,53 +183,53 @@ public:
static FactionValues InsertOne(
Database& db,
FactionValues faction_values_entry
FactionValues e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(faction_values_entry.char_id));
insert_values.push_back(std::to_string(faction_values_entry.faction_id));
insert_values.push_back(std::to_string(faction_values_entry.current_value));
insert_values.push_back(std::to_string(faction_values_entry.temp));
v.push_back(std::to_string(e.char_id));
v.push_back(std::to_string(e.faction_id));
v.push_back(std::to_string(e.current_value));
v.push_back(std::to_string(e.temp));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
faction_values_entry.char_id = results.LastInsertedID();
return faction_values_entry;
e.char_id = results.LastInsertedID();
return e;
}
faction_values_entry = NewEntity();
e = NewEntity();
return faction_values_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<FactionValues> faction_values_entries
const std::vector<FactionValues> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &faction_values_entry: faction_values_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(faction_values_entry.char_id));
insert_values.push_back(std::to_string(faction_values_entry.faction_id));
insert_values.push_back(std::to_string(faction_values_entry.current_value));
insert_values.push_back(std::to_string(faction_values_entry.temp));
v.push_back(std::to_string(e.char_id));
v.push_back(std::to_string(e.faction_id));
v.push_back(std::to_string(e.current_value));
v.push_back(std::to_string(e.temp));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -256,20 +256,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
FactionValues entry{};
FactionValues e{};
entry.char_id = atoi(row[0]);
entry.faction_id = atoi(row[1]);
entry.current_value = atoi(row[2]);
entry.temp = atoi(row[3]);
e.char_id = atoi(row[0]);
e.faction_id = atoi(row[1]);
e.current_value = atoi(row[2]);
e.temp = atoi(row[3]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<FactionValues> GetWhere(Database& db, std::string where_filter)
static std::vector<FactionValues> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<FactionValues> all_entries;
@@ -284,20 +284,20 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
FactionValues entry{};
FactionValues e{};
entry.char_id = atoi(row[0]);
entry.faction_id = atoi(row[1]);
entry.current_value = atoi(row[2]);
entry.temp = atoi(row[3]);
e.char_id = atoi(row[0]);
e.faction_id = atoi(row[1]);
e.current_value = atoi(row[2]);
e.temp = atoi(row[3]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -322,6 +322,32 @@ public:
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_FACTION_VALUES_REPOSITORY_H
+129 -103
View File
@@ -106,24 +106,24 @@ public:
static Fishing NewEntity()
{
Fishing entry{};
Fishing e{};
entry.id = 0;
entry.zoneid = 0;
entry.Itemid = 0;
entry.skill_level = 0;
entry.chance = 0;
entry.npc_id = 0;
entry.npc_chance = 0;
entry.min_expansion = -1;
entry.max_expansion = -1;
entry.content_flags = "";
entry.content_flags_disabled = "";
e.id = 0;
e.zoneid = 0;
e.Itemid = 0;
e.skill_level = 0;
e.chance = 0;
e.npc_id = 0;
e.npc_chance = 0;
e.min_expansion = -1;
e.max_expansion = -1;
e.content_flags = "";
e.content_flags_disabled = "";
return entry;
return e;
}
static Fishing GetFishingEntry(
static Fishing GetFishing(
const std::vector<Fishing> &fishings,
int fishing_id
)
@@ -152,21 +152,21 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
Fishing entry{};
Fishing e{};
entry.id = atoi(row[0]);
entry.zoneid = atoi(row[1]);
entry.Itemid = atoi(row[2]);
entry.skill_level = atoi(row[3]);
entry.chance = atoi(row[4]);
entry.npc_id = atoi(row[5]);
entry.npc_chance = atoi(row[6]);
entry.min_expansion = atoi(row[7]);
entry.max_expansion = atoi(row[8]);
entry.content_flags = row[9] ? row[9] : "";
entry.content_flags_disabled = row[10] ? row[10] : "";
e.id = atoi(row[0]);
e.zoneid = atoi(row[1]);
e.Itemid = atoi(row[2]);
e.skill_level = atoi(row[3]);
e.chance = atoi(row[4]);
e.npc_id = atoi(row[5]);
e.npc_chance = atoi(row[6]);
e.min_expansion = atoi(row[7]);
e.max_expansion = atoi(row[8]);
e.content_flags = row[9] ? row[9] : "";
e.content_flags_disabled = row[10] ? row[10] : "";
return entry;
return e;
}
return NewEntity();
@@ -191,31 +191,31 @@ public:
static int UpdateOne(
Database& db,
Fishing fishing_entry
const Fishing &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(fishing_entry.zoneid));
update_values.push_back(columns[2] + " = " + std::to_string(fishing_entry.Itemid));
update_values.push_back(columns[3] + " = " + std::to_string(fishing_entry.skill_level));
update_values.push_back(columns[4] + " = " + std::to_string(fishing_entry.chance));
update_values.push_back(columns[5] + " = " + std::to_string(fishing_entry.npc_id));
update_values.push_back(columns[6] + " = " + std::to_string(fishing_entry.npc_chance));
update_values.push_back(columns[7] + " = " + std::to_string(fishing_entry.min_expansion));
update_values.push_back(columns[8] + " = " + std::to_string(fishing_entry.max_expansion));
update_values.push_back(columns[9] + " = '" + Strings::Escape(fishing_entry.content_flags) + "'");
update_values.push_back(columns[10] + " = '" + Strings::Escape(fishing_entry.content_flags_disabled) + "'");
v.push_back(columns[1] + " = " + std::to_string(e.zoneid));
v.push_back(columns[2] + " = " + std::to_string(e.Itemid));
v.push_back(columns[3] + " = " + std::to_string(e.skill_level));
v.push_back(columns[4] + " = " + std::to_string(e.chance));
v.push_back(columns[5] + " = " + std::to_string(e.npc_id));
v.push_back(columns[6] + " = " + std::to_string(e.npc_chance));
v.push_back(columns[7] + " = " + std::to_string(e.min_expansion));
v.push_back(columns[8] + " = " + std::to_string(e.max_expansion));
v.push_back(columns[9] + " = '" + Strings::Escape(e.content_flags) + "'");
v.push_back(columns[10] + " = '" + Strings::Escape(e.content_flags_disabled) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
fishing_entry.id
e.id
)
);
@@ -224,67 +224,67 @@ public:
static Fishing InsertOne(
Database& db,
Fishing fishing_entry
Fishing e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(fishing_entry.id));
insert_values.push_back(std::to_string(fishing_entry.zoneid));
insert_values.push_back(std::to_string(fishing_entry.Itemid));
insert_values.push_back(std::to_string(fishing_entry.skill_level));
insert_values.push_back(std::to_string(fishing_entry.chance));
insert_values.push_back(std::to_string(fishing_entry.npc_id));
insert_values.push_back(std::to_string(fishing_entry.npc_chance));
insert_values.push_back(std::to_string(fishing_entry.min_expansion));
insert_values.push_back(std::to_string(fishing_entry.max_expansion));
insert_values.push_back("'" + Strings::Escape(fishing_entry.content_flags) + "'");
insert_values.push_back("'" + Strings::Escape(fishing_entry.content_flags_disabled) + "'");
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.zoneid));
v.push_back(std::to_string(e.Itemid));
v.push_back(std::to_string(e.skill_level));
v.push_back(std::to_string(e.chance));
v.push_back(std::to_string(e.npc_id));
v.push_back(std::to_string(e.npc_chance));
v.push_back(std::to_string(e.min_expansion));
v.push_back(std::to_string(e.max_expansion));
v.push_back("'" + Strings::Escape(e.content_flags) + "'");
v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
fishing_entry.id = results.LastInsertedID();
return fishing_entry;
e.id = results.LastInsertedID();
return e;
}
fishing_entry = NewEntity();
e = NewEntity();
return fishing_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<Fishing> fishing_entries
const std::vector<Fishing> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &fishing_entry: fishing_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(fishing_entry.id));
insert_values.push_back(std::to_string(fishing_entry.zoneid));
insert_values.push_back(std::to_string(fishing_entry.Itemid));
insert_values.push_back(std::to_string(fishing_entry.skill_level));
insert_values.push_back(std::to_string(fishing_entry.chance));
insert_values.push_back(std::to_string(fishing_entry.npc_id));
insert_values.push_back(std::to_string(fishing_entry.npc_chance));
insert_values.push_back(std::to_string(fishing_entry.min_expansion));
insert_values.push_back(std::to_string(fishing_entry.max_expansion));
insert_values.push_back("'" + Strings::Escape(fishing_entry.content_flags) + "'");
insert_values.push_back("'" + Strings::Escape(fishing_entry.content_flags_disabled) + "'");
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.zoneid));
v.push_back(std::to_string(e.Itemid));
v.push_back(std::to_string(e.skill_level));
v.push_back(std::to_string(e.chance));
v.push_back(std::to_string(e.npc_id));
v.push_back(std::to_string(e.npc_chance));
v.push_back(std::to_string(e.min_expansion));
v.push_back(std::to_string(e.max_expansion));
v.push_back("'" + Strings::Escape(e.content_flags) + "'");
v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -311,27 +311,27 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Fishing entry{};
Fishing e{};
entry.id = atoi(row[0]);
entry.zoneid = atoi(row[1]);
entry.Itemid = atoi(row[2]);
entry.skill_level = atoi(row[3]);
entry.chance = atoi(row[4]);
entry.npc_id = atoi(row[5]);
entry.npc_chance = atoi(row[6]);
entry.min_expansion = atoi(row[7]);
entry.max_expansion = atoi(row[8]);
entry.content_flags = row[9] ? row[9] : "";
entry.content_flags_disabled = row[10] ? row[10] : "";
e.id = atoi(row[0]);
e.zoneid = atoi(row[1]);
e.Itemid = atoi(row[2]);
e.skill_level = atoi(row[3]);
e.chance = atoi(row[4]);
e.npc_id = atoi(row[5]);
e.npc_chance = atoi(row[6]);
e.min_expansion = atoi(row[7]);
e.max_expansion = atoi(row[8]);
e.content_flags = row[9] ? row[9] : "";
e.content_flags_disabled = row[10] ? row[10] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<Fishing> GetWhere(Database& db, std::string where_filter)
static std::vector<Fishing> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<Fishing> all_entries;
@@ -346,27 +346,27 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Fishing entry{};
Fishing e{};
entry.id = atoi(row[0]);
entry.zoneid = atoi(row[1]);
entry.Itemid = atoi(row[2]);
entry.skill_level = atoi(row[3]);
entry.chance = atoi(row[4]);
entry.npc_id = atoi(row[5]);
entry.npc_chance = atoi(row[6]);
entry.min_expansion = atoi(row[7]);
entry.max_expansion = atoi(row[8]);
entry.content_flags = row[9] ? row[9] : "";
entry.content_flags_disabled = row[10] ? row[10] : "";
e.id = atoi(row[0]);
e.zoneid = atoi(row[1]);
e.Itemid = atoi(row[2]);
e.skill_level = atoi(row[3]);
e.chance = atoi(row[4]);
e.npc_id = atoi(row[5]);
e.npc_chance = atoi(row[6]);
e.min_expansion = atoi(row[7]);
e.max_expansion = atoi(row[8]);
e.content_flags = row[9] ? row[9] : "";
e.content_flags_disabled = row[10] ? row[10] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -391,6 +391,32 @@ public:
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_FISHING_REPOSITORY_H
+115 -89
View File
@@ -100,22 +100,22 @@ public:
static Forage NewEntity()
{
Forage entry{};
Forage e{};
entry.id = 0;
entry.zoneid = 0;
entry.Itemid = 0;
entry.level = 0;
entry.chance = 0;
entry.min_expansion = -1;
entry.max_expansion = -1;
entry.content_flags = "";
entry.content_flags_disabled = "";
e.id = 0;
e.zoneid = 0;
e.Itemid = 0;
e.level = 0;
e.chance = 0;
e.min_expansion = -1;
e.max_expansion = -1;
e.content_flags = "";
e.content_flags_disabled = "";
return entry;
return e;
}
static Forage GetForageEntry(
static Forage GetForage(
const std::vector<Forage> &forages,
int forage_id
)
@@ -144,19 +144,19 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
Forage entry{};
Forage e{};
entry.id = atoi(row[0]);
entry.zoneid = atoi(row[1]);
entry.Itemid = atoi(row[2]);
entry.level = atoi(row[3]);
entry.chance = atoi(row[4]);
entry.min_expansion = atoi(row[5]);
entry.max_expansion = atoi(row[6]);
entry.content_flags = row[7] ? row[7] : "";
entry.content_flags_disabled = row[8] ? row[8] : "";
e.id = atoi(row[0]);
e.zoneid = atoi(row[1]);
e.Itemid = atoi(row[2]);
e.level = atoi(row[3]);
e.chance = atoi(row[4]);
e.min_expansion = atoi(row[5]);
e.max_expansion = atoi(row[6]);
e.content_flags = row[7] ? row[7] : "";
e.content_flags_disabled = row[8] ? row[8] : "";
return entry;
return e;
}
return NewEntity();
@@ -181,29 +181,29 @@ public:
static int UpdateOne(
Database& db,
Forage forage_entry
const Forage &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(forage_entry.zoneid));
update_values.push_back(columns[2] + " = " + std::to_string(forage_entry.Itemid));
update_values.push_back(columns[3] + " = " + std::to_string(forage_entry.level));
update_values.push_back(columns[4] + " = " + std::to_string(forage_entry.chance));
update_values.push_back(columns[5] + " = " + std::to_string(forage_entry.min_expansion));
update_values.push_back(columns[6] + " = " + std::to_string(forage_entry.max_expansion));
update_values.push_back(columns[7] + " = '" + Strings::Escape(forage_entry.content_flags) + "'");
update_values.push_back(columns[8] + " = '" + Strings::Escape(forage_entry.content_flags_disabled) + "'");
v.push_back(columns[1] + " = " + std::to_string(e.zoneid));
v.push_back(columns[2] + " = " + std::to_string(e.Itemid));
v.push_back(columns[3] + " = " + std::to_string(e.level));
v.push_back(columns[4] + " = " + std::to_string(e.chance));
v.push_back(columns[5] + " = " + std::to_string(e.min_expansion));
v.push_back(columns[6] + " = " + std::to_string(e.max_expansion));
v.push_back(columns[7] + " = '" + Strings::Escape(e.content_flags) + "'");
v.push_back(columns[8] + " = '" + Strings::Escape(e.content_flags_disabled) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
forage_entry.id
e.id
)
);
@@ -212,63 +212,63 @@ public:
static Forage InsertOne(
Database& db,
Forage forage_entry
Forage e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(forage_entry.id));
insert_values.push_back(std::to_string(forage_entry.zoneid));
insert_values.push_back(std::to_string(forage_entry.Itemid));
insert_values.push_back(std::to_string(forage_entry.level));
insert_values.push_back(std::to_string(forage_entry.chance));
insert_values.push_back(std::to_string(forage_entry.min_expansion));
insert_values.push_back(std::to_string(forage_entry.max_expansion));
insert_values.push_back("'" + Strings::Escape(forage_entry.content_flags) + "'");
insert_values.push_back("'" + Strings::Escape(forage_entry.content_flags_disabled) + "'");
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.zoneid));
v.push_back(std::to_string(e.Itemid));
v.push_back(std::to_string(e.level));
v.push_back(std::to_string(e.chance));
v.push_back(std::to_string(e.min_expansion));
v.push_back(std::to_string(e.max_expansion));
v.push_back("'" + Strings::Escape(e.content_flags) + "'");
v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
forage_entry.id = results.LastInsertedID();
return forage_entry;
e.id = results.LastInsertedID();
return e;
}
forage_entry = NewEntity();
e = NewEntity();
return forage_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<Forage> forage_entries
const std::vector<Forage> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &forage_entry: forage_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(forage_entry.id));
insert_values.push_back(std::to_string(forage_entry.zoneid));
insert_values.push_back(std::to_string(forage_entry.Itemid));
insert_values.push_back(std::to_string(forage_entry.level));
insert_values.push_back(std::to_string(forage_entry.chance));
insert_values.push_back(std::to_string(forage_entry.min_expansion));
insert_values.push_back(std::to_string(forage_entry.max_expansion));
insert_values.push_back("'" + Strings::Escape(forage_entry.content_flags) + "'");
insert_values.push_back("'" + Strings::Escape(forage_entry.content_flags_disabled) + "'");
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.zoneid));
v.push_back(std::to_string(e.Itemid));
v.push_back(std::to_string(e.level));
v.push_back(std::to_string(e.chance));
v.push_back(std::to_string(e.min_expansion));
v.push_back(std::to_string(e.max_expansion));
v.push_back("'" + Strings::Escape(e.content_flags) + "'");
v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -295,25 +295,25 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Forage entry{};
Forage e{};
entry.id = atoi(row[0]);
entry.zoneid = atoi(row[1]);
entry.Itemid = atoi(row[2]);
entry.level = atoi(row[3]);
entry.chance = atoi(row[4]);
entry.min_expansion = atoi(row[5]);
entry.max_expansion = atoi(row[6]);
entry.content_flags = row[7] ? row[7] : "";
entry.content_flags_disabled = row[8] ? row[8] : "";
e.id = atoi(row[0]);
e.zoneid = atoi(row[1]);
e.Itemid = atoi(row[2]);
e.level = atoi(row[3]);
e.chance = atoi(row[4]);
e.min_expansion = atoi(row[5]);
e.max_expansion = atoi(row[6]);
e.content_flags = row[7] ? row[7] : "";
e.content_flags_disabled = row[8] ? row[8] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<Forage> GetWhere(Database& db, std::string where_filter)
static std::vector<Forage> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<Forage> all_entries;
@@ -328,25 +328,25 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Forage entry{};
Forage e{};
entry.id = atoi(row[0]);
entry.zoneid = atoi(row[1]);
entry.Itemid = atoi(row[2]);
entry.level = atoi(row[3]);
entry.chance = atoi(row[4]);
entry.min_expansion = atoi(row[5]);
entry.max_expansion = atoi(row[6]);
entry.content_flags = row[7] ? row[7] : "";
entry.content_flags_disabled = row[8] ? row[8] : "";
e.id = atoi(row[0]);
e.zoneid = atoi(row[1]);
e.Itemid = atoi(row[2]);
e.level = atoi(row[3]);
e.chance = atoi(row[4]);
e.min_expansion = atoi(row[5]);
e.max_expansion = atoi(row[6]);
e.content_flags = row[7] ? row[7] : "";
e.content_flags_disabled = row[8] ? row[8] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -371,6 +371,32 @@ public:
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_FORAGE_REPOSITORY_H
@@ -82,16 +82,16 @@ public:
static Friends NewEntity()
{
Friends entry{};
Friends e{};
entry.charid = 0;
entry.type = 1;
entry.name = "";
e.charid = 0;
e.type = 1;
e.name = "";
return entry;
return e;
}
static Friends GetFriendsEntry(
static Friends GetFriends(
const std::vector<Friends> &friendss,
int friends_id
)
@@ -120,13 +120,13 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
Friends entry{};
Friends e{};
entry.charid = atoi(row[0]);
entry.type = atoi(row[1]);
entry.name = row[2] ? row[2] : "";
e.charid = atoi(row[0]);
e.type = atoi(row[1]);
e.name = row[2] ? row[2] : "";
return entry;
return e;
}
return NewEntity();
@@ -151,24 +151,24 @@ public:
static int UpdateOne(
Database& db,
Friends friends_entry
const Friends &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(friends_entry.charid));
update_values.push_back(columns[1] + " = " + std::to_string(friends_entry.type));
update_values.push_back(columns[2] + " = '" + Strings::Escape(friends_entry.name) + "'");
v.push_back(columns[0] + " = " + std::to_string(e.charid));
v.push_back(columns[1] + " = " + std::to_string(e.type));
v.push_back(columns[2] + " = '" + Strings::Escape(e.name) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
friends_entry.charid
e.charid
)
);
@@ -177,51 +177,51 @@ public:
static Friends InsertOne(
Database& db,
Friends friends_entry
Friends e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(friends_entry.charid));
insert_values.push_back(std::to_string(friends_entry.type));
insert_values.push_back("'" + Strings::Escape(friends_entry.name) + "'");
v.push_back(std::to_string(e.charid));
v.push_back(std::to_string(e.type));
v.push_back("'" + Strings::Escape(e.name) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
friends_entry.charid = results.LastInsertedID();
return friends_entry;
e.charid = results.LastInsertedID();
return e;
}
friends_entry = NewEntity();
e = NewEntity();
return friends_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<Friends> friends_entries
const std::vector<Friends> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &friends_entry: friends_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(friends_entry.charid));
insert_values.push_back(std::to_string(friends_entry.type));
insert_values.push_back("'" + Strings::Escape(friends_entry.name) + "'");
v.push_back(std::to_string(e.charid));
v.push_back(std::to_string(e.type));
v.push_back("'" + Strings::Escape(e.name) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -248,19 +248,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Friends entry{};
Friends e{};
entry.charid = atoi(row[0]);
entry.type = atoi(row[1]);
entry.name = row[2] ? row[2] : "";
e.charid = atoi(row[0]);
e.type = atoi(row[1]);
e.name = row[2] ? row[2] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<Friends> GetWhere(Database& db, std::string where_filter)
static std::vector<Friends> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<Friends> all_entries;
@@ -275,19 +275,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Friends entry{};
Friends e{};
entry.charid = atoi(row[0]);
entry.type = atoi(row[1]);
entry.name = row[2] ? row[2] : "";
e.charid = atoi(row[0]);
e.type = atoi(row[1]);
e.name = row[2] ? row[2] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -312,6 +312,32 @@ public:
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_FRIENDS_REPOSITORY_H
@@ -124,30 +124,30 @@ public:
static GlobalLoot NewEntity()
{
GlobalLoot entry{};
GlobalLoot e{};
entry.id = 0;
entry.description = "";
entry.loottable_id = 0;
entry.enabled = 1;
entry.min_level = 0;
entry.max_level = 0;
entry.rare = 0;
entry.raid = 0;
entry.race = "";
entry.class_ = "";
entry.bodytype = "";
entry.zone = "";
entry.hot_zone = 0;
entry.min_expansion = -1;
entry.max_expansion = -1;
entry.content_flags = "";
entry.content_flags_disabled = "";
e.id = 0;
e.description = "";
e.loottable_id = 0;
e.enabled = 1;
e.min_level = 0;
e.max_level = 0;
e.rare = 0;
e.raid = 0;
e.race = "";
e.class_ = "";
e.bodytype = "";
e.zone = "";
e.hot_zone = 0;
e.min_expansion = -1;
e.max_expansion = -1;
e.content_flags = "";
e.content_flags_disabled = "";
return entry;
return e;
}
static GlobalLoot GetGlobalLootEntry(
static GlobalLoot GetGlobalLoot(
const std::vector<GlobalLoot> &global_loots,
int global_loot_id
)
@@ -176,27 +176,27 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
GlobalLoot entry{};
GlobalLoot e{};
entry.id = atoi(row[0]);
entry.description = row[1] ? row[1] : "";
entry.loottable_id = atoi(row[2]);
entry.enabled = atoi(row[3]);
entry.min_level = atoi(row[4]);
entry.max_level = atoi(row[5]);
entry.rare = atoi(row[6]);
entry.raid = atoi(row[7]);
entry.race = row[8] ? row[8] : "";
entry.class_ = row[9] ? row[9] : "";
entry.bodytype = row[10] ? row[10] : "";
entry.zone = row[11] ? row[11] : "";
entry.hot_zone = atoi(row[12]);
entry.min_expansion = atoi(row[13]);
entry.max_expansion = atoi(row[14]);
entry.content_flags = row[15] ? row[15] : "";
entry.content_flags_disabled = row[16] ? row[16] : "";
e.id = atoi(row[0]);
e.description = row[1] ? row[1] : "";
e.loottable_id = atoi(row[2]);
e.enabled = atoi(row[3]);
e.min_level = atoi(row[4]);
e.max_level = atoi(row[5]);
e.rare = atoi(row[6]);
e.raid = atoi(row[7]);
e.race = row[8] ? row[8] : "";
e.class_ = row[9] ? row[9] : "";
e.bodytype = row[10] ? row[10] : "";
e.zone = row[11] ? row[11] : "";
e.hot_zone = atoi(row[12]);
e.min_expansion = atoi(row[13]);
e.max_expansion = atoi(row[14]);
e.content_flags = row[15] ? row[15] : "";
e.content_flags_disabled = row[16] ? row[16] : "";
return entry;
return e;
}
return NewEntity();
@@ -221,37 +221,37 @@ public:
static int UpdateOne(
Database& db,
GlobalLoot global_loot_entry
const GlobalLoot &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + Strings::Escape(global_loot_entry.description) + "'");
update_values.push_back(columns[2] + " = " + std::to_string(global_loot_entry.loottable_id));
update_values.push_back(columns[3] + " = " + std::to_string(global_loot_entry.enabled));
update_values.push_back(columns[4] + " = " + std::to_string(global_loot_entry.min_level));
update_values.push_back(columns[5] + " = " + std::to_string(global_loot_entry.max_level));
update_values.push_back(columns[6] + " = " + std::to_string(global_loot_entry.rare));
update_values.push_back(columns[7] + " = " + std::to_string(global_loot_entry.raid));
update_values.push_back(columns[8] + " = '" + Strings::Escape(global_loot_entry.race) + "'");
update_values.push_back(columns[9] + " = '" + Strings::Escape(global_loot_entry.class_) + "'");
update_values.push_back(columns[10] + " = '" + Strings::Escape(global_loot_entry.bodytype) + "'");
update_values.push_back(columns[11] + " = '" + Strings::Escape(global_loot_entry.zone) + "'");
update_values.push_back(columns[12] + " = " + std::to_string(global_loot_entry.hot_zone));
update_values.push_back(columns[13] + " = " + std::to_string(global_loot_entry.min_expansion));
update_values.push_back(columns[14] + " = " + std::to_string(global_loot_entry.max_expansion));
update_values.push_back(columns[15] + " = '" + Strings::Escape(global_loot_entry.content_flags) + "'");
update_values.push_back(columns[16] + " = '" + Strings::Escape(global_loot_entry.content_flags_disabled) + "'");
v.push_back(columns[1] + " = '" + Strings::Escape(e.description) + "'");
v.push_back(columns[2] + " = " + std::to_string(e.loottable_id));
v.push_back(columns[3] + " = " + std::to_string(e.enabled));
v.push_back(columns[4] + " = " + std::to_string(e.min_level));
v.push_back(columns[5] + " = " + std::to_string(e.max_level));
v.push_back(columns[6] + " = " + std::to_string(e.rare));
v.push_back(columns[7] + " = " + std::to_string(e.raid));
v.push_back(columns[8] + " = '" + Strings::Escape(e.race) + "'");
v.push_back(columns[9] + " = '" + Strings::Escape(e.class_) + "'");
v.push_back(columns[10] + " = '" + Strings::Escape(e.bodytype) + "'");
v.push_back(columns[11] + " = '" + Strings::Escape(e.zone) + "'");
v.push_back(columns[12] + " = " + std::to_string(e.hot_zone));
v.push_back(columns[13] + " = " + std::to_string(e.min_expansion));
v.push_back(columns[14] + " = " + std::to_string(e.max_expansion));
v.push_back(columns[15] + " = '" + Strings::Escape(e.content_flags) + "'");
v.push_back(columns[16] + " = '" + Strings::Escape(e.content_flags_disabled) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
global_loot_entry.id
e.id
)
);
@@ -260,79 +260,79 @@ public:
static GlobalLoot InsertOne(
Database& db,
GlobalLoot global_loot_entry
GlobalLoot e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(global_loot_entry.id));
insert_values.push_back("'" + Strings::Escape(global_loot_entry.description) + "'");
insert_values.push_back(std::to_string(global_loot_entry.loottable_id));
insert_values.push_back(std::to_string(global_loot_entry.enabled));
insert_values.push_back(std::to_string(global_loot_entry.min_level));
insert_values.push_back(std::to_string(global_loot_entry.max_level));
insert_values.push_back(std::to_string(global_loot_entry.rare));
insert_values.push_back(std::to_string(global_loot_entry.raid));
insert_values.push_back("'" + Strings::Escape(global_loot_entry.race) + "'");
insert_values.push_back("'" + Strings::Escape(global_loot_entry.class_) + "'");
insert_values.push_back("'" + Strings::Escape(global_loot_entry.bodytype) + "'");
insert_values.push_back("'" + Strings::Escape(global_loot_entry.zone) + "'");
insert_values.push_back(std::to_string(global_loot_entry.hot_zone));
insert_values.push_back(std::to_string(global_loot_entry.min_expansion));
insert_values.push_back(std::to_string(global_loot_entry.max_expansion));
insert_values.push_back("'" + Strings::Escape(global_loot_entry.content_flags) + "'");
insert_values.push_back("'" + Strings::Escape(global_loot_entry.content_flags_disabled) + "'");
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.description) + "'");
v.push_back(std::to_string(e.loottable_id));
v.push_back(std::to_string(e.enabled));
v.push_back(std::to_string(e.min_level));
v.push_back(std::to_string(e.max_level));
v.push_back(std::to_string(e.rare));
v.push_back(std::to_string(e.raid));
v.push_back("'" + Strings::Escape(e.race) + "'");
v.push_back("'" + Strings::Escape(e.class_) + "'");
v.push_back("'" + Strings::Escape(e.bodytype) + "'");
v.push_back("'" + Strings::Escape(e.zone) + "'");
v.push_back(std::to_string(e.hot_zone));
v.push_back(std::to_string(e.min_expansion));
v.push_back(std::to_string(e.max_expansion));
v.push_back("'" + Strings::Escape(e.content_flags) + "'");
v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
global_loot_entry.id = results.LastInsertedID();
return global_loot_entry;
e.id = results.LastInsertedID();
return e;
}
global_loot_entry = NewEntity();
e = NewEntity();
return global_loot_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<GlobalLoot> global_loot_entries
const std::vector<GlobalLoot> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &global_loot_entry: global_loot_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(global_loot_entry.id));
insert_values.push_back("'" + Strings::Escape(global_loot_entry.description) + "'");
insert_values.push_back(std::to_string(global_loot_entry.loottable_id));
insert_values.push_back(std::to_string(global_loot_entry.enabled));
insert_values.push_back(std::to_string(global_loot_entry.min_level));
insert_values.push_back(std::to_string(global_loot_entry.max_level));
insert_values.push_back(std::to_string(global_loot_entry.rare));
insert_values.push_back(std::to_string(global_loot_entry.raid));
insert_values.push_back("'" + Strings::Escape(global_loot_entry.race) + "'");
insert_values.push_back("'" + Strings::Escape(global_loot_entry.class_) + "'");
insert_values.push_back("'" + Strings::Escape(global_loot_entry.bodytype) + "'");
insert_values.push_back("'" + Strings::Escape(global_loot_entry.zone) + "'");
insert_values.push_back(std::to_string(global_loot_entry.hot_zone));
insert_values.push_back(std::to_string(global_loot_entry.min_expansion));
insert_values.push_back(std::to_string(global_loot_entry.max_expansion));
insert_values.push_back("'" + Strings::Escape(global_loot_entry.content_flags) + "'");
insert_values.push_back("'" + Strings::Escape(global_loot_entry.content_flags_disabled) + "'");
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.description) + "'");
v.push_back(std::to_string(e.loottable_id));
v.push_back(std::to_string(e.enabled));
v.push_back(std::to_string(e.min_level));
v.push_back(std::to_string(e.max_level));
v.push_back(std::to_string(e.rare));
v.push_back(std::to_string(e.raid));
v.push_back("'" + Strings::Escape(e.race) + "'");
v.push_back("'" + Strings::Escape(e.class_) + "'");
v.push_back("'" + Strings::Escape(e.bodytype) + "'");
v.push_back("'" + Strings::Escape(e.zone) + "'");
v.push_back(std::to_string(e.hot_zone));
v.push_back(std::to_string(e.min_expansion));
v.push_back(std::to_string(e.max_expansion));
v.push_back("'" + Strings::Escape(e.content_flags) + "'");
v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -359,33 +359,33 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
GlobalLoot entry{};
GlobalLoot e{};
entry.id = atoi(row[0]);
entry.description = row[1] ? row[1] : "";
entry.loottable_id = atoi(row[2]);
entry.enabled = atoi(row[3]);
entry.min_level = atoi(row[4]);
entry.max_level = atoi(row[5]);
entry.rare = atoi(row[6]);
entry.raid = atoi(row[7]);
entry.race = row[8] ? row[8] : "";
entry.class_ = row[9] ? row[9] : "";
entry.bodytype = row[10] ? row[10] : "";
entry.zone = row[11] ? row[11] : "";
entry.hot_zone = atoi(row[12]);
entry.min_expansion = atoi(row[13]);
entry.max_expansion = atoi(row[14]);
entry.content_flags = row[15] ? row[15] : "";
entry.content_flags_disabled = row[16] ? row[16] : "";
e.id = atoi(row[0]);
e.description = row[1] ? row[1] : "";
e.loottable_id = atoi(row[2]);
e.enabled = atoi(row[3]);
e.min_level = atoi(row[4]);
e.max_level = atoi(row[5]);
e.rare = atoi(row[6]);
e.raid = atoi(row[7]);
e.race = row[8] ? row[8] : "";
e.class_ = row[9] ? row[9] : "";
e.bodytype = row[10] ? row[10] : "";
e.zone = row[11] ? row[11] : "";
e.hot_zone = atoi(row[12]);
e.min_expansion = atoi(row[13]);
e.max_expansion = atoi(row[14]);
e.content_flags = row[15] ? row[15] : "";
e.content_flags_disabled = row[16] ? row[16] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<GlobalLoot> GetWhere(Database& db, std::string where_filter)
static std::vector<GlobalLoot> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<GlobalLoot> all_entries;
@@ -400,33 +400,33 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
GlobalLoot entry{};
GlobalLoot e{};
entry.id = atoi(row[0]);
entry.description = row[1] ? row[1] : "";
entry.loottable_id = atoi(row[2]);
entry.enabled = atoi(row[3]);
entry.min_level = atoi(row[4]);
entry.max_level = atoi(row[5]);
entry.rare = atoi(row[6]);
entry.raid = atoi(row[7]);
entry.race = row[8] ? row[8] : "";
entry.class_ = row[9] ? row[9] : "";
entry.bodytype = row[10] ? row[10] : "";
entry.zone = row[11] ? row[11] : "";
entry.hot_zone = atoi(row[12]);
entry.min_expansion = atoi(row[13]);
entry.max_expansion = atoi(row[14]);
entry.content_flags = row[15] ? row[15] : "";
entry.content_flags_disabled = row[16] ? row[16] : "";
e.id = atoi(row[0]);
e.description = row[1] ? row[1] : "";
e.loottable_id = atoi(row[2]);
e.enabled = atoi(row[3]);
e.min_level = atoi(row[4]);
e.max_level = atoi(row[5]);
e.rare = atoi(row[6]);
e.raid = atoi(row[7]);
e.race = row[8] ? row[8] : "";
e.class_ = row[9] ? row[9] : "";
e.bodytype = row[10] ? row[10] : "";
e.zone = row[11] ? row[11] : "";
e.hot_zone = atoi(row[12]);
e.min_expansion = atoi(row[13]);
e.max_expansion = atoi(row[14]);
e.content_flags = row[15] ? row[15] : "";
e.content_flags_disabled = row[16] ? row[16] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -451,6 +451,32 @@ public:
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_GLOBAL_LOOT_REPOSITORY_H
@@ -82,16 +82,16 @@ public:
static GmIps NewEntity()
{
GmIps entry{};
GmIps e{};
entry.name = "";
entry.account_id = 0;
entry.ip_address = "";
e.name = "";
e.account_id = 0;
e.ip_address = "";
return entry;
return e;
}
static GmIps GetGmIpsEntry(
static GmIps GetGmIps(
const std::vector<GmIps> &gm_ipss,
int gm_ips_id
)
@@ -120,13 +120,13 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
GmIps entry{};
GmIps e{};
entry.name = row[0] ? row[0] : "";
entry.account_id = atoi(row[1]);
entry.ip_address = row[2] ? row[2] : "";
e.name = row[0] ? row[0] : "";
e.account_id = atoi(row[1]);
e.ip_address = row[2] ? row[2] : "";
return entry;
return e;
}
return NewEntity();
@@ -151,24 +151,24 @@ public:
static int UpdateOne(
Database& db,
GmIps gm_ips_entry
const GmIps &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = '" + Strings::Escape(gm_ips_entry.name) + "'");
update_values.push_back(columns[1] + " = " + std::to_string(gm_ips_entry.account_id));
update_values.push_back(columns[2] + " = '" + Strings::Escape(gm_ips_entry.ip_address) + "'");
v.push_back(columns[0] + " = '" + Strings::Escape(e.name) + "'");
v.push_back(columns[1] + " = " + std::to_string(e.account_id));
v.push_back(columns[2] + " = '" + Strings::Escape(e.ip_address) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
gm_ips_entry.account_id
e.account_id
)
);
@@ -177,51 +177,51 @@ public:
static GmIps InsertOne(
Database& db,
GmIps gm_ips_entry
GmIps e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back("'" + Strings::Escape(gm_ips_entry.name) + "'");
insert_values.push_back(std::to_string(gm_ips_entry.account_id));
insert_values.push_back("'" + Strings::Escape(gm_ips_entry.ip_address) + "'");
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back(std::to_string(e.account_id));
v.push_back("'" + Strings::Escape(e.ip_address) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
gm_ips_entry.account_id = results.LastInsertedID();
return gm_ips_entry;
e.account_id = results.LastInsertedID();
return e;
}
gm_ips_entry = NewEntity();
e = NewEntity();
return gm_ips_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<GmIps> gm_ips_entries
const std::vector<GmIps> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &gm_ips_entry: gm_ips_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back("'" + Strings::Escape(gm_ips_entry.name) + "'");
insert_values.push_back(std::to_string(gm_ips_entry.account_id));
insert_values.push_back("'" + Strings::Escape(gm_ips_entry.ip_address) + "'");
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back(std::to_string(e.account_id));
v.push_back("'" + Strings::Escape(e.ip_address) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -248,19 +248,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
GmIps entry{};
GmIps e{};
entry.name = row[0] ? row[0] : "";
entry.account_id = atoi(row[1]);
entry.ip_address = row[2] ? row[2] : "";
e.name = row[0] ? row[0] : "";
e.account_id = atoi(row[1]);
e.ip_address = row[2] ? row[2] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<GmIps> GetWhere(Database& db, std::string where_filter)
static std::vector<GmIps> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<GmIps> all_entries;
@@ -275,19 +275,19 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
GmIps entry{};
GmIps e{};
entry.name = row[0] ? row[0] : "";
entry.account_id = atoi(row[1]);
entry.ip_address = row[2] ? row[2] : "";
e.name = row[0] ? row[0] : "";
e.account_id = atoi(row[1]);
e.ip_address = row[2] ? row[2] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -312,6 +312,32 @@ public:
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_GM_IPS_REPOSITORY_H
@@ -79,15 +79,15 @@ public:
static Goallists NewEntity()
{
Goallists entry{};
Goallists e{};
entry.listid = 0;
entry.entry = 0;
e.listid = 0;
e.entry = 0;
return entry;
return e;
}
static Goallists GetGoallistsEntry(
static Goallists GetGoallists(
const std::vector<Goallists> &goallistss,
int goallists_id
)
@@ -116,12 +116,12 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
Goallists entry{};
Goallists e{};
entry.listid = atoi(row[0]);
entry.entry = atoi(row[1]);
e.listid = atoi(row[0]);
e.entry = atoi(row[1]);
return entry;
return e;
}
return NewEntity();
@@ -146,23 +146,23 @@ public:
static int UpdateOne(
Database& db,
Goallists goallists_entry
const Goallists &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(goallists_entry.listid));
update_values.push_back(columns[1] + " = " + std::to_string(goallists_entry.entry));
v.push_back(columns[0] + " = " + std::to_string(e.listid));
v.push_back(columns[1] + " = " + std::to_string(e.entry));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
goallists_entry.listid
e.listid
)
);
@@ -171,49 +171,49 @@ public:
static Goallists InsertOne(
Database& db,
Goallists goallists_entry
Goallists e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(goallists_entry.listid));
insert_values.push_back(std::to_string(goallists_entry.entry));
v.push_back(std::to_string(e.listid));
v.push_back(std::to_string(e.entry));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
goallists_entry.listid = results.LastInsertedID();
return goallists_entry;
e.listid = results.LastInsertedID();
return e;
}
goallists_entry = NewEntity();
e = NewEntity();
return goallists_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<Goallists> goallists_entries
const std::vector<Goallists> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &goallists_entry: goallists_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(goallists_entry.listid));
insert_values.push_back(std::to_string(goallists_entry.entry));
v.push_back(std::to_string(e.listid));
v.push_back(std::to_string(e.entry));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -240,18 +240,18 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Goallists entry{};
Goallists e{};
entry.listid = atoi(row[0]);
entry.entry = atoi(row[1]);
e.listid = atoi(row[0]);
e.entry = atoi(row[1]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<Goallists> GetWhere(Database& db, std::string where_filter)
static std::vector<Goallists> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<Goallists> all_entries;
@@ -266,18 +266,18 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Goallists entry{};
Goallists e{};
entry.listid = atoi(row[0]);
entry.entry = atoi(row[1]);
e.listid = atoi(row[0]);
e.entry = atoi(row[1]);
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -302,6 +302,32 @@ public:
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_GOALLISTS_REPOSITORY_H
@@ -91,19 +91,19 @@ public:
static Graveyard NewEntity()
{
Graveyard entry{};
Graveyard e{};
entry.id = 0;
entry.zone_id = 0;
entry.x = 0;
entry.y = 0;
entry.z = 0;
entry.heading = 0;
e.id = 0;
e.zone_id = 0;
e.x = 0;
e.y = 0;
e.z = 0;
e.heading = 0;
return entry;
return e;
}
static Graveyard GetGraveyardEntry(
static Graveyard GetGraveyard(
const std::vector<Graveyard> &graveyards,
int graveyard_id
)
@@ -132,16 +132,16 @@ public:
auto row = results.begin();
if (results.RowCount() == 1) {
Graveyard entry{};
Graveyard e{};
entry.id = atoi(row[0]);
entry.zone_id = atoi(row[1]);
entry.x = static_cast<float>(atof(row[2]));
entry.y = static_cast<float>(atof(row[3]));
entry.z = static_cast<float>(atof(row[4]));
entry.heading = static_cast<float>(atof(row[5]));
e.id = atoi(row[0]);
e.zone_id = atoi(row[1]);
e.x = static_cast<float>(atof(row[2]));
e.y = static_cast<float>(atof(row[3]));
e.z = static_cast<float>(atof(row[4]));
e.heading = static_cast<float>(atof(row[5]));
return entry;
return e;
}
return NewEntity();
@@ -166,26 +166,26 @@ public:
static int UpdateOne(
Database& db,
Graveyard graveyard_entry
const Graveyard &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = " + std::to_string(graveyard_entry.zone_id));
update_values.push_back(columns[2] + " = " + std::to_string(graveyard_entry.x));
update_values.push_back(columns[3] + " = " + std::to_string(graveyard_entry.y));
update_values.push_back(columns[4] + " = " + std::to_string(graveyard_entry.z));
update_values.push_back(columns[5] + " = " + std::to_string(graveyard_entry.heading));
v.push_back(columns[1] + " = " + std::to_string(e.zone_id));
v.push_back(columns[2] + " = " + std::to_string(e.x));
v.push_back(columns[3] + " = " + std::to_string(e.y));
v.push_back(columns[4] + " = " + std::to_string(e.z));
v.push_back(columns[5] + " = " + std::to_string(e.heading));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
graveyard_entry.id
e.id
)
);
@@ -194,57 +194,57 @@ public:
static Graveyard InsertOne(
Database& db,
Graveyard graveyard_entry
Graveyard e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(graveyard_entry.id));
insert_values.push_back(std::to_string(graveyard_entry.zone_id));
insert_values.push_back(std::to_string(graveyard_entry.x));
insert_values.push_back(std::to_string(graveyard_entry.y));
insert_values.push_back(std::to_string(graveyard_entry.z));
insert_values.push_back(std::to_string(graveyard_entry.heading));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.zone_id));
v.push_back(std::to_string(e.x));
v.push_back(std::to_string(e.y));
v.push_back(std::to_string(e.z));
v.push_back(std::to_string(e.heading));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", insert_values)
Strings::Implode(",", v)
)
);
if (results.Success()) {
graveyard_entry.id = results.LastInsertedID();
return graveyard_entry;
e.id = results.LastInsertedID();
return e;
}
graveyard_entry = NewEntity();
e = NewEntity();
return graveyard_entry;
return e;
}
static int InsertMany(
Database& db,
std::vector<Graveyard> graveyard_entries
const std::vector<Graveyard> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &graveyard_entry: graveyard_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(graveyard_entry.id));
insert_values.push_back(std::to_string(graveyard_entry.zone_id));
insert_values.push_back(std::to_string(graveyard_entry.x));
insert_values.push_back(std::to_string(graveyard_entry.y));
insert_values.push_back(std::to_string(graveyard_entry.z));
insert_values.push_back(std::to_string(graveyard_entry.heading));
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.zone_id));
v.push_back(std::to_string(e.x));
v.push_back(std::to_string(e.y));
v.push_back(std::to_string(e.z));
v.push_back(std::to_string(e.heading));
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
@@ -271,22 +271,22 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Graveyard entry{};
Graveyard e{};
entry.id = atoi(row[0]);
entry.zone_id = atoi(row[1]);
entry.x = static_cast<float>(atof(row[2]));
entry.y = static_cast<float>(atof(row[3]));
entry.z = static_cast<float>(atof(row[4]));
entry.heading = static_cast<float>(atof(row[5]));
e.id = atoi(row[0]);
e.zone_id = atoi(row[1]);
e.x = static_cast<float>(atof(row[2]));
e.y = static_cast<float>(atof(row[3]));
e.z = static_cast<float>(atof(row[4]));
e.heading = static_cast<float>(atof(row[5]));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<Graveyard> GetWhere(Database& db, std::string where_filter)
static std::vector<Graveyard> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<Graveyard> all_entries;
@@ -301,22 +301,22 @@ public:
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Graveyard entry{};
Graveyard e{};
entry.id = atoi(row[0]);
entry.zone_id = atoi(row[1]);
entry.x = static_cast<float>(atof(row[2]));
entry.y = static_cast<float>(atof(row[3]));
entry.z = static_cast<float>(atof(row[4]));
entry.heading = static_cast<float>(atof(row[5]));
e.id = atoi(row[0]);
e.zone_id = atoi(row[1]);
e.x = static_cast<float>(atof(row[2]));
e.y = static_cast<float>(atof(row[3]));
e.z = static_cast<float>(atof(row[4]));
e.heading = static_cast<float>(atof(row[5]));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, std::string where_filter)
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
@@ -341,6 +341,32 @@ public:
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_GRAVEYARD_REPOSITORY_H

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