feat: virtual company module, team projects, PWA dishes app, and startup scripts overhaul

- Add company module (3-tier org, CEO planning, parallel departments)
- Add company orchestrator, knowledge extractor, presets, scheduler
- Add company API endpoints, models, and frontend views
- Add 今天吃啥 PWA app (69 dishes, real images, offline support)
- Add team_projects output directory structure
- Add unified manage.ps1 for service lifecycle
- Add Windows startup guide v1.0
- Add TTS troubleshooting doc
- Update frontend (AgentChat UX overhaul, new views)
- Update backend (voice engine fix, multi-tenant, RBAC)
- Remove deprecated startup scripts and old docs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-07-10 22:37:56 +08:00
parent 3483c6b3be
commit f2e65a8fbb
259 changed files with 39239 additions and 3148 deletions

View File

@@ -12,6 +12,7 @@ from pydantic import BaseModel
from app.core.database import get_db
from app.api.auth import get_current_user
from app.api.deps import require_admin
from app.models.user import User
from app.models.audit_log import AuditLog
@@ -52,20 +53,13 @@ class AuditLogStats(BaseModel):
by_resource: dict # {"agent": 8, "workflow": 7, ...}
# ── Helpers ──────────────────────────────────────────────────────
def _check_admin(current_user: User):
if getattr(current_user, "role", None) != "admin":
from app.core.exceptions import ForbiddenError
raise ForbiddenError("仅管理员可访问审计日志")
# ── Endpoints ────────────────────────────────────────────────────
@router.get("", response_model=List[AuditLogItem])
async def get_audit_logs(
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
_admin: User = Depends(require_admin()),
user_id: Optional[str] = Query(None, description="按用户ID过滤"),
action: Optional[str] = Query(None, description="操作类型: CREATE/UPDATE/DELETE/EXECUTE/LOGIN"),
resource_type: Optional[str] = Query(None, description="资源类型: agent/workflow/user"),
@@ -77,8 +71,6 @@ async def get_audit_logs(
limit: int = Query(50, ge=1, le=1000),
):
"""查询操作审计日志(仅管理员)"""
_check_admin(current_user)
query = db.query(AuditLog)
if user_id:
@@ -106,10 +98,9 @@ async def get_audit_logs(
async def get_audit_logs_stats(
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
_admin: User = Depends(require_admin()),
):
"""获取审计日志统计(仅管理员)"""
_check_admin(current_user)
total = db.query(func.count(AuditLog.id)).scalar() or 0
action_rows = db.query(