28 lines
598 B
Go
28 lines
598 B
Go
package repository
|
|
|
|
import (
|
|
"context"
|
|
"kontor-api-gin/internal/models"
|
|
"log/slog"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type ArticleAuthorRepository struct {
|
|
db *gorm.DB
|
|
}
|
|
|
|
func NewArticleAuthorRepository(db *gorm.DB) *ArticleAuthorRepository {
|
|
repo := &ArticleAuthorRepository{db: db}
|
|
return repo
|
|
}
|
|
|
|
func (repository *ArticleAuthorRepository) FindAll(context context.Context) ([]models.ArticleAuthor, error) {
|
|
var articleAuthors []models.ArticleAuthor
|
|
|
|
result := repository.db.Find(&articleAuthors)
|
|
slog.Info("ArticleAuthorRepository#FindAll", "count", result.RowsAffected)
|
|
|
|
return articleAuthors, nil
|
|
}
|