-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
There was a problem hiding this 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()) |
There was a problem hiding this comment.
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, ...)).
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ボディーは空でHTTP204だけを返す
概要
チャンネルの実装を追加
変更点
Issue
Closes: #31