database

package
v0.0.0-...-7fb66d3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID           int64  `json:"-" db:"id"`
	Email        string `json:"email" db:"email"`
	Name         string `json:"name" db:"name"`
	PasswordHash string `json:"-" db:"password_hash"`
}

func (*Account) CheckPassword

func (a *Account) CheckPassword(clear_password string) bool

func (*Account) HashPassword

func (a *Account) HashPassword(clear_password string) error

type File

type File struct {
	ID         int64     `json:"id,omitempty" db:"id"`
	Name       string    `json:"name" db:"name"`
	MimeType   string    `json:"mime_type" db:"mime_type"`
	Size       int64     `json:"size" db:"size"`
	SystemPath string    `json:"system_path" db:"system_path"`
	FolderId   int64     `json:"folder_id" db:"folder_id"`
	CreatedAt  time.Time `json:"created_at,omitempty" db:"created_at"`
}

func (*File) DownloadPath

func (f *File) DownloadPath() string

func (*File) FormatSize

func (f *File) FormatSize() string

func (*File) FormatTime

func (f *File) FormatTime() string

func (*File) PreviewPath

func (f *File) PreviewPath() string

type Folder

type Folder struct {
	ID        int64     `json:"id" db:"id"`
	Name      string    `json:"name" db:"name"`
	Color     string    `json:"color" db:"color"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
}

type Repository

type Repository interface {
	Migrate() error
	GetAccount(id int64) (*Account, error)
	GetAccountByEmail(email string) (*Account, error)
	CreateAccount(email, name, password string) (*Account, error)
	ChangeAccount(id int64, user *Account) error
	AllFiles() ([]File, error)
	SaveFile(file *File) error
	GetFile(file_id int64) (*File, error)
	DeleteFile(file_id int64) error
	ChangeFile(file *File) error
	GetFolder(folder_id int64) (*Folder, error)
	CreateFolder(folder *Folder) error
	ChangeFolder(folder *Folder) error
	DeleteFolder(folder_id int64) error
}

type SQLiteRepository

type SQLiteRepository struct {
	DB *sql.DB
}

func InitSQLiteRepository

func InitSQLiteRepository(db *sql.DB) *SQLiteRepository

func (*SQLiteRepository) AllFiles

func (db *SQLiteRepository) AllFiles() ([]File, error)

func (*SQLiteRepository) ChangeAccount

func (db *SQLiteRepository) ChangeAccount(id int64, user *Account) error

func (*SQLiteRepository) ChangeFile

func (db *SQLiteRepository) ChangeFile(file *File) error

"move" file from folder or IN folder is the same as ChangeFile. So it's unnececery to create separate handlers

func (*SQLiteRepository) ChangeFolder

func (db *SQLiteRepository) ChangeFolder(folder *Folder) error

func (*SQLiteRepository) CreateAccount

func (db *SQLiteRepository) CreateAccount(email, name, password string) (*Account, error)

func (*SQLiteRepository) CreateFolder

func (db *SQLiteRepository) CreateFolder(folder *Folder) error

func (*SQLiteRepository) DeleteFile

func (db *SQLiteRepository) DeleteFile(file_id int64) error

func (*SQLiteRepository) DeleteFolder

func (db *SQLiteRepository) DeleteFolder(folder_id int64) error

func (*SQLiteRepository) GetAccount

func (db *SQLiteRepository) GetAccount(id int64) (*Account, error)

func (*SQLiteRepository) GetAccountByEmail

func (db *SQLiteRepository) GetAccountByEmail(email string) (*Account, error)

func (*SQLiteRepository) GetFile

func (db *SQLiteRepository) GetFile(file_id int64) (*File, error)

func (*SQLiteRepository) GetFolder

func (db *SQLiteRepository) GetFolder(folder_id int64) (*Folder, error)

func (*SQLiteRepository) Migrate

func (db *SQLiteRepository) Migrate() error

func (*SQLiteRepository) SaveFile

func (db *SQLiteRepository) SaveFile(file *File) error

Jump to

Keyboard shortcuts

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