fix: writer.py 生成的 HTML 未写入数据库导致预览和合规优化均取不到内容

save_html 在写文件后新增 save_article() 调用,将 HTML 持久化到 articles 表,
使预览 API 和 compliance_optimizer 能从 DB 正常读取文章内容
This commit is contained in:
Yuzhiran Dev
2026-05-18 08:18:32 +08:00
parent 52564ad036
commit 279dc5b894
+6 -1
View File
@@ -7,7 +7,7 @@ PROJECT_ROOT = Path(__file__).parent.parent
sys.path.insert(0, str(PROJECT_ROOT))
sys.path.insert(0, str(PROJECT_ROOT / 'platform' / 'backend'))
from db_helper import get_topic_by_id, update_topic_status
from db_helper import get_topic_by_id, update_topic_status, save_article
try:
from app.core.nvidia_client import call_llm
HAVE_LLM = True
@@ -424,6 +424,11 @@ class Writer:
out_path = out_dir / filename
out_path.write_text(html, encoding='utf-8')
logger.info(f"HTML 生成: {out_path}")
try:
save_article(self.topic_id, platform, html)
logger.info(f"文章写入数据库: {platform}_{self.topic_id}")
except Exception as e:
logger.warning(f"数据库保存失败: {e}")
return out_path
def mark_draft(self):