feat(tenant): implement self-service tenant creation functionality

Added a new API endpoint for creating tenants, allowing any logged-in user to create their own workspace. The backend automatically assigns the creator as the Owner of the new tenant. A new CreateTenantDialog component was introduced in the frontend, enabling users to input the workspace name and an optional description. Internationalization files were updated to include relevant messages for this feature across multiple languages.

Refs: #1303
This commit is contained in:
wizardchen
2026-05-16 04:42:21 +08:00
committed by lyingbug
parent 79d397297d
commit 29dc99ae79
10 changed files with 466 additions and 29 deletions
+20
View File
@@ -91,6 +91,26 @@ export async function updateTenant(
}
}
/**
* 创建新工作区(任意已登录用户均可调用)。
* 后端会自动把调用者写成新租户的 Owner,并生成 api_key、默认 storage_quota
* 等服务端字段,所以这里只暴露 name + description。
* 路由:POST /api/v1/tenants(router 上不挂 g.CrossTenant(),自助场景使用)。
*/
export async function createTenant(
payload: { name: string; description?: string },
): Promise<{ success: boolean; data?: TenantInfo; message?: string }> {
try {
const response = await post('/api/v1/tenants', payload)
return response as unknown as { success: boolean; data?: TenantInfo; message?: string }
} catch (error: any) {
return {
success: false,
message: error.message || t('error.tenant.createFailed'),
}
}
}
/**
* 搜索租户(支持分页、关键词搜索和租户ID过滤)
*/