Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public Slice<PostDTO.ResponseEducationAll> findEducationPosts(Long userId, Part

if (user.hasRole(Role.ADMIN)) {

return postFindService.findByCategory(part, Category.Education, pageNumber, pageSize)
return postFindService.findByCategory(part, Category.Education, cardinalNumber, pageNumber, pageSize)
.map(post -> mapper.toEducationAll(post, checkFileExistsByPost(post.getId())));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,15 @@ OR LOWER(p.content) LIKE LOWER(CONCAT('%', :kw, '%'))
SELECT p
FROM Post p
WHERE p.category = :category
AND (:cardinal IS NULL OR p.cardinalNumber = :cardinal)
AND (
:partName = 'ALL'
OR FUNCTION('FIND_IN_SET', :partName, p.parts) > 0
OR FUNCTION('FIND_IN_SET', 'ALL', p.parts) > 0
)
)
ORDER BY p.id DESC
""")
Slice<Post> findByCategoryWithPart(@Param("partName") String partName, @Param("category") Category category, Pageable pageable);
Slice<Post> findByCategoryAndOptionalCardinalWithPart(@Param("partName") String partName, @Param("category") Category category, @Param("cardinal") Integer cardinal, Pageable pageable);

@Query("""
SELECT p
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ public Slice<Post> findEducationByCardinal(Part part, int cardinalNumber, Pageab
return postRepository.findByCategoryAndCardinalNumberWithPart(partName, Category.Education, cardinalNumber, pageable);
}

public Slice<Post> findByCategory(Part part, Category category, int pageNumber, int pageSize) {
public Slice<Post> findByCategory(Part part, Category category, Integer cardinal, int pageNumber, int pageSize) {
Pageable pageable = PageRequest.of(pageNumber, pageSize, Sort.by(Sort.Direction.DESC, "id"));
String partName = (part != null ? part.name() : Part.ALL.name());

return postRepository.findByCategoryWithPart(partName, category, pageable);
return postRepository.findByCategoryAndOptionalCardinalWithPart(partName, category, cardinal, pageable);
}
}