Documentation
¶
Overview ¶
Package domain rsshub领域逻辑
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RepoContent ¶
type RepoContent interface {
// UpsertContent 添加一条文章
UpsertContent(ctx context.Context, content *RssContent) error
// DeleteSourceContents 删除订阅源的所有文章,返回被删除的文章数
DeleteSourceContents(ctx context.Context, channelID int64) (int64, error)
// IsContentHashIDExist hash id 对应的文章是否已存在
IsContentHashIDExist(ctx context.Context, hashID string) (bool, error)
}
RepoContent RSS 推送信息存储接口
type RepoMultiQuery ¶
type RepoMultiQuery interface {
// GetSubscribesBySource 获取一个源对应的所有订阅群组
GetSubscribesBySource(ctx context.Context, feedPath string) ([]*RssSubscribe, error)
// GetIfExistedSubscribe 判断一个群组是否已订阅了一个源
GetIfExistedSubscribe(ctx context.Context, gid int64, feedPath string) (*RssSubscribe, bool, error)
// GetSubscribedChannelsByGroupID 获取该群所有的订阅
GetSubscribedChannelsByGroupID(ctx context.Context, gid int64) ([]*RssSource, error)
}
RepoMultiQuery 多表查询接口
type RepoSource ¶
type RepoSource interface {
// UpsertSource 添加一个订阅源
UpsertSource(ctx context.Context, rfc *RssSource) error
// GetSources 获取所有订阅源信息
GetSources(ctx context.Context) ([]RssSource, error)
// GetSourceByRssHubFeedLink 通过 rssHub 的 feed 链接获取订阅源信息
GetSourceByRssHubFeedLink(ctx context.Context, url string) (*RssSource, error)
// DeleteSource 删除一个订阅源
DeleteSource(ctx context.Context, fID int64) error
}
RepoSource RSS 订阅源存储接口
type RepoStorage ¶
type RepoStorage interface {
RepoContent
RepoSource
RepoSubscribe
RepoMultiQuery
// contains filtered or unexported methods
}
RepoStorage 定义RepoStorage接口
type RepoSubscribe ¶
type RepoSubscribe interface {
// CreateSubscribe 添加一个订阅
CreateSubscribe(ctx context.Context, gid, rssSourceID int64) error
// DeleteSubscribe 删除一个订阅
DeleteSubscribe(ctx context.Context, subscribeID int64) error
// GetSubscribeByID 获取一个订阅
GetSubscribeByID(ctx context.Context, gid int64, subscribeID int64) (*RssSubscribe, error)
// GetSubscribes 获取全部订阅
GetSubscribes(ctx context.Context) ([]*RssSubscribe, error)
}
RepoSubscribe RSS 订阅存储接口
type RssClientView ¶
type RssClientView struct {
Source *RssSource
Contents []*RssContent
}
RssClientView 频道视图
type RssContent ¶
type RssContent struct {
// Id 自增id
ID int64 `gorm:"column:id;primary_key;AUTO_INCREMENT"`
HashID string `gorm:"column:hash_id;unique" json:"hash_id"`
RssSourceID int64 `gorm:"column:rss_source_id;not null" json:"rss_source_id"`
Title string `gorm:"column:title" json:"title"`
Description string `gorm:"column:description" json:"description"`
Link string `gorm:"column:link" json:"link"`
Date time.Time `gorm:"column:date" json:"date"`
Author string `gorm:"column:author" json:"author"`
Thumbnail string `gorm:"column:thumbnail" json:"thumbnail"`
Content string `gorm:"column:content" json:"content"`
//// Ctime create time
// Ctime int64 `gorm:"column:ctime;default:current_timestamp" json:"ctime"`
// Mtime update time
Mtime time.Time `gorm:"column:mtime;default:current_timestamp;" json:"mtime"`
}
RssContent 订阅的RSS频道的推送信息
type RssDomain ¶
type RssDomain interface {
// Subscribe 订阅Rss频道
Subscribe(ctx context.Context, gid int64, route string) (rv *RssClientView, isChannelExisted,
isSubExisted bool, err error)
// Unsubscribe 取消订阅Rss频道
Unsubscribe(ctx context.Context, gid int64, route string) (err error)
// GetSubscribedChannelsByGroupID 获取群组订阅的Rss频道
GetSubscribedChannelsByGroupID(ctx context.Context, gid int64) (rv []*RssClientView, err error)
// Sync 同步Rss频道
// 返回群组-频道推送视图 map[群组]推送内容数组
Sync(ctx context.Context) (groupView map[int64][]*RssClientView, err error)
}
RssDomain RssRepo定义
func NewRssDomain ¶
NewRssDomain 新建RssDomain,调用方保证单例模式
type RssHubClient ¶
RssHubClient rss hub client (http)
type RssSource ¶
type RssSource struct {
// Id 自增id
ID int64 `gorm:"column:id;primary_key;AUTO_INCREMENT"`
// RssHubFeedPath 频道路由 用于区分rss_hub 不同的频道 例如: `/bangumi/tv/calendar/today`
RssHubFeedPath string `gorm:"column:rss_hub_feed_path;not null;unique;" json:"rss_hub_feed_path"`
// Title 频道标题
Title string `gorm:"column:title" json:"title"`
// ChannelDesc 频道描述
ChannelDesc string `gorm:"column:channel_desc" json:"channel_desc"`
// ImageURL 频道图片
ImageURL string `gorm:"column:image_url" json:"image_url"`
// Link 频道链接
Link string `gorm:"column:link" json:"link"`
// UpdatedParsed RSS页面更新时间
UpdatedParsed time.Time `gorm:"column:updated_parsed" json:"updated_parsed"`
//// Ctime create time
// Ctime int64 `gorm:"column:ctime;default:current_timestamp" json:"ctime"`
// Mtime update time
Mtime time.Time `gorm:"column:mtime;default:current_timestamp;" json:"mtime"`
}
RssSource RSS频道
func (RssSource) IfNeedUpdate ¶
IfNeedUpdate ...
type RssSubscribe ¶
type RssSubscribe struct {
// Id 自增id
ID int64 `gorm:"column:id;primary_key;AUTO_INCREMENT"`
// 订阅群组
GroupID int64 `gorm:"column:group_id;not null;uniqueIndex:uk_sid_gid"`
// 订阅频道
RssSourceID int64 `gorm:"column:rss_source_id;not null;uniqueIndex:uk_sid_gid"`
//// Ctime create time
// Ctime int64 `gorm:"column:ctime;default:current_timestamp" json:"ctime"`
// Mtime update time
Mtime time.Time `gorm:"column:mtime;default:current_timestamp;" json:"mtime"`
}
RssSubscribe 订阅关系表:群组-RSS频道
Click to show internal directories.
Click to hide internal directories.