forked from ebhomengo/niki
49 lines
1.3 KiB
Go
49 lines
1.3 KiB
Go
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
|
|
// @Tags KindBoxReq
|
|
// @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
|
|
// @Router /admins/kindboxreqs/{id} [get].
|
|
func (h Handler) Get(c echo.Context) error {
|
|
var req param.GetKindBoxReqRequest
|
|
if err := c.Bind(&req); err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest)
|
|
}
|
|
|
|
if fieldErrors, err := h.adminKindBoxReqVld.ValidateGetRequest(req); err != nil {
|
|
msg, code := httpmsg.Error(err)
|
|
|
|
return c.JSON(code, httpmsg.ErrorResponse{
|
|
Message: msg,
|
|
Errors: fieldErrors,
|
|
})
|
|
}
|
|
|
|
resp, err := h.adminKindBoxReqSvc.Get(c.Request().Context(), req)
|
|
if err != nil {
|
|
msg, code := httpmsg.Error(err)
|
|
|
|
return echo.NewHTTPError(code, msg)
|
|
}
|
|
|
|
return c.JSON(http.StatusOK, resp)
|
|
}
|