feat: Wave 2 - API org isolation + factory.html + insights.html

- Add org_id auto-population to articles.py, publishing.py, metrics.py
- Add org_id filtering to search_rankings.py geo endpoints
- Add org_id to calendar.py create/update/delete endpoints
- Add org_id to tasks.py create endpoints
- Create factory.html content pipeline page (3-tab: 待创作/进行中/待审查)
- Create insights.html analytics page (4-tab: 概览/搜索排名/GEO/平台对比)
This commit is contained in:
Yuzhiran Dev
2026-06-17 16:13:48 +08:00
parent dcfeccc97b
commit 5caf7bc52e
11 changed files with 2091 additions and 37 deletions
+12 -2
View File
@@ -97,7 +97,7 @@ def create_entry(
if current_user.role != "admin" and topic.org_id != current_user.org_id:
raise HTTPException(status_code=404, detail="选题不存在")
entry = ContentCalendar(**data.model_dump())
entry = ContentCalendar(**data.model_dump(), org_id=current_user.org_id or "default")
db.add(entry)
db.commit()
db.refresh(entry)
@@ -119,6 +119,13 @@ def update_entry(
entry = db.query(ContentCalendar).filter(ContentCalendar.id == entry_id).first()
if not entry:
raise HTTPException(status_code=404, detail="日历条目不存在")
# Verify ownership via topic org_id
if entry.topic_id:
topic_check = db.query(Topic).filter(Topic.id == entry.topic_id).first()
if topic_check and current_user.role != "admin" and topic_check.org_id != current_user.org_id:
raise HTTPException(status_code=404, detail="日历条目不存在")
if not entry.topic_id and current_user.role != "admin" and entry.org_id != current_user.org_id:
raise HTTPException(status_code=404, detail="日历条目不存在")
if entry.topic_id:
topic = db.query(Topic).filter(Topic.id == entry.topic_id).first()
@@ -156,6 +163,8 @@ def delete_entry(
topic = db.query(Topic).filter(Topic.id == entry.topic_id).first()
if topic and current_user.role != "admin" and topic.org_id != current_user.org_id:
raise HTTPException(status_code=404, detail="日历条目不存在")
if not entry.topic_id and current_user.role != "admin" and entry.org_id != current_user.org_id:
raise HTTPException(status_code=404, detail="日历条目不存在")
db.delete(entry)
db.commit()
return {"ok": True}
@@ -232,7 +241,8 @@ def create_from_topic(
title=topic.title,
planned_date=planned_date,
platform=platform,
created_by=current_user.username
created_by=current_user.username,
org_id=current_user.org_id or "default"
)
db.add(entry)
db.commit()