mirror of
https://github.com/PaulReichmuth/timekeep-backend.git
synced 2025-12-22 22:41:59 +00:00
begin service structure
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
package de.pnreichmuth.timekeep_backend.controllers;
|
||||
|
||||
import de.pnreichmuth.timekeep_backend.entities.Team;
|
||||
import de.pnreichmuth.timekeep_backend.exceptions.TeamNotFoundException;
|
||||
import de.pnreichmuth.timekeep_backend.services.TeamService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.rmi.NoSuchObjectException;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@@ -13,8 +15,11 @@ import java.util.List;
|
||||
@Slf4j
|
||||
public class TeamRestController {
|
||||
|
||||
@Autowired
|
||||
TeamService teamService;
|
||||
|
||||
@PostMapping("createTeam")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public Team createTeam(@RequestBody Team team){
|
||||
teamService.createTeam(team);
|
||||
return team;
|
||||
@@ -26,17 +31,15 @@ public class TeamRestController {
|
||||
}
|
||||
|
||||
@DeleteMapping("all")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void deleteAllTeams(){
|
||||
teamService.deleteAllTeams();
|
||||
}
|
||||
|
||||
@DeleteMapping("deleteTeam")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void deleteTeam(@RequestBody Team team){
|
||||
try{
|
||||
teamService.deleteTeam(team.getTeamName());
|
||||
} catch (NoSuchObjectException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
teamService.deleteTeam(team.getTeamName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user