@@ -292,23 +292,23 @@ private List<Post> findAllPosts(PostSortScrollRequestDto reqBody) {
292292 return switch (reqBody .postSortStatus ()) {
293293 case POPULAR -> {
294294 if (reqBody .lastId () == null || reqBody .lastLikeCount () == null ) {
295- yield postRepository .findTop10ByOrderByLikeCountDescIdDesc ( );
295+ yield postRepository .findTop10ByStatusNotOrderByLikeCountDescIdDesc ( PostStatus . DELETED );
296296 } else {
297- yield postRepository .findTop10ByLikeCountLessThanOrLikeCountEqualsAndIdLessThanOrderByLikeCountDescIdDesc ( reqBody .lastLikeCount (), reqBody .lastLikeCount (), reqBody .lastId ());
297+ yield postRepository .findTop10ByStatusNotAndLikeCountLessThanOrLikeCountEqualsAndIdLessThanOrderByLikeCountDescIdDesc ( PostStatus . DELETED , reqBody .lastLikeCount (), reqBody .lastLikeCount (), reqBody .lastId ());
298298 }
299299 }
300300 case COMMENTS -> {
301301 if (reqBody .lastId () == null || reqBody .lastCommentCount () == null ) {
302- yield postRepository .findTop10ByOrderByCommentCountDescIdDesc ( );
302+ yield postRepository .findTop10ByStatusNotOrderByCommentCountDescIdDesc ( PostStatus . DELETED );
303303 } else {
304- yield postRepository .findTop10ByCommentCountLessThanOrCommentCountEqualsAndIdLessThanOrderByCommentCountDescIdDesc ( reqBody .lastCommentCount (), reqBody .lastCommentCount (), reqBody .lastId ());
304+ yield postRepository .findTop10ByStatusNotAndCommentCountLessThanOrCommentCountEqualsAndIdLessThanOrderByCommentCountDescIdDesc ( PostStatus . DELETED , reqBody .lastCommentCount (), reqBody .lastCommentCount (), reqBody .lastId ());
305305 }
306306 }
307307 case LATEST -> {
308308 if (reqBody .lastId () == null ) {
309- yield postRepository .findTop10ByOrderByIdDesc ( );
309+ yield postRepository .findTop10ByStatusNotOrderByIdDesc ( PostStatus . DELETED );
310310 } else {
311- yield postRepository .findTop10ByIdLessThanOrderByIdDesc ( reqBody .lastId ());
311+ yield postRepository .findTop10ByStatusNotAndIdLessThanOrderByIdDesc ( PostStatus . DELETED , reqBody .lastId ());
312312 }
313313 }
314314 default -> throw new IllegalArgumentException ("지원하지 않는 정렬 기준: " + reqBody .postSortStatus ());
@@ -320,29 +320,29 @@ private List<Post> findPostsByCategory(PostSortScrollRequestDto reqBody) {
320320 return switch (reqBody .postSortStatus ()) {
321321 case POPULAR -> {
322322 if (reqBody .lastId () == null || reqBody .lastLikeCount () == null ) {
323- yield postRepository .findTop10ByCategoryIdOrderByLikeCountDescIdDesc (
324- reqBody .categoryId ());
323+ yield postRepository .findTop10ByCategoryIdAndStatusNotOrderByLikeCountDescIdDesc (
324+ reqBody .categoryId (), PostStatus . DELETED );
325325 } else {
326- yield postRepository .findTop10ByCategoryIdAndLikeCountLessThanOrLikeCountEqualsAndIdLessThanOrderByLikeCountDescIdDesc (
327- reqBody .categoryId (), reqBody .lastLikeCount (), reqBody .lastLikeCount (),
326+ yield postRepository .findTop10ByCategoryIdAndStatusNotAndLikeCountLessThanOrLikeCountEqualsAndIdLessThanOrderByLikeCountDescIdDesc (
327+ reqBody .categoryId (), PostStatus . DELETED , reqBody .lastLikeCount (), reqBody .lastLikeCount (),
328328 reqBody .lastId ());
329329 }
330330 }
331331 case COMMENTS -> {
332332 if (reqBody .lastId () == null || reqBody .lastCommentCount () == null ) {
333- yield postRepository .findTop10ByCategoryIdOrderByCommentCountDescIdDesc (
334- reqBody .categoryId ());
333+ yield postRepository .findTop10ByCategoryIdAndStatusNotOrderByCommentCountDescIdDesc (
334+ reqBody .categoryId (), PostStatus . DELETED );
335335 } else {
336- yield postRepository .findTop10ByCategoryIdAndCommentCountLessThanOrCommentCountEqualsAndIdLessThanOrderByCommentCountDescIdDesc (
337- reqBody .categoryId (), reqBody .lastCommentCount (), reqBody .lastCommentCount (),
336+ yield postRepository .findTop10ByCategoryIdAndStatusNotAndCommentCountLessThanOrCommentCountEqualsAndIdLessThanOrderByCommentCountDescIdDesc (
337+ reqBody .categoryId (), PostStatus . DELETED , reqBody .lastCommentCount (), reqBody .lastCommentCount (),
338338 reqBody .lastId ());
339339 }
340340 }
341341 case LATEST -> {
342342 if (reqBody .lastId () == null ) {
343- yield postRepository .findTop10ByCategoryIdOrderByIdDesc (reqBody .categoryId ());
343+ yield postRepository .findTop10ByCategoryIdAndStatusNotOrderByIdDesc (reqBody .categoryId (), PostStatus . DELETED );
344344 } else {
345- yield postRepository .findTop10ByCategoryIdAndIdLessThanOrderByIdDesc (reqBody .categoryId (),
345+ yield postRepository .findTop10ByCategoryIdAndStatusNotAndIdLessThanOrderByIdDesc (reqBody .categoryId (), PostStatus . DELETED ,
346346 reqBody .lastId ());
347347 }
348348 }
0 commit comments