From e7fcb24b6ec351cd36ffc3d2cc1535f68d8f6690 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 6 Jul 2026 01:21:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=86=E7=B1=BB=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=A2=84=E5=8A=A0=E8=BD=BD=20PurchaseGroup?= =?UTF-8?q?=20=E5=85=B3=E8=81=94=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/api/handlers/product.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/internal/api/handlers/product.go b/backend/internal/api/handlers/product.go index ed852ce..65ea7e8 100644 --- a/backend/internal/api/handlers/product.go +++ b/backend/internal/api/handlers/product.go @@ -20,9 +20,9 @@ func NewCategoryHandler() *CategoryHandler { func (h *CategoryHandler) List(c *gin.Context) { var categories []models.Category - utils.DB.Where("parent_id IS NULL").Order("sort_order ASC, id ASC").Find(&categories) + utils.DB.Where("parent_id IS NULL").Order("sort_order ASC, id ASC").Preload("PurchaseGroup").Find(&categories) for i := range categories { - utils.DB.Where("parent_id = ?", categories[i].ID).Order("sort_order ASC, id ASC").Find(&categories[i].Children) + utils.DB.Where("parent_id = ?", categories[i].ID).Order("sort_order ASC, id ASC").Preload("PurchaseGroup").Find(&categories[i].Children) var count int64 utils.DB.Table("product_categories").Where("category_id = ?", categories[i].ID).Count(&count) categories[i].ProductCount = count