feat(auth): 实现平台超管与多租户角色权限深度隔离、前端动态路由白名单及DeepSeek配额守卫

这个提交包含在:
wikiboss
2026-09-21 11:21:54 +08:00
父节点 0f1a318f95
当前提交 13752f9906
共有 11 个文件被更改,包括 380 次插入 和 28 次删除

查看文件

@@ -148,6 +148,13 @@ export class DeepSeekService extends BaseService {
this.tenantQuotas.set(tenantId, Math.max(0, Number(maxTotalTokens) || 0));
}
/**
* 获取指定租户的 Token 最大额度上限
*/
getTenantTokenQuota(tenantId: string | number): number {
return this.tenantQuotas.get(tenantId) || 0;
}
/**
* 断言当前租户 Token 配额充足,超限则抛出 429 阻断
*/
@@ -339,8 +346,12 @@ export class DeepSeekService extends BaseService {
/**
* 测试与 DeepSeek 官方端点连通性
*/
async testConnection(testApiKey?: string): Promise<DeepSeekTestConnectionResult> {
const key = (testApiKey || this.config.apiKey || '').trim();
async testConnection(
testApiKey?: string,
tenantId?: number | string
): Promise<DeepSeekTestConnectionResult> {
const cfg = this.getTenantConfig(tenantId);
const key = (testApiKey || cfg.apiKey || '').trim();
if (!key) {
return {
success: false,
@@ -349,8 +360,8 @@ export class DeepSeekService extends BaseService {
}
const startTime = Date.now();
const endpoint = `${this.config.baseUrl || 'https://api.deepseek.com'}/chat/completions`;
const model = this.config.model || 'deepseek-chat';
const endpoint = `${cfg.baseUrl || 'https://api.deepseek.com'}/chat/completions`;
const model = cfg.model || 'deepseek-chat';
try {
await this.httpClient.post(