This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type AssignmentRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewAssignmentRepository(db *gorm.DB) *AssignmentRepository {
|
||||
repository := &AssignmentRepository{db: db}
|
||||
return repository
|
||||
}
|
||||
|
||||
func (repository *AssignmentRepository) FindAll(context context.Context) ([]models.Assignment, error) {
|
||||
var assignments []models.Assignment
|
||||
|
||||
result := repository.db.Find(&assignments)
|
||||
slog.Info("AssignmentRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return assignments, nil
|
||||
}
|
||||
|
||||
func (repository *AssignmentRepository) GetById(context context.Context, id string) (models.Assignment, error) {
|
||||
var assignment = models.Assignment{ID: id}
|
||||
slog.Info("AssignmentRepository#GetById", "id", id)
|
||||
result := repository.db.First(&assignment)
|
||||
if result.Error != nil {
|
||||
slog.Info("AssignmentRepository#GetById", "error", result.Error.Error())
|
||||
}
|
||||
return assignment, result.Error
|
||||
}
|
||||
@@ -21,7 +21,7 @@ func (repository *IssueworkRepository) FindAll(context context.Context) ([]model
|
||||
var issueworks []models.IssueWork
|
||||
|
||||
result := repository.db.Find(&issueworks)
|
||||
slog.Info("IssueRepository#FindAll", "count", result.RowsAffected)
|
||||
slog.Info("IssueworkRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return issueworks, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type MediaVideoRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewMediaVideoRepository(db *gorm.DB) *MediaVideoRepository {
|
||||
repo := &MediaVideoRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *MediaVideoRepository) FindAll(context context.Context) ([]models.MediaVideo, error) {
|
||||
var videos []models.MediaVideo
|
||||
|
||||
result := repository.db.Find(&videos)
|
||||
slog.Info("MediaVideoRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return videos, nil
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type TokenRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewTokenRepository(db *gorm.DB) *TokenRepository {
|
||||
repository := &TokenRepository{db: db}
|
||||
return repository
|
||||
}
|
||||
|
||||
func (repository *TokenRepository) FindAll(context context.Context) ([]models.Token, error) {
|
||||
var tokens []models.Token
|
||||
|
||||
result := repository.db.Find(&tokens)
|
||||
slog.Info("TokenRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return tokens, nil
|
||||
}
|
||||
|
||||
func (repository *TokenRepository) GetById(context context.Context, id string) (models.Token, error) {
|
||||
var token = models.Token{ID: id}
|
||||
slog.Info("TokenRepository#GetById", "id", id)
|
||||
result := repository.db.First(&token)
|
||||
if result.Error != nil {
|
||||
slog.Info("TokenRepository#GetById", "error", result.Error.Error())
|
||||
}
|
||||
return token, result.Error
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type TradePaperbackRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewTradePaperbackRepository(db *gorm.DB) *TradePaperbackRepository {
|
||||
repo := &TradePaperbackRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *TradePaperbackRepository) FindAll(context context.Context) ([]models.TradePaperback, error) {
|
||||
var tradepaperbacks []models.TradePaperback
|
||||
|
||||
result := repository.db.Find(&tradepaperbacks)
|
||||
slog.Info("TradePaperbackRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return tradepaperbacks, nil
|
||||
}
|
||||
@@ -21,7 +21,7 @@ func (repository *WorkTypeRepository) FindAll(context context.Context) ([]models
|
||||
var workTypes []models.WorkType
|
||||
|
||||
result := repository.db.Find(&workTypes)
|
||||
slog.Info("VolumeRepository#FindAll", "count", result.RowsAffected)
|
||||
slog.Info("WorkTypeRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return workTypes, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user