feat(server): persist renderContent texture and cover it in asset lifecycle

Add an optional renderContent field to canvas nodes across the go-zero API
type, domain node, SQLC models/queries, PostgreSQL schema, and mappers so a
lightweight transparent-WebP display texture persists alongside the original
content. Prefer renderContent for project thumbnails and main-canvas
previews, and treat both content and renderContent as protected/deletable
asset URLs during canvas asset cleanup. Extend round-trip coverage.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-16 20:45:56 +08:00
parent e7a0cc0b86
commit ee2c52bbc6
17 changed files with 75 additions and 46 deletions
@@ -467,7 +467,7 @@ func (q *Queries) ListMessagesByProject(ctx context.Context, arg ListMessagesByP
}
const listNodesByProject = `-- name: ListNodesByProject :many
SELECT id, project_id, user_id, node_type, title, x, y, width, height, content, tone, status, sort_order, parent_id, layer_role, font_size, font_family, font_weight, color, text_align, line_height, letter_spacing, text_decoration, text_transform, opacity, fill_color, stroke_color, stroke_width, stroke_style, flip_x, flip_y, rotation, semantic_context
SELECT id, project_id, user_id, node_type, title, x, y, width, height, content, tone, status, sort_order, parent_id, layer_role, font_size, font_family, font_weight, color, text_align, line_height, letter_spacing, text_decoration, text_transform, opacity, fill_color, stroke_color, stroke_width, stroke_style, flip_x, flip_y, rotation, semantic_context, render_content
FROM canvas_nodes
WHERE project_id = $1 AND user_id = $2
ORDER BY sort_order ASC, id ASC
@@ -521,6 +521,7 @@ func (q *Queries) ListNodesByProject(ctx context.Context, arg ListNodesByProject
&i.FlipY,
&i.Rotation,
&i.SemanticContext,
&i.RenderContent,
); err != nil {
return nil, err
}
@@ -746,8 +747,8 @@ func (q *Queries) UpsertBrandKit(ctx context.Context, arg UpsertBrandKitParams)
}
const upsertCanvasNode = `-- name: UpsertCanvasNode :exec
INSERT INTO canvas_nodes (id, project_id, user_id, node_type, title, x, y, width, height, content, tone, status, sort_order, parent_id, layer_role, font_size, font_family, font_weight, color, text_align, line_height, letter_spacing, text_decoration, text_transform, opacity, fill_color, stroke_color, stroke_width, stroke_style, flip_x, flip_y, rotation, semantic_context)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33)
INSERT INTO canvas_nodes (id, project_id, user_id, node_type, title, x, y, width, height, content, tone, status, sort_order, parent_id, layer_role, font_size, font_family, font_weight, color, text_align, line_height, letter_spacing, text_decoration, text_transform, opacity, fill_color, stroke_color, stroke_width, stroke_style, flip_x, flip_y, rotation, semantic_context, render_content)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34)
ON CONFLICT (id) DO UPDATE SET
project_id = EXCLUDED.project_id,
user_id = EXCLUDED.user_id,
@@ -780,7 +781,8 @@ ON CONFLICT (id) DO UPDATE SET
flip_x = EXCLUDED.flip_x,
flip_y = EXCLUDED.flip_y,
rotation = EXCLUDED.rotation,
semantic_context = EXCLUDED.semantic_context
semantic_context = EXCLUDED.semantic_context,
render_content = EXCLUDED.render_content
`
type UpsertCanvasNodeParams struct {
@@ -817,6 +819,7 @@ type UpsertCanvasNodeParams struct {
FlipY bool `json:"flip_y"`
Rotation float64 `json:"rotation"`
SemanticContext string `json:"semantic_context"`
RenderContent string `json:"render_content"`
}
func (q *Queries) UpsertCanvasNode(ctx context.Context, arg UpsertCanvasNodeParams) error {
@@ -854,6 +857,7 @@ func (q *Queries) UpsertCanvasNode(ctx context.Context, arg UpsertCanvasNodePara
arg.FlipY,
arg.Rotation,
arg.SemanticContext,
arg.RenderContent,
)
return err
}