This commit is contained in:
@@ -24,77 +24,121 @@ var exportCmd = &cobra.Command{
|
||||
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"`
|
||||
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"`
|
||||
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"`
|
||||
TradePaperback []models.TradePaperbackDTO `json:"trade_paperback"`
|
||||
ComicWork []models.ComicworkDTO `json:"comic_work"`
|
||||
IssueWork []models.IssueworkDTO `json:"issue_work"`
|
||||
MediaArticle []models.MediaArticleDTO `json:"media_article"`
|
||||
MediaVideo []models.MediaVideoDTO `json:"media_video"`
|
||||
MediaLoFi []models.MediaLoFiDTO `json:"media_lofi"`
|
||||
MediaFile []models.MediaFileDTO `json:"media_file"`
|
||||
Profile []models.ProfileDTO `json:"profile"`
|
||||
Permission []models.PermissionDTO `json:"permission"`
|
||||
Assignment []models.AssignmentDTO `json:"assignment"`
|
||||
Token []models.TokenDTO `json:"token"`
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
tradepaperbacks []models.TradePaperbackDTO
|
||||
comicworks []models.ComicworkDTO
|
||||
issueworks []models.IssueworkDTO
|
||||
mediaarticles []models.MediaArticleDTO
|
||||
mediavideos []models.MediaVideoDTO
|
||||
mediafiles []models.MediaFileDTO
|
||||
medialofis []models.MediaLoFiDTO
|
||||
profiles []models.ProfileDTO
|
||||
permissions []models.PermissionDTO
|
||||
assignments []models.AssignmentDTO
|
||||
tokens []models.TokenDTO
|
||||
)
|
||||
|
||||
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,
|
||||
"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,
|
||||
"http://127.0.0.1:8550/api/v1/comics/tradepaperbacks": &tradepaperbacks,
|
||||
"http://127.0.0.1:8550/api/v1/comics/comicworks": &comicworks,
|
||||
"http://127.0.0.1:8550/api/v1/comics/issueworks": &issueworks,
|
||||
"http://127.0.0.1:8550/api/v1/media/articles": &mediaarticles,
|
||||
"http://127.0.0.1:8550/api/v1/media/videos": &mediavideos,
|
||||
"http://127.0.0.1:8550/api/v1/media/files": &mediafiles,
|
||||
"http://127.0.0.1:8550/api/v1/media/lofis": &medialofis,
|
||||
"http://127.0.0.1:8550/api/v1/user/profiles": &profiles,
|
||||
"http://127.0.0.1:8550/api/v1/user/permissions": &permissions,
|
||||
"http://127.0.0.1:8550/api/v1/user/assignments": &assignments,
|
||||
"http://127.0.0.1:8550/api/v1/user/tokens": &tokens,
|
||||
}
|
||||
for url, value := range registry {
|
||||
GetJSON(client, login.Token, url, value)
|
||||
}
|
||||
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,
|
||||
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,
|
||||
TradePaperback: tradepaperbacks,
|
||||
ComicWork: comicworks,
|
||||
IssueWork: issueworks,
|
||||
MediaArticle: mediaarticles,
|
||||
MediaVideo: mediavideos,
|
||||
MediaFile: mediafiles,
|
||||
MediaLoFi: medialofis,
|
||||
Profile: profiles,
|
||||
Permission: permissions,
|
||||
Assignment: assignments,
|
||||
Token: tokens,
|
||||
}
|
||||
defer client.Close()
|
||||
jsonData, err := json.MarshalIndent(export, "", " ")
|
||||
|
||||
@@ -9,14 +9,20 @@ import (
|
||||
|
||||
type AdminHandler struct {
|
||||
AuthHandler *AuthHandler
|
||||
ProfileHandler *ProfileHandler
|
||||
PermissionHandler *PermissionHandler
|
||||
AssignmentHandler *AssignmentHandler
|
||||
TokenHandler *TokenHandler
|
||||
Secret []byte
|
||||
}
|
||||
|
||||
func NewAdminHandler(db *gorm.DB, secret []byte) *AdminHandler {
|
||||
adminHandler := &AdminHandler{
|
||||
AuthHandler: &AuthHandler{Service: service.NewAuthService(repository.NewProfileRepository(db), secret)},
|
||||
ProfileHandler: NewProfileHandler(db),
|
||||
PermissionHandler: &PermissionHandler{Service: service.NewPermissionService(repository.NewPermissionRepository(db))},
|
||||
AssignmentHandler: NewAssignmentHandler(db),
|
||||
TokenHandler: NewTokenHandler(db),
|
||||
Secret: secret,
|
||||
}
|
||||
return adminHandler
|
||||
|
||||
@@ -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 AssignmentHandler struct {
|
||||
Service *service.AssignmentService
|
||||
}
|
||||
|
||||
func NewAssignmentHandler(db *gorm.DB) *AssignmentHandler {
|
||||
handler := &AssignmentHandler{Service: service.NewAssignmentService(repository.NewAssignmentRepository(db))}
|
||||
return handler
|
||||
}
|
||||
|
||||
func (handler *AssignmentHandler) List(c *gin.Context) {
|
||||
assignments, err := handler.Service.List(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
dtos := models.ConvertAssignmentsToDtos(assignments)
|
||||
c.JSON(http.StatusOK, dtos)
|
||||
}
|
||||
@@ -13,28 +13,30 @@ import (
|
||||
)
|
||||
|
||||
type ComicsHandler struct {
|
||||
ComicHandler *ComicHandler
|
||||
PublisherHandler *PublisherHandler
|
||||
ArtistHandler *ArtistHandler
|
||||
IssueHandler *IssueHandler
|
||||
WorkTypeHandler *WorkTypeHandler
|
||||
VolumeHandler *VolumeHandler
|
||||
StoryArcHandler *StoryArcHandler
|
||||
ComicworkHandler *ComicworkHandler
|
||||
IssueworkHandler *IssueworkHandler
|
||||
ComicHandler *ComicHandler
|
||||
PublisherHandler *PublisherHandler
|
||||
ArtistHandler *ArtistHandler
|
||||
IssueHandler *IssueHandler
|
||||
WorkTypeHandler *WorkTypeHandler
|
||||
VolumeHandler *VolumeHandler
|
||||
StoryArcHandler *StoryArcHandler
|
||||
ComicworkHandler *ComicworkHandler
|
||||
IssueworkHandler *IssueworkHandler
|
||||
TradePaperbackHandler *TradePaperbackHandler
|
||||
}
|
||||
|
||||
func NewComicsHandler(db *gorm.DB) *ComicsHandler {
|
||||
comicsHandler := &ComicsHandler{
|
||||
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),
|
||||
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),
|
||||
TradePaperbackHandler: NewTradePaperbackHandler(db),
|
||||
}
|
||||
return comicsHandler
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"kontor-api-gin/internal/repository"
|
||||
"kontor-api-gin/internal/service"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -11,13 +8,15 @@ type MediaHandler struct {
|
||||
MediaActorHandler *MediaActorHandler
|
||||
MediaFileHandler *MediaFileHandler
|
||||
MediaLoFiHandler *MediaLoFiHandler
|
||||
MediaVideoHandler *MediaVideoHandler
|
||||
}
|
||||
|
||||
func NewMediaHandler(db *gorm.DB) *MediaHandler {
|
||||
mediaHandler := &MediaHandler{
|
||||
MediaActorHandler: &MediaActorHandler{Service: service.NewMediaActorService(repository.NewMediaActorRepository(db))},
|
||||
MediaFileHandler: &MediaFileHandler{Service: service.NewMediaFileService(repository.NewMediaFileRepository(db))},
|
||||
MediaLoFiHandler: &MediaLoFiHandler{Service: service.NewMediaLoFiService(repository.NewMediaLoFiRepository(db))},
|
||||
MediaActorHandler: NewMediaActorHandler(db),
|
||||
MediaFileHandler: NewMediaFileHandler(db),
|
||||
MediaLoFiHandler: NewMediaLoFiHandler(db),
|
||||
MediaVideoHandler: NewMediaVideoHandler(db),
|
||||
}
|
||||
return mediaHandler
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
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-contrib/slog"
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type MediaVideoHandler struct {
|
||||
Service *service.MediaVideoService
|
||||
}
|
||||
|
||||
func NewMediaVideoHandler(db *gorm.DB) *MediaVideoHandler {
|
||||
handler := &MediaVideoHandler{Service: service.NewMediaVideoService(repository.NewMediaVideoRepository(db))}
|
||||
return handler
|
||||
}
|
||||
|
||||
func (handler *MediaVideoHandler) List(c *gin.Context) {
|
||||
logger := slog.Get(c)
|
||||
logger.Info("MediaVideoHandler#List")
|
||||
videos, err := handler.Service.List(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
dtos := models.ConvertMediaVideosToDtos(videos)
|
||||
c.JSON(http.StatusOK, dtos)
|
||||
}
|
||||
|
||||
func (handler *MediaVideoHandler) ListPage(c *gin.Context) {
|
||||
session := sessions.Default(c)
|
||||
user := session.Get(globals.UserKey)
|
||||
videos, err := handler.Service.List(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.HTML(http.StatusOK, "mediavideos", gin.H{
|
||||
"title": "Kontor MediaFiles",
|
||||
"version": "0.4.0",
|
||||
"message": "MediaFiles...",
|
||||
"mediavideos": videos,
|
||||
"user": user,
|
||||
})
|
||||
}
|
||||
@@ -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 ProfileHandler struct {
|
||||
Service *service.ProfileService
|
||||
}
|
||||
|
||||
func NewProfileHandler(db *gorm.DB) *ProfileHandler {
|
||||
handler := &ProfileHandler{Service: service.NewProfileService(repository.NewProfileRepository(db))}
|
||||
return handler
|
||||
}
|
||||
|
||||
func (handler *ProfileHandler) List(c *gin.Context) {
|
||||
profiles, err := handler.Service.List(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
dtos := models.ConvertProfilesToDtos(profiles)
|
||||
c.JSON(http.StatusOK, dtos)
|
||||
}
|
||||
@@ -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 TokenHandler struct {
|
||||
Service *service.TokenService
|
||||
}
|
||||
|
||||
func NewTokenHandler(db *gorm.DB) *TokenHandler {
|
||||
handler := &TokenHandler{Service: service.NewTokenService(repository.NewTokenRepository(db))}
|
||||
return handler
|
||||
}
|
||||
|
||||
func (handler *TokenHandler) List(c *gin.Context) {
|
||||
tokens, err := handler.Service.List(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
dtos := models.ConvertTokensToDtos(tokens)
|
||||
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 TradePaperbackHandler struct {
|
||||
Service *service.TradePaperbackService
|
||||
}
|
||||
|
||||
func NewTradePaperbackHandler(db *gorm.DB) *TradePaperbackHandler {
|
||||
handler := &TradePaperbackHandler{Service: service.NewTradePaperbackService(repository.NewTradePaperbackRepository(db))}
|
||||
return handler
|
||||
}
|
||||
|
||||
func (handler *TradePaperbackHandler) List(c *gin.Context) {
|
||||
tradepaperbacks, err := handler.Service.List(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
dtos := models.ConvertTradePaperbacksToDtos(tradepaperbacks)
|
||||
c.JSON(http.StatusOK, dtos)
|
||||
}
|
||||
|
||||
func (handler *TradePaperbackHandler) ListPage(c *gin.Context) {
|
||||
session := sessions.Default(c)
|
||||
user := session.Get(globals.UserKey)
|
||||
tradepaperbacks, err := handler.Service.List(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.HTML(http.StatusOK, "comics", gin.H{
|
||||
"title": "Kontor Comics",
|
||||
"version": "0.4.0",
|
||||
"message": "Comics...",
|
||||
"tradepaperbacks": tradepaperbacks,
|
||||
"user": user,
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
type DateOnly struct {
|
||||
time.Time
|
||||
}
|
||||
|
||||
func (d DateOnly) MarshalJSON() ([]byte, error) {
|
||||
if d.IsZero() {
|
||||
return []byte("null"), nil
|
||||
}
|
||||
return json.Marshal(d.Format("2006-01-02"))
|
||||
}
|
||||
|
||||
func (d *DateOnly) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
if err := json.Unmarshal(b, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
if s == "" {
|
||||
return nil
|
||||
}
|
||||
t, err := time.Parse("2006-01-02", s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
d.Time = t
|
||||
return nil
|
||||
}
|
||||
|
||||
type KontorTime struct {
|
||||
time.Time
|
||||
}
|
||||
|
||||
const layout = "2006-01-02 15:04:05.000000"
|
||||
|
||||
func (kt KontorTime) MarshalJSON() ([]byte, error) {
|
||||
if kt.IsZero() {
|
||||
return []byte("null"), nil
|
||||
}
|
||||
return json.Marshal(kt.Format(layout))
|
||||
}
|
||||
|
||||
func (kt *KontorTime) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
if err := json.Unmarshal(b, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
if s == "" {
|
||||
return nil
|
||||
}
|
||||
t, err := time.Parse(layout, s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
kt.Time = t
|
||||
return nil
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Artist struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -17,13 +20,13 @@ func (artist *Artist) TableName() string {
|
||||
}
|
||||
|
||||
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"`
|
||||
ID string `json:"id"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date"`
|
||||
UpdatedAt helpers.KontorTime `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 {
|
||||
@@ -31,8 +34,8 @@ func ConvertArtistsToDtos(artists []Artist) []ArtistDTO {
|
||||
for i, artist := range artists {
|
||||
dtos[i] = ArtistDTO{
|
||||
ID: artist.ID,
|
||||
CreatedAt: artist.CreatedAt,
|
||||
UpdatedAt: artist.UpdatedAt,
|
||||
CreatedAt: helpers.KontorTime{Time: artist.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: artist.UpdatedAt},
|
||||
DeletedAt: artist.DeletedAt,
|
||||
Version: artist.Version,
|
||||
Name: artist.Name,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Assignment struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -19,11 +22,27 @@ func (assignment *Assignment) TableName() string {
|
||||
}
|
||||
|
||||
type AssignmentDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_date" binding:"required"`
|
||||
UpdatedAt time.Time `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
ProfileID *string `json:"profile_id" binding:"required"`
|
||||
PermissionID *string `json:"permission_id" binding:"required"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
||||
Version int `json:"version"`
|
||||
ProfileID *string `json:"profile_id"`
|
||||
PermissionID *string `json:"permission_id"`
|
||||
}
|
||||
|
||||
func ConvertAssignmentsToDtos(assignments []Assignment) []AssignmentDTO {
|
||||
dtos := make([]AssignmentDTO, len(assignments))
|
||||
for i, assignment := range assignments {
|
||||
dtos[i] = AssignmentDTO{
|
||||
ID: assignment.ID,
|
||||
CreatedAt: helpers.KontorTime{Time: assignment.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: assignment.UpdatedAt},
|
||||
DeletedAt: assignment.DeletedAt,
|
||||
Version: assignment.Version,
|
||||
ProfileID: assignment.ProfileID,
|
||||
PermissionID: assignment.PermissionID,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Card struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -23,16 +26,16 @@ func (card *Card) TableName() string {
|
||||
}
|
||||
|
||||
type CardDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_date" binding:"required"`
|
||||
UpdatedAt time.Time `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
CardNumber int `json:"card_number" binding:"required"`
|
||||
Year int `json:"year" binding:"required"`
|
||||
CardSetID string `json:"card_set_id" binding:"required"`
|
||||
RoosterID string `json:"rooster_id" binding:"required"`
|
||||
VendorID string `json:"vendor_id" binding:"required"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date" binding:"required"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
CardNumber int `json:"card_number" binding:"required"`
|
||||
Year int `json:"year" binding:"required"`
|
||||
CardSetID string `json:"card_set_id" binding:"required"`
|
||||
RoosterID string `json:"rooster_id" binding:"required"`
|
||||
VendorID string `json:"vendor_id" binding:"required"`
|
||||
}
|
||||
|
||||
func ConvertCardsToDtos(cards []Card) []CardDTO {
|
||||
@@ -40,8 +43,8 @@ func ConvertCardsToDtos(cards []Card) []CardDTO {
|
||||
for i, card := range cards {
|
||||
dtos[i] = CardDTO{
|
||||
ID: card.ID,
|
||||
CreatedAt: card.CreatedAt,
|
||||
UpdatedAt: card.UpdatedAt,
|
||||
CreatedAt: helpers.KontorTime{Time: card.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: card.UpdatedAt},
|
||||
DeletedAt: card.DeletedAt,
|
||||
Version: card.Version,
|
||||
CardNumber: card.CardNumber,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type CardSet struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -21,15 +24,15 @@ func (cardset *CardSet) TableName() string {
|
||||
}
|
||||
|
||||
type CardSetDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_date" binding:"required"`
|
||||
UpdatedAt time.Time `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
ParallelSet bool `json:"parallel_set" binding:"required"`
|
||||
InsertSet bool `json:"insert_set" binding:"required"`
|
||||
VendorID string `json:"vendor_id" binding:"required"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date" binding:"required"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
ParallelSet bool `json:"parallel_set" binding:"required"`
|
||||
InsertSet bool `json:"insert_set" binding:"required"`
|
||||
VendorID string `json:"vendor_id" binding:"required"`
|
||||
}
|
||||
|
||||
func ConvertCardSetsToDtos(cardsets []CardSet) []CardSetDTO {
|
||||
@@ -37,8 +40,8 @@ func ConvertCardSetsToDtos(cardsets []CardSet) []CardSetDTO {
|
||||
for i, cardset := range cardsets {
|
||||
dtos[i] = CardSetDTO{
|
||||
ID: cardset.ID,
|
||||
CreatedAt: cardset.CreatedAt,
|
||||
UpdatedAt: cardset.UpdatedAt,
|
||||
CreatedAt: helpers.KontorTime{Time: cardset.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: cardset.UpdatedAt},
|
||||
DeletedAt: cardset.DeletedAt,
|
||||
Version: cardset.Version,
|
||||
Name: cardset.Name,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -28,16 +29,16 @@ func (comic *Comic) TableName() string {
|
||||
}
|
||||
|
||||
type ComicDTO 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"`
|
||||
PublisherID *string `json:"publisher_id"`
|
||||
CurrentOrder bool `json:"current_order"`
|
||||
Completed bool `json:"completed"`
|
||||
WebLink string `json:"weblink"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
||||
Version int `json:"version"`
|
||||
Title string `json:"title"`
|
||||
PublisherID *string `json:"publisher_id"`
|
||||
CurrentOrder bool `json:"current_order"`
|
||||
Completed bool `json:"completed"`
|
||||
WebLink string `json:"weblink"`
|
||||
}
|
||||
|
||||
func ConvertComicsToDtos(comics []Comic) []ComicDTO {
|
||||
@@ -45,8 +46,8 @@ func ConvertComicsToDtos(comics []Comic) []ComicDTO {
|
||||
for i, comic := range comics {
|
||||
dtos[i] = ComicDTO{
|
||||
ID: comic.ID,
|
||||
CreatedAt: comic.CreatedAt,
|
||||
UpdatedAt: comic.UpdatedAt,
|
||||
CreatedAt: helpers.KontorTime{Time: comic.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: comic.UpdatedAt},
|
||||
DeletedAt: comic.DeletedAt,
|
||||
Version: comic.Version,
|
||||
Title: comic.Title,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ComicWork struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -21,14 +24,14 @@ func (comic_work *ComicWork) TableName() string {
|
||||
}
|
||||
|
||||
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"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
||||
Version int `json:"version"`
|
||||
ComicID *string `json:"comic_id"`
|
||||
ArtistID *string `json:"artist_id"`
|
||||
WorkTypeID *string `json:"work_type_id"`
|
||||
}
|
||||
|
||||
func ConvertComicworksToDtos(comicworks []ComicWork) []ComicworkDTO {
|
||||
@@ -36,8 +39,8 @@ func ConvertComicworksToDtos(comicworks []ComicWork) []ComicworkDTO {
|
||||
for i, comicwork := range comicworks {
|
||||
dtos[i] = ComicworkDTO{
|
||||
ID: comicwork.ID,
|
||||
CreatedAt: comicwork.CreatedAt,
|
||||
UpdatedAt: comicwork.UpdatedAt,
|
||||
CreatedAt: helpers.KontorTime{Time: comicwork.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: comicwork.UpdatedAt},
|
||||
DeletedAt: comicwork.DeletedAt,
|
||||
Version: comicwork.Version,
|
||||
ArtistID: comicwork.ArtistID,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Issue struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -26,16 +29,19 @@ func (issue *Issue) TableName() string {
|
||||
}
|
||||
|
||||
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"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
||||
Version int `json:"version"`
|
||||
IssueNumber string `json:"issue_number"`
|
||||
Title string `json:"title"`
|
||||
PublishedOn helpers.DateOnly `json:"published_on"`
|
||||
InStock bool `json:"in_stock"`
|
||||
IsRead bool `json:"is_read"`
|
||||
ComicID *string `json:"comic_id"`
|
||||
VolumeID *string `json:"volume_id"`
|
||||
StoryArcID *string `json:"story_arc_id"`
|
||||
}
|
||||
|
||||
func ConvertIssuesToDtos(issues []Issue) []IssueDTO {
|
||||
@@ -43,15 +49,18 @@ func ConvertIssuesToDtos(issues []Issue) []IssueDTO {
|
||||
for i, issue := range issues {
|
||||
dtos[i] = IssueDTO{
|
||||
ID: issue.ID,
|
||||
CreatedAt: issue.CreatedAt,
|
||||
UpdatedAt: issue.UpdatedAt,
|
||||
CreatedAt: helpers.KontorTime{Time: issue.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: issue.UpdatedAt},
|
||||
DeletedAt: issue.DeletedAt,
|
||||
Version: issue.Version,
|
||||
IssueNumber: issue.IssueNumber,
|
||||
Title: issue.Title,
|
||||
PublishedOn: issue.PublishedOn,
|
||||
PublishedOn: helpers.DateOnly{Time: issue.PublishedOn},
|
||||
InStock: issue.InStock,
|
||||
IsRead: issue.IsRead,
|
||||
ComicID: issue.ComicID,
|
||||
StoryArcID: issue.StoryArcID,
|
||||
VolumeID: issue.VolumeID,
|
||||
StoryArcID: issue.StoryArcID,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type IssueWork struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -21,14 +24,14 @@ func (issue_work *IssueWork) TableName() string {
|
||||
}
|
||||
|
||||
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"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
||||
Version int `json:"version"`
|
||||
IssueID *string `json:"issue_id"`
|
||||
ArtistID *string `json:"artist_id"`
|
||||
WorkTypeID *string `json:"work_type_id"`
|
||||
}
|
||||
|
||||
func ConvertIssueworksToDtos(issueworks []IssueWork) []IssueworkDTO {
|
||||
@@ -36,8 +39,8 @@ func ConvertIssueworksToDtos(issueworks []IssueWork) []IssueworkDTO {
|
||||
for i, issuework := range issueworks {
|
||||
dtos[i] = IssueworkDTO{
|
||||
ID: issuework.ID,
|
||||
CreatedAt: issuework.CreatedAt,
|
||||
UpdatedAt: issuework.UpdatedAt,
|
||||
CreatedAt: helpers.KontorTime{Time: issuework.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: issuework.UpdatedAt},
|
||||
DeletedAt: issuework.DeletedAt,
|
||||
Version: issuework.Version,
|
||||
ArtistID: issuework.ArtistID,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type MediaFile struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -24,18 +27,18 @@ func (media_file *MediaFile) TableName() string {
|
||||
}
|
||||
|
||||
type MediaFileDTO 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"`
|
||||
Version int `json:"version"`
|
||||
CloudLink string `json:"cloud_link"`
|
||||
FileName string `json:"file_name"`
|
||||
Path string `json:"path"`
|
||||
Review bool `json:"review"`
|
||||
Title string `json:"title"`
|
||||
WebLink string `json:"url"`
|
||||
ShouldDownload bool `json:"should_download"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
||||
Version int `json:"version"`
|
||||
CloudLink string `json:"cloud_link"`
|
||||
FileName string `json:"file_name"`
|
||||
Path string `json:"path"`
|
||||
Review bool `json:"review"`
|
||||
Title string `json:"title"`
|
||||
WebLink string `json:"url"`
|
||||
ShouldDownload bool `json:"should_download"`
|
||||
}
|
||||
|
||||
func ConvertMediaFilesToDtos(media_files []MediaFile) []MediaFileDTO {
|
||||
@@ -43,8 +46,8 @@ func ConvertMediaFilesToDtos(media_files []MediaFile) []MediaFileDTO {
|
||||
for i, media_file := range media_files {
|
||||
dtos[i] = MediaFileDTO{
|
||||
ID: media_file.ID,
|
||||
CreatedAt: media_file.CreatedAt,
|
||||
UpdatedAt: media_file.UpdatedAt,
|
||||
CreatedAt: helpers.KontorTime{Time: media_file.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: media_file.UpdatedAt},
|
||||
DeletedAt: media_file.DeletedAt,
|
||||
Version: media_file.Version,
|
||||
CloudLink: media_file.CloudLink,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type MediaLoFi struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -11,7 +14,7 @@ type MediaLoFi struct {
|
||||
WebLink string `gorm:"column:url" json:"url"`
|
||||
Review bool `gorm:"column:review" json:"review"`
|
||||
ShouldDownload bool `gorm:"column:should_download" json:"should_download"`
|
||||
Title string `gorm:"size:300, column:title" json:"title"`
|
||||
Title string `gorm:"size:300;column:title" json:"title"`
|
||||
FileName string `gorm:"column:file_name" json:"file_name"`
|
||||
}
|
||||
|
||||
@@ -20,16 +23,16 @@ func (media_lofi *MediaLoFi) TableName() string {
|
||||
}
|
||||
|
||||
type MediaLoFiDTO 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"`
|
||||
Version int `json:"version"`
|
||||
WebLink string `json:"url"`
|
||||
Review bool `json:"review"`
|
||||
ShouldDownload bool `json:"should_download"`
|
||||
Title string `json:"title"`
|
||||
FileName string `json:"file_name"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
||||
Version int `json:"version"`
|
||||
FileName string `json:"file_name"`
|
||||
Review bool `json:"review"`
|
||||
ShouldDownload bool `json:"should_download"`
|
||||
Title string `json:"title"`
|
||||
WebLink string `json:"url"`
|
||||
}
|
||||
|
||||
func ConvertMediaLoFisToDtos(media_lofis []MediaLoFi) []MediaLoFiDTO {
|
||||
@@ -37,8 +40,8 @@ func ConvertMediaLoFisToDtos(media_lofis []MediaLoFi) []MediaLoFiDTO {
|
||||
for i, media_lofi := range media_lofis {
|
||||
dtos[i] = MediaLoFiDTO{
|
||||
ID: media_lofi.ID,
|
||||
CreatedAt: media_lofi.CreatedAt,
|
||||
UpdatedAt: media_lofi.UpdatedAt,
|
||||
CreatedAt: helpers.KontorTime{Time: media_lofi.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: media_lofi.UpdatedAt},
|
||||
DeletedAt: media_lofi.DeletedAt,
|
||||
Version: media_lofi.Version,
|
||||
WebLink: media_lofi.WebLink,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type MediaVideo struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -13,7 +16,7 @@ type MediaVideo struct {
|
||||
Path string `gorm:"column:path" json:"path"`
|
||||
Review bool `gorm:"column:review" json:"review"`
|
||||
Title string `gorm:"size:300, column:title" json:"title"`
|
||||
WebLink string `gorm:"uniqueIndex,column:url" json:"url"`
|
||||
WebLink string `gorm:"uniqueIndex;column:url" json:"url"`
|
||||
ShouldDownload bool `gorm:"column:should_download" json:"should_download"`
|
||||
}
|
||||
|
||||
@@ -22,18 +25,18 @@ func (media_video *MediaVideo) TableName() string {
|
||||
}
|
||||
|
||||
type MediaVideoDTO 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"`
|
||||
Version int `json:"version"`
|
||||
CloudLink string `json:"cloud_link"`
|
||||
FileName string `json:"file_name"`
|
||||
Path string `json:"path"`
|
||||
Review bool `json:"review"`
|
||||
Title string `json:"title"`
|
||||
WebLink string `json:"url"`
|
||||
ShouldDownload bool `json:"should_download"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
||||
Version int `json:"version"`
|
||||
CloudLink string `json:"cloud_link"`
|
||||
FileName string `json:"file_name"`
|
||||
Path string `json:"path"`
|
||||
Review bool `json:"review"`
|
||||
Title string `json:"title"`
|
||||
WebLink string `json:"url"`
|
||||
ShouldDownload bool `json:"should_download"`
|
||||
}
|
||||
|
||||
func ConvertMediaVideosToDtos(media_videos []MediaVideo) []MediaVideoDTO {
|
||||
@@ -41,8 +44,8 @@ func ConvertMediaVideosToDtos(media_videos []MediaVideo) []MediaVideoDTO {
|
||||
for i, media_video := range media_videos {
|
||||
dtos[i] = MediaVideoDTO{
|
||||
ID: media_video.ID,
|
||||
CreatedAt: media_video.CreatedAt,
|
||||
UpdatedAt: media_video.UpdatedAt,
|
||||
CreatedAt: helpers.KontorTime{Time: media_video.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: media_video.UpdatedAt},
|
||||
DeletedAt: media_video.DeletedAt,
|
||||
Version: media_video.Version,
|
||||
CloudLink: media_video.CloudLink,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Permission struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -17,10 +20,25 @@ func (permission *Permission) TableName() string {
|
||||
}
|
||||
|
||||
type PermissionDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_date" binding:"required"`
|
||||
UpdatedAt time.Time `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date" binding:"required"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty" binding:"required"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
}
|
||||
|
||||
func ConvertPermissionsToDtos(permissions []Permission) []PermissionDTO {
|
||||
dtos := make([]PermissionDTO, len(permissions))
|
||||
for i, permission := range permissions {
|
||||
dtos[i] = PermissionDTO{
|
||||
ID: permission.ID,
|
||||
CreatedAt: helpers.KontorTime{Time: permission.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: permission.UpdatedAt},
|
||||
DeletedAt: permission.DeletedAt,
|
||||
Version: permission.Version,
|
||||
Name: permission.Name,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Player struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -18,13 +21,13 @@ func (player *Player) TableName() string {
|
||||
}
|
||||
|
||||
type PlayerDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_date" binding:"required"`
|
||||
UpdatedAt time.Time `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
FirstName string `json:"first_name" binding:"required"`
|
||||
LastName string `json:"last_name" binding:"required"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date" binding:"required"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
FirstName string `json:"first_name" binding:"required"`
|
||||
LastName string `json:"last_name" binding:"required"`
|
||||
}
|
||||
|
||||
func ConvertPlayersToDtos(players []Player) []PlayerDTO {
|
||||
@@ -32,8 +35,8 @@ func ConvertPlayersToDtos(players []Player) []PlayerDTO {
|
||||
for i, player := range players {
|
||||
dtos[i] = PlayerDTO{
|
||||
ID: player.ID,
|
||||
CreatedAt: player.CreatedAt,
|
||||
UpdatedAt: player.UpdatedAt,
|
||||
CreatedAt: helpers.KontorTime{Time: player.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: player.UpdatedAt},
|
||||
DeletedAt: player.DeletedAt,
|
||||
Version: player.Version,
|
||||
FirstName: player.FirstName,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Position struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -20,14 +23,14 @@ func (position *Position) TableName() string {
|
||||
}
|
||||
|
||||
type PositionDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_date" binding:"required"`
|
||||
UpdatedAt time.Time `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
ShortName string `json:"short_name" binding:"required"`
|
||||
SportID string `json:"sport_id" binding:"required"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date" binding:"required"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
ShortName string `json:"short_name" binding:"required"`
|
||||
SportID string `json:"sport_id" binding:"required"`
|
||||
}
|
||||
|
||||
func ConvertPositionsToDtos(positions []Position) []PositionDTO {
|
||||
@@ -35,8 +38,8 @@ func ConvertPositionsToDtos(positions []Position) []PositionDTO {
|
||||
for i, position := range positions {
|
||||
dtos[i] = PositionDTO{
|
||||
ID: position.ID,
|
||||
CreatedAt: position.CreatedAt,
|
||||
UpdatedAt: position.UpdatedAt,
|
||||
CreatedAt: helpers.KontorTime{Time: position.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: position.UpdatedAt},
|
||||
DeletedAt: position.DeletedAt,
|
||||
Version: position.Version,
|
||||
Name: position.Name,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Profile struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -35,18 +38,38 @@ func (profile *Profile) GetFullName() string {
|
||||
return full_name
|
||||
}
|
||||
|
||||
type ProfileDTO_ struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_date" binding:"required"`
|
||||
UpdatedAt time.Time `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
First_Name *string `json:"first_name" binding:"required"`
|
||||
Last_Name *string `json:"last_name" binding:"required"`
|
||||
User_Name string `json:"user_name" binding:"required"`
|
||||
Email string `json:"email" binding:"required"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
Enabled bool `json:"enabled" binding:"required"`
|
||||
type ProfileDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date" binding:"required"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
First_Name *string `json:"first_name" binding:"required"`
|
||||
Last_Name *string `json:"last_name" binding:"required"`
|
||||
User_Name string `json:"user_name" binding:"required"`
|
||||
Email string `json:"email" binding:"required"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
Enabled bool `json:"enabled" binding:"required"`
|
||||
}
|
||||
|
||||
func ConvertProfilesToDtos(profiles []Profile) []ProfileDTO {
|
||||
dtos := make([]ProfileDTO, len(profiles))
|
||||
for i, profile := range profiles {
|
||||
dtos[i] = ProfileDTO{
|
||||
ID: profile.ID,
|
||||
CreatedAt: helpers.KontorTime{Time: profile.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: profile.UpdatedAt},
|
||||
DeletedAt: profile.DeletedAt,
|
||||
Version: profile.Version,
|
||||
First_Name: profile.First_Name,
|
||||
Last_Name: profile.Last_Name,
|
||||
User_Name: profile.User_Name,
|
||||
Email: profile.Email,
|
||||
Password: profile.Password,
|
||||
Enabled: profile.Enabled,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
type LoginInput struct {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Publisher struct {
|
||||
ID string `gorm:"type:string;primary_key;"`
|
||||
@@ -21,28 +24,28 @@ func (publisher *Publisher) TableName() string {
|
||||
}
|
||||
|
||||
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,omitempty"`
|
||||
Version int `json:"version"`
|
||||
Name string `json:"name"`
|
||||
WebLink string `json:"weblink"`
|
||||
ParentPublisherID *string `json:"parent_publisher_id"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
||||
Version int `json:"version"`
|
||||
Name string `json:"name"`
|
||||
WebLink string `json:"weblink"`
|
||||
ParentPublisherID *string `json:"parent_publisher_id"`
|
||||
}
|
||||
|
||||
func ConvertPublishersToDtos(publishers []Publisher) []PublisherDTO {
|
||||
dtos := make([]PublisherDTO, len(publishers))
|
||||
for i, comic := range publishers {
|
||||
for i, publisher := range publishers {
|
||||
dtos[i] = PublisherDTO{
|
||||
ID: comic.ID,
|
||||
CreatedAt: comic.CreatedAt,
|
||||
UpdatedAt: comic.UpdatedAt,
|
||||
DeletedAt: comic.DeletedAt,
|
||||
Version: comic.Version,
|
||||
Name: comic.Name,
|
||||
WebLink: comic.WebLink,
|
||||
ParentPublisherID: comic.ParentPublisherID,
|
||||
ID: publisher.ID,
|
||||
CreatedAt: helpers.KontorTime{Time: publisher.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: publisher.UpdatedAt},
|
||||
DeletedAt: publisher.DeletedAt,
|
||||
Version: publisher.Version,
|
||||
Name: publisher.Name,
|
||||
WebLink: publisher.WebLink,
|
||||
ParentPublisherID: publisher.ParentPublisherID,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Rooster struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -23,15 +26,15 @@ func (rooster *Rooster) TableName() string {
|
||||
}
|
||||
|
||||
type RoosterDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_date" binding:"required"`
|
||||
UpdatedAt time.Time `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
Year int `json:"year" binding:"required"`
|
||||
TeamID string `json:"team_id" binding:"required"`
|
||||
PlayerID string `json:"player_id" binding:"required"`
|
||||
PositionID string `json:"position_id" binding:"required"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date" binding:"required"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
Year int `json:"year" binding:"required"`
|
||||
TeamID string `json:"team_id" binding:"required"`
|
||||
PlayerID string `json:"player_id" binding:"required"`
|
||||
PositionID string `json:"position_id" binding:"required"`
|
||||
}
|
||||
|
||||
func ConvertRoostersToDtos(roosters []Rooster) []RoosterDTO {
|
||||
@@ -39,8 +42,8 @@ func ConvertRoostersToDtos(roosters []Rooster) []RoosterDTO {
|
||||
for i, rooster := range roosters {
|
||||
dtos[i] = RoosterDTO{
|
||||
ID: rooster.ID,
|
||||
CreatedAt: rooster.CreatedAt,
|
||||
UpdatedAt: rooster.UpdatedAt,
|
||||
CreatedAt: helpers.KontorTime{Time: rooster.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: rooster.UpdatedAt},
|
||||
DeletedAt: rooster.DeletedAt,
|
||||
Version: rooster.Version,
|
||||
Year: rooster.Year,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Sport struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -16,12 +19,12 @@ func (sport *Sport) TableName() string {
|
||||
}
|
||||
|
||||
type SportDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_date" binding:"required"`
|
||||
UpdatedAt time.Time `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date" binding:"required"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
}
|
||||
|
||||
func ConvertSportsToDtos(sports []Sport) []SportDTO {
|
||||
@@ -29,8 +32,8 @@ func ConvertSportsToDtos(sports []Sport) []SportDTO {
|
||||
for i, sport := range sports {
|
||||
dtos[i] = SportDTO{
|
||||
ID: sport.ID,
|
||||
CreatedAt: sport.CreatedAt,
|
||||
UpdatedAt: sport.UpdatedAt,
|
||||
CreatedAt: helpers.KontorTime{Time: sport.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: sport.UpdatedAt},
|
||||
DeletedAt: sport.DeletedAt,
|
||||
Version: sport.Version,
|
||||
Name: sport.Name,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type StoryArc struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -20,14 +23,14 @@ func (story_arc *StoryArc) TableName() string {
|
||||
}
|
||||
|
||||
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"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date"`
|
||||
UpdatedAt helpers.KontorTime `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 {
|
||||
@@ -35,8 +38,8 @@ func ConvertStoryArcsToDtos(storyarcs []StoryArc) []StoryArcDTO {
|
||||
for i, storyarc := range storyarcs {
|
||||
dtos[i] = StoryArcDTO{
|
||||
ID: storyarc.ID,
|
||||
CreatedAt: storyarc.CreatedAt,
|
||||
UpdatedAt: storyarc.UpdatedAt,
|
||||
CreatedAt: helpers.KontorTime{Time: storyarc.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: storyarc.UpdatedAt},
|
||||
DeletedAt: storyarc.DeletedAt,
|
||||
Version: storyarc.Version,
|
||||
Name: storyarc.Name,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Team struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -20,14 +23,14 @@ func (team *Team) TableName() string {
|
||||
}
|
||||
|
||||
type TeamDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_date" binding:"required"`
|
||||
UpdatedAt time.Time `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
ShortName string `json:"short_name" binding:"required"`
|
||||
SportID string `json:"sport_id" binding:"required"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date" binding:"required"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
ShortName string `json:"short_name" binding:"required"`
|
||||
SportID string `json:"sport_id" binding:"required"`
|
||||
}
|
||||
|
||||
func ConvertTeamsToDtos(teams []Team) []TeamDTO {
|
||||
@@ -35,8 +38,8 @@ func ConvertTeamsToDtos(teams []Team) []TeamDTO {
|
||||
for i, team := range teams {
|
||||
dtos[i] = TeamDTO{
|
||||
ID: team.ID,
|
||||
CreatedAt: team.CreatedAt,
|
||||
UpdatedAt: team.UpdatedAt,
|
||||
CreatedAt: helpers.KontorTime{Time: team.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: team.UpdatedAt},
|
||||
DeletedAt: team.DeletedAt,
|
||||
Version: team.Version,
|
||||
Name: team.Name,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Token struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -21,11 +24,26 @@ func (token *Token) TableName() string {
|
||||
}
|
||||
|
||||
type TokenDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_date" binding:"required"`
|
||||
UpdatedAt time.Time `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
Token string `json:"token" binding:"required"`
|
||||
ProfileID *string `json:"profile_id" binding:"required"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date.omitempty"`
|
||||
Version int `json:"version"`
|
||||
Token string `json:"token"`
|
||||
ProfileID *string `json:"profile_id"`
|
||||
}
|
||||
|
||||
func ConvertTokensToDtos(tokens []Token) []TokenDTO {
|
||||
dtos := make([]TokenDTO, len(tokens))
|
||||
for i, token := range tokens {
|
||||
dtos[i] = TokenDTO{
|
||||
ID: token.ID,
|
||||
CreatedAt: helpers.KontorTime{Time: token.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: token.UpdatedAt},
|
||||
DeletedAt: token.DeletedAt,
|
||||
Version: token.Version,
|
||||
ProfileID: token.ProfileID,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
@@ -1,20 +1,53 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type TradePaperback 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"`
|
||||
IssueStart int `gorm:"column:issue_start" json:"issue_start"`
|
||||
IssueEnd int `gorm:"column:issue_end" json:"issue_end"`
|
||||
ComicID *string `gorm:"column:comic_id" json:"comic_id"`
|
||||
Comic *Comic `gorm:"foreignKey:ComicID"`
|
||||
Name string `gorm:"uniqueIndex" json:"name"`
|
||||
IssueStart int `gorm:"column:issue_start" json:"issue_start"`
|
||||
IssueEnd int `gorm:"column:issue_end" json:"issue_end"`
|
||||
ComicID *string `gorm:"column:comic_id" json:"comic_id"`
|
||||
Comic *Comic `gorm:"foreignKey:ComicID" json:"comic"`
|
||||
}
|
||||
|
||||
func (trade_paperback *TradePaperback) TableName() string {
|
||||
return "trade_paperback"
|
||||
}
|
||||
|
||||
type TradePaperbackDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date" binding:"required"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
IssueStart int `json:"issue_start"`
|
||||
IssueEnd int `json:"issue_end"`
|
||||
ComicID *string `json:"comic_id"`
|
||||
}
|
||||
|
||||
func ConvertTradePaperbacksToDtos(tradepaperbacks []TradePaperback) []TradePaperbackDTO {
|
||||
dtos := make([]TradePaperbackDTO, len(tradepaperbacks))
|
||||
for i, tradepaperback := range tradepaperbacks {
|
||||
dtos[i] = TradePaperbackDTO{
|
||||
ID: tradepaperback.ID,
|
||||
CreatedAt: helpers.KontorTime{Time: tradepaperback.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: tradepaperback.UpdatedAt},
|
||||
DeletedAt: tradepaperback.DeletedAt,
|
||||
Version: tradepaperback.Version,
|
||||
Name: tradepaperback.Name,
|
||||
IssueStart: tradepaperback.IssueStart,
|
||||
IssueEnd: tradepaperback.IssueEnd,
|
||||
ComicID: tradepaperback.ComicID,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Vendor struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -18,12 +21,12 @@ func (vendor *Vendor) TableName() string {
|
||||
}
|
||||
|
||||
type VendorDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_date" binding:"required"`
|
||||
UpdatedAt time.Time `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date" binding:"required"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
}
|
||||
|
||||
func ConvertVendorsToDtos(vendors []Vendor) []VendorDTO {
|
||||
@@ -31,8 +34,8 @@ func ConvertVendorsToDtos(vendors []Vendor) []VendorDTO {
|
||||
for i, vendor := range vendors {
|
||||
dtos[i] = VendorDTO{
|
||||
ID: vendor.ID,
|
||||
CreatedAt: vendor.CreatedAt,
|
||||
UpdatedAt: vendor.UpdatedAt,
|
||||
CreatedAt: helpers.KontorTime{Time: vendor.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: vendor.UpdatedAt},
|
||||
DeletedAt: vendor.DeletedAt,
|
||||
Version: vendor.Version,
|
||||
Name: vendor.Name,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Volume struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -18,13 +21,13 @@ func (volume *Volume) TableName() string {
|
||||
}
|
||||
|
||||
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"`
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date"`
|
||||
UpdatedAt helpers.KontorTime `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 {
|
||||
@@ -32,8 +35,8 @@ func ConvertVolumesToDtos(volumes []Volume) []VolumeDTO {
|
||||
for i, volume := range volumes {
|
||||
dtos[i] = VolumeDTO{
|
||||
ID: volume.ID,
|
||||
CreatedAt: volume.CreatedAt,
|
||||
UpdatedAt: volume.UpdatedAt,
|
||||
CreatedAt: helpers.KontorTime{Time: volume.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: volume.UpdatedAt},
|
||||
DeletedAt: volume.DeletedAt,
|
||||
Version: volume.Version,
|
||||
Name: volume.Name,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type WorkType struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
@@ -16,12 +19,12 @@ func (worktype *WorkType) TableName() string {
|
||||
}
|
||||
|
||||
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"`
|
||||
ID string `json:"id"`
|
||||
CreatedAt helpers.KontorTime `json:"created_date"`
|
||||
UpdatedAt helpers.KontorTime `json:"last_modified_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
||||
Version int `json:"version"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func ConvertWorkTypesToDtos(worktypes []WorkType) []WorkTypeDTO {
|
||||
@@ -29,8 +32,8 @@ func ConvertWorkTypesToDtos(worktypes []WorkType) []WorkTypeDTO {
|
||||
for i, worktype := range worktypes {
|
||||
dtos[i] = WorkTypeDTO{
|
||||
ID: worktype.ID,
|
||||
CreatedAt: worktype.CreatedAt,
|
||||
UpdatedAt: worktype.UpdatedAt,
|
||||
CreatedAt: helpers.KontorTime{Time: worktype.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: worktype.UpdatedAt},
|
||||
DeletedAt: worktype.DeletedAt,
|
||||
Version: worktype.Version,
|
||||
Name: worktype.Name,
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type AssignmentRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewAssignmentRepository(db *gorm.DB) *AssignmentRepository {
|
||||
repository := &AssignmentRepository{db: db}
|
||||
return repository
|
||||
}
|
||||
|
||||
func (repository *AssignmentRepository) FindAll(context context.Context) ([]models.Assignment, error) {
|
||||
var assignments []models.Assignment
|
||||
|
||||
result := repository.db.Find(&assignments)
|
||||
slog.Info("AssignmentRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return assignments, nil
|
||||
}
|
||||
|
||||
func (repository *AssignmentRepository) GetById(context context.Context, id string) (models.Assignment, error) {
|
||||
var assignment = models.Assignment{ID: id}
|
||||
slog.Info("AssignmentRepository#GetById", "id", id)
|
||||
result := repository.db.First(&assignment)
|
||||
if result.Error != nil {
|
||||
slog.Info("AssignmentRepository#GetById", "error", result.Error.Error())
|
||||
}
|
||||
return assignment, result.Error
|
||||
}
|
||||
@@ -21,7 +21,7 @@ func (repository *IssueworkRepository) FindAll(context context.Context) ([]model
|
||||
var issueworks []models.IssueWork
|
||||
|
||||
result := repository.db.Find(&issueworks)
|
||||
slog.Info("IssueRepository#FindAll", "count", result.RowsAffected)
|
||||
slog.Info("IssueworkRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return issueworks, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type MediaVideoRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewMediaVideoRepository(db *gorm.DB) *MediaVideoRepository {
|
||||
repo := &MediaVideoRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *MediaVideoRepository) FindAll(context context.Context) ([]models.MediaVideo, error) {
|
||||
var videos []models.MediaVideo
|
||||
|
||||
result := repository.db.Find(&videos)
|
||||
slog.Info("MediaVideoRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return videos, nil
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type TokenRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewTokenRepository(db *gorm.DB) *TokenRepository {
|
||||
repository := &TokenRepository{db: db}
|
||||
return repository
|
||||
}
|
||||
|
||||
func (repository *TokenRepository) FindAll(context context.Context) ([]models.Token, error) {
|
||||
var tokens []models.Token
|
||||
|
||||
result := repository.db.Find(&tokens)
|
||||
slog.Info("TokenRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return tokens, nil
|
||||
}
|
||||
|
||||
func (repository *TokenRepository) GetById(context context.Context, id string) (models.Token, error) {
|
||||
var token = models.Token{ID: id}
|
||||
slog.Info("TokenRepository#GetById", "id", id)
|
||||
result := repository.db.First(&token)
|
||||
if result.Error != nil {
|
||||
slog.Info("TokenRepository#GetById", "error", result.Error.Error())
|
||||
}
|
||||
return token, result.Error
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type TradePaperbackRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewTradePaperbackRepository(db *gorm.DB) *TradePaperbackRepository {
|
||||
repo := &TradePaperbackRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *TradePaperbackRepository) FindAll(context context.Context) ([]models.TradePaperback, error) {
|
||||
var tradepaperbacks []models.TradePaperback
|
||||
|
||||
result := repository.db.Find(&tradepaperbacks)
|
||||
slog.Info("TradePaperbackRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return tradepaperbacks, nil
|
||||
}
|
||||
@@ -21,7 +21,7 @@ func (repository *WorkTypeRepository) FindAll(context context.Context) ([]models
|
||||
var workTypes []models.WorkType
|
||||
|
||||
result := repository.db.Find(&workTypes)
|
||||
slog.Info("VolumeRepository#FindAll", "count", result.RowsAffected)
|
||||
slog.Info("WorkTypeRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return workTypes, nil
|
||||
}
|
||||
|
||||
@@ -70,7 +70,10 @@ func New(admin *handlers.AdminHandler, comics *handlers.ComicsHandler, media *ha
|
||||
{
|
||||
secured := v1.Group("")
|
||||
secured.Use(middleware.JWT(admin.Secret))
|
||||
secured.GET("admin/permissions", admin.PermissionHandler.List)
|
||||
secured.GET("user/profiles", admin.ProfileHandler.List)
|
||||
secured.GET("user/permissions", admin.PermissionHandler.List)
|
||||
secured.GET("user/assignments", admin.AssignmentHandler.List)
|
||||
secured.GET("user/tokens", admin.TokenHandler.List)
|
||||
secured.GET("tysc/sports", tysc.SportHandler.List)
|
||||
secured.GET("tysc/sports/:id", tysc.SportHandler.Get)
|
||||
secured.GET("tysc/players", tysc.PlayerHandler.List)
|
||||
@@ -84,12 +87,14 @@ func New(admin *handlers.AdminHandler, comics *handlers.ComicsHandler, media *ha
|
||||
secured.GET("/comics/publishers", comics.PublisherHandler.List)
|
||||
secured.GET("/comics/artists", comics.ArtistHandler.List)
|
||||
secured.GET("/comics/issues", comics.IssueHandler.List)
|
||||
secured.GET("/comics/tradepaperbacks", comics.TradePaperbackHandler.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/videos", media.MediaVideoHandler.List)
|
||||
secured.GET("/media/lofis", media.MediaLoFiHandler.List)
|
||||
secured.GET("/media/actors", media.MediaActorHandler.List)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"kontor-api-gin/internal/repository"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
type AssignmentService struct {
|
||||
repository *repository.AssignmentRepository
|
||||
}
|
||||
|
||||
func NewAssignmentService(repo *repository.AssignmentRepository) *AssignmentService {
|
||||
service := &AssignmentService{repository: repo}
|
||||
return service
|
||||
}
|
||||
|
||||
func (service *AssignmentService) List(context context.Context) ([]models.Assignment, error) {
|
||||
slog.Info("AssignmentService#List")
|
||||
return service.repository.FindAll(context)
|
||||
}
|
||||
|
||||
func (service *AssignmentService) Get(context context.Context, id string) (models.Assignment, error) {
|
||||
slog.Info("AssignmentService#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 MediaVideoService struct {
|
||||
repository *repository.MediaVideoRepository
|
||||
}
|
||||
|
||||
func NewMediaVideoService(repo *repository.MediaVideoRepository) *MediaVideoService {
|
||||
service := &MediaVideoService{repository: repo}
|
||||
return service
|
||||
}
|
||||
|
||||
func (service *MediaVideoService) List(context context.Context) ([]models.MediaVideo, error) {
|
||||
slog.Info("MediaVideoService#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 ProfileService struct {
|
||||
repository *repository.ProfileRepository
|
||||
}
|
||||
|
||||
func NewProfileService(repo *repository.ProfileRepository) *ProfileService {
|
||||
service := &ProfileService{repository: repo}
|
||||
return service
|
||||
}
|
||||
|
||||
func (service *ProfileService) List(context context.Context) ([]models.Profile, error) {
|
||||
slog.Info("ProfileService#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 TokenService struct {
|
||||
repository *repository.TokenRepository
|
||||
}
|
||||
|
||||
func NewTokenService(repo *repository.TokenRepository) *TokenService {
|
||||
service := &TokenService{repository: repo}
|
||||
return service
|
||||
}
|
||||
|
||||
func (service *TokenService) List(context context.Context) ([]models.Token, error) {
|
||||
slog.Info("TokenService#List")
|
||||
return service.repository.FindAll(context)
|
||||
}
|
||||
|
||||
func (service *TokenService) Get(context context.Context, id string) (models.Token, error) {
|
||||
slog.Info("TokenService#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 TradePaperbackService struct {
|
||||
repository *repository.TradePaperbackRepository
|
||||
}
|
||||
|
||||
func NewTradePaperbackService(repo *repository.TradePaperbackRepository) *TradePaperbackService {
|
||||
service := &TradePaperbackService{repository: repo}
|
||||
return service
|
||||
}
|
||||
|
||||
func (service *TradePaperbackService) List(context context.Context) ([]models.TradePaperback, error) {
|
||||
slog.Info("TradePaperbackService#List")
|
||||
return service.repository.FindAll(context)
|
||||
}
|
||||
Reference in New Issue
Block a user