docs: annotate Foundry source and deployment lifecycle in Chinese [skip ci]
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// 成员移动事务把文档重分配、嵌套孩子重挂、祖先端口修复和回执组合为一个原子操作。
|
||||
package platform
|
||||
|
||||
import (
|
||||
@@ -7,6 +8,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// moveSubgraphMembers 要求源/目标至少一侧是路径 frame 的孩子,另一侧只能是父或其直接孩子。
|
||||
func (s *service) moveSubgraphMembers(w http.ResponseWriter, r *http.Request, project, account string) error {
|
||||
if r.Method != http.MethodPost {
|
||||
reject(w, 405, "method_not_allowed")
|
||||
@@ -81,6 +83,7 @@ func (s *service) moveSubgraphMembers(w http.ResponseWriter, r *http.Request, pr
|
||||
reject(w, 409, "ownership_conflict")
|
||||
return nil
|
||||
}
|
||||
// 参与集合首先包括协调父、源与目标;移动嵌套 frame 时还需加入其所有后代以校验版本和权限。
|
||||
participants := map[string]bool{parent: true, input.Source: true, input.Target: true}
|
||||
for _, board := range []string{input.Source, input.Target} {
|
||||
if board == parent {
|
||||
@@ -99,6 +102,7 @@ func (s *service) moveSubgraphMembers(w http.ResponseWriter, r *http.Request, pr
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// frame 节点移动保留子画布 ID,只改变关系的 Parent;不可移到自己或后代内部形成循环。
|
||||
sourceNodes := canvasNodeData(sourceSnapshot.Document)
|
||||
changes := []subgraphRelationChange{}
|
||||
for _, node := range input.Nodes {
|
||||
@@ -155,6 +159,7 @@ func (s *service) moveSubgraphMembers(w http.ResponseWriter, r *http.Request, pr
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 若父画布对外暴露了被移动节点,还要将上一层祖先加入事务,保持端口链可解析。
|
||||
repair, err := planAncestorPortRepair(r, tx, project, workspace, parent, input.Source, account, input.Nodes, parentSnapshot.Document)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -162,6 +167,7 @@ func (s *service) moveSubgraphMembers(w http.ResponseWriter, r *http.Request, pr
|
||||
if repair != nil {
|
||||
participants[repair.Ancestor] = true
|
||||
}
|
||||
// 要求版本表完整且不夹带额外项,防止只确认局部版本就改写更大所有权子树。
|
||||
if len(input.Expected) != len(participants) {
|
||||
reject(w, 428, "version_required")
|
||||
return nil
|
||||
@@ -199,6 +205,7 @@ func (s *service) moveSubgraphMembers(w http.ResponseWriter, r *http.Request, pr
|
||||
before = append(before, snapshot)
|
||||
}
|
||||
raw := map[string]json.RawMessage{parent: snapshots[parent].Document, input.Source: snapshots[input.Source].Document, input.Target: snapshots[input.Target].Document}
|
||||
// 可选落点先写到来源局部文档,再交纯算法做一次空间转换,不能提前写成目标坐标。
|
||||
if input.Positions != nil {
|
||||
positioned, err := positionMemberDrop(raw[input.Source], input.Positions)
|
||||
if err != nil {
|
||||
@@ -222,6 +229,7 @@ func (s *service) moveSubgraphMembers(w http.ResponseWriter, r *http.Request, pr
|
||||
return err
|
||||
}
|
||||
}
|
||||
// 写关系、保存所有参与快照并记录 before/after 版本,同一事务出错即回滚。
|
||||
for _, change := range changes {
|
||||
if err = writeSubgraphRelation(r, tx, project, workspace, change.After); err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user