93 lines
2.2 KiB
Go
93 lines
2.2 KiB
Go
package controllers
|
|
|
|
import (
|
|
"kontor-api-gin/pkg/schema"
|
|
"net/http"
|
|
|
|
"github.com/gin-contrib/slog"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func ListComics(c *gin.Context) {
|
|
var comics []schema.Comic
|
|
|
|
logger := slog.Get(c)
|
|
// query := schema.DB.Model(&schema.MediaFile{})
|
|
// result := query.Find(&files)
|
|
result := schema.DB.Find(&comics)
|
|
logger.Info("found Comics", "count", result.RowsAffected)
|
|
c.JSON(http.StatusOK, comics)
|
|
}
|
|
|
|
func ListComicPublishers(c *gin.Context) {
|
|
var publishers []schema.Publisher
|
|
|
|
logger := slog.Get(c)
|
|
result := schema.DB.Find(&publishers)
|
|
logger.Info("found Comic Publishers", "count", result.RowsAffected)
|
|
c.JSON(http.StatusOK, publishers)
|
|
}
|
|
|
|
func ListComicArtists(c *gin.Context) {
|
|
var artists []schema.Artist
|
|
|
|
logger := slog.Get(c)
|
|
result := schema.DB.Find(&artists)
|
|
logger.Info("found Comic Artists", "count", result.RowsAffected)
|
|
c.JSON(http.StatusOK, artists)
|
|
}
|
|
|
|
func ListComicIssues(c *gin.Context) {
|
|
var issues []schema.Issue
|
|
|
|
logger := slog.Get(c)
|
|
result := schema.DB.Find(&issues)
|
|
logger.Info("found Comic Issues", "count", result.RowsAffected)
|
|
c.JSON(http.StatusOK, issues)
|
|
}
|
|
|
|
func ListComicWorkTypes(c *gin.Context) {
|
|
var worktypes []schema.WorkType
|
|
|
|
logger := slog.Get(c)
|
|
result := schema.DB.Find(&worktypes)
|
|
logger.Info("found Comic WorkTypes", "count", result.RowsAffected)
|
|
c.JSON(http.StatusOK, worktypes)
|
|
}
|
|
|
|
func ListComicVolumes(c *gin.Context) {
|
|
var items []schema.Volume
|
|
|
|
logger := slog.Get(c)
|
|
result := schema.DB.Find(&items)
|
|
logger.Info("found Comic Volumes", "count", result.RowsAffected)
|
|
c.JSON(http.StatusOK, items)
|
|
}
|
|
|
|
func ListComicStoryArcs(c *gin.Context) {
|
|
var items []schema.StoryArc
|
|
|
|
logger := slog.Get(c)
|
|
result := schema.DB.Find(&items)
|
|
logger.Info("ListComicStoryArcs", "count", result.RowsAffected)
|
|
c.JSON(http.StatusOK, items)
|
|
}
|
|
|
|
func ListComicWorks(c *gin.Context) {
|
|
var items []schema.ComicWork
|
|
|
|
logger := slog.Get(c)
|
|
result := schema.DB.Find(&items)
|
|
logger.Info("found Comic ComicWorks", "count", result.RowsAffected)
|
|
c.JSON(http.StatusOK, items)
|
|
}
|
|
|
|
func ListComicIssueWorks(c *gin.Context) {
|
|
var items []schema.IssueWork
|
|
|
|
logger := slog.Get(c)
|
|
result := schema.DB.Find(&items)
|
|
logger.Info("found Comic IssueWorks", "count", result.RowsAffected)
|
|
c.JSON(http.StatusOK, items)
|
|
}
|