feat: add finance module with yearly income/expense tracking

- FinanceEntry model (income/expense x fixed/extra)
- CRUD API endpoints for finance entries
- FinancePage with summary cards and drill-down
- Updated navigation with Finance tab
- Updated todos default filter to active
This commit is contained in:
2026-07-29 00:15:41 +08:00
parent acb1291137
commit acd70d319f
9 changed files with 505 additions and 16 deletions
+10 -2
View File
@@ -36,14 +36,16 @@ func main() {
}
// 自动建表
db.AutoMigrate(&model.Todo{}, &model.DailyLog{})
db.AutoMigrate(&model.Todo{}, &model.DailyLog{}, &model.FinanceEntry{})
// 初始化各层
todoRepo := repository.NewTodoRepository(db)
dailyLogRepo := repository.NewDailyLogRepository(db)
financeRepo := repository.NewFinanceRepository(db)
todoSvc := service.NewTodoService(todoRepo)
dailyLogSvc := service.NewDailyLogService(dailyLogRepo)
h := handler.NewHandler(todoSvc, dailyLogSvc)
financeSvc := service.NewFinanceService(financeRepo)
h := handler.NewHandler(todoSvc, dailyLogSvc, financeSvc)
// Gin 路由
r := gin.New()
@@ -70,6 +72,12 @@ func main() {
api.GET("/logs/:date", h.GetDailyLog)
api.GET("/logs", h.GetRecentLogs)
api.PUT("/logs/:date", h.SaveDailyLog)
// 经济记录
api.GET("/finance/:year", h.GetFinanceByYear)
api.POST("/finance", h.CreateFinanceEntry)
api.PUT("/finance/:id", h.UpdateFinanceEntry)
api.DELETE("/finance/:id", h.DeleteFinanceEntry)
}
port := getEnv("PORT", "17010")