From 67f3286e091acfc07097e04971d8445fae82cba8 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 10 Apr 2026 17:21:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E8=B5=84=E9=87=91=E6=91=98=E8=A6=81=E6=8E=A5=E5=8F=A3username?= =?UTF-8?q?=E5=92=8Cphone=E5=AD=97=E6=AE=B5=E4=B8=BA=E7=A9=BA=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题原因:GetPrimaryAccountsByShopIDs 在 Store 层重复应用了数据权限过滤, 导致当前用户无权限访问的店铺账号被错误过滤,accountMap 为 nil, 最终返回的 username 和 phone 为空字符串。 解决方案:移除 Store 层的 ApplyShopFilter 权限过滤, 因为调用方(Service 层)已经保证了 shopIDs 的合法性。 --- internal/store/postgres/account_store.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/store/postgres/account_store.go b/internal/store/postgres/account_store.go index cc75ac7..94764c0 100644 --- a/internal/store/postgres/account_store.go +++ b/internal/store/postgres/account_store.go @@ -261,8 +261,9 @@ func (s *AccountStore) GetPrimaryAccountsByShopIDs(ctx context.Context, shopIDs var accounts []*model.Account query := s.db.WithContext(ctx). Where("shop_id IN ? AND is_primary = ?", shopIDs, true) - // 应用数据权限过滤 - query = middleware.ApplyShopFilter(ctx, query) + // 注意:此处不再应用数据权限过滤 + // 因为调用方(Service 层)已经保证了 shopIDs 的合法性 + // 在 ListShopFundSummary 场景中,店铺列表已由 Service 层过滤 if err := query.Find(&accounts).Error; err != nil { return nil, err }