api: Add controllers
parent
8cb2b2f6c6
commit
458a9d4ecb
|
@ -0,0 +1,43 @@
|
|||
package com.maradona.backend.controllers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.maradona.backend.entities.Employee;
|
||||
import com.maradona.backend.services.EmployeeService;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/employees")
|
||||
public class EmployeeController {
|
||||
|
||||
@Autowired
|
||||
private EmployeeService employeeService;
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<Employee> createEmployee(@RequestBody Employee employee) {
|
||||
Employee savedEmployee = employeeService.saveEmployee(employee);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(savedEmployee);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Employee> getEmployee(@PathVariable Long id) {
|
||||
Optional<Employee> employee = employeeService.getEmployeeById(id);
|
||||
return employee.map(ResponseEntity::ok)
|
||||
.orElseGet(() -> ResponseEntity.status(HttpStatus.NOT_FOUND).build());
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Void> deleteEmployee(@PathVariable Long id) {
|
||||
employeeService.deleteEmployee(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<Iterable<Employee>> getAllEmployees() {
|
||||
Iterable<Employee> employees = employeeService.getAllEmployees();
|
||||
return ResponseEntity.ok(employees);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.maradona.backend.controllers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.maradona.backend.entities.FormOfAddress;
|
||||
import com.maradona.backend.services.FormOfAddressService;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/form-of-address")
|
||||
public class FormOfAddressController {
|
||||
|
||||
@Autowired
|
||||
private FormOfAddressService formOfAddressService;
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<FormOfAddress> createFormOfAddress(@RequestBody FormOfAddress formOfAddress) {
|
||||
FormOfAddress savedFormOfAddress = formOfAddressService.saveFormOfAddress(formOfAddress);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(savedFormOfAddress);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<FormOfAddress> getFormOfAddress(@PathVariable Long id) {
|
||||
Optional<FormOfAddress> formOfAddress = formOfAddressService.getFormOfAddressById(id);
|
||||
return formOfAddress.map(ResponseEntity::ok)
|
||||
.orElseGet(() -> ResponseEntity.status(HttpStatus.NOT_FOUND).build());
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Void> deleteFormOfAddress(@PathVariable Long id) {
|
||||
formOfAddressService.deleteFormOfAddress(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<Iterable<FormOfAddress>> getAllFormOfAddresses() {
|
||||
Iterable<FormOfAddress> formOfAddresses = formOfAddressService.getAllFormOfAddresses();
|
||||
return ResponseEntity.ok(formOfAddresses);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.maradona.backend.controllers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.maradona.backend.entities.PrimarySkill;
|
||||
import com.maradona.backend.services.PrimarySkillService;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/primary-skills")
|
||||
public class PrimarySkillController {
|
||||
|
||||
@Autowired
|
||||
private PrimarySkillService primarySkillService;
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<PrimarySkill> createPrimarySkill(@RequestBody PrimarySkill primarySkill) {
|
||||
PrimarySkill savedPrimarySkill = primarySkillService.savePrimarySkill(primarySkill);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(savedPrimarySkill);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<PrimarySkill> getPrimarySkill(@PathVariable Long id) {
|
||||
Optional<PrimarySkill> primarySkill = primarySkillService.getPrimarySkillById(id);
|
||||
return primarySkill.map(ResponseEntity::ok)
|
||||
.orElseGet(() -> ResponseEntity.status(HttpStatus.NOT_FOUND).build());
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Void> deletePrimarySkill(@PathVariable Long id) {
|
||||
primarySkillService.deletePrimarySkill(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<Iterable<PrimarySkill>> getAllPrimarySkills() {
|
||||
Iterable<PrimarySkill> primarySkills = primarySkillService.getAllPrimarySkills();
|
||||
return ResponseEntity.ok(primarySkills);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.maradona.backend.controllers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.maradona.backend.entities.ProjectAssignment;
|
||||
import com.maradona.backend.services.ProjectAssignmentService;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/project-assignments")
|
||||
public class ProjectAssignmentController {
|
||||
|
||||
@Autowired
|
||||
private ProjectAssignmentService projectAssignmentService;
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<ProjectAssignment> createProjectAssignment(@RequestBody ProjectAssignment projectAssignment) {
|
||||
ProjectAssignment savedProjectAssignment = projectAssignmentService.saveProjectAssignment(projectAssignment);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(savedProjectAssignment);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<ProjectAssignment> getProjectAssignment(@PathVariable Long id) {
|
||||
Optional<ProjectAssignment> projectAssignment = projectAssignmentService.getProjectAssignmentById(id);
|
||||
return projectAssignment.map(ResponseEntity::ok)
|
||||
.orElseGet(() -> ResponseEntity.status(HttpStatus.NOT_FOUND).build());
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Void> deleteProjectAssignment(@PathVariable Long id) {
|
||||
projectAssignmentService.deleteProjectAssignment(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<Iterable<ProjectAssignment>> getAllProjectAssignments() {
|
||||
Iterable<ProjectAssignment> projectAssignments = projectAssignmentService.getAllProjectAssignments();
|
||||
return ResponseEntity.ok(projectAssignments);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.maradona.backend.controllers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.maradona.backend.entities.Project;
|
||||
import com.maradona.backend.services.ProjectService;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/projects")
|
||||
public class ProjectController {
|
||||
|
||||
@Autowired
|
||||
private ProjectService projectService;
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<Project> createProject(@RequestBody Project project) {
|
||||
Project savedProject = projectService.saveProject(project);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(savedProject);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Project> getProject(@PathVariable Long id) {
|
||||
Optional<Project> project = projectService.getProjectById(id);
|
||||
return project.map(ResponseEntity::ok)
|
||||
.orElseGet(() -> ResponseEntity.status(HttpStatus.NOT_FOUND).build());
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Void> deleteProject(@PathVariable Long id) {
|
||||
projectService.deleteProject(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<Iterable<Project>> getAllProjects() {
|
||||
Iterable<Project> projects = projectService.getAllProjects();
|
||||
return ResponseEntity.ok(projects);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.maradona.backend.controllers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.maradona.backend.entities.SecondarySkill;
|
||||
import com.maradona.backend.services.SecondarySkillService;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/secondary-skills")
|
||||
public class SecondarySkillController {
|
||||
|
||||
@Autowired
|
||||
private SecondarySkillService secondarySkillService;
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<SecondarySkill> createSecondarySkill(@RequestBody SecondarySkill secondarySkill) {
|
||||
SecondarySkill savedSecondarySkill = secondarySkillService.saveSecondarySkill(secondarySkill);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(savedSecondarySkill);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<SecondarySkill> getSecondarySkill(@PathVariable Long id) {
|
||||
Optional<SecondarySkill> secondarySkill = secondarySkillService.getSecondarySkillById(id);
|
||||
return secondarySkill.map(ResponseEntity::ok)
|
||||
.orElseGet(() -> ResponseEntity.status(HttpStatus.NOT_FOUND).build());
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Void> deleteSecondarySkill(@PathVariable Long id) {
|
||||
secondarySkillService.deleteSecondarySkill(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<Iterable<SecondarySkill>> getAllSecondarySkills() {
|
||||
Iterable<SecondarySkill> secondarySkills = secondarySkillService.getAllSecondarySkills();
|
||||
return ResponseEntity.ok(secondarySkills);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.maradona.backend.controllers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.maradona.backend.entities.SkillAssignment;
|
||||
import com.maradona.backend.services.SkillAssignmentService;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/skill-assignments")
|
||||
public class SkillAssignmentController {
|
||||
|
||||
@Autowired
|
||||
private SkillAssignmentService skillAssignmentService;
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<SkillAssignment> createSkillAssignment(@RequestBody SkillAssignment skillAssignment) {
|
||||
SkillAssignment savedSkillAssignment = skillAssignmentService.saveSkillAssignment(skillAssignment);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(savedSkillAssignment);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<SkillAssignment> getSkillAssignment(@PathVariable Long id) {
|
||||
Optional<SkillAssignment> skillAssignment = skillAssignmentService.getSkillAssignmentById(id);
|
||||
return skillAssignment.map(ResponseEntity::ok)
|
||||
.orElseGet(() -> ResponseEntity.status(HttpStatus.NOT_FOUND).build());
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Void> deleteSkillAssignment(@PathVariable Long id) {
|
||||
skillAssignmentService.deleteSkillAssignment(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<Iterable<SkillAssignment>> getAllSkillAssignments() {
|
||||
Iterable<SkillAssignment> skillAssignments = skillAssignmentService.getAllSkillAssignments();
|
||||
return ResponseEntity.ok(skillAssignments);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue