-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFamilyController.java
More file actions
38 lines (32 loc) · 1.25 KB
/
FamilyController.java
File metadata and controls
38 lines (32 loc) · 1.25 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
package org.dailystudio.springbootstudy.controller;
import lombok.RequiredArgsConstructor;
import org.dailystudio.springbootstudy.domain.Parent;
import org.dailystudio.springbootstudy.dto.parent.ParentDto;
import org.dailystudio.springbootstudy.service.FamilyService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("api/family")
@RequiredArgsConstructor
public class FamilyController {
private final FamilyService familyService;
@PostMapping("/save/parent")
public ResponseEntity<Void> saveParent(){
familyService.saveParent();
return ResponseEntity.ok().build();
}
@PostMapping("/save/children")
public ResponseEntity<Void> saveChildren(){
familyService.saveChild();
return ResponseEntity.ok().build();
}
@GetMapping("/parent")
public ResponseEntity<ParentDto> getParent(){
Parent parent = familyService.getParent();
ParentDto parentDto = new ParentDto(parent);
return ResponseEntity.ok(parentDto);
}
}