This commit is contained in:
+1
-2
@@ -15,6 +15,7 @@ require (
|
|||||||
golang.org/x/time v0.16.0
|
golang.org/x/time v0.16.0
|
||||||
gorm.io/driver/postgres v1.6.3
|
gorm.io/driver/postgres v1.6.3
|
||||||
gorm.io/gorm v1.31.2
|
gorm.io/gorm v1.31.2
|
||||||
|
resty.dev/v3 v3.0.0-rc.4
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
@@ -66,6 +67,4 @@ require (
|
|||||||
golang.org/x/sys v0.48.0 // indirect
|
golang.org/x/sys v0.48.0 // indirect
|
||||||
golang.org/x/text v0.42.0 // indirect
|
golang.org/x/text v0.42.0 // indirect
|
||||||
google.golang.org/protobuf v1.36.12 // indirect
|
google.golang.org/protobuf v1.36.12 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
|
||||||
resty.dev/v3 v3.0.0-rc.4 // indirect
|
|
||||||
)
|
)
|
||||||
|
|||||||
+6
-12
@@ -18,16 +18,12 @@ github.com/gabriel-vasile/mimetype v1.4.15 h1:05iP/CYtZ/w455R/KZM6rZ5ieAdh99UPtd
|
|||||||
github.com/gabriel-vasile/mimetype v1.4.15/go.mod h1:azpTcoLcDZRNgFou5j+APrqQx9HqVPWa6ijYQIIVswQ=
|
github.com/gabriel-vasile/mimetype v1.4.15/go.mod h1:azpTcoLcDZRNgFou5j+APrqQx9HqVPWa6ijYQIIVswQ=
|
||||||
github.com/gin-contrib/cors v1.7.2 h1:oLDHxdg8W/XDoN/8zamqk/Drgt4oVZDvaV0YmvVICQw=
|
github.com/gin-contrib/cors v1.7.2 h1:oLDHxdg8W/XDoN/8zamqk/Drgt4oVZDvaV0YmvVICQw=
|
||||||
github.com/gin-contrib/cors v1.7.2/go.mod h1:SUJVARKgQ40dmrzgXEVxj2m7Ig1v1qIboQkPDTQ9t2E=
|
github.com/gin-contrib/cors v1.7.2/go.mod h1:SUJVARKgQ40dmrzgXEVxj2m7Ig1v1qIboQkPDTQ9t2E=
|
||||||
github.com/gin-contrib/sessions v1.0.2 h1:UaIjUvTH1cMeOdj3in6dl+Xb6It8RiKRF9Z1anbUyCA=
|
|
||||||
github.com/gin-contrib/sessions v1.0.2/go.mod h1:KxKxWqWP5LJVDCInulOl4WbLzK2KSPlLesfZ66wRvMs=
|
|
||||||
github.com/gin-contrib/sessions v1.1.2 h1:utWRqOHT/kbqxxqF/mtutV9wfGLi1+uu5YuvWUhj/Ow=
|
github.com/gin-contrib/sessions v1.1.2 h1:utWRqOHT/kbqxxqF/mtutV9wfGLi1+uu5YuvWUhj/Ow=
|
||||||
github.com/gin-contrib/sessions v1.1.2/go.mod h1:qRxYwA/TYJw0wv28oFzs4gY/8G8z69id862SNgX9Gmw=
|
github.com/gin-contrib/sessions v1.1.2/go.mod h1:qRxYwA/TYJw0wv28oFzs4gY/8G8z69id862SNgX9Gmw=
|
||||||
github.com/gin-contrib/slog v1.1.0 h1:K9MVNrETT6r/C3u2Aheer/gxwVeVqrGL0hXlsmv3fm4=
|
github.com/gin-contrib/slog v1.1.0 h1:K9MVNrETT6r/C3u2Aheer/gxwVeVqrGL0hXlsmv3fm4=
|
||||||
github.com/gin-contrib/slog v1.1.0/go.mod h1:PvNXQVXcVOAaaiJR84LV1/xlQHIaXi9ygEXyBkmjdkY=
|
github.com/gin-contrib/slog v1.1.0/go.mod h1:PvNXQVXcVOAaaiJR84LV1/xlQHIaXi9ygEXyBkmjdkY=
|
||||||
github.com/gin-contrib/sse v1.1.2 h1:MU2fgl1RrdYTMcgJLtz2kJF+vPg3xrqaaKfUUU18tCo=
|
github.com/gin-contrib/sse v1.1.2 h1:MU2fgl1RrdYTMcgJLtz2kJF+vPg3xrqaaKfUUU18tCo=
|
||||||
github.com/gin-contrib/sse v1.1.2/go.mod h1:QXzuVkA0YO7o/gun03UI1Q+FTI8ZV/n5t03kIQAI89s=
|
github.com/gin-contrib/sse v1.1.2/go.mod h1:QXzuVkA0YO7o/gun03UI1Q+FTI8ZV/n5t03kIQAI89s=
|
||||||
github.com/gin-gonic/gin v1.10.1 h1:T0ujvqyCSqRopADpgPgiTT63DUQVSfojyME59Ei63pQ=
|
|
||||||
github.com/gin-gonic/gin v1.10.1/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
|
||||||
github.com/gin-gonic/gin v1.12.0 h1:b3YAbrZtnf8N//yjKeU2+MQsh2mY5htkZidOM7O0wG8=
|
github.com/gin-gonic/gin v1.12.0 h1:b3YAbrZtnf8N//yjKeU2+MQsh2mY5htkZidOM7O0wG8=
|
||||||
github.com/gin-gonic/gin v1.12.0/go.mod h1:VxccKfsSllpKshkBWgVgRniFFAzFb9csfngsqANjnLc=
|
github.com/gin-gonic/gin v1.12.0/go.mod h1:VxccKfsSllpKshkBWgVgRniFFAzFb9csfngsqANjnLc=
|
||||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||||
@@ -36,8 +32,6 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
|
|||||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||||
github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4Bx7ia+JlgcnOao=
|
|
||||||
github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
|
|
||||||
github.com/go-playground/validator/v10 v10.30.3 h1:4MU6YkEwx7GbcPJOZxrtbu+QfF3pJLJuaYTeAH0DYy8=
|
github.com/go-playground/validator/v10 v10.30.3 h1:4MU6YkEwx7GbcPJOZxrtbu+QfF3pJLJuaYTeAH0DYy8=
|
||||||
github.com/go-playground/validator/v10 v10.30.3/go.mod h1:4Axh7oCNGcoGkqLoE4YWt6n20mcEIsPRlB7vPk3lpyc=
|
github.com/go-playground/validator/v10 v10.30.3/go.mod h1:4Axh7oCNGcoGkqLoE4YWt6n20mcEIsPRlB7vPk3lpyc=
|
||||||
github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro=
|
github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro=
|
||||||
@@ -97,12 +91,14 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY
|
|||||||
github.com/pelletier/go-toml/v2 v2.4.3 h1:GTRvJQutkOSftxIFD5xw9aepkYNuPWmVJpffdDPYVpY=
|
github.com/pelletier/go-toml/v2 v2.4.3 h1:GTRvJQutkOSftxIFD5xw9aepkYNuPWmVJpffdDPYVpY=
|
||||||
github.com/pelletier/go-toml/v2 v2.4.3/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
github.com/pelletier/go-toml/v2 v2.4.3/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/quic-go/go-ossfuzz-seeds v0.1.0 h1:APacT+iIaNF6fd8AGEiN3bT/Jtkd2jz4v4TzM7MFjy0=
|
||||||
|
github.com/quic-go/go-ossfuzz-seeds v0.1.0/go.mod h1:3IOHRbJIc+L6YKMwfDtJAM9Vj9k0YY4muhuyUYk5tbk=
|
||||||
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
|
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
|
||||||
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
|
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
|
||||||
github.com/quic-go/quic-go v0.60.0 h1:xcQioE8OM66UQLeUMHltK1CCcOu3JbVB4JAQdDQSB+0=
|
github.com/quic-go/quic-go v0.60.0 h1:xcQioE8OM66UQLeUMHltK1CCcOu3JbVB4JAQdDQSB+0=
|
||||||
github.com/quic-go/quic-go v0.60.0/go.mod h1:wpKpjmPpftl30sL6pFh7REVpjbcCVy4zt2vDyK1TuJk=
|
github.com/quic-go/quic-go v0.60.0/go.mod h1:wpKpjmPpftl30sL6pFh7REVpjbcCVy4zt2vDyK1TuJk=
|
||||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/sagikazarmark/locafero v0.12.0 h1:/NQhBAkUb4+fH1jivKHWusDYFjMOOKU88eegjfxfHb4=
|
github.com/sagikazarmark/locafero v0.12.0 h1:/NQhBAkUb4+fH1jivKHWusDYFjMOOKU88eegjfxfHb4=
|
||||||
github.com/sagikazarmark/locafero v0.12.0/go.mod h1:sZh36u/YSZ918v0Io+U9ogLYQJ9tLLBmM4eneO6WwsI=
|
github.com/sagikazarmark/locafero v0.12.0/go.mod h1:sZh36u/YSZ918v0Io+U9ogLYQJ9tLLBmM4eneO6WwsI=
|
||||||
@@ -135,9 +131,10 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS
|
|||||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||||
github.com/ugorji/go/codec v1.3.2 h1:zkEASHHyEClGeURfgNT9PJZVfAbs9oEX9QXggwWNJbc=
|
github.com/ugorji/go/codec v1.3.2 h1:zkEASHHyEClGeURfgNT9PJZVfAbs9oEX9QXggwWNJbc=
|
||||||
github.com/ugorji/go/codec v1.3.2/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
github.com/ugorji/go/codec v1.3.2/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
||||||
go.mongodb.org/mongo-driver v1.17.9 h1:IexDdCuuNJ3BHrELgBlyaH9p60JXAvdzWR128q+U5tU=
|
|
||||||
go.mongodb.org/mongo-driver/v2 v2.8.0 h1:CxWDGQYY8QQwNjAl/aq2sfWakdnWZynnqJ9F4DhHbP8=
|
go.mongodb.org/mongo-driver/v2 v2.8.0 h1:CxWDGQYY8QQwNjAl/aq2sfWakdnWZynnqJ9F4DhHbP8=
|
||||||
go.mongodb.org/mongo-driver/v2 v2.8.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0=
|
go.mongodb.org/mongo-driver/v2 v2.8.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0=
|
||||||
|
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
||||||
|
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
||||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||||
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
|
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
|
||||||
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
|
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
|
||||||
@@ -158,10 +155,7 @@ golang.org/x/time v0.16.0/go.mod h1:rVKOqvZeKvrDKTQiAHJ7wmwP0RzleSphoEA9RcdLA0s=
|
|||||||
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
|
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
|
||||||
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gorm.io/driver/postgres v1.6.3 h1:bAn6O2pUa8LtpWEvL5NFU4+52Tfx8Ut7IVaIacCLcI0=
|
gorm.io/driver/postgres v1.6.3 h1:bAn6O2pUa8LtpWEvL5NFU4+52Tfx8Ut7IVaIacCLcI0=
|
||||||
gorm.io/driver/postgres v1.6.3/go.mod h1:0c4fQA44XhOklXDkgtuKqysHCycTa5i9e3EIpDGCwXk=
|
gorm.io/driver/postgres v1.6.3/go.mod h1:0c4fQA44XhOklXDkgtuKqysHCycTa5i9e3EIpDGCwXk=
|
||||||
|
|||||||
@@ -19,96 +19,85 @@ var exportCmd = &cobra.Command{
|
|||||||
slog.Info("export kontor")
|
slog.Info("export kontor")
|
||||||
slog.Info("Verbosity level", "level", verbose)
|
slog.Info("Verbosity level", "level", verbose)
|
||||||
var login LoginResponse
|
var login LoginResponse
|
||||||
|
|
||||||
client := resty.New()
|
client := resty.New()
|
||||||
_, err := client.R().
|
PostJSON(client, "http://127.0.0.1:8550/api/login", &login)
|
||||||
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)
|
|
||||||
|
|
||||||
type ExportData struct {
|
type ExportData struct {
|
||||||
Sport []models.SportDTO `json:"sport"`
|
Sport []models.SportDTO `json:"sport"`
|
||||||
Player []models.PlayerDTO `json:"player"`
|
Player []models.PlayerDTO `json:"player"`
|
||||||
Team []models.TeamDTO `json:"team"`
|
Team []models.TeamDTO `json:"team"`
|
||||||
Position []models.PositionDTO `json:"field_position"`
|
Position []models.PositionDTO `json:"field_position"`
|
||||||
Rooster []models.RoosterDTO `json:"rooster"`
|
Rooster []models.RoosterDTO `json:"rooster"`
|
||||||
Vendor []models.VendorDTO `json:"vendor"`
|
Vendor []models.VendorDTO `json:"vendor"`
|
||||||
CardSet []models.CardSetDTO `json:"card_set"`
|
CardSet []models.CardSetDTO `json:"card_set"`
|
||||||
Card []models.CardDTO `json:"card"`
|
Card []models.CardDTO `json:"card"`
|
||||||
Comic []models.ComicDTO `json:"comic"`
|
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
|
var (
|
||||||
_, err = client.R().
|
sports []models.SportDTO
|
||||||
SetAuthToken(login.Token).
|
players []models.PlayerDTO
|
||||||
SetHeader("Accept", "application/json").
|
teams []models.TeamDTO
|
||||||
SetResult(&sports).
|
positions []models.PositionDTO
|
||||||
Get("http://127.0.0.1:8550/api/v1/tysc/sports")
|
roosters []models.RoosterDTO
|
||||||
if err != nil {
|
vendors []models.VendorDTO
|
||||||
slog.Info("sports", "error", err.Error())
|
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
|
registry := map[string]any{
|
||||||
_, err = client.R().
|
"http://127.0.0.1:8550/api/v1/tysc/sports": &sports,
|
||||||
SetAuthToken(login.Token).
|
"http://127.0.0.1:8550/api/v1/tysc/players": &players,
|
||||||
SetHeader("Accept", "application/json").
|
"http://127.0.0.1:8550/api/v1/tysc/teams": &teams,
|
||||||
SetResult(&players).
|
"http://127.0.0.1:8550/api/v1/tysc/positions": &positions,
|
||||||
Get("http://127.0.0.1:8550/api/v1/tysc/players")
|
"http://127.0.0.1:8550/api/v1/tysc/roosters": &roosters,
|
||||||
if err != nil {
|
"http://127.0.0.1:8550/api/v1/tysc/vendors": &vendors,
|
||||||
slog.Info("players", "error", err.Error())
|
"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,
|
||||||
}
|
}
|
||||||
|
for url, value := range registry {
|
||||||
var teams []models.TeamDTO
|
GetJSON(client, login.Token, url, value)
|
||||||
_, 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())
|
|
||||||
}
|
}
|
||||||
|
export := ExportData{
|
||||||
var positions []models.PositionDTO
|
Sport: sports,
|
||||||
_, err = client.R().
|
Player: players,
|
||||||
SetAuthToken(login.Token).
|
Team: teams,
|
||||||
SetHeader("Accept", "application/json").
|
Position: positions,
|
||||||
SetResult(&positions).
|
Rooster: roosters,
|
||||||
Get("http://127.0.0.1:8550/api/v1/tysc/positions")
|
Vendor: vendors,
|
||||||
if err != nil {
|
CardSet: cardsets,
|
||||||
slog.Info("teams", "error", err.Error())
|
Card: cards,
|
||||||
}
|
Artist: artists,
|
||||||
|
Publisher: publishers,
|
||||||
var comics []models.ComicDTO
|
Worktype: worktypes,
|
||||||
_, err = client.R().
|
Comic: comics,
|
||||||
SetAuthToken(login.Token).
|
Volume: volumes,
|
||||||
SetHeader("Accept", "application/json").
|
StoryArc: storyarcs,
|
||||||
SetResult(&comics).
|
Issue: issues,
|
||||||
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,
|
|
||||||
}
|
}
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
jsonData, err := json.MarshalIndent(data, "", " ")
|
jsonData, err := json.MarshalIndent(export, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Info("JSON MarshalIndent failed", "Error:", err)
|
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() {
|
func init() {
|
||||||
rootCmd.AddCommand(exportCmd)
|
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 {
|
type ComicsHandler struct {
|
||||||
ComicHandler *ComicHandler
|
ComicHandler *ComicHandler
|
||||||
PublisherHandler *PublisherHandler
|
PublisherHandler *PublisherHandler
|
||||||
// ArtistHandler *ArtistHandler
|
ArtistHandler *ArtistHandler
|
||||||
// IssueHandler *IssueHandler
|
IssueHandler *IssueHandler
|
||||||
// WorktypeHandler *WorktypeHandler
|
WorkTypeHandler *WorkTypeHandler
|
||||||
// VolumeHandler *VolumeHandler
|
VolumeHandler *VolumeHandler
|
||||||
// StoryarcHandler *StoryarcHandler
|
StoryArcHandler *StoryArcHandler
|
||||||
// ComicworkHandler *ComicworkHandler
|
ComicworkHandler *ComicworkHandler
|
||||||
// IssueworkHandler *IssueworkHandler
|
IssueworkHandler *IssueworkHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewComicsHandler(db *gorm.DB) *ComicsHandler {
|
func NewComicsHandler(db *gorm.DB) *ComicsHandler {
|
||||||
comicsHandler := &ComicsHandler{
|
comicsHandler := &ComicsHandler{
|
||||||
ComicHandler: &ComicHandler{Service: service.NewComicService(repository.NewComicRepository(db))},
|
ComicHandler: NewComicHandler(db),
|
||||||
PublisherHandler: &PublisherHandler{Service: service.NewPublisherService(repository.NewPublisherRepository(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
|
return comicsHandler
|
||||||
}
|
}
|
||||||
@@ -36,6 +43,11 @@ type ComicHandler struct {
|
|||||||
Service *service.ComicService
|
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) {
|
func (handler *ComicHandler) List(c *gin.Context) {
|
||||||
comics, err := handler.Service.List(c.Request.Context())
|
comics, err := handler.Service.List(c.Request.Context())
|
||||||
if err != nil {
|
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 (
|
import (
|
||||||
"kontor-api-gin/internal/models"
|
"kontor-api-gin/internal/models"
|
||||||
|
"kontor-api-gin/internal/repository"
|
||||||
"kontor-api-gin/internal/service"
|
"kontor-api-gin/internal/service"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PlayerHandler struct {
|
type PlayerHandler struct {
|
||||||
@@ -31,3 +33,8 @@ func (handler *PlayerHandler) Get(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, player)
|
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 (
|
import (
|
||||||
"kontor-api-gin/internal/models"
|
"kontor-api-gin/internal/models"
|
||||||
|
"kontor-api-gin/internal/repository"
|
||||||
"kontor-api-gin/internal/service"
|
"kontor-api-gin/internal/service"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PositionHandler struct {
|
type PositionHandler struct {
|
||||||
@@ -31,3 +33,8 @@ func (handler *PositionHandler) Get(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, position)
|
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 (
|
import (
|
||||||
"kontor-api-gin/internal/models"
|
"kontor-api-gin/internal/models"
|
||||||
|
"kontor-api-gin/internal/repository"
|
||||||
"kontor-api-gin/internal/service"
|
"kontor-api-gin/internal/service"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PublisherHandler struct {
|
type PublisherHandler struct {
|
||||||
Service *service.PublisherService
|
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) {
|
func (handler *PublisherHandler) List(c *gin.Context) {
|
||||||
comics, err := handler.Service.List(c.Request.Context())
|
comics, err := handler.Service.List(c.Request.Context())
|
||||||
if err != nil {
|
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 (
|
import (
|
||||||
"kontor-api-gin/internal/models"
|
"kontor-api-gin/internal/models"
|
||||||
|
"kontor-api-gin/internal/repository"
|
||||||
"kontor-api-gin/internal/service"
|
"kontor-api-gin/internal/service"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SportHandler struct {
|
type SportHandler struct {
|
||||||
@@ -31,3 +33,8 @@ func (handler *SportHandler) Get(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, sport)
|
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 (
|
import (
|
||||||
"kontor-api-gin/internal/models"
|
"kontor-api-gin/internal/models"
|
||||||
|
"kontor-api-gin/internal/repository"
|
||||||
"kontor-api-gin/internal/service"
|
"kontor-api-gin/internal/service"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TeamHandler struct {
|
type TeamHandler struct {
|
||||||
@@ -31,3 +33,8 @@ func (handler *TeamHandler) Get(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, team)
|
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
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"kontor-api-gin/internal/repository"
|
|
||||||
"kontor-api-gin/internal/service"
|
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,18 +9,22 @@ type TyscHandler struct {
|
|||||||
PlayerHandler *PlayerHandler
|
PlayerHandler *PlayerHandler
|
||||||
TeamHandler *TeamHandler
|
TeamHandler *TeamHandler
|
||||||
PositionHandler *PositionHandler
|
PositionHandler *PositionHandler
|
||||||
// RoosterHandler *RoosterHandler
|
RoosterHandler *RoosterHandler
|
||||||
// VendorHandler *VendorHandler
|
VendorHandler *VendorHandler
|
||||||
// CardSetHandler *CardSetHandler
|
CardSetHandler *CardSetHandler
|
||||||
// CardHandler *CardHandler
|
CardHandler *CardHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTyscHandler(db *gorm.DB) *TyscHandler {
|
func NewTyscHandler(db *gorm.DB) *TyscHandler {
|
||||||
handlerMap := &TyscHandler{
|
handlerMap := &TyscHandler{
|
||||||
SportHandler: &SportHandler{Service: service.NewSportService(repository.NewSportRepository(db))},
|
SportHandler: NewSportHandler(db),
|
||||||
PlayerHandler: &PlayerHandler{Service: service.NewPlayerService(repository.NewPlayerRepository(db))},
|
PlayerHandler: NewPlayerHandler(db),
|
||||||
TeamHandler: &TeamHandler{Service: service.NewTeamService(repository.NewTeamRepository(db))},
|
TeamHandler: NewTeamHandler(db),
|
||||||
PositionHandler: &PositionHandler{Service: service.NewPositionService(repository.NewPositionRepository(db))},
|
PositionHandler: NewPositionHandler(db),
|
||||||
|
RoosterHandler: NewRoosterHandler(db),
|
||||||
|
VendorHandler: NewVendorHandler(db),
|
||||||
|
CardSetHandler: NewCardSetHandler(db),
|
||||||
|
CardHandler: NewCardHandler(db),
|
||||||
}
|
}
|
||||||
return handlerMap
|
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"
|
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 {
|
type CreateArtistDTO struct {
|
||||||
Name string `json:"name" binding:"required"`
|
Name string `json:"name" binding:"required"`
|
||||||
WebLink string `json:"weblink" binding:"required"`
|
WebLink string `json:"weblink" binding:"required"`
|
||||||
|
|||||||
@@ -3,19 +3,47 @@ package models
|
|||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
type ComicWork struct {
|
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"`
|
CreatedAt time.Time `gorm:"column:created_date" json:"created_date"`
|
||||||
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
||||||
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_date"`
|
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_date"`
|
||||||
Version int `gorm:"default:0" json:"version"`
|
Version int `gorm:"default:0" json:"version"`
|
||||||
ArtistID *string `gorm:"column:artist_id" json:"artist_id"`
|
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"`
|
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"`
|
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 {
|
func (comic_work *ComicWork) TableName() string {
|
||||||
return "comic_work"
|
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"
|
import "time"
|
||||||
|
|
||||||
type Issue struct {
|
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"`
|
CreatedAt time.Time `gorm:"column:created_date" json:"created_date"`
|
||||||
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
||||||
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_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"`
|
Title string `gorm:"column:title" json:"title"`
|
||||||
PublishedOn time.Time `gorm:"column:published_on" json:"published_on"`
|
PublishedOn time.Time `gorm:"column:published_on" json:"published_on"`
|
||||||
ComicID *string `gorm:"column:comic_id" json:"comic_id"`
|
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"`
|
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"`
|
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 {
|
func (issue *Issue) TableName() string {
|
||||||
return "issue"
|
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"
|
import "time"
|
||||||
|
|
||||||
type IssueWork struct {
|
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"`
|
CreatedAt time.Time `gorm:"column:created_date" json:"created_date"`
|
||||||
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
||||||
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_date"`
|
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_date"`
|
||||||
Version int `gorm:"default:0" json:"version"`
|
Version int `gorm:"default:0" json:"version"`
|
||||||
ArtistID *string `gorm:"column:artist_id" json:"artist_id"`
|
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"`
|
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"`
|
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 {
|
func (issue_work *IssueWork) TableName() string {
|
||||||
return "issue_work"
|
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"`
|
ID string `json:"id" binding:"required"`
|
||||||
CreatedAt time.Time `json:"created_date"`
|
CreatedAt time.Time `json:"created_date"`
|
||||||
UpdatedAt time.Time `json:"last_modified_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"`
|
Version int `json:"version"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
WebLink string `json:"weblink"`
|
WebLink string `json:"weblink"`
|
||||||
|
|||||||
@@ -3,18 +3,46 @@ package models
|
|||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
type StoryArc struct {
|
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"`
|
CreatedAt time.Time `gorm:"column:created_date" json:"created_date"`
|
||||||
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
||||||
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_date"`
|
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_date"`
|
||||||
Version int `gorm:"default:0" json:"version"`
|
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"`
|
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"`
|
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 {
|
func (story_arc *StoryArc) TableName() string {
|
||||||
return "story_arc"
|
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"
|
import "time"
|
||||||
|
|
||||||
type Volume struct {
|
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"`
|
CreatedAt time.Time `gorm:"column:created_date" json:"created_date"`
|
||||||
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
||||||
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_date"`
|
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_date"`
|
||||||
Version int `gorm:"default:0" json:"version"`
|
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"`
|
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 {
|
func (volume *Volume) TableName() string {
|
||||||
return "volume"
|
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"
|
import "time"
|
||||||
|
|
||||||
type WorkType struct {
|
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"`
|
CreatedAt time.Time `gorm:"column:created_date" json:"created_date"`
|
||||||
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
||||||
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_date"`
|
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_date"`
|
||||||
Version int `gorm:"default:0" json:"version"`
|
Version int `gorm:"default:0" json:"version"`
|
||||||
Name string `gorm:"uniqueIndex" json:"name"`
|
Name string `gorm:"uniqueIndex" json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (worktype *WorkType) TableName() string {
|
func (worktype *WorkType) TableName() string {
|
||||||
return "worktype"
|
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/players", tysc.PlayerHandler.List)
|
||||||
secured.GET("tysc/teams", tysc.TeamHandler.List)
|
secured.GET("tysc/teams", tysc.TeamHandler.List)
|
||||||
secured.GET("tysc/positions", tysc.PositionHandler.List)
|
secured.GET("tysc/positions", tysc.PositionHandler.List)
|
||||||
// secured.GET("tysc/roosters", tysc.RoosterHandler.List)
|
secured.GET("tysc/roosters", tysc.RoosterHandler.List)
|
||||||
// secured.GET("tysc/vendors", tysc.VendorHandler.List)
|
secured.GET("tysc/vendors", tysc.VendorHandler.List)
|
||||||
// secured.GET("tysc/cardsets", tysc.CardSetHandler.List)
|
secured.GET("tysc/cardsets", tysc.CardSetHandler.List)
|
||||||
// secured.GET("tysc/cards", tysc.CardHandler.List)
|
secured.GET("tysc/cards", tysc.CardHandler.List)
|
||||||
secured.GET("/comics/comics", comics.ComicHandler.List)
|
secured.GET("/comics/comics", comics.ComicHandler.List)
|
||||||
secured.GET("/comics/publishers", comics.PublisherHandler.List)
|
secured.GET("/comics/publishers", comics.PublisherHandler.List)
|
||||||
// comic.GET("/artists", comics.ArtistHandler.List)
|
secured.GET("/comics/artists", comics.ArtistHandler.List)
|
||||||
// comic.GET("/issues", comics.IssueHandler.List)
|
secured.GET("/comics/issues", comics.IssueHandler.List)
|
||||||
// comic.GET("/worktypes", comics.WorktypeHandler.List)
|
secured.GET("/comics/worktypes", comics.WorkTypeHandler.List)
|
||||||
// comic.GET("/volumes", comics.VolumeHandler.List)
|
secured.GET("/comics/volumes", comics.VolumeHandler.List)
|
||||||
// comic.GET("/storyarcs", comics.StoryarcHandler.List)
|
secured.GET("/comics/storyarcs", comics.StoryArcHandler.List)
|
||||||
// comic.GET("/comicworks", comics.ComicworkHandler.List)
|
secured.GET("/comics/comicworks", comics.ComicworkHandler.List)
|
||||||
// comic.GET("/issueworks", comics.IssueworkHandler.List)
|
secured.GET("/comics/issueworks", comics.IssueworkHandler.List)
|
||||||
secured.GET("/media/files", media.MediaFileHandler.List)
|
secured.GET("/media/files", media.MediaFileHandler.List)
|
||||||
secured.GET("/media/lofis", media.MediaLoFiHandler.List)
|
secured.GET("/media/lofis", media.MediaLoFiHandler.List)
|
||||||
secured.GET("/media/actors", media.MediaActorHandler.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