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

36 lines
969 B
Go
Raw Normal View History

package transport
import (
"github.com/gin-gonic/gin"
"github.com/geo-platform/tenant-api/internal/bootstrap"
"github.com/geo-platform/tenant-api/internal/shared/auth"
"github.com/geo-platform/tenant-api/internal/shared/response"
"github.com/geo-platform/tenant-api/internal/tenant/app"
)
type PublishJobHandler struct {
svc *app.PublishJobService
}
func NewPublishJobHandler(a *bootstrap.App) *PublishJobHandler {
return &PublishJobHandler{
svc: app.NewPublishJobService(a.DB, a.RabbitMQ, a.Redis, a.Logger).WithCache(a.Cache),
}
}
func (h *PublishJobHandler) Create(c *gin.Context) {
var req app.CreatePublishJobRequest
if err := c.ShouldBindJSON(&req); err != nil {
response.Error(c, response.ErrBadRequest(40001, "invalid_params", err.Error()))
return
}
data, err := h.svc.Create(c.Request.Context(), auth.MustActor(c.Request.Context()), req)
if err != nil {
response.Error(c, err)
return
}
response.SuccessWithStatus(c, 201, data)
}