This commit is contained in:
@@ -19,96 +19,85 @@ var exportCmd = &cobra.Command{
|
||||
slog.Info("export kontor")
|
||||
slog.Info("Verbosity level", "level", verbose)
|
||||
var login LoginResponse
|
||||
|
||||
client := resty.New()
|
||||
_, err := client.R().
|
||||
SetBody(Login{
|
||||
Email: "thomas.peetz@thpeetz.de",
|
||||
Password: "admin",
|
||||
}).
|
||||
SetHeader("Accept", "application/json").
|
||||
SetResult(&login).
|
||||
Post("http://127.0.0.1:8550/api/login")
|
||||
if err != nil {
|
||||
slog.Info("Health", "error", err.Error())
|
||||
}
|
||||
slog.Info("health", "token", login.Token)
|
||||
PostJSON(client, "http://127.0.0.1:8550/api/login", &login)
|
||||
|
||||
type ExportData struct {
|
||||
Sport []models.SportDTO `json:"sport"`
|
||||
Player []models.PlayerDTO `json:"player"`
|
||||
Team []models.TeamDTO `json:"team"`
|
||||
Position []models.PositionDTO `json:"field_position"`
|
||||
Rooster []models.RoosterDTO `json:"rooster"`
|
||||
Vendor []models.VendorDTO `json:"vendor"`
|
||||
CardSet []models.CardSetDTO `json:"card_set"`
|
||||
Card []models.CardDTO `json:"card"`
|
||||
Comic []models.ComicDTO `json:"comic"`
|
||||
Sport []models.SportDTO `json:"sport"`
|
||||
Player []models.PlayerDTO `json:"player"`
|
||||
Team []models.TeamDTO `json:"team"`
|
||||
Position []models.PositionDTO `json:"field_position"`
|
||||
Rooster []models.RoosterDTO `json:"rooster"`
|
||||
Vendor []models.VendorDTO `json:"vendor"`
|
||||
CardSet []models.CardSetDTO `json:"card_set"`
|
||||
Card []models.CardDTO `json:"card"`
|
||||
Artist []models.ArtistDTO `json:"artist"`
|
||||
Publisher []models.PublisherDTO `json:"publisher"`
|
||||
Worktype []models.WorkTypeDTO `json:"worktype"`
|
||||
Comic []models.ComicDTO `json:"comic"`
|
||||
Volume []models.VolumeDTO `json:"volume"`
|
||||
StoryArc []models.StoryArcDTO `json:"story_arc"`
|
||||
Issue []models.IssueDTO `json:"issue"`
|
||||
}
|
||||
|
||||
var sports []models.SportDTO
|
||||
_, err = client.R().
|
||||
SetAuthToken(login.Token).
|
||||
SetHeader("Accept", "application/json").
|
||||
SetResult(&sports).
|
||||
Get("http://127.0.0.1:8550/api/v1/tysc/sports")
|
||||
if err != nil {
|
||||
slog.Info("sports", "error", err.Error())
|
||||
}
|
||||
var (
|
||||
sports []models.SportDTO
|
||||
players []models.PlayerDTO
|
||||
teams []models.TeamDTO
|
||||
positions []models.PositionDTO
|
||||
roosters []models.RoosterDTO
|
||||
vendors []models.VendorDTO
|
||||
cardsets []models.CardSetDTO
|
||||
cards []models.CardDTO
|
||||
artists []models.ArtistDTO
|
||||
publishers []models.PublisherDTO
|
||||
worktypes []models.WorkTypeDTO
|
||||
comics []models.ComicDTO
|
||||
volumes []models.VolumeDTO
|
||||
storyarcs []models.StoryArcDTO
|
||||
issues []models.IssueDTO
|
||||
)
|
||||
|
||||
var players []models.PlayerDTO
|
||||
_, err = client.R().
|
||||
SetAuthToken(login.Token).
|
||||
SetHeader("Accept", "application/json").
|
||||
SetResult(&players).
|
||||
Get("http://127.0.0.1:8550/api/v1/tysc/players")
|
||||
if err != nil {
|
||||
slog.Info("players", "error", err.Error())
|
||||
registry := map[string]any{
|
||||
"http://127.0.0.1:8550/api/v1/tysc/sports": &sports,
|
||||
"http://127.0.0.1:8550/api/v1/tysc/players": &players,
|
||||
"http://127.0.0.1:8550/api/v1/tysc/teams": &teams,
|
||||
"http://127.0.0.1:8550/api/v1/tysc/positions": &positions,
|
||||
"http://127.0.0.1:8550/api/v1/tysc/roosters": &roosters,
|
||||
"http://127.0.0.1:8550/api/v1/tysc/vendors": &vendors,
|
||||
"http://127.0.0.1:8550/api/v1/tysc/cardsets": &cardsets,
|
||||
"http://127.0.0.1:8550/api/v1/tysc/cards": &cards,
|
||||
"http://127.0.0.1:8550/api/v1/comics/artists": &artists,
|
||||
"http://127.0.0.1:8550/api/v1/comics/publishers": &publishers,
|
||||
"http://127.0.0.1:8550/api/v1/comics/worktypes": &worktypes,
|
||||
"http://127.0.0.1:8550/api/v1/comics/comics": &comics,
|
||||
"http://127.0.0.1:8550/api/v1/comics/volumes": &volumes,
|
||||
"http://127.0.0.1:8550/api/v1/comics/storyarcs": &storyarcs,
|
||||
"http://127.0.0.1:8550/api/v1/comics/issues": &issues,
|
||||
}
|
||||
|
||||
var teams []models.TeamDTO
|
||||
_, err = client.R().
|
||||
SetAuthToken(login.Token).
|
||||
SetHeader("Accept", "application/json").
|
||||
SetResult(&teams).
|
||||
Get("http://127.0.0.1:8550/api/v1/tysc/teams")
|
||||
if err != nil {
|
||||
slog.Info("teams", "error", err.Error())
|
||||
for url, value := range registry {
|
||||
GetJSON(client, login.Token, url, value)
|
||||
}
|
||||
|
||||
var positions []models.PositionDTO
|
||||
_, err = client.R().
|
||||
SetAuthToken(login.Token).
|
||||
SetHeader("Accept", "application/json").
|
||||
SetResult(&positions).
|
||||
Get("http://127.0.0.1:8550/api/v1/tysc/positions")
|
||||
if err != nil {
|
||||
slog.Info("teams", "error", err.Error())
|
||||
}
|
||||
|
||||
var comics []models.ComicDTO
|
||||
_, err = client.R().
|
||||
SetAuthToken(login.Token).
|
||||
SetHeader("Accept", "application/json").
|
||||
SetResult(&comics).
|
||||
Get("http://127.0.0.1:8550/api/v1/comics/comics")
|
||||
if err != nil {
|
||||
slog.Info("comics", "error", err.Error())
|
||||
}
|
||||
// slog.Info("comics", "res", comics)
|
||||
|
||||
data := ExportData{
|
||||
Sport: sports,
|
||||
Player: players,
|
||||
Team: teams,
|
||||
Position: positions,
|
||||
Rooster: []models.RoosterDTO{},
|
||||
Vendor: []models.VendorDTO{},
|
||||
CardSet: []models.CardSetDTO{},
|
||||
Card: []models.CardDTO{},
|
||||
Comic: comics,
|
||||
export := ExportData{
|
||||
Sport: sports,
|
||||
Player: players,
|
||||
Team: teams,
|
||||
Position: positions,
|
||||
Rooster: roosters,
|
||||
Vendor: vendors,
|
||||
CardSet: cardsets,
|
||||
Card: cards,
|
||||
Artist: artists,
|
||||
Publisher: publishers,
|
||||
Worktype: worktypes,
|
||||
Comic: comics,
|
||||
Volume: volumes,
|
||||
StoryArc: storyarcs,
|
||||
Issue: issues,
|
||||
}
|
||||
defer client.Close()
|
||||
jsonData, err := json.MarshalIndent(data, "", " ")
|
||||
jsonData, err := json.MarshalIndent(export, "", " ")
|
||||
if err != nil {
|
||||
slog.Info("JSON MarshalIndent failed", "Error:", err)
|
||||
}
|
||||
@@ -121,6 +110,32 @@ var exportCmd = &cobra.Command{
|
||||
},
|
||||
}
|
||||
|
||||
func GetJSON(client *resty.Client, token string, url string, v any) {
|
||||
_, err := client.R().
|
||||
SetAuthToken(token).
|
||||
SetHeader("Accept", "application/json").
|
||||
SetResult(v).
|
||||
Get(url)
|
||||
if err != nil {
|
||||
slog.Info(url, "error", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func PostJSON(client *resty.Client, url string, v any) {
|
||||
_, err := client.R().
|
||||
SetBody(Login{
|
||||
Email: "thomas.peetz@thpeetz.de",
|
||||
Password: "admin",
|
||||
}).
|
||||
SetHeader("Accept", "application/json").
|
||||
SetResult(v).
|
||||
Post(url)
|
||||
if err != nil {
|
||||
slog.Info("Health", "error", err.Error())
|
||||
}
|
||||
slog.Info(url, "token", v)
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(exportCmd)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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,
|
||||
})
|
||||
}
|
||||
@@ -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,
|
||||
})
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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,
|
||||
})
|
||||
}
|
||||
@@ -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,
|
||||
})
|
||||
}
|
||||
@@ -16,6 +16,32 @@ func (artist *Artist) TableName() string {
|
||||
return "artist"
|
||||
}
|
||||
|
||||
type ArtistDTO struct {
|
||||
ID string `json:"id"`
|
||||
CreatedAt time.Time `json:"created_date"`
|
||||
UpdatedAt time.Time `json:"last_modified_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
||||
Version int `json:"version"`
|
||||
Name string `json:"name"`
|
||||
WebLink string `json:"weblink"`
|
||||
}
|
||||
|
||||
func ConvertArtistsToDtos(artists []Artist) []ArtistDTO {
|
||||
dtos := make([]ArtistDTO, len(artists))
|
||||
for i, artist := range artists {
|
||||
dtos[i] = ArtistDTO{
|
||||
ID: artist.ID,
|
||||
CreatedAt: artist.CreatedAt,
|
||||
UpdatedAt: artist.UpdatedAt,
|
||||
DeletedAt: artist.DeletedAt,
|
||||
Version: artist.Version,
|
||||
Name: artist.Name,
|
||||
WebLink: artist.WebLink,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
type CreateArtistDTO struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
WebLink string `json:"weblink" binding:"required"`
|
||||
|
||||
@@ -3,19 +3,47 @@ package models
|
||||
import "time"
|
||||
|
||||
type ComicWork struct {
|
||||
ID string `gorm:"type:string;primary_key;"`
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
CreatedAt time.Time `gorm:"column:created_date" json:"created_date"`
|
||||
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
||||
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_date"`
|
||||
Version int `gorm:"default:0" json:"version"`
|
||||
ArtistID *string `gorm:"column:artist_id" json:"artist_id"`
|
||||
Artist *Artist `gorm:"foreignKey:ArtistID"`
|
||||
Artist *Artist `gorm:"foreignKey:ArtistID" json:"artist"`
|
||||
ComicID *string `gorm:"column:comic_id" json:"comic_id"`
|
||||
Comic *Comic `gorm:"foreignKey:ComicID"`
|
||||
Comic *Comic `gorm:"foreignKey:ComicID" json:"comic"`
|
||||
WorkTypeID *string `gorm:"column:work_type_id" json:"work_type_id"`
|
||||
WorkType *WorkType `gorm:"foreignKey:WorkTypeID"`
|
||||
WorkType *WorkType `gorm:"foreignKey:WorkTypeID" json:"work_type"`
|
||||
}
|
||||
|
||||
func (comic_work *ComicWork) TableName() string {
|
||||
return "comic_work"
|
||||
}
|
||||
|
||||
type ComicworkDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_date"`
|
||||
UpdatedAt time.Time `json:"last_modified_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
||||
Version int `json:"version"`
|
||||
ArtistID *string `json:"artist_id"`
|
||||
ComicID *string `json:"comic_id"`
|
||||
WorkTypeID *string `json:"work_type_id"`
|
||||
}
|
||||
|
||||
func ConvertComicworksToDtos(comicworks []ComicWork) []ComicworkDTO {
|
||||
dtos := make([]ComicworkDTO, len(comicworks))
|
||||
for i, comicwork := range comicworks {
|
||||
dtos[i] = ComicworkDTO{
|
||||
ID: comicwork.ID,
|
||||
CreatedAt: comicwork.CreatedAt,
|
||||
UpdatedAt: comicwork.UpdatedAt,
|
||||
DeletedAt: comicwork.DeletedAt,
|
||||
Version: comicwork.Version,
|
||||
ArtistID: comicwork.ArtistID,
|
||||
ComicID: comicwork.ComicID,
|
||||
WorkTypeID: comicwork.WorkTypeID,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package models
|
||||
import "time"
|
||||
|
||||
type Issue struct {
|
||||
ID string `gorm:"type:string;primary_key;"`
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
CreatedAt time.Time `gorm:"column:created_date" json:"created_date"`
|
||||
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
||||
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_date"`
|
||||
@@ -14,13 +14,45 @@ type Issue struct {
|
||||
Title string `gorm:"column:title" json:"title"`
|
||||
PublishedOn time.Time `gorm:"column:published_on" json:"published_on"`
|
||||
ComicID *string `gorm:"column:comic_id" json:"comic_id"`
|
||||
Comic *Comic `gorm:"foreignKey:ComicID"`
|
||||
Comic *Comic `gorm:"foreignKey:ComicID" json:"comic"`
|
||||
StoryArcID *string `gorm:"column:story_arc_id" json:"story_arc_id"`
|
||||
StoryArc *StoryArc `gorm:"foreignKey:StoryArcID"`
|
||||
StoryArc *StoryArc `gorm:"foreignKey:StoryArcID" json:"story_arc"`
|
||||
VolumeID *string `gorm:"column:volume_id" json:"volume_id"`
|
||||
Volume *Volume `gorm:"foreignKey:VolumeID"`
|
||||
Volume *Volume `gorm:"foreignKey:VolumeID" json:"volume"`
|
||||
}
|
||||
|
||||
func (issue *Issue) TableName() string {
|
||||
return "issue"
|
||||
}
|
||||
|
||||
type IssueDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_date"`
|
||||
UpdatedAt time.Time `json:"last_modified_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
||||
Version int `json:"version"`
|
||||
Title string `json:"title"`
|
||||
PublishedOn time.Time `json:"published_on"`
|
||||
ComicID *string `json:"comic_id"`
|
||||
StoryArcID *string `json:"story_arc_id"`
|
||||
VolumeID *string `json:"volume_id"`
|
||||
}
|
||||
|
||||
func ConvertIssuesToDtos(issues []Issue) []IssueDTO {
|
||||
dtos := make([]IssueDTO, len(issues))
|
||||
for i, issue := range issues {
|
||||
dtos[i] = IssueDTO{
|
||||
ID: issue.ID,
|
||||
CreatedAt: issue.CreatedAt,
|
||||
UpdatedAt: issue.UpdatedAt,
|
||||
DeletedAt: issue.DeletedAt,
|
||||
Version: issue.Version,
|
||||
Title: issue.Title,
|
||||
PublishedOn: issue.PublishedOn,
|
||||
ComicID: issue.ComicID,
|
||||
StoryArcID: issue.StoryArcID,
|
||||
VolumeID: issue.VolumeID,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
@@ -3,19 +3,47 @@ package models
|
||||
import "time"
|
||||
|
||||
type IssueWork struct {
|
||||
ID string `gorm:"type:string;primary_key;"`
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
CreatedAt time.Time `gorm:"column:created_date" json:"created_date"`
|
||||
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
||||
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_date"`
|
||||
Version int `gorm:"default:0" json:"version"`
|
||||
ArtistID *string `gorm:"column:artist_id" json:"artist_id"`
|
||||
Artist *Artist `gorm:"foreignKey:ArtistID"`
|
||||
Artist *Artist `gorm:"foreignKey:ArtistID" json:"artist"`
|
||||
IssueID *string `gorm:"column:issue_id" json:"issue_id"`
|
||||
Issue *Issue `gorm:"foreignKey:IssueID"`
|
||||
Issue *Issue `gorm:"foreignKey:IssueID" json:"issue"`
|
||||
WorkTypeID *string `gorm:"column:work_type_id" json:"work_type_id"`
|
||||
WorkType *WorkType `gorm:"foreignKey:WorkTypeID"`
|
||||
WorkType *WorkType `gorm:"foreignKey:WorkTypeID" json:"work_type"`
|
||||
}
|
||||
|
||||
func (issue_work *IssueWork) TableName() string {
|
||||
return "issue_work"
|
||||
}
|
||||
|
||||
type IssueworkDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_date"`
|
||||
UpdatedAt time.Time `json:"last_modified_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
||||
Version int `json:"version"`
|
||||
ArtistID *string `json:"artist_id"`
|
||||
IssueID *string `json:"issue_id"`
|
||||
WorkTypeID *string `json:"work_type_id"`
|
||||
}
|
||||
|
||||
func ConvertIssueworksToDtos(issueworks []IssueWork) []IssueworkDTO {
|
||||
dtos := make([]IssueworkDTO, len(issueworks))
|
||||
for i, issuework := range issueworks {
|
||||
dtos[i] = IssueworkDTO{
|
||||
ID: issuework.ID,
|
||||
CreatedAt: issuework.CreatedAt,
|
||||
UpdatedAt: issuework.UpdatedAt,
|
||||
DeletedAt: issuework.DeletedAt,
|
||||
Version: issuework.Version,
|
||||
ArtistID: issuework.ArtistID,
|
||||
IssueID: issuework.IssueID,
|
||||
WorkTypeID: issuework.WorkTypeID,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ type PublisherDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_date"`
|
||||
UpdatedAt time.Time `json:"last_modified_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
||||
Version int `json:"version"`
|
||||
Name string `json:"name"`
|
||||
WebLink string `json:"weblink"`
|
||||
|
||||
@@ -3,18 +3,46 @@ package models
|
||||
import "time"
|
||||
|
||||
type StoryArc struct {
|
||||
ID string `gorm:"type:string;primary_key;"`
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
CreatedAt time.Time `gorm:"column:created_date" json:"created_date"`
|
||||
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
||||
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_date"`
|
||||
Version int `gorm:"default:0" json:"version"`
|
||||
Name string `gorm:"uniqueIndex" json:"name"`
|
||||
ComicID *string `gorm:"column:comic_id" json:"comic_id"`
|
||||
Comic *Comic `gorm:"foreignKey:ComicID"`
|
||||
Comic *Comic `gorm:"foreignKey:ComicID" json:"comic"`
|
||||
VolumeID *string `gorm:"column:volume_id" json:"volume_id"`
|
||||
Volume *Volume `gorm:"foreignKey:VolumeID"`
|
||||
Volume *Volume `gorm:"foreignKey:VolumeID" json:"volume"`
|
||||
}
|
||||
|
||||
func (story_arc *StoryArc) TableName() string {
|
||||
return "story_arc"
|
||||
}
|
||||
|
||||
type StoryArcDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_date"`
|
||||
UpdatedAt time.Time `json:"last_modified_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
||||
Version int `json:"version"`
|
||||
Name string `json:"name"`
|
||||
ComicID *string `json:"comic_id"`
|
||||
VolumeID *string `json:"volume_id"`
|
||||
}
|
||||
|
||||
func ConvertStoryArcsToDtos(storyarcs []StoryArc) []StoryArcDTO {
|
||||
dtos := make([]StoryArcDTO, len(storyarcs))
|
||||
for i, storyarc := range storyarcs {
|
||||
dtos[i] = StoryArcDTO{
|
||||
ID: storyarc.ID,
|
||||
CreatedAt: storyarc.CreatedAt,
|
||||
UpdatedAt: storyarc.UpdatedAt,
|
||||
DeletedAt: storyarc.DeletedAt,
|
||||
Version: storyarc.Version,
|
||||
Name: storyarc.Name,
|
||||
ComicID: storyarc.ComicID,
|
||||
VolumeID: storyarc.VolumeID,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
@@ -3,16 +3,42 @@ package models
|
||||
import "time"
|
||||
|
||||
type Volume struct {
|
||||
ID string `gorm:"type:string;primary_key;"`
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
CreatedAt time.Time `gorm:"column:created_date" json:"created_date"`
|
||||
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
||||
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_date"`
|
||||
Version int `gorm:"default:0" json:"version"`
|
||||
Name string `gorm:"uniqueIndex" json:"name"`
|
||||
Name string `gorm:"uniqueIndex" json:"name"`
|
||||
ComicID *string `gorm:"column:comic_id" json:"comic_id"`
|
||||
Comic *Comic `gorm:"foreignKey:ComicID"`
|
||||
Comic *Comic `gorm:"foreignKey:ComicID" json:"comic"`
|
||||
}
|
||||
|
||||
func (volume *Volume) TableName() string {
|
||||
return "volume"
|
||||
}
|
||||
|
||||
type VolumeDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_date"`
|
||||
UpdatedAt time.Time `json:"last_modified_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
||||
Version int `json:"version"`
|
||||
Name string `json:"name"`
|
||||
ComicID *string `json:"comic_id"`
|
||||
}
|
||||
|
||||
func ConvertVolumesToDtos(volumes []Volume) []VolumeDTO {
|
||||
dtos := make([]VolumeDTO, len(volumes))
|
||||
for i, volume := range volumes {
|
||||
dtos[i] = VolumeDTO{
|
||||
ID: volume.ID,
|
||||
CreatedAt: volume.CreatedAt,
|
||||
UpdatedAt: volume.UpdatedAt,
|
||||
DeletedAt: volume.DeletedAt,
|
||||
Version: volume.Version,
|
||||
Name: volume.Name,
|
||||
ComicID: volume.ComicID,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
@@ -3,14 +3,38 @@ package models
|
||||
import "time"
|
||||
|
||||
type WorkType struct {
|
||||
ID string `gorm:"type:string;primary_key;"`
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
CreatedAt time.Time `gorm:"column:created_date" json:"created_date"`
|
||||
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
||||
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_date"`
|
||||
Version int `gorm:"default:0" json:"version"`
|
||||
Name string `gorm:"uniqueIndex" json:"name"`
|
||||
Name string `gorm:"uniqueIndex" json:"name"`
|
||||
}
|
||||
|
||||
func (worktype *WorkType) TableName() string {
|
||||
return "worktype"
|
||||
}
|
||||
|
||||
type WorkTypeDTO struct {
|
||||
ID string `json:"id"`
|
||||
CreatedAt time.Time `json:"created_date"`
|
||||
UpdatedAt time.Time `json:"last_modified_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date"`
|
||||
Version int `json:"version"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func ConvertWorkTypesToDtos(worktypes []WorkType) []WorkTypeDTO {
|
||||
dtos := make([]WorkTypeDTO, len(worktypes))
|
||||
for i, worktype := range worktypes {
|
||||
dtos[i] = WorkTypeDTO{
|
||||
ID: worktype.ID,
|
||||
CreatedAt: worktype.CreatedAt,
|
||||
UpdatedAt: worktype.UpdatedAt,
|
||||
DeletedAt: worktype.DeletedAt,
|
||||
Version: worktype.Version,
|
||||
Name: worktype.Name,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ArtistRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewArtistRepository(db *gorm.DB) *ArtistRepository {
|
||||
repo := &ArtistRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *ArtistRepository) FindAll(context context.Context) ([]models.Artist, error) {
|
||||
var artists []models.Artist
|
||||
|
||||
result := repository.db.Find(&artists)
|
||||
slog.Info("ArtistRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return artists, nil
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type CardRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewCardRepository(db *gorm.DB) *CardRepository {
|
||||
repo := &CardRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *CardRepository) FindAll(context context.Context) ([]models.Card, error) {
|
||||
var cards []models.Card
|
||||
|
||||
result := repository.db.Find(&cards)
|
||||
slog.Info("CardRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return cards, nil
|
||||
}
|
||||
|
||||
func (repository *CardRepository) GetById(context context.Context, id string) (models.Card, error) {
|
||||
var card = models.Card{ID: id}
|
||||
slog.Info("CardRepository#GetById", "id", id)
|
||||
result := repository.db.First(&card)
|
||||
if result.Error != nil {
|
||||
slog.Info("CardRepository#GetById", "error", result.Error.Error())
|
||||
}
|
||||
return card, result.Error
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type CardSetRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewCardSetRepository(db *gorm.DB) *CardSetRepository {
|
||||
repo := &CardSetRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *CardSetRepository) FindAll(context context.Context) ([]models.CardSet, error) {
|
||||
var cardsets []models.CardSet
|
||||
|
||||
result := repository.db.Find(&cardsets)
|
||||
slog.Info("CardSetRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return cardsets, nil
|
||||
}
|
||||
|
||||
func (repository *CardSetRepository) GetById(context context.Context, id string) (models.CardSet, error) {
|
||||
var cardset = models.CardSet{ID: id}
|
||||
slog.Info("CardSetRepository#GetById", "id", id)
|
||||
result := repository.db.First(&cardset)
|
||||
if result.Error != nil {
|
||||
slog.Info("CardSetRepository#GetById", "error", result.Error.Error())
|
||||
}
|
||||
return cardset, result.Error
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ComicworkRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewComicworkRepository(db *gorm.DB) *ComicworkRepository {
|
||||
repo := &ComicworkRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *ComicworkRepository) FindAll(context context.Context) ([]models.ComicWork, error) {
|
||||
var comicworks []models.ComicWork
|
||||
|
||||
result := repository.db.Find(&comicworks)
|
||||
slog.Info("ComicRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return comicworks, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type IssueRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewIssueRepository(db *gorm.DB) *IssueRepository {
|
||||
repo := &IssueRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *IssueRepository) FindAll(context context.Context) ([]models.Issue, error) {
|
||||
var issues []models.Issue
|
||||
|
||||
result := repository.db.Find(&issues)
|
||||
slog.Info("IssueRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return issues, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type IssueworkRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewIssueworkRepository(db *gorm.DB) *IssueworkRepository {
|
||||
repo := &IssueworkRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *IssueworkRepository) FindAll(context context.Context) ([]models.IssueWork, error) {
|
||||
var issueworks []models.IssueWork
|
||||
|
||||
result := repository.db.Find(&issueworks)
|
||||
slog.Info("IssueRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return issueworks, nil
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type RoosterRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewRoosterRepository(db *gorm.DB) *RoosterRepository {
|
||||
repo := &RoosterRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *RoosterRepository) FindAll(context context.Context) ([]models.Rooster, error) {
|
||||
var roosters []models.Rooster
|
||||
|
||||
result := repository.db.Find(&roosters)
|
||||
slog.Info("RoosterRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return roosters, nil
|
||||
}
|
||||
|
||||
func (repository *RoosterRepository) GetById(context context.Context, id string) (models.Rooster, error) {
|
||||
var rooster = models.Rooster{ID: id}
|
||||
slog.Info("RoosterRepository#GetById", "id", id)
|
||||
result := repository.db.First(&rooster)
|
||||
if result.Error != nil {
|
||||
slog.Info("RoosterRepository#GetById", "error", result.Error.Error())
|
||||
}
|
||||
return rooster, result.Error
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type StoryArcRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewStoryArcRepository(db *gorm.DB) *StoryArcRepository {
|
||||
repo := &StoryArcRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *StoryArcRepository) FindAll(context context.Context) ([]models.StoryArc, error) {
|
||||
var storyArcs []models.StoryArc
|
||||
|
||||
result := repository.db.Find(&storyArcs)
|
||||
slog.Info("StoryArcRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return storyArcs, nil
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type VendorRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewVendorRepository(db *gorm.DB) *VendorRepository {
|
||||
repo := &VendorRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *VendorRepository) FindAll(context context.Context) ([]models.Vendor, error) {
|
||||
var vendors []models.Vendor
|
||||
|
||||
result := repository.db.Find(&vendors)
|
||||
slog.Info("VendorRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return vendors, nil
|
||||
}
|
||||
|
||||
func (repository *VendorRepository) GetById(context context.Context, id string) (models.Vendor, error) {
|
||||
var vendor = models.Vendor{ID: id}
|
||||
slog.Info("VendorRepository#GetById", "id", id)
|
||||
result := repository.db.First(&vendor)
|
||||
if result.Error != nil {
|
||||
slog.Info("VendorRepository#GetById", "error", result.Error.Error())
|
||||
}
|
||||
return vendor, result.Error
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type VolumeRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewVolumeRepository(db *gorm.DB) *VolumeRepository {
|
||||
repo := &VolumeRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *VolumeRepository) FindAll(context context.Context) ([]models.Volume, error) {
|
||||
var volumes []models.Volume
|
||||
|
||||
result := repository.db.Find(&volumes)
|
||||
slog.Info("VolumeRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return volumes, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type WorkTypeRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewWorkTypeRepository(db *gorm.DB) *WorkTypeRepository {
|
||||
repo := &WorkTypeRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *WorkTypeRepository) FindAll(context context.Context) ([]models.WorkType, error) {
|
||||
var workTypes []models.WorkType
|
||||
|
||||
result := repository.db.Find(&workTypes)
|
||||
slog.Info("VolumeRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return workTypes, nil
|
||||
}
|
||||
@@ -76,19 +76,19 @@ func New(admin *handlers.AdminHandler, comics *handlers.ComicsHandler, media *ha
|
||||
secured.GET("tysc/players", tysc.PlayerHandler.List)
|
||||
secured.GET("tysc/teams", tysc.TeamHandler.List)
|
||||
secured.GET("tysc/positions", tysc.PositionHandler.List)
|
||||
// secured.GET("tysc/roosters", tysc.RoosterHandler.List)
|
||||
// secured.GET("tysc/vendors", tysc.VendorHandler.List)
|
||||
// secured.GET("tysc/cardsets", tysc.CardSetHandler.List)
|
||||
// secured.GET("tysc/cards", tysc.CardHandler.List)
|
||||
secured.GET("tysc/roosters", tysc.RoosterHandler.List)
|
||||
secured.GET("tysc/vendors", tysc.VendorHandler.List)
|
||||
secured.GET("tysc/cardsets", tysc.CardSetHandler.List)
|
||||
secured.GET("tysc/cards", tysc.CardHandler.List)
|
||||
secured.GET("/comics/comics", comics.ComicHandler.List)
|
||||
secured.GET("/comics/publishers", comics.PublisherHandler.List)
|
||||
// comic.GET("/artists", comics.ArtistHandler.List)
|
||||
// comic.GET("/issues", comics.IssueHandler.List)
|
||||
// comic.GET("/worktypes", comics.WorktypeHandler.List)
|
||||
// comic.GET("/volumes", comics.VolumeHandler.List)
|
||||
// comic.GET("/storyarcs", comics.StoryarcHandler.List)
|
||||
// comic.GET("/comicworks", comics.ComicworkHandler.List)
|
||||
// comic.GET("/issueworks", comics.IssueworkHandler.List)
|
||||
secured.GET("/comics/artists", comics.ArtistHandler.List)
|
||||
secured.GET("/comics/issues", comics.IssueHandler.List)
|
||||
secured.GET("/comics/worktypes", comics.WorkTypeHandler.List)
|
||||
secured.GET("/comics/volumes", comics.VolumeHandler.List)
|
||||
secured.GET("/comics/storyarcs", comics.StoryArcHandler.List)
|
||||
secured.GET("/comics/comicworks", comics.ComicworkHandler.List)
|
||||
secured.GET("/comics/issueworks", comics.IssueworkHandler.List)
|
||||
secured.GET("/media/files", media.MediaFileHandler.List)
|
||||
secured.GET("/media/lofis", media.MediaLoFiHandler.List)
|
||||
secured.GET("/media/actors", media.MediaActorHandler.List)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"kontor-api-gin/internal/repository"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
type ArtistService struct {
|
||||
repository *repository.ArtistRepository
|
||||
}
|
||||
|
||||
func NewArtistService(repo *repository.ArtistRepository) *ArtistService {
|
||||
service := &ArtistService{repository: repo}
|
||||
return service
|
||||
}
|
||||
|
||||
func (service *ArtistService) List(context context.Context) ([]models.Artist, error) {
|
||||
slog.Info("ArtistService#List")
|
||||
return service.repository.FindAll(context)
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"kontor-api-gin/internal/repository"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
type CardService struct {
|
||||
repository *repository.CardRepository
|
||||
}
|
||||
|
||||
func NewCardService(repo *repository.CardRepository) *CardService {
|
||||
service := &CardService{repository: repo}
|
||||
return service
|
||||
}
|
||||
|
||||
func (service *CardService) List(context context.Context) ([]models.Card, error) {
|
||||
slog.Info("CardService#List")
|
||||
return service.repository.FindAll(context)
|
||||
}
|
||||
|
||||
func (service *CardService) Get(context context.Context, id string) (models.Card, error) {
|
||||
slog.Info("CardService#Get")
|
||||
return service.repository.GetById(context, id)
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"kontor-api-gin/internal/repository"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
type CardSetService struct {
|
||||
repository *repository.CardSetRepository
|
||||
}
|
||||
|
||||
func NewCardSetService(repo *repository.CardSetRepository) *CardSetService {
|
||||
service := &CardSetService{repository: repo}
|
||||
return service
|
||||
}
|
||||
|
||||
func (service *CardSetService) List(context context.Context) ([]models.CardSet, error) {
|
||||
slog.Info("CardSetService#List")
|
||||
return service.repository.FindAll(context)
|
||||
}
|
||||
|
||||
func (service *CardSetService) Get(context context.Context, id string) (models.CardSet, error) {
|
||||
slog.Info("CardSetService#Get")
|
||||
return service.repository.GetById(context, id)
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"kontor-api-gin/internal/repository"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
type ComicworkService struct {
|
||||
repository *repository.ComicworkRepository
|
||||
}
|
||||
|
||||
func NewComicworkService(repo *repository.ComicworkRepository) *ComicworkService {
|
||||
service := &ComicworkService{repository: repo}
|
||||
return service
|
||||
}
|
||||
|
||||
func (service *ComicworkService) List(context context.Context) ([]models.ComicWork, error) {
|
||||
slog.Info("ComicworkService#List")
|
||||
return service.repository.FindAll(context)
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"kontor-api-gin/internal/repository"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
type IssueService struct {
|
||||
repository *repository.IssueRepository
|
||||
}
|
||||
|
||||
func NewIssueService(repo *repository.IssueRepository) *IssueService {
|
||||
service := &IssueService{repository: repo}
|
||||
return service
|
||||
}
|
||||
|
||||
func (service *IssueService) List(context context.Context) ([]models.Issue, error) {
|
||||
slog.Info("IssueService#List")
|
||||
return service.repository.FindAll(context)
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"kontor-api-gin/internal/repository"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
type IssueworkService struct {
|
||||
repository *repository.IssueworkRepository
|
||||
}
|
||||
|
||||
func NewIssueworkService(repo *repository.IssueworkRepository) *IssueworkService {
|
||||
service := &IssueworkService{repository: repo}
|
||||
return service
|
||||
}
|
||||
|
||||
func (service *IssueworkService) List(context context.Context) ([]models.IssueWork, error) {
|
||||
slog.Info("IssueworkService#List")
|
||||
return service.repository.FindAll(context)
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"kontor-api-gin/internal/repository"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
type RoosterService struct {
|
||||
repository *repository.RoosterRepository
|
||||
}
|
||||
|
||||
func NewRoosterService(repo *repository.RoosterRepository) *RoosterService {
|
||||
service := &RoosterService{repository: repo}
|
||||
return service
|
||||
}
|
||||
|
||||
func (service *RoosterService) List(context context.Context) ([]models.Rooster, error) {
|
||||
slog.Info("RoosterService#List")
|
||||
return service.repository.FindAll(context)
|
||||
}
|
||||
|
||||
func (service *RoosterService) Get(context context.Context, id string) (models.Rooster, error) {
|
||||
slog.Info("RoosterService#Get")
|
||||
return service.repository.GetById(context, id)
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"kontor-api-gin/internal/repository"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
type StoryArcService struct {
|
||||
repository *repository.StoryArcRepository
|
||||
}
|
||||
|
||||
func NewStoryArcService(repo *repository.StoryArcRepository) *StoryArcService {
|
||||
service := &StoryArcService{repository: repo}
|
||||
return service
|
||||
}
|
||||
|
||||
func (service *StoryArcService) List(context context.Context) ([]models.StoryArc, error) {
|
||||
slog.Info("StoryArcService#List")
|
||||
return service.repository.FindAll(context)
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"kontor-api-gin/internal/repository"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
type VendorService struct {
|
||||
repository *repository.VendorRepository
|
||||
}
|
||||
|
||||
func NewVendorService(repo *repository.VendorRepository) *VendorService {
|
||||
service := &VendorService{repository: repo}
|
||||
return service
|
||||
}
|
||||
|
||||
func (service *VendorService) List(context context.Context) ([]models.Vendor, error) {
|
||||
slog.Info("VendorService#List")
|
||||
return service.repository.FindAll(context)
|
||||
}
|
||||
|
||||
func (service *VendorService) Get(context context.Context, id string) (models.Vendor, error) {
|
||||
slog.Info("VendorService#Get")
|
||||
return service.repository.GetById(context, id)
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"kontor-api-gin/internal/repository"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
type VolumeService struct {
|
||||
repository *repository.VolumeRepository
|
||||
}
|
||||
|
||||
func NewVolumeService(repo *repository.VolumeRepository) *VolumeService {
|
||||
service := &VolumeService{repository: repo}
|
||||
return service
|
||||
}
|
||||
|
||||
func (service *VolumeService) List(context context.Context) ([]models.Volume, error) {
|
||||
slog.Info("VolumeService#List")
|
||||
return service.repository.FindAll(context)
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"kontor-api-gin/internal/repository"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
type WorkTypeService struct {
|
||||
repository *repository.WorkTypeRepository
|
||||
}
|
||||
|
||||
func NewWorkTypeService(repo *repository.WorkTypeRepository) *WorkTypeService {
|
||||
service := &WorkTypeService{repository: repo}
|
||||
return service
|
||||
}
|
||||
|
||||
func (service *WorkTypeService) List(context context.Context) ([]models.WorkType, error) {
|
||||
slog.Info("WorkTypeService#List")
|
||||
return service.repository.FindAll(context)
|
||||
}
|
||||
Reference in New Issue
Block a user