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の実装 #67

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Luftalian
Copy link
Contributor

PUT /words/me/
POST /words/me/all

postmanで確認済み

@Luftalian
Copy link
Contributor Author

#32
#33

Comment on lines +18 to +25
err := db.Select(&wordMe, "SELECT me_notification, word FROM words WHERE word = ? AND trap_id = ?", word, userId)
if errors.Is(err, sql.ErrNoRows) {
slog.Info("No Data Found")
return err
} else if err != nil {
slog.Info("Error: %s", err)
return err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

ここの存在確認、model.ExistWordを事前にhandler側の関数で呼び出してやるのがいいんじゃない?

Copy link
Contributor

Choose a reason for hiding this comment

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

そもそもdb.Selectを使うとsql.ErrNoRowsは返ってこないです

Comment on lines +26 to +29
if len(wordMe) != 1 {
slog.Info("Already exist too many data same trap_id and word: %d", len(wordMe))
return fmt.Errorf("Already exist too many data same trap_id and word: %d", len(wordMe))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

model.ExistWordを使えばこの考慮はいらないはず

Comment on lines +39 to +46
err := db.Select(&wordMes, "SELECT me_notification, word FROM words WHERE trap_id = ?", userId)
if errors.Is(err, sql.ErrNoRows) {
slog.Info("No Data Found")
return err
} else if err != nil {
slog.Info("Error: %s", err)
return err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

一括全件更新のときはこのチェックなしでupdateかけていい

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