|
2 | 2 |
|
3 | 3 | import com.cloudcomputing.ohhanahana.entity.Person;
|
4 | 4 | import com.cloudcomputing.ohhanahana.repository.PersonRepository;
|
| 5 | +import io.swagger.v3.oas.annotations.Operation; |
| 6 | +import io.swagger.v3.oas.annotations.tags.Tag; |
5 | 7 | import java.util.List;
|
6 |
| -import lombok.RequiredArgsConstructor; |
7 | 8 | import org.springframework.beans.factory.annotation.Autowired;
|
8 | 9 | import org.springframework.web.bind.annotation.DeleteMapping;
|
9 | 10 | import org.springframework.web.bind.annotation.GetMapping;
|
|
14 | 15 | import org.springframework.web.bind.annotation.RequestMapping;
|
15 | 16 | import org.springframework.web.bind.annotation.RestController;
|
16 | 17 |
|
| 18 | +@Tag(name = "Person API", description = "Person 관련 API") |
17 | 19 | @RestController
|
18 | 20 | @RequestMapping("/persons")
|
19 | 21 | public class PersonController {
|
20 | 22 |
|
21 | 23 | @Autowired
|
22 | 24 | private PersonRepository personRepository;
|
23 | 25 |
|
| 26 | + @Operation(summary = "Person 저장 API", description = "Person을 저장하는 API입니다.") |
24 | 27 | @PostMapping
|
25 | 28 | public Person save(@RequestBody Person person) {
|
26 | 29 |
|
27 | 30 | return personRepository.save(person);
|
28 | 31 | }
|
29 | 32 |
|
| 33 | + @Operation(summary = "Person 조회 API", description = "Person을 조회하는 API입니다.") |
30 | 34 | @GetMapping("/{id}")
|
31 | 35 | public Person findById(@PathVariable(value = "id") String id) {
|
32 | 36 | return personRepository.findById(id);
|
33 | 37 | }
|
34 | 38 |
|
| 39 | + @Operation(summary = "Person 전체 조회 API", description = "Person 전체를 조회하는 API입니다.") |
35 | 40 | @GetMapping("/all")
|
36 | 41 | public List<Person> findAll() {
|
37 | 42 | return personRepository.findAll();
|
38 | 43 | }
|
39 | 44 |
|
| 45 | + @Operation(summary = "Person 수정 API", description = "Person을 수정하는 API입니다.") |
40 | 46 | @PutMapping("/{id}")
|
41 | 47 | public String update(@PathVariable(value="id") String id,
|
42 | 48 | @RequestBody Person person) {
|
43 | 49 | return personRepository.update(id, person);
|
44 | 50 | }
|
45 | 51 |
|
| 52 | + @Operation(summary = "Person 삭제 API", description = "Person을 삭제하는 API입니다.") |
46 | 53 | @DeleteMapping("/{id}")
|
47 | 54 | public String delete(@PathVariable(value="id") String id) {
|
48 | 55 | return personRepository.delete(id);
|
|
0 commit comments