draincloud-core/internal/storage/interface.go
2024-11-23 03:52:06 -05:00

38 lines
1.1 KiB
Go

package storage
import (
"context"
"os"
"git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models"
auditmodels "git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models/audit"
)
type Database interface {
AuthStorage
}
type AuthStorage interface {
AddUser(ctx context.Context, login string, username string, passwordHash []byte) (int64, error)
GetUserByLogin(ctx context.Context, login string) (*models.User, error)
GetUserByID(ctx context.Context, id uint64) (*models.User, error)
AddSession(ctx context.Context, ses *models.Session) (int64, error)
GetSession(ctx context.Context, sessionToken string) (*models.Session, error)
RemoveSession(ctx context.Context, id int64) error
}
type AuthAuditLogStorage interface {
AddEntry(ctx context.Context, entry auditmodels.AuditLogEntry) error
}
type MetaStorage interface {
SaveMetadata(ctx context.Context, fileType string, size int64, ext string) (int64, error)
}
type BlobStorage interface {
GetFile(ctx context.Context, id int64) (*os.File, error)
SaveBlob(ctx context.Context, id int64, data []byte) error
DeleteFile(ctx context.Context, id int64) error
}