mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-27 05:11:34 +00:00
This change introduces a service layer to encapsulate the business logic for each domain aggregate. This will make the code more modular, testable, and easier to maintain. The following services have been created: - author - bookmark - category - collection - comment - like - tag - translation - user The main Application struct has been updated to use these new services. The integration test suite has also been updated to use the new Application struct and services. This is a work in progress. The next step is to fix the compilation errors and then refactor the resolvers to use the new services.
53 lines
1.6 KiB
Go
53 lines
1.6 KiB
Go
package sql
|
|
|
|
import (
|
|
"tercul/internal/domain"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Repositories struct {
|
|
Work domain.WorkRepository
|
|
User domain.UserRepository
|
|
Author domain.AuthorRepository
|
|
Translation domain.TranslationRepository
|
|
Comment domain.CommentRepository
|
|
Like domain.LikeRepository
|
|
Bookmark domain.BookmarkRepository
|
|
Collection domain.CollectionRepository
|
|
Tag domain.TagRepository
|
|
Category domain.CategoryRepository
|
|
Book domain.BookRepository
|
|
Publisher domain.PublisherRepository
|
|
Source domain.SourceRepository
|
|
Copyright domain.CopyrightRepository
|
|
Monetization domain.MonetizationRepository
|
|
Analytics domain.AnalyticsRepository
|
|
Auth domain.AuthRepository
|
|
Localization domain.LocalizationRepository
|
|
}
|
|
|
|
// NewRepositories creates a new Repositories container
|
|
func NewRepositories(db *gorm.DB) *Repositories {
|
|
return &Repositories{
|
|
Work: NewWorkRepository(db),
|
|
User: NewUserRepository(db),
|
|
Author: NewAuthorRepository(db),
|
|
Translation: NewTranslationRepository(db),
|
|
Comment: NewCommentRepository(db),
|
|
Like: NewLikeRepository(db),
|
|
Bookmark: NewBookmarkRepository(db),
|
|
Collection: NewCollectionRepository(db),
|
|
Tag: NewTagRepository(db),
|
|
Category: NewCategoryRepository(db),
|
|
Book: NewBookRepository(db),
|
|
Publisher: NewPublisherRepository(db),
|
|
Source: NewSourceRepository(db),
|
|
Copyright: NewCopyrightRepository(db),
|
|
Monetization: NewMonetizationRepository(db),
|
|
Analytics: NewAnalyticsRepository(db),
|
|
Auth: NewAuthRepository(db),
|
|
Localization: NewLocalizationRepository(db),
|
|
}
|
|
}
|