Add GetWhere and DeleteWhere repository methods

This commit is contained in:
Akkadius
2020-04-04 04:44:39 -05:00
parent 9faae00d15
commit 15c9b64120
164 changed files with 8806 additions and 594 deletions
+58 -1
View File
@@ -298,7 +298,7 @@ public:
return account_entry;
}
account_entry = InstanceListRepository::NewEntity();
account_entry = AccountRepository::NewEntity();
return account_entry;
}
@@ -389,6 +389,63 @@ public:
return all_entries;
}
static std::vector<Account> GetWhere(std::string where_filter)
{
std::vector<Account> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Account entry{};
entry.id = atoi(row[0]);
entry.name = row[1];
entry.charname = row[2];
entry.sharedplat = atoi(row[3]);
entry.password = row[4];
entry.status = atoi(row[5]);
entry.ls_id = row[6];
entry.lsaccount_id = atoi(row[7]);
entry.gmspeed = atoi(row[8]);
entry.revoked = atoi(row[9]);
entry.karma = atoi(row[10]);
entry.minilogin_ip = row[11];
entry.hideme = atoi(row[12]);
entry.rulesflag = atoi(row[13]);
entry.suspendeduntil = row[14];
entry.time_creation = atoi(row[15]);
entry.expansion = atoi(row[16]);
entry.ban_reason = row[17];
entry.suspend_reason = row[18];
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_ACCOUNT_REPOSITORY_H