feat(auth): 实现平台超管与多租户角色权限深度隔离、前端动态路由白名单及DeepSeek配额守卫
这个提交包含在:
@@ -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(
|
||||
|
||||
在新工单中引用
屏蔽一个用户