Files
kontor/kontor-gin/internal/handlers/artist.go
T
Thomas Peetz f5abb44466
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
WIP: Export Kontor DB
2026-09-30 18:55:59 +02:00

31 lines
714 B
Go

package handlers
import (
"kontor-api-gin/internal/models"
"kontor-api-gin/internal/repository"
"kontor-api-gin/internal/service"
"net/http"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
type ArtistHandler struct {
Service *service.ArtistService
}
func NewArtistHandler(db *gorm.DB) *ArtistHandler {
handler := &ArtistHandler{Service: service.NewArtistService(repository.NewArtistRepository(db))}
return handler
}
func (handler *ArtistHandler) List(c *gin.Context) {
artists, err := handler.Service.List(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
dtos := models.ConvertArtistsToDtos(artists)
c.JSON(http.StatusOK, dtos)
}