db

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChunkQuery

type ChunkQuery struct {
	gorm.Model
	UploadID   string `json:"upload_id"`
	ChunkIndex *int   `json:"chunk_index"`
	Status     string `json:"status"`
	Completed  *bool  `json:"completed"`
	Limit      int    `json:"limit"`
	Offset     int    `json:"offset"`
}

ChunkQuery 分片查询条件

type ChunkStats

type ChunkStats struct {
	gorm.Model
	TotalChunks     int64 `json:"total_chunks"`
	CompletedChunks int64 `json:"completed_chunks"`
	PendingChunks   int64 `json:"pending_chunks"`
	FailedChunks    int64 `json:"failed_chunks"`
}

ChunkStats 分片统计查询结果

type ChunkUpdate

type ChunkUpdate struct {
	gorm.Model
	ChunkHash  *string    `json:"chunk_hash"`
	Completed  *bool      `json:"completed"`
	RetryCount *int       `json:"retry_count"`
	LastError  *string    `json:"last_error"`
	Status     *string    `json:"status"`
	UpdatedAt  *time.Time `json:"updated_at"`
}

ChunkUpdate 分片更新数据

type FileCode

type FileCode struct {
	gorm.Model
	Code         string     `gorm:"uniqueIndex;size:255" json:"code"`
	Prefix       string     `gorm:"size:255" json:"prefix"`
	Suffix       string     `gorm:"size:255" json:"suffix"`
	UUIDFileName string     `gorm:"size:255" json:"uuid_file_name"`
	FilePath     string     `gorm:"size:255" json:"file_path"`
	Size         int64      `gorm:"default:0" json:"size"`
	Text         string     `gorm:"type:text" json:"text"`
	ExpiredAt    *time.Time `json:"expired_at"`
	ExpiredCount int        `gorm:"default:0" json:"expired_count"`
	UsedCount    int        `gorm:"default:0" json:"used_count"`

	FileHash  string `gorm:"size:64" json:"file_hash"`
	IsChunked bool   `gorm:"default:false" json:"is_chunked"`
	UploadID  string `gorm:"size:36" json:"upload_id"`

	// 新增:用户认证相关字段
	UserID      *uint  `gorm:"index" json:"user_id"`                           // 上传用户ID,为null表示匿名上传
	UploadType  string `gorm:"size:20;default:'anonymous'" json:"upload_type"` // anonymous, authenticated
	RequireAuth bool   `gorm:"default:false" json:"require_auth"`              // 是否需要登录才能下载
	OwnerIP     string `gorm:"size:45" json:"owner_ip"`                        // 上传者IP地址
}

FileCode 文件代码模型

func (*FileCode) GetFilePath

func (f *FileCode) GetFilePath() string

GetFilePath 获取文件路径

func (*FileCode) IsExpired

func (f *FileCode) IsExpired() bool

IsExpired 检查是否过期

type FileCodeQuery

type FileCodeQuery struct {
	gorm.Model
	Code        string     `json:"code"`
	UserID      *uint      `json:"user_id"`
	UploadType  string     `json:"upload_type"`
	RequireAuth *bool      `json:"require_auth"`
	IsExpired   *bool      `json:"is_expired"`
	Search      string     `json:"search"` // 模糊搜索文件名
	StartDate   *time.Time `json:"start_date"`
	EndDate     *time.Time `json:"end_date"`
	Limit       int        `json:"limit"`
	Offset      int        `json:"offset"`
}

FileCodeQuery 文件代码查询条件

type FileCodeStats

type FileCodeStats struct {
	gorm.Model
	TotalFiles     int64 `json:"total_files"`
	TotalSize      int64 `json:"total_size"`
	TodayUploads   int64 `json:"today_uploads"`
	TodayDownloads int64 `json:"today_downloads"`
	ExpiredFiles   int64 `json:"expired_files"`
	AnonymousFiles int64 `json:"anonymous_files"`
	UserFiles      int64 `json:"user_files"`
}

FileCodeStats 文件统计查询结果

type FileCodeUpdate

type FileCodeUpdate struct {
	gorm.Model
	ExpiredAt    *time.Time `json:"expired_at"`
	ExpiredCount *int       `json:"expired_count"`
	UsedCount    *int       `json:"used_count"`
	RequireAuth  *bool      `json:"require_auth"`
	OwnerIP      *string    `json:"owner_ip"`
}

FileCodeUpdate 文件代码更新数据

type KeyValue

type KeyValue struct {
	gorm.Model
	Key   string `gorm:"uniqueIndex;size:255" json:"key"`
	Value string `gorm:"type:text" json:"value"`
}

KeyValue 键值对模型

type KeyValueQuery

type KeyValueQuery struct {
	gorm.Model
	Key       string `json:"key"`
	KeyPrefix string `json:"key_prefix"` // 前缀匹配
	Limit     int    `json:"limit"`
	Offset    int    `json:"offset"`
}

KeyValueQuery 键值对查询条件

type KeyValueUpdate

type KeyValueUpdate struct {
	gorm.Model
	Value     *string    `json:"value"`
	UpdatedAt *time.Time `json:"updated_at"`
}

KeyValueUpdate 键值对更新数据

type SessionQuery

type SessionQuery struct {
	gorm.Model
	UserID    *uint      `json:"user_id"`
	SessionID string     `json:"session_id"`
	IPAddress string     `json:"ip_address"`
	IsActive  *bool      `json:"is_active"`
	StartDate *time.Time `json:"start_date"`
	EndDate   *time.Time `json:"end_date"`
	Limit     int        `json:"limit"`
	Offset    int        `json:"offset"`
}

SessionQuery 会话查询条件

type SessionUpdate

type SessionUpdate struct {
	gorm.Model
	IsActive  *bool      `json:"is_active"`
	ExpiresAt *time.Time `json:"expires_at"`
	UpdatedAt *time.Time `json:"updated_at"`
}

SessionUpdate 会话更新数据

type UploadChunk

type UploadChunk struct {
	ID          uint      `gorm:"primarykey" json:"id"`
	UploadID    string    `gorm:"index;size:36" json:"upload_id"`
	ChunkIndex  int       `json:"chunk_index"`
	ChunkHash   string    `gorm:"size:64" json:"chunk_hash"`
	TotalChunks int       `json:"total_chunks"`
	FileSize    int64     `json:"file_size"`
	ChunkSize   int       `json:"chunk_size"`
	FileName    string    `gorm:"size:255" json:"file_name"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	Completed   bool      `gorm:"default:false" json:"completed"`
	RetryCount  int       `gorm:"default:0" json:"retry_count"`            // 重试次数
	LastError   string    `gorm:"type:text" json:"last_error"`             // 最后错误信息
	Status      string    `gorm:"size:20;default:'pending'" json:"status"` // pending, uploading, completed, failed
}

UploadChunk 上传分片模型

type User

type User struct {
	gorm.Model
	Username      string     `gorm:"uniqueIndex;size:50" json:"username"`
	Email         string     `gorm:"uniqueIndex;size:100" json:"email"`
	PasswordHash  string     `gorm:"size:128" json:"-"`                      // 密码哈希,不返回给前端
	Nickname      string     `gorm:"size:50" json:"nickname"`                // 用户昵称
	Avatar        string     `gorm:"size:255" json:"avatar"`                 // 头像URL
	Role          string     `gorm:"size:20;default:'user'" json:"role"`     // admin, user
	Status        string     `gorm:"size:20;default:'active'" json:"status"` // active, inactive, banned
	EmailVerified bool       `gorm:"default:false" json:"email_verified"`    // 邮箱是否验证
	LastLoginAt   *time.Time `json:"last_login_at"`                          // 最后登录时间
	LastLoginIP   string     `gorm:"size:45" json:"last_login_ip"`           // 最后登录IP

	// 用户上传统计
	TotalUploads    int   `gorm:"default:0" json:"total_uploads"`     // 总上传次数
	TotalDownloads  int   `gorm:"default:0" json:"total_downloads"`   // 总下载次数
	TotalStorage    int64 `gorm:"default:0" json:"total_storage"`     // 总存储大小(字节)
	MaxUploadSize   int64 `gorm:"default:0" json:"max_upload_size"`   // 最大单次上传大小(字节),0表示使用系统默认
	MaxStorageQuota int64 `gorm:"default:0" json:"max_storage_quota"` // 最大存储配额(字节),0表示无限制
}

User 用户模型

type UserQuery

type UserQuery struct {
	gorm.Model
	ID       *uint  `json:"id"`
	Username string `json:"username"`
	Email    string `json:"email"`
	Role     string `json:"role"`
	Status   string `json:"status"`
	Search   string `json:"search"` // 模糊搜索用户名或邮箱
	Limit    int    `json:"limit"`
	Offset   int    `json:"offset"`
}

UserQuery 用户查询条件

type UserSession

type UserSession struct {
	gorm.Model
	UserID    uint      `gorm:"index" json:"user_id"`
	SessionID string    `gorm:"uniqueIndex;size:128" json:"session_id"` // JWT token ID
	IPAddress string    `gorm:"size:45" json:"ip_address"`              // 登录IP
	UserAgent string    `gorm:"size:500" json:"user_agent"`             // 用户代理
	ExpiresAt time.Time `json:"expires_at"`                             // 过期时间

	IsActive bool `gorm:"default:true" json:"is_active"` // 是否活跃
}

UserSession 用户会话模型

type UserStats

type UserStats struct {
	gorm.Model
	UserID         uint  `json:"user_id"`
	TotalUploads   int   `json:"total_uploads"`
	TotalDownloads int   `json:"total_downloads"`
	TotalStorage   int64 `json:"total_storage"`
	FileCount      int   `json:"file_count"`
}

UserStats 用户统计查询结果

type UserUpdate

type UserUpdate struct {
	gorm.Model
	Username      *string    `json:"username"`
	Email         *string    `json:"email"`
	PasswordHash  *string    `json:"password_hash"`
	Nickname      *string    `json:"nickname"`
	Avatar        *string    `json:"avatar"`
	Role          *string    `json:"role"`
	Status        *string    `json:"status"`
	EmailVerified *bool      `json:"email_verified"`
	LastLoginAt   *time.Time `json:"last_login_at"`
	LastLoginIP   *string    `json:"last_login_ip"`
}

UserUpdate 用户更新数据

Jump to

Keyboard shortcuts

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