Merge pull request 'fix: Correct spelling of 'prototype' in API and documentation' (#92) from 3002833/Backend:main into restfull

Reviewed-on: Maradona/Backend#92
pull/1/head
David Hess 2024-11-11 19:56:00 +01:00
commit e05e074ea5
4 changed files with 87 additions and 7 deletions

View File

@ -26,7 +26,7 @@ import com.maradona.backend.services.details.EmployeeDetails;
* - GET /api/employee/all
* - GET /api/employee/from-skill
* - GET /api/employee/skill/all
* - POST /api/employee/skill/protoype
* - POST /api/employee/skill/prototype
* - PUT /api/employee/skill/level
* - DELETE /api/employee/skill
*
@ -107,8 +107,8 @@ public class EmployeeController {
* @see com.maradona.backend.entities.Employee
* @see com.maradona.backend.entities.SecondarySkill
*/
@PostMapping("/skill/protoype")
public ResponseEntity<Void> postSkillProtoype(@RequestBody SkillPrototype skillPrototype) {
@PostMapping("/skill/prototype")
public ResponseEntity<Void> postSkillPrototype(@RequestBody SkillPrototype skillPrototype) {
employeeActions.addSecondarySkillToEmployee(user, skillPrototype);
return ResponseEntity.status(HttpStatus.CREATED).build();
}

View File

@ -82,11 +82,11 @@ public class SkillsPage {
*
* Attributes that can be used by the frontend are a PrimarySkill object
* "primarySkill", a SecondarySkill object "secondarySkill" and a
* SkillProtoype object "skillProtoype".
* SkillPrototype object "skillPrototype".
*
* The skillProtoype object contains the data needed to add a skill to the user
* The skillPrototype object contains the data needed to add a skill to the user
* profile.
* To add it to a user profile, POST to /api/employee/skill/protoype.
* To add it to a user profile, POST to /api/employee/skill/prototype.
*
* @param model The model with the data to be displayed
* @return The add skill page template
@ -98,7 +98,7 @@ public class SkillsPage {
public String addSkill(Model model) {
// TODO: Make sure it returns the correct initail data for secondary skills
model.addAttribute("primarySkills", primarySkillDetails.getAllPrimarySkills());
model.addAttribute("skillProtoype", new SkillPrototype());
model.addAttribute("skillPrototype", new SkillPrototype());
return "/pages/skills/add";
}

View File

@ -5,27 +5,64 @@ import com.maradona.backend.entities.SecondarySkill;
import org.springframework.data.util.Pair;
import java.util.List;
/**
* This classs provides an easier way to send a list of skills with levels to
* the frontend.
*/
public class SkillList {
/**
* The primary skill.
*/
private PrimarySkill primarySkill;
/**
* The list of secondary skills with their levels.
*/
private List<Pair<SecondarySkill, Integer>> secondarySkills;
/**
* Creates a new SkillList object.
*
* @param primarySkill The primary skill.
* @param secondarySkills The list of secondary skills with their levels.
*/
public SkillList(PrimarySkill primarySkill, List<Pair<SecondarySkill, Integer>> secondarySkills) {
this.primarySkill = primarySkill;
this.secondarySkills = secondarySkills;
}
/**
* Returns the primary skill.
*
* @return The primary skill.
*/
public PrimarySkill getPrimarySkill() {
return primarySkill;
}
/**
* Sets the primary skill.
*
* @param primarySkill The primary skill.
*/
public void setPrimarySkill(PrimarySkill primarySkill) {
this.primarySkill = primarySkill;
}
/**
* Returns the list of secondary skills with their levels.
*
* @return The list of secondary skills with their levels.
*/
public List<Pair<SecondarySkill, Integer>> getSecondarySkills() {
return secondarySkills;
}
/**
* Sets the list of secondary skills with their levels.
*
* @param secondarySkills The list of secondary skills with their levels.
*/
public void setSecondarySkills(List<Pair<SecondarySkill, Integer>> secondarySkills) {
this.secondarySkills = secondarySkills;
}

View File

@ -1,30 +1,73 @@
package com.maradona.backend.dto;
/**
* This class provides an easy way to receive raw data that can be usd to build
* a skill from the frontend.
*/
public class SkillPrototype {
/**
* The primary skill ID.
*/
private Long psid;
/**
* The secondary skill ID.
*/
private Long ssid;
/**
* The level of the skill.
*/
private Integer level;
/**
* Returns the primary skill ID.
*/
public Long getPsid() {
return psid;
}
/**
* Sets the primary skill ID.
*
* @param psid The primary skill ID to set.
*/
public void setPsid(Long psid) {
this.psid = psid;
}
/**
* Returns the secondary skill ID.
*
* @return The secondary skill ID.
*/
public Long getSsid() {
return ssid;
}
/**
* Sets the secondary skill ID.
*
* @param ssid The secondary skill ID to set.
*/
public void setSsid(Long ssid) {
this.ssid = ssid;
}
/**
* Returns the level of the skill.
*
* @return The level of the skill.
*/
public Integer getLevel() {
return level;
}
/**
* Sets the level of the skill.
*
* @param level The level of the skill to set.
*/
public void setLevel(Integer level) {
this.level = level;
}