fix: 修复代理用户能看到全部店铺的问题
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m3s

在 ShopStore.List 中应用数据权限过滤,新增 ApplyShopIDFilter
函数用于对 Shop 表的 id 字段进行过滤。

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-26 16:55:47 +08:00
parent 03a0960c4d
commit 1d602ad1f9
2 changed files with 15 additions and 0 deletions

View File

@@ -89,3 +89,15 @@ func ApplyShopTagFilter(ctx context.Context, query *gorm.DB) *gorm.DB {
}
return query.Where("shop_id_tag IN ?", shopIDs)
}
// ApplyShopIDFilter 应用店铺主键数据权限过滤
// 用于 Shop 表,根据 id 字段过滤
// 平台用户/超管:不添加条件
// 代理用户WHERE id IN (subordinateShopIDs)
func ApplyShopIDFilter(ctx context.Context, query *gorm.DB) *gorm.DB {
shopIDs := GetSubordinateShopIDs(ctx)
if shopIDs == nil {
return query
}
return query.Where("id IN ?", shopIDs)
}