优化
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
|
||||
import type {
|
||||
CarrierScheduleQueryAttempt,
|
||||
CarrierScheduleQueryDetail,
|
||||
CarrierScheduleQueryFilter,
|
||||
CarrierScheduleQueryHistory,
|
||||
CarrierScheduleNodeFact,
|
||||
CarrierScheduleQueryPage,
|
||||
CarrierScheduleQueryResource,
|
||||
CarrierScheduleQueryView,
|
||||
@@ -22,21 +22,20 @@ function resource(raw: CarrierScheduleQueryResource): CarrierScheduleQueryResour
|
||||
oceanBookingId: String(raw.oceanBookingId),
|
||||
containerBookingId: optionalId(raw.containerBookingId),
|
||||
resultPortScheduleId: optionalId(raw.resultPortScheduleId),
|
||||
attemptCount: numberValue(raw.attemptCount),
|
||||
version: numberValue(raw.version),
|
||||
}
|
||||
}
|
||||
|
||||
function view(raw: CarrierScheduleQueryView): CarrierScheduleQueryView {
|
||||
return { ...raw, query: resource(raw.query), maxAttempts: numberValue(raw.maxAttempts), nextAllowedAt: raw.nextAllowedAt ?? raw.query.nextAllowedAt ?? null }
|
||||
return { ...raw, query: resource(raw.query) }
|
||||
}
|
||||
|
||||
function attempt(raw: CarrierScheduleQueryAttempt): CarrierScheduleQueryAttempt {
|
||||
return { ...raw, id: String(raw.id), queryId: String(raw.queryId), windowAttemptNo: numberValue(raw.windowAttemptNo), coverageGap: Boolean(raw.coverageGap) }
|
||||
function node(raw: CarrierScheduleNodeFact): CarrierScheduleNodeFact {
|
||||
return { ...raw, id: String(raw.id), nodeSequence: numberValue(raw.nodeSequence) }
|
||||
}
|
||||
|
||||
function history(raw: CarrierScheduleQueryHistory): CarrierScheduleQueryHistory {
|
||||
return { ...raw, id: String(raw.id), queryId: String(raw.queryId), fromVersion: raw.fromVersion == null ? null : numberValue(raw.fromVersion), toVersion: raw.toVersion == null ? null : numberValue(raw.toVersion) }
|
||||
return { ...raw, id: String(raw.id), fromVersion: raw.fromVersion == null ? null : numberValue(raw.fromVersion), toVersion: raw.toVersion == null ? null : numberValue(raw.toVersion), operatorId: optionalId(raw.operatorId) }
|
||||
}
|
||||
|
||||
export async function listCarrierScheduleQueries(filter: CarrierScheduleQueryFilter): Promise<CarrierScheduleQueryPage> {
|
||||
@@ -48,5 +47,5 @@ export async function listCarrierScheduleQueries(filter: CarrierScheduleQueryFil
|
||||
export async function getCarrierScheduleQuery(queryId: string): Promise<CarrierScheduleQueryDetail> {
|
||||
const response = await http.get<ApiEnvelope<CarrierScheduleQueryDetail>, ApiEnvelope<CarrierScheduleQueryDetail>>(`${basePath}/${encodeURIComponent(queryId)}`)
|
||||
const result = unwrapApiResponse(response)
|
||||
return { ...result, query: view(result.query), attempts: (result.attempts || []).map(attempt), histories: (result.histories || []).map(history) }
|
||||
return { ...result, query: view(result.query), nodes: (result.nodes || []).map(node), histories: (result.histories || []).map(history) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user