package handlers import ( "kontor-api-echo/internal/models" "kontor-api-echo/internal/repository" "kontor-api-echo/internal/service" "net/http" "github.com/labstack/echo/v5" "github.com/uptrace/bun" ) type ProfileHandler struct { Service *service.ProfileService } func NewProfileHandler(db *bun.DB) *ProfileHandler { handler := &ProfileHandler{Service: service.NewProfileService(repository.NewProfileRepository(db))} return handler } func (handler *ProfileHandler) List(c *echo.Context) { profiles, err := handler.Service.List(c.Request().Context()) if err != nil { c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()}) return } dtos := models.ConvertProfilesToDtos(profiles) c.JSON(http.StatusOK, dtos) }