diff --git a/src/main/java/com/connect/accountApp/domain/household/adapter/in/web/controller/GetHouseholdInviteCodeController.java b/src/main/java/com/connect/accountApp/domain/household/adapter/in/web/controller/GetHouseholdInviteCodeController.java new file mode 100644 index 0000000..17241c1 --- /dev/null +++ b/src/main/java/com/connect/accountApp/domain/household/adapter/in/web/controller/GetHouseholdInviteCodeController.java @@ -0,0 +1,32 @@ +package com.connect.accountApp.domain.household.adapter.in.web.controller; + +import com.connect.accountApp.domain.household.application.port.in.GetHouseholdUseCase; +import com.connect.accountApp.global.common.adapter.in.web.response.SuccessResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/api/v1/household") +@RequiredArgsConstructor +public class GetHouseholdInviteCodeController { + + private final GetHouseholdUseCase getHouseholdHomeUseCase; + + + @GetMapping("/inviteCode") + public ResponseEntity getHouseholdHome(@AuthenticationPrincipal UserDetails userDetails) { + + String userEmail = userDetails.getUsername(); + + String householdInviteCode = getHouseholdHomeUseCase.getHouseholdInviteCode(userEmail); + + return ResponseEntity.ok(SuccessResponse.create200SuccessResponse(householdInviteCode)); + } + + +} diff --git a/src/main/java/com/connect/accountApp/domain/household/application/port/in/GetHouseholdUseCase.java b/src/main/java/com/connect/accountApp/domain/household/application/port/in/GetHouseholdUseCase.java index 009f1a5..d105c00 100644 --- a/src/main/java/com/connect/accountApp/domain/household/application/port/in/GetHouseholdUseCase.java +++ b/src/main/java/com/connect/accountApp/domain/household/application/port/in/GetHouseholdUseCase.java @@ -4,4 +4,6 @@ public interface GetHouseholdUseCase { String getHouseholdName(String userEmail); + String getHouseholdInviteCode(String userEmail); + } diff --git a/src/main/java/com/connect/accountApp/domain/household/application/service/GetHouseholdService.java b/src/main/java/com/connect/accountApp/domain/household/application/service/GetHouseholdService.java index 0f2c032..fd7c877 100644 --- a/src/main/java/com/connect/accountApp/domain/household/application/service/GetHouseholdService.java +++ b/src/main/java/com/connect/accountApp/domain/household/application/service/GetHouseholdService.java @@ -19,4 +19,11 @@ public String getHouseholdName(String userEmail) { return userWithHousehold.getHousehold().getHouseholdName(); } + + @Override + public String getHouseholdInviteCode(String userEmail) { + User userWithHousehold = getUserPort.findUserWithHousehold(userEmail); + + return userWithHousehold.getHousehold().getInviteCode(); + } }