8000 feat(delete_channel):チャンネルの削除を実装 by kasatomorning · Pull Request #37 · comb19/chat_back · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(delete_channel):チャンネルの削除を実装 #37

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

Merged
merged 1 commit into from
May 20, 2025

Conversation

kasatomorning
Copy link
Contributor

概要

チャンネルの実装を追加

変更点

  • persistence、usecase、handlerの変更
  • DBのスキーマは変更なし

Issue

Closes: #31

@kasatomorning kasatomorning self-assigned this May 20, 2025
Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds endpoint and business logic to delete channels.

  • Exposed Delete in the usecase and repository interfaces
  • Implemented persistence deletion and HTTP handler
  • Wired DELETE /channels/:channelID route to the handler

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
api/usecase/channel.go Added Delete method to usecase
api/interface/handler/channel.go Implemented HandleDelete handler
api/infrastructure/persistence/channel.go Added Delete in persistence layer
api/domain/repository/channel_repository.go Added Delete to repository interface
api/cmd/app/app.go Wired DELETE route to HandleDelete
Comments suppressed due to low confidence (1)

api/usecase/channel.go:47

  • Consider adding unit tests for the Delete use case to cover success and failure scenarios, including repository errors.
func (cu channelUseCase) Delete(id string) error {


var uri types.ChannelURI
if err := ctx.BindUri(&uri); err != nil {
slog.ErrorContext(ctx, err.Error())
Copy link
Preview
Copilot AI May 20, 2025

Choose a reason for hiding this comment

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

When URI binding fails, the handler logs the error but does not set a response status, leaving the client hanging. Consider returning a 400 Bad Request (e.g., ctx.AbortWithStatusJSON(http.StatusBadRequest, ...)).

Suggested change
slog.ErrorContext(ctx, err.Error())
slog.ErrorContext(ctx, err.Error())
ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "Invalid URI parameters"})

Copilot uses AI. Check for mistakes.

@@ -35,6 +35,15 @@ func (cp *channelPersistence) Insert(name string, description string, private bo
return &channel, result.Error
}

func (cp *channelPersistence) Delete(id string) error {
var channel model.Channel
result := cp.db.Where("id = ?", id).Delete(&channel)
Copy link
Preview
Copilot AI May 20, 2025

Choose a reason for hiding this comment

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

This Delete call does not check RowsAffected, so deleting a non-existent channel returns no error. Consider checking result.RowsAffected and returning a not-found error if zero rows were deleted.

Copilot uses AI. Check for mistakes.

ctx.Status(http.StatusInternalServerError)
return
}
ctx.Status(http.StatusNoContent)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ボディーは空でHTTP204だけを返す

@kasatomorning kasatomorning merged commit 90dfd88 into develop May 20, 2025
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
0