Skip to content

Commit

Permalink
fix: meilisearch から serialize する用の struct を定義
Browse files Browse the repository at this point in the history
  • Loading branch information
rito528 committed Sep 25, 2024
1 parent fad8b55 commit 4d78443
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
3 changes: 2 additions & 1 deletion server/domain/src/repository/search_repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use errors::Error;
use mockall::automock;

use crate::{
form::models::{Answer, Comment, Form, Label},
form::models::{Answer, Form, Label},
search::models::Comment,
user::models::User,
};

Expand Down
11 changes: 10 additions & 1 deletion server/domain/src/search/models.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
use serde::{Deserialize, Serialize};
use uuid::Uuid;

use crate::{
form::models::{Answer, Comment, Form, Label},
form::models::{Answer, AnswerId, CommentId, Form, Label},
user::models::User,
};

#[derive(Serialize, Deserialize, Debug, PartialEq)]
pub struct Comment {
pub answer_id: AnswerId,
pub id: CommentId,
pub content: String,
pub commented_by: Uuid,
}

#[derive(Serialize, Debug, PartialEq)]
pub struct CrossSearchResult {
pub forms: Vec<Form>,
Expand Down
5 changes: 4 additions & 1 deletion server/infra/resource/src/database/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,8 @@ pub trait SearchDatabase: Send + Sync {
async fn search_labels_for_forms(&self, query: &str) -> Result<Vec<Label>, InfraError>;
async fn search_labels_for_answers(&self, query: &str) -> Result<Vec<Label>, InfraError>;
async fn search_answers(&self, query: &str) -> Result<Vec<Answer>, InfraError>;
async fn search_comments(&self, query: &str) -> Result<Vec<Comment>, InfraError>;
async fn search_comments(
&self,
query: &str,
) -> Result<Vec<domain::search::models::Comment>, InfraError>;
}
3 changes: 2 additions & 1 deletion server/infra/resource/src/database/search.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use async_trait::async_trait;
use domain::{
form::models::{Answer, Comment, Form, Label},
form::models::{Answer, Form, Label},
search::models::Comment,
user::models::User,
};
use errors::infra::InfraError;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use async_trait::async_trait;
use domain::{
form::models::{Answer, Comment, Form, Label},
form::models::{Answer, Form, Label},
repository::search_repository::SearchRepository,
search::models::Comment,
user::models::User,
};
use errors::Error;
Expand Down

0 comments on commit 4d78443

Please sign in to comment.