Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MODIFY] 커피챗 API 변경 (#462) #463

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import lombok.RequiredArgsConstructor;
import lombok.val;
import org.sopt.app.application.auth.dto.PlaygroundAuthTokenInfo.RefreshedToken;
import org.sopt.app.application.playground.dto.PlayGroundCoffeeChatResponse;
import org.sopt.app.application.playground.dto.PlayGroundEmploymentResponse;
import org.sopt.app.application.playground.dto.PlayGroundPostCategory;
import org.sopt.app.application.playground.dto.PlayGroundPostDetailResponse;
Expand Down Expand Up @@ -209,7 +210,7 @@ public List<RecentPostsResponse> getRecentPostsWithMemberInfo(String playgroundT
List<RecentPostsResponse> recentPosts = getRecentPosts(playgroundToken);
return getPostsWithMemberInfo(playgroundToken, recentPosts);
}

public List<EmploymentPostResponse> getPlaygroundEmploymentPost(String accessToken) {
Map<String, String> requestHeader = createAuthorizationHeaderByUserPlaygroundToken(accessToken);
PlayGroundEmploymentResponse postInfo = playgroundClient.getPlaygroundEmploymentPost(requestHeader,16,10,0);
Expand All @@ -222,10 +223,12 @@ public List<CoffeeChatResponse> getCoffeeChatList(String accessToken) {
Map<String, String> headers = PlaygroundHeaderCreator.createAuthorizationHeaderByUserPlaygroundToken(accessToken);
return playgroundClient.getCoffeeChatList(headers).coffeeChatList().stream()
.filter(member -> !member.isBlind())
.map(CoffeeChatResponse::of)
.map(i -> CoffeeChatResponse.of(i, getCurrentActivity(i)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3. i 말고 더 명확한 변수명 사용해주시면 좋을 것 같아요!

.toList();
}



public List<EmploymentPostResponse> getPlaygroundEmploymentPostWithMemberInfo(String playgroundToken) {
List<EmploymentPostResponse> employmentPosts = getPlaygroundEmploymentPost(playgroundToken);
return getPostsWithMemberInfo(playgroundToken, employmentPosts);
Expand All @@ -250,4 +253,11 @@ private <T extends PostWithMemberInfo> List<T> getPostsWithMemberInfo(String pla
}
return mutablePosts;
}

private String getCurrentActivity(PlayGroundCoffeeChatResponse playGroundCoffeeChatResponse) {
return playGroundCoffeeChatResponse.soptActivities().stream()
.filter(activity -> activity.contains(currentGeneration.toString()))
.findFirst()
.orElse(null);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.sopt.app.presentation.home.response;

import java.util.ArrayList;
import java.util.List;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -17,18 +18,24 @@ public class CoffeeChatResponse {
private String organization;
private String companyJob;
private List<String> soptActivities;
private String currentSoptActivity;

public static CoffeeChatResponse of(PlayGroundCoffeeChatResponse playGroundCoffeeChatResponse){
public static CoffeeChatResponse of(PlayGroundCoffeeChatResponse playGroundCoffeeChatResponse, String currentSoptActivity) {
List<String> updatedSoptActivities = new ArrayList<>(playGroundCoffeeChatResponse.soptActivities());
if (currentSoptActivity != null) {
updatedSoptActivities.remove(currentSoptActivity);
}
return CoffeeChatResponse.builder()
.memberId(playGroundCoffeeChatResponse.memberId())
.bio(playGroundCoffeeChatResponse.bio())
.topicTypeList(playGroundCoffeeChatResponse.topicTypeList())
.profileImage(playGroundCoffeeChatResponse.profileImage())
.name(playGroundCoffeeChatResponse.name())
.career(playGroundCoffeeChatResponse.career())
.career(playGroundCoffeeChatResponse.career().equals("아직 없어요") ? null : playGroundCoffeeChatResponse.career())
.organization(playGroundCoffeeChatResponse.organization())
.companyJob(playGroundCoffeeChatResponse.companyJob())
.soptActivities(playGroundCoffeeChatResponse.soptActivities())
.soptActivities(updatedSoptActivities)
.currentSoptActivity(currentSoptActivity)
.build();
}
}