using System.Diagnostics;
using Fake;
using Fake.EventBus.RabbitMQ;
using Fake.Modularity;
using Fake.ObjectMapping.AutoMapper;
using FreeRedis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Oms.Application.Helpers;
using Oms.Application.Integrations.SmallBagTrack;
using Oms.Application.Integrations.Itfx;
using Oms.Application.Integrations.PlatformShop;
using Oms.Application.Labeling;
using Oms.Application.Labeling.Hiprint;
using Oms.Application.Shared;
using Oms.Application.Storage;
using Oms.Application.Workers;
using Oms.Domain;
namespace Oms.Application;
///
/// OMS 应用层模块注册。
///
[DependsOn(
typeof(OmsDomainModule),
typeof(FakeObjectMappingAutoMapperModule),
typeof(FakeEventBusRabbitMqModule)
)]
public class OmsApplicationModule : FakeModule
{
///
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
context.Services.Configure(options =>
{
options.ScanProfiles();
});
var redisOptions = configuration.GetSection("Redis").Get();
if (redisOptions == null || string.IsNullOrWhiteSpace(redisOptions.Host))
{
throw new FakeException("未找到Redis相关配置,请检查配置文件中是否包含名为Redis的节点(且包含 Host)");
}
RedisHelper.Init(redisOptions, showLogInfo: Debugger.IsAttached);
// 面单 PDF:显式注册接口,避免约定注册未暴露 ILabelPdfRenderer 导致激活失败
context.Services.AddTransient();
context.Services.AddTransient();
context.Services.AddTransient();
context.Services.AddOmsFileStorage(configuration);
context.Services.AddOmsSmallBagTrack(configuration);
context.Services.AddOmsItfxIntegration(configuration);
context.Services.AddOmsPlatformShopIntegration(configuration);
context.Services.AddOmsOrderBatchMessaging(configuration);
context.Services.AddAiLlmClient();
context.Services.AddHostedService();
context.Services.AddHostedService();
}
}