db

package
v1.3.0-rc.0...-0a48220 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseModel

type BaseModel struct {
	ID        int64     `json:"id" gorm:"primary_key"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

BaseModel common info for all models

type Client

type Client struct {
	*gorm.DB
}

func (*Client) CreateFile

func (client *Client) CreateFile(file *File) error

func (*Client) DeleteFile

func (client *Client) DeleteFile(id uint64) error

func (*Client) GetFile

func (client *Client) GetFile(id uint64) (File, error)

func (*Client) GetFileByUUID

func (client *Client) GetFileByUUID(uuid string) (File, error)

func (*Client) ListExpiredFiles

func (client *Client) ListExpiredFiles(expiredAt time.Time) ([]File, error)

type File

type File struct {
	BaseModel

	UUID             string       // UUID,解决重名问题;用自增 id 在存储介质上容易冲突
	DisplayName      string       // 文件名,用于下载的时候展示
	Ext              string       // 文件后缀,带 dot
	ByteSize         int64        // 文件大小,Byte
	StorageType      storage.Type // 存储类型
	FullRelativePath string       // 文件相对路径,不包含 网盘挂载点 或 oss bucket
	From             string       // 文件来源,例如 issue / gittar mr
	Creator          string       // 文件创建者 ID
	Extra            FileExtra    // 额外信息,包括存储介质关键信息快照等
	ExpiredAt        *time.Time   // 文件超时自动删除
}

func (File) TableName

func (File) TableName() string

type FileExtra

type FileExtra struct {
	OSSSnapshot OSSSnapshot `json:"ossSnapshot,omitempty"`
	IsPublic    bool        `json:"isPublic,omitempty"`

	Encrypt             bool   `json:"encrypt,omitempty"`
	KMSKeyID            string `json:"kmsKeyID,omitempty"`
	DEKCiphertextBase64 string `json:"dekCiphertextBase64,omitempty"`
}

func (*FileExtra) Scan

func (ex *FileExtra) Scan(value interface{}) error

func (FileExtra) Value

func (ex FileExtra) Value() (driver.Value, error)

type OSSSnapshot

type OSSSnapshot struct {
	OSSEndpoint string `json:"ossEndpoint,omitempty"`
	OSSBucket   string `json:"ossBucket,omitempty"`
}

Jump to

Keyboard shortcuts

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