mh_frame_sps/APT.Infrastructure.EF/Impl/SimpleHeaderTenantInfoGenerator.cs

31 lines
933 B
C#
Raw Permalink Normal View History

2026-04-07 13:47:52 +08:00
using Microsoft.AspNetCore.Http;
using APT.Infrastructure.Api;
namespace APT.Infrastructure.EF
{
public class SimpleHeaderTenantInfoGenerator : ITenantInfoGenerator
{
private readonly TenantInfo tenantInfo;
public SimpleHeaderTenantInfoGenerator(TenantInfo tenantInfo)
{
this.tenantInfo = tenantInfo;
}
public TenantInfo GenerateTenant(object sender, Microsoft.AspNetCore.Http.HttpContext httpContext)
{
if (!this.tenantInfo.IsPresent)
{
var tenantName = httpContext?.Request?.Headers["TenantName"];
if (!string.IsNullOrEmpty(tenantName))
{
this.tenantInfo.IsPresent = true;
this.tenantInfo.Name = tenantName;
this.tenantInfo.Generator = this;
}
}
return this.tenantInfo;
}
}
}