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
@@ -119,7 +119,7 @@ func TestRequireAnyPermission(t *testing.T) {
c.Next()
})
r.GET("/test-any", RequireAnyPermission(rdb, "distribution:site_view", "qrcode:view"), func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"ok": true})
c.JSON(http.StatusOK, gin.H{"ok": true, "all_tenants": tenancy.HasAdminAllTenantScope(c.Request.Context())})
})
return r
}
@@ -161,4 +161,11 @@ func TestRequireAnyPermission(t *testing.T) {
if w.Code != http.StatusOK {
t.Fatalf("expected 200, got %d", w.Code)
}
var payload map[string]any
if err := json.Unmarshal(w.Body.Bytes(), &payload); err != nil {
t.Fatalf("decode wildcard response: %v", err)
}
if payload["all_tenants"] != true {
t.Fatalf("super admin all-tenant scope marker missing: %v", payload)
}
}