-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2907 from actiontech/2192
api definition: get knowledge base and tags of knowledge base #2192
- Loading branch information
Showing
6 changed files
with
483 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package v1 | ||
|
||
import ( | ||
"github.com/actiontech/sqle/sqle/api/controller" | ||
"github.com/labstack/echo/v4" | ||
) | ||
|
||
type GetKnowledgeBaseListReq struct { | ||
KeyWords string `json:"keywords" query:"keywords" example:"keywords"` // 搜索内容 | ||
Tags []string `json:"tags" query:"tags" example:"tag1"` // 搜索标签 | ||
Limit uint32 `json:"limit" query:"limit" example:"10" validate:"required"` | ||
Offset uint32 `json:"offset" query:"offset" example:"0"` | ||
} | ||
|
||
type GetKnowledgeBaseListRes struct { | ||
controller.BaseRes | ||
Data []*KnowledgeBase `json:"data"` | ||
TotalNums uint64 `json:"total_nums"` | ||
} | ||
|
||
type KnowledgeBase struct { | ||
ID uint `json:"id"` // 知识库ID | ||
Title string `json:"title"` // 标题 | ||
Description string `json:"description"` // 描述 | ||
Content string `json:"content"` // 内容 | ||
Tags []*Tag `json:"tags"` // 标签 | ||
} | ||
|
||
type Tag struct { | ||
ID uint `json:"id"` // 标签ID | ||
Name string `json:"name"` // 标签名称 | ||
} | ||
|
||
// GetKnowledgeBaseList | ||
// @Summary 获取知识库列表 | ||
// @Description get knowledge base list | ||
// @Id getKnowledgeBaseList | ||
// @Tags knowledge_base | ||
// @Param keywords query string false "keywords" | ||
// @Param tags query []string false "tags" | ||
// @Security ApiKeyAuth | ||
// @Success 200 {object} v1.GetKnowledgeBaseListRes | ||
// @router /v1/knowledge_bases [get] | ||
func GetKnowledgeBaseList(c echo.Context) error { | ||
return getKnowledgeBaseList(c) | ||
} | ||
|
||
type GetKnowledgeBaseTagListRes struct { | ||
controller.BaseRes | ||
TotalNums uint64 `json:"total_nums"` | ||
Data []*Tag `json:"data"` | ||
} | ||
|
||
// GetKnowledgeBaseTagList | ||
// @Summary 获取知识库标签列表 | ||
// @Description get tag list of knowledge base | ||
// @Id getKnowledgeBaseTagList | ||
// @Tags knowledge_base | ||
// @Security ApiKeyAuth | ||
// @Success 200 {object} v1.GetKnowledgeBaseTagListRes | ||
// @router /v1/knowledge_bases/tags [get] | ||
func GetKnowledgeBaseTagList(c echo.Context) error { | ||
return getKnowledgeBaseTagList(c) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//go:build !enterprise | ||
// +build !enterprise | ||
|
||
package v1 | ||
|
||
import ( | ||
e "errors" | ||
|
||
"github.com/actiontech/sqle/sqle/errors" | ||
"github.com/labstack/echo/v4" | ||
) | ||
|
||
var ErrCommunityEditionDoesNotSupportKnowledgeBase = errors.New(errors.EnterpriseEditionFeatures, e.New("community edition does not support knowledge base")) | ||
|
||
func getKnowledgeBaseList(c echo.Context) error { | ||
return ErrCommunityEditionDoesNotSupportKnowledgeBase | ||
} | ||
|
||
func getKnowledgeBaseTagList(c echo.Context) error { | ||
return ErrCommunityEditionDoesNotSupportKnowledgeBase | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.