54 lines
2.1 KiB
TypeScript
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`)),
|
|
};
|