Files
ga-commission-system/ga-frontend/src/api/deduction.ts
T
ysukkyu 88e14edffd 1
2026-05-14 18:14:49 +09:00

54 lines
2.1 KiB
TypeScript

import api, { PageResponse, unwrap } from './request';
// ── Response VO ────────────────────────────────────────────────────────────
export interface DeductionResp {
deductionId: number;
agentId: number;
agentName: string;
settleMonth: string; // YYYYMM
deductionType: string;
deductionTypeName: string;
amount: number; // BigDecimal → number
description?: string;
status: string;
statusName: string;
createdAt: string;
}
// ── Request VO ─────────────────────────────────────────────────────────────
export interface DeductionSaveReq {
agentId: number;
settleMonth: string; // YYYYMM 6자리
deductionType: string;
amount: number; // 양수
description?: string;
}
// ── Search Params ──────────────────────────────────────────────────────────
export interface DeductionSearchParam {
agentId?: number;
settleMonth?: string;
deductionType?: string;
status?: string;
pageNum?: number;
pageSize?: number;
}
// ── API ────────────────────────────────────────────────────────────────────
export const deductionApi = {
list: (p: DeductionSearchParam) =>
unwrap<PageResponse<DeductionResp>>(api.get('/api/deductions', { params: p })),
get: (deductionId: number) =>
unwrap<DeductionResp>(api.get(`/api/deductions/${deductionId}`)),
create: (req: DeductionSaveReq) =>
unwrap<number>(api.post('/api/deductions', req)),
update: (deductionId: number, req: DeductionSaveReq) =>
unwrap<void>(api.put(`/api/deductions/${deductionId}`, req)),
cancel: (deductionId: number) =>
unwrap<void>(api.put(`/api/deductions/${deductionId}/cancel`)),
};