fix(tenant): 收紧双站后台边界并补齐货架管理
This commit is contained in:
@@ -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,返回空串表示主站。经营租户请求始终返回空串,
|
||||
|
||||
Reference in New Issue
Block a user