Merge remote-tracking branch 'origin/feature/sein' into iipbs/st/dev
This commit is contained in:
@@ -0,0 +1,242 @@
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { stClient } from "@/shared/api/client";
|
||||
|
||||
import type {
|
||||
DomesticPopulationListResponse,
|
||||
DomesticPopulationFinalResponse,
|
||||
UpperCodesByNameResponse,
|
||||
DomesticPopulationMappingItem,
|
||||
} from "../model/ppltn/statistics-domestic-population-interface";
|
||||
|
||||
// 1. 응답 데이터의 타입을 정의합니다 (이미 정의된 것이 있다면 그것을 사용하세요)
|
||||
interface ChartDataResponse {
|
||||
status: string;
|
||||
data: {
|
||||
X_AXIS: string[];
|
||||
TOT: number[];
|
||||
ORIGIN_MALE: (number | null)[];
|
||||
ORIGIN_FEMALE: (number | null)[];
|
||||
FOREIGN_MALE: (number | null)[];
|
||||
FOREIGN_FEMALE: (number | null)[];
|
||||
};
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export class StatisticsPpltnApiService {
|
||||
|
||||
/** 내국인 엑셀 임시 업로드 */
|
||||
public async uploadDomesticPopulationExcel(
|
||||
file: File,
|
||||
statsYr: string,
|
||||
): Promise<{ status: string; message?: string }> {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
formData.append("statsYr", statsYr);
|
||||
|
||||
const response = await stClient.post<{ status: string; message?: string }>(
|
||||
`${ENDPOINT.ST_SERVICE.PPLTN}/domestic-population-excel`,
|
||||
formData,
|
||||
{ headers: { "Content-Type": "multipart/form-data" } },
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/** 내국인 임시 적재 리스트 조회
|
||||
* @param opt1 "1" = 전체 리스트(좌측), "2" = 미매핑 리스트(우측)
|
||||
*/
|
||||
public async getDomesticPopulationList(
|
||||
statsYr: string,
|
||||
opt1: "1" | "2",
|
||||
): Promise<DomesticPopulationListResponse> {
|
||||
const response = await stClient.get<DomesticPopulationListResponse>(
|
||||
`${ENDPOINT.ST_SERVICE.PPLTN}/domestic-population-list`,
|
||||
{ params: { statsYr, opt1 } },
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/** 내국인 최종 마스터 반영 */
|
||||
public async saveDomesticPopulationFinal(
|
||||
statsYr: string,
|
||||
regList: DomesticPopulationMappingItem[],
|
||||
): Promise<DomesticPopulationFinalResponse> {
|
||||
const response = await stClient.post<DomesticPopulationFinalResponse>(
|
||||
`${ENDPOINT.ST_SERVICE.PPLTN}/domestic-population-final`,
|
||||
{ YR: statsYr, regList },
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
/** 미매핑 행 클릭 시 상위 코드 후보 조회 */
|
||||
|
||||
public async getUpperCodesByName(
|
||||
statsYr: string,
|
||||
admdstNm: string,
|
||||
admdstCd: string
|
||||
): Promise<UpperCodesByNameResponse> {
|
||||
// GET 요청으로 변경하고 params 객체를 추가합니다.
|
||||
const response = await stClient.get<UpperCodesByNameResponse>(
|
||||
`${ENDPOINT.ST_SERVICE.PPLTN}/upper-codes-by-name`,
|
||||
{
|
||||
params: { statsYr, admdstNm,admdstCd }
|
||||
},
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/* ════════════════════════════════════
|
||||
외국인
|
||||
════════════════════════════════════ */
|
||||
|
||||
/** 외국인 엑셀 임시 업로드 */
|
||||
public async uploadForeignPopulationExcel(
|
||||
file: File,
|
||||
statsYr: string,
|
||||
): Promise<{ status: string; message?: string }> {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
formData.append("statsYr", statsYr);
|
||||
const response = await stClient.post<{ status: string; message?: string }>(
|
||||
`${ENDPOINT.ST_SERVICE.PPLTN}/foreign-population-excel`,
|
||||
formData,
|
||||
{ headers: { "Content-Type": "multipart/form-data" } },
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/** 외국인 임시 적재 리스트 조회
|
||||
* @param opt1 "1" = 전체 리스트(좌측), "2" = 미매핑 리스트(우측)
|
||||
*/
|
||||
public async getForeignPopulationList(
|
||||
statsYr: string,
|
||||
opt1: "1" | "2",
|
||||
): Promise<{ status: string; data: object[]; message?: string }> {
|
||||
const response = await stClient.get<{ status: string; data: object[]; message?: string }>(
|
||||
`${ENDPOINT.ST_SERVICE.PPLTN}/foreign-population-list`,
|
||||
{ params: { statsYr, opt1 } },
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/** 외국인 최종 마스터 반영 */
|
||||
public async saveForeignPopulationFinal(
|
||||
statsYr: string,
|
||||
regList: DomesticPopulationMappingItem[],
|
||||
): Promise<{ status: string; message?: string }> {
|
||||
const response = await stClient.post<{ status: string; message?: string }>(
|
||||
`${ENDPOINT.ST_SERVICE.PPLTN}/foreign-population-final`,
|
||||
{ statsYr, regList },
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
|
||||
/* ════════════════════════════════════
|
||||
행정동갱신
|
||||
════════════════════════════════════ */
|
||||
|
||||
/** 행정동 갱신 — 감축/추가 행정구역 조회
|
||||
* @param opt1 "1" = 추가된 행정구역, "2" = 감축된 행정구역
|
||||
*/
|
||||
public async searchChangedArea(
|
||||
statsYr: string,
|
||||
opt1: "1" | "2",
|
||||
): Promise<{ status: string; data: object[]; message?: string }> {
|
||||
const response = await stClient.get<{ status: string; data: object[]; message?: string }>(
|
||||
`${ENDPOINT.ST_SERVICE.PPLTN}/admdst-renewal/search`,
|
||||
{ params: { statsYr, opt1 } },
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/** 행정동 갱신 — 감축/추가 반영 */
|
||||
public async saveChangedArea(
|
||||
reducedList: object[],
|
||||
addedList: object[],
|
||||
): Promise<{ status: string; message?: string }> {
|
||||
const response = await stClient.post<{ status: string; message?: string }>(
|
||||
`${ENDPOINT.ST_SERVICE.PPLTN}/admdst-renewal/save`,
|
||||
{ reducedList, addedList },
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
// /** 행정동 갱신 — 법정동코드 후보 조회 (행정동명 클릭 시) */
|
||||
// public async getRenewalUpperCodesByName(
|
||||
// statsYr: string,
|
||||
// admdstNm: string,
|
||||
// ): Promise<UpperCodesByNameResponse> {
|
||||
// const response = await stClient.get<UpperCodesByNameResponse>(
|
||||
// `${ENDPOINT.ST_SERVICE.PPLTN}/admdst-renewal/upper-codes-by-name`,
|
||||
// {
|
||||
// params: { statsYr, admdstNm }
|
||||
// },
|
||||
// );
|
||||
// return response.data;
|
||||
// }
|
||||
|
||||
/** 행정동 갱신 — 법정동코드 후보 조회 */
|
||||
public async getLawCdsByName(
|
||||
adstCd : string,
|
||||
): Promise<UpperCodesByNameResponse> {
|
||||
const response = await stClient.get<UpperCodesByNameResponse>(
|
||||
`${ENDPOINT.ST_SERVICE.PPLTN}/admdst-renewal/law-codes-by-name`,
|
||||
{
|
||||
params: { adstCd }
|
||||
},
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
/* ════════════════════════════════════
|
||||
행정인구현황
|
||||
════════════════════════════════════ */
|
||||
|
||||
/** 행정인구현황 — 체크박스 조건에 따른 인구 현황 조회 */
|
||||
public async searchPopByEachCondition(
|
||||
statsYr: string,
|
||||
oMale: boolean,
|
||||
oFemale: boolean,
|
||||
fMale: boolean,
|
||||
fFemale: boolean,
|
||||
): Promise<{ status: string; data: object[]; message?: string }> {
|
||||
const response = await stClient.get<{ status: string; data: object[]; message?: string }>(
|
||||
`${ENDPOINT.ST_SERVICE.PPLTN}/admdst-renewal/pop-by-condition`,
|
||||
{
|
||||
params: {
|
||||
statsYr,
|
||||
oMale: oMale ? "TRUE" : "FALSE",
|
||||
oFemale: oFemale ? "TRUE" : "FALSE",
|
||||
fMale: fMale ? "TRUE" : "FALSE",
|
||||
fFemale: fFemale ? "TRUE" : "FALSE",
|
||||
}
|
||||
},
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/** 행정인구현황 시각화 — 기준연도 기준 최대 5년치 차트 데이터 조회 */
|
||||
public async getChartDatas1(
|
||||
statsYr: string,
|
||||
oMale: boolean,
|
||||
oFemale: boolean,
|
||||
fMale: boolean,
|
||||
fFemale: boolean,
|
||||
): Promise<ChartDataResponse> {
|
||||
const response = await stClient.get<ChartDataResponse>(
|
||||
`${ENDPOINT.ST_SERVICE.PPLTN}/admdst-renewal/chart-datas`,
|
||||
{
|
||||
params: {
|
||||
statsYr,
|
||||
oMale: oMale ? "TRUE" : "FALSE",
|
||||
oFemale: oFemale ? "TRUE" : "FALSE",
|
||||
fMale: fMale ? "TRUE" : "FALSE",
|
||||
fFemale: fFemale ? "TRUE" : "FALSE",
|
||||
}
|
||||
},
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
export const statisticsPpltnApi = new StatisticsPpltnApiService();
|
||||
Reference in New Issue
Block a user