- 修复 parse_amount 函数同时支持全角¥和半角¥ - 新增 MonthRangePicker 日期选择组件 - 新增 /api/monthly-stats 接口获取月度统计 - 分析页面月度趋势使用全量数据 - 新增健康检查路由
49 lines
1.7 KiB
Go
49 lines
1.7 KiB
Go
// Package repository 定义数据存储层接口
|
|
// 负责所有数据持久化操作的抽象
|
|
package repository
|
|
|
|
import "billai-server/model"
|
|
|
|
// BillRepository 账单存储接口
|
|
type BillRepository interface {
|
|
// Connect 建立连接
|
|
Connect() error
|
|
|
|
// Disconnect 断开连接
|
|
Disconnect() error
|
|
|
|
// SaveRawBills 保存原始账单数据
|
|
SaveRawBills(bills []model.RawBill) (int, error)
|
|
|
|
// SaveCleanedBills 保存清洗后的账单数据
|
|
// 返回: 保存数量、重复数量、错误
|
|
SaveCleanedBills(bills []model.CleanedBill) (saved int, duplicates int, err error)
|
|
|
|
// CheckRawDuplicate 检查原始数据是否重复
|
|
CheckRawDuplicate(fieldName, value string) (bool, error)
|
|
|
|
// CheckCleanedDuplicate 检查清洗后数据是否重复
|
|
CheckCleanedDuplicate(bill *model.CleanedBill) (bool, error)
|
|
|
|
// GetCleanedBills 获取清洗后的账单列表
|
|
GetCleanedBills(filter map[string]interface{}) ([]model.CleanedBill, error)
|
|
|
|
// GetCleanedBillsPaged 获取清洗后的账单列表(带分页)
|
|
// 返回: 账单列表、总数、错误
|
|
GetCleanedBillsPaged(filter map[string]interface{}, page, pageSize int) ([]model.CleanedBill, int64, error)
|
|
|
|
// GetBillsAggregate 获取账单聚合统计(总收入、总支出)
|
|
// 返回: 总支出、总收入、错误
|
|
GetBillsAggregate(filter map[string]interface{}) (totalExpense float64, totalIncome float64, err error)
|
|
|
|
// GetMonthlyStats 获取月度统计(全部数据,不受筛选条件影响)
|
|
// 返回: 月度统计列表、错误
|
|
GetMonthlyStats() ([]model.MonthlyStat, error)
|
|
|
|
// GetBillsNeedReview 获取需要复核的账单
|
|
GetBillsNeedReview() ([]model.CleanedBill, error)
|
|
|
|
// CountRawByField 按字段统计原始数据数量
|
|
CountRawByField(fieldName, value string) (int64, error)
|
|
}
|