feat: 完善客户列表管理操作
This commit is contained in:
@@ -2,6 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { http } from '@/shared/api/http'
|
||||
import {
|
||||
approveEnterpriseReview,
|
||||
archivePlatformTenant,
|
||||
assignPlatformInternalUserRoles,
|
||||
changePlatformManagedUserStatus,
|
||||
changePlatformInternalUserStatus,
|
||||
@@ -12,6 +13,7 @@ import {
|
||||
createPlatformManagedUser,
|
||||
createPlatformRole,
|
||||
createPlatformTenant,
|
||||
createPlatformTenantImpersonation,
|
||||
deletePlatformPermission,
|
||||
deletePlatformRole,
|
||||
downloadTenantQualification,
|
||||
@@ -27,6 +29,7 @@ import {
|
||||
replacePlatformRolePermissions,
|
||||
resetPlatformInternalUserPassword,
|
||||
resetPlatformManagedUserPassword,
|
||||
resetPlatformTenantOwnerPassword,
|
||||
submitPlatformTenantReview,
|
||||
updatePlatformInternalUser,
|
||||
updatePlatformManagedUser,
|
||||
@@ -290,6 +293,24 @@ describe('platform IAM roles', () => {
|
||||
expect(http.put).toHaveBeenNthCalledWith(2, '/platform/v1/iam/tenants/8/status', { status: 'DISABLED' })
|
||||
})
|
||||
|
||||
it('supports owner password reset, logical archive, and audited impersonation contracts', async () => {
|
||||
const password = { newPassword: 'NewPassword#2026', forceChangePassword: true }
|
||||
const archivedTenant = { id: '190000000000000099', tenantCode: 'TEN99', tenantName: '测试客户', status: 'DISABLED' }
|
||||
const impersonation = { code: 'ticket-code', ticketId: 'ticket-id', expiresIn: 60 }
|
||||
vi.mocked(http.put).mockResolvedValue({ code: '200', message: 'success', data: null })
|
||||
vi.mocked(http.post)
|
||||
.mockResolvedValueOnce({ code: '200', message: 'success', data: archivedTenant })
|
||||
.mockResolvedValueOnce({ code: '200', message: 'success', data: impersonation })
|
||||
|
||||
await expect(resetPlatformTenantOwnerPassword('190000000000000099', password)).resolves.toBeNull()
|
||||
await expect(archivePlatformTenant('190000000000000099')).resolves.toEqual(archivedTenant)
|
||||
await expect(createPlatformTenantImpersonation('190000000000000099', { reason: '客户问题排查' })).resolves.toEqual(impersonation)
|
||||
|
||||
expect(http.put).toHaveBeenCalledWith('/platform/v1/iam/tenants/190000000000000099/owner/password', password)
|
||||
expect(http.post).toHaveBeenNthCalledWith(1, '/platform/v1/iam/tenants/190000000000000099/archive', {})
|
||||
expect(http.post).toHaveBeenNthCalledWith(2, '/platform/v1/iam/tenants/190000000000000099/impersonation', { reason: '客户问题排查' })
|
||||
})
|
||||
|
||||
it('loads real order totals for the visible customer tenants', async () => {
|
||||
const counts = [{ tenantId: '8', orderCount: 12 }, { tenantId: '9', orderCount: 0 }]
|
||||
vi.mocked(http.get).mockResolvedValue({ code: '200', message: 'success', data: counts })
|
||||
|
||||
@@ -141,6 +141,21 @@ export interface EnterpriseApprovalResponse {
|
||||
temporaryPassword: string | null
|
||||
}
|
||||
|
||||
export interface ResetPlatformTenantOwnerPasswordRequest {
|
||||
newPassword: string
|
||||
forceChangePassword: boolean
|
||||
}
|
||||
|
||||
export interface CreatePlatformTenantImpersonationRequest {
|
||||
reason: string
|
||||
}
|
||||
|
||||
export interface PlatformTenantImpersonationResponse {
|
||||
code: string
|
||||
ticketId: string
|
||||
expiresIn: number
|
||||
}
|
||||
|
||||
export interface PlatformRoleResource {
|
||||
id: number | string
|
||||
tenantId: number | string
|
||||
@@ -350,6 +365,24 @@ export function submitPlatformTenantReview(tenantId: number | string) {
|
||||
return postData<PlatformTenantResource>(`/platform/v1/iam/tenants/${tenantId}/submit-review`, {})
|
||||
}
|
||||
|
||||
export function resetPlatformTenantOwnerPassword(
|
||||
tenantId: number | string,
|
||||
payload: ResetPlatformTenantOwnerPasswordRequest,
|
||||
) {
|
||||
return putData<void>(`/platform/v1/iam/tenants/${tenantId}/owner/password`, payload)
|
||||
}
|
||||
|
||||
export function archivePlatformTenant(tenantId: number | string) {
|
||||
return postData<PlatformTenantResource>(`/platform/v1/iam/tenants/${tenantId}/archive`, {})
|
||||
}
|
||||
|
||||
export function createPlatformTenantImpersonation(
|
||||
tenantId: number | string,
|
||||
payload: CreatePlatformTenantImpersonationRequest,
|
||||
) {
|
||||
return postData<PlatformTenantImpersonationResponse>(`/platform/v1/iam/tenants/${tenantId}/impersonation`, payload)
|
||||
}
|
||||
|
||||
export async function uploadPlatformTenantQualification(
|
||||
tenantId: number | string,
|
||||
qualificationType: PlatformQualificationType,
|
||||
|
||||
Reference in New Issue
Block a user