-
Notifications
You must be signed in to change notification settings - Fork 1
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
[DDING-65] Feed 조회 API 구현 및 커서 기반 페이지네이션 적용 #206
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
46c4006
feat : 페이지네이션 적용에 따른 명세 및 dto 수정
KoSeonJe a2960b3
feat : 커서 기반 페이지네이션 쿼리 작성
KoSeonJe 1094f18
feat : 페이지네이션 적용에 따른 변경 로직 및 FileMetaData 적용에 따른 변경 로직 구현
KoSeonJe b121c94
feat : feed상세 조회 API 명세 수정에 따른 dto 수정
KoSeonJe 3c34283
feat : feed url 처리 로직 수정
KoSeonJe bed1bdf
feat : page찾기 메소드 이름 수정
KoSeonJe 5ade9f3
test : 커서 기반 페이지네이션 쿼리 테스트 작성
KoSeonJe f679b60
test : page 정확한 정보 반환하는지 테스트 작성
KoSeonJe c5b4866
feat : 다음 페이지 존재 여부 로직 추가
KoSeonJe eb7cf83
refactor: pagingQuery 입력 변수 수정
KoSeonJe b598176
test : repository 테스트 일부 수정
KoSeonJe aa2adb5
feat : 모든 동아리 최신 피드 페이지 조회 API 구현
KoSeonJe c82b50d
test : 모든 동아리 최신 피드 페이지 조회 쿼리 테스트 작성
KoSeonJe 78c3698
refactor : 사용하지 않은 쿼리 제거
KoSeonJe e561ec8
merge develop
KoSeonJe edadc87
test : test 에러 수정
KoSeonJe 9ca4756
refactor : pathVariable 파라미터 지정
KoSeonJe 7374d2f
feat : page의 콘텐츠가 빈 값일 때 예외 추가
KoSeonJe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
49 changes: 28 additions & 21 deletions
49
src/main/java/ddingdong/ddingdongBE/domain/feed/api/FeedApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,49 @@ | ||
package ddingdong.ddingdongBE.domain.feed.api; | ||
|
||
import ddingdong.ddingdongBE.domain.feed.controller.dto.response.FeedListResponse; | ||
import ddingdong.ddingdongBE.domain.feed.controller.dto.response.ClubFeedPageResponse; | ||
import ddingdong.ddingdongBE.domain.feed.controller.dto.response.FeedResponse; | ||
import ddingdong.ddingdongBE.domain.feed.controller.dto.response.NewestFeedListResponse; | ||
import ddingdong.ddingdongBE.domain.feed.controller.dto.response.NewestFeedPerClubPageResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import java.util.List; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
||
@Tag(name = "Feed - User", description = "Feed API") | ||
@RequestMapping("/server") | ||
public interface FeedApi { | ||
|
||
@Operation(summary = "동아리 피드 전체 조회 API") | ||
@ApiResponse(responseCode = "200", description = "동아리 피드 전체 조회 성공", | ||
content = @Content(schema = @Schema(implementation = FeedListResponse.class))) | ||
@ResponseStatus(HttpStatus.OK) | ||
@GetMapping("/clubs/{clubId}/feeds") | ||
List<FeedListResponse> getAllFeedByClubId(@PathVariable Long clubId); | ||
@Operation(summary = "특정 동아리 피드 페이지 조회 API") | ||
@ApiResponse(responseCode = "200", description = "특정 동아리 피드 페이지 조회 성공", | ||
content = @Content(schema = @Schema(implementation = ClubFeedPageResponse.class))) | ||
@ResponseStatus(HttpStatus.OK) | ||
@GetMapping("/clubs/{clubId}/feeds") | ||
ClubFeedPageResponse getFeedPageByClub( | ||
@PathVariable("clubId") Long clubId, | ||
@RequestParam(value = "size", defaultValue = "9") int size, | ||
@RequestParam(value = "currentCursorId", defaultValue = "-1") Long currentCursorId | ||
); | ||
|
||
@Operation(summary = "전체 동아리 최신 피드 조회 API") | ||
@ApiResponse(responseCode = "200", description = "전체 동아리 최신 피드 조회 성공", | ||
content = @Content(schema = @Schema(implementation = NewestFeedListResponse.class))) | ||
@ResponseStatus(HttpStatus.OK) | ||
@GetMapping("/feeds") | ||
List<NewestFeedListResponse> getNewestAllFeed(); | ||
@Operation(summary = "모든 동아리 최신 피드 페이지 조회 API") | ||
@ApiResponse(responseCode = "200", description = "모든 동아리 최신 피드 페이지 조회 성공", | ||
content = @Content(schema = @Schema(implementation = NewestFeedPerClubPageResponse.class))) | ||
@ResponseStatus(HttpStatus.OK) | ||
@GetMapping("/feeds") | ||
NewestFeedPerClubPageResponse getNewestFeedPerClub( | ||
@RequestParam(value = "size", defaultValue = "9") int size, | ||
@RequestParam(value = "currentCursorId", defaultValue = "-1") Long currentCursorId | ||
); | ||
|
||
@Operation(summary = "동아리 피드 상세 조회 API") | ||
@ApiResponse(responseCode = "200", description = "동아리 피드 상세 조회 API", | ||
content = @Content(schema = @Schema(implementation = FeedResponse.class))) | ||
@ResponseStatus(HttpStatus.OK) | ||
@GetMapping("/feeds/{feedId}") | ||
FeedResponse getByFeedId(@PathVariable("feedId") Long feedId); | ||
@Operation(summary = "동아리 피드 상세 조회 API") | ||
@ApiResponse(responseCode = "200", description = "동아리 피드 상세 조회 API", | ||
content = @Content(schema = @Schema(implementation = FeedResponse.class))) | ||
@ResponseStatus(HttpStatus.OK) | ||
@GetMapping("/feeds/{feedId}") | ||
FeedResponse getByFeedId(@PathVariable("feedId") Long feedId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
.../java/ddingdong/ddingdongBE/domain/feed/controller/dto/response/ClubFeedPageResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package ddingdong.ddingdongBE.domain.feed.controller.dto.response; | ||
|
||
import ddingdong.ddingdongBE.domain.feed.service.dto.query.ClubFeedPageQuery; | ||
import ddingdong.ddingdongBE.domain.feed.service.dto.query.FeedListQuery; | ||
import io.swagger.v3.oas.annotations.media.ArraySchema; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import java.util.List; | ||
import lombok.Builder; | ||
|
||
public record ClubFeedPageResponse( | ||
@ArraySchema(schema = @Schema(name = "동아리 피드 정보", implementation = ClubFeedListResponse.class)) | ||
List<ClubFeedListResponse> clubFeeds, | ||
@Schema(name = "피드 페이지 정보", implementation = PagingResponse.class) | ||
PagingResponse pagingInfo | ||
) { | ||
|
||
public static ClubFeedPageResponse from(ClubFeedPageQuery clubFeedPageQuery) { | ||
List<ClubFeedListResponse> clubFeeds = clubFeedPageQuery.feedListQueries().stream() | ||
.map(ClubFeedListResponse::from) | ||
.toList(); | ||
return new ClubFeedPageResponse(clubFeeds, PagingResponse.from(clubFeedPageQuery.pagingQuery())); | ||
} | ||
|
||
@Builder | ||
record ClubFeedListResponse( | ||
@Schema(description = "피드 ID", example = "1") | ||
Long id, | ||
@Schema(description = "피드 썸네일 CDN URL", example = "https://%s.s3.%s.amazonaws.com/%s/%s/%s") | ||
String thumbnailCdnUrl, | ||
@Schema(description = "피드 썸네일 S3 URL", example = "https://%s.s3.%s.amazonaws.com/%s/%s/%s") | ||
String thumbnailOriginUrl, | ||
@Schema(description = "피드 타입", example = "IMAGE") | ||
String feedType | ||
) { | ||
|
||
public static ClubFeedListResponse from(FeedListQuery feedListQuery) { | ||
return ClubFeedListResponse.builder() | ||
.id(feedListQuery.id()) | ||
.thumbnailCdnUrl(feedListQuery.thumbnailCdnUrl()) | ||
.thumbnailOriginUrl(feedListQuery.thumbnailOriginUrl()) | ||
.feedType(feedListQuery.feedType()) | ||
.build(); | ||
} | ||
} | ||
} |
24 changes: 0 additions & 24 deletions
24
...main/java/ddingdong/ddingdongBE/domain/feed/controller/dto/response/FeedListResponse.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
...ava/ddingdong/ddingdongBE/domain/feed/controller/dto/response/NewestFeedListResponse.java
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
...ngdong/ddingdongBE/domain/feed/controller/dto/response/NewestFeedPerClubPageResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package ddingdong.ddingdongBE.domain.feed.controller.dto.response; | ||
|
||
import ddingdong.ddingdongBE.domain.feed.service.dto.query.FeedListQuery; | ||
import ddingdong.ddingdongBE.domain.feed.service.dto.query.NewestFeedPerClubPageQuery; | ||
import io.swagger.v3.oas.annotations.media.ArraySchema; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import java.util.List; | ||
import lombok.Builder; | ||
|
||
public record NewestFeedPerClubPageResponse( | ||
@ArraySchema(schema = @Schema(name = "동아리 최신 피드 정보", implementation = NewestFeedListResponse.class)) | ||
List<NewestFeedListResponse> newestFeeds, | ||
@Schema(name = "피드 페이지 정보", implementation = PagingResponse.class) | ||
PagingResponse pagingInfo | ||
) { | ||
|
||
public static NewestFeedPerClubPageResponse from(NewestFeedPerClubPageQuery newestFeedPerClubPageQuery) { | ||
List<NewestFeedListResponse> newestFeeds = newestFeedPerClubPageQuery.feedListQueries().stream() | ||
.map(NewestFeedListResponse::from) | ||
.toList(); | ||
return new NewestFeedPerClubPageResponse(newestFeeds, | ||
PagingResponse.from(newestFeedPerClubPageQuery.pagingQuery())); | ||
} | ||
|
||
@Builder | ||
public record NewestFeedListResponse( | ||
@Schema(description = "피드 ID", example = "1") | ||
Long id, | ||
@Schema(description = "피드 썸네일 CDN URL", example = "https://%s.s3.%s.amazonaws.com/%s/%s/%s") | ||
String thumbnailCdnUrl, | ||
@Schema(description = "피드 썸네일 S3 URL", example = "https://%s.s3.%s.amazonaws.com/%s/%s/%s") | ||
String thumbnailOriginUrl, | ||
@Schema(description = "피드 타입", example = "IMAGE") | ||
String feedType | ||
) { | ||
|
||
public static NewestFeedListResponse from(FeedListQuery query) { | ||
return NewestFeedListResponse.builder() | ||
.id(query.id()) | ||
.thumbnailOriginUrl(query.thumbnailOriginUrl()) | ||
.thumbnailCdnUrl(query.thumbnailCdnUrl()) | ||
.feedType(query.feedType()) | ||
.build(); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/ddingdong/ddingdongBE/domain/feed/controller/dto/response/PagingResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package ddingdong.ddingdongBE.domain.feed.controller.dto.response; | ||
|
||
import ddingdong.ddingdongBE.domain.feed.service.dto.query.PagingQuery; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
public record PagingResponse( | ||
@Schema(name = "현재 커서 id", description = "9") | ||
Long currentCursorId, | ||
@Schema(name = "다음 커서 id", description = "10") | ||
Long nextCursorId, | ||
@Schema(name = "다음 커서 존재 여부", description = "true") | ||
boolean hasNext | ||
) { | ||
|
||
public static PagingResponse from(PagingQuery pagingQuery) { | ||
return new PagingResponse(pagingQuery.currentCursorId(), pagingQuery.nextCursorId(), pagingQuery.hasNext()); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
from 메서드에 null 체크 추가 필요
pagingQuery
가 null인 경우에 대한 처리가 누락되었습니다.