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
+30
View File
@@ -0,0 +1,30 @@
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 ArtistHandler struct {
Service *service.ArtistService
}
func NewArtistHandler(db *gorm.DB) *ArtistHandler {
handler := &ArtistHandler{Service: service.NewArtistService(repository.NewArtistRepository(db))}
return handler
}
func (handler *ArtistHandler) List(c *gin.Context) {
artists, err := handler.Service.List(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
dtos := models.ConvertArtistsToDtos(artists)
c.JSON(http.StatusOK, dtos)
}
+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 CardHandler struct {
Service *service.CardService
}
func (handler *CardHandler) List(c *gin.Context) {
cards, err := handler.Service.List(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
dtos := models.ConvertCardsToDtos(cards)
c.JSON(http.StatusOK, dtos)
}
func (handler *CardHandler) Get(c *gin.Context) {
id := c.Param("id")
card, err := handler.Service.Get(c.Request.Context(), id)
if err != nil {
c.JSON(http.StatusNotFound, gin.H{"error": "card not found"})
return
}
c.JSON(http.StatusOK, card)
}
func NewCardHandler(db *gorm.DB) *CardHandler {
handler := &CardHandler{Service: service.NewCardService(repository.NewCardRepository(db))}
return handler
}
+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 CardSetHandler struct {
Service *service.CardSetService
}
func (handler *CardSetHandler) List(c *gin.Context) {
cardsets, err := handler.Service.List(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
dtos := models.ConvertCardSetsToDtos(cardsets)
c.JSON(http.StatusOK, dtos)
}
func (handler *CardSetHandler) Get(c *gin.Context) {
id := c.Param("id")
cardset, err := handler.Service.Get(c.Request.Context(), id)
if err != nil {
c.JSON(http.StatusNotFound, gin.H{"error": "cardset not found"})
return
}
c.JSON(http.StatusOK, cardset)
}
func NewCardSetHandler(db *gorm.DB) *CardSetHandler {
handler := &CardSetHandler{Service: service.NewCardSetService(repository.NewCardSetRepository(db))}
return handler
}
+21 -9
View File
@@ -15,19 +15,26 @@ import (
type ComicsHandler struct {
ComicHandler *ComicHandler
PublisherHandler *PublisherHandler
// ArtistHandler *ArtistHandler
// IssueHandler *IssueHandler
// WorktypeHandler *WorktypeHandler
// VolumeHandler *VolumeHandler
// StoryarcHandler *StoryarcHandler
// ComicworkHandler *ComicworkHandler
// IssueworkHandler *IssueworkHandler
ArtistHandler *ArtistHandler
IssueHandler *IssueHandler
WorkTypeHandler *WorkTypeHandler
VolumeHandler *VolumeHandler
StoryArcHandler *StoryArcHandler
ComicworkHandler *ComicworkHandler
IssueworkHandler *IssueworkHandler
}
func NewComicsHandler(db *gorm.DB) *ComicsHandler {
comicsHandler := &ComicsHandler{
ComicHandler: &ComicHandler{Service: service.NewComicService(repository.NewComicRepository(db))},
PublisherHandler: &PublisherHandler{Service: service.NewPublisherService(repository.NewPublisherRepository(db))},
ComicHandler: NewComicHandler(db),
PublisherHandler: NewPublisherHandler(db),
ArtistHandler: NewArtistHandler(db),
IssueHandler: NewIssueHandler(db),
WorkTypeHandler: NewWorkTypeHandler(db),
VolumeHandler: NewVolumeHandler(db),
StoryArcHandler: NewStoryArcHandler(db),
ComicworkHandler: NewComicworkHandler(db),
IssueworkHandler: NewIssueworkHandler(db),
}
return comicsHandler
}
@@ -36,6 +43,11 @@ type ComicHandler struct {
Service *service.ComicService
}
func NewComicHandler(db *gorm.DB) *ComicHandler {
handler := &ComicHandler{Service: service.NewComicService(repository.NewComicRepository(db))}
return handler
}
func (handler *ComicHandler) List(c *gin.Context) {
comics, err := handler.Service.List(c.Request.Context())
if err != nil {
+30
View File
@@ -0,0 +1,30 @@
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 ComicworkHandler struct {
Service *service.ComicworkService
}
func NewComicworkHandler(db *gorm.DB) *ComicworkHandler {
handler := &ComicworkHandler{Service: service.NewComicworkService(repository.NewComicworkRepository(db))}
return handler
}
func (handler *ComicworkHandler) List(c *gin.Context) {
comicworks, err := handler.Service.List(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
dtos := models.ConvertComicworksToDtos(comicworks)
c.JSON(http.StatusOK, dtos)
}
+49
View File
@@ -0,0 +1,49 @@
package handlers
import (
"kontor-api-gin/internal/globals"
"kontor-api-gin/internal/models"
"kontor-api-gin/internal/repository"
"kontor-api-gin/internal/service"
"net/http"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
type IssueHandler struct {
Service *service.IssueService
}
func NewIssueHandler(db *gorm.DB) *IssueHandler {
handler := &IssueHandler{Service: service.NewIssueService(repository.NewIssueRepository(db))}
return handler
}
func (handler *IssueHandler) List(c *gin.Context) {
issues, err := handler.Service.List(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
dtos := models.ConvertIssuesToDtos(issues)
c.JSON(http.StatusOK, dtos)
}
func (handler *IssueHandler) ListPage(c *gin.Context) {
session := sessions.Default(c)
user := session.Get(globals.UserKey)
issues, err := handler.Service.List(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.HTML(http.StatusOK, "Issues", gin.H{
"title": "Kontor Issues",
"version": "0.4.0",
"message": "Issues...",
"issues": issues,
"user": user,
})
}
+49
View File
@@ -0,0 +1,49 @@
package handlers
import (
"kontor-api-gin/internal/globals"
"kontor-api-gin/internal/models"
"kontor-api-gin/internal/repository"
"kontor-api-gin/internal/service"
"net/http"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
type IssueworkHandler struct {
Service *service.IssueworkService
}
func NewIssueworkHandler(db *gorm.DB) *IssueworkHandler {
handler := &IssueworkHandler{Service: service.NewIssueworkService(repository.NewIssueworkRepository(db))}
return handler
}
func (handler *IssueworkHandler) List(c *gin.Context) {
issueworks, err := handler.Service.List(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
dtos := models.ConvertIssueworksToDtos(issueworks)
c.JSON(http.StatusOK, dtos)
}
func (handler *IssueworkHandler) ListPage(c *gin.Context) {
session := sessions.Default(c)
user := session.Get(globals.UserKey)
issueworks, err := handler.Service.List(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.HTML(http.StatusOK, "Issues", gin.H{
"title": "Kontor Issues",
"version": "0.4.0",
"message": "Issues...",
"issueworks": issueworks,
"user": user,
})
}
+7
View File
@@ -2,10 +2,12 @@ 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 PlayerHandler struct {
@@ -31,3 +33,8 @@ func (handler *PlayerHandler) Get(c *gin.Context) {
}
c.JSON(http.StatusOK, player)
}
func NewPlayerHandler(db *gorm.DB) *PlayerHandler {
handler := &PlayerHandler{Service: service.NewPlayerService(repository.NewPlayerRepository(db))}
return handler
}
+7
View File
@@ -2,10 +2,12 @@ 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 PositionHandler struct {
@@ -31,3 +33,8 @@ func (handler *PositionHandler) Get(c *gin.Context) {
}
c.JSON(http.StatusOK, position)
}
func NewPositionHandler(db *gorm.DB) *PositionHandler {
handler := &PositionHandler{Service: service.NewPositionService(repository.NewPositionRepository(db))}
return handler
}
@@ -2,16 +2,23 @@ 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 PublisherHandler struct {
Service *service.PublisherService
}
func NewPublisherHandler(db *gorm.DB) *PublisherHandler {
handler := &PublisherHandler{Service: service.NewPublisherService(repository.NewPublisherRepository(db))}
return handler
}
func (handler *PublisherHandler) List(c *gin.Context) {
comics, err := handler.Service.List(c.Request.Context())
if err != nil {
+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
}
+7
View File
@@ -2,10 +2,12 @@ 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 SportHandler struct {
@@ -31,3 +33,8 @@ func (handler *SportHandler) Get(c *gin.Context) {
}
c.JSON(http.StatusOK, sport)
}
func NewSportHandler(db *gorm.DB) *SportHandler {
handler := &SportHandler{Service: service.NewSportService(repository.NewSportRepository(db))}
return handler
}
+49
View File
@@ -0,0 +1,49 @@
package handlers
import (
"kontor-api-gin/internal/globals"
"kontor-api-gin/internal/models"
"kontor-api-gin/internal/repository"
"kontor-api-gin/internal/service"
"net/http"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
type StoryArcHandler struct {
Service *service.StoryArcService
}
func NewStoryArcHandler(db *gorm.DB) *StoryArcHandler {
handler := &StoryArcHandler{Service: service.NewStoryArcService(repository.NewStoryArcRepository(db))}
return handler
}
func (handler *StoryArcHandler) List(c *gin.Context) {
storyArcs, err := handler.Service.List(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
dtos := models.ConvertStoryArcsToDtos(storyArcs)
c.JSON(http.StatusOK, dtos)
}
func (handler *StoryArcHandler) ListPage(c *gin.Context) {
session := sessions.Default(c)
user := session.Get(globals.UserKey)
storyArcs, err := handler.Service.List(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.HTML(http.StatusOK, "StoryArcs", gin.H{
"title": "Kontor StoryArcs",
"version": "0.4.0",
"message": "StoryArcs...",
"storyArcs": storyArcs,
"user": user,
})
}
+7
View File
@@ -2,10 +2,12 @@ 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 TeamHandler struct {
@@ -31,3 +33,8 @@ func (handler *TeamHandler) Get(c *gin.Context) {
}
c.JSON(http.StatusOK, team)
}
func NewTeamHandler(db *gorm.DB) *TeamHandler {
handler := &TeamHandler{Service: service.NewTeamService(repository.NewTeamRepository(db))}
return handler
}
+12 -11
View File
@@ -1,9 +1,6 @@
package handlers
import (
"kontor-api-gin/internal/repository"
"kontor-api-gin/internal/service"
"gorm.io/gorm"
)
@@ -12,18 +9,22 @@ type TyscHandler struct {
PlayerHandler *PlayerHandler
TeamHandler *TeamHandler
PositionHandler *PositionHandler
// RoosterHandler *RoosterHandler
// VendorHandler *VendorHandler
// CardSetHandler *CardSetHandler
// CardHandler *CardHandler
RoosterHandler *RoosterHandler
VendorHandler *VendorHandler
CardSetHandler *CardSetHandler
CardHandler *CardHandler
}
func NewTyscHandler(db *gorm.DB) *TyscHandler {
handlerMap := &TyscHandler{
SportHandler: &SportHandler{Service: service.NewSportService(repository.NewSportRepository(db))},
PlayerHandler: &PlayerHandler{Service: service.NewPlayerService(repository.NewPlayerRepository(db))},
TeamHandler: &TeamHandler{Service: service.NewTeamService(repository.NewTeamRepository(db))},
PositionHandler: &PositionHandler{Service: service.NewPositionService(repository.NewPositionRepository(db))},
SportHandler: NewSportHandler(db),
PlayerHandler: NewPlayerHandler(db),
TeamHandler: NewTeamHandler(db),
PositionHandler: NewPositionHandler(db),
RoosterHandler: NewRoosterHandler(db),
VendorHandler: NewVendorHandler(db),
CardSetHandler: NewCardSetHandler(db),
CardHandler: NewCardHandler(db),
}
return handlerMap
}
+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 VendorHandler struct {
Service *service.VendorService
}
func (handler *VendorHandler) List(c *gin.Context) {
vendors, err := handler.Service.List(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
dtos := models.ConvertVendorsToDtos(vendors)
c.JSON(http.StatusOK, dtos)
}
func (handler *VendorHandler) Get(c *gin.Context) {
id := c.Param("id")
vendor, err := handler.Service.Get(c.Request.Context(), id)
if err != nil {
c.JSON(http.StatusNotFound, gin.H{"error": "vendor not found"})
return
}
c.JSON(http.StatusOK, vendor)
}
func NewVendorHandler(db *gorm.DB) *VendorHandler {
handler := &VendorHandler{Service: service.NewVendorService(repository.NewVendorRepository(db))}
return handler
}
+49
View File
@@ -0,0 +1,49 @@
package handlers
import (
"kontor-api-gin/internal/globals"
"kontor-api-gin/internal/models"
"kontor-api-gin/internal/repository"
"kontor-api-gin/internal/service"
"net/http"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
type VolumeHandler struct {
Service *service.VolumeService
}
func NewVolumeHandler(db *gorm.DB) *VolumeHandler {
handler := &VolumeHandler{Service: service.NewVolumeService(repository.NewVolumeRepository(db))}
return handler
}
func (handler *VolumeHandler) List(c *gin.Context) {
volumes, err := handler.Service.List(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
dtos := models.ConvertVolumesToDtos(volumes)
c.JSON(http.StatusOK, dtos)
}
func (handler *VolumeHandler) ListPage(c *gin.Context) {
session := sessions.Default(c)
user := session.Get(globals.UserKey)
volumes, err := handler.Service.List(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.HTML(http.StatusOK, "Volumes", gin.H{
"title": "Kontor Volumes",
"version": "0.4.0",
"message": "Volumes...",
"volumes": volumes,
"user": user,
})
}
+49
View File
@@ -0,0 +1,49 @@
package handlers
import (
"kontor-api-gin/internal/globals"
"kontor-api-gin/internal/models"
"kontor-api-gin/internal/repository"
"kontor-api-gin/internal/service"
"net/http"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
type WorkTypeHandler struct {
Service *service.WorkTypeService
}
func NewWorkTypeHandler(db *gorm.DB) *WorkTypeHandler {
handler := &WorkTypeHandler{Service: service.NewWorkTypeService(repository.NewWorkTypeRepository(db))}
return handler
}
func (handler *WorkTypeHandler) List(c *gin.Context) {
workTypes, err := handler.Service.List(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
dtos := models.ConvertWorkTypesToDtos(workTypes)
c.JSON(http.StatusOK, dtos)
}
func (handler *WorkTypeHandler) ListPage(c *gin.Context) {
session := sessions.Default(c)
user := session.Get(globals.UserKey)
workTypes, err := handler.Service.List(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.HTML(http.StatusOK, "WorkTypes", gin.H{
"title": "Kontor WorkTypes",
"version": "0.4.0",
"message": "WorkTypes...",
"workTypes": workTypes,
"user": user,
})
}