2024-07-21 14:16:01 +00:00
|
|
|
package adminkindboxreqhandler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
|
|
|
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Get godoc
|
|
|
|
// @Summary Get a specific kind box req by ID
|
2024-08-27 17:49:34 +00:00
|
|
|
// @Tags Admins KindBoxReqs
|
2024-07-21 14:16:01 +00:00
|
|
|
// @Accept json
|
|
|
|
// @Produce json
|
|
|
|
// @Param id path int true "KindBoxReq ID"
|
|
|
|
// @Success 200 {object} param.GetKindBoxReqResponse
|
|
|
|
// @Failure 400 {string} "Bad Request"
|
|
|
|
// @Failure 401 {string} "invalid or expired jwt"
|
|
|
|
// @Failure 403 {string} "user not allowed"
|
|
|
|
// @Failure 422 {object} httpmsg.ErrorResponse
|
|
|
|
// @Failure 500 {string} "something went wrong"
|
|
|
|
// @Security AuthBearerAdmin
|
2024-07-24 23:45:04 +00:00
|
|
|
// @Router /admins/kindboxreqs/{id} [get].
|
2024-07-21 14:16:01 +00:00
|
|
|
func (h Handler) Get(c echo.Context) error {
|
|
|
|
var req param.GetKindBoxReqRequest
|
|
|
|
if err := c.Bind(&req); err != nil {
|
|
|
|
return echo.NewHTTPError(http.StatusBadRequest)
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := h.adminKindBoxReqSvc.Get(c.Request().Context(), req)
|
|
|
|
if err != nil {
|
|
|
|
msg, code := httpmsg.Error(err)
|
2024-08-01 10:20:18 +00:00
|
|
|
if resp.FieldErrors != nil {
|
|
|
|
return c.JSON(code, echo.Map{
|
|
|
|
"message": msg,
|
|
|
|
"errors": resp.FieldErrors,
|
|
|
|
})
|
|
|
|
}
|
2024-07-21 14:16:01 +00:00
|
|
|
|
|
|
|
return echo.NewHTTPError(code, msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.JSON(http.StatusOK, resp)
|
|
|
|
}
|