feat(imitation): add article imitation create flow

Introduce 仿写创作: new list and create views, backend imitation service
and prompt templates, worker task routing for imitation jobs, and one-click
rewrite triggers from question citation sources. Surface source article
URL/title on article list/detail, and restrict failed articles to delete-only.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-25 21:36:44 +08:00
parent 46d0a7aea0
commit 40d9a6cc63
29 changed files with 2678 additions and 120 deletions
@@ -241,7 +241,7 @@ func (s *TemplateService) SaveDraft(ctx context.Context, templateID int64, req S
AND template_id = $4
AND source_type = 'template'
AND deleted_at IS NULL
AND generate_status IN ('draft', 'failed')
AND generate_status = 'draft'
RETURNING id
`, stateJSON, *req.ArticleID, actor.TenantID, templateID).Scan(&articleID)
if err != nil {
@@ -333,7 +333,7 @@ func (s *TemplateService) Generate(ctx context.Context, templateID int64, req Ge
AND template_id = $3
AND source_type = 'template'
AND deleted_at IS NULL
AND generate_status IN ('draft', 'failed')
AND generate_status = 'draft'
FOR UPDATE
`, *req.ArticleID, actor.TenantID, templateID).Scan(&articleID)
if err != nil {
@@ -630,6 +630,8 @@ func generationFailureStageLabel(stage string) string {
return "AI 正文生成失败"
case "knowledge_resolve":
return "知识库检索失败"
case "source_fetch":
return "源文章抓取失败"
case "persist_begin_tx":
return "写入生成结果事务启动失败"
case "persist_create_version":