tercul-backend/internal/data/sql/repositories.go
google-labs-jules[bot] 85f052b2d6 refactor: Align codebase with DDD architecture to fix build
This commit addresses a broken build state caused by a mid-stream architectural refactoring. The changes align the existing code with the new Domain-Driven Design (DDD-lite) structure outlined in `refactor.md`.

Key changes include:
- Defined missing domain interfaces for `Auth`, `Localization`, and `Search`.
- Refactored application services to use a `Commands` and `Queries` pattern.
- Updated GraphQL resolvers to call application services instead of accessing repositories directly.
- Fixed dependency injection in `cmd/api/main.go` by removing the non-existent `ApplicationBuilder` and manually instantiating services.
- Corrected numerous test files (`integration`, `unit`, and `repository` tests) to reflect the new architecture, including fixing mock objects and test suite setups.
- Added missing database migrations for test schemas to resolve "no such table" errors.

This effort successfully gets the application to a compilable state and passes a significant portion of the test suite, laying the groundwork for further development and fixing the remaining test failures.
2025-10-03 01:17:53 +00:00

55 lines
1.7 KiB
Go

package sql
import (
"tercul/internal/domain"
"tercul/internal/domain/auth"
"tercul/internal/domain/localization"
"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 auth.AuthRepository
Localization localization.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),
}
}