110 lines
3.2 KiB
Go
110 lines
3.2 KiB
Go
package rss
|
||
|
||
import "time"
|
||
|
||
// RSS源订阅信息-如果没有对应的订阅信息关联,则应该被清除
|
||
type RssFeed struct {
|
||
ID int `json:"id" gorm:"primaryKey"`
|
||
FeedURL string `json:"feed_url" gorm:"feed_url"`
|
||
Creator string `json:"creator" gorm:"creator"`
|
||
LastUpdate time.Time `json:"last_update" gorm:"last_update"`
|
||
}
|
||
|
||
func (RssFeed) TableName() string {
|
||
return "rss_feed"
|
||
}
|
||
|
||
// 群订阅信息-通过此数据定时检测最新的rss数据是否有更新,若有则向对应群发送消息
|
||
type RssSubscribe struct {
|
||
ID int `json:"id" gorm:"primaryKey"`
|
||
FeedID int `json:"feed_id" gorm:"feed_id"`
|
||
GroupID int `json:"group_id" gorm:"group_id"`
|
||
Creator int `json:"creator" gorm:"creator"`
|
||
CreateAt time.Time `json:"create_at" gorm:"create_at"`
|
||
LastItemHash string `json:"last_item_hash" gorm:"last_item_hash"`
|
||
}
|
||
|
||
func (RssSubscribe) TableName() string {
|
||
return "rss_subscribe"
|
||
}
|
||
|
||
// RSS条目信息
|
||
type RssItem struct {
|
||
Title string `json:"title"` // 标题
|
||
Link string `json:"link"` // 链接
|
||
Description string `json:"description"` // 描述
|
||
PubDate time.Time `json:"pub_date"` // 发布时间
|
||
GUID string `json:"guid"` // 全局唯一标识符
|
||
Author string `json:"author"` // 作者
|
||
Category string `json:"category"` // 分类
|
||
Hash string `json:"hash"` // 内容哈希值,用于检测更新
|
||
}
|
||
|
||
// RSS Feed结构体,用于解析XML
|
||
type RSSFeed struct {
|
||
XMLName string `xml:"rss"`
|
||
Channel struct {
|
||
Title string `xml:"title"`
|
||
Link string `xml:"link"`
|
||
Description string `xml:"description"`
|
||
Items []RSSItem `xml:"item"`
|
||
} `xml:"channel"`
|
||
}
|
||
|
||
// RSS Item结构体,用于解析XML中的item
|
||
type RSSItem struct {
|
||
Title string `xml:"title"`
|
||
Link string `xml:"link"`
|
||
Description string `xml:"description"`
|
||
PubDate string `xml:"pubDate"`
|
||
GUID string `xml:"guid"`
|
||
Author string `xml:"author"`
|
||
Category string `xml:"category"`
|
||
}
|
||
|
||
// Atom Feed结构体,用于解析Atom XML
|
||
type AtomFeed struct {
|
||
XMLName string `xml:"feed"`
|
||
Title string `xml:"title"`
|
||
Link []AtomLink `xml:"link"`
|
||
ID string `xml:"id"`
|
||
Updated string `xml:"updated"`
|
||
Author AtomAuthor `xml:"author"`
|
||
Entries []AtomEntry `xml:"entry"`
|
||
}
|
||
|
||
// Atom Link结构体
|
||
type AtomLink struct {
|
||
Href string `xml:"href,attr"`
|
||
Rel string `xml:"rel,attr"`
|
||
}
|
||
|
||
// Atom Author结构体
|
||
type AtomAuthor struct {
|
||
Name string `xml:"name"`
|
||
}
|
||
|
||
// Atom Entry结构体,用于解析Atom XML中的entry
|
||
type AtomEntry struct {
|
||
Title string `xml:"title"`
|
||
Link []AtomLink `xml:"link"`
|
||
ID string `xml:"id"`
|
||
Updated string `xml:"updated"`
|
||
Published string `xml:"published"`
|
||
Author AtomAuthor `xml:"author"`
|
||
Content AtomContent `xml:"content"`
|
||
Summary string `xml:"summary"`
|
||
Category []AtomCategory `xml:"category"`
|
||
}
|
||
|
||
// Atom Content结构体
|
||
type AtomContent struct {
|
||
Type string `xml:"type,attr"`
|
||
Value string `xml:",chardata"`
|
||
}
|
||
|
||
// Atom Category结构体
|
||
type AtomCategory struct {
|
||
Term string `xml:"term,attr"`
|
||
}
|