package handlers import ( "git.godopu.com/lab/landing_page/backend/internal/httpx" "git.godopu.com/lab/landing_page/backend/internal/repository" "github.com/gin-gonic/gin" ) type PublicationsHandler struct { repo *repository.PublicationsRepository } func NewPublicationsHandler(repo *repository.PublicationsRepository) *PublicationsHandler { return &PublicationsHandler{repo: repo} } func (h *PublicationsHandler) GetPublications(c *gin.Context) { category := c.Query("category") if category != "" && category != "intl-journal-conf" && category != "domestic-journal-conf" { httpx.BadRequest(c, "Invalid category parameter: must be 'intl-journal-conf' or 'domestic-journal-conf'") return } pubs, err := h.repo.GetPublications(c.Request.Context(), category) if err != nil { httpx.InternalServerError(c, "Failed to retrieve publications: "+err.Error()) return } httpx.OK(c, pubs) } func (h *PublicationsHandler) GetHighlights(c *gin.Context) { highlights, err := h.repo.GetHighlights(c.Request.Context()) if err != nil { httpx.InternalServerError(c, "Failed to retrieve highlights: "+err.Error()) return } httpx.OK(c, highlights) } func (h *PublicationsHandler) GetPatents(c *gin.Context) { patents, err := h.repo.GetPatents(c.Request.Context()) if err != nil { httpx.InternalServerError(c, "Failed to retrieve patents: "+err.Error()) return } httpx.OK(c, patents) }