feat: 新增账户服务层,实现账户的增删改查及转账功能,并初始化AI记账、交易服务和预算仓库。

This commit is contained in:
2026-01-29 23:36:57 +08:00
parent d974e81d1d
commit 28ff8b80c2
4 changed files with 90 additions and 21 deletions

View File

@@ -144,7 +144,13 @@ func (r *BudgetRepository) GetSpentAmount(budget *models.Budget, startDate, endD
// Filter by category if specified
if budget.CategoryID != nil {
query = query.Where("category_id = ?", *budget.CategoryID)
// Get sub-categories
var subCategoryIDs []uint
r.db.Model(&models.Category{}).Where("parent_id = ?", *budget.CategoryID).Pluck("id", &subCategoryIDs)
// Include the category itself and all its children
categoryIDs := append(subCategoryIDs, *budget.CategoryID)
query = query.Where("category_id IN ?", categoryIDs)
}
// Filter by account if specified