get single merch

This commit is contained in:
nquidox 2026-03-16 21:09:01 +03:00
parent ec4fe5151e
commit 7922c00238
4 changed files with 117 additions and 7 deletions

View file

@ -4,6 +4,7 @@ import (
"errors"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
log "github.com/sirupsen/logrus"
"merch-api/pkg/responses"
"merch-api/pkg/utils"
"net/http"
@ -87,7 +88,37 @@ func (co *controller) create(c *gin.Context) {
c.Status(http.StatusCreated)
}
func (co *controller) getOne(c *gin.Context) {}
// getOne godoc
//
// @Summary Получить всю информацию про мерч
// @Description Получить всю информацию про мерч по его uuid
// @Tags Merch
// @Security BearerAuth
// @Produce json
// @Param uuid path string true "merch_uuid"
// @Success 200 {object} singleMerchResponse
//
// @Failure 400 {object} responses.BadRequest
// @Failure 401 {object} responses.Unauthorized
// @Failure 500 {object} responses.InternalServerError
//
// @Router /merch/{uuid} [get]
func (co *controller) getOne(c *gin.Context) {
merchUuid := c.Param("uuid")
if merchUuid == "" {
c.JSON(http.StatusBadRequest, responses.BadRequest{Error: "MerchUuid is empty"})
return
}
response, err := co.service.getSingleMerch(c, getUserId(c), merchUuid)
if err != nil {
c.JSON(http.StatusBadRequest, responses.InternalServerError{Error: err.Error()})
log.WithError(err).Error("Merch | Failed to get single merch")
return
}
c.JSON(http.StatusOK, response)
}
// getMany godoc
//
@ -95,7 +126,7 @@ func (co *controller) getOne(c *gin.Context) {}
// @Description Get all merch without origins
// @Tags Merch
// @Produce json
// @Success 200 {array} ListResponse
// @Success 200 {array} listResponse
// @Success 204
// @Failure 400 {object} responses.BadRequest
// @Failure 401 {object} responses.Unauthorized