Files
sb-front/src/api/accountApi.js
T
ByungCheol 68dd926cce
CI / build (push) Failing after 14m1s
feat: 영수증 OCR을 Google Vision(백엔드) 방식으로 전환
- 이미지를 백엔드(/account/ocr/receipt)로 업로드 → Vision 텍스트 → 금액·날짜·상호 파싱
- 업로드 전 이미지 축소(최대 1600px JPEG), Tesseract.js 의존성 제거
- 진행률 표시 제거(인식 중…), 정확도·속도 대폭 개선

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 17:37:35 +09:00

166 lines
4.8 KiB
JavaScript

import http from './http'
// 백엔드 /api/account 엔드포인트와 매핑 (본인 데이터만)
export const accountApi = {
list({ year, month, type, category, walletId, keyword, tagId } = {}) {
return http.get('/account/entries', { params: { year, month, type, category, walletId, keyword, tagId } })
},
summary({ year, month } = {}) {
return http.get('/account/summary', { params: { year, month } })
},
stats({ unit, year, month } = {}) {
return http.get('/account/stats', { params: { unit, year, month } })
},
categoryStats({ type, year, month } = {}) {
return http.get('/account/category-stats', { params: { type, year, month } })
},
netWorthTrend({ months } = {}) {
return http.get('/account/networth/trend', { params: { months } })
},
create(payload) {
return http.post('/account/entries', payload)
},
update(id, payload) {
return http.put(`/account/entries/${id}`, payload)
},
remove(id) {
return http.delete(`/account/entries/${id}`)
},
// 계좌/카드 (사용자별)
wallets() {
return http.get('/account/wallets')
},
netWorth() {
return http.get('/account/networth')
},
repayment(payload) {
return http.post('/account/repayment', payload)
},
// 정기/반복 거래
recurrings() {
return http.get('/account/recurrings')
},
createRecurring(payload) {
return http.post('/account/recurrings', payload)
},
updateRecurring(id, payload) {
return http.put(`/account/recurrings/${id}`, payload)
},
removeRecurring(id) {
return http.delete(`/account/recurrings/${id}`)
},
runRecurrings() {
return http.post('/account/recurrings/run')
},
// 예산 (사용자별)
budgets() {
return http.get('/account/budgets')
},
budgetStatus({ year, month }) {
return http.get('/account/budgets/status', { params: { year, month } })
},
budgetPeriod({ unit, year, month }) {
return http.get('/account/budgets/period', { params: { unit, year, month } })
},
expectedIncome({ year, month }) {
return http.get('/account/budgets/income', { params: { year, month } })
},
setExpectedIncome({ year, month, expectedIncome }) {
return http.put('/account/budgets/income', { expectedIncome }, { params: { year, month } })
},
createBudget(payload) {
return http.post('/account/budgets', payload)
},
updateBudget(id, payload) {
return http.put(`/account/budgets/${id}`, payload)
},
removeBudget(id) {
return http.delete(`/account/budgets/${id}`)
},
createWallet(payload) {
return http.post('/account/wallets', payload)
},
updateWallet(id, payload) {
return http.put(`/account/wallets/${id}`, payload)
},
removeWallet(id) {
return http.delete(`/account/wallets/${id}`)
},
reorderWallets(type, ids) {
return http.put('/account/wallets/reorder', { type, ids })
},
walletEntries(id) {
return http.get(`/account/wallets/${id}/entries`)
},
// 투자 포트폴리오 (C) — 종목/매매
investHoldings(walletId) {
return http.get('/account/invest/holdings', { params: { walletId } })
},
createHolding(payload) {
return http.post('/account/invest/holdings', payload)
},
updateHolding(id, payload) {
return http.put(`/account/invest/holdings/${id}`, payload)
},
removeHolding(id) {
return http.delete(`/account/invest/holdings/${id}`)
},
holdingTrades(holdingId) {
return http.get(`/account/invest/holdings/${holdingId}/trades`)
},
addTrade(holdingId, payload) {
return http.post(`/account/invest/holdings/${holdingId}/trades`, payload)
},
removeTrade(id) {
return http.delete(`/account/invest/trades/${id}`)
},
// 분류(카테고리) — 사용자별
categories() {
return http.get('/account/categories')
},
createCategory(payload) {
return http.post('/account/categories', payload)
},
updateCategory(id, payload) {
return http.put(`/account/categories/${id}`, payload)
},
removeCategory(id) {
return http.delete(`/account/categories/${id}`)
},
reorderCategories(type, ids) {
return http.put('/account/categories/reorder', { type, ids })
},
importCategories() {
return http.post('/account/categories/import')
},
// 사용자별 가계부 태그
tags() {
return http.get('/account/tags')
},
createTag(payload) {
return http.post('/account/tags', payload)
},
updateTag(id, payload) {
return http.put(`/account/tags/${id}`, payload)
},
removeTag(id) {
return http.delete(`/account/tags/${id}`)
},
// 영수증 OCR (백엔드가 Google Vision 호출 → 전체 텍스트 반환)
ocrReceipt(blob) {
const fd = new FormData()
fd.append('image', blob, 'receipt.jpg')
return http.post('/account/ocr/receipt', fd, {
headers: { 'Content-Type': 'multipart/form-data' },
timeout: 30000,
})
},
}