using Localization.Resources.AbpUi;
using JiShe.CollectBus.Localization;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Microsoft.Extensions.DependencyInjection;

namespace JiShe.CollectBus;

[DependsOn(
    typeof(CollectBusApplicationModule),
    typeof(CollectBusApplicationContractsModule),
    typeof(AbpAspNetCoreMvcModule)
    )]
public class CollectBusHttpApiModule : AbpModule
{
    public override void PreConfigureServices(ServiceConfigurationContext context)
    {
        PreConfigure<IMvcBuilder>(mvcBuilder =>
        {
            mvcBuilder.AddApplicationPartIfNotExists(typeof(CollectBusHttpApiModule).Assembly);
        });

        Configure<AbpAspNetCoreMvcOptions>(options =>
        {
            options.ConventionalControllers
                .Create(typeof(CollectBusApplicationModule).Assembly);
        });
    }

    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        Configure<AbpLocalizationOptions>(options =>
        {
            options.Resources
                .Get<CollectBusResource>()
                .AddBaseTypes(typeof(AbpUiResource));
        });
    }
}
