优化
This commit is contained in:
@@ -1,7 +1,34 @@
|
||||
import type { PlatformTenantResource } from '@/modules/iam'
|
||||
import type { InboundListQuery } from './core/types'
|
||||
|
||||
export type InboundTaskMode = 'measurement' | 'review'
|
||||
|
||||
export interface ActiveCustomerPage {
|
||||
records: PlatformTenantResource[]
|
||||
pages: number
|
||||
}
|
||||
|
||||
export interface ActiveCustomerQuery {
|
||||
page: number
|
||||
size: number
|
||||
status: 'ACTIVE'
|
||||
}
|
||||
|
||||
export async function loadAllActiveCustomers(
|
||||
fetchPage: (query: ActiveCustomerQuery) => Promise<ActiveCustomerPage>,
|
||||
) {
|
||||
const records: PlatformTenantResource[] = []
|
||||
let page = 1
|
||||
let pages = 1
|
||||
do {
|
||||
const response = await fetchPage({ page, size: 200, status: 'ACTIVE' })
|
||||
records.push(...response.records)
|
||||
pages = Math.max(1, response.pages)
|
||||
page += 1
|
||||
} while (page <= pages)
|
||||
return records
|
||||
}
|
||||
|
||||
export function buildInboundTaskQuery(
|
||||
mode: InboundTaskMode,
|
||||
query: Omit<InboundListQuery, 'tab' | 'processStatus' | 'measureReviewStatus'>,
|
||||
|
||||
Reference in New Issue
Block a user