Add pagination to admin management tabs (cases/categories/sources/orgs)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from fastapi import APIRouter, HTTPException, Query, Depends
|
||||
from fastapi import APIRouter, HTTPException, Query, Depends, Body
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlalchemy import or_
|
||||
from pathlib import Path
|
||||
@@ -140,6 +140,31 @@ def preview_article(topic_id: str, platform: str = "zhihu", current_user: User =
|
||||
raise HTTPException(status_code=404, detail=f"Article not found for {topic_id} on {platform}")
|
||||
return {"topic_id": topic_id, "platform": platform, "html": article.html_content}
|
||||
|
||||
@router.put("/{topic_id}/content")
|
||||
def update_article_content(
|
||||
topic_id: str,
|
||||
platform: str = Body(...),
|
||||
html_content: str = Body(...),
|
||||
current_user: User = Depends(get_current_user),
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
"""保存用户编辑后的文章 HTML 内容"""
|
||||
topic = db.query(Topic).filter(Topic.id == topic_id).first()
|
||||
if topic and current_user.role != "admin" and topic.org_id != current_user.org_id:
|
||||
raise HTTPException(status_code=404, detail="Topic not found")
|
||||
article_id = f"{platform}_{topic_id}"
|
||||
article = db.query(Article).filter(Article.id == article_id).first()
|
||||
if not article:
|
||||
article = Article(
|
||||
id=article_id, topic_id=topic_id, platform=platform,
|
||||
file_path=f"db:{article_id}", status="draft"
|
||||
)
|
||||
db.add(article)
|
||||
article.html_content = html_content
|
||||
article.updated_at = datetime.now()
|
||||
db.commit()
|
||||
return {"ok": True, "id": article_id}
|
||||
|
||||
@router.get("/optimization-report")
|
||||
def get_optimization_report(publish_date: str = None, current_user: User = Depends(get_current_user)):
|
||||
"""获取合规优化报告"""
|
||||
|
||||
Reference in New Issue
Block a user