diff --git a/app/grad_2025/router.py b/app/grad_2025/router.py index 8add821..2004e7c 100644 --- a/app/grad_2025/router.py +++ b/app/grad_2025/router.py @@ -40,12 +40,12 @@ async def search_grad_2025_posts( str | None, Query(description="Base64 인코딩된 커서 (응답의 next_cursor 값)"), ] = None, - category: Category | None = Query(None), - univ_major: str | None = Query(None), + categories: list[Category] | None = Query(default=None), + univ_majors: list[str] | None = Query(default=None), ) -> Page[PostCompactRead]: decoded_cursor = Grad2025Cursor.decode(cursor) return await grad_2025_service.search_posts( cursor=decoded_cursor, - category=category, - univ_major=univ_major, + categories=categories, + univ_majors=univ_majors, ) diff --git a/app/grad_2025/service.py b/app/grad_2025/service.py index e715e42..6ec98cd 100644 --- a/app/grad_2025/service.py +++ b/app/grad_2025/service.py @@ -24,15 +24,15 @@ async def search_posts( *, cursor: Grad2025Cursor | None, limit: int = POST_CURSOR_LIMIT, - category: Category | None = None, - univ_major: str | None = None, + categories: list[Category] | None = None, + univ_majors: list[str] | None = None, ) -> Page[PostCompactRead]: cursor_id = cursor.id if cursor else None posts = await self.post_repository.find_grad_2025_posts( cursor=cursor_id, limit=limit, - category=category, - univ_major=univ_major, + categories=categories, + univ_majors=univ_majors, ) compact_posts = [PostCompactRead.from_post(post) for post in posts] next_cursor = ( diff --git a/app/posts/repository.py b/app/posts/repository.py index c2f09fa..b68aa9b 100644 --- a/app/posts/repository.py +++ b/app/posts/repository.py @@ -287,8 +287,8 @@ async def find_grad_2025_posts( *, cursor: int | None, limit: int, - category: Category | None = None, - univ_major: str | None = None, + categories: list[Category] | None = None, + univ_majors: list[str] | None = None, ) -> list[Post]: """post_grad_2025_table에 존재하는 Post만 조회합니다.""" stmt = ( @@ -315,13 +315,13 @@ async def find_grad_2025_posts( ) ) - if category is not None: - stmt = stmt.where(Post.category == category) + if categories is not None: + stmt = stmt.where(Post.category.in_(categories)) - if univ_major is not None: + if univ_majors is not None: stmt = stmt.join( Grad2025, post_grad_2025_table.c.grad_2025_id == Grad2025.id - ).where(Grad2025.name == univ_major) + ).where(Grad2025.name.in_(univ_majors)) result = await self.session.scalars(stmt) return list(result.unique().all())