2026-04-03 00:39:15 +08:00
|
|
|
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 {
|
2026-04-20 13:52:35 +08:00
|
|
|
svc *app.MediaService
|
2026-04-03 00:39:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewMediaHandler(a *bootstrap.App) *MediaHandler {
|
2026-04-03 17:48:30 +08:00
|
|
|
return &MediaHandler{
|
2026-04-20 13:52:35 +08:00
|
|
|
svc: app.NewMediaService(a.DB),
|
2026-04-03 17:48:30 +08:00
|
|
|
}
|
2026-04-03 00:39:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
}
|