fix: 三端联调测试 2 P1 + 2 P2 + 4 P3 修复
P1-07: billing get_or_create_usage 同步 max_* 列到当前计划限额 P1-08: relay handler 增加直接配额检查 (relay_requests/input/output_tokens) P2-09: relay failover 成功后记录 tokens 并标记 completed P2-10: Tauri agentStore saas-relay 模式下从 SaaS API 获取真实用量 P2-14: super_admin 合成 subscription + check_quota 放行 P3-19: 新建 ApiKeys.tsx 页面替代 ModelServices 路由 P3-15: antd destroyOnClose → destroyOnHidden (3处) P3-16: ProTable onSearch → onSubmit (2处)
This commit is contained in:
@@ -119,13 +119,13 @@ pub async fn quota_check_middleware(
|
||||
}
|
||||
|
||||
// 从扩展中获取认证上下文
|
||||
let account_id = match req.extensions().get::<AuthContext>() {
|
||||
Some(ctx) => ctx.account_id.clone(),
|
||||
let (account_id, role) = match req.extensions().get::<AuthContext>() {
|
||||
Some(ctx) => (ctx.account_id.clone(), ctx.role.clone()),
|
||||
None => return next.run(req).await,
|
||||
};
|
||||
|
||||
// 检查 relay_requests 配额
|
||||
match crate::billing::service::check_quota(&state.db, &account_id, "relay_requests").await {
|
||||
match crate::billing::service::check_quota(&state.db, &account_id, &role, "relay_requests").await {
|
||||
Ok(check) if !check.allowed => {
|
||||
tracing::warn!(
|
||||
"Quota exceeded for account {}: {} ({}/{})",
|
||||
@@ -146,7 +146,7 @@ pub async fn quota_check_middleware(
|
||||
}
|
||||
|
||||
// P1-8 修复: 同时检查 input_tokens 配额
|
||||
match crate::billing::service::check_quota(&state.db, &account_id, "input_tokens").await {
|
||||
match crate::billing::service::check_quota(&state.db, &account_id, &role, "input_tokens").await {
|
||||
Ok(check) if !check.allowed => {
|
||||
tracing::warn!(
|
||||
"Token quota exceeded for account {}: {} ({}/{})",
|
||||
|
||||
Reference in New Issue
Block a user