Actually make fucking interfaces

This commit is contained in:
2025-10-10 22:31:01 +02:00
parent da5133eef8
commit a09a01e7bc
8 changed files with 44 additions and 19 deletions

View File

@@ -14,10 +14,11 @@ import (
)
// Database manages all repositories and provides a unified interface
// Implements DatabaseInterface
type Database struct {
*gorm.DB
Character *CharacterRepository
Cache *CacheRepository
character *CharacterRepository
cache *CacheRepository
}
// NewDatabase creates a new database instance with all repositories
@@ -49,8 +50,8 @@ func NewDatabase() (*Database, error) {
database := &Database{
DB: db,
Character: characterRepo,
Cache: cacheRepo,
character: characterRepo,
cache: cacheRepo,
}
// Run migrations
@@ -62,3 +63,13 @@ func NewDatabase() (*Database, error) {
logger.Info("Database initialized successfully")
return database, nil
}
// Character returns the character repository
func (d *Database) Character() CharacterRepositoryInterface {
return d.character
}
// Cache returns the cache repository
func (d *Database) Cache() CacheRepositoryInterface {
return d.cache
}