Add get router by id endpoint
This commit is contained in:
@@ -4,6 +4,7 @@ import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/routers")
|
||||
@@ -24,4 +25,9 @@ public class RouterController {
|
||||
public Router create(@Valid @RequestBody CreateRouterRequest request) {
|
||||
return service.create(request);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public Router getById(@PathVariable UUID id) {
|
||||
return service.findById(id);
|
||||
}
|
||||
}
|
||||
@@ -38,4 +38,9 @@ public class RouterService {
|
||||
|
||||
return repository.save(router);
|
||||
}
|
||||
|
||||
public Router findById(UUID id) {
|
||||
return repository.findById(id)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Router not found: " + id));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user