43 lines
1003 B
Go
43 lines
1003 B
Go
|
|
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 DesktopContentHandler struct {
|
||
|
|
svc *app.DesktopContentService
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewDesktopContentHandler(a *bootstrap.App) *DesktopContentHandler {
|
||
|
|
return &DesktopContentHandler{
|
||
|
|
svc: app.NewDesktopContentService(
|
||
|
|
a.DB,
|
||
|
|
a.AuditLogs,
|
||
|
|
a.ObjectStorage,
|
||
|
|
a.Cache,
|
||
|
|
),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (h *DesktopContentHandler) Article(c *gin.Context) {
|
||
|
|
articleID, err := strconv.ParseInt(c.Param("id"), 10, 64)
|
||
|
|
if err != nil || articleID <= 0 {
|
||
|
|
response.Error(c, response.ErrBadRequest(40095, "invalid_article_id", "article id must be a positive integer"))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
data, svcErr := h.svc.Article(c.Request.Context(), MustDesktopClient(c.Request.Context()), articleID)
|
||
|
|
if svcErr != nil {
|
||
|
|
response.Error(c, svcErr)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
response.Success(c, data)
|
||
|
|
}
|