feat(knowledge-base): document list filters and explicit batch-management UX
Add three new optional filters to the document list under a knowledge base detail page — parse status, source/channel, and updated time range — and rework multi-select to no longer cause the card title to jitter on hover. Backend - Introduce types.KnowledgeListFilter to aggregate optional filter dimensions (tag, keyword, file_type, parse_status, source, updated_from/to) and switch ListPagedKnowledgeByKnowledgeBaseID (repository/service/interface) to accept it instead of a growing positional parameter list. - The ListKnowledge HTTP handler accepts new parse_status, source, start_time and end_time query params; time params accept RFC3339, "YYYY-MM-DD HH:MM:SS" and "YYYY-MM-DD". The repository routes source="manual"/"url" onto the type column to stay consistent with file_type semantics; other source values match the channel column. - Update the four other callers (agent_service, initialization) to pass an empty filter struct, preserving prior behavior. Frontend - Add three controls in the doc-filter-bar (status select, source select, date-range picker with future-date disabled) wired through getKnowled / listKnowledgeFiles into the new backend params. - Replace the hover-triggered card checkbox with an explicit "批量管理" mode (mirrors the session list UX): in card view the checkbox only renders while batch mode is on, entered via the per-card "..." menu; the list view keeps its leading checkbox column. Switching from list to grid auto-enables batch mode when something is already selected, so the selection stays visible. - DocumentBatchBar now stays open whenever batch mode or selection > 0, and its "取消选择" button both clears the selection and exits batch mode. API surface sync - Regenerate Swagger artifacts (docs/docs.go / swagger.json / swagger.yaml). - Update docs/api/knowledge.md with the new query parameters. - Add backward-compatible ListKnowledgeWithFilter + KnowledgeListFilter to the Go SDK; the existing ListKnowledge keeps its signature. i18n - New filter labels in zh-CN / en-US / ko-KR / ru-RU; reuse existing menu.batchManage / batchManage.cancel for the multi-select strings.
This commit is contained in:
+54
-9
@@ -278,20 +278,65 @@ func (c *Client) GetKnowledgeBatch(ctx context.Context, knowledgeIDs []string) (
|
||||
return response.Data, nil
|
||||
}
|
||||
|
||||
// ListKnowledge lists knowledge entries in a knowledge base with pagination
|
||||
// ListKnowledge lists knowledge entries in a knowledge base with pagination.
|
||||
// For richer filtering (keyword, file type, parse status, source, time range)
|
||||
// use ListKnowledgeWithFilter.
|
||||
func (c *Client) ListKnowledge(ctx context.Context,
|
||||
knowledgeBaseID string,
|
||||
page int,
|
||||
pageSize int,
|
||||
tagID string,
|
||||
) ([]Knowledge, int64, error) {
|
||||
return c.ListKnowledgeWithFilter(ctx, knowledgeBaseID, page, pageSize, KnowledgeListFilter{TagID: tagID})
|
||||
}
|
||||
|
||||
// KnowledgeListFilter mirrors the server-side filters accepted by GET
|
||||
// /api/v1/knowledge-bases/{id}/knowledge. Empty / zero fields are omitted from
|
||||
// the request.
|
||||
type KnowledgeListFilter struct {
|
||||
TagID string
|
||||
Keyword string
|
||||
FileType string
|
||||
ParseStatus string
|
||||
Source string
|
||||
// StartTime / EndTime filter on knowledge updated_at. Zero values are skipped.
|
||||
// They are serialized in RFC3339 format.
|
||||
StartTime time.Time
|
||||
EndTime time.Time
|
||||
}
|
||||
|
||||
// ListKnowledgeWithFilter lists knowledge entries with the full filter surface.
|
||||
func (c *Client) ListKnowledgeWithFilter(ctx context.Context,
|
||||
knowledgeBaseID string,
|
||||
page int,
|
||||
pageSize int,
|
||||
filter KnowledgeListFilter,
|
||||
) ([]Knowledge, int64, error) {
|
||||
path := fmt.Sprintf("/api/v1/knowledge-bases/%s/knowledge", knowledgeBaseID)
|
||||
|
||||
queryParams := url.Values{}
|
||||
queryParams.Add("page", strconv.Itoa(page))
|
||||
queryParams.Add("page_size", strconv.Itoa(pageSize))
|
||||
if tagID != "" {
|
||||
queryParams.Add("tag_id", tagID)
|
||||
if filter.TagID != "" {
|
||||
queryParams.Add("tag_id", filter.TagID)
|
||||
}
|
||||
if filter.Keyword != "" {
|
||||
queryParams.Add("keyword", filter.Keyword)
|
||||
}
|
||||
if filter.FileType != "" {
|
||||
queryParams.Add("file_type", filter.FileType)
|
||||
}
|
||||
if filter.ParseStatus != "" {
|
||||
queryParams.Add("parse_status", filter.ParseStatus)
|
||||
}
|
||||
if filter.Source != "" {
|
||||
queryParams.Add("source", filter.Source)
|
||||
}
|
||||
if !filter.StartTime.IsZero() {
|
||||
queryParams.Add("start_time", filter.StartTime.Format(time.RFC3339))
|
||||
}
|
||||
if !filter.EndTime.IsZero() {
|
||||
queryParams.Add("end_time", filter.EndTime.Format(time.RFC3339))
|
||||
}
|
||||
|
||||
resp, err := c.doRequest(ctx, http.MethodGet, path, nil, queryParams)
|
||||
@@ -439,8 +484,8 @@ func (c *Client) UpdateImageInfo(ctx context.Context,
|
||||
|
||||
// CreateManualKnowledgeRequest contains the parameters for creating a manual Markdown knowledge entry.
|
||||
type CreateManualKnowledgeRequest struct {
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
TagID string `json:"tag_id,omitempty"`
|
||||
Channel string `json:"channel,omitempty"`
|
||||
}
|
||||
@@ -550,8 +595,8 @@ func (c *Client) MoveKnowledge(ctx context.Context, req *MoveKnowledgeRequest) (
|
||||
}
|
||||
|
||||
var result struct {
|
||||
Success bool `json:"success"`
|
||||
Data *MoveKnowledgeResponse `json:"data"`
|
||||
Success bool `json:"success"`
|
||||
Data *MoveKnowledgeResponse `json:"data"`
|
||||
}
|
||||
if err := parseResponse(resp, &result); err != nil {
|
||||
return nil, err
|
||||
@@ -579,8 +624,8 @@ func (c *Client) GetKnowledgeMoveProgress(ctx context.Context, taskID string) (*
|
||||
}
|
||||
|
||||
var result struct {
|
||||
Success bool `json:"success"`
|
||||
Data *KnowledgeMoveProgress `json:"data"`
|
||||
Success bool `json:"success"`
|
||||
Data *KnowledgeMoveProgress `json:"data"`
|
||||
}
|
||||
if err := parseResponse(resp, &result); err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user