From b75f4d1aec85e8d764bf5488a085068e91f29ee3 Mon Sep 17 00:00:00 2001 From: eunhee Date: Sat, 11 Nov 2023 02:59:40 +0900 Subject: [PATCH] =?UTF-8?q?feat(household):=20=EC=B4=88=EB=8C=80=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=A1=B0=ED=9A=8C=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GetHouseholdInviteCodeController.java | 32 +++++++++++++++++++ .../port/in/GetHouseholdUseCase.java | 2 ++ .../service/GetHouseholdService.java | 7 ++++ 3 files changed, 41 insertions(+) create mode 100644 src/main/java/com/connect/accountApp/domain/household/adapter/in/web/controller/GetHouseholdInviteCodeController.java 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(); + } }