[Repositories] Update repositories (#2040)

This commit is contained in:
Chris Miles 2022-03-11 15:27:36 -08:00 committed by GitHub
parent f22608a43a
commit 3ed6663c4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
170 changed files with 5543 additions and 511 deletions

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseAaAbilityRepository {
public:
@ -59,11 +60,36 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"name",
"category",
"classes",
"races",
"drakkin_heritage",
"deities",
"status",
"type",
"charges",
"grant_only",
"first_rank_id",
"enabled",
"reset_on_death",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("aa_ability");
@ -73,7 +99,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseAaRankEffectsRepository {
public:
@ -41,11 +42,27 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"rank_id",
"slot",
"effect_id",
"base1",
"base2",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("aa_rank_effects");
@ -55,7 +72,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseAaRankPrereqsRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"rank_id",
"aa_id",
"points",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("aa_rank_prereqs");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseAaRanksRepository {
public:
@ -57,11 +58,35 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"upper_hotkey_sid",
"lower_hotkey_sid",
"title_sid",
"desc_sid",
"cost",
"level_req",
"spell",
"spell_type",
"recast_time",
"expansion",
"prev_id",
"next_id",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("aa_ranks");
@ -71,7 +96,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseAccountFlagsRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"p_accid",
"p_flag",
"p_value",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("account_flags");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseAccountIpRepository {
public:
@ -39,11 +40,26 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"accid",
"ip",
"count",
"lastused",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("account_ip");
@ -53,7 +69,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@ -74,7 +90,7 @@ public:
entry.accid = 0;
entry.ip = "";
entry.count = 1;
entry.lastused = "";
entry.lastused = std::time(nullptr);
return entry;
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseAccountRewardsRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"account_id",
"reward_id",
"amount",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("account_rewards");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseAdventureDetailsRepository {
public:
@ -49,11 +50,31 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"adventure_id",
"instance_id",
"count",
"assassinate_count",
"status",
"time_created",
"time_zoned",
"time_completed",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("adventure_details");
@ -63,7 +84,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseAdventureMembersRepository {
public:
@ -35,11 +36,24 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"charid",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("adventure_members");
@ -49,7 +63,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseAdventureStatsRepository {
public:
@ -53,11 +54,33 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"player_id",
"guk_wins",
"mir_wins",
"mmc_wins",
"ruj_wins",
"tak_wins",
"guk_losses",
"mir_losses",
"mmc_losses",
"ruj_losses",
"tak_losses",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("adventure_stats");
@ -67,7 +90,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseAdventureTemplateEntryFlavorRepository {
public:
@ -35,11 +36,24 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"text",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("adventure_template_entry_flavor");
@ -49,7 +63,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseAdventureTemplateEntryRepository {
public:
@ -35,11 +36,24 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"template_id",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("adventure_template_entry");
@ -49,7 +63,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseAdventureTemplateRepository {
public:
@ -97,11 +98,55 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"zone",
"zone_version",
"is_hard",
"is_raid",
"min_level",
"max_level",
"type",
"type_data",
"type_count",
"assa_x",
"assa_y",
"assa_z",
"assa_h",
"text",
"duration",
"zone_in_time",
"win_points",
"lose_points",
"theme",
"zone_in_zone_id",
"zone_in_x",
"zone_in_y",
"zone_in_object_id",
"dest_x",
"dest_y",
"dest_z",
"dest_h",
"graveyard_zone_id",
"graveyard_x",
"graveyard_y",
"graveyard_z",
"graveyard_radius",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("adventure_template");
@ -111,7 +156,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@ -148,7 +193,7 @@ public:
entry.zone_in_time = 1800;
entry.win_points = 0;
entry.lose_points = 0;
entry.theme = LDoNThemes::GUK;
entry.theme = 1;
entry.zone_in_zone_id = 0;
entry.zone_in_x = 0;
entry.zone_in_y = 0;

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseAlternateCurrencyRepository {
public:
@ -35,11 +36,24 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"item_id",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("alternate_currency");
@ -49,7 +63,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseAurasRepository {
public:
@ -53,11 +54,33 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"type",
"npc_type",
"name",
"spell_id",
"distance",
"aura_type",
"spawn_type",
"movement",
"duration",
"icon",
"cast_time",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("auras");
@ -67,7 +90,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseBaseDataRepository {
public:
@ -51,11 +52,32 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"level",
"`class`",
"hp",
"mana",
"end",
"unk1",
"unk2",
"hp_fac",
"mana_fac",
"end_fac",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("base_data");
@ -65,7 +87,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseBlockedSpellsRepository {
public:
@ -55,11 +56,34 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"spellid",
"type",
"zoneid",
"x",
"y",
"z",
"x_diff",
"y_diff",
"z_diff",
"message",
"description",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("blocked_spells");
@ -69,7 +93,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -0,0 +1,326 @@
/**
* 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_BOOKS_REPOSITORY_H
#define EQEMU_BASE_BOOKS_REPOSITORY_H
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseBooksRepository {
public:
struct Books {
int id;
std::string name;
std::string txtfile;
int language;
};
static std::string PrimaryKey()
{
return std::string("id");
}
static std::vector<std::string> Columns()
{
return {
"id",
"name",
"txtfile",
"language",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"name",
"txtfile",
"language",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("books");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static Books NewEntity()
{
Books entry{};
entry.id = 0;
entry.name = "";
entry.txtfile = "";
entry.language = 0;
return entry;
}
static Books GetBooksEntry(
const std::vector<Books> &bookss,
int books_id
)
{
for (auto &books : bookss) {
if (books.id == books_id) {
return books;
}
}
return NewEntity();
}
static Books FindOne(
Database& db,
int books_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
books_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
Books entry{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.txtfile = row[2] ? row[2] : "";
entry.language = atoi(row[3]);
return entry;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int books_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
books_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
Books books_entry
)
{
std::vector<std::string> update_values;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + EscapeString(books_entry.name) + "'");
update_values.push_back(columns[2] + " = '" + EscapeString(books_entry.txtfile) + "'");
update_values.push_back(columns[3] + " = " + std::to_string(books_entry.language));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
books_entry.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static Books InsertOne(
Database& db,
Books books_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(books_entry.id));
insert_values.push_back("'" + EscapeString(books_entry.name) + "'");
insert_values.push_back("'" + EscapeString(books_entry.txtfile) + "'");
insert_values.push_back(std::to_string(books_entry.language));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
books_entry.id = results.LastInsertedID();
return books_entry;
}
books_entry = NewEntity();
return books_entry;
}
static int InsertMany(
Database& db,
std::vector<Books> books_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &books_entry: books_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(books_entry.id));
insert_values.push_back("'" + EscapeString(books_entry.name) + "'");
insert_values.push_back("'" + EscapeString(books_entry.txtfile) + "'");
insert_values.push_back(std::to_string(books_entry.language));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Books> All(Database& db)
{
std::vector<Books> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Books entry{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.txtfile = row[2] ? row[2] : "";
entry.language = atoi(row[3]);
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<Books> GetWhere(Database& db, std::string where_filter)
{
std::vector<Books> 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) {
Books entry{};
entry.id = atoi(row[0]);
entry.name = row[1] ? row[1] : "";
entry.txtfile = row[2] ? row[2] : "";
entry.language = atoi(row[3]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(Database& db, 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);
}
};
#endif //EQEMU_BASE_BOOKS_REPOSITORY_H

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseBugReportsRepository {
public:
@ -45,9 +46,9 @@ public:
int _unknown_value;
std::string bug_report;
std::string system_info;
std::string report_datetime;
time_t report_datetime;
int bug_status;
std::string last_review;
time_t last_review;
std::string last_reviewer;
std::string reviewer_notes;
};
@ -95,11 +96,54 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"zone",
"client_version_id",
"client_version_name",
"account_id",
"character_id",
"character_name",
"reporter_spoof",
"category_id",
"category_name",
"reporter_name",
"ui_path",
"pos_x",
"pos_y",
"pos_z",
"heading",
"time_played",
"target_id",
"target_name",
"optional_info_mask",
"_can_duplicate",
"_crash_bug",
"_target_info",
"_character_flags",
"_unknown_value",
"bug_report",
"system_info",
"UNIX_TIMESTAMP(report_datetime)",
"bug_status",
"UNIX_TIMESTAMP(last_review)",
"last_reviewer",
"reviewer_notes",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("bug_reports");
@ -109,7 +153,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@ -154,9 +198,9 @@ public:
entry._unknown_value = 0;
entry.bug_report = "";
entry.system_info = "";
entry.report_datetime = "";
entry.report_datetime = std::time(nullptr);
entry.bug_status = 0;
entry.last_review = "";
entry.last_review = std::time(nullptr);
entry.last_reviewer = "None";
entry.reviewer_notes = "";
@ -221,9 +265,9 @@ public:
entry._unknown_value = atoi(row[24]);
entry.bug_report = row[25] ? row[25] : "";
entry.system_info = row[26] ? row[26] : "";
entry.report_datetime = row[27] ? row[27] : "";
entry.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10);
entry.bug_status = atoi(row[28]);
entry.last_review = row[29] ? row[29] : "";
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] : "";
@ -285,9 +329,9 @@ public:
update_values.push_back(columns[24] + " = " + std::to_string(bug_reports_entry._unknown_value));
update_values.push_back(columns[25] + " = '" + EscapeString(bug_reports_entry.bug_report) + "'");
update_values.push_back(columns[26] + " = '" + EscapeString(bug_reports_entry.system_info) + "'");
update_values.push_back(columns[27] + " = '" + EscapeString(bug_reports_entry.report_datetime) + "'");
update_values.push_back(columns[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] + " = '" + EscapeString(bug_reports_entry.last_review) + "'");
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] + " = '" + EscapeString(bug_reports_entry.last_reviewer) + "'");
update_values.push_back(columns[31] + " = '" + EscapeString(bug_reports_entry.reviewer_notes) + "'");
@ -338,9 +382,9 @@ public:
insert_values.push_back(std::to_string(bug_reports_entry._unknown_value));
insert_values.push_back("'" + EscapeString(bug_reports_entry.bug_report) + "'");
insert_values.push_back("'" + EscapeString(bug_reports_entry.system_info) + "'");
insert_values.push_back("'" + EscapeString(bug_reports_entry.report_datetime) + "'");
insert_values.push_back("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("'" + EscapeString(bug_reports_entry.last_review) + "'");
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("'" + EscapeString(bug_reports_entry.last_reviewer) + "'");
insert_values.push_back("'" + EscapeString(bug_reports_entry.reviewer_notes) + "'");
@ -399,9 +443,9 @@ public:
insert_values.push_back(std::to_string(bug_reports_entry._unknown_value));
insert_values.push_back("'" + EscapeString(bug_reports_entry.bug_report) + "'");
insert_values.push_back("'" + EscapeString(bug_reports_entry.system_info) + "'");
insert_values.push_back("'" + EscapeString(bug_reports_entry.report_datetime) + "'");
insert_values.push_back("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("'" + EscapeString(bug_reports_entry.last_review) + "'");
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("'" + EscapeString(bug_reports_entry.last_reviewer) + "'");
insert_values.push_back("'" + EscapeString(bug_reports_entry.reviewer_notes) + "'");
@ -464,9 +508,9 @@ public:
entry._unknown_value = atoi(row[24]);
entry.bug_report = row[25] ? row[25] : "";
entry.system_info = row[26] ? row[26] : "";
entry.report_datetime = row[27] ? row[27] : "";
entry.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10);
entry.bug_status = atoi(row[28]);
entry.last_review = row[29] ? row[29] : "";
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] : "";
@ -520,9 +564,9 @@ public:
entry._unknown_value = atoi(row[24]);
entry.bug_report = row[25] ? row[25] : "";
entry.system_info = row[26] ? row[26] : "";
entry.report_datetime = row[27] ? row[27] : "";
entry.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10);
entry.bug_status = atoi(row[28]);
entry.last_review = row[29] ? row[29] : "";
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] : "";

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseBugsRepository {
public:
@ -57,11 +58,35 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"zone",
"name",
"ui",
"x",
"y",
"z",
"type",
"flag",
"target",
"bug",
"date",
"status",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("bugs");
@ -71,7 +96,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseBuyerRepository {
public:
@ -43,11 +44,28 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"charid",
"buyslot",
"itemid",
"itemname",
"quantity",
"price",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("buyer");
@ -57,7 +75,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharCreateCombinationsRepository {
public:
@ -43,11 +44,28 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"allocation_id",
"race",
"`class`",
"deity",
"start_zone",
"expansions_req",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("char_create_combinations");
@ -57,7 +75,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharCreatePointAllocationsRepository {
public:
@ -61,11 +62,37 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"base_str",
"base_sta",
"base_dex",
"base_agi",
"base_int",
"base_wis",
"base_cha",
"alloc_str",
"alloc_sta",
"alloc_dex",
"alloc_agi",
"alloc_int",
"alloc_wis",
"alloc_cha",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("char_create_point_allocations");
@ -75,7 +102,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharRecipeListRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"char_id",
"recipe_id",
"madecount",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("char_recipe_list");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterActivitiesRepository {
public:
@ -41,11 +42,27 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"charid",
"taskid",
"activityid",
"donecount",
"completed",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_activities");
@ -55,7 +72,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterAltCurrencyRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"char_id",
"currency_id",
"amount",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_alt_currency");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterAlternateAbilitiesRepository {
public:
@ -39,11 +40,26 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"aa_id",
"aa_value",
"charges",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_alternate_abilities");
@ -53,7 +69,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterAurasRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"slot",
"spell_id",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_auras");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterBandolierRepository {
public:
@ -43,11 +44,28 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"bandolier_id",
"bandolier_slot",
"item_id",
"icon",
"bandolier_name",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_bandolier");
@ -57,7 +75,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterBindRepository {
public:
@ -47,11 +48,30 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"slot",
"zone_id",
"instance_id",
"x",
"y",
"z",
"heading",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_bind");
@ -61,7 +81,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterBuffsRepository {
public:
@ -65,11 +66,39 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"character_id",
"slot_id",
"spell_id",
"caster_level",
"caster_name",
"ticsremaining",
"counters",
"numhits",
"melee_rune",
"magic_rune",
"persistent",
"dot_rune",
"caston_x",
"caston_y",
"caston_z",
"ExtraDIChance",
"instrument_mod",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_buffs");
@ -79,7 +108,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterCorpseItemsRepository {
public:
@ -53,11 +54,33 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"corpse_id",
"equip_slot",
"item_id",
"charges",
"aug_1",
"aug_2",
"aug_3",
"aug_4",
"aug_5",
"aug_6",
"attuned",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_corpse_items");
@ -67,7 +90,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterCorpsesRepository {
public:
@ -27,7 +28,7 @@ public:
float y;
float z;
float heading;
std::string time_of_death;
time_t time_of_death;
int guild_consent_id;
int is_rezzed;
int is_buried;
@ -125,11 +126,69 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"charid",
"charname",
"zone_id",
"instance_id",
"x",
"y",
"z",
"heading",
"UNIX_TIMESTAMP(time_of_death)",
"guild_consent_id",
"is_rezzed",
"is_buried",
"was_at_graveyard",
"is_locked",
"exp",
"size",
"level",
"race",
"gender",
"`class`",
"deity",
"texture",
"helm_texture",
"copper",
"silver",
"gold",
"platinum",
"hair_color",
"beard_color",
"eye_color_1",
"eye_color_2",
"hair_style",
"face",
"beard",
"drakkin_heritage",
"drakkin_tattoo",
"drakkin_details",
"wc_1",
"wc_2",
"wc_3",
"wc_4",
"wc_5",
"wc_6",
"wc_7",
"wc_8",
"wc_9",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_corpses");
@ -139,7 +198,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@ -166,7 +225,7 @@ public:
entry.y = 0;
entry.z = 0;
entry.heading = 0;
entry.time_of_death = "0000-00-00 00:00:00";
entry.time_of_death = 0;
entry.guild_consent_id = 0;
entry.is_rezzed = 0;
entry.is_buried = 0;
@ -248,7 +307,7 @@ public:
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 = row[9] ? row[9] : "";
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]);
@ -327,7 +386,7 @@ public:
update_values.push_back(columns[6] + " = " + std::to_string(character_corpses_entry.y));
update_values.push_back(columns[7] + " = " + std::to_string(character_corpses_entry.z));
update_values.push_back(columns[8] + " = " + std::to_string(character_corpses_entry.heading));
update_values.push_back(columns[9] + " = '" + EscapeString(character_corpses_entry.time_of_death) + "'");
update_values.push_back(columns[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));
@ -395,7 +454,7 @@ public:
insert_values.push_back(std::to_string(character_corpses_entry.y));
insert_values.push_back(std::to_string(character_corpses_entry.z));
insert_values.push_back(std::to_string(character_corpses_entry.heading));
insert_values.push_back("'" + EscapeString(character_corpses_entry.time_of_death) + "'");
insert_values.push_back("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));
@ -471,7 +530,7 @@ public:
insert_values.push_back(std::to_string(character_corpses_entry.y));
insert_values.push_back(std::to_string(character_corpses_entry.z));
insert_values.push_back(std::to_string(character_corpses_entry.heading));
insert_values.push_back("'" + EscapeString(character_corpses_entry.time_of_death) + "'");
insert_values.push_back("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));
@ -551,7 +610,7 @@ public:
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 = row[9] ? row[9] : "";
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]);
@ -622,7 +681,7 @@ public:
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 = row[9] ? row[9] : "";
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]);

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterCurrencyRepository {
public:
@ -65,11 +66,39 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"platinum",
"gold",
"silver",
"copper",
"platinum_bank",
"gold_bank",
"silver_bank",
"copper_bank",
"platinum_cursor",
"gold_cursor",
"silver_cursor",
"copper_cursor",
"radiant_crystals",
"career_radiant_crystals",
"ebon_crystals",
"career_ebon_crystals",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_currency");
@ -79,7 +108,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterDataRepository {
public:
@ -119,7 +120,7 @@ public:
int aa_points_spent_old;
int aa_points_old;
int e_last_invsnapshot;
std::string deleted_at;
time_t deleted_at;
};
static std::string PrimaryKey()
@ -235,11 +236,124 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"account_id",
"name",
"last_name",
"title",
"suffix",
"zone_id",
"zone_instance",
"y",
"x",
"z",
"heading",
"gender",
"race",
"`class`",
"level",
"deity",
"birthday",
"last_login",
"time_played",
"level2",
"anon",
"gm",
"face",
"hair_color",
"hair_style",
"beard",
"beard_color",
"eye_color_1",
"eye_color_2",
"drakkin_heritage",
"drakkin_tattoo",
"drakkin_details",
"ability_time_seconds",
"ability_number",
"ability_time_minutes",
"ability_time_hours",
"exp",
"aa_points_spent",
"aa_exp",
"aa_points",
"group_leadership_exp",
"raid_leadership_exp",
"group_leadership_points",
"raid_leadership_points",
"points",
"cur_hp",
"mana",
"endurance",
"intoxication",
"str",
"sta",
"cha",
"dex",
"`int`",
"agi",
"wis",
"zone_change_count",
"toxicity",
"hunger_level",
"thirst_level",
"ability_up",
"ldon_points_guk",
"ldon_points_mir",
"ldon_points_mmc",
"ldon_points_ruj",
"ldon_points_tak",
"ldon_points_available",
"tribute_time_remaining",
"career_tribute_points",
"tribute_points",
"tribute_active",
"pvp_status",
"pvp_kills",
"pvp_deaths",
"pvp_current_points",
"pvp_career_points",
"pvp_best_kill_streak",
"pvp_worst_death_streak",
"pvp_current_kill_streak",
"pvp2",
"pvp_type",
"show_helm",
"group_auto_consent",
"raid_auto_consent",
"guild_auto_consent",
"leadership_exp_on",
"RestTimer",
"air_remaining",
"autosplit_enabled",
"lfp",
"lfg",
"mailkey",
"xtargets",
"firstlogon",
"e_aa_effects",
"e_percent_to_aa",
"e_expended_aa_spent",
"aa_points_spent_old",
"aa_points_old",
"e_last_invsnapshot",
"UNIX_TIMESTAMP(deleted_at)",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_data");
@ -249,7 +363,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@ -368,7 +482,7 @@ public:
entry.aa_points_spent_old = 0;
entry.aa_points_old = 0;
entry.e_last_invsnapshot = 0;
entry.deleted_at = "";
entry.deleted_at = 0;
return entry;
}
@ -505,7 +619,7 @@ public:
entry.aa_points_spent_old = atoi(row[98]);
entry.aa_points_old = atoi(row[99]);
entry.e_last_invsnapshot = atoi(row[100]);
entry.deleted_at = row[101] ? row[101] : "";
entry.deleted_at = strtoll(row[101] ? row[101] : "-1", nullptr, 10);
return entry;
}
@ -639,7 +753,7 @@ public:
update_values.push_back(columns[98] + " = " + std::to_string(character_data_entry.aa_points_spent_old));
update_values.push_back(columns[99] + " = " + std::to_string(character_data_entry.aa_points_old));
update_values.push_back(columns[100] + " = " + std::to_string(character_data_entry.e_last_invsnapshot));
update_values.push_back(columns[101] + " = '" + EscapeString(character_data_entry.deleted_at) + "'");
update_values.push_back(columns[101] + " = FROM_UNIXTIME(" + (character_data_entry.deleted_at > 0 ? std::to_string(character_data_entry.deleted_at) : "null") + ")");
auto results = db.QueryDatabase(
fmt::format(
@ -762,7 +876,7 @@ public:
insert_values.push_back(std::to_string(character_data_entry.aa_points_spent_old));
insert_values.push_back(std::to_string(character_data_entry.aa_points_old));
insert_values.push_back(std::to_string(character_data_entry.e_last_invsnapshot));
insert_values.push_back("'" + EscapeString(character_data_entry.deleted_at) + "'");
insert_values.push_back("FROM_UNIXTIME(" + (character_data_entry.deleted_at > 0 ? std::to_string(character_data_entry.deleted_at) : "null") + ")");
auto results = db.QueryDatabase(
fmt::format(
@ -893,7 +1007,7 @@ public:
insert_values.push_back(std::to_string(character_data_entry.aa_points_spent_old));
insert_values.push_back(std::to_string(character_data_entry.aa_points_old));
insert_values.push_back(std::to_string(character_data_entry.e_last_invsnapshot));
insert_values.push_back("'" + EscapeString(character_data_entry.deleted_at) + "'");
insert_values.push_back("FROM_UNIXTIME(" + (character_data_entry.deleted_at > 0 ? std::to_string(character_data_entry.deleted_at) : "null") + ")");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
@ -1028,7 +1142,7 @@ public:
entry.aa_points_spent_old = atoi(row[98]);
entry.aa_points_old = atoi(row[99]);
entry.e_last_invsnapshot = atoi(row[100]);
entry.deleted_at = row[101] ? row[101] : "";
entry.deleted_at = strtoll(row[101] ? row[101] : "-1", nullptr, 10);
all_entries.push_back(entry);
}
@ -1154,7 +1268,7 @@ public:
entry.aa_points_spent_old = atoi(row[98]);
entry.aa_points_old = atoi(row[99]);
entry.e_last_invsnapshot = atoi(row[100]);
entry.deleted_at = row[101] ? row[101] : "";
entry.deleted_at = strtoll(row[101] ? row[101] : "-1", nullptr, 10);
all_entries.push_back(entry);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterDisciplinesRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"slot_id",
"disc_id",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_disciplines");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -0,0 +1,327 @@
/**
* 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_EXP_MODIFIERS_REPOSITORY_H
#define EQEMU_BASE_CHARACTER_EXP_MODIFIERS_REPOSITORY_H
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterExpModifiersRepository {
public:
struct CharacterExpModifiers {
int character_id;
int zone_id;
float aa_modifier;
float exp_modifier;
};
static std::string PrimaryKey()
{
return std::string("character_id");
}
static std::vector<std::string> Columns()
{
return {
"character_id",
"zone_id",
"aa_modifier",
"exp_modifier",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"character_id",
"zone_id",
"aa_modifier",
"exp_modifier",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_exp_modifiers");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static CharacterExpModifiers NewEntity()
{
CharacterExpModifiers entry{};
entry.character_id = 0;
entry.zone_id = 0;
entry.aa_modifier = 0;
entry.exp_modifier = 0;
return entry;
}
static CharacterExpModifiers GetCharacterExpModifiersEntry(
const std::vector<CharacterExpModifiers> &character_exp_modifierss,
int character_exp_modifiers_id
)
{
for (auto &character_exp_modifiers : character_exp_modifierss) {
if (character_exp_modifiers.character_id == character_exp_modifiers_id) {
return character_exp_modifiers;
}
}
return NewEntity();
}
static CharacterExpModifiers FindOne(
Database& db,
int character_exp_modifiers_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
character_exp_modifiers_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
CharacterExpModifiers entry{};
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]));
return entry;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int character_exp_modifiers_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
character_exp_modifiers_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
CharacterExpModifiers character_exp_modifiers_entry
)
{
std::vector<std::string> update_values;
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));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
character_exp_modifiers_entry.character_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static CharacterExpModifiers InsertOne(
Database& db,
CharacterExpModifiers character_exp_modifiers_entry
)
{
std::vector<std::string> insert_values;
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));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
implode(",", insert_values)
)
);
if (results.Success()) {
character_exp_modifiers_entry.character_id = results.LastInsertedID();
return character_exp_modifiers_entry;
}
character_exp_modifiers_entry = NewEntity();
return character_exp_modifiers_entry;
}
static int InsertMany(
Database& db,
std::vector<CharacterExpModifiers> character_exp_modifiers_entries
)
{
std::vector<std::string> insert_chunks;
for (auto &character_exp_modifiers_entry: character_exp_modifiers_entries) {
std::vector<std::string> insert_values;
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));
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
std::vector<std::string> insert_values;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterExpModifiers> All(Database& db)
{
std::vector<CharacterExpModifiers> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
CharacterExpModifiers entry{};
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]));
all_entries.push_back(entry);
}
return all_entries;
}
static std::vector<CharacterExpModifiers> GetWhere(Database& db, std::string where_filter)
{
std::vector<CharacterExpModifiers> 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) {
CharacterExpModifiers entry{};
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]));
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(Database& db, 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);
}
};
#endif //EQEMU_BASE_CHARACTER_EXP_MODIFIERS_REPOSITORY_H

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterExpeditionLockoutsRepository {
public:
@ -22,7 +23,7 @@ public:
int character_id;
std::string expedition_name;
std::string event_name;
std::string expire_time;
time_t expire_time;
int duration;
std::string from_expedition_uuid;
};
@ -45,11 +46,29 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"character_id",
"expedition_name",
"event_name",
"UNIX_TIMESTAMP(expire_time)",
"duration",
"from_expedition_uuid",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_expedition_lockouts");
@ -59,7 +78,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@ -81,7 +100,7 @@ public:
entry.character_id = 0;
entry.expedition_name = "";
entry.event_name = "";
entry.expire_time = "";
entry.expire_time = std::time(nullptr);
entry.duration = 0;
entry.from_expedition_uuid = "";
@ -123,7 +142,7 @@ public:
entry.character_id = atoi(row[1]);
entry.expedition_name = row[2] ? row[2] : "";
entry.event_name = row[3] ? row[3] : "";
entry.expire_time = row[4] ? row[4] : "";
entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
entry.duration = atoi(row[5]);
entry.from_expedition_uuid = row[6] ? row[6] : "";
@ -162,7 +181,7 @@ public:
update_values.push_back(columns[1] + " = " + std::to_string(character_expedition_lockouts_entry.character_id));
update_values.push_back(columns[2] + " = '" + EscapeString(character_expedition_lockouts_entry.expedition_name) + "'");
update_values.push_back(columns[3] + " = '" + EscapeString(character_expedition_lockouts_entry.event_name) + "'");
update_values.push_back(columns[4] + " = '" + EscapeString(character_expedition_lockouts_entry.expire_time) + "'");
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] + " = '" + EscapeString(character_expedition_lockouts_entry.from_expedition_uuid) + "'");
@ -190,7 +209,7 @@ public:
insert_values.push_back(std::to_string(character_expedition_lockouts_entry.character_id));
insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.expedition_name) + "'");
insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.event_name) + "'");
insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.expire_time) + "'");
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("'" + EscapeString(character_expedition_lockouts_entry.from_expedition_uuid) + "'");
@ -226,7 +245,7 @@ public:
insert_values.push_back(std::to_string(character_expedition_lockouts_entry.character_id));
insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.expedition_name) + "'");
insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.event_name) + "'");
insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.expire_time) + "'");
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("'" + EscapeString(character_expedition_lockouts_entry.from_expedition_uuid) + "'");
@ -266,7 +285,7 @@ public:
entry.character_id = atoi(row[1]);
entry.expedition_name = row[2] ? row[2] : "";
entry.event_name = row[3] ? row[3] : "";
entry.expire_time = row[4] ? row[4] : "";
entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
entry.duration = atoi(row[5]);
entry.from_expedition_uuid = row[6] ? row[6] : "";
@ -297,7 +316,7 @@ public:
entry.character_id = atoi(row[1]);
entry.expedition_name = row[2] ? row[2] : "";
entry.event_name = row[3] ? row[3] : "";
entry.expire_time = row[4] ? row[4] : "";
entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
entry.duration = atoi(row[5]);
entry.from_expedition_uuid = row[6] ? row[6] : "";

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterInspectMessagesRepository {
public:
@ -35,11 +36,24 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"inspect_message",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_inspect_messages");
@ -49,7 +63,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterInstanceSafereturnsRepository {
public:
@ -49,11 +50,31 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"character_id",
"instance_zone_id",
"instance_id",
"safe_zone_id",
"safe_x",
"safe_y",
"safe_z",
"safe_heading",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_instance_safereturns");
@ -63,7 +84,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterItemRecastRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"recast_type",
"timestamp",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_item_recast");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterLanguagesRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"lang_id",
"value",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_languages");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterLeadershipAbilitiesRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"slot",
"rank",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_leadership_abilities");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterMaterialRepository {
public:
@ -45,11 +46,29 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"slot",
"blue",
"green",
"red",
"use_tint",
"color",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_material");
@ -59,7 +78,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterMemmedSpellsRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"slot_id",
"spell_id",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_memmed_spells");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterPetBuffsRepository {
public:
@ -53,11 +54,33 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"char_id",
"pet",
"slot",
"spell_id",
"caster_level",
"castername",
"ticsremaining",
"counters",
"numhits",
"rune",
"instrument_mod",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_pet_buffs");
@ -67,7 +90,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterPetInfoRepository {
public:
@ -49,11 +50,31 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"char_id",
"pet",
"petname",
"petpower",
"spell_id",
"hp",
"mana",
"size",
"taunting",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_pet_info");
@ -63,7 +84,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterPetInventoryRepository {
public:
@ -39,11 +40,26 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"char_id",
"pet",
"slot",
"item_id",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_pet_inventory");
@ -53,7 +69,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterPotionbeltRepository {
public:
@ -39,11 +40,26 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"potion_id",
"item_id",
"icon",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_potionbelt");
@ -53,7 +69,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterSkillsRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"skill_id",
"value",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_skills");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterSpellsRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"slot_id",
"spell_id",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_spells");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -134,7 +134,7 @@ public:
entry.character_id = atoi(row[1]);
entry.task_id = atoi(row[2]);
entry.timer_type = atoi(row[3]);
entry.expire_time = strtoll(row[4], nullptr, 10);
entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
return entry;
}
@ -171,7 +171,7 @@ public:
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] + " = FROM_UNIXTIME(" + std::to_string(character_task_timers_entry.expire_time) + ")");
update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (character_task_timers_entry.expire_time > 0 ? std::to_string(character_task_timers_entry.expire_time) : "null") + ")");
auto results = db.QueryDatabase(
fmt::format(
@ -197,7 +197,7 @@ public:
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("FROM_UNIXTIME(" + std::to_string(character_task_timers_entry.expire_time) + ")");
insert_values.push_back("FROM_UNIXTIME(" + (character_task_timers_entry.expire_time > 0 ? std::to_string(character_task_timers_entry.expire_time) : "null") + ")");
auto results = db.QueryDatabase(
fmt::format(
@ -231,7 +231,7 @@ public:
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("FROM_UNIXTIME(" + std::to_string(character_task_timers_entry.expire_time) + ")");
insert_values.push_back("FROM_UNIXTIME(" + (character_task_timers_entry.expire_time > 0 ? std::to_string(character_task_timers_entry.expire_time) : "null") + ")");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
@ -269,7 +269,7 @@ public:
entry.character_id = atoi(row[1]);
entry.task_id = atoi(row[2]);
entry.timer_type = atoi(row[3]);
entry.expire_time = strtoll(row[4], nullptr, 10);
entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
all_entries.push_back(entry);
}
@ -298,7 +298,7 @@ public:
entry.character_id = atoi(row[1]);
entry.task_id = atoi(row[2]);
entry.timer_type = atoi(row[3]);
entry.expire_time = strtoll(row[4], nullptr, 10);
entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
all_entries.push_back(entry);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCharacterTasksRepository {
public:
@ -41,11 +42,27 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"charid",
"taskid",
"slot",
"type",
"acceptedtime",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("character_tasks");
@ -55,7 +72,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseCompletedTasksRepository {
public:
@ -39,11 +40,26 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"charid",
"completedtime",
"taskid",
"activityid",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("completed_tasks");
@ -53,7 +69,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseContentFlagsRepository {
public:
@ -39,11 +40,26 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"flag_name",
"enabled",
"notes",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("content_flags");
@ -53,7 +69,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseDamageshieldtypesRepository {
public:
@ -35,11 +36,24 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"spellid",
"type",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("damageshieldtypes");
@ -49,7 +63,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseDataBucketsRepository {
public:
@ -39,11 +40,26 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"key",
"value",
"expires",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("data_buckets");
@ -53,7 +69,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@ -110,7 +126,7 @@ public:
if (results.RowCount() == 1) {
DataBuckets entry{};
entry.id = strtoll(row[0], NULL, 10);
entry.id = strtoll(row[0], nullptr, 10);
entry.key = row[1] ? row[1] : "";
entry.value = row[2] ? row[2] : "";
entry.expires = atoi(row[3]);
@ -241,7 +257,7 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
DataBuckets entry{};
entry.id = strtoll(row[0], NULL, 10);
entry.id = strtoll(row[0], nullptr, 10);
entry.key = row[1] ? row[1] : "";
entry.value = row[2] ? row[2] : "";
entry.expires = atoi(row[3]);
@ -269,7 +285,7 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
DataBuckets entry{};
entry.id = strtoll(row[0], NULL, 10);
entry.id = strtoll(row[0], nullptr, 10);
entry.key = row[1] ? row[1] : "";
entry.value = row[2] ? row[2] : "";
entry.expires = atoi(row[3]);

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseDbStrRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"type",
"value",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("db_str");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseDiscoveredItemsRepository {
public:
@ -39,11 +40,26 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"item_id",
"char_name",
"discovered_date",
"account_status",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("discovered_items");
@ -53,7 +69,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseDoorsRepository {
public:
@ -101,11 +102,57 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"doorid",
"zone",
"version",
"name",
"pos_y",
"pos_x",
"pos_z",
"heading",
"opentype",
"guild",
"lockpick",
"keyitem",
"nokeyring",
"triggerdoor",
"triggertype",
"disable_timer",
"doorisopen",
"door_param",
"dest_zone",
"dest_instance",
"dest_x",
"dest_y",
"dest_z",
"dest_heading",
"invert_state",
"incline",
"size",
"buffer",
"client_version_mask",
"is_ldon_door",
"min_expansion",
"max_expansion",
"content_flags",
"content_flags_disabled",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("doors");
@ -115,7 +162,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@ -164,8 +211,8 @@ public:
entry.buffer = 0;
entry.client_version_mask = 4294967295;
entry.is_ldon_door = 0;
entry.min_expansion = 0;
entry.max_expansion = 0;
entry.min_expansion = -1;
entry.max_expansion = -1;
entry.content_flags = "";
entry.content_flags_disabled = "";

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseDynamicZoneMembersRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"dynamic_zone_id",
"character_id",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("dynamic_zone_members");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseDynamicZonesRepository {
public:
@ -75,11 +76,44 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"instance_id",
"type",
"uuid",
"name",
"leader_id",
"min_players",
"max_players",
"compass_zone_id",
"compass_x",
"compass_y",
"compass_z",
"safe_return_zone_id",
"safe_return_x",
"safe_return_y",
"safe_return_z",
"safe_return_heading",
"zone_in_x",
"zone_in_y",
"zone_in_z",
"zone_in_heading",
"has_zone_in",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("dynamic_zones");
@ -89,7 +123,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseEventlogRepository {
public:
@ -51,11 +52,32 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"accountname",
"accountid",
"status",
"charname",
"target",
"time",
"descriptiontype",
"description",
"event_nid",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("eventlog");
@ -65,7 +87,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@ -89,7 +111,7 @@ public:
entry.status = 0;
entry.charname = "";
entry.target = "None";
entry.time = "";
entry.time = std::time(nullptr);
entry.descriptiontype = "";
entry.description = "";
entry.event_nid = 0;

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseExpeditionLockoutsRepository {
public:
@ -21,7 +22,7 @@ public:
int id;
int expedition_id;
std::string event_name;
std::string expire_time;
time_t expire_time;
int duration;
std::string from_expedition_uuid;
};
@ -43,11 +44,28 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"expedition_id",
"event_name",
"UNIX_TIMESTAMP(expire_time)",
"duration",
"from_expedition_uuid",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("expedition_lockouts");
@ -57,7 +75,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@ -78,7 +96,7 @@ public:
entry.id = 0;
entry.expedition_id = 0;
entry.event_name = "";
entry.expire_time = "";
entry.expire_time = std::time(nullptr);
entry.duration = 0;
entry.from_expedition_uuid = "";
@ -119,7 +137,7 @@ public:
entry.id = atoi(row[0]);
entry.expedition_id = atoi(row[1]);
entry.event_name = row[2] ? row[2] : "";
entry.expire_time = row[3] ? row[3] : "";
entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
entry.duration = atoi(row[4]);
entry.from_expedition_uuid = row[5] ? row[5] : "";
@ -157,7 +175,7 @@ public:
update_values.push_back(columns[1] + " = " + std::to_string(expedition_lockouts_entry.expedition_id));
update_values.push_back(columns[2] + " = '" + EscapeString(expedition_lockouts_entry.event_name) + "'");
update_values.push_back(columns[3] + " = '" + EscapeString(expedition_lockouts_entry.expire_time) + "'");
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] + " = '" + EscapeString(expedition_lockouts_entry.from_expedition_uuid) + "'");
@ -184,7 +202,7 @@ public:
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("'" + EscapeString(expedition_lockouts_entry.event_name) + "'");
insert_values.push_back("'" + EscapeString(expedition_lockouts_entry.expire_time) + "'");
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("'" + EscapeString(expedition_lockouts_entry.from_expedition_uuid) + "'");
@ -219,7 +237,7 @@ public:
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("'" + EscapeString(expedition_lockouts_entry.event_name) + "'");
insert_values.push_back("'" + EscapeString(expedition_lockouts_entry.expire_time) + "'");
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("'" + EscapeString(expedition_lockouts_entry.from_expedition_uuid) + "'");
@ -258,7 +276,7 @@ public:
entry.id = atoi(row[0]);
entry.expedition_id = atoi(row[1]);
entry.event_name = row[2] ? row[2] : "";
entry.expire_time = row[3] ? row[3] : "";
entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
entry.duration = atoi(row[4]);
entry.from_expedition_uuid = row[5] ? row[5] : "";
@ -288,7 +306,7 @@ public:
entry.id = atoi(row[0]);
entry.expedition_id = atoi(row[1]);
entry.event_name = row[2] ? row[2] : "";
entry.expire_time = row[3] ? row[3] : "";
entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10);
entry.duration = atoi(row[4]);
entry.from_expedition_uuid = row[5] ? row[5] : "";

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseExpeditionsRepository {
public:
@ -39,11 +40,26 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"dynamic_zone_id",
"add_replay_on_join",
"is_locked",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("expeditions");
@ -53,7 +69,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseFactionBaseDataRepository {
public:
@ -43,11 +44,28 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"client_faction_id",
"min",
"max",
"unk_hero1",
"unk_hero2",
"unk_hero3",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("faction_base_data");
@ -57,7 +75,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseFactionListModRepository {
public:
@ -39,11 +40,26 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"faction_id",
"mod",
"mod_name",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("faction_list_mod");
@ -53,7 +69,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseFactionListRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"name",
"base",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("faction_list");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseFactionValuesRepository {
public:
@ -39,11 +40,26 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"char_id",
"faction_id",
"current_value",
"temp",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("faction_values");
@ -53,7 +69,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseFishingRepository {
public:
@ -53,11 +54,33 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"zoneid",
"Itemid",
"skill_level",
"chance",
"npc_id",
"npc_chance",
"min_expansion",
"max_expansion",
"content_flags",
"content_flags_disabled",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("fishing");
@ -67,7 +90,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@ -92,8 +115,8 @@ public:
entry.chance = 0;
entry.npc_id = 0;
entry.npc_chance = 0;
entry.min_expansion = 0;
entry.max_expansion = 0;
entry.min_expansion = -1;
entry.max_expansion = -1;
entry.content_flags = "";
entry.content_flags_disabled = "";

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseForageRepository {
public:
@ -49,11 +50,31 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"zoneid",
"Itemid",
"level",
"chance",
"min_expansion",
"max_expansion",
"content_flags",
"content_flags_disabled",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("forage");
@ -63,7 +84,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@ -86,8 +107,8 @@ public:
entry.Itemid = 0;
entry.level = 0;
entry.chance = 0;
entry.min_expansion = 0;
entry.max_expansion = 0;
entry.min_expansion = -1;
entry.max_expansion = -1;
entry.content_flags = "";
entry.content_flags_disabled = "";

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseFriendsRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"charid",
"type",
"name",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("friends");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseGlobalLootRepository {
public:
@ -65,11 +66,39 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"description",
"loottable_id",
"enabled",
"min_level",
"max_level",
"rare",
"raid",
"race",
"`class`",
"bodytype",
"zone",
"hot_zone",
"min_expansion",
"max_expansion",
"content_flags",
"content_flags_disabled",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("global_loot");
@ -79,7 +108,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@ -110,8 +139,8 @@ public:
entry.bodytype = "";
entry.zone = "";
entry.hot_zone = 0;
entry.min_expansion = 0;
entry.max_expansion = 0;
entry.min_expansion = -1;
entry.max_expansion = -1;
entry.content_flags = "";
entry.content_flags_disabled = "";

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseGmIpsRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"name",
"account_id",
"ip_address",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("gm_ips");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseGoallistsRepository {
public:
@ -35,11 +36,24 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"listid",
"entry",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("goallists");
@ -49,7 +63,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseGraveyardRepository {
public:
@ -43,11 +44,28 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"zone_id",
"x",
"y",
"z",
"heading",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("graveyard");
@ -57,7 +75,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseGroundSpawnsRepository {
public:
@ -67,11 +68,40 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"zoneid",
"version",
"max_x",
"max_y",
"max_z",
"min_x",
"min_y",
"heading",
"name",
"item",
"max_allowed",
"comment",
"respawn_timer",
"min_expansion",
"max_expansion",
"content_flags",
"content_flags_disabled",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("ground_spawns");
@ -81,7 +111,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@ -113,8 +143,8 @@ public:
entry.max_allowed = 1;
entry.comment = "";
entry.respawn_timer = 300;
entry.min_expansion = 0;
entry.max_expansion = 0;
entry.min_expansion = -1;
entry.max_expansion = -1;
entry.content_flags = "";
entry.content_flags_disabled = "";

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseGroupIdRepository {
public:
@ -39,11 +40,26 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"groupid",
"charid",
"name",
"ismerc",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("group_id");
@ -53,7 +69,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseGroupLeadersRepository {
public:
@ -49,11 +50,31 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"gid",
"leadername",
"marknpc",
"leadershipaa",
"maintank",
"assist",
"puller",
"mentoree",
"mentor_percent",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("group_leaders");
@ -63,7 +84,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseGuildMembersRepository {
public:
@ -49,11 +50,31 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"char_id",
"guild_id",
"rank",
"tribute_enable",
"total_tribute",
"last_tribute",
"banker",
"public_note",
"alt",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("guild_members");
@ -63,7 +84,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseGuildRanksRepository {
public:
@ -53,11 +54,33 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"guild_id",
"rank",
"title",
"can_hear",
"can_speak",
"can_invite",
"can_remove",
"can_promote",
"can_demote",
"can_motd",
"can_warpeace",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("guild_ranks");
@ -67,7 +90,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseGuildRelationsRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"guild1",
"guild2",
"relation",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("guild_relations");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseGuildsRepository {
public:
@ -49,11 +50,31 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"name",
"leader",
"minstatus",
"motd",
"tribute",
"motd_setter",
"channel",
"url",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("guilds");
@ -63,7 +84,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseHackersRepository {
public:
@ -43,11 +44,28 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"account",
"name",
"hacked",
"zone",
"date",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("hackers");
@ -57,7 +75,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@ -80,7 +98,7 @@ public:
entry.name = "";
entry.hacked = "";
entry.zone = "";
entry.date = "";
entry.date = std::time(nullptr);
return entry;
}

View File

@ -1,29 +1,12 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
* DO NOT MODIFY THIS FILE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
*/
/**
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to
* the repository extending the base. Any modifications to base repositories are to
* be made by the generator only
* Any repository modifications 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_HORSES_REPOSITORY_H
@ -31,26 +14,42 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseHorsesRepository {
public:
struct Horses {
int id;
std::string filename;
int16 race;
int8 gender;
int8 texture;
int race;
int gender;
int texture;
float mountspeed;
std::string notes;
};
static std::string PrimaryKey()
{
return std::string("filename");
return std::string("id");
}
static std::vector<std::string> Columns()
{
return {
"id",
"filename",
"race",
"gender",
"texture",
"mountspeed",
"notes",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"filename",
"race",
"gender",
@ -65,19 +64,9 @@ public:
return std::string(implode(", ", Columns()));
}
static std::string InsertColumnsRaw()
static std::string SelectColumnsRaw()
{
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));
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
@ -89,7 +78,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@ -99,7 +88,7 @@ public:
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
InsertColumnsRaw()
ColumnsRaw()
);
}
@ -107,6 +96,7 @@ public:
{
Horses entry{};
entry.id = 0;
entry.filename = "";
entry.race = 216;
entry.gender = 0;
@ -123,7 +113,7 @@ public:
)
{
for (auto &horses : horsess) {
if (horses.filename == horses_id) {
if (horses.id == horses_id) {
return horses;
}
}
@ -132,10 +122,11 @@ public:
}
static Horses FindOne(
Database& db,
int horses_id
)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
@ -147,12 +138,13 @@ public:
if (results.RowCount() == 1) {
Horses entry{};
entry.filename = row[0] ? row[0] : "";
entry.race = atoi(row[1]);
entry.gender = atoi(row[2]);
entry.texture = atoi(row[3]);
entry.mountspeed = atof(row[4]);
entry.notes = row[5] ? row[5] : "";
entry.id = atoi(row[0]);
entry.filename = row[1] ? row[1] : "";
entry.race = atoi(row[2]);
entry.gender = atoi(row[3]);
entry.texture = atoi(row[4]);
entry.mountspeed = static_cast<float>(atof(row[5]));
entry.notes = row[6] ? row[6] : "";
return entry;
}
@ -161,10 +153,11 @@ public:
}
static int DeleteOne(
Database& db,
int horses_id
)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
@ -177,6 +170,7 @@ public:
}
static int UpdateOne(
Database& db,
Horses horses_entry
)
{
@ -184,20 +178,20 @@ public:
auto columns = Columns();
update_values.push_back(columns[0] + " = '" + EscapeString(horses_entry.filename) + "'");
update_values.push_back(columns[1] + " = " + std::to_string(horses_entry.race));
update_values.push_back(columns[2] + " = " + std::to_string(horses_entry.gender));
update_values.push_back(columns[3] + " = " + std::to_string(horses_entry.texture));
update_values.push_back(columns[4] + " = " + std::to_string(horses_entry.mountspeed));
update_values.push_back(columns[5] + " = '" + EscapeString(horses_entry.notes) + "'");
update_values.push_back(columns[1] + " = '" + EscapeString(horses_entry.filename) + "'");
update_values.push_back(columns[2] + " = " + std::to_string(horses_entry.race));
update_values.push_back(columns[3] + " = " + std::to_string(horses_entry.gender));
update_values.push_back(columns[4] + " = " + std::to_string(horses_entry.texture));
update_values.push_back(columns[5] + " = " + std::to_string(horses_entry.mountspeed));
update_values.push_back(columns[6] + " = '" + EscapeString(horses_entry.notes) + "'");
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
implode(", ", update_values),
PrimaryKey(),
horses_entry.filename
horses_entry.id
)
);
@ -205,11 +199,13 @@ public:
}
static Horses InsertOne(
Database& db,
Horses horses_entry
)
{
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(horses_entry.id));
insert_values.push_back("'" + EscapeString(horses_entry.filename) + "'");
insert_values.push_back(std::to_string(horses_entry.race));
insert_values.push_back(std::to_string(horses_entry.gender));
@ -217,7 +213,7 @@ public:
insert_values.push_back(std::to_string(horses_entry.mountspeed));
insert_values.push_back("'" + EscapeString(horses_entry.notes) + "'");
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
@ -226,7 +222,7 @@ public:
);
if (results.Success()) {
horses_entry.filename = results.LastInsertedID();
horses_entry.id = results.LastInsertedID();
return horses_entry;
}
@ -236,6 +232,7 @@ public:
}
static int InsertMany(
Database& db,
std::vector<Horses> horses_entries
)
{
@ -244,6 +241,7 @@ public:
for (auto &horses_entry: horses_entries) {
std::vector<std::string> insert_values;
insert_values.push_back(std::to_string(horses_entry.id));
insert_values.push_back("'" + EscapeString(horses_entry.filename) + "'");
insert_values.push_back(std::to_string(horses_entry.race));
insert_values.push_back(std::to_string(horses_entry.gender));
@ -256,7 +254,7 @@ public:
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
@ -267,11 +265,11 @@ public:
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Horses> All()
static std::vector<Horses> All(Database& db)
{
std::vector<Horses> all_entries;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
@ -283,12 +281,13 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
Horses entry{};
entry.filename = row[0] ? row[0] : "";
entry.race = atoi(row[1]);
entry.gender = atoi(row[2]);
entry.texture = atoi(row[3]);
entry.mountspeed = atof(row[4]);
entry.notes = row[5] ? row[5] : "";
entry.id = atoi(row[0]);
entry.filename = row[1] ? row[1] : "";
entry.race = atoi(row[2]);
entry.gender = atoi(row[3]);
entry.texture = atoi(row[4]);
entry.mountspeed = static_cast<float>(atof(row[5]));
entry.notes = row[6] ? row[6] : "";
all_entries.push_back(entry);
}
@ -296,11 +295,11 @@ public:
return all_entries;
}
static std::vector<Horses> GetWhere(std::string where_filter)
static std::vector<Horses> GetWhere(Database& db, std::string where_filter)
{
std::vector<Horses> all_entries;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
@ -313,12 +312,13 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
Horses entry{};
entry.filename = row[0] ? row[0] : "";
entry.race = atoi(row[1]);
entry.gender = atoi(row[2]);
entry.texture = atoi(row[3]);
entry.mountspeed = atof(row[4]);
entry.notes = row[5] ? row[5] : "";
entry.id = atoi(row[0]);
entry.filename = row[1] ? row[1] : "";
entry.race = atoi(row[2]);
entry.gender = atoi(row[3]);
entry.texture = atoi(row[4]);
entry.mountspeed = static_cast<float>(atof(row[5]));
entry.notes = row[6] ? row[6] : "";
all_entries.push_back(entry);
}
@ -326,13 +326,12 @@ public:
return all_entries;
}
static int DeleteWhere(std::string where_filter)
static int DeleteWhere(Database& db, std::string where_filter)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
@ -340,6 +339,18 @@ public:
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);
}
};
#endif //EQEMU_BASE_HORSES_REPOSITORY_H

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseInstanceListPlayerRepository {
public:
@ -35,11 +36,24 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"charid",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("instance_list_player");
@ -49,7 +63,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseInstanceListRepository {
public:
@ -45,11 +46,29 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"zone",
"version",
"is_global",
"start_time",
"duration",
"never_expires",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("instance_list");
@ -59,7 +78,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseInventoryRepository {
public:
@ -63,11 +64,38 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"charid",
"slotid",
"itemid",
"charges",
"color",
"augslot1",
"augslot2",
"augslot3",
"augslot4",
"augslot5",
"augslot6",
"instnodrop",
"custom_data",
"ornamenticon",
"ornamentidfile",
"ornament_hero_model",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("inventory");
@ -77,7 +105,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseInventorySnapshotsRepository {
public:
@ -65,11 +66,39 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"time_index",
"charid",
"slotid",
"itemid",
"charges",
"color",
"augslot1",
"augslot2",
"augslot3",
"augslot4",
"augslot5",
"augslot6",
"instnodrop",
"custom_data",
"ornamenticon",
"ornamentidfile",
"ornament_hero_model",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("inventory_snapshots");
@ -79,7 +108,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseIpExemptionsRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"exemption_id",
"exemption_ip",
"exemption_amount",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("ip_exemptions");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseItemTickRepository {
public:
@ -43,11 +44,28 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"it_itemid",
"it_chance",
"it_level",
"it_id",
"it_qglobal",
"it_bagslot",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("item_tick");
@ -57,7 +75,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseItemsRepository {
public:
@ -152,7 +153,7 @@ public:
int UNK124;
int attuneable;
int nopet;
std::string updated;
time_t updated;
std::string comment;
int UNK127;
int pointtype;
@ -182,8 +183,8 @@ public:
int scrolllevel2;
int scrolllevel;
int UNK157;
std::string serialized;
std::string verified;
time_t serialized;
time_t verified;
std::string serialization;
std::string source;
int UNK033;
@ -601,11 +602,307 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"minstatus",
"Name",
"aagi",
"ac",
"accuracy",
"acha",
"adex",
"aint",
"artifactflag",
"asta",
"astr",
"attack",
"augrestrict",
"augslot1type",
"augslot1visible",
"augslot2type",
"augslot2visible",
"augslot3type",
"augslot3visible",
"augslot4type",
"augslot4visible",
"augslot5type",
"augslot5visible",
"augslot6type",
"augslot6visible",
"augtype",
"avoidance",
"awis",
"bagsize",
"bagslots",
"bagtype",
"bagwr",
"banedmgamt",
"banedmgraceamt",
"banedmgbody",
"banedmgrace",
"bardtype",
"bardvalue",
"book",
"casttime",
"casttime_",
"charmfile",
"charmfileid",
"classes",
"color",
"combateffects",
"extradmgskill",
"extradmgamt",
"price",
"cr",
"damage",
"damageshield",
"deity",
"delay",
"augdistiller",
"dotshielding",
"dr",
"clicktype",
"clicklevel2",
"elemdmgtype",
"elemdmgamt",
"endur",
"factionamt1",
"factionamt2",
"factionamt3",
"factionamt4",
"factionmod1",
"factionmod2",
"factionmod3",
"factionmod4",
"filename",
"focuseffect",
"fr",
"fvnodrop",
"haste",
"clicklevel",
"hp",
"regen",
"icon",
"idfile",
"itemclass",
"itemtype",
"ldonprice",
"ldontheme",
"ldonsold",
"light",
"lore",
"loregroup",
"magic",
"mana",
"manaregen",
"enduranceregen",
"material",
"herosforgemodel",
"maxcharges",
"mr",
"nodrop",
"norent",
"pendingloreflag",
"pr",
"procrate",
"races",
"range",
"reclevel",
"recskill",
"reqlevel",
"sellrate",
"shielding",
"size",
"skillmodtype",
"skillmodvalue",
"slots",
"clickeffect",
"spellshield",
"strikethrough",
"stunresist",
"summonedflag",
"tradeskills",
"favor",
"weight",
"UNK012",
"UNK013",
"benefitflag",
"UNK054",
"UNK059",
"booktype",
"recastdelay",
"recasttype",
"guildfavor",
"UNK123",
"UNK124",
"attuneable",
"nopet",
"UNIX_TIMESTAMP(updated)",
"comment",
"UNK127",
"pointtype",
"potionbelt",
"potionbeltslots",
"stacksize",
"notransfer",
"stackable",
"UNK134",
"UNK137",
"proceffect",
"proctype",
"proclevel2",
"proclevel",
"UNK142",
"worneffect",
"worntype",
"wornlevel2",
"wornlevel",
"UNK147",
"focustype",
"focuslevel2",
"focuslevel",
"UNK152",
"scrolleffect",
"scrolltype",
"scrolllevel2",
"scrolllevel",
"UNK157",
"UNIX_TIMESTAMP(serialized)",
"UNIX_TIMESTAMP(verified)",
"serialization",
"source",
"UNK033",
"lorefile",
"UNK014",
"svcorruption",
"skillmodmax",
"UNK060",
"augslot1unk2",
"augslot2unk2",
"augslot3unk2",
"augslot4unk2",
"augslot5unk2",
"augslot6unk2",
"UNK120",
"UNK121",
"questitemflag",
"UNK132",
"clickunk5",
"clickunk6",
"clickunk7",
"procunk1",
"procunk2",
"procunk3",
"procunk4",
"procunk6",
"procunk7",
"wornunk1",
"wornunk2",
"wornunk3",
"wornunk4",
"wornunk5",
"wornunk6",
"wornunk7",
"focusunk1",
"focusunk2",
"focusunk3",
"focusunk4",
"focusunk5",
"focusunk6",
"focusunk7",
"scrollunk1",
"scrollunk2",
"scrollunk3",
"scrollunk4",
"scrollunk5",
"scrollunk6",
"scrollunk7",
"UNK193",
"purity",
"evoitem",
"evoid",
"evolvinglevel",
"evomax",
"clickname",
"procname",
"wornname",
"focusname",
"scrollname",
"dsmitigation",
"heroic_str",
"heroic_int",
"heroic_wis",
"heroic_agi",
"heroic_dex",
"heroic_sta",
"heroic_cha",
"heroic_pr",
"heroic_dr",
"heroic_fr",
"heroic_cr",
"heroic_mr",
"heroic_svcorrup",
"healamt",
"spelldmg",
"clairvoyance",
"backstabdmg",
"created",
"elitematerial",
"ldonsellbackrate",
"scriptfileid",
"expendablearrow",
"powersourcecapacity",
"bardeffect",
"bardeffecttype",
"bardlevel2",
"bardlevel",
"bardunk1",
"bardunk2",
"bardunk3",
"bardunk4",
"bardunk5",
"bardname",
"bardunk7",
"UNK214",
"subtype",
"UNK220",
"UNK221",
"heirloom",
"UNK223",
"UNK224",
"UNK225",
"UNK226",
"UNK227",
"UNK228",
"UNK229",
"UNK230",
"UNK231",
"UNK232",
"UNK233",
"UNK234",
"placeable",
"UNK236",
"UNK237",
"UNK238",
"UNK239",
"UNK240",
"UNK241",
"epicitem",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("items");
@ -615,7 +912,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@ -717,7 +1014,7 @@ public:
entry.itemclass = 0;
entry.itemtype = 0;
entry.ldonprice = 0;
entry.ldontheme = LDoNThemes::Unused;
entry.ldontheme = 0;
entry.ldonsold = 0;
entry.light = 0;
entry.lore = "";
@ -767,7 +1064,7 @@ public:
entry.UNK124 = 0;
entry.attuneable = 0;
entry.nopet = 0;
entry.updated = "0000-00-00 00:00:00";
entry.updated = 0;
entry.comment = "";
entry.UNK127 = 0;
entry.pointtype = 0;
@ -797,8 +1094,8 @@ public:
entry.scrolllevel2 = 0;
entry.scrolllevel = 0;
entry.UNK157 = 0;
entry.serialized = "";
entry.verified = "";
entry.serialized = 0;
entry.verified = 0;
entry.serialization = "";
entry.source = "";
entry.UNK033 = 0;
@ -1087,7 +1384,7 @@ public:
entry.UNK124 = atoi(row[131]);
entry.attuneable = atoi(row[132]);
entry.nopet = atoi(row[133]);
entry.updated = row[134] ? row[134] : "";
entry.updated = strtoll(row[134] ? row[134] : "-1", nullptr, 10);
entry.comment = row[135] ? row[135] : "";
entry.UNK127 = atoi(row[136]);
entry.pointtype = atoi(row[137]);
@ -1117,8 +1414,8 @@ public:
entry.scrolllevel2 = atoi(row[161]);
entry.scrolllevel = atoi(row[162]);
entry.UNK157 = atoi(row[163]);
entry.serialized = row[164] ? row[164] : "";
entry.verified = row[165] ? row[165] : "";
entry.serialized = strtoll(row[164] ? row[164] : "-1", nullptr, 10);
entry.verified = strtoll(row[165] ? row[165] : "-1", nullptr, 10);
entry.serialization = row[166] ? row[166] : "";
entry.source = row[167] ? row[167] : "";
entry.UNK033 = atoi(row[168]);
@ -1405,7 +1702,7 @@ public:
update_values.push_back(columns[131] + " = " + std::to_string(items_entry.UNK124));
update_values.push_back(columns[132] + " = " + std::to_string(items_entry.attuneable));
update_values.push_back(columns[133] + " = " + std::to_string(items_entry.nopet));
update_values.push_back(columns[134] + " = '" + EscapeString(items_entry.updated) + "'");
update_values.push_back(columns[134] + " = FROM_UNIXTIME(" + (items_entry.updated > 0 ? std::to_string(items_entry.updated) : "null") + ")");
update_values.push_back(columns[135] + " = '" + EscapeString(items_entry.comment) + "'");
update_values.push_back(columns[136] + " = " + std::to_string(items_entry.UNK127));
update_values.push_back(columns[137] + " = " + std::to_string(items_entry.pointtype));
@ -1435,8 +1732,8 @@ public:
update_values.push_back(columns[161] + " = " + std::to_string(items_entry.scrolllevel2));
update_values.push_back(columns[162] + " = " + std::to_string(items_entry.scrolllevel));
update_values.push_back(columns[163] + " = " + std::to_string(items_entry.UNK157));
update_values.push_back(columns[164] + " = '" + EscapeString(items_entry.serialized) + "'");
update_values.push_back(columns[165] + " = '" + EscapeString(items_entry.verified) + "'");
update_values.push_back(columns[164] + " = FROM_UNIXTIME(" + (items_entry.serialized > 0 ? std::to_string(items_entry.serialized) : "null") + ")");
update_values.push_back(columns[165] + " = FROM_UNIXTIME(" + (items_entry.verified > 0 ? std::to_string(items_entry.verified) : "null") + ")");
update_values.push_back(columns[166] + " = '" + EscapeString(items_entry.serialization) + "'");
update_values.push_back(columns[167] + " = '" + EscapeString(items_entry.source) + "'");
update_values.push_back(columns[168] + " = " + std::to_string(items_entry.UNK033));
@ -1711,7 +2008,7 @@ public:
insert_values.push_back(std::to_string(items_entry.UNK124));
insert_values.push_back(std::to_string(items_entry.attuneable));
insert_values.push_back(std::to_string(items_entry.nopet));
insert_values.push_back("'" + EscapeString(items_entry.updated) + "'");
insert_values.push_back("FROM_UNIXTIME(" + (items_entry.updated > 0 ? std::to_string(items_entry.updated) : "null") + ")");
insert_values.push_back("'" + EscapeString(items_entry.comment) + "'");
insert_values.push_back(std::to_string(items_entry.UNK127));
insert_values.push_back(std::to_string(items_entry.pointtype));
@ -1741,8 +2038,8 @@ public:
insert_values.push_back(std::to_string(items_entry.scrolllevel2));
insert_values.push_back(std::to_string(items_entry.scrolllevel));
insert_values.push_back(std::to_string(items_entry.UNK157));
insert_values.push_back("'" + EscapeString(items_entry.serialized) + "'");
insert_values.push_back("'" + EscapeString(items_entry.verified) + "'");
insert_values.push_back("FROM_UNIXTIME(" + (items_entry.serialized > 0 ? std::to_string(items_entry.serialized) : "null") + ")");
insert_values.push_back("FROM_UNIXTIME(" + (items_entry.verified > 0 ? std::to_string(items_entry.verified) : "null") + ")");
insert_values.push_back("'" + EscapeString(items_entry.serialization) + "'");
insert_values.push_back("'" + EscapeString(items_entry.source) + "'");
insert_values.push_back(std::to_string(items_entry.UNK033));
@ -2025,7 +2322,7 @@ public:
insert_values.push_back(std::to_string(items_entry.UNK124));
insert_values.push_back(std::to_string(items_entry.attuneable));
insert_values.push_back(std::to_string(items_entry.nopet));
insert_values.push_back("'" + EscapeString(items_entry.updated) + "'");
insert_values.push_back("FROM_UNIXTIME(" + (items_entry.updated > 0 ? std::to_string(items_entry.updated) : "null") + ")");
insert_values.push_back("'" + EscapeString(items_entry.comment) + "'");
insert_values.push_back(std::to_string(items_entry.UNK127));
insert_values.push_back(std::to_string(items_entry.pointtype));
@ -2055,8 +2352,8 @@ public:
insert_values.push_back(std::to_string(items_entry.scrolllevel2));
insert_values.push_back(std::to_string(items_entry.scrolllevel));
insert_values.push_back(std::to_string(items_entry.UNK157));
insert_values.push_back("'" + EscapeString(items_entry.serialized) + "'");
insert_values.push_back("'" + EscapeString(items_entry.verified) + "'");
insert_values.push_back("FROM_UNIXTIME(" + (items_entry.serialized > 0 ? std::to_string(items_entry.serialized) : "null") + ")");
insert_values.push_back("FROM_UNIXTIME(" + (items_entry.verified > 0 ? std::to_string(items_entry.verified) : "null") + ")");
insert_values.push_back("'" + EscapeString(items_entry.serialization) + "'");
insert_values.push_back("'" + EscapeString(items_entry.source) + "'");
insert_values.push_back(std::to_string(items_entry.UNK033));
@ -2343,7 +2640,7 @@ public:
entry.UNK124 = atoi(row[131]);
entry.attuneable = atoi(row[132]);
entry.nopet = atoi(row[133]);
entry.updated = row[134] ? row[134] : "";
entry.updated = strtoll(row[134] ? row[134] : "-1", nullptr, 10);
entry.comment = row[135] ? row[135] : "";
entry.UNK127 = atoi(row[136]);
entry.pointtype = atoi(row[137]);
@ -2373,8 +2670,8 @@ public:
entry.scrolllevel2 = atoi(row[161]);
entry.scrolllevel = atoi(row[162]);
entry.UNK157 = atoi(row[163]);
entry.serialized = row[164] ? row[164] : "";
entry.verified = row[165] ? row[165] : "";
entry.serialized = strtoll(row[164] ? row[164] : "-1", nullptr, 10);
entry.verified = strtoll(row[165] ? row[165] : "-1", nullptr, 10);
entry.serialization = row[166] ? row[166] : "";
entry.source = row[167] ? row[167] : "";
entry.UNK033 = atoi(row[168]);
@ -2652,7 +2949,7 @@ public:
entry.UNK124 = atoi(row[131]);
entry.attuneable = atoi(row[132]);
entry.nopet = atoi(row[133]);
entry.updated = row[134] ? row[134] : "";
entry.updated = strtoll(row[134] ? row[134] : "-1", nullptr, 10);
entry.comment = row[135] ? row[135] : "";
entry.UNK127 = atoi(row[136]);
entry.pointtype = atoi(row[137]);
@ -2682,8 +2979,8 @@ public:
entry.scrolllevel2 = atoi(row[161]);
entry.scrolllevel = atoi(row[162]);
entry.UNK157 = atoi(row[163]);
entry.serialized = row[164] ? row[164] : "";
entry.verified = row[165] ? row[165] : "";
entry.serialized = strtoll(row[164] ? row[164] : "-1", nullptr, 10);
entry.verified = strtoll(row[165] ? row[165] : "-1", nullptr, 10);
entry.serialization = row[166] ? row[166] : "";
entry.source = row[167] ? row[167] : "";
entry.UNK033 = atoi(row[168]);

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseLdonTrapEntriesRepository {
public:
@ -35,11 +36,24 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"trap_id",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("ldon_trap_entries");
@ -49,7 +63,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseLdonTrapTemplatesRepository {
public:
@ -41,11 +42,27 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"type",
"spell_id",
"skill",
"locked",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("ldon_trap_templates");
@ -55,7 +72,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseLevelExpModsRepository {
public:
@ -37,11 +38,25 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"level",
"exp_mod",
"aa_exp_mod",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("level_exp_mods");
@ -51,7 +66,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseLfguildRepository {
public:
@ -49,11 +50,31 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"type",
"name",
"comment",
"fromlevel",
"tolevel",
"classes",
"aacount",
"timezone",
"timeposted",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("lfguild");
@ -63,7 +84,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseLoginAccountsRepository {
public:
@ -24,9 +25,9 @@ public:
std::string account_email;
std::string source_loginserver;
std::string last_ip_address;
std::string last_login_date;
std::string created_at;
std::string updated_at;
time_t last_login_date;
time_t created_at;
time_t updated_at;
};
static std::string PrimaryKey()
@ -49,11 +50,31 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"account_name",
"account_password",
"account_email",
"source_loginserver",
"last_ip_address",
"UNIX_TIMESTAMP(last_login_date)",
"UNIX_TIMESTAMP(created_at)",
"UNIX_TIMESTAMP(updated_at)",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("login_accounts");
@ -63,7 +84,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@ -87,9 +108,9 @@ public:
entry.account_email = "";
entry.source_loginserver = "";
entry.last_ip_address = "";
entry.last_login_date = "";
entry.created_at = "";
entry.updated_at = "";
entry.last_login_date = 0;
entry.created_at = 0;
entry.updated_at = std::time(nullptr);
return entry;
}
@ -131,9 +152,9 @@ public:
entry.account_email = row[3] ? row[3] : "";
entry.source_loginserver = row[4] ? row[4] : "";
entry.last_ip_address = row[5] ? row[5] : "";
entry.last_login_date = row[6] ? row[6] : "";
entry.created_at = row[7] ? row[7] : "";
entry.updated_at = row[8] ? row[8] : "";
entry.last_login_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10);
entry.created_at = strtoll(row[7] ? row[7] : "-1", nullptr, 10);
entry.updated_at = strtoll(row[8] ? row[8] : "-1", nullptr, 10);
return entry;
}
@ -173,9 +194,9 @@ public:
update_values.push_back(columns[3] + " = '" + EscapeString(login_accounts_entry.account_email) + "'");
update_values.push_back(columns[4] + " = '" + EscapeString(login_accounts_entry.source_loginserver) + "'");
update_values.push_back(columns[5] + " = '" + EscapeString(login_accounts_entry.last_ip_address) + "'");
update_values.push_back(columns[6] + " = '" + EscapeString(login_accounts_entry.last_login_date) + "'");
update_values.push_back(columns[7] + " = '" + EscapeString(login_accounts_entry.created_at) + "'");
update_values.push_back(columns[8] + " = '" + EscapeString(login_accounts_entry.updated_at) + "'");
update_values.push_back(columns[6] + " = FROM_UNIXTIME(" + (login_accounts_entry.last_login_date > 0 ? std::to_string(login_accounts_entry.last_login_date) : "null") + ")");
update_values.push_back(columns[7] + " = FROM_UNIXTIME(" + (login_accounts_entry.created_at > 0 ? std::to_string(login_accounts_entry.created_at) : "null") + ")");
update_values.push_back(columns[8] + " = FROM_UNIXTIME(" + (login_accounts_entry.updated_at > 0 ? std::to_string(login_accounts_entry.updated_at) : "null") + ")");
auto results = db.QueryDatabase(
fmt::format(
@ -203,9 +224,9 @@ public:
insert_values.push_back("'" + EscapeString(login_accounts_entry.account_email) + "'");
insert_values.push_back("'" + EscapeString(login_accounts_entry.source_loginserver) + "'");
insert_values.push_back("'" + EscapeString(login_accounts_entry.last_ip_address) + "'");
insert_values.push_back("'" + EscapeString(login_accounts_entry.last_login_date) + "'");
insert_values.push_back("'" + EscapeString(login_accounts_entry.created_at) + "'");
insert_values.push_back("'" + EscapeString(login_accounts_entry.updated_at) + "'");
insert_values.push_back("FROM_UNIXTIME(" + (login_accounts_entry.last_login_date > 0 ? std::to_string(login_accounts_entry.last_login_date) : "null") + ")");
insert_values.push_back("FROM_UNIXTIME(" + (login_accounts_entry.created_at > 0 ? std::to_string(login_accounts_entry.created_at) : "null") + ")");
insert_values.push_back("FROM_UNIXTIME(" + (login_accounts_entry.updated_at > 0 ? std::to_string(login_accounts_entry.updated_at) : "null") + ")");
auto results = db.QueryDatabase(
fmt::format(
@ -241,9 +262,9 @@ public:
insert_values.push_back("'" + EscapeString(login_accounts_entry.account_email) + "'");
insert_values.push_back("'" + EscapeString(login_accounts_entry.source_loginserver) + "'");
insert_values.push_back("'" + EscapeString(login_accounts_entry.last_ip_address) + "'");
insert_values.push_back("'" + EscapeString(login_accounts_entry.last_login_date) + "'");
insert_values.push_back("'" + EscapeString(login_accounts_entry.created_at) + "'");
insert_values.push_back("'" + EscapeString(login_accounts_entry.updated_at) + "'");
insert_values.push_back("FROM_UNIXTIME(" + (login_accounts_entry.last_login_date > 0 ? std::to_string(login_accounts_entry.last_login_date) : "null") + ")");
insert_values.push_back("FROM_UNIXTIME(" + (login_accounts_entry.created_at > 0 ? std::to_string(login_accounts_entry.created_at) : "null") + ")");
insert_values.push_back("FROM_UNIXTIME(" + (login_accounts_entry.updated_at > 0 ? std::to_string(login_accounts_entry.updated_at) : "null") + ")");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
@ -283,9 +304,9 @@ public:
entry.account_email = row[3] ? row[3] : "";
entry.source_loginserver = row[4] ? row[4] : "";
entry.last_ip_address = row[5] ? row[5] : "";
entry.last_login_date = row[6] ? row[6] : "";
entry.created_at = row[7] ? row[7] : "";
entry.updated_at = row[8] ? row[8] : "";
entry.last_login_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10);
entry.created_at = strtoll(row[7] ? row[7] : "-1", nullptr, 10);
entry.updated_at = strtoll(row[8] ? row[8] : "-1", nullptr, 10);
all_entries.push_back(entry);
}
@ -316,9 +337,9 @@ public:
entry.account_email = row[3] ? row[3] : "";
entry.source_loginserver = row[4] ? row[4] : "";
entry.last_ip_address = row[5] ? row[5] : "";
entry.last_login_date = row[6] ? row[6] : "";
entry.created_at = row[7] ? row[7] : "";
entry.updated_at = row[8] ? row[8] : "";
entry.last_login_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10);
entry.created_at = strtoll(row[7] ? row[7] : "-1", nullptr, 10);
entry.updated_at = strtoll(row[8] ? row[8] : "-1", nullptr, 10);
all_entries.push_back(entry);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseLoginApiTokensRepository {
public:
@ -22,8 +23,8 @@ public:
std::string token;
int can_write;
int can_read;
std::string created_at;
std::string updated_at;
time_t created_at;
time_t updated_at;
};
static std::string PrimaryKey()
@ -43,11 +44,28 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"token",
"can_write",
"can_read",
"UNIX_TIMESTAMP(created_at)",
"UNIX_TIMESTAMP(updated_at)",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("login_api_tokens");
@ -57,7 +75,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@ -79,8 +97,8 @@ public:
entry.token = "";
entry.can_write = 0;
entry.can_read = 0;
entry.created_at = "";
entry.updated_at = "";
entry.created_at = 0;
entry.updated_at = std::time(nullptr);
return entry;
}
@ -120,8 +138,8 @@ public:
entry.token = row[1] ? row[1] : "";
entry.can_write = atoi(row[2]);
entry.can_read = atoi(row[3]);
entry.created_at = row[4] ? row[4] : "";
entry.updated_at = row[5] ? row[5] : "";
entry.created_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
entry.updated_at = strtoll(row[5] ? row[5] : "-1", nullptr, 10);
return entry;
}
@ -158,8 +176,8 @@ public:
update_values.push_back(columns[1] + " = '" + EscapeString(login_api_tokens_entry.token) + "'");
update_values.push_back(columns[2] + " = " + std::to_string(login_api_tokens_entry.can_write));
update_values.push_back(columns[3] + " = " + std::to_string(login_api_tokens_entry.can_read));
update_values.push_back(columns[4] + " = '" + EscapeString(login_api_tokens_entry.created_at) + "'");
update_values.push_back(columns[5] + " = '" + EscapeString(login_api_tokens_entry.updated_at) + "'");
update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (login_api_tokens_entry.created_at > 0 ? std::to_string(login_api_tokens_entry.created_at) : "null") + ")");
update_values.push_back(columns[5] + " = FROM_UNIXTIME(" + (login_api_tokens_entry.updated_at > 0 ? std::to_string(login_api_tokens_entry.updated_at) : "null") + ")");
auto results = db.QueryDatabase(
fmt::format(
@ -185,8 +203,8 @@ public:
insert_values.push_back("'" + EscapeString(login_api_tokens_entry.token) + "'");
insert_values.push_back(std::to_string(login_api_tokens_entry.can_write));
insert_values.push_back(std::to_string(login_api_tokens_entry.can_read));
insert_values.push_back("'" + EscapeString(login_api_tokens_entry.created_at) + "'");
insert_values.push_back("'" + EscapeString(login_api_tokens_entry.updated_at) + "'");
insert_values.push_back("FROM_UNIXTIME(" + (login_api_tokens_entry.created_at > 0 ? std::to_string(login_api_tokens_entry.created_at) : "null") + ")");
insert_values.push_back("FROM_UNIXTIME(" + (login_api_tokens_entry.updated_at > 0 ? std::to_string(login_api_tokens_entry.updated_at) : "null") + ")");
auto results = db.QueryDatabase(
fmt::format(
@ -220,8 +238,8 @@ public:
insert_values.push_back("'" + EscapeString(login_api_tokens_entry.token) + "'");
insert_values.push_back(std::to_string(login_api_tokens_entry.can_write));
insert_values.push_back(std::to_string(login_api_tokens_entry.can_read));
insert_values.push_back("'" + EscapeString(login_api_tokens_entry.created_at) + "'");
insert_values.push_back("'" + EscapeString(login_api_tokens_entry.updated_at) + "'");
insert_values.push_back("FROM_UNIXTIME(" + (login_api_tokens_entry.created_at > 0 ? std::to_string(login_api_tokens_entry.created_at) : "null") + ")");
insert_values.push_back("FROM_UNIXTIME(" + (login_api_tokens_entry.updated_at > 0 ? std::to_string(login_api_tokens_entry.updated_at) : "null") + ")");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
}
@ -259,8 +277,8 @@ public:
entry.token = row[1] ? row[1] : "";
entry.can_write = atoi(row[2]);
entry.can_read = atoi(row[3]);
entry.created_at = row[4] ? row[4] : "";
entry.updated_at = row[5] ? row[5] : "";
entry.created_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
entry.updated_at = strtoll(row[5] ? row[5] : "-1", nullptr, 10);
all_entries.push_back(entry);
}
@ -289,8 +307,8 @@ public:
entry.token = row[1] ? row[1] : "";
entry.can_write = atoi(row[2]);
entry.can_read = atoi(row[3]);
entry.created_at = row[4] ? row[4] : "";
entry.updated_at = row[5] ? row[5] : "";
entry.created_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10);
entry.updated_at = strtoll(row[5] ? row[5] : "-1", nullptr, 10);
all_entries.push_back(entry);
}

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseLoginServerAdminsRepository {
public:
@ -24,7 +25,7 @@ public:
std::string first_name;
std::string last_name;
std::string email;
std::string registration_date;
time_t registration_date;
std::string registration_ip_address;
};
@ -47,11 +48,30 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"account_name",
"account_password",
"first_name",
"last_name",
"email",
"UNIX_TIMESTAMP(registration_date)",
"registration_ip_address",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("login_server_admins");
@ -61,7 +81,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}
@ -85,7 +105,7 @@ public:
entry.first_name = "";
entry.last_name = "";
entry.email = "";
entry.registration_date = "";
entry.registration_date = 0;
entry.registration_ip_address = "";
return entry;
@ -128,7 +148,7 @@ public:
entry.first_name = row[3] ? row[3] : "";
entry.last_name = row[4] ? row[4] : "";
entry.email = row[5] ? row[5] : "";
entry.registration_date = row[6] ? row[6] : "";
entry.registration_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10);
entry.registration_ip_address = row[7] ? row[7] : "";
return entry;
@ -168,7 +188,7 @@ public:
update_values.push_back(columns[3] + " = '" + EscapeString(login_server_admins_entry.first_name) + "'");
update_values.push_back(columns[4] + " = '" + EscapeString(login_server_admins_entry.last_name) + "'");
update_values.push_back(columns[5] + " = '" + EscapeString(login_server_admins_entry.email) + "'");
update_values.push_back(columns[6] + " = '" + EscapeString(login_server_admins_entry.registration_date) + "'");
update_values.push_back(columns[6] + " = FROM_UNIXTIME(" + (login_server_admins_entry.registration_date > 0 ? std::to_string(login_server_admins_entry.registration_date) : "null") + ")");
update_values.push_back(columns[7] + " = '" + EscapeString(login_server_admins_entry.registration_ip_address) + "'");
auto results = db.QueryDatabase(
@ -197,7 +217,7 @@ public:
insert_values.push_back("'" + EscapeString(login_server_admins_entry.first_name) + "'");
insert_values.push_back("'" + EscapeString(login_server_admins_entry.last_name) + "'");
insert_values.push_back("'" + EscapeString(login_server_admins_entry.email) + "'");
insert_values.push_back("'" + EscapeString(login_server_admins_entry.registration_date) + "'");
insert_values.push_back("FROM_UNIXTIME(" + (login_server_admins_entry.registration_date > 0 ? std::to_string(login_server_admins_entry.registration_date) : "null") + ")");
insert_values.push_back("'" + EscapeString(login_server_admins_entry.registration_ip_address) + "'");
auto results = db.QueryDatabase(
@ -234,7 +254,7 @@ public:
insert_values.push_back("'" + EscapeString(login_server_admins_entry.first_name) + "'");
insert_values.push_back("'" + EscapeString(login_server_admins_entry.last_name) + "'");
insert_values.push_back("'" + EscapeString(login_server_admins_entry.email) + "'");
insert_values.push_back("'" + EscapeString(login_server_admins_entry.registration_date) + "'");
insert_values.push_back("FROM_UNIXTIME(" + (login_server_admins_entry.registration_date > 0 ? std::to_string(login_server_admins_entry.registration_date) : "null") + ")");
insert_values.push_back("'" + EscapeString(login_server_admins_entry.registration_ip_address) + "'");
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
@ -275,7 +295,7 @@ public:
entry.first_name = row[3] ? row[3] : "";
entry.last_name = row[4] ? row[4] : "";
entry.email = row[5] ? row[5] : "";
entry.registration_date = row[6] ? row[6] : "";
entry.registration_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10);
entry.registration_ip_address = row[7] ? row[7] : "";
all_entries.push_back(entry);
@ -307,7 +327,7 @@ public:
entry.first_name = row[3] ? row[3] : "";
entry.last_name = row[4] ? row[4] : "";
entry.email = row[5] ? row[5] : "";
entry.registration_date = row[6] ? row[6] : "";
entry.registration_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10);
entry.registration_ip_address = row[7] ? row[7] : "";
all_entries.push_back(entry);

View File

@ -14,6 +14,7 @@
#include "../../database.h"
#include "../../string_util.h"
#include <ctime>
class BaseLoginServerListTypesRepository {
public:
@ -35,11 +36,24 @@ public:
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"description",
};
}
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("login_server_list_types");
@ -49,7 +63,7 @@ public:
{
return fmt::format(
"SELECT {} FROM {}",
ColumnsRaw(),
SelectColumnsRaw(),
TableName()
);
}

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