66import Oops .backend .common .status .SuccessStatus ;
77import Oops .backend .domain .auth .AuthenticatedUser ;
88import Oops .backend .domain .post .dto .PostResponse ;
9+ import Oops .backend .domain .post .entity .SortType ;
910import Oops .backend .domain .post .model .Situation ;
1011import Oops .backend .domain .post .service .SpecFeedService ;
1112import Oops .backend .domain .user .entity .User ;
@@ -36,50 +37,52 @@ public class SpecFeedController {
3637 * 베스트 Failers 피드
3738 */
3839 @ GetMapping ("/best/all" )
39- @ Operation (summary = "베스트 Failers 피드 조회 API" ,description = "실패담을 베스트 지표에 따라 정렬하여 보여줍니다 ." )
40+ @ Operation (summary = "베스트 Failers 피드 조회 API" ,description = "베스트 지표에 따라 선정된 베스트 실패담 50개를 정렬 기준에 따라 조회합니다 ." )
4041 public ResponseEntity <BaseResponse > getBestPostList (@ Parameter (description = "페이지 번호 (0부터 시작)" )
4142 @ RequestParam (defaultValue = "0" ) int page ,
4243 @ Parameter (description = "페이지당 게시글 수" )
43- @ RequestParam (defaultValue = "10" ) int limit ) {
44-
45- log .info ("Get /api/feeds/best/all 호출" );
46-
44+ @ RequestParam (defaultValue = "10" ) int limit ,
45+ @ Parameter (description = "정렬 기준 (BEST, LATEST, LIKE, VIEW, COMMENT)" )
46+ @ RequestParam (defaultValue = "LATEST" ) SortType sort ) {
4747 LocalDateTime cutoff = LocalDateTime .now ();
4848 Pageable pageable = PageRequest .of (page , limit );
4949
50- PostResponse .PostPreviewListDto result = specFeedService .getBestPostList (cutoff , pageable );
50+ PostResponse .PostPreviewListDto result = specFeedService .getBestPostList (cutoff , pageable , sort );
5151 return BaseResponse .onSuccess (SuccessStatus ._OK , result );
5252 }
5353
5454 /**
5555 * 즐겨찾기한 카테고리 피드
5656 */
57- @ GetMapping ("/bookmarked/all" )
58- @ Operation (summary = "즐겨찾기한 카테고리 피드 조회 API" ,description = "즐겨찾기한 카테고리의 글 중 요청 situation인 게시글을 최신순으로 조회합니다." )
59- public ResponseEntity <BaseResponse > getMarkedPostList (@ Parameter (
60- description = "게시글 상태 (OOPS: 웁스중, OVERCOMING: 극복중, OVERCOME: 극복완료)"
61- )
57+ @ GetMapping ("/bookmarked/{categoryId}/ all" )
58+ @ Operation (summary = "즐겨찾기한 카테고리 피드 조회 API" ,description = "즐겨찾기한 카테고리 중 선택된 카테고리의 글 중 요청 situation인 게시글을 정렬 기준에 따라 조회합니다." )
59+ public ResponseEntity <BaseResponse > getMarkedPostList (@ Parameter (description = "카테고리 아이디: 0이면 전체 카테고리 조회입니다." )
60+ @ PathVariable Long categoryId ,
61+ @ Parameter ( description = "게시글 상태 (OOPS: 웁스중, OVERCOMING: 극복중, OVERCOME: 극복완료)" )
6262 @ RequestParam ("situation" ) Situation situation ,
6363 @ Parameter (description = "페이지 번호 (0부터 시작)" )
6464 @ RequestParam (defaultValue = "0" ) int page ,
6565 @ Parameter (description = "페이지당 게시글 수" )
6666 @ RequestParam (defaultValue = "10" ) int limit ,
67- @ Parameter (hidden = true ) @ AuthenticatedUser User user ) {
68-
69- log .info ("Get /api/feeds/bookmarked/all 호출" );
67+ @ Parameter (hidden = true ) @ AuthenticatedUser User user ,
68+ @ Parameter (description = "정렬 기준 (LATEST, LIKE, VIEW, COMMENT)" )
69+ @ RequestParam (defaultValue = "LATEST" ) SortType sort ) {
70+ if (categoryId <0 || categoryId >15 ){
71+ throw new GeneralException (ErrorStatus .INVALID_CATEGORY_ID );
72+ }
7073
7174 LocalDateTime cutoff = LocalDateTime .now ();
72- Pageable pageable = PageRequest .of (page , limit , Sort . by ( Sort . Direction . DESC , "createdAt" ) );
75+ Pageable pageable = PageRequest .of (page , limit );
7376
74- PostResponse .PostPreviewListDto result = specFeedService .getMarkedPostList (situation , cutoff , pageable , user );
77+ PostResponse .PostPreviewListDto result = specFeedService .getMarkedPostList (situation , cutoff , pageable , user , sort , categoryId );
7578 return BaseResponse .onSuccess (SuccessStatus ._OK , result );
7679 }
7780
7881 /**
7982 * 카테고리별 피드
8083 */
8184 @ GetMapping ("/categories/{categoryId}/all" )
82- @ Operation (summary = "카테고리별 피드 조회 API" ,description = "선택된 카테고리의 글 중 요청 situation인 게시글을 최신순으로 조회합니다." )
85+ @ Operation (summary = "카테고리별 피드 조회 API" ,description = "선택된 카테고리의 글 중 요청 situation인 게시글을 정렬 기준에 따라 조회합니다." )
8386 public ResponseEntity <BaseResponse > getMarkedPostList (@ PathVariable Long categoryId ,
8487 @ Parameter (
8588 description = "게시글 상태 (OOPS: 웁스중, OVERCOMING: 극복중, OVERCOME: 극복완료)"
@@ -88,17 +91,17 @@ public ResponseEntity<BaseResponse> getMarkedPostList(@PathVariable Long categor
8891 @ Parameter (description = "페이지 번호 (0부터 시작)" )
8992 @ RequestParam (defaultValue = "0" ) int page ,
9093 @ Parameter (description = "페이지당 게시글 수" )
91- @ RequestParam (defaultValue = "10" ) int limit ) {
92-
93- log . info ( "Get /api/feeds/categories/{categoryId}/all 호출" );
94+ @ RequestParam (defaultValue = "10" ) int limit ,
95+ @ Parameter ( description = "정렬 기준 (LATEST, LIKE, VIEW, COMMENT)" )
96+ @ RequestParam ( defaultValue = "LATEST" ) SortType sort ) {
9497
9598 if (categoryId <1 || categoryId >15 ){
9699 throw new GeneralException (ErrorStatus .INVALID_CATEGORY_ID );
97100 }
98101 LocalDateTime cutoff = LocalDateTime .now ();
99- Pageable pageable = PageRequest .of (page , limit , Sort . by ( Sort . Direction . DESC , "createdAt" ) );
102+ Pageable pageable = PageRequest .of (page , limit );
100103
101- PostResponse .PostPreviewListDto result = specFeedService .getPostByCategoryList (situation , cutoff , pageable , categoryId );
104+ PostResponse .PostPreviewListDto result = specFeedService .getPostByCategoryList (situation , cutoff , pageable , categoryId , sort );
102105
103106 return BaseResponse .onSuccess (SuccessStatus ._OK , result );
104107 }
@@ -107,19 +110,21 @@ public ResponseEntity<BaseResponse> getMarkedPostList(@PathVariable Long categor
107110 * 이번주 랜덤 주제 피드
108111 */
109112 @ GetMapping ("/randomTopic/current/all" )
110- @ Operation (summary = "이번주 랜덤주제 피드 API" ,description = "이번주 랜덤주제의 글 중 요청 situation인 게시글을 최신순으로 조회합니다." )
113+ @ Operation (summary = "이번주 랜덤주제 피드 API" ,description = "이번주 랜덤주제의 글 중 요청 situation인 게시글을 정렬 기준에 따라 조회합니다." )
111114 public ResponseEntity <BaseResponse > getThisWeekPostList (@ Parameter (
112115 description = "게시글 상태 (OOPS: 웁스중, OVERCOMING: 극복중, OVERCOME: 극복완료)"
113116 )
114117 @ RequestParam ("situation" ) Situation situation ,
115118 @ Parameter (description = "페이지 번호 (0부터 시작)" )
116119 @ RequestParam (defaultValue = "0" ) int page ,
117120 @ Parameter (description = "페이지당 게시글 수" )
118- @ RequestParam (defaultValue = "10" ) int limit ) {
121+ @ RequestParam (defaultValue = "10" ) int limit ,
122+ @ Parameter (description = "정렬 기준 (LATEST, LIKE, VIEW, COMMENT)" )
123+ @ RequestParam (defaultValue = "LATEST" ) SortType sort ) {
119124 LocalDateTime cutoff = LocalDateTime .now ();
120- Pageable pageable = PageRequest .of (page , limit , Sort . by ( Sort . Direction . DESC , "createdAt" ) );
125+ Pageable pageable = PageRequest .of (page , limit );
121126
122- PostResponse .PostPreviewListDto result = specFeedService .getThisWeekPostList (situation , cutoff , pageable );
127+ PostResponse .PostPreviewListDto result = specFeedService .getThisWeekPostList (situation , cutoff , pageable , sort );
123128
124129 return BaseResponse .onSuccess (SuccessStatus ._OK , result );
125130 }
@@ -128,20 +133,22 @@ public ResponseEntity<BaseResponse> getThisWeekPostList(@Parameter(
128133 * 저번주 랜덤 주제 피드
129134 */
130135 @ GetMapping ("/randomTopic/last/all" )
131- @ Operation (summary = "저번주 랜덤주제 피드 API" ,description = "저번주 랜덤주제 top3 글과 요청 situation인 게시글을 최신순으로 조회합니다." )
136+ @ Operation (summary = "저번주 랜덤주제 피드 API" ,description = "저번주 랜덤주제 top3 글과 요청 situation인 게시글을 정렬 기준에 따라 조회합니다." )
132137 public ResponseEntity <BaseResponse > getLastWeekPostList (@ Parameter (
133138 description = "게시글 상태 (OOPS: 웁스중, OVERCOMING: 극복중, OVERCOME: 극복완료)"
134139 )
135140 @ RequestParam ("situation" ) Situation situation ,
136141 @ Parameter (description = "페이지 번호 (0부터 시작)" )
137142 @ RequestParam (defaultValue = "0" ) int page ,
138143 @ Parameter (description = "페이지당 게시글 수" )
139- @ RequestParam (defaultValue = "10" ) int limit ) {
144+ @ RequestParam (defaultValue = "10" ) int limit ,
145+ @ Parameter (description = "정렬 기준 (LATEST, LIKE, VIEW, COMMENT)" )
146+ @ RequestParam (defaultValue = "LATEST" ) SortType sort ) {
140147
141148 LocalDateTime cutoff = LocalDateTime .now ();
142- Pageable pageable = PageRequest .of (page , limit , Sort . by ( Sort . Direction . DESC , "createdAt" ) );
149+ Pageable pageable = PageRequest .of (page , limit );
143150
144- List <PostResponse .PostPreviewListDto > result = specFeedService .getLastWeekPostList (situation , cutoff , pageable );
151+ List <PostResponse .PostPreviewListDto > result = specFeedService .getLastWeekPostList (situation , cutoff , pageable , sort );
145152
146153 return BaseResponse .onSuccess (SuccessStatus ._OK , result );
147154 }
0 commit comments