Merge pull request 'api: Small things' (#90) from 3002833/Backend:main into restfull

Reviewed-on: Maradona/Backend#90
pull/1/head
David Hess 2024-11-11 16:50:16 +01:00
commit 2fc92dbc3a
5 changed files with 97 additions and 11 deletions

View File

@ -35,11 +35,9 @@ public class DefaultValueLoader implements CommandLineRunner {
@Override
public void run(String... args) {
// Clear all tables
employeeRepository.deleteAll();
secondarySkillRepository.deleteAll();
primarySkillRepository.deleteAll();
formOfAddressRepository.deleteAll();
if (employeeRepository.count() > 0) {
return;
}
// Create form of addresses
FormOfAddress formOfAddress1 = new FormOfAddress();
@ -48,9 +46,6 @@ public class DefaultValueLoader implements CommandLineRunner {
FormOfAddress formOfAddress2 = new FormOfAddress();
formOfAddress2.setDescription("Frau");
FormOfAddress formOfAddress3 = new FormOfAddress();
formOfAddress3.setDescription("Einkaufstüte");
formOfAddress1 = formOfAddressRepository.save(formOfAddress1);
formOfAddress2 = formOfAddressRepository.save(formOfAddress2);

View File

@ -0,0 +1,58 @@
package com.maradona.backend.controllers.page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Controller for routing to the error pages.
*
* List of endpoints:
* - GET /error/400
* - GET /error/404
* - GET /error/500
*/
@Controller
@RequestMapping("/error")
public class ErrorPage {
/**
* Error page for 400 Bad Request.
*
* This page is displayed when the request is malformed and the server cannot
* process it.
*
* @return The 400 error page template.
*/
@GetMapping("/400")
public String error400() {
return "pages/error/400";
}
/**
* Error page for 404 Not Found.
*
* This page is displayed when the requested resource could not be found on the
* server. This can be due to a wrong URL or a deleted resource. The user should
* be informed that the resource is not available.
*
* @return The 404 error page template.
*/
@GetMapping("/404")
public String error404() {
return "pages/error/404";
}
/**
* Error page for 500 Internal Server Error.
*
* This page is displayed when the server encountered an unexpected condition
* that prevented it from fulfilling the request. The user should be informed
* that the server is experiencing problems and the request cannot be processed.
*
* @return The 500 error page template.
*/
@GetMapping("/500")
public String error500() {
return "pages/error/500";
}
}

View File

@ -4,24 +4,53 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
/**
* Controller for routing to the core pages.
*
* List of endpoints:
* - GET /
* - GET /impressum
* - GET /datenschutz
* - GET /notes
*/
@Controller
public class Page {
/**
* Returns the home page.
*
* @param model The model with the data to be displayed.
* @return The home page template.
*/
@GetMapping({ "/", "" })
public String home(Model model) {
return "pages/core/home";
}
/**
* Returns the impressum page.
*
* @return The impressum page template.
*/
@GetMapping("/impressum")
public String impressum() {
return "pages/core/impressum";
}
/**
* Returns the datenschutz page.
*
* @return The datenschutz page template.
*/
@GetMapping("/datenschutz")
public String datenschutz() {
return "pages/core/datenschutz";
}
/**
* Returns the notes page.
*
* @return The notes page template.
*/
@GetMapping("/notes")
public String notes() {
return "pages/core/notes";

View File

@ -52,7 +52,11 @@ public class SkillsPage {
*/
@GetMapping({ "/", "" })
public String profile(Model model) {
model.addAttribute("employee", employeeDetails.getEmployeeByEid(user).orElse(null));
var employee = employeeDetails.getEmployeeByEid(user).orElse(null);
if (employee == null) {
return "/404";
}
model.addAttribute("employee", employee);
model.addAttribute("skills", skillService.getUserSkills(user));
return "/pages/skills/overview";
}

View File

@ -24,7 +24,7 @@ public class Employee {
private String lastName;
@ManyToOne
@JoinColumn(name = "FID", referencedColumnName = "fid")
@JoinColumn(name = "fid")
private FormOfAddress formOfAddress;
private LocalTime dStart;