Documentation
¶
Index ¶
- type CrawlingRecord
- type NewsDetail
- func (n *NewsDetail) Compare(other *NewsDetail) int
- func (n *NewsDetail) ExtractAuthor(doc *goquery.Selection)
- func (n *NewsDetail) ExtractContents(doc *goquery.Selection)
- func (n *NewsDetail) ExtractImages(doc *goquery.Selection)
- func (n *NewsDetail) ExtractLink(baseURL string, doc *goquery.Selection)
- func (n *NewsDetail) ExtractPublishTime(minPublishTime time.Time, doc *goquery.Selection)
- func (n *NewsDetail) ExtractSummary(doc *goquery.Selection)
- func (n *NewsDetail) ExtractTitle(doc *goquery.Selection)
- func (n *NewsDetail) IsValid(minPublishTime time.Time) bool
- func (n *NewsDetail) ToModel() (*model.NewsDetail, error)
- type SystemConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CrawlingRecord ¶
type CrawlingRecord struct {
Id uint
RecordType valueobject.CrawlingRecordType
Quantity int64
Status valueobject.CrawlingRecordStatus
Config *valueobject.CrawlingRecordConfig
CreatedAt time.Time
UpdatedAt time.Time
}
CrawlingRecord represents a crawling record.
func NewCrawlingRecord ¶
func NewCrawlingRecord(recordType valueobject.CrawlingRecordType, config *valueobject.CrawlingRecordConfig) *CrawlingRecord
NewCrawlingRecord creates a new CrawlingRecord entity.
func NewCrawlingRecordFromModel ¶
func NewCrawlingRecordFromModel(m *model.CrawlingRecord) (*CrawlingRecord, error)
NewCrawlingRecordFromModel converts a CrawlingRecordModel to a CrawlingRecord entity.
func (*CrawlingRecord) CrawlingCompleted ¶
func (c *CrawlingRecord) CrawlingCompleted()
CrawlingCompleted set the crawling record status to completed.
func (*CrawlingRecord) CrawlingFailed ¶
func (c *CrawlingRecord) CrawlingFailed()
CrawlingFailed set the crawling record status to failed.
func (*CrawlingRecord) CrawlingPaused ¶
func (c *CrawlingRecord) CrawlingPaused()
CrawlingPaused set the crawling record status to paused.
func (*CrawlingRecord) ToModel ¶
func (c *CrawlingRecord) ToModel() (*model.CrawlingRecord, error)
ToModel converts the CrawlingRecord entity to a CrawlingRecordModel.
func (*CrawlingRecord) UpdateStatus ¶
func (c *CrawlingRecord) UpdateStatus(status valueobject.CrawlingRecordStatus) error
UpdateStatus updates the crawling record status.
type NewsDetail ¶
type NewsDetail struct {
Id uint
RecordId uint // crawling record id
Source string
Topic string
Title string
Author string
PublishedAt time.Time
Link string
Contents []string
Images []string
Video string
Scraped bool
Favorited bool
CreatedAt time.Time
}
NewsDetail represents the detailed information about a news item.
func NewNewsDetailFromModel ¶
func NewNewsDetailFromModel(m *model.NewsDetail) (*NewsDetail, error)
NewNewsDetailFromModel converts a NewsDetailModel to a NewsDetail entity.
func NewNewsDetailFromTopicLink ¶ added in v1.2.0
func NewNewsDetailFromTopicLink(recordId uint, link *valueobject.NewsTopicLink) *NewsDetail
NewNewsDetailFromTopicLink creates a NewsDetail entity from a NewsTopicLink.
func (*NewsDetail) Compare ¶ added in v1.2.0
func (n *NewsDetail) Compare(other *NewsDetail) int
Compare compare the priorities of news.
func (*NewsDetail) ExtractAuthor ¶ added in v1.2.0
func (n *NewsDetail) ExtractAuthor(doc *goquery.Selection)
ExtractAuthor extracts the author from the news detail.
func (*NewsDetail) ExtractContents ¶ added in v1.2.0
func (n *NewsDetail) ExtractContents(doc *goquery.Selection)
ExtractContents extracts the news content from the document.
func (*NewsDetail) ExtractImages ¶ added in v1.2.0
func (n *NewsDetail) ExtractImages(doc *goquery.Selection)
ExtractImages extracts the images from the news detail.
func (*NewsDetail) ExtractLink ¶ added in v1.2.0
func (n *NewsDetail) ExtractLink(baseURL string, doc *goquery.Selection)
ExtractLink extracts the link from the news detail.
func (*NewsDetail) ExtractPublishTime ¶
func (n *NewsDetail) ExtractPublishTime(minPublishTime time.Time, doc *goquery.Selection)
ExtractPublishTime extracts the publish time from the news detail.
func (*NewsDetail) ExtractSummary ¶ added in v1.2.0
func (n *NewsDetail) ExtractSummary(doc *goquery.Selection)
ExtractSummary extracts the summary from the news detail.
func (*NewsDetail) ExtractTitle ¶
func (n *NewsDetail) ExtractTitle(doc *goquery.Selection)
ExtractTitle extracts the title from the news detail.
func (*NewsDetail) IsValid ¶ added in v1.2.0
func (n *NewsDetail) IsValid(minPublishTime time.Time) bool
IsValid checks if the news detail is valid.
func (*NewsDetail) ToModel ¶
func (n *NewsDetail) ToModel() (*model.NewsDetail, error)
ToModel converts the NewsDetail entity to a NewsDetailModel.
type SystemConfig ¶
type SystemConfig struct {
Id uint
Key valueobject.SystemConfigKey
Value string
CreatedAt time.Time
UpdatedAt time.Time
}
SystemConfig represents the structure of system configuration data stored in the database.
func NewSystemConfig ¶
func NewSystemConfig(key string, value any) (*SystemConfig, error)
NewSystemConfig creates a new SystemConfig entity.
func NewSystemConfigFromModel ¶
func NewSystemConfigFromModel(m *model.SystemConfig) (*SystemConfig, error)
NewSystemConfigFromModel converts a SystemConfigModel to a SystemConfig entity.
func (*SystemConfig) ToModel ¶
func (s *SystemConfig) ToModel() (*model.SystemConfig, error)
ToModel converts the SystemConfig entity to a SystemConfigModel.
func (*SystemConfig) UnmarshalValue ¶ added in v1.2.0
func (s *SystemConfig) UnmarshalValue(v any) error
UnmarshalValue unmarshal config value
func (*SystemConfig) UpdateSystemConfig ¶
func (s *SystemConfig) UpdateSystemConfig() error
UpdateSystemConfig updates the system configuration.