This commit is contained in:
2026-08-25 09:52:45 +08:00
parent e9b6979a82
commit 5641545fd5
4 changed files with 208 additions and 6 deletions
+30 -3
View File
@@ -1,5 +1,6 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { http } from '@/shared/api/http'
import { overseasHttp } from '@/shared/api/overseasHttp'
import {
approveEnterpriseReview,
archivePlatformTenant,
@@ -24,6 +25,7 @@ import {
listPlatformRoles,
listPlatformInternalUsers,
listPlatformManagedUsers,
listSharedReceivingOverseasWarehouseOptions,
getPlatformUserOptions,
qualificationFileName,
replacePlatformRolePermissions,
@@ -49,6 +51,10 @@ vi.mock('@/shared/api/http', () => ({
unwrapApiResponse: <T>(response: { data: T }) => response.data,
}))
vi.mock('@/shared/api/overseasHttp', () => ({
overseasHttp: { get: vi.fn() },
}))
const role: PlatformRoleResource = {
id: 4000002,
tenantId: 0,
@@ -108,6 +114,7 @@ const managedUser: PlatformManagedUser = {
roleNames: ['运营管理员'],
lastLoginAt: '2026-06-01T10:30:00',
protectedAccount: false,
overseasWarehouseId: null,
}
describe('platform IAM roles', () => {
@@ -116,6 +123,7 @@ describe('platform IAM roles', () => {
vi.mocked(http.post).mockReset()
vi.mocked(http.put).mockReset()
vi.mocked(http.delete).mockReset()
vi.mocked(overseasHttp.get).mockReset()
})
it('loads roles from the platform IAM prefix', async () => {
@@ -212,15 +220,15 @@ describe('platform IAM roles', () => {
it('maintains paginated platform users through the unified user contract', async () => {
const userOptions = {
tenants: [{ id: '0', name: '平台', status: 'ACTIVE' }],
roles: [{ id: '40001', tenantId: '0', name: '运营管理员', status: 'ACTIVE' }],
roles: [{ id: '40001', tenantId: '0', roleCode: 'PLATFORM_OPERATOR', name: '运营管理员', status: 'ACTIVE' }],
}
const create = {
username: 'zhangwei', displayName: '张伟', phone: '13800138000', email: 'zhangwei@example.com',
tenantId: '0', roleIds: ['40001'], password: 'Password1', status: 'ACTIVE' as const,
tenantId: '0', roleIds: ['40001'], overseasWarehouseId: null, password: 'Password1', status: 'ACTIVE' as const,
}
const update = {
displayName: '张伟', phone: '13800138000', email: 'zhangwei@example.com',
tenantId: '0', roleIds: ['40001'],
tenantId: '0', roleIds: ['40001'], overseasWarehouseId: null,
}
const userPage = { records: [managedUser], page: 2, size: 10, total: 11, pages: 2 }
vi.mocked(http.get).mockResolvedValueOnce({
@@ -247,6 +255,25 @@ describe('platform IAM roles', () => {
expect(http.put).toHaveBeenNthCalledWith(3, `/platform/v1/iam/users/${managedUser.membershipId}/password`, { newPassword: 'ChangeMe123' })
})
it('loads only active shared receiving overseas warehouses through the overseas gateway', async () => {
vi.mocked(overseasHttp.get).mockResolvedValue({
code: '200', message: 'success', data: {
records: [
{ id: '90071992547409931', customerId: '0', warehouseCode: 'LAX-01', warehouseName: '洛杉矶收货仓', warehouseType: 'OVERSEAS', countryCode: 'US', status: 'ACTIVE' },
{ id: '2', customerId: '100', warehouseCode: 'CUST', warehouseName: '客户仓', warehouseType: 'OVERSEAS', countryCode: 'US', status: 'ACTIVE' },
{ id: '3', customerId: '0', warehouseCode: 'PARTNER', warehouseName: '合作仓', warehouseType: 'OVERSEAS_PARTNER', countryCode: 'US', status: 'ACTIVE' },
], page: 1, size: 200, total: 3, pages: 1,
},
})
await expect(listSharedReceivingOverseasWarehouseOptions()).resolves.toEqual([
{ id: '90071992547409931', warehouseCode: 'LAX-01', warehouseName: '洛杉矶收货仓', countryCode: 'US' },
])
expect(overseasHttp.get).toHaveBeenCalledWith('/platform/v1/warehouse-admin', {
params: { customerId: '0', page: 1, size: 200, capabilityCode: 'RECEIVING', status: 'ACTIVE' },
})
})
it('loads qualifications for the selected tenant', async () => {
const qualification = {
id: 12,
+40 -1
View File
@@ -1,4 +1,5 @@
import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
import { overseasHttp } from '@/shared/api/overseasHttp'
import type { PlatformPermissionResource } from '@/shared/types/platformPermission'
export type { PlatformPermissionResource } from '@/shared/types/platformPermission'
@@ -253,6 +254,7 @@ export interface PlatformManagedUser {
roleNames: string[]
lastLoginAt: string | null
protectedAccount: boolean
overseasWarehouseId: number | string | null
}
export interface PlatformManagedUserPage {
@@ -272,7 +274,14 @@ export interface PlatformManagedUserQuery {
export interface PlatformUserOptions {
tenants: Array<{ id: number | string; name: string; status: string }>
roles: Array<{ id: number | string; tenantId: number | string; name: string; status: string }>
roles: Array<{ id: number | string; tenantId: number | string; roleCode: string; name: string; status: string }>
}
export interface SharedReceivingOverseasWarehouseOption {
id: string
warehouseCode: string
warehouseName: string
countryCode: string
}
export interface CreatePlatformManagedUserRequest {
@@ -282,6 +291,7 @@ export interface CreatePlatformManagedUserRequest {
email: string
tenantId: number | string
roleIds: Array<number | string>
overseasWarehouseId: number | string | null
password: string
status: 'ACTIVE' | 'DISABLED'
}
@@ -292,6 +302,7 @@ export interface UpdatePlatformManagedUserRequest {
email: string
tenantId: number | string
roleIds: Array<number | string>
overseasWarehouseId: number | string | null
}
async function getData<T>(path: string): Promise<T> {
@@ -558,6 +569,34 @@ export function getPlatformUserOptions() {
return getData<PlatformUserOptions>('/platform/v1/iam/users/options')
}
export async function listSharedReceivingOverseasWarehouseOptions() {
interface WarehousePage {
records: Array<{
id: number | string
customerId: number | string
warehouseCode: string
warehouseName: string
warehouseType: string
countryCode: string
status: string
}>
}
const response = await overseasHttp.get<ApiEnvelope<WarehousePage>, ApiEnvelope<WarehousePage>>(
'/platform/v1/warehouse-admin',
{ params: { customerId: '0', page: 1, size: 200, capabilityCode: 'RECEIVING', status: 'ACTIVE' } },
)
return unwrapApiResponse(response).records
.filter((warehouse) => String(warehouse.customerId) === '0'
&& warehouse.warehouseType === 'OVERSEAS'
&& warehouse.status === 'ACTIVE')
.map((warehouse) => ({
id: String(warehouse.id),
warehouseCode: warehouse.warehouseCode,
warehouseName: warehouse.warehouseName,
countryCode: warehouse.countryCode,
}))
}
export function createPlatformManagedUser(payload: CreatePlatformManagedUserRequest) {
return postData<PlatformManagedUser>('/platform/v1/iam/users', payload)
}