diff --git a/backend/feature/post/src/adapter/delivery.rs b/backend/feature/post/src/adapter/delivery.rs index 98332cd..02884a5 100644 --- a/backend/feature/post/src/adapter/delivery.rs +++ b/backend/feature/post/src/adapter/delivery.rs @@ -1,4 +1,5 @@ pub mod label_response_dto; pub mod post_controller; +pub mod post_info_query_dto; pub mod post_info_response_dto; pub mod post_response_dto; diff --git a/backend/feature/post/src/adapter/delivery/post_controller.rs b/backend/feature/post/src/adapter/delivery/post_controller.rs index b2567e2..861bfb8 100644 --- a/backend/feature/post/src/adapter/delivery/post_controller.rs +++ b/backend/feature/post/src/adapter/delivery/post_controller.rs @@ -14,7 +14,11 @@ use super::{post_info_response_dto::PostInfoResponseDto, post_response_dto::Post #[async_trait] pub trait PostController: Send + Sync { - async fn get_all_post_info(&self) -> Result, PostError>; + async fn get_all_post_info( + &self, + is_published_only: bool, + ) -> Result, PostError>; + async fn get_full_post(&self, id: i32) -> Result; } @@ -37,8 +41,11 @@ impl PostControllerImpl { #[async_trait] impl PostController for PostControllerImpl { - async fn get_all_post_info(&self) -> Result, PostError> { - let result = self.get_all_post_info_use_case.execute().await; + async fn get_all_post_info( + &self, + is_published_only: bool, + ) -> Result, PostError> { + let result = self.get_all_post_info_use_case.execute(is_published_only).await; result.map(|post_info_list| { let post_info_response_dto_list: Vec = post_info_list diff --git a/backend/feature/post/src/adapter/delivery/post_info_query_dto.rs b/backend/feature/post/src/adapter/delivery/post_info_query_dto.rs new file mode 100644 index 0000000..22e3676 --- /dev/null +++ b/backend/feature/post/src/adapter/delivery/post_info_query_dto.rs @@ -0,0 +1,6 @@ +use serde::Deserialize; + +#[derive(Deserialize)] +pub struct PostQueryDto { + pub is_published_only: Option, +} diff --git a/backend/feature/post/src/adapter/gateway/post_db_service.rs b/backend/feature/post/src/adapter/gateway/post_db_service.rs index a075dd0..43f5c22 100644 --- a/backend/feature/post/src/adapter/gateway/post_db_service.rs +++ b/backend/feature/post/src/adapter/gateway/post_db_service.rs @@ -7,6 +7,6 @@ use crate::{ #[async_trait] pub trait PostDbService: Send + Sync { - async fn get_all_post_info(&self) -> Result, PostError>; + async fn get_all_post_info(&self, is_published_only: bool) -> Result, PostError>; async fn get_full_post(&self, id: i32) -> Result; } diff --git a/backend/feature/post/src/adapter/gateway/post_repository_impl.rs b/backend/feature/post/src/adapter/gateway/post_repository_impl.rs index ca5403a..43a005e 100644 --- a/backend/feature/post/src/adapter/gateway/post_repository_impl.rs +++ b/backend/feature/post/src/adapter/gateway/post_repository_impl.rs @@ -21,8 +21,8 @@ impl PostRepositoryImpl { #[async_trait] impl PostRepository for PostRepositoryImpl { - async fn get_all_post_info(&self) -> Result, PostError> { - self.post_db_service.get_all_post_info().await + async fn get_all_post_info(&self, is_published_only: bool) -> Result, PostError> { + self.post_db_service.get_all_post_info(is_published_only).await } async fn get_full_post(&self, id: i32) -> Result { diff --git a/backend/feature/post/src/application/error/post_error.rs b/backend/feature/post/src/application/error/post_error.rs index e4e659f..bcd0086 100644 --- a/backend/feature/post/src/application/error/post_error.rs +++ b/backend/feature/post/src/application/error/post_error.rs @@ -1,4 +1,4 @@ -#[derive(Debug)] +#[derive(Debug, PartialEq)] pub enum PostError { DatabaseError(String), NotFound, diff --git a/backend/feature/post/src/application/gateway/post_repository.rs b/backend/feature/post/src/application/gateway/post_repository.rs index a3eac42..4e6c9e5 100644 --- a/backend/feature/post/src/application/gateway/post_repository.rs +++ b/backend/feature/post/src/application/gateway/post_repository.rs @@ -7,6 +7,6 @@ use crate::{ #[async_trait] pub trait PostRepository: Send + Sync { - async fn get_all_post_info(&self) -> Result, PostError>; + async fn get_all_post_info(&self, is_published_only: bool) -> Result, PostError>; async fn get_full_post(&self, id: i32) -> Result; } diff --git a/backend/feature/post/src/application/use_case/get_all_post_info_use_case.rs b/backend/feature/post/src/application/use_case/get_all_post_info_use_case.rs index 9cc7f24..f2895d5 100644 --- a/backend/feature/post/src/application/use_case/get_all_post_info_use_case.rs +++ b/backend/feature/post/src/application/use_case/get_all_post_info_use_case.rs @@ -9,7 +9,7 @@ use crate::{ #[async_trait] pub trait GetAllPostInfoUseCase: Send + Sync { - async fn execute(&self) -> Result, PostError>; + async fn execute(&self, is_published_only: bool) -> Result, PostError>; } pub struct GetAllPostInfoUseCaseImpl { @@ -24,7 +24,7 @@ impl GetAllPostInfoUseCaseImpl { #[async_trait] impl GetAllPostInfoUseCase for GetAllPostInfoUseCaseImpl { - async fn execute(&self) -> Result, PostError> { - self.post_repository.get_all_post_info().await + async fn execute(&self, is_published_only: bool) -> Result, PostError> { + self.post_repository.get_all_post_info(is_published_only).await } } diff --git a/backend/feature/post/src/domain/entity/post_info.rs b/backend/feature/post/src/domain/entity/post_info.rs index f24de11..ee5f7f9 100644 --- a/backend/feature/post/src/domain/entity/post_info.rs +++ b/backend/feature/post/src/domain/entity/post_info.rs @@ -10,4 +10,3 @@ pub struct PostInfo { pub labels: Vec