diff --git a/src/main/java/econo/buddybridge/post/controller/PostController.java b/src/main/java/econo/buddybridge/post/controller/PostController.java index a7abf7e..0b4eaf0 100644 --- a/src/main/java/econo/buddybridge/post/controller/PostController.java +++ b/src/main/java/econo/buddybridge/post/controller/PostController.java @@ -64,7 +64,7 @@ public ApiResponse> getAllPosts( @RequestParam(defaultValue = "desc", required = false) String sort, @RequestParam(value = "post-status", required = false) PostStatus postStatus, @RequestParam(value = "disability-type", required = false) List disabilityType, - @RequestParam(value = "assistance-type", required = false) AssistanceType assistanceType, + @RequestParam(value = "assistance-type", required = false) List assistanceType, HttpServletRequest request ) { Long memberId = SessionUtils.getMemberId(request); diff --git a/src/main/java/econo/buddybridge/post/entity/AssistanceType.java b/src/main/java/econo/buddybridge/post/entity/AssistanceType.java index 38e289b..4fc3911 100644 --- a/src/main/java/econo/buddybridge/post/entity/AssistanceType.java +++ b/src/main/java/econo/buddybridge/post/entity/AssistanceType.java @@ -4,8 +4,9 @@ @Getter public enum AssistanceType { - 교육("교육"), - 생활("생활"); + 학습("학습"), + 식사("식사"), + 이동("이동"); private final String assistanceType; diff --git a/src/main/java/econo/buddybridge/post/repository/PostRepositoryCustom.java b/src/main/java/econo/buddybridge/post/repository/PostRepositoryCustom.java index abd1641..bbeac0f 100644 --- a/src/main/java/econo/buddybridge/post/repository/PostRepositoryCustom.java +++ b/src/main/java/econo/buddybridge/post/repository/PostRepositoryCustom.java @@ -13,7 +13,7 @@ public interface PostRepositoryCustom { PostResDto findByMemberIdAndPostId(Long memberId, Long postId); PostCustomPage findPosts(Long memberId, Integer page, Integer size, String sort, PostType postType, - PostStatus postStatus, List disabilityType, AssistanceType assistanceType); + PostStatus postStatus, List disabilityType, List assistanceType); PostCustomPage findPostsMyPage(Long memberId, Integer page, Integer size, String sort, PostType postType); } diff --git a/src/main/java/econo/buddybridge/post/repository/PostRepositoryImpl.java b/src/main/java/econo/buddybridge/post/repository/PostRepositoryImpl.java index b66523a..f7c1dac 100644 --- a/src/main/java/econo/buddybridge/post/repository/PostRepositoryImpl.java +++ b/src/main/java/econo/buddybridge/post/repository/PostRepositoryImpl.java @@ -50,12 +50,12 @@ public PostResDto findByMemberIdAndPostId(Long memberId, Long postId) { @Override public PostCustomPage findPosts(Long memberId, Integer page, Integer size, String sort, PostType postType, - PostStatus postStatus, List disabilityType, AssistanceType assistanceType) { + PostStatus postStatus, List disabilityType, List assistanceType) { List posts = queryFactory .selectFrom(post) .where(buildPostStatusExpression(postStatus), buildPostTypeExpression(postType), - buildPostDisabilityTypesExpression(disabilityType), buildPostAssistanceTypeExpression(assistanceType)) + buildPostDisabilityTypesExpression(disabilityType), buildPostAssistanceTypesExpression(assistanceType)) .offset((long) page * size) .limit(size) .orderBy(buildOrderSpecifier(sort)) @@ -67,7 +67,7 @@ public PostCustomPage findPosts(Long memberId, Integer page, Integer size, Strin .select(post.count()) .from(post) .where(buildPostStatusExpression(postStatus), buildPostTypeExpression(postType), - buildPostDisabilityTypesExpression(disabilityType), buildPostAssistanceTypeExpression(assistanceType)) + buildPostDisabilityTypesExpression(disabilityType), buildPostAssistanceTypesExpression(assistanceType)) .fetchOne(); return new PostCustomPage(content, totalElements, content.size() < size); @@ -142,9 +142,12 @@ private BooleanExpression buildPostDistrictExpression(District district) { return district == null ? null : post.district.eq(district); } - // 교육, 생활 - private BooleanExpression buildPostAssistanceTypeExpression(AssistanceType assistanceType) { - return assistanceType == null ? null : post.assistanceType.eq(assistanceType); + // 학습, 식사, 이동 + private BooleanExpression buildPostAssistanceTypesExpression(List assistanceTypes) { + if (assistanceTypes == null || assistanceTypes.isEmpty()) { + return null; + } + return post.assistanceType.in(assistanceTypes); } private OrderSpecifier buildOrderSpecifier(String sort) { diff --git a/src/main/java/econo/buddybridge/post/service/PostService.java b/src/main/java/econo/buddybridge/post/service/PostService.java index 510f888..a01fc96 100644 --- a/src/main/java/econo/buddybridge/post/service/PostService.java +++ b/src/main/java/econo/buddybridge/post/service/PostService.java @@ -48,7 +48,7 @@ public PostCustomPage getPostsMyPage(Long memberId, Integer page, Integer size, @Transactional(readOnly = true) // 전체 게시글 조회 public PostCustomPage getPosts(Long memberId, Integer page, Integer size, String sort, PostType postType, PostStatus postStatus, - List disabilityType, AssistanceType assistanceType) { + List disabilityType, List assistanceType) { return postRepository.findPosts(memberId, page - 1, size, sort, postType, postStatus, disabilityType, assistanceType); }