feat: 添加预算管理功能,包括其handler、service和repository层。

This commit is contained in:
2026-02-02 13:55:41 +08:00
parent d08f7902c9
commit 4b2355deee
3 changed files with 75 additions and 3 deletions

View File

@@ -98,6 +98,7 @@ func (h *BudgetHandler) GetBudget(c *gin.Context) {
}
// GetAllBudgets handles GET /api/v1/budgets
// Returns budgets with calculated spent and progress fields
func (h *BudgetHandler) GetAllBudgets(c *gin.Context) {
// Get user ID from context
userID, exists := c.Get("user_id")
@@ -106,7 +107,8 @@ func (h *BudgetHandler) GetAllBudgets(c *gin.Context) {
return
}
budgets, err := h.service.GetAllBudgets(userID.(uint))
// Use GetAllBudgetsWithProgress to return budgets with spent and progress calculated
budgets, err := h.service.GetAllBudgetsWithProgress(userID.(uint))
if err != nil {
api.InternalError(c, "Failed to get budgets")
return