Files
kontor/kontor-echo/internal/handlers/mailaccount.go
T
Thomas Peetz debdf3d0b0
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 6s
Gitea Actions Demo / build-and-test (push) Failing after 11s
kontor-echo: setup project to show homepage
2026-11-09 17:02:59 +01:00

31 lines
796 B
Go

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 MailAccountHandler struct {
Service *service.MailAccountService
}
func NewMailAccountHandler(db *bun.DB) *MailAccountHandler {
handler := &MailAccountHandler{Service: service.NewMailAccountService(repository.NewMailAccountRepository(db))}
return handler
}
func (handler *MailAccountHandler) List(c *echo.Context) {
mailaccounts, err := handler.Service.List(c.Request().Context())
if err != nil {
c.JSON(http.StatusInternalServerError, map[string]any{"error": err.Error()})
return
}
dtos := models.ConvertMailAccountsToDtos(mailaccounts)
c.JSON(http.StatusOK, dtos)
}