22
33import com .ai .lawyer .domain .post .dto .*;
44import com .ai .lawyer .domain .post .service .PostService ;
5- import com .ai .lawyer .domain .member .entity .Member ;
65import com .ai .lawyer .domain .member .repositories .MemberRepository ;
76import com .ai .lawyer .global .jwt .TokenProvider ;
87import com .ai .lawyer .global .response .ApiResponse ;
98import io .swagger .v3 .oas .annotations .Operation ;
109import io .swagger .v3 .oas .annotations .tags .Tag ;
11- import jakarta .servlet .http .HttpServletRequest ;
12- import lombok .AllArgsConstructor ;
13- import lombok .Data ;
1410import lombok .RequiredArgsConstructor ;
15- import org .springframework .beans .factory .annotation .Autowired ;
1611import org .springframework .http .ResponseEntity ;
1712import org .springframework .web .bind .annotation .*;
1813import org .springframework .web .server .ResponseStatusException ;
@@ -66,7 +61,7 @@ public ResponseEntity<ApiResponse<List<PostDetailDto>>> getAllPosts() {
6661 }
6762
6863 @ Operation (summary = "게시글 간편 전체 조회" )
69- @ GetMapping ("/simple " )
64+ @ GetMapping ("/simplePost " )
7065 public ResponseEntity <ApiResponse <List <PostSimpleDto >>> getAllSimplePosts () {
7166 List <PostSimpleDto > posts = postService .getAllSimplePosts ();
7267 return ResponseEntity .ok (new ApiResponse <>(200 , "게시글 간편 전체 조회 성공" , posts ));
@@ -153,7 +148,7 @@ public ResponseEntity<ApiResponse<List<PostDto>>> getMyPosts() {
153148 }
154149
155150 @ Operation (summary = "게시글+투표 동시 등록" )
156- @ PostMapping ("/with-poll " )
151+ @ PostMapping ("/createpost " )
157152 public ResponseEntity <ApiResponse <PostDetailDto >> createPostWithPoll (@ RequestBody PostWithPollCreateDto dto ) {
158153 Authentication authentication = SecurityContextHolder .getContext ().getAuthentication ();
159154 Object principal = authentication .getPrincipal ();
@@ -171,7 +166,7 @@ public ResponseEntity<ApiResponse<PostDetailDto>> createPostWithPoll(@RequestBod
171166
172167 @ Operation (summary = "게시글 페이징 조회" )
173168 @ GetMapping ("/paged" )
174- public ResponseEntity <ApiResponse <PostPageDTO >> getPostsPaged (
169+ public ResponseEntity <ApiResponse <PostPageDto >> getPostsPaged (
175170 @ RequestParam (defaultValue = "0" ) int page ,
176171 @ RequestParam (defaultValue = "10" ) int size
177172 ) {
@@ -180,7 +175,37 @@ public ResponseEntity<ApiResponse<PostPageDTO>> getPostsPaged(
180175 if (posts == null ) {
181176 posts = new org .springframework .data .domain .PageImpl <>(java .util .Collections .emptyList (), pageable , 0 );
182177 }
183- PostPageDTO response = new PostPageDTO (posts );
178+ PostPageDto response = new PostPageDto (posts );
184179 return ResponseEntity .ok (new ApiResponse <>(200 , "페이징 게시글 조회 성공" , response ));
185180 }
181+
182+ @ Operation (summary = "진행중 투표 게시글 페이징 조회" )
183+ @ GetMapping ("/ongoingPaged" )
184+ public ResponseEntity <ApiResponse <PostPageDto >> getOngoingPostsPaged (
185+ @ RequestParam (defaultValue = "0" ) int page ,
186+ @ RequestParam (defaultValue = "10" ) int size
187+ ) {
188+ Pageable pageable = PageRequest .of (page , size , Sort .by ("createdAt" ).descending ());
189+ Page <PostDto > posts = postService .getOngoingPostsPaged (pageable );
190+ if (posts == null ) {
191+ posts = new org .springframework .data .domain .PageImpl <>(java .util .Collections .emptyList (), pageable , 0 );
192+ }
193+ PostPageDto response = new PostPageDto (posts );
194+ return ResponseEntity .ok (new ApiResponse <>(200 , "진행중 투표 게시글 페이징 조회 성공" , response ));
195+ }
196+
197+ @ Operation (summary = "마감 투표 게시글 페이징 조회" )
198+ @ GetMapping ("/closedPaged" )
199+ public ResponseEntity <ApiResponse <PostPageDto >> getClosedPostsPaged (
200+ @ RequestParam (defaultValue = "0" ) int page ,
201+ @ RequestParam (defaultValue = "10" ) int size
202+ ) {
203+ Pageable pageable = PageRequest .of (page , size , Sort .by ("createdAt" ).descending ());
204+ Page <PostDto > posts = postService .getClosedPostsPaged (pageable );
205+ if (posts == null ) {
206+ posts = new org .springframework .data .domain .PageImpl <>(java .util .Collections .emptyList (), pageable , 0 );
207+ }
208+ PostPageDto response = new PostPageDto (posts );
209+ return ResponseEntity .ok (new ApiResponse <>(200 , "마감된 투표 게시글 페이징 조회 성공" , response ));
210+ }
186211}
0 commit comments