diff --git a/src/main/java/org/sopt/app/application/playground/PlaygroundAuthService.java b/src/main/java/org/sopt/app/application/playground/PlaygroundAuthService.java index e0ccc256..35fffe81 100755 --- a/src/main/java/org/sopt/app/application/playground/PlaygroundAuthService.java +++ b/src/main/java/org/sopt/app/application/playground/PlaygroundAuthService.java @@ -184,6 +184,10 @@ private String convertPlaygroundWebPageUrl(Long postId) { return playgroundWebPageUrl + "/?feed=" + postId; } + private String convertCoffeeChatWebPageUrl(Long memberId) { + return playgroundWebPageUrl + "/coffeechat/" + memberId; + } + public boolean isCurrentGeneration(Long generation) { return generation.equals(currentGeneration); } @@ -191,12 +195,18 @@ public boolean isCurrentGeneration(Long generation) { public List getRecentPosts(String playgroundToken) { final Map accessToken = createAuthorizationHeaderByUserPlaygroundToken(playgroundToken); try (ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor()) { - List categories = List.of(PlayGroundPostCategory.SOPT_ACTIVITY, PlayGroundPostCategory.FREE, PlayGroundPostCategory.PART); - CompletableFuture hotPostFuture = CompletableFuture.supplyAsync(() -> - RecentPostsResponse.of(playgroundClient.getPlaygroundHotPost(accessToken)), executor); + List categories = List.of(PlayGroundPostCategory.SOPT_ACTIVITY, + PlayGroundPostCategory.FREE, PlayGroundPostCategory.PART); + CompletableFuture hotPostFuture = CompletableFuture.supplyAsync( + () -> playgroundClient.getPlaygroundHotPost(accessToken), executor) + .thenApply(post -> RecentPostsResponse.of(post, convertPlaygroundWebPageUrl(post.postId()))); List> categoryFutures = categories.stream() - .map(category -> CompletableFuture.supplyAsync(() -> playgroundClient.getRecentPosts(accessToken, category.getDisplayName()), executor)) - .toList(); + .map(category -> CompletableFuture.supplyAsync( + () -> playgroundClient.getRecentPosts(accessToken, category.getDisplayName()), executor) + .thenApply(post -> { + post.setLink(convertPlaygroundWebPageUrl(post.getId())); + return post; + })).toList(); List> allFutures = new ArrayList<>(categoryFutures); allFutures.addFirst(hotPostFuture); CompletableFuture allOf = CompletableFuture.allOf(allFutures.toArray(new CompletableFuture[0])); @@ -214,22 +224,20 @@ public List getRecentPostsWithMemberInfo(String playgroundT public List getPlaygroundEmploymentPost(String accessToken) { Map requestHeader = createAuthorizationHeaderByUserPlaygroundToken(accessToken); - PlayGroundEmploymentResponse postInfo = playgroundClient.getPlaygroundEmploymentPost(requestHeader,16,10,0); + PlayGroundEmploymentResponse postInfo = playgroundClient.getPlaygroundEmploymentPost(requestHeader, 16, 10, 0); return postInfo.posts().stream() - .map(EmploymentPostResponse::of) + .map(post -> EmploymentPostResponse.of(post, convertPlaygroundWebPageUrl(post.id()))) .toList(); } public List getCoffeeChatList(String accessToken) { - Map headers = PlaygroundHeaderCreator.createAuthorizationHeaderByUserPlaygroundToken(accessToken); + Map headers = PlaygroundHeaderCreator.createAuthorizationHeaderByUserPlaygroundToken( + accessToken); return playgroundClient.getCoffeeChatList(headers).coffeeChatList().stream() .filter(member -> !member.isBlind()) - .map(i -> CoffeeChatResponse.of(i, getCurrentActivity(i))) - .toList(); + .map(member -> CoffeeChatResponse.of(member, getCurrentActivity(member), convertCoffeeChatWebPageUrl(member.memberId()))).toList(); } - - public List getPlaygroundEmploymentPostWithMemberInfo(String playgroundToken) { List employmentPosts = getPlaygroundEmploymentPost(playgroundToken); return getPostsWithMemberInfo(playgroundToken, employmentPosts); @@ -239,7 +247,8 @@ private T addMemberInfoToPost(T post, PlayGroundP if (postDetail.member() != null) { return (T) post.withMemberDetail(postDetail.member().name(), postDetail.member().profileImage()); } else if (postDetail.anonymousProfile() != null) { - return (T) post.withMemberDetail(postDetail.anonymousProfile().nickname(), postDetail.anonymousProfile().profileImgUrl()); + return (T) post.withMemberDetail(postDetail.anonymousProfile().nickname(), + postDetail.anonymousProfile().profileImgUrl()); } throw new EntityNotFoundException("Member not found"); } @@ -261,9 +270,11 @@ private String getCurrentActivity(PlayGroundCoffeeChatResponse playGroundCoffeeC .findFirst() .orElse(null); } + public int getUserSoptLevel(User user) { - final Map accessToken = createAuthorizationHeaderByUserPlaygroundToken(user.getPlaygroundToken()); - return playgroundClient.getPlayGroundUserSoptLevel(accessToken,user.getPlaygroundId()).soptProjectCount(); + final Map accessToken = createAuthorizationHeaderByUserPlaygroundToken( + user.getPlaygroundToken()); + return playgroundClient.getPlayGroundUserSoptLevel(accessToken, user.getPlaygroundId()).soptProjectCount(); } public PlaygroundProfile getPlayGroundProfile(String accessToken) {