Skip to content

Commit

Permalink
feat(household): 초대코드 조회 API 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
ehBeak committed Nov 10, 2023
1 parent 23efe11 commit b75f4d1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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));
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ public interface GetHouseholdUseCase {

String getHouseholdName(String userEmail);

String getHouseholdInviteCode(String userEmail);

}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit b75f4d1

Please sign in to comment.