Skip to content

Commit

Permalink
[MERGE] 커피챗 API 변경 (#462) (#463)
Browse files Browse the repository at this point in the history
  • Loading branch information
rlarlgnszx authored Jan 30, 2025
2 parents 4fbe7d8 + a49ca78 commit 3d74498
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
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 @@ -210,7 +211,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 @@ -223,10 +224,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)))
.toList();
}



public List<EmploymentPostResponse> getPlaygroundEmploymentPostWithMemberInfo(String playgroundToken) {
List<EmploymentPostResponse> employmentPosts = getPlaygroundEmploymentPost(playgroundToken);
return getPostsWithMemberInfo(playgroundToken, employmentPosts);
Expand All @@ -252,6 +255,12 @@ 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);
}
public int getUserSoptLevel(User user) {
final Map<String, String> accessToken = createAuthorizationHeaderByUserPlaygroundToken(user.getPlaygroundToken());
return playgroundClient.getPlayGroundUserSoptLevel(accessToken,user.getPlaygroundId()).soptProjectCount();
Expand All @@ -260,6 +269,5 @@ public int getUserSoptLevel(User user) {
public PlaygroundProfile getPlayGroundProfile(String accessToken) {
Map<String, String> requestHeader = createAuthorizationHeaderByUserPlaygroundToken(accessToken);
return playgroundClient.getPlayGroundProfile(requestHeader);

}
}
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();
}
}

0 comments on commit 3d74498

Please sign in to comment.