docs: annotate Foundry source and deployment lifecycle in Chinese [skip ci]

This commit is contained in:
2026-11-16 17:52:11 +08:00
parent 30829eeb86
commit 1090591503
123 changed files with 1279 additions and 3 deletions
+8
View File
@@ -1,3 +1,4 @@
// 旧多画布事务撤销:校验回执有效性与当前后态,恢复文档/关系并创建独立幂等撤销回执。
package platform
import (
@@ -7,6 +8,7 @@ import (
"strings"
)
// undoCanvasTransaction 只支持列出的子图/连接动作,过期或已撤销回执不可再次执行。
func (s *service) undoCanvasTransaction(w http.ResponseWriter, r *http.Request, project, account string) error {
if r.Method != http.MethodPost {
reject(w, 405, "method_not_allowed")
@@ -91,6 +93,7 @@ func (s *service) undoCanvasTransaction(w http.ResponseWriter, r *http.Request,
if err = json.Unmarshal(relationsRaw, &changes); err != nil {
return err
}
// 归档孩子无法按普通素材路径授权,需通过其当前父画布验证编辑权限;关系必须仍等于原 After。
archivedParticipants := map[string]bool{}
for _, change := range changes {
actual, err := readSubgraphRelation(r, tx, project, workspace, change.After.Child)
@@ -122,6 +125,7 @@ func (s *service) undoCanvasTransaction(w http.ResponseWriter, r *http.Request,
if err = json.Unmarshal(afterResponse, &recorded); err != nil {
return err
}
// 从原响应的不同形态收集操作后文档,用内容相等而非原版本号判断是否仍可安全栈式撤销。
afterStates := map[string]json.RawMessage{}
if recorded.Parent.BoardID != "" {
afterStates[recorded.Parent.BoardID] = recorded.Parent.Document
@@ -153,12 +157,14 @@ func (s *service) undoCanvasTransaction(w http.ResponseWriter, r *http.Request,
reject(w, 428, "version_required")
return nil
}
// 客户端确认当前版本,服务端还确认当前内容等于原后态,防止覆盖后续独立编辑。
if expected != snapshot.Version || !sameCanvasDocument(snapshot.Document, afterStates[id]) {
reject(w, 412, "version_conflict")
return nil
}
current[id] = snapshot
}
// 全部参与者校验完再恢复关系与快照;版本以当前值加一推进,绝不倒退到历史版本。
for _, change := range changes {
if err = writeSubgraphRelation(r, tx, project, workspace, change.Before); err != nil {
return err
@@ -176,6 +182,7 @@ func (s *service) undoCanvasTransaction(w http.ResponseWriter, r *http.Request,
updated = append(updated, snapshot)
appliedVersions[snapshot.BoardID] = snapshot.Version
}
// 原操作前不存在的孩子不删除,归档并使旧版本失效,保留完整数据供恢复。
archived := []string{}
for id, snapshot := range current {
if beforeIDs[id] {
@@ -223,6 +230,7 @@ func (s *service) undoCanvasTransaction(w http.ResponseWriter, r *http.Request,
return nil
}
// sameCanvasDocument 解码后重编码比较摘要,忽略 JSON 对象键顺序,无法解码时明确不相等。
func sameCanvasDocument(a, b json.RawMessage) bool {
var first, second any
if json.Unmarshal(a, &first) != nil || json.Unmarshal(b, &second) != nil {