Files
geo/server/internal/tenant/transport/media_handler.go
T

45 lines
1020 B
Go
Raw Normal View History

package transport
import (
"strconv"
"github.com/gin-gonic/gin"
"github.com/geo-platform/tenant-api/internal/bootstrap"
"github.com/geo-platform/tenant-api/internal/shared/response"
"github.com/geo-platform/tenant-api/internal/tenant/app"
)
type MediaHandler struct {
svc *app.MediaService
}
func NewMediaHandler(a *bootstrap.App) *MediaHandler {
return &MediaHandler{
svc: app.NewMediaService(a.DB),
}
}
func (h *MediaHandler) ListPlatforms(c *gin.Context) {
data, err := h.svc.ListPlatforms(c.Request.Context())
if err != nil {
response.Error(c, err)
return
}
response.Success(c, data)
}
func (h *MediaHandler) ListPublishRecords(c *gin.Context) {
articleID, err := strconv.ParseInt(c.Param("id"), 10, 64)
if err != nil {
response.Error(c, response.ErrBadRequest(40001, "invalid_id", "article id must be a number"))
return
}
data, err := h.svc.ListArticlePublishRecords(c.Request.Context(), articleID)
if err != nil {
response.Error(c, err)
return
}
response.Success(c, data)
}