修改代码

增加云商品数据
This commit is contained in:
chfei committed 2026-10-14 11:53:36 +08:00
1 parent 2f406c840f
commit db4f030c17
58 files changed
+1550 -120

No files matched your search

@@ -0,0 +1,32 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace Store.Modules.CloudProduct.Services
{
/// <summary>
/// Hangfire 定时任务:把数据库中未同步(IndexStatus=0)的商品写入 OpenSearch 分词索引。
/// </summary>
public class GoodsIndexJob
{
private readonly IServiceScopeFactory _scopeFactory;
private readonly IConfiguration _configuration;
private readonly ILogger<GoodsIndexJob> _logger;
public GoodsIndexJob(IServiceScopeFactory scopeFactory, IConfiguration configuration,ILogger<GoodsIndexJob> logger)
{
_scopeFactory = scopeFactory;
_configuration = configuration;
_logger = logger;
}
public async Task ProcessPendingAsync()
{
var batchSize = _configuration.GetValue<int?>("Indexing:BatchSize") ?? 1000;
using var scope = _scopeFactory.CreateScope();
var service = scope.ServiceProvider.GetRequiredService<GoodsService>();
var count = await service.IndexPendingGoodsAsync(batchSize);
_logger.LogInformation($"[Hangfire] 商品分词定时任务完成,本次同步 {count} 条");
}
}
}