From 4a52409dd1d66b728c740588c475ef449b49f953 Mon Sep 17 00:00:00 2001 From: sckwon770 Date: Sun, 9 Jun 2024 17:23:57 +0900 Subject: [PATCH] =?UTF-8?q?[OING-339]=20feat:=20=ED=99=95=EC=9E=A5?= =?UTF-8?q?=EB=90=9C=20=EA=B0=80=EC=A1=B1=20=EC=B4=88=EB=8C=80=20=EB=A7=81?= =?UTF-8?q?=ED=81=AC=20=EA=B8=B0=EB=8A=A5=EC=9D=84=20=EA=B5=AC=ED=98=84?= =?UTF-8?q?=ED=95=98=EA=B8=B0=20=EC=9C=84=ED=95=9C=20View=20API=20Spec=20?= =?UTF-8?q?=EC=9A=B0=EC=84=A0=20=EA=B5=AC=ED=98=84=20=EB=B0=8F=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20=EB=AA=A8=ED=82=B9=20(#260)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FamilyInvitationLinkResponse.java | 10 ---- .../FamilyInviteDeepLinkResponse.java | 34 ++++++++++++++ .../FamilyInviteViewController.java | 46 +++++++++++++++++++ .../com/oing/restapi/FamilyInviteViewApi.java | 35 ++++++++++++++ .../com/oing/service/DeepLinkService.java | 12 +++++ 5 files changed, 127 insertions(+), 10 deletions(-) delete mode 100644 family/src/main/java/com/oing/dto/response/FamilyInvitationLinkResponse.java create mode 100644 family/src/main/java/com/oing/dto/response/FamilyInviteDeepLinkResponse.java create mode 100644 gateway/src/main/java/com/oing/controller/FamilyInviteViewController.java create mode 100644 gateway/src/main/java/com/oing/restapi/FamilyInviteViewApi.java diff --git a/family/src/main/java/com/oing/dto/response/FamilyInvitationLinkResponse.java b/family/src/main/java/com/oing/dto/response/FamilyInvitationLinkResponse.java deleted file mode 100644 index dbcad2ef..00000000 --- a/family/src/main/java/com/oing/dto/response/FamilyInvitationLinkResponse.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.oing.dto.response; - -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema(description = "가족 초대 링크 응답") -public record FamilyInvitationLinkResponse( - @Schema(description = "가족 초대 링크", example = "https://no5ing.kr/o/be9238cSDfke") - String url -) { -} diff --git a/family/src/main/java/com/oing/dto/response/FamilyInviteDeepLinkResponse.java b/family/src/main/java/com/oing/dto/response/FamilyInviteDeepLinkResponse.java new file mode 100644 index 00000000..aa6b6def --- /dev/null +++ b/family/src/main/java/com/oing/dto/response/FamilyInviteDeepLinkResponse.java @@ -0,0 +1,34 @@ +package com.oing.dto.response; + +import io.swagger.v3.oas.annotations.media.Schema; + +import java.util.List; + +@Schema(description = "가족 초대 링크 응답") +public record FamilyInviteDeepLinkResponse( + + @Schema(description = "가족 ID", example = "01HGW2N7EHJVJ4CJ999RRS2E97") + String familyId, + + @Schema(description = "가족 명", example = "사랑하는 우리가족") + String familyName, + + @Schema(description = "대표 가족구성원 프로필 이미지 URL", example = "https://asset.no5ing.kr/member/profile/ab3fde93ee") + List familyMembersProfileImageUrls, + + @Schema(description = "대표 가족구성원 외 구성원 수", example = "3") + Integer extraFamilyMembersCount, + + @Schema(description = "전체 가족 구성원 수", example = "5") + Integer familyMembersCoun, + + @Schema(description = "초대자 이름", example = "김철수") + String inviterName, + + @Schema(description = "완료한 생존신고의 수", example = "3") + Integer survivalCount, + + @Schema(description = "요청자가 이미 가족에 가입되어 있는지 여부 (토큰 첨부 시에만 반환, 미첨부 시 null 반환)", example = "true") + Boolean isRequesterJoinedFamily +) { +} diff --git a/gateway/src/main/java/com/oing/controller/FamilyInviteViewController.java b/gateway/src/main/java/com/oing/controller/FamilyInviteViewController.java new file mode 100644 index 00000000..1776438e --- /dev/null +++ b/gateway/src/main/java/com/oing/controller/FamilyInviteViewController.java @@ -0,0 +1,46 @@ +package com.oing.controller; + +import com.oing.dto.response.FamilyInviteDeepLinkResponse; +import com.oing.restapi.DeepLinkApi; +import com.oing.restapi.FamilyInviteViewApi; +import com.oing.restapi.MeApi; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Controller; + +import java.util.List; + +@Controller +@RequiredArgsConstructor +public class FamilyInviteViewController implements FamilyInviteViewApi { + + private final DeepLinkApi deepLinkApi; + private final MeApi meApi; + + @Override + public FamilyInviteDeepLinkResponse getFamilyInviteLinkDetails(String linkId, String loginMemberId) { + + // TODO : 기능 구현할 때, 응답 모킹용 코드 삭제하고 아래 주석 풀기 + boolean isRequesterJoinedFamily = false; +// MemberResponse me = meApi.getMe(loginMemberId); +// if (me.familyId() != null) { +// isRequesterJoinedFamily = true; +// } + // + if (loginMemberId != null) { + isRequesterJoinedFamily = true; + } + + + + return new FamilyInviteDeepLinkResponse ( + "01HGW2N7EHJVJ4CJ999RRS2E97", + "사랑하는 우리가족", + List.of("https://upload.wikimedia.org/wikipedia/en/thumb/6/63/Feels_good_man.jpg/200px-Feels_good_man.jpg", "https://upload.wikimedia.org/wikipedia/en/thumb/6/63/Feels_good_man.jpg/200px-Feels_good_man.jpg"), + 3, + 5, + "김철수", + 3, + isRequesterJoinedFamily + ); + } +} diff --git a/gateway/src/main/java/com/oing/restapi/FamilyInviteViewApi.java b/gateway/src/main/java/com/oing/restapi/FamilyInviteViewApi.java new file mode 100644 index 00000000..a546d5df --- /dev/null +++ b/gateway/src/main/java/com/oing/restapi/FamilyInviteViewApi.java @@ -0,0 +1,35 @@ +package com.oing.restapi; + +import com.oing.dto.response.FamilyInviteDeepLinkResponse; +import com.oing.util.security.LoginMemberId; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "가족초대 페이지 뷰 기반 API", description = "웹뷰와 앱에서 가족초대와 관련된 페이지 기반으로 작성된 View API입니다.") +@RestController +@RequestMapping("/v1/view/family-invite") +public interface FamilyInviteViewApi { + + @Operation( + summary = "가족 초대 링크 정보 조회 (딥링크 웹뷰 + 가족 가입 앱 겸용)", + description = """ + linkId를 통해 해당 가족 초대 링크의 세부 정보들을 조회합니다. + 토큰 미첨부 시 : 가족 초대 링크 상세 정보 조회 (딥링크 웹뷰 페이지용) + 토큰 첨부 시 : 요청자 입장에서의 가족 초대 링크 정보 조회 (가족 가입 프로세스 앱 페이지용)""" + ) + @GetMapping("/{linkId}") + FamilyInviteDeepLinkResponse getFamilyInviteLinkDetails( + @PathVariable + @Parameter(description = "링크 ID", example = "bef039df") + String linkId, + + @LoginMemberId + @Parameter(hidden = true) + String loginMemberId + ); +} diff --git a/gateway/src/main/java/com/oing/service/DeepLinkService.java b/gateway/src/main/java/com/oing/service/DeepLinkService.java index f63e0594..9d1ca856 100644 --- a/gateway/src/main/java/com/oing/service/DeepLinkService.java +++ b/gateway/src/main/java/com/oing/service/DeepLinkService.java @@ -44,4 +44,16 @@ public DeepLink getDeepLink(String linkId) { .findById(linkId) .orElseThrow(LinkNotValidException::new); } + + public DeepLink getFamilyInviteLink(String linkId) { + DeepLink deepLink = deepLinkRepository + .findById(linkId) + .orElseThrow(LinkNotValidException::new); + + if (!deepLink.getType().equals(DeepLinkType.FAMILY_REGISTRATION)) { + throw new LinkNotValidException(); + } + + return deepLink; + } }