서버페이징 변경
This commit is contained in:
@@ -6,7 +6,7 @@ import {
|
||||
postRawJson,
|
||||
putData,
|
||||
} from "@/components/lib/api";
|
||||
import { fetchAllPages } from "@/shared/lib/fetch-all-pages";
|
||||
import { requestGridExcel } from "@/shared/api/grid-export";
|
||||
import { isDredgingBackendEnabled } from "./backend-mode";
|
||||
import { toDredgingApiError } from "./dredging-error";
|
||||
import {
|
||||
@@ -28,6 +28,41 @@ import type {
|
||||
} from "../model/registration-request";
|
||||
export type { AttachmentReference } from "../model/registration-request";
|
||||
|
||||
/** 그리드는 0 기반 서버 페이지 하나만 요청한다. 지도·전체 다운로드는 별도 계약이다. */
|
||||
export type DredgingGridQuery = {
|
||||
viewType: string;
|
||||
fromDate: string;
|
||||
toDate: string;
|
||||
ctpv?: string;
|
||||
sgg?: string;
|
||||
page: number;
|
||||
size: number;
|
||||
sort?: string;
|
||||
};
|
||||
|
||||
export const fetchDredgingGridPage = async (query: DredgingGridQuery): Promise<{
|
||||
content: Array<Record<string, unknown> & { recordIds: string[] }>;
|
||||
totalElements: number;
|
||||
number: number;
|
||||
size: number;
|
||||
}> => {
|
||||
const params = new URLSearchParams();
|
||||
Object.entries(query).forEach(([key, value]) => {
|
||||
if (value !== undefined && value !== "") params.set(key, String(value));
|
||||
});
|
||||
const body = await getRawJson(`v1/dredging/grid?${params}`);
|
||||
return body?.data ?? body;
|
||||
};
|
||||
|
||||
/** 적용 조건 전체의 서버 XLSX를 받는다. page/size는 다운로드에 전달하지 않는다. */
|
||||
export const downloadDredgingGridExcel = (query: Omit<DredgingGridQuery, "page" | "size">): Promise<void> => {
|
||||
const params = new URLSearchParams();
|
||||
Object.entries(query).forEach(([key, value]) => {
|
||||
if (value !== undefined && value !== "") params.set(key, String(value));
|
||||
});
|
||||
return requestGridExcel(`v1/dredging/grid/exportJobs?${params}`, {}, `준설관리_${query.viewType}_${query.fromDate}_${query.toDate}.xlsx`);
|
||||
};
|
||||
|
||||
type LocationRequest = GeoPoint & {
|
||||
locationKey: string;
|
||||
};
|
||||
@@ -64,18 +99,6 @@ export const fetchDredgingRecords = async (params: {
|
||||
}
|
||||
};
|
||||
|
||||
/** 조회조건에 맞는 준설기록 전체 페이지를 순회해 목록·Excel 건수를 일치시킨다. */
|
||||
export const fetchAllDredgingRecords = async (params: {
|
||||
fromDate: string;
|
||||
toDate: string;
|
||||
ctpv?: string;
|
||||
sgg?: string;
|
||||
}) =>
|
||||
fetchAllPages({
|
||||
fetchPage: (page, size) => fetchDredgingRecords({ ...params, page, size }),
|
||||
getItems: (response) => response.items ?? [],
|
||||
getTotal: (response) => Number(response.total ?? 0),
|
||||
});
|
||||
|
||||
/** 등록된 준설사진의 공통 첨부파일 참조를 조회한다. */
|
||||
export const fetchDredgingPhotos = async (
|
||||
|
||||
Reference in New Issue
Block a user