Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

選択肢の更新削除用のapi #172

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mumumu6
Copy link
Collaborator

@mumumu6 mumumu6 commented Feb 9, 2025

更新なんですが、選択肢のidと選択肢をもつ質問のidをどちらも取得しています。
片方だけでも動きはするなと思いました。

アンケートの編集の際に必要だったので作成しました

Closes #68

return echo.NewHTTPError(http.StatusBadRequest, "Bad request")
}

var updatedOption model.Option
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#162 (comment) と同じ理由で、一旦既存のOptionを持ってきてほしいです。今はOption単体を取得する関数がないので、それを追加する必要もありそう 👀

Suggested change
var updatedOption model.Option
updatedOption, err := s.repo.GetOption(uint(optionID))
if err != nil {
if errors.Is(err, model.ErrNotFound) {
return echo.NewHTTPError(http.StatusNotFound, "Not found")
}
e.Logger().Errorf("failed to get option: %v", err)
return echo.NewHTTPError(http.StatusInternalServerError, "Internal server error")
}

@akimon658
Copy link
Member

更新なんですが、選択肢のidと選択肢をもつ質問のidをどちらも取得しています。
片方だけでも動きはするなと思いました。

これはRequest bodyにquestion_idが含まれていることについてですか?だとしたら、それは紐づける質問を変更できるようにするためです。
そんな機能使うか?というのはあるけど、question_idを含めておくとPOSTとPUTで同じ型を使い回せたりして、わざわざ消すメリットもないかなと思ったので含めてます

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

選択肢の編集・削除
2 participants