add tysc handlers to kontor-gin
This commit is contained in:
@@ -2,7 +2,7 @@ package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models/comics"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
@@ -17,11 +17,11 @@ func NewComicRepository(db *gorm.DB) *ComicRepository {
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *ComicRepository) List(context context.Context) ([]comics.Comic, error) {
|
||||
var comics []comics.Comic
|
||||
func (repository *ComicRepository) FindAll(context context.Context) ([]models.Comic, error) {
|
||||
var comics []models.Comic
|
||||
|
||||
result := repository.db.Find(&comics)
|
||||
slog.Info("ComicRepository#List", "count", result.RowsAffected)
|
||||
slog.Info("ComicRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return comics, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type MediaActorRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewMediaActorRepository(db *gorm.DB) *MediaActorRepository {
|
||||
repo := &MediaActorRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *MediaActorRepository) FindAll(context context.Context) ([]models.MediaActor, error) {
|
||||
var actors []models.MediaActor
|
||||
|
||||
result := repository.db.Find(&actors)
|
||||
slog.Info("MediaActorRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return actors, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type MediaFileRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewMediaFileRepository(db *gorm.DB) *MediaFileRepository {
|
||||
repo := &MediaFileRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *MediaFileRepository) FindAll(context context.Context) ([]models.MediaFile, error) {
|
||||
var files []models.MediaFile
|
||||
|
||||
result := repository.db.Find(&files)
|
||||
slog.Info("MediaFileRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return files, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type MediaLoFiRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewMediaLoFiRepository(db *gorm.DB) *MediaLoFiRepository {
|
||||
repo := &MediaLoFiRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *MediaLoFiRepository) FindAll(context context.Context) ([]models.MediaLoFi, error) {
|
||||
var lofis []models.MediaLoFi
|
||||
|
||||
result := repository.db.Find(&lofis)
|
||||
slog.Info("MediaLoFiRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return lofis, nil
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type PermissionRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func (repository *PermissionRepository) FindAll(context context.Context) ([]models.Permission, error) {
|
||||
|
||||
var permissions []models.Permission
|
||||
|
||||
result := repository.db.Find(&permissions)
|
||||
slog.Info("ComicRepository#List", "count", result.RowsAffected)
|
||||
|
||||
return permissions, nil
|
||||
}
|
||||
|
||||
func NewPermissionRepository(db *gorm.DB) *PermissionRepository {
|
||||
repository := &PermissionRepository{db: db}
|
||||
return repository
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type PlayerRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewPlayerRepository(db *gorm.DB) *PlayerRepository {
|
||||
repo := &PlayerRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *PlayerRepository) FindAll(context context.Context) ([]models.Player, error) {
|
||||
var players []models.Player
|
||||
|
||||
result := repository.db.Find(&players)
|
||||
slog.Info("PlayerRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return players, nil
|
||||
}
|
||||
|
||||
func (repository *PlayerRepository) GetById(context context.Context, id string) (models.Player, error) {
|
||||
var player = models.Player{ID: id}
|
||||
slog.Info("PlayerRepository#GetById", "id", id)
|
||||
result := repository.db.First(&player)
|
||||
if result.Error != nil {
|
||||
slog.Info("PlayerRepository#GetById", "error", result.Error.Error())
|
||||
}
|
||||
return player, result.Error
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type PositionRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewPositionRepository(db *gorm.DB) *PositionRepository {
|
||||
repo := &PositionRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *PositionRepository) FindAll(context context.Context) ([]models.Position, error) {
|
||||
var positions []models.Position
|
||||
|
||||
result := repository.db.Find(&positions)
|
||||
slog.Info("PositionRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return positions, nil
|
||||
}
|
||||
|
||||
func (repository *PositionRepository) GetById(context context.Context, id string) (models.Position, error) {
|
||||
var position = models.Position{ID: id}
|
||||
slog.Info("PositionRepository#GetById", "id", id)
|
||||
result := repository.db.First(&position)
|
||||
if result.Error != nil {
|
||||
slog.Info("PositionRepository#GetById", "error", result.Error.Error())
|
||||
}
|
||||
return position, result.Error
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -12,3 +16,23 @@ func NewProfileRepository(db *gorm.DB) *ProfileRepository {
|
||||
repository := &ProfileRepository{db: db}
|
||||
return repository
|
||||
}
|
||||
|
||||
func (repository *ProfileRepository) FindAll(context context.Context) ([]models.Profile, error) {
|
||||
var profiles []models.Profile
|
||||
|
||||
result := repository.db.Find(&profiles)
|
||||
slog.Info("ProfileRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return profiles, nil
|
||||
}
|
||||
|
||||
func (repository *ProfileRepository) FindProfileByEmail(email string) (*models.Profile, error) {
|
||||
var profile models.Profile
|
||||
|
||||
err := repository.db.Model(models.Profile{}).Where("email = ?", email).Take(&profile).Error
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &profile, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type PublisherRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewPublisherRepository(db *gorm.DB) *PublisherRepository {
|
||||
repo := &PublisherRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *PublisherRepository) FindAll(context context.Context) ([]models.Publisher, error) {
|
||||
var publishers []models.Publisher
|
||||
|
||||
result := repository.db.Find(&publishers)
|
||||
slog.Info("PublisherRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return publishers, nil
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type SportRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewSportRepository(db *gorm.DB) *SportRepository {
|
||||
repo := &SportRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *SportRepository) FindAll(context context.Context) ([]models.Sport, error) {
|
||||
var sports []models.Sport
|
||||
|
||||
result := repository.db.Find(&sports)
|
||||
slog.Info("SportRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return sports, nil
|
||||
}
|
||||
|
||||
func (repository *SportRepository) GetById(context context.Context, id string) (models.Sport, error) {
|
||||
var sport = models.Sport{ID: id}
|
||||
slog.Info("SportRepository#GetById", "id", id)
|
||||
result := repository.db.First(&sport)
|
||||
if result.Error != nil {
|
||||
slog.Info("SportRepository#GetById", "error", result.Error.Error())
|
||||
}
|
||||
return sport, result.Error
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type TeamRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewTeamRepository(db *gorm.DB) *TeamRepository {
|
||||
repo := &TeamRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *TeamRepository) FindAll(context context.Context) ([]models.Team, error) {
|
||||
var teams []models.Team
|
||||
|
||||
result := repository.db.Find(&teams)
|
||||
slog.Info("TeamRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return teams, nil
|
||||
}
|
||||
|
||||
func (repository *TeamRepository) GetById(context context.Context, id string) (models.Team, error) {
|
||||
var team = models.Team{ID: id}
|
||||
slog.Info("TeamRepository#GetById", "id", id)
|
||||
result := repository.db.First(&team)
|
||||
if result.Error != nil {
|
||||
slog.Info("TeamRepository#GetById", "error", result.Error.Error())
|
||||
}
|
||||
return team, result.Error
|
||||
}
|
||||
Reference in New Issue
Block a user