repository

package
v0.0.0-...-8491d02 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmployeeNotFound    = errors.New("employee not found")
	ErrEmployeeIDExists    = errors.New("employee ID already exists")
	ErrUserAlreadyEmployee = errors.New("user is already an employee in this organization")
	ErrManagerNotFound     = errors.New("manager not found")
)

Common errors for employee repository

View Source
var (
	ErrOrganizationNotFound   = errors.New("organization not found")
	ErrOrganizationNameExists = errors.New("organization name already exists")
)

Common errors for organization repository

View Source
var (
	ErrProjectNotFound   = errors.New("project not found")
	ErrProjectNameExists = errors.New("project name already exists in this organization")
)

Common errors for project repository

View Source
var (
	ErrRoleNotFound         = errors.New("role not found")
	ErrPermissionNotFound   = errors.New("permission not found")
	ErrRoleNameExists       = errors.New("role name already exists")
	ErrPermissionNameExists = errors.New("permission name already exists")
)

Common errors

View Source
var (
	ErrTimeEntryNotFound = errors.New("time entry not found")
	ErrRunningTimeEntry  = errors.New("user already has a running time entry for this task")
)

Common errors for time entry repository

View Source
var (
	ErrUserNotFound       = errors.New("user not found")
	ErrEmailAlreadyExists = errors.New("email already exists")
	ErrDatabaseError      = errors.New("database error")
)

Common errors

View Source
var (
	ErrCommentNotFound = errors.New("comment not found")
)

Common errors for comment repository

View Source
var (
	ErrFileAttachmentNotFound = errors.New("file attachment not found")
)

Common errors for file attachment repository

View Source
var (
	ErrNotificationNotFound = errors.New("notification not found")
)

Common errors for notification repository

View Source
var (
	ErrTaskNotFound = errors.New("task not found")
)

Common errors for task repository

Functions

This section is empty.

Types

type CommentRepository

type CommentRepository interface {
	// Create creates a new comment
	Create(ctx context.Context, comment *models.Comment) error

	// GetByID retrieves a comment by ID
	GetByID(ctx context.Context, id uuid.UUID) (*models.Comment, error)

	// List retrieves comments based on filter parameters
	List(ctx context.Context, params models.CommentListParams) ([]models.Comment, int, error)

	// Update updates a comment
	Update(ctx context.Context, comment *models.Comment) error

	// Delete deletes a comment
	Delete(ctx context.Context, id uuid.UUID) error

	// AddMention adds a mention to a comment
	AddMention(ctx context.Context, commentID, userID uuid.UUID) error

	// GetMentions retrieves all mentions for a comment
	GetMentions(ctx context.Context, commentID uuid.UUID) ([]uuid.UUID, error)
}

CommentRepository defines the interface for comment data access

func NewPostgresCommentRepository

func NewPostgresCommentRepository(db *sqlx.DB) CommentRepository

NewPostgresCommentRepository creates a new PostgresCommentRepository

type EmployeeRepository

type EmployeeRepository interface {
	// Create creates a new employee
	Create(ctx context.Context, employee *models.Employee) error

	// GetByID retrieves an employee by ID
	GetByID(ctx context.Context, id uuid.UUID) (*models.Employee, error)

	// GetByEmployeeID retrieves an employee by employee ID
	GetByEmployeeID(ctx context.Context, organizationID uuid.UUID, employeeID string) (*models.Employee, error)

	// GetByUserID retrieves an employee by user ID
	GetByUserID(ctx context.Context, organizationID, userID uuid.UUID) (*models.Employee, error)

	// List retrieves employees based on filter parameters
	List(ctx context.Context, params models.EmployeeListParams) ([]models.Employee, int, error)

	// Update updates an employee
	Update(ctx context.Context, employee *models.Employee) error

	// Delete marks an employee as inactive
	Delete(ctx context.Context, id uuid.UUID) error

	// GetDB returns the database connection
	GetDB() *sqlx.DB
}

EmployeeRepository defines the interface for employee data access

func NewPostgresEmployeeRepository

func NewPostgresEmployeeRepository(db *sqlx.DB) EmployeeRepository

NewPostgresEmployeeRepository creates a new PostgresEmployeeRepository

type FileAttachmentRepository

type FileAttachmentRepository interface {
	// Create creates a new file attachment
	Create(ctx context.Context, fileAttachment *models.FileAttachment) error

	// GetByID retrieves a file attachment by ID
	GetByID(ctx context.Context, id uuid.UUID) (*models.FileAttachment, error)

	// List retrieves file attachments based on filter parameters
	List(ctx context.Context, params models.FileAttachmentListParams) ([]models.FileAttachment, int, error)

	// Delete deletes a file attachment
	Delete(ctx context.Context, id uuid.UUID) error
}

FileAttachmentRepository defines the interface for file attachment data access

func NewPostgresFileAttachmentRepository

func NewPostgresFileAttachmentRepository(db *sqlx.DB) FileAttachmentRepository

NewPostgresFileAttachmentRepository creates a new PostgresFileAttachmentRepository

type NotificationRepository

type NotificationRepository interface {
	// Create creates a new notification
	Create(ctx context.Context, notification *models.Notification) error

	// GetByID retrieves a notification by ID
	GetByID(ctx context.Context, id uuid.UUID) (*models.Notification, error)

	// List retrieves notifications based on filter parameters
	List(ctx context.Context, params models.NotificationListParams) ([]models.Notification, int, error)

	// MarkAsRead marks a notification as read
	MarkAsRead(ctx context.Context, id uuid.UUID) error

	// MarkAllAsRead marks all notifications for a user as read
	MarkAllAsRead(ctx context.Context, userID uuid.UUID) error

	// Delete deletes a notification
	Delete(ctx context.Context, id uuid.UUID) error

	// DeleteAllForUser deletes all notifications for a user
	DeleteAllForUser(ctx context.Context, userID uuid.UUID) error
}

NotificationRepository defines the interface for notification data access

func NewPostgresNotificationRepository

func NewPostgresNotificationRepository(db *sqlx.DB) NotificationRepository

NewPostgresNotificationRepository creates a new PostgresNotificationRepository

type OrganizationRepository

type OrganizationRepository interface {
	// Create creates a new organization
	Create(ctx context.Context, organization *models.Organization) error

	// GetByID retrieves an organization by ID
	GetByID(ctx context.Context, id uuid.UUID) (*models.Organization, error)

	// GetByName retrieves an organization by name
	GetByName(ctx context.Context, name string) (*models.Organization, error)

	// List retrieves all organizations
	List(ctx context.Context) ([]models.Organization, error)

	// Update updates an organization
	Update(ctx context.Context, organization *models.Organization) error

	// Delete marks an organization as inactive
	Delete(ctx context.Context, id uuid.UUID) error

	// AddUser adds a user to an organization
	AddUser(ctx context.Context, organizationUser *models.OrganizationUser) error

	// RemoveUser removes a user from an organization
	RemoveUser(ctx context.Context, organizationID, userID uuid.UUID) error

	// GetUsers retrieves all users in an organization
	GetUsers(ctx context.Context, organizationID uuid.UUID) ([]models.User, error)

	// GetOrganizations retrieves all organizations a user belongs to
	GetOrganizations(ctx context.Context, userID uuid.UUID) ([]models.Organization, error)

	// GetDB returns the database connection
	GetDB() *sqlx.DB
}

OrganizationRepository defines the interface for organization data access

func NewPostgresOrganizationRepository

func NewPostgresOrganizationRepository(db *sqlx.DB) OrganizationRepository

NewPostgresOrganizationRepository creates a new PostgresOrganizationRepository

type PostgresCommentRepository

type PostgresCommentRepository struct {
	// contains filtered or unexported fields
}

PostgresCommentRepository implements CommentRepository using PostgreSQL

func (*PostgresCommentRepository) AddMention

func (r *PostgresCommentRepository) AddMention(ctx context.Context, commentID, userID uuid.UUID) error

AddMention adds a mention to a comment

func (*PostgresCommentRepository) Create

func (r *PostgresCommentRepository) Create(ctx context.Context, comment *models.Comment) error

Create creates a new comment

func (*PostgresCommentRepository) Delete

Delete deletes a comment

func (*PostgresCommentRepository) GetByID

GetByID retrieves a comment by ID

func (*PostgresCommentRepository) GetMentions

func (r *PostgresCommentRepository) GetMentions(ctx context.Context, commentID uuid.UUID) ([]uuid.UUID, error)

GetMentions retrieves all mentions for a comment

func (*PostgresCommentRepository) List

List retrieves comments based on filter parameters

func (*PostgresCommentRepository) Update

func (r *PostgresCommentRepository) Update(ctx context.Context, comment *models.Comment) error

Update updates a comment

type PostgresEmployeeRepository

type PostgresEmployeeRepository struct {
	// contains filtered or unexported fields
}

PostgresEmployeeRepository implements EmployeeRepository using PostgreSQL

func (*PostgresEmployeeRepository) Create

func (r *PostgresEmployeeRepository) Create(ctx context.Context, employee *models.Employee) error

Create creates a new employee

func (*PostgresEmployeeRepository) Delete

Delete marks an employee as inactive

func (*PostgresEmployeeRepository) GetByEmployeeID

func (r *PostgresEmployeeRepository) GetByEmployeeID(ctx context.Context, organizationID uuid.UUID, employeeID string) (*models.Employee, error)

GetByEmployeeID retrieves an employee by employee ID

func (*PostgresEmployeeRepository) GetByID

GetByID retrieves an employee by ID

func (*PostgresEmployeeRepository) GetByUserID

func (r *PostgresEmployeeRepository) GetByUserID(ctx context.Context, organizationID, userID uuid.UUID) (*models.Employee, error)

GetByUserID retrieves an employee by user ID

func (*PostgresEmployeeRepository) GetDB

func (r *PostgresEmployeeRepository) GetDB() *sqlx.DB

GetDB returns the database connection

func (*PostgresEmployeeRepository) List

List retrieves employees based on filter parameters

func (*PostgresEmployeeRepository) Update

func (r *PostgresEmployeeRepository) Update(ctx context.Context, employee *models.Employee) error

Update updates an employee

type PostgresFileAttachmentRepository

type PostgresFileAttachmentRepository struct {
	// contains filtered or unexported fields
}

PostgresFileAttachmentRepository implements FileAttachmentRepository using PostgreSQL

func (*PostgresFileAttachmentRepository) Create

Create creates a new file attachment

func (*PostgresFileAttachmentRepository) Delete

Delete deletes a file attachment

func (*PostgresFileAttachmentRepository) GetByID

GetByID retrieves a file attachment by ID

func (*PostgresFileAttachmentRepository) List

List retrieves file attachments based on filter parameters

type PostgresNotificationRepository

type PostgresNotificationRepository struct {
	// contains filtered or unexported fields
}

PostgresNotificationRepository implements NotificationRepository using PostgreSQL

func (*PostgresNotificationRepository) Create

Create creates a new notification

func (*PostgresNotificationRepository) Delete

Delete deletes a notification

func (*PostgresNotificationRepository) DeleteAllForUser

func (r *PostgresNotificationRepository) DeleteAllForUser(ctx context.Context, userID uuid.UUID) error

DeleteAllForUser deletes all notifications for a user

func (*PostgresNotificationRepository) GetByID

GetByID retrieves a notification by ID

func (*PostgresNotificationRepository) List

List retrieves notifications based on filter parameters

func (*PostgresNotificationRepository) MarkAllAsRead

func (r *PostgresNotificationRepository) MarkAllAsRead(ctx context.Context, userID uuid.UUID) error

MarkAllAsRead marks all notifications for a user as read

func (*PostgresNotificationRepository) MarkAsRead

MarkAsRead marks a notification as read

type PostgresOrganizationRepository

type PostgresOrganizationRepository struct {
	// contains filtered or unexported fields
}

PostgresOrganizationRepository implements OrganizationRepository using PostgreSQL

func (*PostgresOrganizationRepository) AddUser

func (r *PostgresOrganizationRepository) AddUser(ctx context.Context, organizationUser *models.OrganizationUser) error

AddUser adds a user to an organization

func (*PostgresOrganizationRepository) Create

Create creates a new organization

func (*PostgresOrganizationRepository) Delete

Delete marks an organization as inactive

func (*PostgresOrganizationRepository) GetByID

GetByID retrieves an organization by ID

func (*PostgresOrganizationRepository) GetByName

GetByName retrieves an organization by name

func (*PostgresOrganizationRepository) GetDB

GetDB returns the database connection

func (*PostgresOrganizationRepository) GetOrganizations

func (r *PostgresOrganizationRepository) GetOrganizations(ctx context.Context, userID uuid.UUID) ([]models.Organization, error)

GetOrganizations retrieves all organizations a user belongs to

func (*PostgresOrganizationRepository) GetUsers

func (r *PostgresOrganizationRepository) GetUsers(ctx context.Context, organizationID uuid.UUID) ([]models.User, error)

GetUsers retrieves all users in an organization

func (*PostgresOrganizationRepository) List

List retrieves all organizations

func (*PostgresOrganizationRepository) RemoveUser

func (r *PostgresOrganizationRepository) RemoveUser(ctx context.Context, organizationID, userID uuid.UUID) error

RemoveUser removes a user from an organization

func (*PostgresOrganizationRepository) Update

Update updates an organization

type PostgresProjectRepository

type PostgresProjectRepository struct {
	// contains filtered or unexported fields
}

PostgresProjectRepository implements ProjectRepository using PostgreSQL

func (*PostgresProjectRepository) Create

func (r *PostgresProjectRepository) Create(ctx context.Context, project *models.Project) error

Create creates a new project

func (*PostgresProjectRepository) Delete

Delete deletes a project

func (*PostgresProjectRepository) GetByID

GetByID retrieves a project by ID

func (*PostgresProjectRepository) GetByName

func (r *PostgresProjectRepository) GetByName(ctx context.Context, organizationID uuid.UUID, name string) (*models.Project, error)

GetByName retrieves a project by name within an organization

func (*PostgresProjectRepository) List

List retrieves projects based on filter parameters

func (*PostgresProjectRepository) Update

func (r *PostgresProjectRepository) Update(ctx context.Context, project *models.Project) error

Update updates a project

type PostgresRoleRepository

type PostgresRoleRepository struct {
	// contains filtered or unexported fields
}

PostgresRoleRepository implements RoleRepository using PostgreSQL

func (*PostgresRoleRepository) AssignPermissionToRole

func (r *PostgresRoleRepository) AssignPermissionToRole(ctx context.Context, roleID, permissionID uuid.UUID) error

AssignPermissionToRole assigns a permission to a role

func (*PostgresRoleRepository) AssignRoleToUser

func (r *PostgresRoleRepository) AssignRoleToUser(ctx context.Context, userRole *models.UserRole) error

AssignRoleToUser assigns a role to a user

func (*PostgresRoleRepository) CreatePermission

func (r *PostgresRoleRepository) CreatePermission(ctx context.Context, permission *models.Permission) error

CreatePermission creates a new permission

func (*PostgresRoleRepository) CreateRole

func (r *PostgresRoleRepository) CreateRole(ctx context.Context, role *models.Role) error

CreateRole creates a new role

func (*PostgresRoleRepository) DeletePermission

func (r *PostgresRoleRepository) DeletePermission(ctx context.Context, id uuid.UUID) error

DeletePermission deletes a permission

func (*PostgresRoleRepository) DeleteRole

func (r *PostgresRoleRepository) DeleteRole(ctx context.Context, id uuid.UUID) error

DeleteRole deletes a role

func (*PostgresRoleRepository) GetPermissionByID

func (r *PostgresRoleRepository) GetPermissionByID(ctx context.Context, id uuid.UUID) (*models.Permission, error)

GetPermissionByID retrieves a permission by ID

func (*PostgresRoleRepository) GetPermissionByName

func (r *PostgresRoleRepository) GetPermissionByName(ctx context.Context, name string) (*models.Permission, error)

GetPermissionByName retrieves a permission by name

func (*PostgresRoleRepository) GetRoleByID

func (r *PostgresRoleRepository) GetRoleByID(ctx context.Context, id uuid.UUID) (*models.Role, error)

GetRoleByID retrieves a role by ID

func (*PostgresRoleRepository) GetRoleByName

func (r *PostgresRoleRepository) GetRoleByName(ctx context.Context, name string) (*models.Role, error)

GetRoleByName retrieves a role by name

func (*PostgresRoleRepository) GetRolePermissions

func (r *PostgresRoleRepository) GetRolePermissions(ctx context.Context, roleID uuid.UUID) ([]models.Permission, error)

GetRolePermissions retrieves all permissions for a role

func (*PostgresRoleRepository) GetUserRoles

func (r *PostgresRoleRepository) GetUserRoles(ctx context.Context, userID, organizationID uuid.UUID) ([]models.Role, error)

GetUserRoles retrieves all roles for a user

func (*PostgresRoleRepository) HasPermission

func (r *PostgresRoleRepository) HasPermission(ctx context.Context, userID, organizationID uuid.UUID, permissionName string) (bool, error)

HasPermission checks if a user has a specific permission

func (*PostgresRoleRepository) ListPermissions

func (r *PostgresRoleRepository) ListPermissions(ctx context.Context) ([]models.Permission, error)

ListPermissions retrieves all permissions

func (*PostgresRoleRepository) ListRoles

func (r *PostgresRoleRepository) ListRoles(ctx context.Context) ([]models.Role, error)

ListRoles retrieves all roles

func (*PostgresRoleRepository) RemovePermissionFromRole

func (r *PostgresRoleRepository) RemovePermissionFromRole(ctx context.Context, roleID, permissionID uuid.UUID) error

RemovePermissionFromRole removes a permission from a role

func (*PostgresRoleRepository) RemoveRoleFromUser

func (r *PostgresRoleRepository) RemoveRoleFromUser(ctx context.Context, userID, roleID, organizationID uuid.UUID) error

RemoveRoleFromUser removes a role from a user

func (*PostgresRoleRepository) UpdatePermission

func (r *PostgresRoleRepository) UpdatePermission(ctx context.Context, permission *models.Permission) error

UpdatePermission updates a permission

func (*PostgresRoleRepository) UpdateRole

func (r *PostgresRoleRepository) UpdateRole(ctx context.Context, role *models.Role) error

UpdateRole updates a role

type PostgresTaskRepository

type PostgresTaskRepository struct {
	// contains filtered or unexported fields
}

PostgresTaskRepository implements TaskRepository using PostgreSQL

func (*PostgresTaskRepository) AddTag

func (r *PostgresTaskRepository) AddTag(ctx context.Context, taskID uuid.UUID, tag string) error

AddTag adds a tag to a task

func (*PostgresTaskRepository) Create

func (r *PostgresTaskRepository) Create(ctx context.Context, task *models.Task) error

Create creates a new task

func (*PostgresTaskRepository) Delete

func (r *PostgresTaskRepository) Delete(ctx context.Context, id uuid.UUID) error

Delete deletes a task

func (*PostgresTaskRepository) GetByID

func (r *PostgresTaskRepository) GetByID(ctx context.Context, id uuid.UUID) (*models.Task, error)

GetByID retrieves a task by ID

func (*PostgresTaskRepository) GetTags

func (r *PostgresTaskRepository) GetTags(ctx context.Context, taskID uuid.UUID) ([]string, error)

GetTags retrieves all tags for a task

func (*PostgresTaskRepository) List

List retrieves tasks based on filter parameters

func (*PostgresTaskRepository) RemoveTag

func (r *PostgresTaskRepository) RemoveTag(ctx context.Context, taskID uuid.UUID, tag string) error

RemoveTag removes a tag from a task

func (*PostgresTaskRepository) Update

func (r *PostgresTaskRepository) Update(ctx context.Context, task *models.Task) error

Update updates a task

type PostgresTimeEntryRepository

type PostgresTimeEntryRepository struct {
	// contains filtered or unexported fields
}

PostgresTimeEntryRepository implements TimeEntryRepository using PostgreSQL

func (*PostgresTimeEntryRepository) Aggregate

Aggregate aggregates time entries based on parameters

func (*PostgresTimeEntryRepository) Create

func (r *PostgresTimeEntryRepository) Create(ctx context.Context, timeEntry *models.TimeEntry) error

Create creates a new time entry

func (*PostgresTimeEntryRepository) Delete

Delete deletes a time entry

func (*PostgresTimeEntryRepository) GetByID

GetByID retrieves a time entry by ID

func (*PostgresTimeEntryRepository) GetRunningTimeEntries

func (r *PostgresTimeEntryRepository) GetRunningTimeEntries(ctx context.Context, userID uuid.UUID) ([]models.TimeEntry, error)

GetRunningTimeEntries retrieves all running time entries for a user

func (*PostgresTimeEntryRepository) GetRunningTimeEntry

func (r *PostgresTimeEntryRepository) GetRunningTimeEntry(ctx context.Context, userID, taskID uuid.UUID) (*models.TimeEntry, error)

GetRunningTimeEntry retrieves a running time entry for a user and task

func (*PostgresTimeEntryRepository) List

List retrieves time entries based on filter parameters

func (*PostgresTimeEntryRepository) Update

func (r *PostgresTimeEntryRepository) Update(ctx context.Context, timeEntry *models.TimeEntry) error

Update updates a time entry

type PostgresUserRepository

type PostgresUserRepository struct {
	// contains filtered or unexported fields
}

PostgresUserRepository implements UserRepository using PostgreSQL

func (*PostgresUserRepository) Create

func (r *PostgresUserRepository) Create(ctx context.Context, user *models.User) error

Create creates a new user

func (*PostgresUserRepository) Delete

func (r *PostgresUserRepository) Delete(ctx context.Context, id uuid.UUID) error

Delete marks a user as inactive

func (*PostgresUserRepository) GetByEmail

func (r *PostgresUserRepository) GetByEmail(ctx context.Context, email string) (*models.User, error)

GetByEmail retrieves a user by email

func (*PostgresUserRepository) GetByID

func (r *PostgresUserRepository) GetByID(ctx context.Context, id uuid.UUID) (*models.User, error)

GetByID retrieves a user by ID

func (*PostgresUserRepository) GetDB

func (r *PostgresUserRepository) GetDB() *sqlx.DB

GetDB returns the database connection

func (*PostgresUserRepository) Update

func (r *PostgresUserRepository) Update(ctx context.Context, user *models.User) error

Update updates a user

type ProjectRepository

type ProjectRepository interface {
	// Create creates a new project
	Create(ctx context.Context, project *models.Project) error

	// GetByID retrieves a project by ID
	GetByID(ctx context.Context, id uuid.UUID) (*models.Project, error)

	// GetByName retrieves a project by name within an organization
	GetByName(ctx context.Context, organizationID uuid.UUID, name string) (*models.Project, error)

	// List retrieves projects based on filter parameters
	List(ctx context.Context, params models.ProjectListParams) ([]models.Project, int, error)

	// Update updates a project
	Update(ctx context.Context, project *models.Project) error

	// Delete deletes a project
	Delete(ctx context.Context, id uuid.UUID) error
}

ProjectRepository defines the interface for project data access

func NewPostgresProjectRepository

func NewPostgresProjectRepository(db *sqlx.DB) ProjectRepository

NewPostgresProjectRepository creates a new PostgresProjectRepository

type RoleRepository

type RoleRepository interface {
	// CreateRole creates a new role
	CreateRole(ctx context.Context, role *models.Role) error

	// GetRoleByID retrieves a role by ID
	GetRoleByID(ctx context.Context, id uuid.UUID) (*models.Role, error)

	// GetRoleByName retrieves a role by name
	GetRoleByName(ctx context.Context, name string) (*models.Role, error)

	// ListRoles retrieves all roles
	ListRoles(ctx context.Context) ([]models.Role, error)

	// UpdateRole updates a role
	UpdateRole(ctx context.Context, role *models.Role) error

	// DeleteRole deletes a role
	DeleteRole(ctx context.Context, id uuid.UUID) error

	// CreatePermission creates a new permission
	CreatePermission(ctx context.Context, permission *models.Permission) error

	// GetPermissionByID retrieves a permission by ID
	GetPermissionByID(ctx context.Context, id uuid.UUID) (*models.Permission, error)

	// GetPermissionByName retrieves a permission by name
	GetPermissionByName(ctx context.Context, name string) (*models.Permission, error)

	// ListPermissions retrieves all permissions
	ListPermissions(ctx context.Context) ([]models.Permission, error)

	// UpdatePermission updates a permission
	UpdatePermission(ctx context.Context, permission *models.Permission) error

	// DeletePermission deletes a permission
	DeletePermission(ctx context.Context, id uuid.UUID) error

	// AssignPermissionToRole assigns a permission to a role
	AssignPermissionToRole(ctx context.Context, roleID, permissionID uuid.UUID) error

	// RemovePermissionFromRole removes a permission from a role
	RemovePermissionFromRole(ctx context.Context, roleID, permissionID uuid.UUID) error

	// GetRolePermissions retrieves all permissions for a role
	GetRolePermissions(ctx context.Context, roleID uuid.UUID) ([]models.Permission, error)

	// AssignRoleToUser assigns a role to a user
	AssignRoleToUser(ctx context.Context, userRole *models.UserRole) error

	// RemoveRoleFromUser removes a role from a user
	RemoveRoleFromUser(ctx context.Context, userID, roleID, organizationID uuid.UUID) error

	// GetUserRoles retrieves all roles for a user
	GetUserRoles(ctx context.Context, userID, organizationID uuid.UUID) ([]models.Role, error)

	// HasPermission checks if a user has a specific permission
	HasPermission(ctx context.Context, userID, organizationID uuid.UUID, permissionName string) (bool, error)
}

RoleRepository defines the interface for role data access

func NewPostgresRoleRepository

func NewPostgresRoleRepository(db *sqlx.DB) RoleRepository

NewPostgresRoleRepository creates a new PostgresRoleRepository

type TaskRepository

type TaskRepository interface {
	// Create creates a new task
	Create(ctx context.Context, task *models.Task) error

	// GetByID retrieves a task by ID
	GetByID(ctx context.Context, id uuid.UUID) (*models.Task, error)

	// List retrieves tasks based on filter parameters
	List(ctx context.Context, params models.TaskListParams) ([]models.Task, int, error)

	// Update updates a task
	Update(ctx context.Context, task *models.Task) error

	// Delete deletes a task
	Delete(ctx context.Context, id uuid.UUID) error

	// AddTag adds a tag to a task
	AddTag(ctx context.Context, taskID uuid.UUID, tag string) error

	// RemoveTag removes a tag from a task
	RemoveTag(ctx context.Context, taskID uuid.UUID, tag string) error

	// GetTags retrieves all tags for a task
	GetTags(ctx context.Context, taskID uuid.UUID) ([]string, error)
}

TaskRepository defines the interface for task data access

func NewPostgresTaskRepository

func NewPostgresTaskRepository(db *sqlx.DB) TaskRepository

NewPostgresTaskRepository creates a new PostgresTaskRepository

type TimeEntryRepository

type TimeEntryRepository interface {
	// Create creates a new time entry
	Create(ctx context.Context, timeEntry *models.TimeEntry) error

	// GetByID retrieves a time entry by ID
	GetByID(ctx context.Context, id uuid.UUID) (*models.TimeEntry, error)

	// List retrieves time entries based on filter parameters
	List(ctx context.Context, params models.TimeEntryListParams) ([]models.TimeEntry, int, error)

	// Update updates a time entry
	Update(ctx context.Context, timeEntry *models.TimeEntry) error

	// Delete deletes a time entry
	Delete(ctx context.Context, id uuid.UUID) error

	// GetRunningTimeEntry retrieves a running time entry for a user and task
	GetRunningTimeEntry(ctx context.Context, userID, taskID uuid.UUID) (*models.TimeEntry, error)

	// GetRunningTimeEntries retrieves all running time entries for a user
	GetRunningTimeEntries(ctx context.Context, userID uuid.UUID) ([]models.TimeEntry, error)

	// Aggregate aggregates time entries based on parameters
	Aggregate(ctx context.Context, params models.TimeEntryAggregationParams) ([]models.TimeEntryAggregation, error)
}

TimeEntryRepository defines the interface for time entry data access

func NewPostgresTimeEntryRepository

func NewPostgresTimeEntryRepository(db *sqlx.DB) TimeEntryRepository

NewPostgresTimeEntryRepository creates a new PostgresTimeEntryRepository

type UserRepository

type UserRepository interface {
	// Create creates a new user
	Create(ctx context.Context, user *models.User) error

	// GetByID retrieves a user by ID
	GetByID(ctx context.Context, id uuid.UUID) (*models.User, error)

	// GetByEmail retrieves a user by email
	GetByEmail(ctx context.Context, email string) (*models.User, error)

	// Update updates a user
	Update(ctx context.Context, user *models.User) error

	// Delete marks a user as inactive
	Delete(ctx context.Context, id uuid.UUID) error

	// GetDB returns the database connection
	GetDB() *sqlx.DB
}

UserRepository defines the interface for user data access

func NewPostgresUserRepository

func NewPostgresUserRepository(db *sqlx.DB) UserRepository

NewPostgresUserRepository creates a new PostgresUserRepository

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址