feat(selection): 支持选股结果服务端分页
This commit is contained in:
@@ -2,6 +2,7 @@ import { requestJson } from "@/shared/api/request-json"
|
||||
|
||||
import type {
|
||||
SelectionResults,
|
||||
SelectionResultsQuery,
|
||||
SelectionRunAccepted,
|
||||
SelectionRunRequest,
|
||||
SelectionStrategy,
|
||||
@@ -10,9 +11,11 @@ import type {
|
||||
export function getSelectionResults(
|
||||
strategy: SelectionStrategy,
|
||||
targetTradeDate?: string,
|
||||
query: SelectionResultsQuery = { page: 1, pageSize: 10 },
|
||||
signal?: AbortSignal,
|
||||
) {
|
||||
const params = new URLSearchParams({ strategy })
|
||||
const params = buildSelectionQueryParams(query)
|
||||
params.set("strategy", strategy)
|
||||
if (targetTradeDate) params.set("target_trade_date", targetTradeDate)
|
||||
return requestJson<SelectionResults>(
|
||||
`/api/v1/selection/results?${params.toString()}`,
|
||||
@@ -20,10 +23,28 @@ export function getSelectionResults(
|
||||
)
|
||||
}
|
||||
|
||||
export function getSelectionRun(runId: string, signal?: AbortSignal) {
|
||||
return requestJson<SelectionResults>(`/api/v1/selection/runs/${runId}`, {
|
||||
signal,
|
||||
export function getSelectionRun(
|
||||
runId: string,
|
||||
query: SelectionResultsQuery = { page: 1, pageSize: 10 },
|
||||
signal?: AbortSignal,
|
||||
) {
|
||||
const params = buildSelectionQueryParams(query)
|
||||
return requestJson<SelectionResults>(
|
||||
`/api/v1/selection/runs/${runId}?${params.toString()}`,
|
||||
{
|
||||
signal,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
function buildSelectionQueryParams(query: SelectionResultsQuery) {
|
||||
const params = new URLSearchParams({
|
||||
page: String(query.page),
|
||||
page_size: String(query.pageSize),
|
||||
})
|
||||
if (query.search) params.set("search", query.search)
|
||||
if (query.category) params.set("category", query.category)
|
||||
return params
|
||||
}
|
||||
|
||||
export function triggerSelectionRun(
|
||||
|
||||
Reference in New Issue
Block a user