forked from ebhomengo/niki
36 lines
935 B
Go
36 lines
935 B
Go
|
package benefactoraddresshandler
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
|
||
|
param "git.gocasts.ir/ebhomengo/niki/param/benefactor/address"
|
||
|
"git.gocasts.ir/ebhomengo/niki/pkg/claim"
|
||
|
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
||
|
"github.com/labstack/echo/v4"
|
||
|
)
|
||
|
|
||
|
// GetAddresses godoc
|
||
|
// @Summary Get all benefactor addresses
|
||
|
// @Tags Address
|
||
|
// @Accept json
|
||
|
// @Produce json
|
||
|
// @Success 200 {object} param.GetAllAddressesResponse
|
||
|
// @Failure 400 {string} "Bad request"
|
||
|
// @Security AuthBearerBenefactor
|
||
|
// @Router /address/ [get]
|
||
|
func (h Handler) GetAddresses(c echo.Context) error {
|
||
|
var req param.GetAllAddressesRequest
|
||
|
|
||
|
claims := claim.GetClaimsFromEchoContext(c)
|
||
|
req.BenefactorID = claims.UserID
|
||
|
|
||
|
resp, sErr := h.addressSvc.GetAll(c.Request().Context(), req)
|
||
|
if sErr != nil {
|
||
|
msg, code := httpmsg.Error(sErr)
|
||
|
|
||
|
return echo.NewHTTPError(code, msg)
|
||
|
}
|
||
|
|
||
|
return c.JSON(http.StatusOK, resp)
|
||
|
}
|