diff --git a/src/models/request/index.ts b/src/models/request/index.ts new file mode 100644 index 0000000..ad61ec9 --- /dev/null +++ b/src/models/request/index.ts @@ -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; +} diff --git a/src/models/response/index.ts b/src/models/response/index.ts new file mode 100644 index 0000000..9215826 --- /dev/null +++ b/src/models/response/index.ts @@ -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[]; +} diff --git a/src/utils/api/Allowance.ts b/src/utils/api/Allowance.ts new file mode 100644 index 0000000..1f96b08 --- /dev/null +++ b/src/utils/api/Allowance.ts @@ -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( + `/allowance/?type=${type}` + ); + return response.data; +}; + +export const exportExcel = async ( + type: "WAR_VETERAN" | "WAR_VETERAN_SPOUSE" | "HONORABLE_ALLOWANCE" +) => { + const response = await instance.get(`/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( + `/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 + ); +}; diff --git a/src/utils/api/Auth.ts b/src/utils/api/Auth.ts new file mode 100644 index 0000000..5cbeaca --- /dev/null +++ b/src/utils/api/Auth.ts @@ -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("/auth/admin/token", { + accountId: accountId, + password: password, + }); +};