feat: UserController
This commit is contained in:
parent
56162ad895
commit
a78ecaeadb
1 changed files with 36 additions and 0 deletions
|
@ -0,0 +1,36 @@
|
||||||
|
package eu.ztsh.wymiana.web.controller;
|
||||||
|
|
||||||
|
import eu.ztsh.wymiana.model.User;
|
||||||
|
import eu.ztsh.wymiana.service.UserService;
|
||||||
|
import eu.ztsh.wymiana.web.model.UserCreateRequest;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Validated
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/user")
|
||||||
|
public class UserController {
|
||||||
|
|
||||||
|
private final UserService userService;
|
||||||
|
|
||||||
|
@GetMapping("{pesel}")
|
||||||
|
public ResponseEntity<User> get(@PathVariable("pesel") String pesel) {
|
||||||
|
return ResponseEntity.of(userService.get(pesel));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public ResponseEntity<Void> create(@Valid @RequestBody UserCreateRequest request) {
|
||||||
|
userService.create(request);
|
||||||
|
return ResponseEntity.status(204).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue