data

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Data db.DB
)

Functions

func CheckFiles added in v0.6.0

func CheckFiles() error

func GetBranches

func GetBranches(platform, mid string, r *[]Post)

获取分支

func GetPosts

func GetPosts(begin, end string, r *[]Post)

通过起始与结束时间获取范围内博文合集

func HasPost

func HasPost(platform, mid string) bool

判断博文是否存在

func Init added in v0.7.0

func Init(r *configs.Config)

func Save

func Save(url string) string

func SavePost

func SavePost(p *Post)

func SavePosts

func SavePosts(p ...*Post)

Types

type Attachment

type Attachment struct {
	db.Model
	// 原网址
	Url string `form:"url" gorm:"unique;not null" cmps:"1"`
	// 本地路径
	Local string
	// 同浏览器 MIME type 附件的媒体类型
	MIME string
}

附件

func (*Attachment) Download

func (a *Attachment) Download() error

下载附件

func (Attachment) MarshalJSON

func (a Attachment) MarshalJSON() ([]byte, error)

func (*Attachment) Path

func (a *Attachment) Path() string

func (*Attachment) Save added in v0.7.0

func (a *Attachment) Save(_ any)

func (*Attachment) Store

func (a *Attachment) Store(data []byte)

func (Attachment) String

func (a Attachment) String() string

type Attachments

type Attachments []Attachment

附件合集

func (Attachments) String

func (as Attachments) String() string

func (Attachments) Urls

func (as Attachments) Urls() string

type Blogger

type Blogger struct {
	db.Model
	Platform    string `form:"platform" json:"platform"`
	Uid         string `form:"uid" json:"uid" cmps:"1"`
	Name        string `form:"name" json:"name"`
	Create      string `form:"create" json:"create"`
	Follower    string `form:"follower" json:"follower"`
	Following   string `form:"following" json:"following"`
	Description string `form:"description" json:"description"`

	FaceID int64      `gorm:"column:face" json:"-"`
	Face   Attachment `form:"face" json:"face" preload:"1" default:"Save"`

	PendantID int64      `gorm:"column:pendant" json:"-"`
	Pendant   Attachment `form:"pendant" json:"pendant" preload:"2" default:"Save"`
}

博主信息部分

func (*Blogger) Query

func (b *Blogger) Query(now time.Time) *Blogger

查询某一时刻前最近的用户状态

func (*Blogger) SetPlatform added in v0.10.0

func (b *Blogger) SetPlatform(p *Post)

func (Blogger) String

func (b Blogger) String() string

type Monitor

type Monitor struct {
	Score float64
	Posts []*Post
}

博文检查器

func GetMonitor

func GetMonitor(typ string) *Monitor

获取检查器

func (*Monitor) IsSubmitted

func (m *Monitor) IsSubmitted(uid string) bool

判断用户是否已经提交

func (*Monitor) Parse

func (m *Monitor) Parse(post *Post)

解析接收到的博文

type Post

type Post struct {
	db.Model
	// 平台
	Platform string `form:"platform" json:"platform"`
	// 博文序号
	Mid string `form:"mid" json:"mid"`
	// 发送时间
	Time string `form:"time" json:"time"`
	// 文本
	Text string `form:"text" json:"text"`
	// 内容
	Content string `gorm:"-" form:"-" json:"-"`
	// 来源
	Source string `form:"source" json:"source"`
	// 博主
	BloggerID string  `form:"-" json:"-" gorm:"column:blogger"`
	Blogger   Blogger `form:"blogger" json:"blogger" preload:"" default:"SetPlatform;initial.Default"`
	// 回复
	RepostID *uint64 `form:"-" json:"-" gorm:"column:repost"`
	Repost   *Post   `form:"repost" json:"repost" binding:"omitempty" default:"SetRepost;initial.Default"`
	// 评论
	CommentID *uint64 `form:"-" json:"-" gorm:"column:comment"`
	Comments  []Post  `form:"comments" json:"comments" gorm:"foreignKey:CommentID" default:"range.SetSubmitter;range.initial.Default"`
	// 附件
	Attachments Attachments `form:"attachments" json:"attachments" gorm:"many2many:post_attachments;" default:"range.Save"`
	// 提交者
	Submitter *user.User `form:"-" json:"submitter"`
	// 编辑距离
	Distance int `gorm:"-" form:"-" json:"-" cmps:"1"`
	// 替换器
	Replacer *strings.Replacer `gorm:"-" form:"-" json:"-"`
}

博文或评论

func GetPost

func GetPost(platform, mid string) *Post

通过平台和序号获取唯一博文

func (*Post) ReplaceData

func (p *Post) ReplaceData(text string) string

替换通配符

func (*Post) SetRepost added in v0.10.0

func (p *Post) SetRepost(parent *Post) error

func (*Post) SetSubmitter added in v0.10.0

func (p *Post) SetSubmitter(parent *Post)

func (Post) String

func (p Post) String() string

func (*Post) Type

func (p *Post) Type() string

func (*Post) Webhook

func (p *Post) Webhook()

回调博文

Jump to

Keyboard shortcuts

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