WIP: add missing handlers, services nd repositories
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"kontor-api-echo/internal/repository"
|
||||
"kontor-api-echo/internal/service"
|
||||
"net/http"
|
||||
|
||||
"github.com/labstack/echo/v5"
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
||||
type PermissionHandler struct {
|
||||
Service *service.PermissionService
|
||||
}
|
||||
|
||||
func NewPermissionHandler(db *bun.DB) *PermissionHandler {
|
||||
handler := &PermissionHandler{Service: service.NewPermissionService(repository.NewPermissionRepository(db))}
|
||||
return handler
|
||||
}
|
||||
|
||||
func (handler *PermissionHandler) List(c *echo.Context) {
|
||||
permissions, err := handler.Service.List(c.Request().Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, permissions)
|
||||
}
|
||||
Reference in New Issue
Block a user