diff --git a/src/main/java/treehouse/server/api/invitation/business/InvitationMapper.java b/src/main/java/treehouse/server/api/invitation/business/InvitationMapper.java index 27c7b8c..f48d16f 100644 --- a/src/main/java/treehouse/server/api/invitation/business/InvitationMapper.java +++ b/src/main/java/treehouse/server/api/invitation/business/InvitationMapper.java @@ -30,5 +30,18 @@ public InvitationResponseDTO.getInvitations toGetInvitations(List invitations = invitationQueryAdapter.findAllByPhone(user.getPhone()); - log.error("size : ", invitations.size()); List invitationDtos = invitations.stream() .map(invitation -> { @@ -57,4 +47,18 @@ public InvitationResponseDTO.getInvitations getInvitations(User user) { .collect(Collectors.toList()); return invitationMapper.toGetInvitations(invitationDtos); } + + public InvitationResponseDTO.myInvitationInfo getMyInvitationInfo(User user){ + return invitationMapper.toMyInvitationInfo(user); + } + + @Transactional + public InvitationResponseDTO.invitationAccept decisionInvitation(User user, InvitationRequestDTO.invitationAcceptDecision request){ + // 해당 User 에게 온 초대장인지 검증하는 로직 추가 + Long treehouseId = 0L; + if (request.isAcceptDecision()==true) { + treehouseId = 1L; // treehouse 관련 로직 개발 후, invitation.getTreeHouse.getId() 등으로 바꾸기 + } + return invitationMapper.toInvitationResult(treehouseId); + } } diff --git a/src/main/java/treehouse/server/api/invitation/presentation/InvitationApi.java b/src/main/java/treehouse/server/api/invitation/presentation/InvitationApi.java index f3c1bfa..430c331 100644 --- a/src/main/java/treehouse/server/api/invitation/presentation/InvitationApi.java +++ b/src/main/java/treehouse/server/api/invitation/presentation/InvitationApi.java @@ -18,7 +18,7 @@ @RequiredArgsConstructor @Slf4j @Validated -@Tag(name = "😎 Invitation API", description = "초대장 관련 API 입니다. 초대장 조회, 전송 등의 API가 포함됩니다.") +@Tag(name = "📨 Invitation API", description = "초대장 관련 API 입니다. 초대장 조회, 전송 등의 API가 포함됩니다.") @RequestMapping("/users") public class InvitationApi { @@ -32,5 +32,18 @@ public CommonResponse getInvitations( return CommonResponse.onSuccess(invitationService.getInvitations(user)); } + @GetMapping("/availableInvitation") + @Operation(summary = "소유한 초대장 개수 및 게이지 조회", description = "소유한 초대장 개수 및 게이지를 조회합니다.") + public CommonResponse getAvailableInvitation(@AuthMember @Parameter(hidden = true) User user){ + + return CommonResponse.onSuccess(invitationService.getMyInvitationInfo(user)); + } + + @PostMapping("/invitations/accept") + @Operation(summary = "초대장을 수락할지 거절할지 결정", description = "초대장을 수락할지 거절할지 결정하는 API 입니다.") + public CommonResponse acceptInvitation( + @AuthMember @Parameter(hidden = true) User user, @RequestBody InvitationRequestDTO.invitationAcceptDecision request) { + return CommonResponse.onSuccess(invitationService.decisionInvitation(user, request)); + } } diff --git a/src/main/java/treehouse/server/api/invitation/presentation/dto/InvitationRequestDTO.java b/src/main/java/treehouse/server/api/invitation/presentation/dto/InvitationRequestDTO.java index aeb894a..0e51853 100644 --- a/src/main/java/treehouse/server/api/invitation/presentation/dto/InvitationRequestDTO.java +++ b/src/main/java/treehouse/server/api/invitation/presentation/dto/InvitationRequestDTO.java @@ -1,18 +1,17 @@ package treehouse.server.api.invitation.presentation.dto; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.util.List; +import lombok.*; public class InvitationRequestDTO { + @Getter + @NoArgsConstructor + public static class invitationAcceptDecision{ + private Long invitationId; + private boolean acceptDecision; + } } diff --git a/src/main/java/treehouse/server/api/invitation/presentation/dto/InvitationResponseDTO.java b/src/main/java/treehouse/server/api/invitation/presentation/dto/InvitationResponseDTO.java index 685489d..717db23 100644 --- a/src/main/java/treehouse/server/api/invitation/presentation/dto/InvitationResponseDTO.java +++ b/src/main/java/treehouse/server/api/invitation/presentation/dto/InvitationResponseDTO.java @@ -28,4 +28,21 @@ public static class getInvitations { List invitations; } + @Builder + @Getter + @NoArgsConstructor + @AllArgsConstructor + public static class myInvitationInfo{ + private Integer availableInvitation; + private Integer activeRate; + } + + @Builder + @Getter + @NoArgsConstructor + @AllArgsConstructor + public static class invitationAccept { + private Long treehouseId; + + } } diff --git a/src/main/java/treehouse/server/global/entity/User/User.java b/src/main/java/treehouse/server/global/entity/User/User.java index 265c907..1522ef7 100644 --- a/src/main/java/treehouse/server/global/entity/User/User.java +++ b/src/main/java/treehouse/server/global/entity/User/User.java @@ -36,10 +36,11 @@ public class User extends BaseDateTimeEntity { // 활동량 및 초대장 개수 트리별로 적용되는 것 맞는지 확인하기 @Builder.Default - private Double activeRate = 0.0; //활동량 + private Integer activeRate = 0; //활동량 @Builder.Default private Integer invitationCount = 3; //남아있는 초대장의 개수 + // 탈퇴일자 필요한지 확인하기 // 특정 트리의 탈퇴한 멤버를 Member Table 에 그대로 쌓을건지? // db의 Member Table에 userId 필드 값은 그대로 두는지 or -1 등으로 갱신하는지