forked from ebhomengo/niki
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package adminrefertimehandler
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
refertimeparam "git.gocasts.ir/ebhomengo/niki/param/admin/refer_time"
|
|
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
|
queryparam "git.gocasts.ir/ebhomengo/niki/pkg/query_param"
|
|
echo "github.com/labstack/echo/v4"
|
|
)
|
|
|
|
// GetAll godoc
|
|
// @Summary Get all refer times
|
|
// @Tags Admins ReferTimes
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param filter_status query entity.ReferTimeStatus false "Filter by KindBoxReq status" Format(enum)
|
|
// @Success 200 {object} adminrefertimeparam.GetAllReferTimeResponse
|
|
// @Failure 400 {string} "Bad request"
|
|
// @Security AuthBearerAdmin
|
|
// @Router /admins/refer-times [get].
|
|
func (h Handler) GetAll(c echo.Context) error {
|
|
var req refertimeparam.GetAllReferTimeRequest
|
|
|
|
if err := c.Bind(&req); err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest)
|
|
}
|
|
|
|
req.Filter = queryparam.GetFilterParams(c)
|
|
|
|
resp, err := h.adminReferTimeSvc.GetAll(c.Request().Context(), req)
|
|
if err != nil {
|
|
msg, code := httpmsg.Error(err)
|
|
if resp.FieldErrors != nil {
|
|
return c.JSON(code, httpmsg.ErrorResponse{
|
|
Message: msg,
|
|
Errors: resp.FieldErrors,
|
|
})
|
|
}
|
|
|
|
return echo.NewHTTPError(code, msg)
|
|
}
|
|
|
|
return c.JSON(http.StatusOK, resp)
|
|
}
|