feat: Initial commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user