增加风控列表总数并优化站内提醒
This commit is contained in:
@@ -65,6 +65,16 @@ async def _idempotent_write(
|
||||
return await ApiTransactionService().execute_in(session, context, scope, key, body, action)
|
||||
|
||||
|
||||
def _risk_list_envelope(page: dict[str, Any], context: RequestContext) -> dict[str, object]:
|
||||
"""在统一列表信封上补充风控列表总数和页大小。"""
|
||||
response = _list_envelope(page, context)
|
||||
meta = response["meta"]
|
||||
if isinstance(meta, dict):
|
||||
meta["total"] = int(page.get("total") or 0)
|
||||
meta["page_size"] = int(page.get("page_size") or 0)
|
||||
return response
|
||||
|
||||
|
||||
@router.get("/overview")
|
||||
async def risk_overview(
|
||||
context: RequestContext = Depends(build_request_context), # noqa: B008
|
||||
@@ -81,7 +91,7 @@ async def list_risk_alerts(
|
||||
session: AsyncSession = Depends(get_session), # noqa: B008
|
||||
) -> dict[str, object]:
|
||||
data = await RiskQueryService(session).list_alerts(context, query)
|
||||
return _list_envelope(data, context)
|
||||
return _risk_list_envelope(data, context)
|
||||
|
||||
|
||||
@router.post("/alerts/scan")
|
||||
@@ -231,7 +241,7 @@ async def list_risk_evidence(
|
||||
session: AsyncSession = Depends(get_session), # noqa: B008
|
||||
) -> dict[str, object]:
|
||||
data = await RiskQueryService(session).list_evidence(context, source, query)
|
||||
return _list_envelope(data, context)
|
||||
return _risk_list_envelope(data, context)
|
||||
|
||||
|
||||
@router.get("/notifications")
|
||||
@@ -241,7 +251,7 @@ async def list_risk_notifications(
|
||||
session: AsyncSession = Depends(get_session), # noqa: B008
|
||||
) -> dict[str, object]:
|
||||
data = await RiskNotificationService(session).list_notifications(context, query)
|
||||
return _list_envelope(data, context)
|
||||
return _risk_list_envelope(data, context)
|
||||
|
||||
|
||||
@router.post("/daily-report")
|
||||
|
||||
Reference in New Issue
Block a user