feat: multi-tenant workspace isolation, RBAC, sidebar nav, billing, and Android enhancements
- Backend: workspace_id isolation for 14 model tables + safe migration/backfill - Backend: RBAC system with 4 roles and 23 permissions, seeded on startup - Backend: workspace admin endpoints (list/manage all workspaces) - Backend: admin user management API (CRUD, reset password) - Backend: billing API with subscription plans, usage tracking, rate limiting - Backend: fix system_logs.py UNION query and wrong column references - Backend: WebSocket JWT auth and workspace enforcement - Frontend: sidebar navigation replacing top dropdown menu - Frontend: user management page (Users.vue) for admins - Frontend: enhanced Workspaces.vue with admin table view - Frontend: workspace RBAC computed properties in user store - Android: agent marketplace, billing/subscription UI, onboarding wizard - Android: phone login, analytics tracker, crash handler, network diagnostics - Android: splash screen, encrypted token storage, app update enhancements - Docs: multi-tenant RBAC guide with 8 sections and role-permission matrix Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import logging
|
||||
from app.core.database import get_db
|
||||
from app.models.alert_rule import AlertRule, AlertLog
|
||||
from app.api.auth import get_current_user
|
||||
from app.api.deps import get_current_workspace_id
|
||||
from app.models.user import User
|
||||
from app.core.exceptions import NotFoundError, ValidationError, ConflictError
|
||||
from app.services.alert_service import AlertService
|
||||
@@ -102,14 +103,17 @@ async def get_alert_rules(
|
||||
alert_type: Optional[str] = Query(None, description="告警类型筛选"),
|
||||
enabled: Optional[bool] = Query(None, description="是否启用筛选"),
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user)
|
||||
current_user: User = Depends(get_current_user),
|
||||
workspace_id: str = Depends(get_current_workspace_id),
|
||||
):
|
||||
"""
|
||||
获取告警规则列表
|
||||
|
||||
|
||||
支持分页和筛选
|
||||
"""
|
||||
query = db.query(AlertRule).filter(AlertRule.user_id == current_user.id)
|
||||
if workspace_id:
|
||||
query = query.filter(AlertRule.workspace_id == workspace_id)
|
||||
|
||||
# 筛选
|
||||
if alert_type:
|
||||
@@ -126,7 +130,8 @@ async def get_alert_rules(
|
||||
async def create_alert_rule(
|
||||
rule_data: AlertRuleCreate,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user)
|
||||
current_user: User = Depends(get_current_user),
|
||||
workspace_id: str = Depends(get_current_workspace_id),
|
||||
):
|
||||
"""
|
||||
创建告警规则
|
||||
@@ -165,7 +170,8 @@ async def create_alert_rule(
|
||||
notification_type=rule_data.notification_type,
|
||||
notification_config=rule_data.notification_config,
|
||||
enabled=rule_data.enabled,
|
||||
user_id=current_user.id
|
||||
user_id=current_user.id,
|
||||
workspace_id=workspace_id or None,
|
||||
)
|
||||
db.add(alert_rule)
|
||||
db.commit()
|
||||
|
||||
Reference in New Issue
Block a user