From f6e326794e3e9f4ded66c45b3a0dae72883b6d15 Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Sat, 18 Jul 2026 07:53:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(backend):=20=E5=87=BA=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E5=88=97=E8=A1=A8=20Preload(Items)=20=E4=BE=9B=E6=89=8B?= =?UTF-8?q?=E6=9C=BA=E7=AB=AF=E5=8D=A1=E7=89=87=E6=98=BE=E7=A4=BA=E5=93=81?= =?UTF-8?q?=E9=A1=B9=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List 之前未 preload items,手机端 MCard sub 行拿不到 items.length。 入库进价对 operator 本就可见(客户端无条件展示+待定价逻辑依赖 costPrice), 故 stock_in 不加脱敏;stock_out 侧成本敏感,List 已有 stripStockOutCost 兜底,安全。 Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01P9G7E3wmAYL9KeYCVZVsqu --- backend/internal/handler/stock_in.go | 4 +++- backend/internal/handler/stock_out.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/internal/handler/stock_in.go b/backend/internal/handler/stock_in.go index 0fe438b..4018a53 100644 --- a/backend/internal/handler/stock_in.go +++ b/backend/internal/handler/stock_in.go @@ -75,7 +75,9 @@ func (h *StockInHandler) List(c *gin.Context) { query.Count(&total) orders := make([]model.StockInOrder, 0) - query.Preload("Warehouse", "shop_id = ?", shopID). + // 列表卡片需要 items.length 显示品项数(手机端 MCard sub 行) + query.Preload("Items"). + Preload("Warehouse", "shop_id = ?", shopID). Preload("Partner", "shop_id = ?", shopID). Preload("Operator", "shop_id = ?", shopID). Preload("Reviewer", "shop_id = ?", shopID). diff --git a/backend/internal/handler/stock_out.go b/backend/internal/handler/stock_out.go index 6c9a81d..c5d72c7 100644 --- a/backend/internal/handler/stock_out.go +++ b/backend/internal/handler/stock_out.go @@ -87,7 +87,9 @@ func (h *StockOutHandler) List(c *gin.Context) { query.Count(&total) orders := make([]model.StockOutOrder, 0) - query.Preload("Warehouse", "shop_id = ?", shopID). + // 列表卡片需要 items.length 显示品项数(手机端 MCard sub 行) + query.Preload("Items"). + Preload("Warehouse", "shop_id = ?", shopID). Preload("Partner", "shop_id = ?", shopID). Preload("Operator", "shop_id = ?", shopID). Preload("Reviewer", "shop_id = ?", shopID).