diff --git a/.omo/ralph-loop.local.md b/.omo/ralph-loop.local.md deleted file mode 100644 index 8e0eb9b..0000000 --- a/.omo/ralph-loop.local.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -active: true -iteration: 1 -max_iterations: 500 -completion_promise: "DONE" -initial_completion_promise: "DONE" -started_at: "2026-06-17T06:11:18.800Z" -session_id: "ses_1dede8a7affeG6DxtfPUOviXrp" -ultrawork: true -strategy: "continue" -message_count_at_start: 8133 ---- -全部按照你的建议执行启动 diff --git a/.omo/run-continuation/ses_1dede8a7affeG6DxtfPUOviXrp.json b/.omo/run-continuation/ses_1dede8a7affeG6DxtfPUOviXrp.json index a2d4ea2..77e46da 100644 --- a/.omo/run-continuation/ses_1dede8a7affeG6DxtfPUOviXrp.json +++ b/.omo/run-continuation/ses_1dede8a7affeG6DxtfPUOviXrp.json @@ -1,10 +1,10 @@ { "sessionID": "ses_1dede8a7affeG6DxtfPUOviXrp", - "updatedAt": "2026-06-15T14:52:36.537Z", + "updatedAt": "2026-06-17T07:11:26.600Z", "sources": { "background-task": { "state": "idle", - "updatedAt": "2026-06-15T14:52:36.537Z" + "updatedAt": "2026-06-17T07:11:26.600Z" } } } \ No newline at end of file diff --git a/platform/backend/app/api/articles.py b/platform/backend/app/api/articles.py index 844e579..6068346 100644 --- a/platform/backend/app/api/articles.py +++ b/platform/backend/app/api/articles.py @@ -160,7 +160,8 @@ def update_article_content( if not article: article = Article( id=article_id, topic_id=topic_id, platform=platform, - file_path=f"db:{article_id}", status="draft" + file_path=f"db:{article_id}", status="draft", + org_id=topic.org_id ) db.add(article) article.html_content = html_content diff --git a/platform/backend/app/api/calendar.py b/platform/backend/app/api/calendar.py index ae754ad..e6e67da 100644 --- a/platform/backend/app/api/calendar.py +++ b/platform/backend/app/api/calendar.py @@ -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() diff --git a/platform/backend/app/api/metrics.py b/platform/backend/app/api/metrics.py index 199299d..f73395e 100644 --- a/platform/backend/app/api/metrics.py +++ b/platform/backend/app/api/metrics.py @@ -179,7 +179,7 @@ def create_metric( db.refresh(existing) return existing - metric = ContentMetrics(**data.model_dump(), last_fetched=datetime.now()) + metric = ContentMetrics(**data.model_dump(), last_fetched=datetime.now(), org_id=topic.org_id) db.add(metric) db.commit() db.refresh(metric) @@ -401,6 +401,7 @@ def fetch_zhihu_metrics( metric = ContentMetrics( topic_id=data.topic_id, platform=platform, + org_id=topic.org_id, **metric_data, last_fetched=datetime.now() ) diff --git a/platform/backend/app/api/publishing.py b/platform/backend/app/api/publishing.py index be13748..8ec2530 100644 --- a/platform/backend/app/api/publishing.py +++ b/platform/backend/app/api/publishing.py @@ -69,7 +69,8 @@ async def create_publish_record( action='publish', status='success', operator=operator, - description=f"选题 {req.topic_id} 发布到 {PLATFORM_LABELS.get(platform, platform)}" + description=f"选题 {req.topic_id} 发布到 {PLATFORM_LABELS.get(platform, platform)}", + org_id=topic.org_id ) db.add(record) results.append(PublishResult( diff --git a/platform/backend/app/api/search_rankings.py b/platform/backend/app/api/search_rankings.py index 56d0a69..168c5ff 100644 --- a/platform/backend/app/api/search_rankings.py +++ b/platform/backend/app/api/search_rankings.py @@ -86,7 +86,10 @@ def get_geo_overview( """GEO 概览 — AI 搜索引用 + 就绪度评分""" cutoff = datetime.now(timezone.utc) - timedelta(days=days) - base = db.query(SearchRanking).filter(SearchRanking.checked_at >= cutoff) + # Filter geo checks by org via articles + base = db.query(SearchRanking) + base = _apply_org_filter(base, current_user, db) + base = base.filter(SearchRanking.checked_at >= cutoff) total_geo = base.filter(SearchRanking.search_engine == "geo").count() total_cited = base.filter( SearchRanking.search_engine == "geo", @@ -138,7 +141,14 @@ def get_geo_readiness_scores( ): """获取 GEO 就绪度评分列表""" cutoff = datetime.now(timezone.utc) - timedelta(days=days) - scores = db.query(GeoReadinessScore).filter( + # Join via articles to filter by org + scores_query = db.query(GeoReadinessScore).join( + ArticleModel, GeoReadinessScore.article_id == ArticleModel.id, isouter=True + ) + of = org_filter(current_user, ArticleModel) + if of is not True: + scores_query = scores_query.filter(of) + scores = scores_query.filter( GeoReadinessScore.checked_at >= cutoff ).order_by(desc(GeoReadinessScore.checked_at)).limit(limit).all() return {"ok": True, "data": [s.to_dict() for s in scores]} diff --git a/platform/backend/app/api/tasks.py b/platform/backend/app/api/tasks.py index d7ea0c9..15a3af3 100644 --- a/platform/backend/app/api/tasks.py +++ b/platform/backend/app/api/tasks.py @@ -16,10 +16,13 @@ router = APIRouter(prefix="/api/tasks", tags=["tasks"]) def _check_task_org(task, current_user, db): """Check if task's topic belongs to user's org""" - if current_user.role == "admin" or not task.topic_id: + if current_user.role == "admin": return True - topic = db.query(Topic).filter(Topic.id == task.topic_id).first() - if topic and topic.org_id != current_user.org_id: + if task.topic_id: + topic = db.query(Topic).filter(Topic.id == task.topic_id).first() + if topic and topic.org_id != current_user.org_id: + raise HTTPException(status_code=404, detail="任务不存在") + elif current_user.role != "admin" and task.org_id != current_user.org_id: raise HTTPException(status_code=404, detail="任务不存在") return True @@ -87,7 +90,8 @@ def create_task( topic_id=data.topic_id, stage=data.stage, status="pending", - created_by=data.created_by or current_user.username + created_by=data.created_by or current_user.username, + org_id=current_user.org_id or "default" ) db.add(task) db.commit() @@ -438,7 +442,8 @@ def run_creator_task( stage="creator", status="running", started_at=now, - created_by=current_user.username + created_by=current_user.username, + org_id=current_user.org_id or "default" ) db.add(task) db.commit() diff --git a/platform/frontend/factory.html b/platform/frontend/factory.html new file mode 100644 index 0000000..f849fff --- /dev/null +++ b/platform/frontend/factory.html @@ -0,0 +1,1097 @@ + + +
+ + +内容表现 · 搜索排名 · GEO 就绪度 · 平台对比
+