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

[FEAT] 커피챗 등록 유저들 리스트 조회 API - #435 #448

Merged
merged 7 commits into from
Nov 23, 2024
Merged
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 @@ -7,6 +7,7 @@
import jakarta.persistence.EntityNotFoundException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -38,6 +39,7 @@
import org.sopt.app.domain.enums.UserStatus;
import org.sopt.app.presentation.auth.AppAuthRequest.AccessTokenRequest;
import org.sopt.app.presentation.auth.AppAuthRequest.CodeRequest;
import org.sopt.app.presentation.home.response.CoffeeChatResponse;
import org.sopt.app.presentation.home.response.EmploymentPostResponse;
import org.sopt.app.presentation.home.response.RecentPostsResponse;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -212,7 +214,16 @@ public List<EmploymentPostResponse> getPlaygroundEmploymentPost(String accessTok
Map<String, String> requestHeader = createAuthorizationHeaderByUserPlaygroundToken(accessToken);
PlayGroundEmploymentResponse postInfo = playgroundClient.getPlaygroundEmploymentPost(requestHeader,16,10,0);
Copy link
Member

Choose a reason for hiding this comment

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

P3: 저번 PR에서 놓쳤는데 16, 10, 0이라는 부분이 알아보기 어렵기도 하고 너무 많은 변수를 가지고 있는 것 같아요.
DTO로 묶거나, 필드로 사용해서 이름을 명시하거나 하는게 좋을 것 같다 생각됩니다!

return postInfo.posts().stream()
.map(EmploymentPostResponse::of).toList();
.map(EmploymentPostResponse::of)
.toList();
}

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

public List<EmploymentPostResponse> getPlaygroundEmploymentPostWithMemberInfo(String playgroundToken) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.List;
import java.util.Map;
import org.sopt.app.application.auth.dto.PlaygroundAuthTokenInfo.RefreshedToken;
import org.sopt.app.application.playground.dto.PlayGroundCoffeeChatWrapper;
import org.sopt.app.application.playground.dto.PlayGroundEmploymentResponse;
import org.sopt.app.application.playground.dto.PlayGroundPostDetailResponse;
import org.sopt.app.application.playground.dto.PlaygroundPostInfo.PlaygroundPostResponse;
Expand Down Expand Up @@ -63,6 +64,9 @@ PlayGroundEmploymentResponse getPlaygroundEmploymentPost(@HeaderMap Map<String,
@Param int limit,
@Param int cursor);

@RequestLine("GET /api/v1/members/coffeechat")
PlayGroundCoffeeChatWrapper getCoffeeChatList(@HeaderMap Map<String, String> headers);

@RequestLine("GET /api/v1/community/posts/{postId}")
PlayGroundPostDetailResponse getPlayGroundPostDetail(@HeaderMap Map<String, String> headers,
@Param Long postId);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.sopt.app.application.playground.dto;

import java.util.List;

public record PlayGroundCoffeeChatResponse(
Long memberId,
String bio,
List<String> topicTypeList,
String profileImage,
String name,
String career,
String organization,
String companyJob,
List<String> soptActivities,
boolean isMine,
boolean isBlind
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sopt.app.application.playground.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

public record PlayGroundCoffeeChatWrapper(
@JsonProperty("coffeeChatList")
Copy link
Member

Choose a reason for hiding this comment

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

Q. 이거 사용하신 이유가 있나요? 알아서 coffeeChatList로 네이밍 되는 것으로 알아서요!

List<PlayGroundCoffeeChatResponse> coffeeChatList
) {
}
12 changes: 9 additions & 3 deletions src/main/java/org/sopt/app/facade/HomeFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.val;
import org.sopt.app.application.app_service.*;
import org.sopt.app.application.app_service.AppServiceBadgeService;
import org.sopt.app.application.app_service.AppServiceService;
import org.sopt.app.application.app_service.dto.AppServiceEntryStatusResponse;
import org.sopt.app.application.app_service.dto.AppServiceInfo;
import org.sopt.app.application.home.ActivityDurationCalculator;
import org.sopt.app.application.playground.PlaygroundAuthService;
import org.sopt.app.application.description.DescriptionInfo.MainDescription;
import org.sopt.app.application.description.DescriptionService;
import org.sopt.app.application.home.ActivityDurationCalculator;
import org.sopt.app.application.playground.PlaygroundAuthService;
import org.sopt.app.domain.entity.User;
import org.sopt.app.domain.enums.UserStatus;
import org.sopt.app.presentation.home.HomeDescriptionResponse;
import org.sopt.app.presentation.home.response.CoffeeChatResponse;
import org.sopt.app.presentation.home.response.RecentPostsResponse;
import org.sopt.app.presentation.home.response.EmploymentPostResponse;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -80,4 +82,8 @@ public List<EmploymentPostResponse> getHomeEmploymentPost(User user) {
return playgroundAuthService.getPlaygroundEmploymentPostWithMemberInfo(user.getPlaygroundToken());
}

@Transactional(readOnly = true)
public List<CoffeeChatResponse> getCoffeeChatList(User user) {
return playgroundAuthService.getCoffeeChatList(user.getPlaygroundToken());
}
}
23 changes: 21 additions & 2 deletions src/main/java/org/sopt/app/presentation/home/HomeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
import org.sopt.app.application.meeting.MeetingResponse;
import org.sopt.app.domain.entity.User;
import org.sopt.app.facade.HomeFacade;
import org.sopt.app.presentation.home.response.RecentPostsResponse;
import org.sopt.app.presentation.home.response.CoffeeChatResponse;
import org.sopt.app.presentation.home.response.EmploymentPostResponse;
import org.sopt.app.presentation.home.response.RecentPostsResponse;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
Expand Down Expand Up @@ -85,6 +89,21 @@ public ResponseEntity<List<EmploymentPostResponse>> getEmploymentPosts(
);
}

@Operation(summary = "커피챗 리스트 조회")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "success"),
@ApiResponse(responseCode = "401", description = "token error", content = @Content),
@ApiResponse(responseCode = "500", description = "server error", content = @Content)
})
@GetMapping("/coffeechat")
public ResponseEntity<List<CoffeeChatResponse>> getCoffeeChatList(
@AuthenticationPrincipal User user
) {
return ResponseEntity.ok(
homeFacade.getCoffeeChatList(user)
);
}

@Operation(summary = "전체 모임 확인")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "success"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.sopt.app.presentation.home.response;

import java.util.List;
import lombok.Builder;
import lombok.Getter;
import org.sopt.app.application.playground.dto.PlayGroundCoffeeChatResponse;

@Getter
@Builder
public class CoffeeChatResponse {
private Long memberId;
private String bio;
private List<String> topicTypeList;
private String profileImage;
private String name;
private String career;
private String organization;
private String companyJob;
private List<String> soptActivities;

public static CoffeeChatResponse of(PlayGroundCoffeeChatResponse playGroundCoffeeChatResponse){
return CoffeeChatResponse.builder()
.memberId(playGroundCoffeeChatResponse.memberId())
.bio(playGroundCoffeeChatResponse.bio())
.topicTypeList(playGroundCoffeeChatResponse.topicTypeList())
.profileImage(playGroundCoffeeChatResponse.profileImage())
.name(playGroundCoffeeChatResponse.name())
.career(playGroundCoffeeChatResponse.career())
.organization(playGroundCoffeeChatResponse.organization())
.companyJob(playGroundCoffeeChatResponse.companyJob())
.soptActivities(playGroundCoffeeChatResponse.soptActivities())
.build();
}
}
Loading