From db0369225ea2083a2b1c97e1b50ff91c3fcf3bf3 Mon Sep 17 00:00:00 2001 From: Kharec Date: Sun, 23 Nov 2025 14:26:45 +0100 Subject: [PATCH] refactor: update references to VoteRequest --- internal/handlers/common_test.go | 2 +- internal/handlers/vote_handler.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/handlers/common_test.go b/internal/handlers/common_test.go index db1e5e0..08dae91 100644 --- a/internal/handlers/common_test.go +++ b/internal/handlers/common_test.go @@ -788,7 +788,7 @@ func createUpdatePostRequest(body string) *http.Request { } func createVoteRequest(body string) *http.Request { - return createRequestWithDTO[dto.VoteRequest](http.MethodPost, "/api/posts/1/vote", []byte(body)) + return createRequestWithDTO[dto.CastVoteRequest](http.MethodPost, "/api/posts/1/vote", []byte(body)) } func TestParsePagination(t *testing.T) { diff --git a/internal/handlers/vote_handler.go b/internal/handlers/vote_handler.go index 2e75d74..1971e43 100644 --- a/internal/handlers/vote_handler.go +++ b/internal/handlers/vote_handler.go @@ -58,7 +58,7 @@ type VoteResponse = CommonResponse // @Produce json // @Security BearerAuth // @Param id path int true "Post ID" -// @Param request body dto.VoteRequest true "Vote data (type: 'up', 'down', or 'none' to remove)" +// @Param request body dto.CastVoteRequest true "Vote data (type: 'up', 'down', or 'none' to remove)" // @Success 200 {object} VoteResponse "Vote cast successfully with updated post statistics" // @Failure 401 {object} VoteResponse "Authentication required" // @Failure 400 {object} VoteResponse "Invalid request data or vote type" @@ -78,7 +78,7 @@ func (h *VoteHandler) CastVote(w http.ResponseWriter, r *http.Request) { return } - req, ok := GetValidatedDTO[dto.VoteRequest](r) + req, ok := GetValidatedDTO[dto.CastVoteRequest](r) if !ok { SendErrorResponse(w, "Invalid request", http.StatusBadRequest) return @@ -283,7 +283,7 @@ func (h *VoteHandler) MountRoutes(r chi.Router, config RouteModuleConfig) { protected = config.GeneralRateLimit(protected) } - protected.Post("/posts/{id}/vote", WithValidation[dto.VoteRequest](config.ValidationMiddleware, h.CastVote)) + protected.Post("/posts/{id}/vote", WithValidation[dto.CastVoteRequest](config.ValidationMiddleware, h.CastVote)) protected.Delete("/posts/{id}/vote", h.RemoveVote) protected.Get("/posts/{id}/vote", h.GetUserVote) protected.Get("/posts/{id}/votes", h.GetPostVotes)