Skip to content

Commit

Permalink
[FEAT] 커피챗 등록 유저들 리스트 조회 API - #435 (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
rlarlgnszx authored Nov 23, 2024
2 parents 921253e + 3334d5a commit 4d1a3f7
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 6 deletions.
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);
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")
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();
}
}

0 comments on commit 4d1a3f7

Please sign in to comment.