This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ArticleRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewArticleRepository(db *gorm.DB) *ArticleRepository {
|
||||
repo := &ArticleRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *ArticleRepository) FindAll(context context.Context) ([]models.Article, error) {
|
||||
var articles []models.Article
|
||||
|
||||
result := repository.db.Find(&articles)
|
||||
slog.Info("ArticleRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return articles, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type AuthorRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewAuthorRepository(db *gorm.DB) *AuthorRepository {
|
||||
repo := &AuthorRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *AuthorRepository) FindAll(context context.Context) ([]models.Author, error) {
|
||||
var authors []models.Author
|
||||
|
||||
result := repository.db.Find(&authors)
|
||||
slog.Info("AuthorRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return authors, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type BookRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewBookRepository(db *gorm.DB) *BookRepository {
|
||||
repo := &BookRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *BookRepository) FindAll(context context.Context) ([]models.Book, error) {
|
||||
var books []models.Book
|
||||
|
||||
result := repository.db.Find(&books)
|
||||
slog.Info("BookRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return books, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type BookAuthorRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewBookAuthorRepository(db *gorm.DB) *BookAuthorRepository {
|
||||
repo := &BookAuthorRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *BookAuthorRepository) FindAll(context context.Context) ([]models.BookAuthor, error) {
|
||||
var bookAuthors []models.BookAuthor
|
||||
|
||||
result := repository.db.Find(&bookAuthors)
|
||||
slog.Info("BookAuthorRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return bookAuthors, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type BookshelfPublisherRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewBookshelfPublisherRepository(db *gorm.DB) *BookshelfPublisherRepository {
|
||||
repo := &BookshelfPublisherRepository{db: db}
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *BookshelfPublisherRepository) FindAll(context context.Context) ([]models.BookshelfPublisher, error) {
|
||||
var bookshelfPublishers []models.BookshelfPublisher
|
||||
|
||||
result := repository.db.Find(&bookshelfPublishers)
|
||||
slog.Info("BookshelfPublisherRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return bookshelfPublishers, nil
|
||||
}
|
||||
Reference in New Issue
Block a user