entity

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileStatusActive   = "active"   // 正常
	FileStatusInactive = "inactive" // 禁用
	FileStatusDeleted  = "deleted"  // 已删除
)

FileStatus 文件状态常量

View Source
const (
	// SEO 配置
	ConfigKeySiteTitle       = "site_title"
	ConfigKeySiteDescription = "site_description"
	ConfigKeyKeywords        = "keywords"
	ConfigKeyAuthor          = "author"
	ConfigKeyCopyright       = "copyright"

	// 自动处理配置组
	ConfigKeyAutoProcessReadyResources = "auto_process_ready_resources"
	ConfigKeyAutoProcessInterval       = "auto_process_interval"
	ConfigKeyAutoTransferEnabled       = "auto_transfer_enabled"
	ConfigKeyAutoTransferLimitDays     = "auto_transfer_limit_days"
	ConfigKeyAutoTransferMinSpace      = "auto_transfer_min_space"
	ConfigKeyAutoFetchHotDramaEnabled  = "auto_fetch_hot_drama_enabled"

	// API配置
	ConfigKeyApiToken = "api_token"

	// 违禁词配置
	ConfigKeyForbiddenWords = "forbidden_words"

	// 广告配置
	ConfigKeyAdKeywords   = "ad_keywords"    // 广告关键词
	ConfigKeyAutoInsertAd = "auto_insert_ad" // 自动插入广告

	// 其他配置
	ConfigKeyPageSize        = "page_size"
	ConfigKeyMaintenanceMode = "maintenance_mode"
	ConfigKeyEnableRegister  = "enable_register"

	// 三方统计配置
	ConfigKeyThirdPartyStatsCode = "third_party_stats_code"

	// Meilisearch配置
	ConfigKeyMeilisearchEnabled   = "meilisearch_enabled"
	ConfigKeyMeilisearchHost      = "meilisearch_host"
	ConfigKeyMeilisearchPort      = "meilisearch_port"
	ConfigKeyMeilisearchMasterKey = "meilisearch_master_key"
	ConfigKeyMeilisearchIndexName = "meilisearch_index_name"

	// Telegram配置
	ConfigKeyTelegramBotEnabled         = "telegram_bot_enabled"
	ConfigKeyTelegramBotApiKey          = "telegram_bot_api_key"
	ConfigKeyTelegramAutoReplyEnabled   = "telegram_auto_reply_enabled"
	ConfigKeyTelegramAutoReplyTemplate  = "telegram_auto_reply_template"
	ConfigKeyTelegramAutoDeleteEnabled  = "telegram_auto_delete_enabled"
	ConfigKeyTelegramAutoDeleteInterval = "telegram_auto_delete_interval"
	ConfigKeyTelegramProxyEnabled       = "telegram_proxy_enabled"
	ConfigKeyTelegramProxyType          = "telegram_proxy_type"
	ConfigKeyTelegramProxyHost          = "telegram_proxy_host"
	ConfigKeyTelegramProxyPort          = "telegram_proxy_port"
	ConfigKeyTelegramProxyUsername      = "telegram_proxy_username"
	ConfigKeyTelegramProxyPassword      = "telegram_proxy_password"

	// 界面配置
	ConfigKeyEnableAnnouncements = "enable_announcements"
	ConfigKeyAnnouncements       = "announcements"
	ConfigKeyEnableFloatButtons  = "enable_float_buttons"
	ConfigKeyWechatSearchImage   = "wechat_search_image"
	ConfigKeyTelegramQrImage     = "telegram_qr_image"
	ConfigKeyQrCodeStyle         = "qr_code_style"
)

ConfigKey 配置键常量

View Source
const (
	ConfigTypeString = "string"
	ConfigTypeInt    = "int"
	ConfigTypeBool   = "bool"
	ConfigTypeJSON   = "json"
)

ConfigType 配置类型常量

View Source
const (
	// 基础字段
	ConfigResponseFieldID        = "id"
	ConfigResponseFieldCreatedAt = "created_at"
	ConfigResponseFieldUpdatedAt = "updated_at"

	// SEO 配置字段
	ConfigResponseFieldSiteTitle       = "site_title"
	ConfigResponseFieldSiteDescription = "site_description"
	ConfigResponseFieldKeywords        = "keywords"
	ConfigResponseFieldAuthor          = "author"
	ConfigResponseFieldCopyright       = "copyright"

	// 自动处理配置字段
	ConfigResponseFieldAutoProcessReadyResources = "auto_process_ready_resources"
	ConfigResponseFieldAutoProcessInterval       = "auto_process_interval"
	ConfigResponseFieldAutoTransferEnabled       = "auto_transfer_enabled"
	ConfigResponseFieldAutoTransferLimitDays     = "auto_transfer_limit_days"
	ConfigResponseFieldAutoTransferMinSpace      = "auto_transfer_min_space"
	ConfigResponseFieldAutoFetchHotDramaEnabled  = "auto_fetch_hot_drama_enabled"

	// API配置字段
	ConfigResponseFieldApiToken = "api_token"

	// 违禁词配置字段
	ConfigResponseFieldForbiddenWords = "forbidden_words"

	// 广告配置字段
	ConfigResponseFieldAdKeywords   = "ad_keywords"
	ConfigResponseFieldAutoInsertAd = "auto_insert_ad"

	// 其他配置字段
	ConfigResponseFieldPageSize        = "page_size"
	ConfigResponseFieldMaintenanceMode = "maintenance_mode"
	ConfigResponseFieldEnableRegister  = "enable_register"

	// 三方统计配置字段
	ConfigResponseFieldThirdPartyStatsCode = "third_party_stats_code"

	// Meilisearch配置字段
	ConfigResponseFieldMeilisearchEnabled   = "meilisearch_enabled"
	ConfigResponseFieldMeilisearchHost      = "meilisearch_host"
	ConfigResponseFieldMeilisearchPort      = "meilisearch_port"
	ConfigResponseFieldMeilisearchMasterKey = "meilisearch_master_key"
	ConfigResponseFieldMeilisearchIndexName = "meilisearch_index_name"

	// Telegram配置字段
	ConfigResponseFieldTelegramBotEnabled         = "telegram_bot_enabled"
	ConfigResponseFieldTelegramBotApiKey          = "telegram_bot_api_key"
	ConfigResponseFieldTelegramAutoReplyEnabled   = "telegram_auto_reply_enabled"
	ConfigResponseFieldTelegramAutoReplyTemplate  = "telegram_auto_reply_template"
	ConfigResponseFieldTelegramAutoDeleteEnabled  = "telegram_auto_delete_enabled"
	ConfigResponseFieldTelegramAutoDeleteInterval = "telegram_auto_delete_interval"
	ConfigResponseFieldTelegramProxyEnabled       = "telegram_proxy_enabled"
	ConfigResponseFieldTelegramProxyType          = "telegram_proxy_type"
	ConfigResponseFieldTelegramProxyHost          = "telegram_proxy_host"
	ConfigResponseFieldTelegramProxyPort          = "telegram_proxy_port"
	ConfigResponseFieldTelegramProxyUsername      = "telegram_proxy_username"
	ConfigResponseFieldTelegramProxyPassword      = "telegram_proxy_password"

	// 界面配置字段
	ConfigResponseFieldEnableAnnouncements = "enable_announcements"
	ConfigResponseFieldAnnouncements       = "announcements"
	ConfigResponseFieldEnableFloatButtons  = "enable_float_buttons"
	ConfigResponseFieldWechatSearchImage   = "wechat_search_image"
	ConfigResponseFieldTelegramQrImage     = "telegram_qr_image"
	ConfigResponseFieldQrCodeStyle         = "qr_code_style"
)

ConfigResponseField API响应字段名常量

View Source
const (
	// SEO 配置默认值
	ConfigDefaultSiteTitle       = "老九网盘资源数据库"
	ConfigDefaultSiteDescription = "专业的老九网盘资源数据库"
	ConfigDefaultKeywords        = "网盘,资源管理,文件分享"
	ConfigDefaultAuthor          = "系统管理员"
	ConfigDefaultCopyright       = "© 2024 老九网盘资源数据库"

	// 自动处理配置默认值
	ConfigDefaultAutoProcessReadyResources = "false"
	ConfigDefaultAutoProcessInterval       = "30"
	ConfigDefaultAutoTransferEnabled       = "false"
	ConfigDefaultAutoTransferLimitDays     = "0"
	ConfigDefaultAutoTransferMinSpace      = "100"
	ConfigDefaultAutoFetchHotDramaEnabled  = "false"

	// API配置默认值
	ConfigDefaultApiToken = ""

	// 违禁词配置默认值
	ConfigDefaultForbiddenWords = ""

	// 广告配置默认值
	ConfigDefaultAdKeywords   = ""
	ConfigDefaultAutoInsertAd = ""

	// 其他配置默认值
	ConfigDefaultPageSize        = "100"
	ConfigDefaultMaintenanceMode = "false"
	ConfigDefaultEnableRegister  = "true"

	// 三方统计配置默认值
	ConfigDefaultThirdPartyStatsCode = ""

	// Meilisearch配置默认值
	ConfigDefaultMeilisearchEnabled   = "false"
	ConfigDefaultMeilisearchHost      = "localhost"
	ConfigDefaultMeilisearchPort      = "7700"
	ConfigDefaultMeilisearchMasterKey = ""
	ConfigDefaultMeilisearchIndexName = "resources"

	// Telegram配置默认值
	ConfigDefaultTelegramBotEnabled         = "false"
	ConfigDefaultTelegramBotApiKey          = ""
	ConfigDefaultTelegramAutoReplyEnabled   = "true"
	ConfigDefaultTelegramAutoReplyTemplate  = "您好!我可以帮您搜索网盘资源,请输入您要搜索的内容。"
	ConfigDefaultTelegramAutoDeleteEnabled  = "false"
	ConfigDefaultTelegramAutoDeleteInterval = "60"
	ConfigDefaultTelegramProxyEnabled       = "false"
	ConfigDefaultTelegramProxyType          = "http"
	ConfigDefaultTelegramProxyHost          = ""
	ConfigDefaultTelegramProxyPort          = "8080"
	ConfigDefaultTelegramProxyUsername      = ""
	ConfigDefaultTelegramProxyPassword      = ""

	// 界面配置默认值
	ConfigDefaultEnableAnnouncements = "false"
	ConfigDefaultAnnouncements       = ""
	ConfigDefaultEnableFloatButtons  = "false"
	ConfigDefaultWechatSearchImage   = ""
	ConfigDefaultTelegramQrImage     = ""
	ConfigDefaultQrCodeStyle         = "Plain"
)

ConfigDefaultValue 配置默认值常量

Variables

This section is empty.

Functions

This section is empty.

Types

type APIAccessLog added in v1.3.1

type APIAccessLog struct {
	ID             uint           `json:"id" gorm:"primaryKey;autoIncrement"`
	IP             string         `json:"ip" gorm:"size:45;not null;comment:客户端IP地址"`
	UserAgent      string         `json:"user_agent" gorm:"size:500;comment:用户代理"`
	Endpoint       string         `json:"endpoint" gorm:"size:255;not null;comment:访问的接口路径"`
	Method         string         `json:"method" gorm:"size:10;not null;comment:HTTP方法"`
	RequestParams  string         `json:"request_params" gorm:"type:text;comment:查询参数(JSON格式)"`
	ResponseStatus int            `json:"response_status" gorm:"default:200;comment:响应状态码"`
	ResponseData   string         `json:"response_data" gorm:"type:text;comment:响应数据(JSON格式)"`
	ProcessCount   int            `json:"process_count" gorm:"default:0;comment:处理数量(查询结果数或添加的数量)"`
	ErrorMessage   string         `json:"error_message" gorm:"size:500;comment:错误消息"`
	ProcessingTime int64          `json:"processing_time" gorm:"comment:处理时间(毫秒)"`
	CreatedAt      time.Time      `json:"created_at"`
	UpdatedAt      time.Time      `json:"updated_at"`
	DeletedAt      gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}

APIAccessLog API访问日志模型

func (APIAccessLog) TableName added in v1.3.1

func (APIAccessLog) TableName() string

TableName 指定表名

type APIAccessLogStats added in v1.3.1

type APIAccessLogStats struct {
	Endpoint       string    `json:"endpoint"`
	Method         string    `json:"method"`
	RequestCount   int64     `json:"request_count"`
	ErrorCount     int64     `json:"error_count"`
	AvgProcessTime int64     `json:"avg_process_time"`
	LastAccess     time.Time `json:"last_access"`
}

APIAccessLogStats 按端点统计

type APIAccessLogSummary added in v1.3.1

type APIAccessLogSummary struct {
	TotalRequests int64 `json:"total_requests"`
	TodayRequests int64 `json:"today_requests"`
	WeekRequests  int64 `json:"week_requests"`
	MonthRequests int64 `json:"month_requests"`
	ErrorRequests int64 `json:"error_requests"`
	UniqueIPs     int64 `json:"unique_ips"`
}

APIAccessLogSummary API访问日志汇总统计

type Category

type Category struct {
	ID          uint           `json:"id" gorm:"primaryKey;autoIncrement"`
	Name        string         `json:"name" gorm:"size:100;not null;unique;comment:分类名称"`
	Description string         `json:"description" gorm:"type:text;comment:分类描述"`
	CreatedAt   time.Time      `json:"created_at"`
	UpdatedAt   time.Time      `json:"updated_at"`
	DeletedAt   gorm.DeletedAt `json:"deleted_at" gorm:"index"`

	// 关联关系
	Resources []Resource `json:"resources" gorm:"foreignKey:CategoryID"`
	Tags      []Tag      `json:"tags" gorm:"foreignKey:CategoryID"`
}

Category 分类模型

func (Category) TableName

func (Category) TableName() string

TableName 指定表名

type Cks

type Cks struct {
	ID          uint           `json:"id" gorm:"primaryKey;autoIncrement"`
	PanID       uint           `json:"pan_id" gorm:"not null;comment:平台ID"`
	Idx         int            `json:"idx" gorm:"comment:索引"`
	Ck          string         `json:"ck" gorm:"type:text;comment:cookie"`
	IsValid     bool           `json:"is_valid" gorm:"default:true;comment:是否有效"`
	Space       int64          `json:"space" gorm:"default:0;comment:总空间(字节)"`
	LeftSpace   int64          `json:"left_space" gorm:"default:0;comment:剩余空间(字节)"`
	UsedSpace   int64          `json:"used_space" gorm:"default:0;comment:已使用空间(字节)"`
	Username    string         `json:"username" gorm:"size:100;comment:用户名"`
	VipStatus   bool           `json:"vip_status" gorm:"default:false;comment:VIP状态"`
	ServiceType string         `json:"service_type" gorm:"size:20;comment:服务类型"`
	Remark      string         `json:"remark" gorm:"size:64;not null;comment:备注"`
	Extra       string         `json:"extra" gorm:"type:text;comment:额外的中间数据如token等"`
	CreatedAt   time.Time      `json:"created_at"`
	UpdatedAt   time.Time      `json:"updated_at"`
	DeletedAt   gorm.DeletedAt `json:"deleted_at" gorm:"index"`

	// 关联关系
	Pan Pan `json:"pan" gorm:"foreignKey:PanID"`
}

Cks 第三方平台账号cookie表

func (Cks) TableName

func (Cks) TableName() string

TableName 指定表名

type DailySearchStat

type DailySearchStat struct {
	Date           time.Time `json:"date"`
	TotalSearches  int       `json:"total_searches"`
	UniqueKeywords int       `json:"unique_keywords"`
}

DailySearchStat 每日搜索统计

type File added in v1.2.3

type File struct {
	ID        uint      `json:"id" gorm:"primaryKey"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	// 文件信息
	OriginalName string `json:"original_name" gorm:"size:255;not null;comment:原始文件名"`
	FileName     string `json:"file_name" gorm:"size:255;not null;unique;comment:存储文件名"`
	FilePath     string `json:"file_path" gorm:"size:500;not null;comment:文件路径"`
	FileSize     int64  `json:"file_size" gorm:"not null;comment:文件大小(字节)"`
	FileType     string `json:"file_type" gorm:"size:100;not null;comment:文件类型"`
	MimeType     string `json:"mime_type" gorm:"size:100;comment:MIME类型"`
	FileHash     string `json:"file_hash" gorm:"size:64;uniqueIndex;comment:文件哈希值"`

	// 访问信息
	AccessURL string `json:"access_url" gorm:"size:500;comment:访问URL"`

	// 用户信息
	UserID uint `json:"user_id" gorm:"comment:上传用户ID"`
	User   User `json:"user" gorm:"foreignKey:UserID"`

	// 状态信息
	Status    string `json:"status" gorm:"size:20;default:'active';comment:文件状态"`
	IsPublic  bool   `json:"is_public" gorm:"default:true;comment:是否公开"`
	IsDeleted bool   `json:"is_deleted" gorm:"default:false;comment:是否已删除"`
}

File 文件实体

func (File) TableName added in v1.2.3

func (File) TableName() string

TableName 指定表名

type HotDrama

type HotDrama struct {
	ID        uint      `json:"id" gorm:"primaryKey"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	// 基本信息
	Title        string  `json:"title" gorm:"size:255;not null"` // 剧名
	CardSubtitle string  `json:"card_subtitle" gorm:"size:500"`  // 副标题
	EpisodesInfo string  `json:"episodes_info" gorm:"size:100"`  // 集数信息
	IsNew        bool    `json:"is_new" gorm:"default:false"`    // 是否新剧
	Rating       float64 `json:"rating" gorm:"default:0"`        // 评分
	RatingCount  int     `json:"rating_count" gorm:"default:0"`  // 评分人数
	Year         string  `json:"year" gorm:"size:10"`            // 年份
	Region       string  `json:"region" gorm:"size:100"`         // 地区
	Genres       string  `json:"genres" gorm:"size:500"`         // 类型(多个用逗号分隔)
	Directors    string  `json:"directors" gorm:"size:500"`      // 导演(多个用逗号分隔)
	Actors       string  `json:"actors" gorm:"size:1000"`        // 演员(多个用逗号分隔)
	PosterURL    string  `json:"poster_url" gorm:"size:500"`     // 海报URL

	// 分类信息
	Category string `json:"category" gorm:"size:50"` // 分类(电影/电视剧)
	SubType  string `json:"sub_type" gorm:"size:50"` // 子类型(华语/欧美/韩国/日本等)
	Rank     int    `json:"rank" gorm:"default:0"`   // 排序(豆瓣返回顺序)

	// 数据来源
	Source    string `json:"source" gorm:"size:50;default:'douban'"` // 数据来源
	DoubanID  string `json:"douban_id" gorm:"size:50"`               // 豆瓣ID
	DoubanURI string `json:"douban_uri" gorm:"size:200"`             // 豆瓣链接
}

HotDrama 热播剧实体

func (HotDrama) TableName

func (HotDrama) TableName() string

TableName 指定表名

type KeywordStat

type KeywordStat struct {
	Keyword string `json:"keyword"`
	Count   int    `json:"count"`
	Rank    int    `json:"rank"`
}

KeywordStat 关键词统计

type Pan

type Pan struct {
	ID        uint           `json:"id" gorm:"primaryKey;autoIncrement"`
	Name      string         `json:"name" gorm:"size:64;comment:平台名称"`
	Key       int            `json:"key" gorm:"comment:平台标识"`
	Icon      string         `json:"icon" gorm:"size:128;comment:图标文字"`
	Remark    string         `json:"remark" gorm:"size:64;not null;comment:备注"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`

	// 关联关系
	Cks []Cks `json:"cks" gorm:"foreignKey:PanID"`
}

Pan 第三方平台表

func (Pan) TableName

func (Pan) TableName() string

TableName 指定表名

type ReadyResource

type ReadyResource struct {
	ID          uint           `json:"id" gorm:"primaryKey;autoIncrement"`
	Title       *string        `json:"title" gorm:"size:255;comment:资源标题"`
	Description string         `json:"description" gorm:"type:text;comment:资源描述"`
	URL         string         `json:"url" gorm:"size:500;not null;comment:资源链接"`
	Category    string         `json:"category" gorm:"size:100;comment:资源分类"`
	Tags        string         `json:"tags" gorm:"size:500;comment:资源标签,多个标签用逗号分隔"`
	Img         string         `json:"img" gorm:"size:500;comment:封面链接"`
	Source      string         `json:"source" gorm:"size:100;comment:数据来源"`
	Extra       string         `json:"extra" gorm:"type:text;comment:额外附加数据"`
	Key         string         `json:"key" gorm:"size:64;index;comment:资源组标识,相同key表示同一组资源"`
	ErrorMsg    string         `json:"error_msg" gorm:"type:text;comment:处理失败时的错误信息"`
	CreateTime  time.Time      `json:"create_time" gorm:"default:CURRENT_TIMESTAMP"`
	IP          *string        `json:"ip" gorm:"size:45;comment:IP地址"`
	CreatedAt   time.Time      `json:"created_at"`
	UpdatedAt   time.Time      `json:"updated_at"`
	DeletedAt   gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}

ReadyResource 待处理资源模型

func (ReadyResource) TableName

func (ReadyResource) TableName() string

TableName 指定表名

type Resource

type Resource struct {
	ID                  uint           `json:"id" gorm:"primaryKey;autoIncrement"`
	Title               string         `json:"title" gorm:"size:255;not null;comment:资源标题"`
	Description         string         `json:"description" gorm:"type:text;comment:资源描述"`
	URL                 string         `json:"url" gorm:"size:128;comment:资源链接"`
	PanID               *uint          `json:"pan_id" gorm:"comment:平台ID"`
	SaveURL             string         `json:"save_url" gorm:"size:500;comment:转存后的链接"`
	FileSize            string         `json:"file_size" gorm:"size:100;comment:文件大小"`
	CategoryID          *uint          `json:"category_id" gorm:"comment:分类ID"`
	ViewCount           int            `json:"view_count" gorm:"default:0;comment:浏览次数"`
	IsValid             bool           `json:"is_valid" gorm:"default:true;comment:是否有效"`
	IsPublic            bool           `json:"is_public" gorm:"default:true;comment:是否公开"`
	CreatedAt           time.Time      `json:"created_at"`
	UpdatedAt           time.Time      `json:"updated_at"`
	DeletedAt           gorm.DeletedAt `json:"deleted_at" gorm:"index"`
	Cover               string         `json:"cover" gorm:"size:500;comment:封面"`
	Author              string         `json:"author" gorm:"size:100;comment:作者"`
	ErrorMsg            string         `json:"error_msg" gorm:"size:255;comment:转存失败原因"`
	CkID                *uint          `json:"ck_id" gorm:"comment:账号ID"`
	Fid                 string         `json:"fid" gorm:"size:128;comment:网盘文件ID"`
	Key                 string         `json:"key" gorm:"size:64;index;comment:资源组标识,相同key表示同一组资源"`
	SyncedToMeilisearch bool           `json:"synced_to_meilisearch" gorm:"default:false;comment:是否已同步到Meilisearch"`
	SyncedAt            *time.Time     `json:"synced_at" gorm:"comment:同步时间"`

	// 关联关系
	Category Category `json:"category" gorm:"foreignKey:CategoryID"`
	Pan      Pan      `json:"pan" gorm:"foreignKey:PanID"`
	Tags     []Tag    `json:"tags" gorm:"many2many:resource_tags;"`
}

Resource 资源模型

func (*Resource) GetDescription added in v1.2.5

func (r *Resource) GetDescription() string

GetDescription 获取资源描述(实现utils.Resource接口)

func (*Resource) GetTitle added in v1.2.5

func (r *Resource) GetTitle() string

GetTitle 获取资源标题(实现utils.Resource接口)

func (*Resource) SetDescription added in v1.2.5

func (r *Resource) SetDescription(description string)

SetDescription 设置资源描述(实现utils.Resource接口)

func (*Resource) SetTitle added in v1.2.5

func (r *Resource) SetTitle(title string)

SetTitle 设置资源标题(实现utils.Resource接口)

func (Resource) TableName

func (Resource) TableName() string

TableName 指定表名

type ResourceTag

type ResourceTag struct {
	ID         uint      `json:"id" gorm:"primaryKey;autoIncrement"`
	ResourceID uint      `json:"resource_id" gorm:"not null;comment:资源ID"`
	TagID      uint      `json:"tag_id" gorm:"not null;comment:标签ID"`
	CreatedAt  time.Time `json:"created_at"`
}

ResourceTag 资源标签关联表

func (ResourceTag) TableName

func (ResourceTag) TableName() string

TableName 指定表名

type ResourceView added in v1.2.0

type ResourceView struct {
	ID         uint           `json:"id" gorm:"primaryKey;autoIncrement"`
	ResourceID uint           `json:"resource_id" gorm:"not null;index;comment:资源ID"`
	IPAddress  string         `json:"ip_address" gorm:"size:45;comment:访问者IP地址"`
	UserAgent  string         `json:"user_agent" gorm:"type:text;comment:用户代理"`
	CreatedAt  time.Time      `json:"created_at" gorm:"autoCreateTime;comment:访问时间"`
	UpdatedAt  time.Time      `json:"updated_at" gorm:"autoUpdateTime"`
	DeletedAt  gorm.DeletedAt `json:"deleted_at" gorm:"index"`

	// 关联关系
	Resource Resource `json:"resource" gorm:"foreignKey:ResourceID"`
}

ResourceView 资源访问记录

func (ResourceView) TableName added in v1.2.0

func (ResourceView) TableName() string

TableName 指定表名

type SearchStat

type SearchStat struct {
	ID        uint           `json:"id" gorm:"primaryKey;autoIncrement"`
	Keyword   string         `json:"keyword" gorm:"size:255;not null;comment:搜索关键词"`
	Count     int            `json:"count" gorm:"default:1;comment:搜索次数"`
	Date      time.Time      `json:"date" gorm:"type:date;not null;comment:搜索日期"`
	IP        string         `json:"ip" gorm:"size:45;comment:用户IP"`
	UserAgent string         `json:"user_agent" gorm:"size:500;comment:用户代理"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}

SearchStat 搜索统计模型

func (SearchStat) TableName

func (SearchStat) TableName() string

TableName 指定表名

type SystemConfig

type SystemConfig struct {
	ID        uint      `json:"id" gorm:"primaryKey"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	// 键值对配置
	Key   string `json:"key" gorm:"size:100;not null;unique;comment:配置键"`
	Value string `json:"value" gorm:"type:text"`
	Type  string `json:"type" gorm:"size:20;default:'string'"` // string, int, bool, json
}

SystemConfig 系统配置实体(键值对形式)

func (SystemConfig) TableName

func (SystemConfig) TableName() string

TableName 指定表名

type Tag

type Tag struct {
	ID          uint           `json:"id" gorm:"primaryKey;autoIncrement"`
	Name        string         `json:"name" gorm:"size:100;not null;unique;comment:标签名称"`
	Description string         `json:"description" gorm:"type:text;comment:标签描述"`
	CategoryID  *uint          `json:"category_id" gorm:"comment:分类ID,可以为空"`
	CreatedAt   time.Time      `json:"created_at"`
	UpdatedAt   time.Time      `json:"updated_at"`
	DeletedAt   gorm.DeletedAt `json:"deleted_at" gorm:"index"`

	// 关联关系
	Category  Category   `json:"category" gorm:"foreignKey:CategoryID"`
	Resources []Resource `json:"resources" gorm:"many2many:resource_tags;"`
}

Tag 标签模型

func (Tag) TableName

func (Tag) TableName() string

TableName 指定表名

type Task added in v1.2.0

type Task struct {
	ID          uint       `json:"id" gorm:"primaryKey;autoIncrement"`
	Title       string     `json:"title" gorm:"size:255;not null;comment:任务标题"`
	Type        TaskType   `json:"type" gorm:"size:50;not null;comment:任务类型"`
	Status      TaskStatus `json:"status" gorm:"size:20;not null;default:pending;comment:任务状态"`
	Description string     `json:"description" gorm:"type:text;comment:任务描述"`

	// 进度信息
	TotalItems     int `json:"total_items" gorm:"not null;default:0;comment:总项目数"`
	ProcessedItems int `json:"processed_items" gorm:"not null;default:0;comment:已处理项目数"`
	SuccessItems   int `json:"success_items" gorm:"not null;default:0;comment:成功项目数"`
	FailedItems    int `json:"failed_items" gorm:"not null;default:0;comment:失败项目数"`

	// 任务配置 (JSON格式存储)
	Config string `json:"config" gorm:"type:text;comment:任务配置"`

	// 任务消息
	Message string `json:"message" gorm:"type:text;comment:任务消息"`

	// 时间信息
	StartedAt   *time.Time     `json:"started_at" gorm:"comment:开始时间"`
	CompletedAt *time.Time     `json:"completed_at" gorm:"comment:完成时间"`
	CreatedAt   time.Time      `json:"created_at" gorm:"autoCreateTime"`
	UpdatedAt   time.Time      `json:"updated_at" gorm:"autoUpdateTime"`
	DeletedAt   gorm.DeletedAt `json:"deleted_at" gorm:"index"`

	// 关联关系
	TaskItems []TaskItem `json:"task_items" gorm:"foreignKey:TaskID"`
}

Task 任务表

func (Task) TableName added in v1.2.0

func (Task) TableName() string

TableName 指定表名

type TaskItem added in v1.2.0

type TaskItem struct {
	ID     uint `json:"id" gorm:"primaryKey;autoIncrement"`
	TaskID uint `json:"task_id" gorm:"not null;index;comment:任务ID"`

	// 通用任务项信息
	Status       TaskItemStatus `json:"status" gorm:"size:20;not null;default:pending;comment:处理状态"`
	ErrorMessage string         `json:"error_message" gorm:"type:text;comment:错误信息"`

	// 输入数据 (JSON格式存储,支持不同任务类型的不同数据结构)
	InputData string `json:"input_data" gorm:"type:text;not null;comment:输入数据(JSON格式)"`

	// 输出数据 (JSON格式存储,支持不同任务类型的不同结果数据)
	OutputData string `json:"output_data" gorm:"type:text;comment:输出数据(JSON格式)"`

	// 处理日志 (可选,用于记录详细的处理过程)
	ProcessLog string `json:"process_log" gorm:"type:text;comment:处理日志"`

	// 时间信息
	ProcessedAt *time.Time     `json:"processed_at" gorm:"comment:处理时间"`
	CreatedAt   time.Time      `json:"created_at" gorm:"autoCreateTime"`
	UpdatedAt   time.Time      `json:"updated_at" gorm:"autoUpdateTime"`
	DeletedAt   gorm.DeletedAt `json:"deleted_at" gorm:"index"`

	// 关联关系
	Task Task `json:"task" gorm:"foreignKey:TaskID"`
}

TaskItem 任务项表(任务的详细记录)

func (*TaskItem) AddProcessLog added in v1.2.0

func (item *TaskItem) AddProcessLog(message string)

AddProcessLog 添加处理日志

func (*TaskItem) GetDisplayName added in v1.2.0

func (item *TaskItem) GetDisplayName(taskType TaskType) string

GetDisplayName 获取显示名称(用于前端显示)

func (*TaskItem) GetInputData added in v1.2.0

func (item *TaskItem) GetInputData(taskType TaskType) (interface{}, error)

GetInputData 获取输入数据(根据任务类型解析JSON)

func (*TaskItem) GetOutputData added in v1.2.0

func (item *TaskItem) GetOutputData(taskType TaskType) (interface{}, error)

GetOutputData 获取输出数据(根据任务类型解析JSON)

func (*TaskItem) SetInputData added in v1.2.0

func (item *TaskItem) SetInputData(data interface{}) error

SetInputData 设置输入数据(将结构体转换为JSON字符串)

func (*TaskItem) SetOutputData added in v1.2.0

func (item *TaskItem) SetOutputData(data interface{}) error

SetOutputData 设置输出数据(将结构体转换为JSON字符串)

func (TaskItem) TableName added in v1.2.0

func (TaskItem) TableName() string

TableName 指定表名

type TaskItemStatus added in v1.2.0

type TaskItemStatus string

TaskItemStatus 任务项状态

const (
	TaskItemStatusPending    TaskItemStatus = "pending"    // 等待处理
	TaskItemStatusProcessing TaskItemStatus = "processing" // 处理中
	TaskItemStatusSuccess    TaskItemStatus = "success"    // 成功
	TaskItemStatusFailed     TaskItemStatus = "failed"     // 失败
	TaskItemStatusSkipped    TaskItemStatus = "skipped"    // 跳过
)

type TaskStatus added in v1.2.0

type TaskStatus string

TaskStatus 任务状态

const (
	TaskStatusPending   TaskStatus = "pending"   // 等待中
	TaskStatusRunning   TaskStatus = "running"   // 运行中
	TaskStatusPaused    TaskStatus = "paused"    // 已暂停
	TaskStatusCompleted TaskStatus = "completed" // 已完成
	TaskStatusFailed    TaskStatus = "failed"    // 失败
	TaskStatusCancelled TaskStatus = "cancelled" // 已取消
)

type TaskType added in v1.2.0

type TaskType string

TaskType 任务类型

const (
	TaskTypeBatchTransfer TaskType = "batch_transfer" // 批量转存
	TaskTypeExpansion     TaskType = "expansion"      // 账号扩容
)

type TelegramChannel added in v1.3.0

type TelegramChannel struct {
	ID        uint      `json:"id" gorm:"primaryKey"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	// Telegram 频道/群组信息
	ChatID   int64  `json:"chat_id" gorm:"not null;comment:Telegram 聊天ID"`
	ChatName string `json:"chat_name" gorm:"size:255;not null;comment:聊天名称"`
	ChatType string `json:"chat_type" gorm:"size:50;not null;comment:类型:channel/group"`

	// 推送配置
	PushEnabled       bool   `json:"push_enabled" gorm:"default:true;comment:是否启用推送"`
	PushFrequency     int    `json:"push_frequency" gorm:"default:5;comment:推送频率(分钟)"`
	PushStartTime     string `json:"push_start_time" gorm:"size:10;comment:推送开始时间,格式HH:mm"`
	PushEndTime       string `json:"push_end_time" gorm:"size:10;comment:推送结束时间,格式HH:mm"`
	ContentCategories string `json:"content_categories" gorm:"type:text;comment:推送的内容分类,用逗号分隔"`
	ContentTags       string `json:"content_tags" gorm:"type:text;comment:推送的标签,用逗号分隔"`

	// 频道状态
	IsActive   bool       `json:"is_active" gorm:"default:true;comment:是否活跃"`
	LastPushAt *time.Time `json:"last_push_at" gorm:"comment:最后推送时间"`

	// 注册信息
	RegisteredBy string    `json:"registered_by" gorm:"size:100;comment:注册者用户名"`
	RegisteredAt time.Time `json:"registered_at"`

	// API配置
	API             string `json:"api" gorm:"size:255;comment:API地址"`
	Token           string `json:"token" gorm:"size:255;comment:访问令牌"`
	ApiType         string `json:"api_type" gorm:"size:50;comment:API类型"`
	IsPushSavedInfo bool   `json:"is_push_saved_info" gorm:"default:false;comment:是否只推送已转存资源"`

	// 资源策略和时间限制配置
	ResourceStrategy string `` /* 144-byte string literal not displayed */
	TimeLimit        string `json:"time_limit" gorm:"size:20;default:'none';comment:时间限制:none-无限制,week-一周内,month-一月内"`
}

TelegramChannel Telegram 频道/群组实体

func (TelegramChannel) TableName added in v1.3.0

func (TelegramChannel) TableName() string

TableName 指定表名

type User

type User struct {
	ID        uint           `json:"id" gorm:"primaryKey;autoIncrement"`
	Username  string         `json:"username" gorm:"size:50;not null;unique;comment:用户名"`
	Password  string         `json:"-" gorm:"size:255;not null;comment:密码"`
	Email     string         `json:"email" gorm:"size:100;comment:邮箱"`
	Role      string         `json:"role" gorm:"size:20;default:'user';comment:角色"`
	IsActive  bool           `json:"is_active" gorm:"default:true;comment:是否激活"`
	LastLogin *time.Time     `json:"last_login" gorm:"comment:最后登录时间"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}

User 用户模型

func (User) TableName

func (User) TableName() string

TableName 指定表名

Jump to

Keyboard shortcuts

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