This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user