Skip to content

Commit

Permalink
Merge pull request #558 from GiganticMinecraft/feat/addAnswerIdToReal…
Browse files Browse the repository at this point in the history
…Answer

chore: answers struct に answer_id を追加
  • Loading branch information
rito528 authored Sep 25, 2024
2 parents dcd60c5 + c610dc6 commit 87ae049
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/domain/src/form/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ pub struct PostedAnswersUpdateSchema {

#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct Answer {
pub answer_id: AnswerId,
pub question_id: QuestionId,
pub answer: String,
}
Expand Down
3 changes: 3 additions & 0 deletions server/infra/resource/src/database/form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ impl FormDatabase for ConnectionPool {
.iter()
.map(|rs| {
Ok::<AnswerDto, DbErr>(AnswerDto {
answer_id: rs.try_get("", "answer_id")?,
question_id: rs.try_get("", "question_id")?,
answer: rs.try_get("", "answer")?,
})
Expand Down Expand Up @@ -697,6 +698,7 @@ impl FormDatabase for ConnectionPool {
})
.map(|rs| {
Ok::<AnswerDto, DbErr>(AnswerDto {
answer_id: rs.try_get("", "answer_id")?,
question_id: rs.try_get("", "question_id")?,
answer: rs.try_get("", "answer")?,
})
Expand Down Expand Up @@ -796,6 +798,7 @@ impl FormDatabase for ConnectionPool {
})
.map(|rs| {
Ok::<AnswerDto, DbErr>(AnswerDto {
answer_id: rs.try_get("", "answer_id")?,
question_id: rs.try_get("", "question_id")?,
answer: rs.try_get("", "answer")?,
})
Expand Down
3 changes: 3 additions & 0 deletions server/infra/resource/src/dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ impl TryFrom<SimpleFormDto> for domain::form::models::SimpleForm {
}

pub struct AnswerDto {
pub answer_id: i32,
pub question_id: i32,
pub answer: String,
}
Expand All @@ -145,11 +146,13 @@ impl TryFrom<AnswerDto> for domain::form::models::Answer {

fn try_from(
AnswerDto {
answer_id,
question_id,
answer,
}: AnswerDto,
) -> Result<Self, Self::Error> {
Ok(domain::form::models::Answer {
answer_id: answer_id.into(),
question_id: question_id.into(),
answer,
})
Expand Down

0 comments on commit 87ae049

Please sign in to comment.