Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorSerializer schema.SerializerInterface = Serializer[error, string]{ Scanner: errors.New, Valuer: error.Error, }
ErrorSerializer 用来序列化和反序列化错误接口
View Source
var URLSerializer schema.SerializerInterface = Serializer[*url.URL, string]{ Scanner: req.MustParseURL, Valuer: (*url.URL).String, }
URLSerializer 用来序列化和反序列化 *url.URL
Functions ¶
func ToHTTPCookies ¶
ToHTTPCookies 将 GORM 模型切片转换成 *http.Cookie 切片
Types ¶
type Blog ¶
type Blog struct {
ID uint64 `json:"id" gorm:"primaryKey;autoIncrement"` // 数据库内标识符
UID string `json:"uid" gorm:"index:idx_blogs;index:idx_type_blogs"` // 博主标识符
Name string `json:"name"` // 博主昵称
Desc string `json:"desc"` // 个人简介
Avatar string `json:"avatar"` // 头像链接
Banner string `json:"banner"` // 头图链接
Follower string `json:"follower"` // 粉丝数量
Following string `json:"following"` // 关注数量
MID string `json:"mid" gorm:"column:mid;index:idx_match"` // 博文标识符
URL string `json:"url"` // 博文链接
Site string `json:"site" gorm:"index:idx_blogs;index:idx_type_blogs;index:idx_match"` // 发布网站
Type string `json:"type" gorm:"index:idx_type_blogs;index:idx_match"` // 博文类型
Time time.Time `json:"time" gorm:"index:idx_blogs,sort:desc;index:idx_type_blogs,sort:desc"` // 发布时间
Title string `json:"title"` // 博文标题
Source string `json:"source"` // 博文来源
Version string `json:"version" gorm:"index:idx_match"` // 编辑版本
Content string `json:"content"` // 原始内容
Plaintext string `json:"plaintext"` // 纯文本内容
Assets []string `json:"assets" gorm:"serializer:json"` // 资源链接
Reply *Blog `json:"reply"` // 被本文回复的博文
ReplyID *uint64 `json:"-"` // 被本文回复的博文的数据库标识符
Comments []*Blog `json:"comments"` // 本文的所有评论,包括二级评论
BlogID *uint64 `json:"-"` // 如果本文是评论,则为根博文的数据库标识符
Uploader *User `json:"uploader"` // 上传者
UploaderID string `json:"-" gorm:"index:idx_match"` // 上传者标识符
Extra Extra `json:"extra" gorm:"serializer:json"` // 扩展字段
Created time.Time `json:"created" gorm:"autoCreateTime"` // 博文创建时间
}
Blog 博文模型
type Cookie ¶
Cookie 是用于 GORM 存取的 Cookie 模型
func FromHTTPCookies ¶
FromHTTPCookies 将 *http.Cookie 切片转换成 GORM 模型切片
type CookieJar ¶
type CookieJar struct {
ID uint64 `gorm:"primaryKey;autoIncrement"`
URL *url.URL `gorm:"serializer:url"`
Jar http.CookieJar `gorm:"-"`
Cookies []Cookie
CreatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
CookieJar 是用于 GORM 存取 http.CookieJar 的模型
func (*CookieJar) BeforeSave ¶
BeforeSave 在保存前读取 http.CookieJar 中数据
type Filter ¶
type Filter struct {
Contributor string `json:"contributor" form:"contributor"` // 博文贡献者
Platform string `json:"platform" form:"platform"` // 发布平台
Type string `json:"type" form:"type"` // 博文类型
UID string `json:"uid" form:"uid"` // 账户序号
TaskID uint64 `json:"-" form:"-"` // 外键
}
博文筛选条件,用来描述一类博文,例如:
filter1 表示所有平台为 "weibo"、类型为 "comment" 的博文
filter2 表示所有由 "114" 提交的用户 "514" 的博文
var filter1 = Filter{
Platform: "weibo",
Type: "comment",
}
var filter2 = Filter{
Contributor: "114",
UID: "514",
}
type RequestLog ¶
type RequestLog struct {
StartedAt time.Time `json:"started_at"`
CreatedAt time.Time `json:"created_at"`
BlogID uint64 `json:"blog_id"`
Result any `json:"result" gorm:"serializer:json"` // 响应为 JSON 会自动解析
Error error `json:"error"` // 请求过程中发生的错误
TaskID uint64 `json:"-" gorm:"index:idx_logs_query"` // 外键
}
请求记录
type Serializer ¶
Serializer 在数据库读写时用来序列化和反序列化
type Task ¶
type Task struct {
ID uint64 `json:"id" gorm:"primaryKey;autoIncrement"`
CreatedAt time.Time `json:"created_at"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
Public bool `json:"public"` // 是否公开
Enable bool `json:"enable"` // 是否启用
Name string `json:"name"` // 任务名称
Description string `json:"description"` // 任务简介
Icon string `json:"icon"` // 任务图标
Banner string `json:"banner"` // 任务头图
Readme string `json:"readme"` // 任务描述
ForkID uint64 `json:"fork_id"` // 复刻来源
ForkCount uint64 `json:"fork_count" gorm:"-"` // 被复刻次数
UserID string `json:"user_id"` // 外键
Template string `json:"templates"` // 请求模板
Filters []Filter `json:"filters"` // 筛选条件
Logs []RequestLog `json:"logs"` // 请求记录
}
任务
type User ¶
type User struct {
UID string `json:"uid" gorm:"primaryKey"` // 用户标识符
Name string `json:"name"` // 用户名
Role Role `json:"role"` // 权限
Title string `json:"title"` // 头衔
Password string `json:"-"` // 密码
Created time.Time `json:"created" gorm:"autoCreateTime"` // 建号时间
Issued time.Time `json:"-"` // 签发时间
Unban time.Time `json:"unban"` // 解封时间
Extra Extra `json:"-" gorm:"serializer:json"` // 扩展字段
}
User 用户模型
Click to show internal directories.
Click to hide internal directories.