-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathIdolController.java
More file actions
54 lines (40 loc) · 1.72 KB
/
IdolController.java
File metadata and controls
54 lines (40 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.codejam.demo.controller;
import com.codejam.demo.dto.PersonalInformationDto;
import com.codejam.demo.dto.ResponseDto;
import com.codejam.demo.service.PersonalInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@RestController
@RequestMapping("/idol")
public class IdolController {
private final PersonalInformationService personalInformationService;
@Autowired
public IdolController(PersonalInformationService personalInformationService) {
this.personalInformationService = personalInformationService;
}
@PostMapping(path = "/users", consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseDto> save(@Valid @RequestBody PersonalInformationDto dto) {
return personalInformationService.save(dto);
}
@GetMapping(path = "users/{id}")
public ResponseEntity<PersonalInformationDto> get(
@PathVariable(value = "id") Integer id
) {
return personalInformationService.get(id);
}
@PutMapping(path = "/users", consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseDto> updateById(@Valid @RequestBody PersonalInformationDto dto) {
return personalInformationService.update(dto);
}
@DeleteMapping(path = "users/{id}")
public ResponseEntity<ResponseDto> deleteById(
@PathVariable(value = "id") Integer id
) {
return personalInformationService.delete(id);
}
}