Rename "temp_ban_timestamp" -> "temp_banned_until"

This commit is contained in:
P0nk
2024-09-29 16:34:04 +02:00
parent b45620154c
commit d00b4ed678
4 changed files with 28 additions and 28 deletions

View File

@@ -12,8 +12,8 @@ import java.util.Objects;
*/ */
@Builder @Builder
public record Account(int id, String name, String password, boolean acceptedTos, Byte gender, LocalDate birthdate, public record Account(int id, String name, String password, boolean acceptedTos, Byte gender, LocalDate birthdate,
String pin, String pic, byte chrSlots, LoginState loginState, LocalDateTime lastLogin, boolean banned, String pin, String pic, byte chrSlots, LoginState loginState, LocalDateTime lastLogin,
LocalDateTime tempBanTimestamp) { boolean banned, LocalDateTime tempBannedUntil) {
public Account { public Account {
Objects.requireNonNull(name); Objects.requireNonNull(name);
Objects.requireNonNull(password); Objects.requireNonNull(password);

View File

@@ -20,7 +20,7 @@ public class AccountRepository {
public Optional<Account> findByNameIgnoreCase(String name) { public Optional<Account> findByNameIgnoreCase(String name) {
String sql = """ String sql = """
SELECT id, name, password, pin, pic, birthdate, gender, tos_accepted, chr_slots, login_state, SELECT id, name, password, pin, pic, birthdate, gender, tos_accepted, chr_slots, login_state,
last_login, banned, temp_ban_timestamp last_login, banned, temp_banned_until
FROM account FROM account
WHERE lower(name) = lower(:name)"""; WHERE lower(name) = lower(:name)""";
try (Handle handle = connection.getHandle()) { try (Handle handle = connection.getHandle()) {
@@ -34,7 +34,7 @@ public class AccountRepository {
public Optional<Account> findById(int accountId) { public Optional<Account> findById(int accountId) {
String sql = """ String sql = """
SELECT id, name, password, pin, pic, birthdate, gender, tos_accepted, chr_slots, login_state, SELECT id, name, password, pin, pic, birthdate, gender, tos_accepted, chr_slots, login_state,
last_login, banned, temp_ban_timestamp last_login, banned, temp_banned_until
FROM account FROM account
WHERE id = :id"""; WHERE id = :id""";
try (Handle handle = connection.getHandle()) { try (Handle handle = connection.getHandle()) {
@@ -55,7 +55,7 @@ public class AccountRepository {
.bind("password", account.password()) .bind("password", account.password())
.bind("birthdate", account.birthdate()) .bind("birthdate", account.birthdate())
.bind("chrSlots", account.chrSlots()) .bind("chrSlots", account.chrSlots())
.bind("loginState", account.loginState()) .bind("loginState", account.loginState().getValue())
.executeAndReturnGeneratedKeys("id") .executeAndReturnGeneratedKeys("id")
.mapTo(Integer.class) .mapTo(Integer.class)
.one(); .one();

View File

@@ -35,7 +35,7 @@ public class AccountRowMapper implements RowMapper<Account> {
.map(Timestamp::toLocalDateTime) .map(Timestamp::toLocalDateTime)
.orElse(null)) .orElse(null))
.banned(rs.getBoolean("banned")) .banned(rs.getBoolean("banned"))
.tempBanTimestamp(Optional.ofNullable(rs.getTimestamp("temp_ban_timestamp")) .tempBannedUntil(Optional.ofNullable(rs.getTimestamp("temp_banned_until"))
.map(Timestamp::toLocalDateTime) .map(Timestamp::toLocalDateTime)
.orElse(null)) .orElse(null))
.build(); .build();

View File

@@ -1,27 +1,27 @@
CREATE TABLE account CREATE TABLE account
( (
id serial NOT NULL, id serial NOT NULL,
name varchar(30) NOT NULL, name varchar(30) NOT NULL,
password varchar(200) NOT NULL, password varchar(200) NOT NULL,
pin varchar(4), pin varchar(4),
pic varchar(26), pic varchar(26),
created_at timestamp DEFAULT now() NOT NULL, created_at timestamp DEFAULT now() NOT NULL,
birthdate date NOT NULL, birthdate date NOT NULL,
tos_accepted boolean DEFAULT false NOT NULL, tos_accepted boolean DEFAULT false NOT NULL,
gender smallint, gender smallint,
chr_slots smallint NOT NULL, chr_slots smallint NOT NULL,
nx_credit integer DEFAULT 0 NOT NULL, nx_credit integer DEFAULT 0 NOT NULL,
maple_point integer DEFAULT 0 NOT NULL, maple_point integer DEFAULT 0 NOT NULL,
nx_prepaid integer DEFAULT 0 NOT NULL, nx_prepaid integer DEFAULT 0 NOT NULL,
login_state smallint NOT NULL, login_state smallint NOT NULL,
last_login timestamp, last_login timestamp,
banned boolean DEFAULT false NOT NULL, banned boolean DEFAULT false NOT NULL,
banreason text, banreason text,
temp_ban_timestamp timestamp, temp_banned_until timestamp,
greason smallint, greason smallint,
ip text, ip text,
hwid text, hwid text,
macs text, macs text,
PRIMARY KEY (id), PRIMARY KEY (id),
UNIQUE (name) UNIQUE (name)
); );