mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 01:11:29 +00:00
Add tables to ignore list that do not follow typical table conventions
This commit is contained in:
parent
3aaa5020b1
commit
9e27ffacff
@ -35,15 +35,15 @@ public:
|
||||
int status;
|
||||
std::string ls_id;
|
||||
int lsaccount_id;
|
||||
int gmspeed;
|
||||
int revoked;
|
||||
int8 gmspeed;
|
||||
int8 revoked;
|
||||
int karma;
|
||||
std::string minilogin_ip;
|
||||
int hideme;
|
||||
int rulesflag;
|
||||
int8 hideme;
|
||||
int8 rulesflag;
|
||||
std::string suspendeduntil;
|
||||
int time_creation;
|
||||
int expansion;
|
||||
int8 expansion;
|
||||
std::string ban_reason;
|
||||
std::string suspend_reason;
|
||||
};
|
||||
@ -56,25 +56,25 @@ public:
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"id"
|
||||
"name"
|
||||
"charname"
|
||||
"sharedplat"
|
||||
"password"
|
||||
"status"
|
||||
"ls_id"
|
||||
"lsaccount_id"
|
||||
"gmspeed"
|
||||
"revoked"
|
||||
"karma"
|
||||
"minilogin_ip"
|
||||
"hideme"
|
||||
"rulesflag"
|
||||
"suspendeduntil"
|
||||
"time_creation"
|
||||
"expansion"
|
||||
"ban_reason"
|
||||
"suspend_reason"
|
||||
"id",
|
||||
"name",
|
||||
"charname",
|
||||
"sharedplat",
|
||||
"password",
|
||||
"status",
|
||||
"ls_id",
|
||||
"lsaccount_id",
|
||||
"gmspeed",
|
||||
"revoked",
|
||||
"karma",
|
||||
"minilogin_ip",
|
||||
"hideme",
|
||||
"rulesflag",
|
||||
"suspendeduntil",
|
||||
"time_creation",
|
||||
"expansion",
|
||||
"ban_reason",
|
||||
"suspend_reason",
|
||||
};
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ public:
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("{{TABLE_NAME}}");
|
||||
return std::string("account");
|
||||
}
|
||||
|
||||
static std::string BaseSelect()
|
||||
|
||||
@ -1,255 +0,0 @@
|
||||
/**
|
||||
* EQEmulator: Everquest Server Emulator
|
||||
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
* are required to give you total support for your newly bought product;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef EQEMU_CHARACTER_ENABLEDTASKS_REPOSITORY_H
|
||||
#define EQEMU_CHARACTER_ENABLEDTASKS_REPOSITORY_H
|
||||
|
||||
#include "../database.h"
|
||||
#include "../string_util.h"
|
||||
|
||||
class CharacterEnabledtasksRepository {
|
||||
public:
|
||||
struct CharacterEnabledtasks {
|
||||
int charid;
|
||||
int taskid;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("taskid");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"charid",
|
||||
"taskid",
|
||||
};
|
||||
}
|
||||
|
||||
static std::string ColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", Columns()));
|
||||
}
|
||||
|
||||
static std::string InsertColumnsRaw()
|
||||
{
|
||||
std::vector<std::string> insert_columns;
|
||||
|
||||
for (auto &column : Columns()) {
|
||||
if (column == PrimaryKey()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
insert_columns.push_back(column);
|
||||
}
|
||||
|
||||
return std::string(implode(", ", insert_columns));
|
||||
}
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("character_enabledtasks");
|
||||
}
|
||||
|
||||
static std::string BaseSelect()
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
static std::string BaseInsert()
|
||||
{
|
||||
return fmt::format(
|
||||
"INSERT INTO {} ({}) ",
|
||||
TableName(),
|
||||
InsertColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static CharacterEnabledtasks NewEntity()
|
||||
{
|
||||
CharacterEnabledtasks entry{};
|
||||
|
||||
entry.charid = 0;
|
||||
entry.taskid = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static CharacterEnabledtasks GetCharacterEnabledtasksEntry(
|
||||
const std::vector<CharacterEnabledtasks> &character_enabledtaskss,
|
||||
int character_enabledtasks_id
|
||||
)
|
||||
{
|
||||
for (auto &character_enabledtasks : character_enabledtaskss) {
|
||||
if (character_enabledtasks.taskid == character_enabledtasks_id) {
|
||||
return character_enabledtasks;
|
||||
}
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static CharacterEnabledtasks FindOne(
|
||||
int character_enabledtasks_id
|
||||
)
|
||||
{
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
character_enabledtasks_id
|
||||
)
|
||||
);
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
CharacterEnabledtasks entry{};
|
||||
|
||||
entry.charid = atoi(row[0]);
|
||||
entry.taskid = atoi(row[1]);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static int DeleteOne(
|
||||
int character_enabledtasks_id
|
||||
)
|
||||
{
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {} = {}",
|
||||
TableName(),
|
||||
PrimaryKey(),
|
||||
character_enabledtasks_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int UpdateOne(
|
||||
CharacterEnabledtasks character_enabledtasks_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
character_enabledtasks_entry.taskid
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static CharacterEnabledtasks InsertOne(
|
||||
CharacterEnabledtasks character_enabledtasks_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
implode(",", insert_values)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
character_enabledtasks_entry.id = results.LastInsertedID();
|
||||
return character_enabledtasks_entry;
|
||||
}
|
||||
|
||||
character_enabledtasks_entry = InstanceListRepository::NewEntity();
|
||||
|
||||
return character_enabledtasks_entry;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
std::vector<CharacterEnabledtasks> character_enabledtasks_entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &character_enabledtasks_entry: character_enabledtasks_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES {}",
|
||||
BaseInsert(),
|
||||
implode(",", insert_chunks)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static std::vector<CharacterEnabledtasks> All()
|
||||
{
|
||||
std::vector<CharacterEnabledtasks> all_entries;
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"{}",
|
||||
BaseSelect()
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
CharacterEnabledtasks entry{};
|
||||
|
||||
entry.charid = atoi(row[0]);
|
||||
entry.taskid = atoi(row[1]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_CHARACTER_ENABLEDTASKS_REPOSITORY_H
|
||||
@ -1,261 +0,0 @@
|
||||
/**
|
||||
* EQEmulator: Everquest Server Emulator
|
||||
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
* are required to give you total support for your newly bought product;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public 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_KEYRING_REPOSITORY_H
|
||||
#define EQEMU_KEYRING_REPOSITORY_H
|
||||
|
||||
#include "../database.h"
|
||||
#include "../string_util.h"
|
||||
|
||||
class KeyringRepository {
|
||||
public:
|
||||
struct Keyring {
|
||||
int char_id;
|
||||
int item_id;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"char_id",
|
||||
"item_id",
|
||||
};
|
||||
}
|
||||
|
||||
static std::string ColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", Columns()));
|
||||
}
|
||||
|
||||
static std::string InsertColumnsRaw()
|
||||
{
|
||||
std::vector<std::string> insert_columns;
|
||||
|
||||
for (auto &column : Columns()) {
|
||||
if (column == PrimaryKey()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
insert_columns.push_back(column);
|
||||
}
|
||||
|
||||
return std::string(implode(", ", insert_columns));
|
||||
}
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("keyring");
|
||||
}
|
||||
|
||||
static std::string BaseSelect()
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
static std::string BaseInsert()
|
||||
{
|
||||
return fmt::format(
|
||||
"INSERT INTO {} ({}) ",
|
||||
TableName(),
|
||||
InsertColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static Keyring NewEntity()
|
||||
{
|
||||
Keyring entry{};
|
||||
|
||||
entry.char_id = 0;
|
||||
entry.item_id = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static Keyring GetKeyringEntry(
|
||||
const std::vector<Keyring> &keyrings,
|
||||
int keyring_id
|
||||
)
|
||||
{
|
||||
for (auto &keyring : keyrings) {
|
||||
if (keyring.== keyring_id) {
|
||||
return keyring;
|
||||
}
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static Keyring FindOne(
|
||||
int keyring_id
|
||||
)
|
||||
{
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
keyring_id
|
||||
)
|
||||
);
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
Keyring entry{};
|
||||
|
||||
entry.char_id = atoi(row[0]);
|
||||
entry.item_id = atoi(row[1]);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static int DeleteOne(
|
||||
int keyring_id
|
||||
)
|
||||
{
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {} = {}",
|
||||
TableName(),
|
||||
PrimaryKey(),
|
||||
keyring_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int UpdateOne(
|
||||
Keyring keyring_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[0] + " = " + std::to_string(keyring_entry.char_id));
|
||||
update_values.push_back(columns[1] + " = " + std::to_string(keyring_entry.item_id));
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
keyring_entry.
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static Keyring InsertOne(
|
||||
Keyring keyring_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(keyring_entry.char_id));
|
||||
insert_values.push_back(std::to_string(keyring_entry.item_id));
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
implode(",", insert_values)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
keyring_entry.id = results.LastInsertedID();
|
||||
return keyring_entry;
|
||||
}
|
||||
|
||||
keyring_entry = InstanceListRepository::NewEntity();
|
||||
|
||||
return keyring_entry;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
std::vector<Keyring> keyring_entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &keyring_entry: keyring_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(keyring_entry.char_id));
|
||||
insert_values.push_back(std::to_string(keyring_entry.item_id));
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES {}",
|
||||
BaseInsert(),
|
||||
implode(",", insert_chunks)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static std::vector<Keyring> All()
|
||||
{
|
||||
std::vector<Keyring> all_entries;
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"{}",
|
||||
BaseSelect()
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Keyring entry{};
|
||||
|
||||
entry.char_id = atoi(row[0]);
|
||||
entry.item_id = atoi(row[1]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_KEYRING_REPOSITORY_H
|
||||
@ -1,253 +0,0 @@
|
||||
/**
|
||||
* EQEmulator: Everquest Server Emulator
|
||||
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
* are required to give you total support for your newly bought product;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public 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_PROFANITY_LIST_REPOSITORY_H
|
||||
#define EQEMU_PROFANITY_LIST_REPOSITORY_H
|
||||
|
||||
#include "../database.h"
|
||||
#include "../string_util.h"
|
||||
|
||||
class ProfanityListRepository {
|
||||
public:
|
||||
struct ProfanityList {
|
||||
std::string word;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"word",
|
||||
};
|
||||
}
|
||||
|
||||
static std::string ColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", Columns()));
|
||||
}
|
||||
|
||||
static std::string InsertColumnsRaw()
|
||||
{
|
||||
std::vector<std::string> insert_columns;
|
||||
|
||||
for (auto &column : Columns()) {
|
||||
if (column == PrimaryKey()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
insert_columns.push_back(column);
|
||||
}
|
||||
|
||||
return std::string(implode(", ", insert_columns));
|
||||
}
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("profanity_list");
|
||||
}
|
||||
|
||||
static std::string BaseSelect()
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
static std::string BaseInsert()
|
||||
{
|
||||
return fmt::format(
|
||||
"INSERT INTO {} ({}) ",
|
||||
TableName(),
|
||||
InsertColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static ProfanityList NewEntity()
|
||||
{
|
||||
ProfanityList entry{};
|
||||
|
||||
entry.word = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static ProfanityList GetProfanityListEntry(
|
||||
const std::vector<ProfanityList> &profanity_lists,
|
||||
int profanity_list_id
|
||||
)
|
||||
{
|
||||
for (auto &profanity_list : profanity_lists) {
|
||||
if (profanity_list.== profanity_list_id) {
|
||||
return profanity_list;
|
||||
}
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static ProfanityList FindOne(
|
||||
int profanity_list_id
|
||||
)
|
||||
{
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
profanity_list_id
|
||||
)
|
||||
);
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
ProfanityList entry{};
|
||||
|
||||
entry.word = row[0];
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static int DeleteOne(
|
||||
int profanity_list_id
|
||||
)
|
||||
{
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {} = {}",
|
||||
TableName(),
|
||||
PrimaryKey(),
|
||||
profanity_list_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int UpdateOne(
|
||||
ProfanityList profanity_list_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[0] + " = '" + EscapeString(profanity_list_entry.word) + "'");
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
profanity_list_entry.
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static ProfanityList InsertOne(
|
||||
ProfanityList profanity_list_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back("'" + EscapeString(profanity_list_entry.word) + "'");
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
implode(",", insert_values)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
profanity_list_entry.id = results.LastInsertedID();
|
||||
return profanity_list_entry;
|
||||
}
|
||||
|
||||
profanity_list_entry = InstanceListRepository::NewEntity();
|
||||
|
||||
return profanity_list_entry;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
std::vector<ProfanityList> profanity_list_entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &profanity_list_entry: profanity_list_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back("'" + EscapeString(profanity_list_entry.word) + "'");
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES {}",
|
||||
BaseInsert(),
|
||||
implode(",", insert_chunks)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static std::vector<ProfanityList> All()
|
||||
{
|
||||
std::vector<ProfanityList> all_entries;
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"{}",
|
||||
BaseSelect()
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
ProfanityList entry{};
|
||||
|
||||
entry.word = row[0];
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_PROFANITY_LIST_REPOSITORY_H
|
||||
@ -1,255 +0,0 @@
|
||||
/**
|
||||
* EQEmulator: Everquest Server Emulator
|
||||
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
* are required to give you total support for your newly bought product;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef EQEMU_ZONE_FLAGS_REPOSITORY_H
|
||||
#define EQEMU_ZONE_FLAGS_REPOSITORY_H
|
||||
|
||||
#include "../database.h"
|
||||
#include "../string_util.h"
|
||||
|
||||
class ZoneFlagsRepository {
|
||||
public:
|
||||
struct ZoneFlags {
|
||||
int charID;
|
||||
int zoneID;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("zoneID");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"charID",
|
||||
"zoneID",
|
||||
};
|
||||
}
|
||||
|
||||
static std::string ColumnsRaw()
|
||||
{
|
||||
return std::string(implode(", ", Columns()));
|
||||
}
|
||||
|
||||
static std::string InsertColumnsRaw()
|
||||
{
|
||||
std::vector<std::string> insert_columns;
|
||||
|
||||
for (auto &column : Columns()) {
|
||||
if (column == PrimaryKey()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
insert_columns.push_back(column);
|
||||
}
|
||||
|
||||
return std::string(implode(", ", insert_columns));
|
||||
}
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("zone_flags");
|
||||
}
|
||||
|
||||
static std::string BaseSelect()
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
static std::string BaseInsert()
|
||||
{
|
||||
return fmt::format(
|
||||
"INSERT INTO {} ({}) ",
|
||||
TableName(),
|
||||
InsertColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static ZoneFlags NewEntity()
|
||||
{
|
||||
ZoneFlags entry{};
|
||||
|
||||
entry.charID = 0;
|
||||
entry.zoneID = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static ZoneFlags GetZoneFlagsEntry(
|
||||
const std::vector<ZoneFlags> &zone_flagss,
|
||||
int zone_flags_id
|
||||
)
|
||||
{
|
||||
for (auto &zone_flags : zone_flagss) {
|
||||
if (zone_flags.zoneID == zone_flags_id) {
|
||||
return zone_flags;
|
||||
}
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static ZoneFlags FindOne(
|
||||
int zone_flags_id
|
||||
)
|
||||
{
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
zone_flags_id
|
||||
)
|
||||
);
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
ZoneFlags entry{};
|
||||
|
||||
entry.charID = atoi(row[0]);
|
||||
entry.zoneID = atoi(row[1]);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static int DeleteOne(
|
||||
int zone_flags_id
|
||||
)
|
||||
{
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {} = {}",
|
||||
TableName(),
|
||||
PrimaryKey(),
|
||||
zone_flags_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int UpdateOne(
|
||||
ZoneFlags zone_flags_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
zone_flags_entry.zoneID
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static ZoneFlags InsertOne(
|
||||
ZoneFlags zone_flags_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
implode(",", insert_values)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
zone_flags_entry.id = results.LastInsertedID();
|
||||
return zone_flags_entry;
|
||||
}
|
||||
|
||||
zone_flags_entry = InstanceListRepository::NewEntity();
|
||||
|
||||
return zone_flags_entry;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
std::vector<ZoneFlags> zone_flags_entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &zone_flags_entry: zone_flags_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES {}",
|
||||
BaseInsert(),
|
||||
implode(",", insert_chunks)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static std::vector<ZoneFlags> All()
|
||||
{
|
||||
std::vector<ZoneFlags> all_entries;
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"{}",
|
||||
BaseSelect()
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
ZoneFlags entry{};
|
||||
|
||||
entry.charID = atoi(row[0]);
|
||||
entry.zoneID = atoi(row[1]);
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //EQEMU_ZONE_FLAGS_REPOSITORY_H
|
||||
@ -114,12 +114,25 @@ foreach my $table_to_generate (@tables) {
|
||||
"login_tables",
|
||||
);
|
||||
|
||||
# These tables don't have a typical schema
|
||||
my @table_ignore_list = (
|
||||
"character_enabledtasks",
|
||||
"keyring",
|
||||
"profanity_list",
|
||||
"zone_flags",
|
||||
);
|
||||
|
||||
foreach my $category (@categories) {
|
||||
if ($table_to_generate ~~ $database_schema->{$category}) {
|
||||
$table_found_in_schema = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($table_to_generate ~~ @table_ignore_list) {
|
||||
print "Table [$table_to_generate] is on ignore list... skipping...\n";
|
||||
$table_found_in_schema = 0;
|
||||
}
|
||||
|
||||
if ($table_found_in_schema == 0) {
|
||||
print "Table [$table_to_generate] not found in schema, skipping\n";
|
||||
next;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user