Files
NTO-2025-Backend-Individual…/src/main/java/ru/example/nto/controller/DepartmentController.java

32 lines
849 B
Java

package ru.example.nto.controller;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import ru.example.nto.entity.Department;
import ru.example.nto.service.DepartmentService;
import java.util.List;
@RestController
@RequestMapping("api/v1/department")
public class DepartmentController {
private final DepartmentService departmentService;
public DepartmentController(DepartmentService departmentService) {
this.departmentService = departmentService;
}
@GetMapping
@ResponseStatus(code = HttpStatus.OK)
public List<Department> getAll() {
return departmentService.getAll();
}
@GetMapping("/{name}")
@ResponseStatus(HttpStatus.OK)
public Department getByName(@PathVariable String name) {
return departmentService.getByName(name);
}
}