From e4d4d8965f621730841dc09c9b2ab07243160b48 Mon Sep 17 00:00:00 2001 From: songjiaxin Date: Tue, 11 Aug 2020 10:42:33 +0800 Subject: [PATCH] add doc --- crawler.go | 3 +++ model.go | 6 ++++++ renovate.json | 5 ----- 3 files changed, 9 insertions(+), 5 deletions(-) delete mode 100644 renovate.json diff --git a/crawler.go b/crawler.go index c5f761c..5f30b88 100644 --- a/crawler.go +++ b/crawler.go @@ -4,6 +4,7 @@ import ( "fmt" ) +// 获取置顶文章pid以及作者信息 func GetPinnedArticlePidAndAuthor(columnName string) (*PinnedArticleAndAuthor, error) { if columnName == "" { return nil, ColumnNameCanNotBeEmpty @@ -23,6 +24,7 @@ func GetPinnedArticlePidAndAuthor(columnName string) (*PinnedArticleAndAuthor, e return &pinnedArticleAndAuthor, nil } +// 获取单个文章 func GetSingleArticle(pid int) (*Article, error) { if pid == 0 { return nil, PidCanNotBeEmpty @@ -42,6 +44,7 @@ func GetSingleArticle(pid int) (*Article, error) { return &article, nil } +// 获取文章pid列表 func GetArticlesListPids(columnName string) ([]int, error) { if columnName == "" { return nil, ColumnNameCanNotBeEmpty diff --git a/model.go b/model.go index 540dd0e..1086a3d 100644 --- a/model.go +++ b/model.go @@ -1,10 +1,12 @@ package ZhihuZhuanlanCrawler +// 专栏 type Zhuanlan struct { Slug string `json:"slug"` Name string `json:"name"` } +// 作者 type Author struct { ID string `json:"id"` Name string `json:"name"` @@ -19,6 +21,7 @@ type Author struct { UserType string `json:"user_type"` } +// 置顶文章及作者信息 type PinnedArticleAndAuthor struct { Type string `json:"type"` ID int `json:"id"` @@ -31,6 +34,7 @@ type PinnedArticleAndAuthor struct { Author Author } +// 主题 type Topic struct { Url string `json:"url"` Type string `json:"type"` @@ -38,6 +42,7 @@ type Topic struct { Name string `json:"name"` } +// 文章 type Article struct { ID int `json:"id"` Type string `json:"type"` @@ -51,6 +56,7 @@ type Article struct { Topics []Topic `json:"topics"` } +// 文章列表 type ArticleList struct { Paging struct { IsEnd bool `json:"is_end"` diff --git a/renovate.json b/renovate.json deleted file mode 100644 index f45d8f1..0000000 --- a/renovate.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": [ - "config:base" - ] -}