chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、 Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。 今日开发的培训推送管理改动随后单独提交。
This commit is contained in:
commit
7ec21f35b0
5767 files changed
+1436788
No files matched your search
@@ -0,0 +1,43 @@
|
||||
package confluence
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type resourceKind uint8
|
||||
|
||||
const (
|
||||
resourceSpace resourceKind = iota
|
||||
resourcePage
|
||||
)
|
||||
|
||||
// resourceRef is the canonical, persisted representation of a selection.
|
||||
// Space IDs deliberately remain unprefixed for backwards compatibility.
|
||||
type resourceRef struct {
|
||||
Kind resourceKind
|
||||
SpaceID string
|
||||
PageID string
|
||||
}
|
||||
|
||||
func makePageResourceID(spaceID, pageID string) string {
|
||||
return "page:" + spaceID + ":" + pageID
|
||||
}
|
||||
|
||||
func parseResourceID(id string) (resourceRef, error) {
|
||||
id = strings.TrimSpace(id)
|
||||
if id == "" {
|
||||
return resourceRef{}, fmt.Errorf("invalid empty Confluence resource ID")
|
||||
}
|
||||
if !strings.HasPrefix(id, "page:") {
|
||||
if strings.Contains(id, ":") {
|
||||
return resourceRef{}, fmt.Errorf("invalid Confluence space resource ID %q", id)
|
||||
}
|
||||
return resourceRef{Kind: resourceSpace, SpaceID: id}, nil
|
||||
}
|
||||
parts := strings.Split(id, ":")
|
||||
if len(parts) != 3 || parts[0] != "page" || strings.TrimSpace(parts[1]) == "" || strings.TrimSpace(parts[2]) == "" {
|
||||
return resourceRef{}, fmt.Errorf("invalid Confluence page resource ID %q", id)
|
||||
}
|
||||
return resourceRef{Kind: resourcePage, SpaceID: parts[1], PageID: parts[2]}, nil
|
||||
}
|
||||
Reference in new issue
Block a user