mirror of
https://github.com/Tencent/WeKnora.git
synced 2026-09-24 16:29:01 +08:00
feat: 添加获取和更新最新FAQ导入结果的方法
This commit is contained in:
@@ -400,3 +400,69 @@ func (c *Client) GetFAQImportProgress(ctx context.Context, taskID string) (*FAQI
|
||||
}
|
||||
return response.Data, nil
|
||||
}
|
||||
|
||||
// FAQImportResult stores statistics of the last FAQ import.
|
||||
// It matches server response from GET /knowledge-bases/{id}/faq/import/last-result.
|
||||
type FAQImportResult struct {
|
||||
TotalEntries int `json:"total_entries"`
|
||||
SuccessCount int `json:"success_count"`
|
||||
FailedCount int `json:"failed_count"`
|
||||
SkippedCount int `json:"skipped_count"`
|
||||
|
||||
ImportMode string `json:"import_mode"`
|
||||
ImportedAt time.Time `json:"imported_at"`
|
||||
TaskID string `json:"task_id"`
|
||||
|
||||
FailedEntriesURL string `json:"failed_entries_url,omitempty"`
|
||||
|
||||
DisplayStatus string `json:"display_status"`
|
||||
ProcessingTime int64 `json:"processing_time"`
|
||||
}
|
||||
|
||||
type faqImportResultResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Data *FAQImportResult `json:"data"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Code string `json:"code,omitempty"`
|
||||
}
|
||||
|
||||
type updateLastFAQImportResultDisplayStatusRequest struct {
|
||||
DisplayStatus string `json:"display_status"`
|
||||
}
|
||||
|
||||
// GetLastFAQImportResult retrieves the last FAQ import result summary for a knowledge base.
|
||||
func (c *Client) GetLastFAQImportResult(ctx context.Context, knowledgeBaseID string) (*FAQImportResult, error) {
|
||||
path := fmt.Sprintf("/api/v1/knowledge-bases/%s/faq/import/last-result", knowledgeBaseID)
|
||||
resp, err := c.doRequest(ctx, http.MethodGet, path, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var response faqImportResultResponse
|
||||
if err := parseResponse(resp, &response); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return response.Data, nil
|
||||
}
|
||||
|
||||
// UpdateLastFAQImportResultDisplayStatus updates the display status (open/close) of the last FAQ import result.
|
||||
func (c *Client) UpdateLastFAQImportResultDisplayStatus(ctx context.Context, knowledgeBaseID string, displayStatus string) error {
|
||||
path := fmt.Sprintf("/api/v1/knowledge-bases/%s/faq/import/last-result/display", knowledgeBaseID)
|
||||
resp, err := c.doRequest(ctx, http.MethodPut, path, &updateLastFAQImportResultDisplayStatusRequest{DisplayStatus: displayStatus}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var response faqSimpleResponse
|
||||
return parseResponse(resp, &response)
|
||||
}
|
||||
|
||||
// GetFAQImportResult is kept for backward compatibility; it now calls GetLastFAQImportResult.
|
||||
func (c *Client) GetFAQImportResult(ctx context.Context, knowledgeBaseID string) (*FAQImportResult, error) {
|
||||
return c.GetLastFAQImportResult(ctx, knowledgeBaseID)
|
||||
}
|
||||
|
||||
// UpdateFAQImportResultDisplayStatus is kept for backward compatibility; it now calls UpdateLastFAQImportResultDisplayStatus.
|
||||
func (c *Client) UpdateFAQImportResultDisplayStatus(ctx context.Context, knowledgeBaseID string, displayStatus string) error {
|
||||
return c.UpdateLastFAQImportResultDisplayStatus(ctx, knowledgeBaseID, displayStatus)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user