refactor: 引入管理端 DbContext 禁用租户过滤

This commit is contained in:
2026-01-29 03:52:11 +00:00
parent f7e21db88a
commit 65c4c00b87
29 changed files with 85 additions and 38 deletions

View File

@@ -13,18 +13,18 @@ public sealed class SqliteTestDatabase : IDisposable
{
_connection = new SqliteConnection("Filename=:memory:");
_connection.Open();
Options = new DbContextOptionsBuilder<TakeoutAppDbContext>()
Options = new DbContextOptionsBuilder<TakeoutAdminDbContext>()
.UseSqlite(_connection)
.EnableSensitiveDataLogging()
.Options;
}
public DbContextOptions<TakeoutAppDbContext> Options { get; }
public DbContextOptions<TakeoutAdminDbContext> Options { get; }
public TakeoutAppDbContext CreateContext(long tenantId, long userId = 0)
public TakeoutAdminDbContext CreateContext(long tenantId, long userId = 0)
{
EnsureCreated();
return new TakeoutAppDbContext(Options, new TestTenantProvider(tenantId), new TestCurrentUserAccessor(userId));
return new TakeoutAdminDbContext(Options, new TestTenantProvider(tenantId), new TestCurrentUserAccessor(userId));
}
public void EnsureCreated()
@@ -34,7 +34,7 @@ public sealed class SqliteTestDatabase : IDisposable
return;
}
using var context = new TakeoutAppDbContext(Options, new TestTenantProvider(1));
using var context = new TakeoutAdminDbContext(Options, new TestTenantProvider(1));
context.Database.EnsureCreated();
_initialized = true;
}