fix(tenant): 收紧双站后台边界并补齐货架管理

This commit is contained in:
yml
2026-11-15 22:28:40 +08:00
parent a68eb815a9
commit 0cb385d84f
42 changed files with 831 additions and 97 deletions
+11
View File
@@ -26,6 +26,7 @@ const HeaderName = "X-Distribution-Site-Code"
const LegacyHeaderName = "X-Site-Code"
type tenantScopeContextKey struct{}
type domainScopeContextKey struct{}
// WithTenantScope 标记当前请求已识别为经营租户。
// 经营租户与历史分销站点使用不同归属模型,识别成功后必须忽略旧分销站点编码。
@@ -39,6 +40,16 @@ func HasTenantScope(ctx context.Context) bool {
return enabled
}
// WithDomainScope 标记当前 Host 已通过历史分销站点域名解析。
func WithDomainScope(ctx context.Context) context.Context {
return context.WithValue(ctx, domainScopeContextKey{}, true)
}
func HasDomainScope(ctx context.Context) bool {
enabled, _ := ctx.Value(domainScopeContextKey{}).(bool)
return enabled
}
// FromRequest 按权威优先级解析站点编码:
// X-Distribution-Site-Code 头 → X-Site-Code 旧头 → distribution_site_code / site_code query。
// 所有来源均做 TrimSpace,返回空串表示主站。经营租户请求始终返回空串,