feat(go): port knowledge compilation template/group + wiki artifact/nav/skill REST APIs from Python (#17656)

This commit is contained in:
Zhichang Yu
2026-07-31 22:57:43 +08:00
committed by GitHub
parent d67d14e4c6
commit b811dce1b0
18 changed files with 3428 additions and 54 deletions

View File

@@ -38,6 +38,7 @@ type fileCommitService interface {
GetCommitTree(ctx context.Context, commitID string) (map[string]interface{}, error)
GetCommitFileContent(ctx context.Context, folderID, commitID, fileID string) ([]byte, error)
GetFileVersionHistory(ctx context.Context, fileID string) ([]entity.VersionEntry, error)
ListPageCommits(ctx context.Context, datasetID, pageType, slug string, page, pageSize int) ([]*entity.FileCommit, int64, error)
}
// FileCommitHandler file commit handler
@@ -217,6 +218,49 @@ func (h *FileCommitHandler) ListCommits(c *gin.Context) {
}
ctx := c.Request.Context()
// Python's list_commits supports ?slug=<page_slug> to filter audit commits
// for a specific wiki/skill page (written by record_page_edit). These page
// commits are scoped to the dataset and page file key, so route them through
// the page-commit path instead of the folder-based ListCommits. This only
// applies to the /datasets/{dataset_id}/commits route.
if slug := c.Query("slug"); slug != "" {
datasetID := c.Param("dataset_id")
if datasetID == "" {
common.ErrorWithCode(c, common.CodeArgumentError, "slug requires a dataset scope")
return
}
pageType := c.Query("page_type")
commits, total, err := h.commitService.ListPageCommits(ctx, datasetID, pageType, slug, page, pageSize)
if err != nil {
jsonInternalError(c, err)
return
}
var commitList []entity.CommitResponse
for _, commit := range commits {
var ct int64
if commit.CreateTime != nil {
ct = *commit.CreateTime
}
commitList = append(commitList, entity.CommitResponse{
ID: commit.ID,
FolderID: commit.FolderID,
ParentID: commit.ParentID,
Message: commit.Message,
AuthorID: commit.AuthorID,
FileCount: commit.FileCount,
CreateTime: &ct,
})
}
common.SuccessWithData(c, gin.H{
"total": total,
"page": page,
"page_size": pageSize,
"commits": commitList,
}, common.CodeSuccess.Message())
return
}
commits, total, err := h.commitService.ListCommits(ctx, folderID, page, pageSize, orderBy, desc)
if err != nil {
jsonInternalError(c, err)