All checks were successful
Build and Push App Image / build-and-push (push) Successful in 1m48s
252 lines
10 KiB
Go
252 lines
10 KiB
Go
package repositories
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gitea.hostxtra.co.uk/mrhid6/notely/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)
|
|
|
|
// GetAllProvidersForAdmin retrieves all providers, including inactive ones
|
|
GetAllProvidersForAdmin(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)
|
|
}
|
|
|
|
// TaskRepository defines task operations
|
|
type TaskRepository interface {
|
|
CreateTask(ctx context.Context, task *entities.Task) error
|
|
GetTaskByID(ctx context.Context, id bson.ObjectID) (*entities.Task, error)
|
|
ListTasks(ctx context.Context, spaceID bson.ObjectID, filters map[string]any) ([]*entities.Task, error)
|
|
SearchTasks(ctx context.Context, spaceID bson.ObjectID, query string) ([]*entities.Task, error)
|
|
UpdateTask(ctx context.Context, task *entities.Task) error
|
|
DeleteTask(ctx context.Context, id bson.ObjectID) error
|
|
DeleteTasksByTaskListID(ctx context.Context, taskListID bson.ObjectID) error
|
|
DeleteTasksBySpaceID(ctx context.Context, spaceID bson.ObjectID) error
|
|
CountChildren(ctx context.Context, parentTaskID bson.ObjectID) (int64, error)
|
|
}
|
|
|
|
// TaskListRepository defines task list operations.
|
|
type TaskListRepository interface {
|
|
CreateTaskList(ctx context.Context, list *entities.TaskList) error
|
|
GetTaskListByID(ctx context.Context, id bson.ObjectID) (*entities.TaskList, error)
|
|
ListTaskLists(ctx context.Context, spaceID bson.ObjectID) ([]*entities.TaskList, error)
|
|
ListTaskListsByCategory(ctx context.Context, spaceID bson.ObjectID, categoryID bson.ObjectID) ([]*entities.TaskList, error)
|
|
UpdateTaskList(ctx context.Context, list *entities.TaskList) error
|
|
DeleteTaskList(ctx context.Context, id bson.ObjectID) error
|
|
DeleteTaskListsBySpaceID(ctx context.Context, spaceID bson.ObjectID) error
|
|
}
|
|
|
|
// TaskStatusRepository defines task status operations
|
|
type TaskStatusRepository interface {
|
|
CreateStatus(ctx context.Context, status *entities.TaskStatus) error
|
|
GetStatusByID(ctx context.Context, id bson.ObjectID) (*entities.TaskStatus, error)
|
|
ListStatuses(ctx context.Context, spaceID bson.ObjectID) ([]*entities.TaskStatus, error)
|
|
UpdateStatus(ctx context.Context, status *entities.TaskStatus) error
|
|
DeleteStatus(ctx context.Context, id bson.ObjectID) error
|
|
}
|