WIP: Export Kontor DB
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s

This commit is contained in:
Thomas Peetz
2026-09-30 18:55:59 +02:00
parent 914e1214de
commit f5abb44466
52 changed files with 1458 additions and 146 deletions
+40
View File
@@ -0,0 +1,40 @@
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 RoosterHandler struct {
Service *service.RoosterService
}
func (handler *RoosterHandler) List(c *gin.Context) {
roosters, err := handler.Service.List(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
dtos := models.ConvertRoostersToDtos(roosters)
c.JSON(http.StatusOK, dtos)
}
func (handler *RoosterHandler) Get(c *gin.Context) {
id := c.Param("id")
rooster, err := handler.Service.Get(c.Request.Context(), id)
if err != nil {
c.JSON(http.StatusNotFound, gin.H{"error": "rooster not found"})
return
}
c.JSON(http.StatusOK, rooster)
}
func NewRoosterHandler(db *gorm.DB) *RoosterHandler {
handler := &RoosterHandler{Service: service.NewRoosterService(repository.NewRoosterRepository(db))}
return handler
}