This commit is contained in:
2026-08-06 14:55:17 +08:00
parent a813426588
commit 4ac0adac62
18 changed files with 379 additions and 352 deletions
@@ -83,6 +83,7 @@ export interface PlatformPartnerImportResult {
}
const basePath = '/platform/v1/partners'
const platformResourceScope = 0
function normalizePartner(resource: PlatformPartnerResource): PlatformPartnerResource {
const legacyTypes: PlatformPartnerType[] = resource.partnerType === 'BOTH'
@@ -96,9 +97,9 @@ function normalizePartner(resource: PlatformPartnerResource): PlatformPartnerRes
}
}
export async function listPlatformPartners(tenantId: number | string | undefined, query: PlatformPartnerQuery) {
export async function listPlatformPartners(query: PlatformPartnerQuery) {
const response = await http.get<ApiEnvelope<PlatformPartnerPagePayload>, ApiEnvelope<PlatformPartnerPagePayload>>(basePath, {
params: { tenantId, ...query },
params: query,
})
const page = unwrapApiResponse(response)
return {
@@ -111,10 +112,10 @@ export async function listPlatformPartners(tenantId: number | string | undefined
}
}
export async function getPlatformPartner(tenantId: number | string, partnerId: number | string) {
export async function getPlatformPartner(partnerId: number | string) {
const response = await http.get<ApiEnvelope<PlatformPartnerResource>, ApiEnvelope<PlatformPartnerResource>>(
`${basePath}/${partnerId}`,
{ params: { tenantId } },
{ params: { tenantId: platformResourceScope } },
)
return normalizePartner(unwrapApiResponse(response))
}
@@ -123,42 +124,40 @@ export async function downloadPlatformPartnerImportTemplate() {
return http.get<Blob, Blob>(`${basePath}/import-template`, { responseType: 'blob' })
}
export async function importPlatformPartners(tenantId: number | string, file: File) {
export async function importPlatformPartners(file: File) {
const form = new FormData()
form.append('file', file)
const response = await http.post<ApiEnvelope<PlatformPartnerImportResult>, ApiEnvelope<PlatformPartnerImportResult>>(
`${basePath}/import`,
form,
{ params: { tenantId } },
{ params: { tenantId: platformResourceScope } },
)
return unwrapApiResponse(response)
}
export async function createPlatformPartner(tenantId: number | string, payload: SavePlatformPartnerRequest) {
export async function createPlatformPartner(payload: SavePlatformPartnerRequest) {
const response = await http.post<ApiEnvelope<number | string>, ApiEnvelope<number | string>>(basePath, payload, {
params: { tenantId },
params: { tenantId: platformResourceScope },
})
return unwrapApiResponse(response)
}
export async function updatePlatformPartner(
tenantId: number | string,
partnerId: number | string,
payload: SavePlatformPartnerRequest,
) {
const response = await http.put<ApiEnvelope<null>, ApiEnvelope<null>>(`${basePath}/${partnerId}`, payload, {
params: { tenantId },
params: { tenantId: platformResourceScope },
})
return unwrapApiResponse(response)
}
export async function changePlatformPartnerStatus(
tenantId: number | string,
partnerId: number | string,
status: PlatformPartnerStatus,
) {
const response = await http.patch<ApiEnvelope<null>, ApiEnvelope<null>>(`${basePath}/${partnerId}/status`, { status }, {
params: { tenantId },
params: { tenantId: platformResourceScope },
})
return unwrapApiResponse(response)
}