feat(database): add user_library table and library access methods

Signed-off-by: Deluan <deluan@navidrome.org>

# Conflicts:
#	tests/mock_library_repo.go
This commit is contained in:
Deluan 2025-06-06 13:20:37 -04:00
commit 40bbae16c4
9 changed files with 533 additions and 6 deletions

View file

@ -39,4 +39,14 @@ func (m *MockLibraryRepo) RefreshStats(id int) error {
return nil
}
// User-library association methods - mock implementations
func (m *MockLibraryRepo) GetUsersWithLibraryAccess(libraryID int) (model.Users, error) {
if m.Err != nil {
return nil, m.Err
}
// Mock: return empty users for now
return model.Users{}, nil
}
var _ model.LibraryRepository = &MockLibraryRepo{}

View file

@ -74,3 +74,37 @@ func (u *MockedUserRepo) UpdateLastAccessAt(id string) error {
}
return u.Error
}
// Library association methods - mock implementations
func (u *MockedUserRepo) GetUserLibraries(userID string) (model.Libraries, error) {
if u.Error != nil {
return nil, u.Error
}
// Mock: return empty libraries for now
return model.Libraries{}, nil
}
func (u *MockedUserRepo) SetUserLibraries(userID string, libraryIDs []int) error {
if u.Error != nil {
return u.Error
}
// Mock: do nothing for now
return nil
}
func (u *MockedUserRepo) AddUserLibrary(userID string, libraryID int) error {
if u.Error != nil {
return u.Error
}
// Mock: do nothing for now
return nil
}
func (u *MockedUserRepo) RemoveUserLibrary(userID string, libraryID int) error {
if u.Error != nil {
return u.Error
}
// Mock: do nothing for now
return nil
}