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 BookshelfPublisherHandler struct { Service *service.BookshelfPublisherService } func NewBookshelfPublisherHandler(db *gorm.DB) *BookshelfPublisherHandler { handler := &BookshelfPublisherHandler{Service: service.NewBookshelfPublisherService(repository.NewBookshelfPublisherRepository(db))} return handler } func (handler *BookshelfPublisherHandler) List(c *gin.Context) { publishers, err := handler.Service.List(c.Request.Context()) if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } dtos := models.ConvertBookshelfPublishersToDtos(publishers) c.JSON(http.StatusOK, dtos) }