api: Change level endpoint

pull/1/head
Lunix-420 2024-11-04 15:18:12 +01:00
parent 67084ebd3a
commit 31e822b96e
2 changed files with 19 additions and 0 deletions

Binary file not shown.

View File

@ -142,4 +142,23 @@ public class SkillsController {
}
return "redirect:/skills";
}
// Update skill level
@PostMapping("/update-level")
public String updateLevel(@RequestParam Long skillId, @RequestParam Integer level) {
var employee = employeeService.getEmployeeById(user).orElseThrow(() -> new RuntimeException("Employee not found"));
var secondarySkill = secondarySkillService.getSecondarySkillById(skillId)
.orElseThrow(() -> new RuntimeException("Secondary Skill not found"));
for (EmployeeSecondarySkill ess : employee.getSecondarySkills()) {
if (ess.getSecondarySkill().getSsid().equals(skillId)) {
ess.setLevel(level);
break;
}
}
employeeService.saveEmployee(employee);
return "redirect:/skills";
}
}