260326_01_ENH: 일부 설정 파일들 리펙토링

This commit is contained in:
2026-03-26 09:55:04 +09:00
parent 2052c84371
commit 8133ab1ee4
44 changed files with 781 additions and 765 deletions

112
src/types/lg.types.ts Normal file
View File

@@ -0,0 +1,112 @@
import {BANNER_GROUP} from "@/const/lg-banner.const";
import {BANNER_KEY_MAP, PRODUCT_KEY_MAP} from "@/const/lg-schema.const";
import {PRODUCTS_FILTER_ITEM} from "@/const/lg-product.const";
import {CategoryTargetType} from "@/types/filter.types";
import {EChartsOption} from "echarts";
export type ProductKey = keyof typeof PRODUCT_KEY_MAP;
export type BannerKey = keyof typeof BANNER_KEY_MAP;
export type ProductsFilterItem = (typeof PRODUCTS_FILTER_ITEM)[number];
export type BaseRow = {
year: string;
rowLabel: string;
total: string;
};
// { year, rowLabel, total, ...category }
export type ProductRow = BaseRow & Partial<Record<ProductKey, string>>;
// { year, rowLabel, total, ...banner }
// (배너는 기본 41개 키 + 차트별 추가 키가 생길 수 있으니 확장 허용)
export type BannerRow = BaseRow &
Partial<Record<BannerKey, string>> &
Record<Exclude<string, keyof BaseRow>, string>;
export type ProductResponse = {
statisticsDataMap : Record<string, Array<ProductRow>>;
};
export type BannerResponse = {
statisticsDataMap : Record<string, Array<BannerRow>>;
};
export type StatisticsRequestOption = {
// 캐시 사용 여부
useCache?: boolean; // default: true
// 마지막 연도만 조회
lastYear?: boolean; // default: false
// 소수점 자리수
decimalPoint?: number; // default: LgePenetrationConst.DECIMAL_POINT
};
export type StatisticsRequest = {
// 변수 ID 맵 (Key: 요청 Key, Value: 변수 ID)
variableIdMap: Record<string, string>;
// 배너 ID 배열 (1단 배너, 옆으로 붙이기)
bannerIdList?: string[];
// 필터 정보
// Key: 필터 키, Value: 필터 값 목록
filterCondition?: Record<string, number[]>;
// 요청 옵션
option?: StatisticsRequestOption; // default: { useCache: true, lastYear: false, decimalPoint: ... }
};
export type LifeStageRow = Record<string, unknown> & {
item: string;
total: string;
"KLIFEstAGE#1": string;
"KLIFEstAGE#2": string;
"KLIFEstAGE#3": string;
"KLIFEstAGE#4": string;
"KLIFEstAGE#5": string;
"KLIFEstAGE#6": string;
"KLIFEstAGE#7": string;
"KLIFEstAGE#8": string;
};
export type LifeStageGroup = {
title: string;
rows: LifeStageRow[]
}
export type BannerGroupKey = keyof typeof BANNER_GROUP;
export type CategoryChartMode = "none" | "stack" | "reverseStack" | "horizontal";
export type PageData<T> = {
title: string;
surveyTitle: string;
chartMode: CategoryChartMode;
chartLegend?: LegendOption;
chartTopMargin?:number;
chartHeight?: number | string;
chartWidth?: number;
data: T[];
};
export type LegendOption = EChartsOption["legend"];
export type CategoryFieldSpec = {
title: string | Record<CategoryTargetType, string>;
requestKey: string;
chartMode:CategoryChartMode;
chartLegend?: LegendOption;
chartTopMargin?:number;
qidByMode: Partial<Record<CategoryTargetType, string>>; // mode별 qid (없으면 숨김/요청 제외)
};
export type CategoryResolvedField = CategoryFieldSpec & {
requestKeyResolved: string;
qid: string;
};
export type BuildPageModeConfigResult = {
fields: CategoryResolvedField[];
variableIdMap: Record<string, string>;
};