first commit
This commit is contained in:
40
backend/internal/domain/repositories/additional.go
Normal file
40
backend/internal/domain/repositories/additional.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/noteapp/backend/internal/domain/entities"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
)
|
||||
|
||||
// AccountRecoveryRepository defines account recovery operations
|
||||
type AccountRecoveryRepository interface {
|
||||
CreateRecovery(ctx context.Context, recovery *entities.AccountRecovery) error
|
||||
GetRecoveryByToken(ctx context.Context, token string) (*entities.AccountRecovery, error)
|
||||
MarkRecoveryUsed(ctx context.Context, id bson.ObjectID) error
|
||||
}
|
||||
|
||||
// FeatureFlagRepository defines app feature-flag operations.
|
||||
type FeatureFlagRepository interface {
|
||||
GetFeatureFlags(ctx context.Context) (*entities.FeatureFlags, error)
|
||||
UpdateFeatureFlags(ctx context.Context, flags *entities.FeatureFlags) error
|
||||
}
|
||||
|
||||
// Additional repository extensions
|
||||
type (
|
||||
// SpaceRepository extensions
|
||||
SpaceRepositoryExt interface {
|
||||
SpaceRepository
|
||||
}
|
||||
|
||||
// MembershipRepository extensions
|
||||
MembershipRepositoryExt interface {
|
||||
MembershipRepository
|
||||
GetUserMemberships(ctx context.Context, userID bson.ObjectID) ([]*entities.Membership, error)
|
||||
}
|
||||
|
||||
// NoteRepository extensions
|
||||
NoteRepositoryExt interface {
|
||||
NoteRepository
|
||||
}
|
||||
)
|
||||
215
backend/internal/domain/repositories/interfaces.go
Normal file
215
backend/internal/domain/repositories/interfaces.go
Normal file
@@ -0,0 +1,215 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/noteapp/backend/internal/domain/entities"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
)
|
||||
|
||||
// UserRepository defines user operations
|
||||
type UserRepository interface {
|
||||
// CreateUser creates a new user
|
||||
CreateUser(ctx context.Context, user *entities.User) error
|
||||
|
||||
// GetUserByID retrieves a user by ID
|
||||
GetUserByID(ctx context.Context, id bson.ObjectID) (*entities.User, error)
|
||||
|
||||
// GetUserByEmail retrieves a user by email
|
||||
GetUserByEmail(ctx context.Context, email string) (*entities.User, error)
|
||||
|
||||
// GetUserByUsername retrieves a user by username
|
||||
GetUserByUsername(ctx context.Context, username string) (*entities.User, error)
|
||||
|
||||
// UpdateUser updates a user
|
||||
UpdateUser(ctx context.Context, user *entities.User) error
|
||||
|
||||
// DeleteUser deletes a user
|
||||
DeleteUser(ctx context.Context, id bson.ObjectID) error
|
||||
|
||||
// ListAllUsers retrieves all users (admin use)
|
||||
ListAllUsers(ctx context.Context) ([]*entities.User, error)
|
||||
}
|
||||
|
||||
// GroupRepository defines permission group operations
|
||||
type GroupRepository interface {
|
||||
// CreateGroup creates a new permission group
|
||||
CreateGroup(ctx context.Context, group *entities.PermissionGroup) error
|
||||
|
||||
// GetGroupByID retrieves a group by ID
|
||||
GetGroupByID(ctx context.Context, id bson.ObjectID) (*entities.PermissionGroup, error)
|
||||
|
||||
// GetGroupByName retrieves a group by name
|
||||
GetGroupByName(ctx context.Context, name string) (*entities.PermissionGroup, error)
|
||||
|
||||
// GetGroupsByIDs retrieves groups by IDs
|
||||
GetGroupsByIDs(ctx context.Context, ids []bson.ObjectID) ([]*entities.PermissionGroup, error)
|
||||
|
||||
// ListGroups retrieves all groups
|
||||
ListGroups(ctx context.Context) ([]*entities.PermissionGroup, error)
|
||||
|
||||
// UpdateGroup updates an existing group
|
||||
UpdateGroup(ctx context.Context, group *entities.PermissionGroup) error
|
||||
|
||||
// DeleteGroup deletes a group
|
||||
DeleteGroup(ctx context.Context, id bson.ObjectID) error
|
||||
}
|
||||
|
||||
// SpaceRepository defines space operations
|
||||
type SpaceRepository interface {
|
||||
// CreateSpace creates a new space
|
||||
CreateSpace(ctx context.Context, space *entities.Space) error
|
||||
|
||||
// GetSpaceByID retrieves a space by ID
|
||||
GetSpaceByID(ctx context.Context, id bson.ObjectID) (*entities.Space, error)
|
||||
|
||||
// GetSpacesByUserID retrieves all spaces for a user
|
||||
GetSpacesByUserID(ctx context.Context, userID bson.ObjectID) ([]*entities.Space, error)
|
||||
|
||||
// GetAllSpaces retrieves all spaces (admin use)
|
||||
GetAllSpaces(ctx context.Context) ([]*entities.Space, error)
|
||||
|
||||
// GetPublicSpaces retrieves all spaces marked as public
|
||||
GetPublicSpaces(ctx context.Context) ([]*entities.Space, error)
|
||||
|
||||
// UpdateSpace updates a space
|
||||
UpdateSpace(ctx context.Context, space *entities.Space) error
|
||||
|
||||
// DeleteSpace deletes a space
|
||||
DeleteSpace(ctx context.Context, id bson.ObjectID) error
|
||||
}
|
||||
|
||||
// MembershipRepository defines membership operations
|
||||
type MembershipRepository interface {
|
||||
// CreateMembership creates a new membership
|
||||
CreateMembership(ctx context.Context, membership *entities.Membership) error
|
||||
|
||||
// GetMembershipByID retrieves a membership by ID
|
||||
GetMembershipByID(ctx context.Context, id bson.ObjectID) (*entities.Membership, error)
|
||||
|
||||
// GetUserMembership retrieves a membership for a user in a space
|
||||
GetUserMembership(ctx context.Context, userID, spaceID bson.ObjectID) (*entities.Membership, error)
|
||||
|
||||
// GetSpaceMembers retrieves all members in a space
|
||||
GetSpaceMembers(ctx context.Context, spaceID bson.ObjectID) ([]*entities.Membership, error)
|
||||
|
||||
// GetUserMemberships retrieves all memberships for a user
|
||||
GetUserMemberships(ctx context.Context, userID bson.ObjectID) ([]*entities.Membership, error)
|
||||
|
||||
// UpdateMembership updates a membership
|
||||
UpdateMembership(ctx context.Context, membership *entities.Membership) error
|
||||
|
||||
// DeleteMembership deletes a membership
|
||||
DeleteMembership(ctx context.Context, id bson.ObjectID) error
|
||||
|
||||
// DeleteMembershipsBySpaceID deletes all memberships for a space
|
||||
DeleteMembershipsBySpaceID(ctx context.Context, spaceID bson.ObjectID) error
|
||||
}
|
||||
|
||||
// NoteRepository defines note operations
|
||||
type NoteRepository interface {
|
||||
// CreateNote creates a new note
|
||||
CreateNote(ctx context.Context, note *entities.Note) error
|
||||
|
||||
// GetNoteByID retrieves a note by ID
|
||||
GetNoteByID(ctx context.Context, id bson.ObjectID) (*entities.Note, error)
|
||||
|
||||
// GetNotesBySpaceID retrieves all notes in a space
|
||||
GetNotesBySpaceID(ctx context.Context, spaceID bson.ObjectID, skip, limit int) ([]*entities.Note, error)
|
||||
|
||||
// GetPublicNotesBySpaceID retrieves public notes in a space
|
||||
GetPublicNotesBySpaceID(ctx context.Context, spaceID bson.ObjectID, skip, limit int) ([]*entities.Note, error)
|
||||
|
||||
// GetNotesByCategory retrieves notes in a category
|
||||
GetNotesByCategory(ctx context.Context, spaceID, categoryID bson.ObjectID) ([]*entities.Note, error)
|
||||
|
||||
// SearchNotes performs full-text search on notes
|
||||
SearchNotes(ctx context.Context, spaceID bson.ObjectID, query string) ([]*entities.Note, error)
|
||||
|
||||
// UpdateNote updates a note
|
||||
UpdateNote(ctx context.Context, note *entities.Note) error
|
||||
|
||||
// DeleteNote deletes a note
|
||||
DeleteNote(ctx context.Context, id bson.ObjectID) error
|
||||
|
||||
// DeleteNotesBySpaceID deletes all notes in a space
|
||||
DeleteNotesBySpaceID(ctx context.Context, spaceID bson.ObjectID) error
|
||||
}
|
||||
|
||||
// CategoryRepository defines category operations
|
||||
type CategoryRepository interface {
|
||||
// CreateCategory creates a new category
|
||||
CreateCategory(ctx context.Context, category *entities.Category) error
|
||||
|
||||
// GetCategoryByID retrieves a category by ID
|
||||
GetCategoryByID(ctx context.Context, id bson.ObjectID) (*entities.Category, error)
|
||||
|
||||
// GetCategoriesBySpaceID retrieves all categories in a space
|
||||
GetCategoriesBySpaceID(ctx context.Context, spaceID bson.ObjectID) ([]*entities.Category, error)
|
||||
|
||||
// GetRootCategories retrieves root level categories in a space
|
||||
GetRootCategories(ctx context.Context, spaceID bson.ObjectID) ([]*entities.Category, error)
|
||||
|
||||
// GetSubcategories retrieves subcategories of a category
|
||||
GetSubcategories(ctx context.Context, parentID bson.ObjectID) ([]*entities.Category, error)
|
||||
|
||||
// UpdateCategory updates a category
|
||||
UpdateCategory(ctx context.Context, category *entities.Category) error
|
||||
|
||||
// DeleteCategory deletes a category
|
||||
DeleteCategory(ctx context.Context, id bson.ObjectID) error
|
||||
|
||||
// DeleteCategoriesBySpaceID deletes all categories in a space
|
||||
DeleteCategoriesBySpaceID(ctx context.Context, spaceID bson.ObjectID) error
|
||||
}
|
||||
|
||||
// AuthProviderRepository defines auth provider operations
|
||||
type AuthProviderRepository interface {
|
||||
// CreateProvider creates a new auth provider
|
||||
CreateProvider(ctx context.Context, provider *entities.AuthProvider) error
|
||||
|
||||
// GetProviderByID retrieves a provider by ID
|
||||
GetProviderByID(ctx context.Context, id bson.ObjectID) (*entities.AuthProvider, error)
|
||||
|
||||
// GetAllProviders retrieves all active providers
|
||||
GetAllProviders(ctx context.Context) ([]*entities.AuthProvider, error)
|
||||
|
||||
// UpdateProvider updates a provider
|
||||
UpdateProvider(ctx context.Context, provider *entities.AuthProvider) error
|
||||
|
||||
// DeleteProvider deletes a provider
|
||||
DeleteProvider(ctx context.Context, id bson.ObjectID) error
|
||||
}
|
||||
|
||||
// UserProviderLinkRepository defines user provider link operations
|
||||
type UserProviderLinkRepository interface {
|
||||
// CreateLink creates a new user provider link
|
||||
CreateLink(ctx context.Context, link *entities.UserProviderLink) error
|
||||
|
||||
// GetLink retrieves a user provider link
|
||||
GetLink(ctx context.Context, userID, providerID bson.ObjectID) (*entities.UserProviderLink, error)
|
||||
|
||||
// GetLinkByProviderUserID retrieves a link by provider user ID
|
||||
GetLinkByProviderUserID(ctx context.Context, providerID bson.ObjectID, providerUserID string) (*entities.UserProviderLink, error)
|
||||
|
||||
// GetUserLinks retrieves all provider links for a user
|
||||
GetUserLinks(ctx context.Context, userID bson.ObjectID) ([]*entities.UserProviderLink, error)
|
||||
|
||||
// UpdateLink updates a provider link
|
||||
UpdateLink(ctx context.Context, link *entities.UserProviderLink) error
|
||||
|
||||
// DeleteLink deletes a provider link
|
||||
DeleteLink(ctx context.Context, id bson.ObjectID) error
|
||||
}
|
||||
|
||||
// NoteRevisionRepository defines note revision operations
|
||||
type NoteRevisionRepository interface {
|
||||
// CreateRevision creates a new note revision
|
||||
CreateRevision(ctx context.Context, revision *entities.NoteRevision) error
|
||||
|
||||
// GetRevisionsByNoteID retrieves all revisions for a note
|
||||
GetRevisionsByNoteID(ctx context.Context, noteID bson.ObjectID) ([]*entities.NoteRevision, error)
|
||||
|
||||
// GetRevisionByID retrieves a specific revision
|
||||
GetRevisionByID(ctx context.Context, id bson.ObjectID) (*entities.NoteRevision, error)
|
||||
}
|
||||
Reference in New Issue
Block a user