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

予約確定機能 #18

Closed
wants to merge 3 commits into from
Closed

予約確定機能 #18

wants to merge 3 commits into from

Conversation

TT-RR
Copy link
Contributor

@TT-RR TT-RR commented Sep 22, 2023

変更の概要

#12

なぜこの変更をするのか

参加者全員が回答したら代表者に通知を送るため

やったこと

entity/event.go

Event,EventRequest構造体の拡張

controller/event.go

CreateAnswer関数にSendMail関数へ行く処理の追加

usecase/event.go

CreateUserAnswer関数にユーザーの回答数を数えるFetchUserAnswerCount関数へ行く処理の追加

repository/event.go

FetchUserAnswerCount関数の追加

課題

ブランチが違うことによるcontroller/event.goの「SendMail関数がありません」エラー

entity/event.go Outdated
UnitSeconds int `json:"unitSeconds"`
Units []EventTimeUnit `json:"units"`
UserAnswers []UserEventAnswer `json:"userAnswers"`
UserAnswersCount int `json:"userAnswersCount"`
Copy link
Contributor

Choose a reason for hiding this comment

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

UserAnswersCountはEventのEntityとしては不要

@@ -120,6 +120,13 @@ func (ec *eventController) CreateAnswer(c echo.Context) error {
if err != nil {
return err
}

// すべての回答が集まったら,確定メールを送る
if event.UserAnswersCount == event.NumberOfParticipants {
Copy link
Contributor

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に!)

Copy link
Contributor Author

@TT-RR TT-RR Sep 22, 2023

Choose a reason for hiding this comment

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

DBに保存するにはどこをどういじればいいですか?

Copy link
Contributor

Choose a reason for hiding this comment

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

ざっくり言うと

  1. migrationファイル追加
  2. make generate
  3. Repository追加
    です!

Comment on lines +30 to +32
NotifyByEmail bool `json:"notifyByEmail"`
NumberOfParticipants int `json:"numberOfParticipants"`
ConfirmationEmail string `json:"confirmationEmail"`
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@TT-RR TT-RR closed this Sep 23, 2023
@TT-RR TT-RR deleted the feature/event_notify_reservation branch September 23, 2023 02:06
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