feat: 账套模式全量接入 — 12个API entity_id统一走token解析链 + 前端登录选公司/切换器重签token

- 后端: kpis/bsc_layers/cash/predict/growth_quality/tax_compliance/data 的 entity_id 参数统一改为 Depends(get_entity_id)
- 前端: 拦截器删除自动附加X-Entity-Id/entity_id; 登录页公司选择器(按用户名授权过滤); 切换器改POST /auth/switch-entity重新签发token+整页刷新; ReportCenter同步改造
- 修复前后端不匹配: login-entities路由→/auth/entities; login响应entity_id取user.entity_id
This commit is contained in:
Hermes CI Fix
2026-08-11 11:29:39 +08:00
parent 12f9ae520b
commit 9986f38faa
11 changed files with 116 additions and 58 deletions
+12 -11
View File
@@ -11,6 +11,7 @@ from fastapi import APIRouter, Depends, HTTPException, Query
from sqlalchemy.orm import Session
from app.database import get_db
from app.deps import get_entity_id
from app.auth_middleware import require_auth, require_role
from app.models import TaxRecord, InvoiceCheck, SocialSecurity, ExpenseReimbursement
@@ -140,7 +141,7 @@ def _apply_burden_to_all(db: Session, entity_id: int):
def list_tax_records(
period: str = Query(None),
tax_type: str = Query(None),
entity_id: int = Query(None),
entity_id: int = Depends(get_entity_id),
db: Session = Depends(get_db),
_=Depends(require_auth),
):
@@ -236,7 +237,7 @@ def delete_tax_record(
@router.get("/burden")
def burden_analysis(
entity_id: int = Query(None),
entity_id: int = Depends(get_entity_id),
tax_type: str = Query(None),
db: Session = Depends(get_db),
_=Depends(require_auth),
@@ -274,7 +275,7 @@ def burden_analysis(
@router.post("/check")
def run_tax_check(
entity_id: int = Query(None),
entity_id: int = Depends(get_entity_id),
db: Session = Depends(get_db),
_=Depends(require_role("ceo", "finance")),
):
@@ -358,7 +359,7 @@ def _check_invoice(db: Session, inv: InvoiceCheck):
def list_invoices(
status: str = Query(None),
keyword: str = Query(None),
entity_id: int = Query(None),
entity_id: int = Depends(get_entity_id),
db: Session = Depends(get_db),
_=Depends(require_auth),
):
@@ -457,7 +458,7 @@ def delete_invoice(
@router.post("/invoices/check")
def batch_check_invoices(
invoice_id: int = Query(None),
entity_id: int = Query(None),
entity_id: int = Depends(get_entity_id),
db: Session = Depends(get_db),
_=Depends(require_role("ceo", "finance")),
):
@@ -481,7 +482,7 @@ def batch_check_invoices(
@router.get("/invoices/abnormal")
def list_abnormal_invoices(
entity_id: int = Query(None),
entity_id: int = Depends(get_entity_id),
limit: int = Query(50),
db: Session = Depends(get_db),
_=Depends(require_auth),
@@ -556,7 +557,7 @@ def list_ss_records(
period: str = Query(None),
employee: str = Query(None),
status: str = Query(None),
entity_id: int = Query(None),
entity_id: int = Depends(get_entity_id),
db: Session = Depends(get_db),
_=Depends(require_auth),
):
@@ -652,7 +653,7 @@ def delete_ss_record(
@router.post("/ss/check")
def batch_check_ss(
entity_id: int = Query(None),
entity_id: int = Depends(get_entity_id),
db: Session = Depends(get_db),
_=Depends(require_role("ceo", "finance")),
):
@@ -674,7 +675,7 @@ def batch_check_ss(
@router.get("/ss/abnormal")
def list_abnormal_ss(
entity_id: int = Query(None),
entity_id: int = Depends(get_entity_id),
limit: int = Query(50),
db: Session = Depends(get_db),
_=Depends(require_auth),
@@ -693,7 +694,7 @@ def list_abnormal_ss(
@router.get("/dashboard")
def tax_dashboard(
entity_id: int = Query(None),
entity_id: int = Depends(get_entity_id),
db: Session = Depends(get_db),
_=Depends(require_auth),
):
@@ -771,7 +772,7 @@ def tax_dashboard(
@router.post("/demo-data")
def seed_demo_data(
entity_id: int = Query(1),
entity_id: int = Depends(get_entity_id),
db: Session = Depends(get_db),
_=Depends(require_role("ceo", "finance")),
):