[as] WIP: 기본계획조회 다이얼로그 구현
This commit is contained in:
@@ -2,9 +2,11 @@ import { client } from "@/shared/api";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
|
||||
import type {
|
||||
ClsfSystmRequestDto,
|
||||
ClsfSystmParamsDto,
|
||||
ClsfSystmResponseDto,
|
||||
DcService,
|
||||
FileDownloadParamsDto,
|
||||
FileParamsDto,
|
||||
LvNowDmgMtncGnsvyResponseDto,
|
||||
LvNowDmgMtncGnsvySearchDto,
|
||||
NowDmgMtncGnsvyResponseDto,
|
||||
@@ -31,15 +33,39 @@ async function getLvNowDmgMtncGnsvy(
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async function getClsfSystm(params: ClsfSystmRequestDto): Promise<ClsfSystmResponseDto[]> {
|
||||
async function getClsfSystm(params: ClsfSystmParamsDto): Promise<ClsfSystmResponseDto[]> {
|
||||
const response = await client.get<ClsfSystmResponseDto[]>(`${ENDPOINT.DC_SERVICE}/clsfSystm`, {
|
||||
params,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async function getFile(params: FileParamsDto): Promise<unknown> {
|
||||
const response = await client.get<unknown>(`${ENDPOINT.DC_SERVICE}/file`, {
|
||||
params,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async function getFilePrcs(fileSn: string): Promise<unknown> {
|
||||
const response = await client.get<unknown>(`${ENDPOINT.DC_SERVICE}/fileprcs`, {
|
||||
params: { fileSn },
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async function fileDownload(params: FileDownloadParamsDto): Promise<unknown> {
|
||||
const response = await client.get<unknown>(`${ENDPOINT.DC_SERVICE}/fileDownload`, {
|
||||
params,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export const dcService = {
|
||||
getNowDmgMtncGnsvy,
|
||||
getLvNowDmgMtncGnsvy,
|
||||
getClsfSystm,
|
||||
getFile,
|
||||
getFilePrcs,
|
||||
fileDownload,
|
||||
} satisfies DcService;
|
||||
|
||||
@@ -3,7 +3,8 @@ import { useQuery } from "@tanstack/react-query";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
|
||||
import type {
|
||||
ClsfSystmRequestDto,
|
||||
ClsfSystmParamsDto,
|
||||
FileParamsDto,
|
||||
LvNowDmgMtncGnsvySearchDto,
|
||||
NowDmgMtncGnsvySearchDto,
|
||||
} from "../model/dc-interface";
|
||||
@@ -20,17 +21,45 @@ export function useNowDmgMtncGnsvy(params: NowDmgMtncGnsvySearchDto) {
|
||||
});
|
||||
}
|
||||
|
||||
function isLvNowDmgMtncGnsvyEnabled(params: LvNowDmgMtncGnsvySearchDto): boolean {
|
||||
if (!params.level || !params.ctpvNm) return false;
|
||||
if (params.level === "1") return true;
|
||||
if (params.level === "2") return Boolean(params.sggNm);
|
||||
if (params.level === "3") return Boolean(params.sggNm && params.gnsvyYr);
|
||||
return false;
|
||||
}
|
||||
|
||||
export function useLvNowDmgMtncGnsvy(params: LvNowDmgMtncGnsvySearchDto) {
|
||||
return useQuery({
|
||||
queryKey: [...baseKey, "lvNowDmgMtncGnsvy", params],
|
||||
queryFn: () => dcService.getLvNowDmgMtncGnsvy(params),
|
||||
enabled: Boolean(params.level && params.ctpvNm && params.sggNm && params.gnsvyYr),
|
||||
enabled: isLvNowDmgMtncGnsvyEnabled(params),
|
||||
});
|
||||
}
|
||||
|
||||
export function useClsfSystm(params: ClsfSystmRequestDto) {
|
||||
export function useClsfSystm(params: ClsfSystmParamsDto) {
|
||||
return useQuery({
|
||||
queryKey: [...baseKey, "clsfSystm", params],
|
||||
queryFn: () => dcService.getClsfSystm(params),
|
||||
// TODO: T4 — upClsfSystmSn 점진 로드 여부 확정 후 enabled/파라미터 조정
|
||||
enabled: Boolean(params.clsfSystmNm),
|
||||
});
|
||||
}
|
||||
|
||||
export function useFile(params: FileParamsDto) {
|
||||
return useQuery({
|
||||
queryKey: [...baseKey, "file", params],
|
||||
queryFn: () => dcService.getFile(params),
|
||||
// TODO: T2 — getFile Response DTO 확정 후 타입 교체
|
||||
enabled: Boolean(params.clsfSystmSn),
|
||||
});
|
||||
}
|
||||
|
||||
export function useFilePrcs(fileSn: string) {
|
||||
return useQuery({
|
||||
queryKey: [...baseKey, "filePrcs", fileSn],
|
||||
queryFn: () => dcService.getFilePrcs(fileSn),
|
||||
// TODO: T2 — getFilePrcs Response DTO 확정 후 타입 교체
|
||||
enabled: Boolean(fileSn),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
export { dcService } from "./api/dc-service";
|
||||
export { baseKey as nowDmgMtncGnsvyBaseKey, useNowDmgMtncGnsvy } from "./api/queries";
|
||||
export type { NowDmgMtncGnsvyResponseDto, NowDmgMtncGnsvySearchDto } from "./model/dc-interface";
|
||||
export {
|
||||
baseKey as nowDmgMtncGnsvyBaseKey,
|
||||
useClsfSystm,
|
||||
useFile,
|
||||
useFilePrcs,
|
||||
useLvNowDmgMtncGnsvy,
|
||||
useNowDmgMtncGnsvy,
|
||||
} from "./api/queries";
|
||||
export type {
|
||||
ClsfSystmParamsDto,
|
||||
ClsfSystmResponseDto,
|
||||
FileDownloadParamsDto,
|
||||
FileParamsDto,
|
||||
LvNowDmgMtncGnsvyResponseDto,
|
||||
LvNowDmgMtncGnsvySearchDto,
|
||||
NowDmgMtncGnsvyResponseDto,
|
||||
NowDmgMtncGnsvySearchDto,
|
||||
} from "./model/dc-interface";
|
||||
|
||||
@@ -12,11 +12,22 @@ export interface LvNowDmgMtncGnsvySearchDto {
|
||||
gnsvyYr?: string;
|
||||
}
|
||||
|
||||
export interface ClsfSystmRequestDto {
|
||||
export interface ClsfSystmParamsDto {
|
||||
clsfSystmNm?: string;
|
||||
upClsfSystmSn?: string;
|
||||
}
|
||||
|
||||
export interface FileParamsDto {
|
||||
sort?: string;
|
||||
clsfSystmSn?: string;
|
||||
vetPrcsYn?: string;
|
||||
}
|
||||
|
||||
export interface FileDownloadParamsDto {
|
||||
filePath?: string;
|
||||
fileName?: string;
|
||||
}
|
||||
|
||||
type NullableNumber = number | null;
|
||||
type NullableString = string | null;
|
||||
|
||||
@@ -67,14 +78,21 @@ export interface NowDmgMtncGnsvyResponseDto
|
||||
sggNm?: NullableString;
|
||||
}
|
||||
|
||||
/**
|
||||
* lvNowDmgMtncGnsvy 계층 노드.
|
||||
* - level 1: ctpvNm + children(구군)
|
||||
* - level 2: sggNm + children(연도)
|
||||
* - level 3: gnsvyYr + children(처리시설)
|
||||
* - 시설 리프: swtrmtFcltCd / swtrmtFcltNm (level 없음)
|
||||
*/
|
||||
export interface LvNowDmgMtncGnsvyResponseDto {
|
||||
level: number;
|
||||
ctpvNm: string;
|
||||
sggNm: string;
|
||||
gnsvyYr: string;
|
||||
swtrmtFcltCd: string;
|
||||
swtrmtFcltNm: string;
|
||||
children: LvNowDmgMtncGnsvyResponseDto[];
|
||||
level?: number;
|
||||
ctpvNm?: string;
|
||||
sggNm?: string;
|
||||
gnsvyYr?: string;
|
||||
swtrmtFcltCd?: string;
|
||||
swtrmtFcltNm?: string;
|
||||
children?: LvNowDmgMtncGnsvyResponseDto[];
|
||||
}
|
||||
|
||||
export interface ClsfSystmResponseDto {
|
||||
@@ -89,5 +107,8 @@ export interface ClsfSystmResponseDto {
|
||||
export interface DcService {
|
||||
getNowDmgMtncGnsvy(params: NowDmgMtncGnsvySearchDto): Promise<NowDmgMtncGnsvyResponseDto[]>;
|
||||
getLvNowDmgMtncGnsvy(params: LvNowDmgMtncGnsvySearchDto): Promise<LvNowDmgMtncGnsvyResponseDto[]>;
|
||||
getClsfSystm(params: ClsfSystmRequestDto): Promise<ClsfSystmResponseDto[]>;
|
||||
getClsfSystm(params: ClsfSystmParamsDto): Promise<ClsfSystmResponseDto[]>;
|
||||
getFile(params: FileParamsDto): Promise<unknown>;
|
||||
getFilePrcs(fileSn: string): Promise<unknown>;
|
||||
fileDownload(params: FileDownloadParamsDto): Promise<unknown>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user