model

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package model is the initial database driver and define the data structures corresponding to the tables.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrRecordNotFound no records found
	ErrRecordNotFound = gorm.ErrRecordNotFound
)

Functions

func CloseDB

func CloseDB() error

CloseDB close db

func DeleteById

func DeleteById[T any](id int) *gorm.DB

func FindFirstByID

func FindFirstByID[T any](id int) *T

func FindItems

func FindItems[T any]() []*T

func GetDB

func GetDB() *gorm.DB

GetDB get db

func InitDB

func InitDB()

InitDB connect database

func InitSqlite

func InitSqlite()

InitSqlite connect sqlite

func Save

func Save(value interface{}) *gorm.DB

func ToList

func ToList(items []*Quick) []list.Item

Types

type File

type File struct {
	*bdpan.FileInfo `gorm:"-"`
	ID              uint64 `gorm:"primaryKey;"`
	FSID            uint64 `json:"fs_id" gorm:"column:fs_id"`
	Path            string `json:"path"`
	Dir             string `json:"dir"`
	Size            int    `json:"size"`
	FileType        int    `json:"isdir" gorm:"column:is_dir"`
	Filename        string `json:"filename"`
	ServerFilename  string `json:"server_filename"`
	Category        int    `json:"category"`
	Dlink           string `json:"dlink"`
	MD5             string `json:"md5"`
	ServerCTime     int64  `json:"server_ctime"`
	ServerMTime     int64  `json:"server_mtime"`
	LocalCTime      int64  `json:"local_ctime"`
	LocalMTime      int64  `json:"local_mtime"`

	// custom
	IsRefresh int  `json:"is_refresh"`
	Level     int  `json:"level"`
	IsSelect  bool `gorm:"-" json:"is_select"` // 是否选中,tui 表格使用
	ORMModel
}

生成 sqlite3 建表语句,开头加上删除语句 sqlite3 字段要符合 gorm 命名规则

func FindFilesByDir

func FindFilesByDir(dir string, page int) []*File

func FindFilesPrefixPath

func FindFilesPrefixPath(path string, isDir bool) []*File

func FindFirstByPath

func FindFirstByPath(path string) *File

func FindNeedRefreshFiles

func FindNeedRefreshFiles(path string) []*File

func NewFile

func NewFile(f *bdpan.FileInfo) *File

func NewFiles

func NewFiles(files []*bdpan.FileInfo) []*File

func NewRootFile

func NewRootFile() *File

func (*File) Fill

func (f *File) Fill() *File

func (*File) Resave

func (f *File) Resave() *gorm.DB

func (*File) Save

func (f *File) Save() *gorm.DB

func (File) TableName

func (File) TableName() string

func (*File) ToQuick

func (f *File) ToQuick() *Quick

type ORMModel

type ORMModel struct {
	CreateTime time.Time `json:"create_time"`
	UpdateTime time.Time `json:"update_time"`
	IsDelete   int8      `json:"is_delete" form:"is_delete" gorm:"index"`
}

func (*ORMModel) Init

func (o *ORMModel) Init()

func (ORMModel) IsNil

func (o ORMModel) IsNil() bool

type Pan

type Pan struct {
	*bdpan.GetPanInfoRes `gorm:"-"`
	ID                   int   `gorm:"primaryKey;"`
	Total                int64 `json:"total,omitempty"`
	Free                 int64 `json:"free,omitempty"`
	Expire               bool  `json:"expire,omitempty"`
	Used                 int64 `json:"used,omitempty"`
}

func NewPan

func NewPan(id int, pan *bdpan.GetPanInfoRes) *Pan

type Quick

type Quick struct {
	ID       uint64 `gorm:"primaryKey;"`
	Filename string `json:"filename"`
	Path     string `json:"path"`
	Key      string `json:"key"`
	ORMModel
}

func (Quick) Description

func (q Quick) Description() string

func (Quick) FilterValue

func (q Quick) FilterValue() string

func (Quick) TableName

func (Quick) TableName() string

func (Quick) Title

func (q Quick) Title() string

type User

type User struct {
	*bdpan.GetUserInfoRes `gorm:"-"`
	ID                    int    `gorm:"primaryKey;"`
	Uk                    int    `json:"uk,omitempty"`
	AvatarUrl             string `json:"avatar_url,omitempty"`
	BaiduName             string `json:"baidu_name,omitempty"`
	NetdiskName           string `json:"netdisk_name,omitempty"`
	VipType               int32  `json:"vip_type,omitempty"`
	VipName               string `json:"vip_name,omitempty"`
}

func NewUser

func NewUser(user *bdpan.GetUserInfoRes) *User

Jump to

Keyboard shortcuts

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