Skip to content

Commit dbb8c53

Browse files
committed
feat doc tree
1 parent e19a797 commit dbb8c53

File tree

21 files changed

+7954
-12570
lines changed

21 files changed

+7954
-12570
lines changed

backend/api/crawler/v1/crawler.go

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,38 @@
11
package v1
22

3-
import "github.com/chaitin/panda-wiki/consts"
3+
import (
4+
"github.com/chaitin/panda-wiki/consts"
5+
"github.com/chaitin/panda-wiki/pkg/anydoc"
6+
)
47

5-
type ScrapeReq struct {
6-
URL string `json:"url" validate:"required"`
7-
KbID string `json:"kb_id" validate:"required"`
8+
type CrawlerParseReq struct {
9+
Key string `json:"key"`
10+
KbID string `json:"kb_id" validate:"required"`
11+
CrawlerSource consts.CrawlerSource `json:"crawler_source" validate:"required"`
12+
Filename string `json:"filename"`
13+
FeishuSetting FeishuSetting `json:"feishu_setting" validate:"required_if=CrawlerSource feishu"`
14+
}
15+
16+
type FeishuSetting struct {
17+
UserAccessToken string `json:"user_access_token"`
18+
AppID string `json:"app_id"`
19+
AppSecret string `json:"app_secret"`
20+
SpaceId string `json:"space_id"`
21+
}
22+
23+
type CrawlerParseResp struct {
24+
ID string `json:"id"`
25+
Docs *anydoc.Child `json:"docs"`
26+
}
27+
28+
type CrawlerExportReq struct {
29+
KbID string `json:"kb_id" validate:"required"`
30+
ID string `json:"id" validate:"required"`
31+
DocID string `json:"doc_id" validate:"required"`
32+
}
33+
34+
type CrawlerExportResp struct {
35+
TaskId string `json:"task_id"`
836
}
937

1038
type ScrapeResp struct {

backend/consts/parse.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package consts
2+
3+
type CrawlerSource string
4+
5+
const (
6+
// CrawlerSourceUrl key或url形式 直接走parse接口
7+
CrawlerSourceUrl CrawlerSource = "url"
8+
CrawlerSourceRSS CrawlerSource = "rss"
9+
CrawlerSourceSitemap CrawlerSource = "sitemap"
10+
CrawlerSourceNotion CrawlerSource = "notion"
11+
CrawlerSourceFeishu CrawlerSource = "feishu"
12+
13+
// CrawlerSourceFile file形式 需要先走upload接口先上传文件
14+
CrawlerSourceFile CrawlerSource = "file"
15+
CrawlerSourceEpub CrawlerSource = "epub"
16+
CrawlerSourceYuque CrawlerSource = "yuque"
17+
CrawlerSourceSiyuan CrawlerSource = "siyuan"
18+
CrawlerSourceMindoc CrawlerSource = "mindoc"
19+
CrawlerSourceWikijs CrawlerSource = "wikijs"
20+
CrawlerSourceConfluence CrawlerSource = "confluence"
21+
)
22+
23+
type CrawlerSourceType string
24+
25+
const (
26+
CrawlerSourceTypeFile CrawlerSourceType = "file"
27+
CrawlerSourceTypeUrl CrawlerSourceType = "url"
28+
CrawlerSourceTypeKey CrawlerSourceType = "key"
29+
)
30+
31+
func (c CrawlerSource) Type() CrawlerSourceType {
32+
switch c {
33+
case CrawlerSourceNotion, CrawlerSourceFeishu:
34+
return CrawlerSourceTypeKey
35+
case CrawlerSourceUrl, CrawlerSourceRSS, CrawlerSourceSitemap:
36+
return CrawlerSourceTypeUrl
37+
case CrawlerSourceFile, CrawlerSourceEpub, CrawlerSourceYuque, CrawlerSourceSiyuan, CrawlerSourceMindoc, CrawlerSourceWikijs, CrawlerSourceConfluence:
38+
return CrawlerSourceTypeFile
39+
default:
40+
return ""
41+
}
42+
}

0 commit comments

Comments
 (0)