2026-04-19 14:18:20 +08:00
|
|
|
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{
|
2026-04-20 09:52:48 +08:00
|
|
|
svc: app.NewPublishJobService(a.DB, a.RabbitMQ, a.Redis, a.Logger).WithCache(a.Cache),
|
2026-04-19 14:18:20 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
}
|