feat: implement battle replay controller, service, and routes with Swagger documentation
Build and Release / release (push) Successful in 3m2s

This commit is contained in:
2026-05-28 02:46:48 +07:00
parent 1d0733819d
commit 54b1522db5
7 changed files with 198 additions and 0 deletions
@@ -2,8 +2,10 @@ package controllers
import (
"context"
"history-api/internal/dtos/request"
"history-api/internal/dtos/response"
"history-api/internal/services"
"history-api/pkg/validator"
"time"
"github.com/gofiber/fiber/v3"
@@ -70,3 +72,40 @@ func (h *BattleReplayController) GetBattleReplaysByGeometryId(c fiber.Ctx) error
Data: res,
})
}
// GetBattleReplaysByGeometryIDs handles fetching battle replays by a list of geometry IDs.
// @Summary Get battle replays by geometry IDs
// @Description Get battle replays grouped by geometry IDs
// @Tags BattleReplays
// @Accept json
// @Produce json
// @Param query query request.GetBattleReplaysByGeometryIDsDto true "Query Parameters"
// @Success 200 {object} response.CommonResponse
// @Failure 400 {object} response.CommonResponse
// @Failure 500 {object} response.CommonResponse
// @Router /battle-replays/geometries [get]
func (h *BattleReplayController) GetBattleReplaysByGeometryIDs(c fiber.Ctx) error {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
dto := &request.GetBattleReplaysByGeometryIDsDto{}
if err := validator.ValidateQueryDto(c, dto); err != nil {
return c.Status(fiber.StatusBadRequest).JSON(response.CommonResponse{
Status: false,
Errors: err,
})
}
res, err := h.service.GetByGeometryIDs(ctx, dto)
if err != nil {
return c.Status(err.Code).JSON(response.CommonResponse{
Status: false,
Message: err.Message,
})
}
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
Status: true,
Data: res,
})
}