Skip to content

Commit

Permalink
refactor: フォームのドメインモデルの定義ファイルを分割
Browse files Browse the repository at this point in the history
  • Loading branch information
rito528 committed Dec 17, 2024
1 parent bec8b6b commit 4a7d046
Show file tree
Hide file tree
Showing 26 changed files with 725 additions and 625 deletions.
4 changes: 4 additions & 0 deletions server/domain/src/form.rs
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
pub mod answer;
pub mod comment;
pub mod message;
pub mod models;
pub mod question;
1 change: 1 addition & 0 deletions server/domain/src/form/answer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod models;
37 changes: 37 additions & 0 deletions server/domain/src/form/answer/models.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use chrono::{DateTime, Utc};
#[cfg(test)]
use proptest_derive::Arbitrary;
use serde::{Deserialize, Serialize};

use crate::{
form::{models::FormId, question::models::QuestionId},
user::models::User,
};

pub type AnswerId = types::IntegerId<FormAnswer>;

#[derive(Serialize, Deserialize, PartialEq, Debug)]
pub struct FormAnswer {
pub id: AnswerId,
pub user: User,
pub timestamp: DateTime<Utc>,
pub form_id: FormId,
pub title: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct FormAnswerContent {
pub answer_id: AnswerId,
pub question_id: QuestionId,
pub answer: String,
}

pub type AnswerLabelId = types::IntegerId<AnswerLabel>;

#[cfg_attr(test, derive(Arbitrary))]
#[derive(Serialize, Deserialize, Debug, PartialEq)]
pub struct AnswerLabel {
pub id: AnswerLabelId,
pub answer_id: AnswerId,
pub name: String,
}
1 change: 1 addition & 0 deletions server/domain/src/form/comment.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod models;
15 changes: 15 additions & 0 deletions server/domain/src/form/comment/models.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

use crate::{form::answer::models::AnswerId, user::models::User};

pub type CommentId = types::IntegerId<Comment>;

#[derive(Serialize, Deserialize, Debug, PartialEq)]
pub struct Comment {
pub answer_id: AnswerId,
pub comment_id: CommentId,
pub content: String,
pub timestamp: DateTime<Utc>,
pub commented_by: User,
}
1 change: 1 addition & 0 deletions server/domain/src/form/message.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod models;
Loading

0 comments on commit 4a7d046

Please sign in to comment.