Skip to content

Commit

Permalink
merge :: API 함수 세팅
Browse files Browse the repository at this point in the history
  • Loading branch information
inung1004 authored Dec 15, 2023
2 parents c6c56c3 + 642e53e commit 7d62661
Show file tree
Hide file tree
Showing 4 changed files with 235 additions and 0 deletions.
89 changes: 89 additions & 0 deletions src/models/request/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
export interface userLoginRequestDto {
accountId: string;
password: string;
}

export interface saveExcelRequestDto {
type: "WAR_VETERAN" | "WAR_VETERAN_SPOUSE" | "HONORABLE_ALLOWANCE";
file: File;
}

export interface editExcelTargetRequestDto {
excelLine: {
serial_number: number;
hang_jung_dong: string;
veterans_number: string;
resident_registration_number: string;
name: string;
address: string;
deposit_type: string;
bank_name: string;
account_holder: string;
bank_account_number: string;
sibi: string;
gubi: string;
allowance_type: string;
note: string;
};
id: number;
}

export interface editExcelCashRequestDto {
excelLine: {
serial_number: number;
hang_jung_dong: string;
veterans_number: string;
resident_registration_number: string;
name: string;
address: string;
deposit_type: string;
sibi: number;
gubi: number;
allowance_type: string;
note: string;
};
id: number;
}

export interface editExcelNewcomerRequestDto {
excelLine: {
serial_number: number;
hang_jung_dong: string;
veterans_number: string;
resident_registration_number: string;
name: string;
address: string;
deposit_type: string;
bank_name: string;
account_holder: string;
bank_account_number: string;
allowance_type: string;
note: string;
transfer_reason: string;
transfer_date: string;
};
id: number;
}

export interface editExcelStoppedRequestDto {
excelLine: {
serial_number: number;
hang_jung_dong: string;
veterans_number: string;
resident_registration_number: string;
name: string;
address: string;
deposit_type: string;
bank_name: string;
account_holder: string;
bank_account_number: string;
sibi: string;
gubi: string;
allowance_type: string;
note: string;
stopped_reason: string;
stopped_date: string;
transfer_address: string;
};
id: number;
}
44 changes: 44 additions & 0 deletions src/models/response/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
export interface userLoginResponseDto {
access_token: "";
access_token_exp: "";
}

export interface getExcelType {
serialNumber: string;
hangJungDong: string;
veteransNumber: string;
residentRegistrationNumber: string;
name: string;
address: string;
depositType: string;
bankName: string;
accountHolder: string;
bankAccountNumber: string;
sibi: number;
gubi: number;
note: string;
}

export interface getExcelResponseDto {
paymentTargetTab: getExcelType[];
}

export interface parsingExcel {
serialNumber: number;
hangJungDong: string;
veteransNumber: string;
residentRegistrationNumber: string;
name: string;
address: string;
depositType: string;
bankName: string;
accountHolder: string;
bankAccountNumber: string;
sibi: number;
gubi: number;
note: string;
}

export interface parsingExcelResponseDto {
paymentTargetTab: parsingExcel[];
}
90 changes: 90 additions & 0 deletions src/utils/api/Allowance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import {
editExcelCashRequestDto,
editExcelNewcomerRequestDto,
editExcelStoppedRequestDto,
editExcelTargetRequestDto,
saveExcelRequestDto,
} from "../../models/request";
import {
getExcelResponseDto,
parsingExcelResponseDto,
} from "../../models/response";
import instance from "../axios";

export const saveExcel = async (request: saveExcelRequestDto) => {
const { type, file } = request;
const formData: FormData = new FormData();
formData.append("file", file);

return await instance.put(`/allowance/?type=${type}`, formData, {
headers: {
"Content-Type": "multipart/form-data",
},
});
};

export const getExcel = async (
type: "WAR_VETERAN" | "WAR_VETERAN_SPOUSE" | "HONORABLE_ALLOWANCE" //참전유공자 명예수당, 참전유공자 배우자수당, 보훈 예우수당
) => {
const response = await instance.get<getExcelResponseDto>(
`/allowance/?type=${type}`
);
return response.data;
};

export const exportExcel = async (
type: "WAR_VETERAN" | "WAR_VETERAN_SPOUSE" | "HONORABLE_ALLOWANCE"
) => {
const response = await instance.get<File>(`/allowance/export/?type=${type}`);
return response.data;
};

export const parsingExcel = async (file: File) => {
const formData: FormData = new FormData();
formData.append("file", file);

const response = await instance.post<parsingExcelResponseDto>(
`/excel/parse`,
formData,
{
headers: {
"Content-Type": "multipart/form-data",
},
}
);
return response.data;
};

//보훈수당 엑셀 파일 수정-대상자 현황
export const editExcelTarget = async (request: editExcelTargetRequestDto) => {
return await instance.patch(
`/allowance/target/${request.id}`,
request.excelLine
);
};

//보훈수당 엑셀 파일 수정-현금 지급
export const editExcelCash = async (request: editExcelCashRequestDto) => {
return await instance.patch(
`/allowance/cash/${request.id}`,
request.excelLine
);
};

//보훈수당 엑셀 파일 수정-신규자
export const editExcelNewcomer = async (
request: editExcelNewcomerRequestDto
) => {
return await instance.patch(
`/allowance/cash/${request.id}`,
request.excelLine
);
};

//보훈수당 엑셀 파일 수정-지급중지자
export const editExcelStopped = async (request: editExcelStoppedRequestDto) => {
return await instance.patch(
`/allowance/cash/${request.id}`,
request.excelLine
);
};
12 changes: 12 additions & 0 deletions src/utils/api/Auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { userLoginRequestDto } from "../../models/request";
import { userLoginResponseDto } from "../../models/response";
import instance from "../axios";

export const userLogin = async (request: userLoginRequestDto) => {
const { accountId, password } = request;

return await instance.post<userLoginResponseDto>("/auth/admin/token", {
accountId: accountId,
password: password,
});
};

0 comments on commit 7d62661

Please sign in to comment.