Merge pull request 'chore: Update branch' (#1) from Maradona/Backend:restfull into restfull
Reviewed-on: #1pull/1/head
commit
6e01b147b3
Binary file not shown.
1
pom.xml
1
pom.xml
|
@ -102,6 +102,7 @@
|
|||
<destDir>${project.build.directory}/docs</destDir>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -9,8 +9,6 @@ import com.maradona.backend.repositories.EmployeeRepository;
|
|||
import com.maradona.backend.repositories.FormOfAddressRepository;
|
||||
import com.maradona.backend.repositories.PrimarySkillRepository;
|
||||
import com.maradona.backend.repositories.SecondarySkillRepository;
|
||||
import com.maradona.backend.repositories.EmployeeSecondarySkillRepository;
|
||||
import com.maradona.backend.repositories.ProjectRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
package com.maradona.backend.controllers.api;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.maradona.backend.dto.SkillPrototype;
|
||||
import com.maradona.backend.entities.Employee;
|
||||
import com.maradona.backend.services.EmployeeService;
|
||||
import com.maradona.backend.services.SecondarySkillService;
|
||||
|
||||
/**
|
||||
* Controller for handling employee related requests.
|
||||
|
@ -28,43 +28,40 @@ import com.maradona.backend.services.SecondarySkillService;
|
|||
* - PUT /api/employee/skill/level
|
||||
* - DELETE /api/employee/skill
|
||||
*
|
||||
* @see EmployeeService
|
||||
* @see SecondarySkillService
|
||||
* @see com.maradona.backend.entities.Employee
|
||||
*/
|
||||
@Controller
|
||||
@RestController
|
||||
@RequestMapping("/api/employee")
|
||||
public class EmployeeController {
|
||||
|
||||
@Autowired
|
||||
private EmployeeService employeeService;
|
||||
|
||||
/**
|
||||
* Hardcoded user ID for testing purposes.
|
||||
*/
|
||||
Long user = Long.valueOf(1);
|
||||
|
||||
/**
|
||||
* Returns a specific employee from the database.
|
||||
*
|
||||
* @param id The ID of the requested employee.
|
||||
* @param model The model with the requested data.
|
||||
* @see Employee
|
||||
* @param id The ID of the requested employee.
|
||||
* @return The employee with the requested ID.
|
||||
* @see com.maradona.backend.entities.Employee
|
||||
*/
|
||||
@GetMapping({ "/", "" })
|
||||
public void get(@RequestParam Long id, Model model) {
|
||||
var employee = employeeService.getEmployeeById(id).orElse(null);
|
||||
model.addAttribute("employee", employee);
|
||||
public ResponseEntity<Employee> get(@RequestParam Long id) {
|
||||
return employeeService.getEmployeeById(id)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all employees from the database.
|
||||
*
|
||||
* @param model The model with the requested data.
|
||||
* @see Employee
|
||||
* @return list of employees
|
||||
* @see com.maradona.backend.entities.Employee
|
||||
*/
|
||||
@GetMapping("/all")
|
||||
public void getAll(Model model) {
|
||||
var employees = employeeService.getAllEmployees();
|
||||
model.addAttribute("employees", employees);
|
||||
public ResponseEntity<Iterable<Employee>> getAll() {
|
||||
return ResponseEntity.ok(employeeService.getAllEmployees());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,12 +70,12 @@ public class EmployeeController {
|
|||
* @param skillId ID of the secondary skill
|
||||
* @param level Level of the secondary skill
|
||||
* @return list of employees
|
||||
* @see Employee
|
||||
* @see com.maradona.backend.entities.Employee
|
||||
* @see com.maradona.backend.entities.SecondarySkill
|
||||
*/
|
||||
@GetMapping("/from-skill")
|
||||
public void getFromSkill(@RequestParam Long skillId, @RequestParam Integer level, Model model) {
|
||||
var employees = employeeService.getEmployeesBySecondarySkill(skillId, level);
|
||||
model.addAttribute("employees", employees);
|
||||
public ResponseEntity<Iterable<Employee>> getFromSkill(@RequestParam Long skillId, @RequestParam Integer level) {
|
||||
return ResponseEntity.ok(employeeService.getEmployeesBySecondarySkill(skillId, level));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,11 +83,14 @@ public class EmployeeController {
|
|||
*
|
||||
* @param skillPrototype The skillPrototype object containing the secondary
|
||||
* skill ID and level
|
||||
* @see SkillPrototype
|
||||
* @return HTTP status indicating the outcome of the operation
|
||||
* @see com.maradona.backend.entities.Employee
|
||||
* @see com.maradona.backend.entities.SecondarySkill
|
||||
*/
|
||||
@PostMapping("/skill/protoype")
|
||||
public void postSkillProtoype(@ModelAttribute SkillPrototype skillPrototype) {
|
||||
public ResponseEntity<Void> postSkillProtoype(@RequestBody SkillPrototype skillPrototype) {
|
||||
employeeService.addSecondarySkillToEmployee(user, skillPrototype);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,21 +98,28 @@ public class EmployeeController {
|
|||
*
|
||||
* @param skillId ID of the secondary skill
|
||||
* @param level Level of the secondary skill
|
||||
* @see SecondarySkill
|
||||
* @return HTTP status indicating the outcome of the operation
|
||||
* @see com.maradona.backend.entities.Employee
|
||||
* @see com.maradona.backend.entities.SecondarySkill
|
||||
* @see com.maradona.backend.entities.EmployeeSecondarySkill
|
||||
*/
|
||||
@PutMapping("/skill/level")
|
||||
public void putSkillLevel(@RequestParam Long skillId, @RequestParam Integer level) {
|
||||
public ResponseEntity<Void> putSkillLevel(@RequestParam Long skillId, @RequestParam Integer level) {
|
||||
employeeService.updateSecondarySkillLevel(user, skillId, level);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes secondary skill from user profile
|
||||
*
|
||||
* @param id ID of the secondary skill
|
||||
* @see SecondarySkill
|
||||
* Removes a secondary skill from the user profile.
|
||||
*
|
||||
* @param id The ID of the secondary skill to be removed
|
||||
* @return HTTP status indicating the outcome of the operation
|
||||
* @see com.maradona.backend.entities.Employee
|
||||
* @see com.maradona.backend.entities.SecondarySkill
|
||||
*/
|
||||
@DeleteMapping("/skill")
|
||||
public void delete(@RequestParam Long id) {
|
||||
public ResponseEntity<Void> delete(@RequestParam Long id) {
|
||||
employeeService.deleteSecondarySkillFromEmployee(user, id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
package com.maradona.backend.controllers.api;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
@ -25,7 +27,7 @@ import com.maradona.backend.services.SecondarySkillService;
|
|||
* - PUT /api/primary-skill
|
||||
* - DELETE /api/primary-skill
|
||||
*
|
||||
* @see PrimarySkill
|
||||
* @see com.maradona.backend.entities.PrimarySkill
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/primary-skill")
|
||||
|
@ -42,51 +44,61 @@ public class PrimarySkillController {
|
|||
*
|
||||
* @param id The ID of the requested primary skill.
|
||||
* @return The primary skill with the requested ID.
|
||||
* @see PrimarySkill
|
||||
* @see com.maradona.backend.entities.PrimarySkill
|
||||
*/
|
||||
@GetMapping({ "/", "" })
|
||||
public PrimarySkill get(@RequestParam Long id) {
|
||||
return primarySkillService.getPrimarySkillById(id).orElse(null);
|
||||
public ResponseEntity<PrimarySkill> get(@RequestParam Long id) {
|
||||
return primarySkillService.getPrimarySkillById(id)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all primary skills from the database.
|
||||
*
|
||||
* @return A list of all primary skills.
|
||||
* @see PrimarySkill
|
||||
* @return list of primary skills
|
||||
* @see com.maradona.backend.entities.PrimarySkill
|
||||
*/
|
||||
@GetMapping("/all")
|
||||
public Iterable<PrimarySkill> getAll() {
|
||||
return primarySkillService.getAllPrimarySkills();
|
||||
public ResponseEntity<Iterable<PrimarySkill>> getAll() {
|
||||
return ResponseEntity.ok(primarySkillService.getAllPrimarySkills());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new primary skill to the database.
|
||||
*
|
||||
* @param primarySkill The primary skill to be added.
|
||||
* @return The added primary skill.
|
||||
* @see PrimarySkill
|
||||
* @param primarySkill The primary skill to be added
|
||||
* @return The added primary skill
|
||||
* @see com.maradona.backend.entities.PrimarySkill
|
||||
*/
|
||||
@PostMapping({ "/", "" })
|
||||
public void post(@RequestBody PrimarySkill primarySkill) {
|
||||
primarySkillService.savePrimarySkill(primarySkill);
|
||||
public ResponseEntity<PrimarySkill> post(@RequestBody PrimarySkill primarySkill) {
|
||||
PrimarySkill savedPrimarySkill = primarySkillService.savePrimarySkill(primarySkill);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(savedPrimarySkill);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing primary skill in the database.
|
||||
* Modifies an existing primary skill in the database.
|
||||
*
|
||||
* @param primarySkill The primary skill to be updated.
|
||||
* @return The updated primary skill.
|
||||
* @see PrimarySkill
|
||||
* @param primarySkill The primary skill to be modified
|
||||
* @return The modified primary skill
|
||||
* @see com.maradona.backend.entities.PrimarySkill
|
||||
*/
|
||||
@PutMapping({ "/", "" })
|
||||
public void put(@RequestBody PrimarySkill primarySkill) {
|
||||
primarySkillService.savePrimarySkill(primarySkill);
|
||||
public ResponseEntity<PrimarySkill> put(@RequestBody PrimarySkill primarySkill) {
|
||||
PrimarySkill updatedPrimarySkill = primarySkillService.savePrimarySkill(primarySkill);
|
||||
return ResponseEntity.ok(updatedPrimarySkill);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a primary skill from the database.
|
||||
*
|
||||
* @param id The ID of the primary skill to be deleted
|
||||
* @return HTTP status indicating the outcome of the operation
|
||||
* @see com.maradona.backend.entities.PrimarySkill
|
||||
*/
|
||||
@DeleteMapping({ "/", "" })
|
||||
public void delete(@RequestParam Long id) {
|
||||
// Find and delete all secondary skills associated with the primary skill
|
||||
public ResponseEntity<Void> delete(@RequestParam Long id) {
|
||||
var primarySkill = primarySkillService.getPrimarySkillById(id);
|
||||
if (primarySkill.isPresent()) {
|
||||
var secondarySkills = secondarySkillService.getAllSecondarySkills();
|
||||
|
@ -95,8 +107,10 @@ public class PrimarySkillController {
|
|||
secondarySkillService.deleteSecondarySkill(secondarySkill.getSsid());
|
||||
}
|
||||
}
|
||||
// Delete the primary skill
|
||||
primarySkillService.deletePrimarySkill(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
} else {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +1,18 @@
|
|||
package com.maradona.backend.controllers.api;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.maradona.backend.entities.Project;
|
||||
import com.maradona.backend.services.ProjectService;
|
||||
|
@ -25,93 +28,88 @@ import com.maradona.backend.services.ProjectService;
|
|||
* - PUT /api/project
|
||||
* - DELETE /api/project
|
||||
*
|
||||
* @warning The ProjectService is not accounting for the user yet.
|
||||
* @see Project
|
||||
* @see ProjectService
|
||||
* @see com.maradona.backend.entities.Project
|
||||
* @see com.maradona.backend.services.ProjectService
|
||||
*/
|
||||
@Controller
|
||||
@RestController
|
||||
@RequestMapping("/api/project")
|
||||
public class ProjectController {
|
||||
|
||||
/**
|
||||
* Service for handling project data.
|
||||
*/
|
||||
@Autowired
|
||||
private ProjectService projectService;
|
||||
|
||||
/**
|
||||
* Hardcoded user ID for testing purposes
|
||||
*/
|
||||
Long user = Long.valueOf(1);
|
||||
|
||||
/**
|
||||
* Returns a specific project from the database.
|
||||
*
|
||||
* @param id The ID of the requested project.
|
||||
* @param model The model with the requested data.
|
||||
* @see Project
|
||||
* @param id The ID of the requested project.
|
||||
* @return The project with the requested ID.
|
||||
* @see com.maradona.backend.entities.Project
|
||||
*/
|
||||
@GetMapping({ "/", "" })
|
||||
public void get(@RequestParam Long id, Model model) {
|
||||
var project = projectService.getProjectById(id).orElse(null);
|
||||
model.addAttribute("project", project);
|
||||
public ResponseEntity<Project> get(@RequestParam Long id) {
|
||||
Optional<Project> project = projectService.getProjectById(id);
|
||||
return project.map(ResponseEntity::ok).orElseGet(() -> ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all projects from the database.
|
||||
*
|
||||
* @param model The model with the requested data.
|
||||
* @see Project
|
||||
* @return list of projects
|
||||
* @see com.maradona.backend.entities.Project
|
||||
*/
|
||||
@GetMapping("/all")
|
||||
public void getAll(Model model) {
|
||||
var projects = projectService.getAllProjects();
|
||||
model.addAttribute("projects", projects);
|
||||
public ResponseEntity<Iterable<Project>> getAll() {
|
||||
return ResponseEntity.ok(projectService.getAllProjects());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all projects from the database that are associated with a specific
|
||||
* user.
|
||||
* Returns a list of projects for a given user.
|
||||
*
|
||||
* @param project
|
||||
* @param model
|
||||
* @see Project
|
||||
* @param userId ID of the user
|
||||
* @return list of projects
|
||||
* @see com.maradona.backend.entities.Project
|
||||
*/
|
||||
@GetMapping("/from-user")
|
||||
public void getFromUser(@ModelAttribute Project project, Model model) {
|
||||
var projects = projectService.getProjectsByUser(user);
|
||||
model.addAttribute("projects", projects);
|
||||
public ResponseEntity<Iterable<Project>> getFromUser(@RequestParam Long userId) {
|
||||
return ResponseEntity.ok(projectService.getProjectsByUserId(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new project in the database.
|
||||
* Adds a new project to the database.
|
||||
*
|
||||
* @param project The project to be created.
|
||||
* @see Project
|
||||
* @param project The project to be added
|
||||
* @return The added project
|
||||
* @see com.maradona.backend.entities.Project
|
||||
*/
|
||||
@PostMapping
|
||||
public void create(@ModelAttribute Project project) {
|
||||
projectService.saveProject(project);
|
||||
@PostMapping({ "/", "" })
|
||||
public ResponseEntity<Project> post(@RequestBody Project project) {
|
||||
Project savedProject = projectService.saveProject(project);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(savedProject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing project in the database.
|
||||
* Modifies an existing project in the database.
|
||||
*
|
||||
* @param project The project to be updated.
|
||||
* @see Project
|
||||
* @param project The project to be modified
|
||||
* @return The modified project
|
||||
* @see com.maradona.backend.entities.Project
|
||||
*/
|
||||
@PutMapping
|
||||
public void update(@ModelAttribute Project project) {
|
||||
projectService.saveProject(project);
|
||||
@PutMapping({ "/", "" })
|
||||
public ResponseEntity<Project> put(@RequestBody Project project) {
|
||||
Project updatedProject = projectService.saveProject(project);
|
||||
return ResponseEntity.ok(updatedProject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a project from the database.
|
||||
*
|
||||
* @param id The ID of the project to be deleted.
|
||||
* @param id The ID of the project to be deleted
|
||||
* @return HTTP status indicating the outcome of the operation
|
||||
* @see com.maradona.backend.entities.Project
|
||||
*/
|
||||
@DeleteMapping
|
||||
public void delete(@RequestParam Long id) {
|
||||
@DeleteMapping({ "/", "" })
|
||||
public ResponseEntity<Void> delete(@RequestParam Long id) {
|
||||
projectService.deleteProject(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
}
|
|
@ -1,19 +1,20 @@
|
|||
package com.maradona.backend.controllers.api;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.maradona.backend.entities.SecondarySkill;
|
||||
import com.maradona.backend.entities.PrimarySkill;
|
||||
import com.maradona.backend.services.SecondarySkillService;
|
||||
|
||||
/**
|
||||
|
@ -27,93 +28,88 @@ import com.maradona.backend.services.SecondarySkillService;
|
|||
* - PUT /api/secondary-skill
|
||||
* - DELETE /api/secondary-skill
|
||||
*
|
||||
* @see SecondarySkill
|
||||
* @see com.maradona.backend.entities.SecondarySkill
|
||||
*/
|
||||
@Controller
|
||||
@RestController
|
||||
@RequestMapping("/api/secondary-skill")
|
||||
public class SecondarySkillController {
|
||||
|
||||
/**
|
||||
* Service for handling secondary skill data.
|
||||
*/
|
||||
@Autowired
|
||||
private SecondarySkillService secondarySkillService;
|
||||
|
||||
/**
|
||||
* Hardcoded user ID for testing purposes.
|
||||
*/
|
||||
Long user = Long.valueOf(1);
|
||||
|
||||
/**
|
||||
* Returns a specific secondary skill from the database.
|
||||
*
|
||||
* @param id The ID of the requested secondary skill.
|
||||
* @param model The model with the requested data.
|
||||
* @see SecondarySkill
|
||||
* @param id The ID of the requested secondary skill.
|
||||
* @return The secondary skill with the requested ID.
|
||||
* @see com.maradona.backend.entities.SecondarySkill
|
||||
*/
|
||||
@GetMapping({ "/", "" })
|
||||
public void get(@RequestParam Long id, Model model) {
|
||||
var skill = secondarySkillService.getSecondarySkillById(id).orElse(null);
|
||||
model.addAttribute("secondarySkill", skill);
|
||||
public ResponseEntity<SecondarySkill> get(@RequestParam Long id) {
|
||||
Optional<SecondarySkill> secondarySkill = secondarySkillService.getSecondarySkillById(id);
|
||||
return secondarySkill.map(ResponseEntity::ok).orElseGet(() -> ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all secondary skills from the database.
|
||||
*
|
||||
* @param model The model with the requested data.
|
||||
* @see SecondarySkill
|
||||
* @return list of secondary skills
|
||||
* @see com.maradona.backend.entities.SecondarySkill
|
||||
*/
|
||||
@GetMapping("/all")
|
||||
public void getAll(Model model) {
|
||||
var skills = secondarySkillService.getAllSecondarySkills();
|
||||
model.addAttribute("secondarySkills", skills);
|
||||
public ResponseEntity<Iterable<SecondarySkill>> getAll() {
|
||||
return ResponseEntity.ok(secondarySkillService.getAllSecondarySkills());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of secondary skills for a given primary skill
|
||||
* Returns a list of secondary skills for a given primary skill.
|
||||
*
|
||||
* @param primarySkillId ID of the primary skill
|
||||
* @return list of secondary skills
|
||||
* @see SecondarySkill
|
||||
* @see PrimarySkill
|
||||
* @see com.maradona.backend.entities.SecondarySkill
|
||||
* @see com.maradona.backend.entities.PrimarySkill
|
||||
*/
|
||||
@GetMapping("/from-primary-skill")
|
||||
@ResponseBody
|
||||
public Iterable<SecondarySkill> getSecondarySkills(@RequestParam Long primarySkillId) {
|
||||
return secondarySkillService.getSecondarySkillsByPrimarySkillId(primarySkillId);
|
||||
public ResponseEntity<Iterable<SecondarySkill>> getSecondarySkills(@RequestParam Long primarySkillId) {
|
||||
return ResponseEntity.ok(secondarySkillService.getSecondarySkillsByPrimarySkillId(primarySkillId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a new secondary skill to the database.
|
||||
* If the associated primary skill does not exist, it will be created.
|
||||
* Adds a new secondary skill to the database.
|
||||
*
|
||||
* @param secondarySkill The secondary skill to be saved
|
||||
* @see SecondarySkill
|
||||
* @see PrimarySkill
|
||||
* @param secondarySkill The secondary skill to be added
|
||||
* @return The added secondary skill
|
||||
* @see com.maradona.backend.entities.SecondarySkill
|
||||
*/
|
||||
@PostMapping({ "/", "" })
|
||||
public void post(@ModelAttribute SecondarySkill secondarySkill) {
|
||||
secondarySkillService.saveSecondarySkill(secondarySkill);
|
||||
public ResponseEntity<SecondarySkill> post(@RequestBody SecondarySkill secondarySkill) {
|
||||
SecondarySkill savedSecondarySkill = secondarySkillService.saveSecondarySkill(secondarySkill);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(savedSecondarySkill);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies an existing secondary skill in the database.
|
||||
*
|
||||
* @param secondarySkill The secondary skill to be modified
|
||||
* @see SecondarySkill
|
||||
* @return The modified secondary skill
|
||||
* @see com.maradona.backend.entities.SecondarySkill
|
||||
*/
|
||||
@PutMapping({ "/", "" })
|
||||
public void put(@ModelAttribute SecondarySkill secondarySkill) {
|
||||
secondarySkillService.saveSecondarySkill(secondarySkill);
|
||||
public ResponseEntity<SecondarySkill> put(@RequestBody SecondarySkill secondarySkill) {
|
||||
SecondarySkill updatedSecondarySkill = secondarySkillService.saveSecondarySkill(secondarySkill);
|
||||
return ResponseEntity.ok(updatedSecondarySkill);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a specific secondary skill from the database.
|
||||
* Deletes a secondary skill from the database.
|
||||
*
|
||||
* @param id The ID of the secondary skill to be deleted
|
||||
* @return HTTP status indicating the outcome of the operation
|
||||
* @see com.maradona.backend.entities.SecondarySkill
|
||||
*/
|
||||
@DeleteMapping({ "/", "" })
|
||||
public void delete(@RequestParam Long id) {
|
||||
public ResponseEntity<Void> delete(@RequestParam Long id) {
|
||||
secondarySkillService.deleteSecondarySkill(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,21 +9,21 @@ public class Page {
|
|||
|
||||
@GetMapping({ "/", "" })
|
||||
public String home(Model model) {
|
||||
return "redirect:/projects";
|
||||
return "pages/core/home";
|
||||
}
|
||||
|
||||
@GetMapping("/impressum")
|
||||
public String impressum() {
|
||||
return "core/impressum";
|
||||
return "pages/core/impressum";
|
||||
}
|
||||
|
||||
@GetMapping("/datenschutz")
|
||||
public String datenschutz() {
|
||||
return "core/datenschutz";
|
||||
return "pages/core/datenschutz";
|
||||
}
|
||||
|
||||
@GetMapping("/notes")
|
||||
public String notes() {
|
||||
return "notes/notes";
|
||||
return "pages/core/notes";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public class ProjectPage {
|
|||
public String projects(Model model) {
|
||||
var projects = projectService.getAllProjects();
|
||||
model.addAttribute("projects", projects);
|
||||
return "projects/projects";
|
||||
return "/pages/projects/overview";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,7 +50,7 @@ public class ProjectPage {
|
|||
*/
|
||||
@GetMapping("/create")
|
||||
public String create(Model model) {
|
||||
model.addAttribute("project", new Project());
|
||||
return "projects/projects-create";
|
||||
model.addAttribute("projects", new Project());
|
||||
return "/pages/projects/create";
|
||||
}
|
||||
}
|
|
@ -14,8 +14,6 @@ import com.maradona.backend.services.SkillService;
|
|||
import com.maradona.backend.services.PrimarySkillService;
|
||||
import com.maradona.backend.dto.SkillPrototype;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Controller for routing to the skills related pages.
|
||||
*
|
||||
|
@ -57,7 +55,7 @@ public class SkillsPage {
|
|||
public String profile(Model model) {
|
||||
model.addAttribute("employee", employeeService.getEmployeeById(user).orElse(null));
|
||||
model.addAttribute("skills", skillService.getUserSkills(user));
|
||||
return "skills/skills";
|
||||
return "/pages/skills/overview";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,7 +71,7 @@ public class SkillsPage {
|
|||
@GetMapping("/create")
|
||||
public String createSkill(Model model) {
|
||||
model.addAttribute("secondarySkill", new SecondarySkill());
|
||||
return "skills/skills-create";
|
||||
return "/pages/skills/create";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,7 +96,7 @@ public class SkillsPage {
|
|||
// TODO: Make sure it returns the correct initail data for secondary skills
|
||||
model.addAttribute("primarySkills", primarySkillService.getAllPrimarySkills());
|
||||
model.addAttribute("skillProtoype", new SkillPrototype());
|
||||
return "skills/skills-add";
|
||||
return "/pages/skills/add";
|
||||
}
|
||||
|
||||
}
|
|
@ -29,7 +29,7 @@ public class ProjectService {
|
|||
return projectRepository.findAll();
|
||||
}
|
||||
|
||||
public Iterable<Project> getProjectsByUser(Long userId) {
|
||||
public Iterable<Project> getProjectsByUserId(Long userId) {
|
||||
// TODO: Actually filter by user
|
||||
return projectRepository.findAll();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue