model

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilterQuery string = "" /* 315-byte string literal not displayed */
	ExceptQuery string = "" /* 127-byte string literal not displayed */
)
View Source
const (
	DoNotUnmarshal = "--" + doNotUnmarshal
)
View Source
const MagicKey string = "__magic_key__"

Variables

View Source
var MaxTextLength = 18

Functions

This section is empty.

Types

type Api

type Api struct {
	Method    string         `json:"method"`
	URL       string         `json:"url"`
	Body      string         `json:"body"`
	Header    Header         `json:"header"`
	Parameter pq.StringArray `json:"parameter" gorm:"type:text[]"`
	// contains filtered or unexported fields
}

func (Api) Do

func (api Api) Do(tmpl *Template) ([]byte, error)

func (Api) DoWithContext

func (api Api) DoWithContext(ctx context.Context, tmpl *Template) (result []byte, err error)

func (*Api) Parse

func (api *Api) Parse() error

type Blog

type Blog struct {
	ID        uint64    `json:"id" gorm:"primaryKey;autoIncrement"`
	CreatedAt time.Time `json:"created_at"`

	Submitter string `json:"submitter" gorm:"index:idx_blogs_query,priority:2"`      // 提交者
	Platform  string `json:"platform" gorm:"index:idx_blogs_query,priority:5"`       // 发布平台
	Type      string `json:"type" gorm:"index:idx_blogs_query,priority:4"`           // 博文类型
	UID       string `json:"uid" gorm:"index:idx_blogs_query,priority:3"`            // 账户序号
	MID       string `json:"mid" gorm:"index:idx_blogs_query,priority:1;column:mid"` // 博文序号

	URL    string    `json:"url"`    // 博文网址
	Text   string    `json:"text"`   // 文本内容
	Time   time.Time `json:"time"`   // 发送时间
	Source string    `json:"source"` // 博文来源
	Edited bool      `json:"edited"` // 是否编辑

	Name        string `json:"name"`        // 账户昵称
	Avatar      string `json:"avatar"`      // 头像网址
	Follower    string `json:"follower"`    // 粉丝数
	Following   string `json:"following"`   // 关注数
	Description string `json:"description"` // 个人简介

	ReplyID  *uint64 `json:"reply_id"`   // 被回复博文序号
	Reply    *Blog   `json:"reply"`      // 被回复博文
	BlogID   *uint64 `json:"comment_id"` // 被评论博文序号
	Comments []Blog  `json:"comments"`   // 本博文的评论

	Assets pq.StringArray `json:"assets" gorm:"type:text[]"` // 资源网址
	Banner pq.StringArray `json:"banner" gorm:"type:text[]"` // 头图网址

	Tags  []Tag          `json:"tags" gorm:"serializer:json"`  // 标签
	Extra map[string]any `json:"extra" gorm:"serializer:json"` // 预留项
}

博文

func (*Blog) BeforeCreate

func (b *Blog) BeforeCreate(tx *gorm.DB) error

func (Blog) String

func (b Blog) String() string

type Filter

type Filter struct {
	Submitter pq.StringArray `json:"submitter" gorm:"type:text[]"`
	Platform  pq.StringArray `json:"platform" gorm:"type:text[]"`
	Type      pq.StringArray `json:"type" gorm:"type:text[]"`
	UID       pq.StringArray `json:"uid" gorm:"type:text[]"`
}
type Header http.Header

func (Header) GormDataType

func (Header) GormDataType() string

func (Header) MarshalJSON

func (h Header) MarshalJSON() ([]byte, error)

func (*Header) Scan

func (h *Header) Scan(src any) error

func (Header) ToString

func (h Header) ToString() string

func (Header) Unwrap

func (h Header) Unwrap() error

func (Header) Value

func (h Header) Value() (driver.Value, error)

func (Header) Wrap

func (h Header) Wrap() error

type RequestLog

type RequestLog struct {
	ID        uint64    `json:"id" gorm:"primaryKey;autoIncrement"`
	CreatedAt time.Time `json:"created_at"`
	TaskID    uint64    `json:"task_id" gorm:"index:idx_logs_query"`
	BlogID    uint64    `json:"blog_id"`
	MID       string    `json:"mid" gorm:"index:idx_logs_query;column:mid"`
	Type      string    `json:"type" gorm:"index:idx_logs_query"`
	Platform  string    `json:"platform" gorm:"index:idx_logs_query"`
	Result    string    `json:"result"`
	Error     string    `json:"error"`
}

请求记录

type Role

type Role uint64 // 权限
const (
	Invalid Role = iota
	Normal
	Trusted
	Admin
	Owner
)

func (Role) IsAdmin

func (r Role) IsAdmin() bool

type Tag

type Tag struct {
	Tag  string `json:"tag"`  // 文字描述
	Href string `json:"href"` // 引用网址
}

标签

type Task

type Task struct {
	ID          uint64         `json:"id" gorm:"primaryKey;autoIncrement"`
	CreatedAt   time.Time      `json:"created_at"`
	DeletedAt   gorm.DeletedAt `json:"-" gorm:"index"`
	Enable      bool           `json:"enable"`
	UserID      string         `json:"user_id"`
	Name        string         `json:"name"`
	Filter      Filter         `json:"filter" gorm:"embedded"`
	Api         Api            `json:"api" gorm:"embedded"`
	RequestOnce bool           `json:"request_once"`
	RequestLogs []RequestLog   `json:"request_logs,omitempty"`
}

任务

type Template

type Template struct {
	// contains filtered or unexported fields
}

func NewTemplate

func NewTemplate(data any) *Template

func (*Template) Any

func (t *Template) Any(i any) (err error)

func (*Template) Reader

func (t *Template) Reader(text string) (io.Reader, error)

func (*Template) String

func (t *Template) String(text string) (string, error)

type User

type User struct {
	UID       string         `json:"uid" gorm:"primaryKey"`
	CreatedAt time.Time      `json:"created_at"`
	Ban       time.Time      `json:"ban"`  // 封禁结束时间
	Role      Role           `json:"role"` // 权限等级
	Name      string         `json:"name"`
	Nickname  string         `json:"nickname"` // 权限昵称
	Password  string         `json:"-"`
	Tasks     []Task         `json:"tasks"`
	Extra     map[string]any `json:"-" gorm:"serializer:json"` // 预留项
}

用户

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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