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
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,
LocalDateTime tempBanTimestamp) {
String pin, String pic, byte chrSlots, LoginState loginState, LocalDateTime lastLogin,
boolean banned, LocalDateTime tempBannedUntil) {
public Account {
Objects.requireNonNull(name);
Objects.requireNonNull(password);

View File

@@ -20,7 +20,7 @@ public class AccountRepository {
public Optional<Account> findByNameIgnoreCase(String name) {
String sql = """
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
WHERE lower(name) = lower(:name)""";
try (Handle handle = connection.getHandle()) {
@@ -34,7 +34,7 @@ public class AccountRepository {
public Optional<Account> findById(int accountId) {
String sql = """
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
WHERE id = :id""";
try (Handle handle = connection.getHandle()) {
@@ -55,7 +55,7 @@ public class AccountRepository {
.bind("password", account.password())
.bind("birthdate", account.birthdate())
.bind("chrSlots", account.chrSlots())
.bind("loginState", account.loginState())
.bind("loginState", account.loginState().getValue())
.executeAndReturnGeneratedKeys("id")
.mapTo(Integer.class)
.one();

View File

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