fix(listing): 保留平台超管全量商品查看

平台超管通过权限通配符获得全租户查询标记;普通租户管理员仍按所属租户及分销站隔离。
This commit is contained in:
2026-11-21 15:24:51 +08:00
parent c22d6b749c
commit b4d058ef63
5 changed files with 43 additions and 3 deletions
@@ -659,6 +659,25 @@ func TestPendingReviewIncludesDistributionSitesOwnedByTenant(t *testing.T) {
t.Fatalf("pending items(B) leaked tenant A listings: %+v", itemsB)
}
superCtx := tenancy.WithAdminAllTenantScope(ctxA)
superItems, err := repo.ListPendingReview(superCtx)
if err != nil {
t.Fatalf("ListPendingReview(platform super admin) error = %v", err)
}
if len(superItems) != 4 {
t.Fatalf("platform super admin pending items = %+v, want all 4 active pending listings", superItems)
}
if _, err := repo.FindAdmin(superCtx, siteB.ID); err != nil {
t.Fatalf("platform super admin FindAdmin cross-tenant site: %v", err)
}
superAdminResult, err := repo.ListAdmin(superCtx, AdminListQuery{Page: 1, PageSize: 20})
if err != nil {
t.Fatalf("ListAdmin(platform super admin) error = %v", err)
}
if superAdminResult.Total != 5 || len(superAdminResult.Items) != 5 {
t.Fatalf("platform super admin listings total=%d items=%d, want all 5", superAdminResult.Total, len(superAdminResult.Items))
}
adminResult, err := repo.ListAdmin(ctxA, AdminListQuery{Page: 1, PageSize: 20})
if err != nil {
t.Fatalf("ListAdmin() error = %v", err)