fix: 修复店铺资金摘要接口username和phone字段为空的bug
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m17s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m17s
问题原因:GetPrimaryAccountsByShopIDs 在 Store 层重复应用了数据权限过滤, 导致当前用户无权限访问的店铺账号被错误过滤,accountMap 为 nil, 最终返回的 username 和 phone 为空字符串。 解决方案:移除 Store 层的 ApplyShopFilter 权限过滤, 因为调用方(Service 层)已经保证了 shopIDs 的合法性。
This commit is contained in:
@@ -261,8 +261,9 @@ func (s *AccountStore) GetPrimaryAccountsByShopIDs(ctx context.Context, shopIDs
|
|||||||
var accounts []*model.Account
|
var accounts []*model.Account
|
||||||
query := s.db.WithContext(ctx).
|
query := s.db.WithContext(ctx).
|
||||||
Where("shop_id IN ? AND is_primary = ?", shopIDs, true)
|
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 {
|
if err := query.Find(&accounts).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user