data

package
v0.0.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// 资源文件夹
	Resource = "resource"
	// 数据库文件名
	File = "posts.db"
)

Functions

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 Reset

func Reset(resource, file string)

重设参数

Types

type Attachment

type Attachment struct {
	// 数据库内序号
	ID int64 `gorm:"primaryKey;autoIncrement" json:"-"`
	// 同浏览器 MIME type 附件的媒体类型
	MIME string
	// 本地路径
	Path string `json:"path"`
	// contains filtered or unexported fields
}

附件

func NewA

func NewA(url string) Attachment

func (*Attachment) Download

func (a *Attachment) Download(url string)

下载附件

func (*Attachment) Make

func (a *Attachment) Make(url string) *Attachment

构造函数

func (*Attachment) NotExist

func (a *Attachment) NotExist() bool

判断附件是否存在

func (*Attachment) ParseType

func (a *Attachment) ParseType()

判断格式

func (*Attachment) SaveToLocal

func (a *Attachment) SaveToLocal()

保存到本地

func (*Attachment) Scan

func (a *Attachment) Scan(val any) error

func (Attachment) String

func (a Attachment) String() string

转字符串

func (Attachment) ToURL

func (a Attachment) ToURL() string

转链接

func (Attachment) Value

func (a Attachment) Value() (driver.Value, error)

type Attachments

type Attachments []Attachment

附件合集

func (*Attachments) Make

func (as *Attachments) Make(urls ...string)

func (*Attachments) Scan

func (as *Attachments) Scan(val any) error

func (*Attachments) ToString

func (as *Attachments) ToString() string

转字符串

func (*Attachments) ToURL

func (as *Attachments) ToURL() string

转链接

func (Attachments) Value

func (as Attachments) Value() (driver.Value, error)

type Blogger

type Blogger struct {
	ID          int64      `gorm:"primaryKey;autoIncrement" form:"-" json:"-"`
	Platform    string     `form:"platform" json:"platform"`
	Uid         string     `form:"uid" json:"uid"`
	CreatedAt   string     `gorm:"column:create" form:"create" json:"create"`
	Name        string     `form:"name" json:"name"`
	Face        Attachment `form:"-" json:"face"`
	Pendant     Attachment `form:"-" json:"pendant"`
	Description string     `form:"description" json:"description"`
	Follower    string     `form:"follower" json:"follower"`
	Following   string     `form:"following" json:"following"`
}

博主信息部分

func (*Blogger) Query

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

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

func (*Blogger) Save

func (b *Blogger) Save()

func (*Blogger) Scan

func (b *Blogger) Scan(val any) error

func (Blogger) Value

func (b Blogger) Value() (driver.Value, error)

type Comment

type Comment struct {
	Post
	Repost string
}

type Comments

type Comments struct {
	Root *Post
	Map  map[string]*Comment
}

func (*Comments) Insert

func (cs *Comments) Insert(c *Comment)

func (*Comments) Query

func (cs *Comments) Query()

type Post

type Post struct {
	ID int64 `gorm:"primaryKey;autoIncrement" form:"-" json:"-"`
	// 平台
	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"`
	// 博主
	Blogger
	// 附件
	Attachments `form:"-" json:"attachments"`
	// 回复
	Repost *Post `form:"-" json:"repost"`
	// 被回复
	Comments []*Comment `gorm:"-" form:"-" json:"comments"`
	// 提交者
	Submitter *user.User `form:"-"`
}

博文或评论

func GetPost

func GetPost(platform, mid string) *Post

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

func (*Post) Insert

func (p *Post) Insert(c *Comment)

func (*Post) Save

func (p *Post) Save()

保存该博文

func (*Post) SaveAsBranche

func (p *Post) SaveAsBranche()

保存分支

func (*Post) Scan

func (p *Post) Scan(val any) error

func (Post) Value

func (p Post) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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