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.Migration;

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

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

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