Add staff application support with database integration and submission flow
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
package com.alttd.altitudeweb.database.web_db.forms;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public record StaffApplication(
|
||||
UUID id,
|
||||
UUID uuid,
|
||||
String email,
|
||||
Integer age,
|
||||
String discordUsername,
|
||||
Boolean meetsRequirements,
|
||||
String pronouns,
|
||||
LocalDate joinDate,
|
||||
Integer weeklyPlaytime,
|
||||
String availableDays,
|
||||
String availableTimes,
|
||||
String previousExperience,
|
||||
String pluginExperience,
|
||||
String moderatorExpectations,
|
||||
String additionalInfo,
|
||||
Instant createdAt,
|
||||
Instant sendAt,
|
||||
Long assignedTo
|
||||
) {
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.alttd.altitudeweb.database.web_db.forms;
|
||||
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface StaffApplicationMapper {
|
||||
|
||||
@Insert("""
|
||||
INSERT INTO staff_applications (
|
||||
id, uuid, email, age, discord_username, meets_requirements, pronouns, join_date,
|
||||
weekly_playtime, available_days, available_times, previous_experience, plugin_experience,
|
||||
moderator_expectations, additional_info, created_at, send_at, assigned_to
|
||||
) VALUES (
|
||||
#{id}, #{uuid}, #{email}, #{age}, #{discordUsername}, #{meetsRequirements}, #{pronouns}, #{joinDate},
|
||||
#{weeklyPlaytime},
|
||||
#{availableDays},
|
||||
#{availableTimes}, #{previousExperience}, #{pluginExperience},
|
||||
#{moderatorExpectations}, #{additionalInfo}, #{createdAt}, #{sendAt}, #{assignedTo}
|
||||
)
|
||||
""")
|
||||
void insert(StaffApplication application);
|
||||
|
||||
@Update("""
|
||||
UPDATE staff_applications SET send_at = NOW()
|
||||
WHERE id = #{id}
|
||||
""")
|
||||
void markAsSent(@Param("id") UUID id);
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import com.alttd.altitudeweb.database.web_db.KeyPairMapper;
|
||||
import com.alttd.altitudeweb.database.web_db.PrivilegedUserMapper;
|
||||
import com.alttd.altitudeweb.database.web_db.SettingsMapper;
|
||||
import com.alttd.altitudeweb.database.web_db.forms.AppealMapper;
|
||||
import com.alttd.altitudeweb.database.web_db.forms.StaffApplicationMapper;
|
||||
import com.alttd.altitudeweb.database.web_db.mail.EmailVerificationMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
@@ -23,6 +24,7 @@ public class InitializeWebDb {
|
||||
configuration.addMapper(KeyPairMapper.class);
|
||||
configuration.addMapper(PrivilegedUserMapper.class);
|
||||
configuration.addMapper(AppealMapper.class);
|
||||
configuration.addMapper(StaffApplicationMapper.class);
|
||||
configuration.addMapper(EmailVerificationMapper.class);
|
||||
}).join()
|
||||
.runQuery(sqlSession -> {
|
||||
@@ -31,6 +33,7 @@ public class InitializeWebDb {
|
||||
createPrivilegedUsersTable(sqlSession);
|
||||
createPrivilegesTable(sqlSession);
|
||||
createAppealTable(sqlSession);
|
||||
createStaffApplicationsTable(sqlSession);
|
||||
createUserEmailsTable(sqlSession);
|
||||
});
|
||||
log.debug("Initialized WebDb");
|
||||
@@ -126,6 +129,37 @@ public class InitializeWebDb {
|
||||
}
|
||||
}
|
||||
|
||||
private static void createStaffApplicationsTable(@NotNull SqlSession sqlSession) {
|
||||
String query = """
|
||||
CREATE TABLE IF NOT EXISTS staff_applications (
|
||||
id UUID NOT NULL DEFAULT (UUID()) PRIMARY KEY,
|
||||
uuid UUID NOT NULL,
|
||||
email VARCHAR(320) NOT NULL,
|
||||
age INT NOT NULL,
|
||||
discord_username VARCHAR(32) NOT NULL,
|
||||
meets_requirements BOOLEAN NOT NULL,
|
||||
pronouns VARCHAR(32) NULL,
|
||||
join_date DATE NOT NULL,
|
||||
weekly_playtime INT NOT NULL,
|
||||
available_days TEXT NOT NULL,
|
||||
available_times TEXT NOT NULL,
|
||||
previous_experience TEXT NOT NULL,
|
||||
plugin_experience TEXT NOT NULL,
|
||||
moderator_expectations TEXT NOT NULL,
|
||||
additional_info TEXT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||
send_at TIMESTAMP NULL,
|
||||
assigned_to BIGINT UNSIGNED NULL,
|
||||
FOREIGN KEY (uuid) REFERENCES privileged_users(uuid) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
""";
|
||||
try (Statement statement = sqlSession.getConnection().createStatement()) {
|
||||
statement.execute(query);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void createAppealTable(@NotNull SqlSession sqlSession) {
|
||||
String query = """
|
||||
CREATE TABLE IF NOT EXISTS appeals (
|
||||
|
||||
Reference in New Issue
Block a user