Skip to content

feat: DELETE /sponsorship_activities/{id} の実装#1066

Merged
Wakai111 merged 1 commit intodevelopfrom
feat/kubosaka/delete--sponsorship-activity
Mar 18, 2026
Merged

feat: DELETE /sponsorship_activities/{id} の実装#1066
Wakai111 merged 1 commit intodevelopfrom
feat/kubosaka/delete--sponsorship-activity

Conversation

@Kubosaka
Copy link
Copy Markdown
Collaborator

対応Issue

resolve #0

概要

DELETE /sponsorship_activities/{id} エンドポイントの実装。

  • Repository: goqu.Dialect("mysql").Delete を使った物理削除クエリの実装
  • Handler: UseCase 経由で削除を実行し、成功時に 200 を返す実装

UseCase 層はすでに実装済みのため、Handler と Repository のみ変更。

画面スクリーンショット等

なし

テスト項目

  • DELETE /sponsorship_activities/{id} に存在するIDをリクエストして 200 が返ること
  • 削除後に GET /sponsorship_activities でそのIDが消えていること

備考

存在しないIDへの DELETE は SQL レベルでエラーにならないため 200 を返す(0行削除)。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying finansu with  Cloudflare Pages  Cloudflare Pages

Latest commit: d551451
Status: ✅  Deploy successful!
Preview URL: https://664bf3b6.finansu.pages.dev
Branch Preview URL: https://feat-kubosaka-delete--sponso.finansu.pages.dev

View logs

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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

  • DELETEエンドポイントの実装: DELETE /sponsorship_activities/{id} エンドポイントが完全に実装されました。
  • ハンドラー層の更新: api/externals/handler/sponsorship_activity_handler.go 内の DeleteSponsorshipActivitiesId メソッドが、ユースケースを呼び出し、成功時にHTTP 200 OK、エラー時にHTTP 500 Internal Server Errorを返すように更新されました。
  • リポジトリ層の更新: api/externals/repository/sponsorship_activity_repository.go 内の Delete メソッドが、goqu.Dialect("mysql").Delete を使用して指定されたIDのスポンサーシップ活動を物理的に削除するSQLクエリを実行するように実装されました。
Changelog
  • api/externals/handler/sponsorship_activity_handler.go
    • DeleteSponsorshipActivitiesId メソッドが、モック応答から実際のユースケース呼び出しとエラーハンドリングを含む実装に更新されました。
  • api/externals/repository/sponsorship_activity_repository.go
    • Delete メソッドが、goqu ライブラリを使用してMySQLデータベースからスポンサーシップ活動を削除するロジックで実装されました。
Activity
  • このプルリクエストには、これまでの活動(コメント、レビューなど)は記録されていません。
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@Kubosaka Kubosaka requested a review from hikahana March 12, 2026 14:29
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

このプルリクエストは、DELETE /sponsorship_activities/{id} エンドポイントを実装するものです。sponsorship_activity_handler.gosponsorship_activity_repository.go に変更が加えられています。

全体的に実装は適切ですが、ハンドラでのレスポンス形式の一貫性とエラーハンドリングについて改善の余地があります。エラー時と成功時で Content-Type が異なるため、エラーレスポンスもJSON形式で返すことを提案します。また、DELETEの成功レスポンスとして、REST APIのベストプラクティスに従い 204 No Content を返すこと、そしてエラー発生時にログを記録することを推奨します。

Comment on lines +102 to +106
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")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

エラーレスポンスと成功レスポンスで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)

Base automatically changed from feat/kubosaka/update-sponsorship-activity-status to develop March 18, 2026 04:32
@Wakai111 Wakai111 merged commit fd61d3e into develop Mar 18, 2026
5 checks passed
@Wakai111 Wakai111 deleted the feat/kubosaka/delete--sponsorship-activity branch March 18, 2026 04:34
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