2222import org .springframework .web .bind .annotation .RestController ;
2323
2424import java .util .List ;
25+ import ongi .family .service .FamilyService ;
26+ import ongi .family .dto .FamilyInfo ;
27+ import ongi .temperature .service .TemperatureService ;
2528
2629@ RestController
2730@ RequestMapping ("/pills" )
2831@ RequiredArgsConstructor
2932public class PillController {
3033
3134 private final PillService pillService ;
35+ private final FamilyService familyService ;
36+ private final TemperatureService temperatureService ;
3237
3338 @ PostMapping
3439 public ResponseEntity <PillInfo > createPill (
@@ -43,6 +48,12 @@ public ResponseEntity<Void> recordPillIntake(
4348 @ AuthenticationPrincipal CustomUserDetails userDetails ,
4449 @ Valid @ RequestBody PillIntakeRecordRequest request ) {
4550 pillService .recordPillIntake (userDetails .getUser (), request );
51+
52+ // 온도 상승: 부모 약 복용 기록 시
53+ FamilyInfo familyInfo = familyService .getFamily (userDetails .getUser ());
54+ String familyId = familyInfo .code ();
55+ temperatureService .increaseTemperatureForParentMedInput (userDetails .getUser ().getUuid (), familyId );
56+
4657 return ResponseEntity .status (HttpStatus .CREATED ).build ();
4758 }
4859
@@ -54,6 +65,14 @@ public ResponseEntity<List<PillInfoWithIntakeStatus>> getPills(
5465 if (date == null ) {
5566 date = LocalDate .now ();
5667 }
68+
69+ // 온도 상승: 자녀가 부모의 약을 조회할 때만
70+ if (parentUuid != null && !userDetails .getUser ().getUuid ().equals (parentUuid ) && !userDetails .getUser ().getIsParent ()) {
71+ FamilyInfo familyInfo = familyService .getFamily (userDetails .getUser ());
72+ String familyId = familyInfo .code ();
73+ temperatureService .increaseTemperatureForChildMedView (userDetails .getUser ().getUuid (), familyId );
74+ }
75+
5776 List <PillInfoWithIntakeStatus > pills = pillService .getFamilyPills (userDetails .getUser (), parentUuid , date );
5877 return ResponseEntity .ok (pills );
5978 }
0 commit comments