feat: 添加预算管理功能,包括其handler、service和repository层。
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user