feat(tenant): add tenant name update functionality and enhance UI
Implemented a new API endpoint for updating tenant names, allowing owners to edit tenant information directly within the UI. The frontend now supports inline editing with success and error notifications. Additionally, internationalization files have been updated to include relevant messages for the new functionality across English, Korean, Russian, and Chinese languages, ensuring a consistent user experience. Refs: #1303
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { get, post } from '@/utils/request'
|
||||
import { get, post, put } from '@/utils/request'
|
||||
import i18n from '@/i18n'
|
||||
|
||||
const t = (key: string) => i18n.global.t(key)
|
||||
@@ -70,6 +70,27 @@ export async function resetTenantApiKey(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新租户信息(目前仅暴露租户名称编辑入口)。
|
||||
* 后端 `PUT /tenants/:id` 走 GORM 的 `Updates(tenant)`,只会写入请求体里
|
||||
* 出现的非零字段;这里只发送 `name` 就只会改名字,不会把其它字段清空。
|
||||
* 权限:owner(与 router.go 中的 g.Owner() 守卫保持一致)。
|
||||
*/
|
||||
export async function updateTenant(
|
||||
tenantId: number,
|
||||
payload: { name: string },
|
||||
): Promise<{ success: boolean; data?: TenantInfo; message?: string }> {
|
||||
try {
|
||||
const response = await put(`/api/v1/tenants/${tenantId}`, payload)
|
||||
return response as unknown as { success: boolean; data?: TenantInfo; message?: string }
|
||||
} catch (error: any) {
|
||||
return {
|
||||
success: false,
|
||||
message: error.message || t('error.tenant.updateFailed'),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索租户(支持分页、关键词搜索和租户ID过滤)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user