-
Notifications
You must be signed in to change notification settings - Fork 0
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
予約確定機能 #18
予約確定機能 #18
Conversation
entity/event.go
Outdated
UnitSeconds int `json:"unitSeconds"` | ||
Units []EventTimeUnit `json:"units"` | ||
UserAnswers []UserEventAnswer `json:"userAnswers"` | ||
UserAnswersCount int `json:"userAnswersCount"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UserAnswersCount
はEventのEntityとしては不要
controller/event.go
Outdated
@@ -120,6 +120,13 @@ func (ec *eventController) CreateAnswer(c echo.Context) error { | |||
if err != nil { | |||
return err | |||
} | |||
|
|||
// すべての回答が集まったら,確定メールを送る | |||
if event.UserAnswersCount == event.NumberOfParticipants { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
現状DBに保存していないので,右辺が揮発してしまいます…
あとそもそも送信するかどうかをチェックしていないので,送信設定していないのに送信する事故が起こりそう
あとは,
あ,ちょっと嘘ついた
controllerでした設計的には,
usecaseのCreateUserAnswer
で,最後にcount処理をrepositoryに用意・取得してそれを呼び,そこから送るのが良いかな
と訂正したように,controllerはデータの変換処理に留めてロジックは書かないでほしいです…!(usecaseに!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DBに保存するにはどこをどういじればいいですか?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ざっくり言うと
- migrationファイル追加
make generate
- Repository追加
です!
NotifyByEmail bool `json:"notifyByEmail"` | ||
NumberOfParticipants int `json:"numberOfParticipants"` | ||
ConfirmationEmail string `json:"confirmationEmail"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
変更の概要
#12
なぜこの変更をするのか
参加者全員が回答したら代表者に通知を送るため
やったこと
entity/event.go
Event,EventRequest構造体の拡張
controller/event.go
CreateAnswer関数にSendMail関数へ行く処理の追加
usecase/event.go
CreateUserAnswer関数にユーザーの回答数を数えるFetchUserAnswerCount関数へ行く処理の追加
repository/event.go
FetchUserAnswerCount関数の追加
課題
ブランチが違うことによるcontroller/event.goの「SendMail関数がありません」エラー