This commit is contained in:
2026-03-30 11:07:30 +08:00
parent 2c44b3a4b2
commit d4a8e71733
74 changed files with 1751 additions and 421 deletions

View File

@@ -0,0 +1,27 @@
using StopShopping.Services;
namespace StopShopping.AdminApi.Workers;
public class DbSeederBackgroundService : BackgroundService
{
public DbSeederBackgroundService(IServiceProvider sp)
{
_sp = sp;
}
private readonly IServiceProvider _sp;
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
using var scope = _sp.CreateScope();
using var scope1 = _sp.CreateScope();
var districtService = scope.ServiceProvider.GetRequiredService<IDistrictService>();
var userService = scope1.ServiceProvider.GetRequiredService<IUserService>();
var districtTask = districtService.InitialDatabaseAsync(stoppingToken);
var adminTask = userService.GenerateDefaultAdminAsync();
await Task.WhenAll(districtTask, adminTask);
}
}