Add REST annotations and refactor properties file handling

Introduced `@RestController` and `@RequestMapping` in `StaffAppController` for standardized API endpoints. Refactored properties file handling in `PropertiesLoader` and `PropertiesWriter` to simplify file creation logic.
This commit is contained in:
Teriuihi 2024-08-06 23:17:06 +02:00
parent 04088c20e5
commit 2c3cb48667
4 changed files with 50 additions and 16 deletions

5
.gitignore vendored
View File

@ -39,4 +39,7 @@ bin/
.vscode/
### Mac OS ###
.DS_Store
.DS_Store
*.bat
config/

View File

@ -4,16 +4,11 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="ce59df2a-8d56-446a-867b-80e627daf479" name="Changes" comment="Update URI to point to Discord bot endpoint&#10;&#10;Changed the URI in VerifyController to use the Discord bot's endpoint for form submission. This adjustment is part of the process to route form data correctly through the specified internal service.">
<change afterPath="$PROJECT_DIR$/src/main/java/com/alttd/forms/apply/StaffAppController.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/com/alttd/forms/apply/StaffAppFormData.java" afterDir="false" />
<list default="true" id="ce59df2a-8d56-446a-867b-80e627daf479" name="Changes" comment="Add REST annotations to StaffAppController&#10;&#10;Introduce `@RestController` and `@RequestMapping` annotations to the `StaffAppController` class. This change standardizes the API endpoint and ensures all methods within this class are mapped correctly under `/api/apply`.">
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/alttd/forms/contact/ContactController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/alttd/forms/contact/ContactController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/alttd/forms/contact/ContactFormData.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/alttd/forms/contact/ContactFormData.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/alttd/forms/contact/StoreFormQuery.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/alttd/forms/form/StoreFormQuery.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/alttd/forms/form/Form.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/alttd/forms/form/Form.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application.properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/test/java/TestForm.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/TestForm.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/alttd/forms/properties/PropertiesLoader.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/alttd/forms/properties/PropertiesLoader.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/alttd/forms/properties/PropertiesWriter.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/alttd/forms/properties/PropertiesWriter.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -146,7 +141,7 @@
<recent name="com.alttd.forms.apply" />
</key>
</component>
<component name="RunManager" selected="Gradle.TestForm">
<component name="RunManager" selected="Spring Boot.Main">
<configuration name="TestForm" type="GradleRunConfiguration" factoryName="Gradle" temporary="true">
<ExternalSystemSettings>
<option name="executionName" />
@ -371,7 +366,7 @@
<workItem from="1722786481232" duration="617000" />
<workItem from="1722801254695" duration="6135000" />
<workItem from="1722879625782" duration="358000" />
<workItem from="1722973564053" duration="2026000" />
<workItem from="1722973564053" duration="5260000" />
</task>
<task id="LOCAL-00001" summary="Initial commit for site for forms">
<option name="closed" value="true" />
@ -493,7 +488,39 @@
<option name="project" value="LOCAL" />
<updated>1722812932077</updated>
</task>
<option name="localTasksCounter" value="16" />
<task id="LOCAL-00016" summary="Rename StoreFormQuery package to forms.form&#10;&#10;Updated the package name for consistency and better categorization. Adjusted imports in related test files to reflect the new package structure.">
<option name="closed" value="true" />
<created>1722975667414</created>
<option name="number" value="00016" />
<option name="presentableId" value="LOCAL-00016" />
<option name="project" value="LOCAL" />
<updated>1722975667414</updated>
</task>
<task id="LOCAL-00017" summary="Refactor HTML generation in ContactFormData&#10;&#10;Extract the HTML generation logic to a reusable method in the Form class. This change reduces code duplication and enhances maintainability by centralizing the table generation functionality.">
<option name="closed" value="true" />
<created>1722975690755</created>
<option name="number" value="00017" />
<option name="presentableId" value="LOCAL-00017" />
<option name="project" value="LOCAL" />
<updated>1722975690755</updated>
</task>
<task id="LOCAL-00018" summary="Add Staff Application Form handling&#10;&#10;Introduced `StaffAppController` and `StaffAppFormData` to handle staff application form submissions. The controller now stores user data, initiates email verification, and provides appropriate responses based on the verification outcome. Additionally, updated `application.properties` and cleaned up IntelliJ workspace.xml.">
<option name="closed" value="true" />
<created>1722975703502</created>
<option name="number" value="00018" />
<option name="presentableId" value="LOCAL-00018" />
<option name="project" value="LOCAL" />
<updated>1722975703502</updated>
</task>
<task id="LOCAL-00019" summary="Add REST annotations to StaffAppController&#10;&#10;Introduce `@RestController` and `@RequestMapping` annotations to the `StaffAppController` class. This change standardizes the API endpoint and ensures all methods within this class are mapped correctly under `/api/apply`.">
<option name="closed" value="true" />
<created>1722975785066</created>
<option name="number" value="00019" />
<option name="presentableId" value="LOCAL-00019" />
<option name="project" value="LOCAL" />
<updated>1722975785066</updated>
</task>
<option name="localTasksCounter" value="20" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -527,6 +554,10 @@
<MESSAGE value="Refactor logging for better granularity&#10;&#10;Updated logging levels in multiple classes to differentiate between debug and trace information. Improved log messages to support parameterized logs, ensuring sensitive or variable information is handled appropriately without concatenation." />
<MESSAGE value="Enhance logging for mail verification details&#10;&#10;Updated logging to provide more detailed information about user credentials and email actions. This helps in debugging and monitoring mail verification processes more effectively. Adjusted trace messages to include username and password for better traceability." />
<MESSAGE value="Update URI to point to Discord bot endpoint&#10;&#10;Changed the URI in VerifyController to use the Discord bot's endpoint for form submission. This adjustment is part of the process to route form data correctly through the specified internal service." />
<option name="LAST_COMMIT_MESSAGE" value="Update URI to point to Discord bot endpoint&#10;&#10;Changed the URI in VerifyController to use the Discord bot's endpoint for form submission. This adjustment is part of the process to route form data correctly through the specified internal service." />
<MESSAGE value="Rename StoreFormQuery package to forms.form&#10;&#10;Updated the package name for consistency and better categorization. Adjusted imports in related test files to reflect the new package structure." />
<MESSAGE value="Refactor HTML generation in ContactFormData&#10;&#10;Extract the HTML generation logic to a reusable method in the Form class. This change reduces code duplication and enhances maintainability by centralizing the table generation functionality." />
<MESSAGE value="Add Staff Application Form handling&#10;&#10;Introduced `StaffAppController` and `StaffAppFormData` to handle staff application form submissions. The controller now stores user data, initiates email verification, and provides appropriate responses based on the verification outcome. Additionally, updated `application.properties` and cleaned up IntelliJ workspace.xml." />
<MESSAGE value="Add REST annotations to StaffAppController&#10;&#10;Introduce `@RestController` and `@RequestMapping` annotations to the `StaffAppController` class. This change standardizes the API endpoint and ensures all methods within this class are mapped correctly under `/api/apply`." />
<option name="LAST_COMMIT_MESSAGE" value="Add REST annotations to StaffAppController&#10;&#10;Introduce `@RestController` and `@RequestMapping` annotations to the `StaffAppController` class. This change standardizes the API endpoint and ensures all methods within this class are mapped correctly under `/api/apply`." />
</component>
</project>

View File

@ -26,7 +26,7 @@ public class PropertiesLoader {
}
file = new File(currentJarPath.get(), fileName);
} else {
file = Path.of(URI.create("file://" + path + File.separator + fileName)).toFile();
file = new File(path, fileName);
}

View File

@ -25,7 +25,7 @@ public class PropertiesWriter {
}
file = new File(currentJarPath.get(), fileName);
} else {
file = Path.of(URI.create("file://" + path + File.separator + fileName)).toFile();
file = new File(path, fileName);
}
if (file.exists()) {