feat: DELETE /sponsorship_activities/{id} の実装#1066
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Deploying finansu with
|
| Latest commit: |
d551451
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://664bf3b6.finansu.pages.dev |
| Branch Preview URL: | https://feat-kubosaka-delete--sponso.finansu.pages.dev |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! このプルリクエストは、スポンサーシップ活動を削除するためのAPIエンドポイントを導入します。これにより、既存のユースケース層と連携し、ハンドラーからリポジトリまでの削除フローが完成します。主な目的は、システムからスポンサーシップ活動を削除する機能を提供することです。 Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
このプルリクエストは、DELETE /sponsorship_activities/{id} エンドポイントを実装するものです。sponsorship_activity_handler.go と sponsorship_activity_repository.go に変更が加えられています。
全体的に実装は適切ですが、ハンドラでのレスポンス形式の一貫性とエラーハンドリングについて改善の余地があります。エラー時と成功時で Content-Type が異なるため、エラーレスポンスもJSON形式で返すことを提案します。また、DELETEの成功レスポンスとして、REST APIのベストプラクティスに従い 204 No Content を返すこと、そしてエラー発生時にログを記録することを推奨します。
| err := h.sponsorshipActivityUseCase.DeleteSponsorshipActivity(c.Request().Context(), id) | ||
| if err != nil { | ||
| return c.String(http.StatusInternalServerError, "failed to delete sponsorship activity") | ||
| } | ||
| return c.JSON(http.StatusOK, "Deleted") |
There was a problem hiding this comment.
エラーレスポンスと成功レスポンスでContent-Typeが異なるため、一貫性を保つためにエラー時もJSONレスポンスを返すように修正するのが望ましいです。また、DELETE操作が成功した場合は、一般的にステータスコード 204 No Content を返し、レスポンスボディは空にすることが推奨されます。
これにより、APIのクライアントはレスポンス形式を一貫して扱うことができます。加えて、エラー発生時には、原因究明のためにエラー内容をログに出力することが重要です。
err := h.sponsorshipActivityUseCase.DeleteSponsorshipActivity(c.Request().Context(), id)
if err != nil {
c.Logger().Error(err)
return c.JSON(http.StatusInternalServerError, map[string]string{"message": "failed to delete sponsorship activity"})
}
return c.NoContent(http.StatusNoContent)
対応Issue
resolve #0
概要
DELETE /sponsorship_activities/{id}エンドポイントの実装。goqu.Dialect("mysql").Deleteを使った物理削除クエリの実装UseCase 層はすでに実装済みのため、Handler と Repository のみ変更。
画面スクリーンショット等
なし
テスト項目
DELETE /sponsorship_activities/{id}に存在するIDをリクエストして 200 が返ることGET /sponsorship_activitiesでそのIDが消えていること備考
存在しないIDへの DELETE は SQL レベルでエラーにならないため 200 を返す(0行削除)。