docs: annotate Foundry source and deployment lifecycle in Chinese [skip ci]
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// 旧 board_layouts 路由:布局变更与父素材版本递增同事务执行,canonical 画布由入口守卫限制旧写入。
|
||||
package platform
|
||||
|
||||
import (
|
||||
@@ -7,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// placement 是素材在旧画布内的矩形位置,MaterialID 指向工作区内可访问且非 board 的素材。
|
||||
type placement struct {
|
||||
MaterialID string `json:"material_id"`
|
||||
X float64 `json:"x"`
|
||||
@@ -16,12 +18,15 @@ type placement struct {
|
||||
ZIndex int `json:"z_index"`
|
||||
}
|
||||
|
||||
// valid 限制有限坐标、正尺寸和层级范围;NaN 显式拒绝,无穷值也会被范围判断拒绝。
|
||||
func (p placement) valid() bool {
|
||||
return !math.IsNaN(p.X) && !math.IsNaN(p.Y) && !math.IsNaN(p.Width) && !math.IsNaN(p.Height) &&
|
||||
p.X >= -1000000 && p.X <= 1000000 && p.Y >= -1000000 && p.Y <= 1000000 &&
|
||||
p.Width >= 1 && p.Width <= 100000 && p.Height >= 1 && p.Height <= 100000 &&
|
||||
p.ZIndex >= -1000000 && p.ZIndex <= 1000000
|
||||
}
|
||||
|
||||
// layouts 对集合提供 GET/POST,对单条提供 PATCH/DELETE;所有写入都比较父画布 If-Match。
|
||||
func (s *service) layouts(w http.ResponseWriter, r *http.Request, project, account string) error {
|
||||
if r.Method != http.MethodGet && r.Method != http.MethodPost && r.Method != http.MethodPatch && r.Method != http.MethodDelete {
|
||||
reject(w, 405, "method_not_allowed")
|
||||
@@ -84,6 +89,7 @@ ORDER BY l.z_index,l.id LIMIT 2000
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
// 工作区锁保护当前事务内版本检查与写入;不匹配立即返回 412,不进入布局变更。
|
||||
if expected != version {
|
||||
reject(w, 412, "version_conflict")
|
||||
return nil
|
||||
@@ -141,6 +147,7 @@ WHERE project=$1 AND workspace_id=$2 AND board_id=$3 AND id=$4
|
||||
return sql.ErrNoRows
|
||||
}
|
||||
}
|
||||
// 即使只移动或删除一条布局,也递增父素材版本,供其他客户端发现画布变更。
|
||||
_, err = tx.ExecContext(r.Context(), "UPDATE materials SET version=version+1,modified_at=now() WHERE project=$1 AND workspace_id=$2 AND id=$3", project, workspace, board)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user