-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DDING-65] Feed 조회 API 구현 및 커서 기반 페이지네이션 적용 (#206)
- Loading branch information
Showing
22 changed files
with
692 additions
and
324 deletions.
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.