55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/saveinmed/backend-go/internal/domain"
|
|
)
|
|
|
|
// ListAllReviews godoc
|
|
// @Summary Lista todas as avaliações (Admin)
|
|
// @Tags Admin
|
|
// @Security BearerAuth
|
|
// @Produce json
|
|
// @Param page query int false "Página"
|
|
// @Param page_size query int false "Tamanho da página"
|
|
// @Success 200 {object} domain.ReviewPage
|
|
// @Failure 401 {object} map[string]string
|
|
// @Failure 500 {object} map[string]string
|
|
// @Router /api/v1/admin/reviews [get]
|
|
// @Router /api/v1/reviews [get]
|
|
func (h *Handler) ListAllReviews(w http.ResponseWriter, r *http.Request) {
|
|
page, pageSize := parsePagination(r)
|
|
|
|
result, err := h.svc.ListReviews(r.Context(), domain.ReviewFilter{}, page, pageSize)
|
|
if err != nil {
|
|
writeError(w, http.StatusInternalServerError, err)
|
|
return
|
|
}
|
|
|
|
writeJSON(w, http.StatusOK, result)
|
|
}
|
|
|
|
// ListAllShipments godoc
|
|
// @Summary Lista todos os envios (Admin)
|
|
// @Tags Admin
|
|
// @Security BearerAuth
|
|
// @Produce json
|
|
// @Param page query int false "Página"
|
|
// @Param page_size query int false "Tamanho da página"
|
|
// @Success 200 {object} domain.ShipmentPage
|
|
// @Failure 401 {object} map[string]string
|
|
// @Failure 500 {object} map[string]string
|
|
// @Router /api/v1/admin/shipments [get]
|
|
// @Router /api/v1/shipments [get]
|
|
func (h *Handler) ListAllShipments(w http.ResponseWriter, r *http.Request) {
|
|
page, pageSize := parsePagination(r)
|
|
|
|
result, err := h.svc.ListShipments(r.Context(), domain.ShipmentFilter{}, page, pageSize)
|
|
if err != nil {
|
|
writeError(w, http.StatusInternalServerError, err)
|
|
return
|
|
}
|
|
|
|
writeJSON(w, http.StatusOK, result)
|
|
}
|