- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserController.java
More file actions
Latest commit
24 lines (20 loc) · 737 Bytes
/
Copy pathUserController.java
File metadata and controls
24 lines (20 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
importorg.springframework.web.bind.annotation.*;
importorg.springframework.http.ResponseEntity;
@RestController
@RequestMapping("/api/users")
publicclassUserController {
@GetMapping("/{id}")
publicResponseEntity<User> getUser(@PathVariableLongid) {
returnResponseEntity.ok(userService.findById(id));
}
@PostMapping
publicResponseEntity<User> createUser(@RequestBodyUserRequestrequest) {
Useruser = userService.create(request);
returnResponseEntity.status(201).body(user);
}
@DeleteMapping("/{id}")
publicResponseEntity<Void> deleteUser(@PathVariableLongid) {
userService.delete(id);
returnResponseEntity.noContent().build();
}
}