- 新增 AdminRolesController 实现角色 CRUD 和权限管理 - 新增 BillingsController 实现账单查询功能 - 新增 SubscriptionsController 实现订阅管理功能 - 新增 TenantPackagesController 实现套餐管理功能 - 新增租户详情、配额使用、账单列表等查询功能 - 新增 TenantPackage、TenantSubscription 等领域实体 - 新增相关枚举:SubscriptionStatus、TenantPackageType 等 - 更新 appsettings 配置文件 - 更新权限授权策略提供者 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
75 lines
3.5 KiB
C#
75 lines
3.5 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using TakeoutSaaS.Application.App.Stores.Services;
|
|
using TakeoutSaaS.Domain.Billings.Repositories;
|
|
using TakeoutSaaS.Domain.Deliveries.Repositories;
|
|
using TakeoutSaaS.Domain.Inventory.Repositories;
|
|
using TakeoutSaaS.Domain.Merchants.Repositories;
|
|
using TakeoutSaaS.Domain.Merchants.Services;
|
|
using TakeoutSaaS.Domain.Orders.Repositories;
|
|
using TakeoutSaaS.Domain.Payments.Repositories;
|
|
using TakeoutSaaS.Domain.Products.Repositories;
|
|
using TakeoutSaaS.Domain.Stores.Repositories;
|
|
using TakeoutSaaS.Domain.Tenants.Repositories;
|
|
using TakeoutSaaS.Infrastructure.App.Options;
|
|
using TakeoutSaaS.Infrastructure.App.Persistence;
|
|
using TakeoutSaaS.Infrastructure.Logs.Persistence;
|
|
using TakeoutSaaS.Infrastructure.Logs.Repositories;
|
|
using TakeoutSaaS.Infrastructure.App.Repositories;
|
|
using TakeoutSaaS.Infrastructure.App.Services;
|
|
using TakeoutSaaS.Infrastructure.Common.Extensions;
|
|
using TakeoutSaaS.Shared.Abstractions.Constants;
|
|
|
|
namespace TakeoutSaaS.Infrastructure.App.Extensions;
|
|
|
|
/// <summary>
|
|
/// 业务主库基础设施注册扩展。
|
|
/// </summary>
|
|
public static class AppServiceCollectionExtensions
|
|
{
|
|
/// <summary>
|
|
/// 注册业务主库 DbContext 与仓储。
|
|
/// </summary>
|
|
/// <param name="services">服务集合。</param>
|
|
/// <param name="configuration">配置源。</param>
|
|
/// <returns>服务集合。</returns>
|
|
public static IServiceCollection AddAppInfrastructure(this IServiceCollection services, IConfiguration configuration)
|
|
{
|
|
services.AddDatabaseInfrastructure(configuration);
|
|
services.AddPostgresDbContext<TakeoutAdminDbContext>(DatabaseConstants.AppDataSource);
|
|
services.AddPostgresDbContext<TakeoutLogsDbContext>(DatabaseConstants.LogsDataSource);
|
|
|
|
services.AddScoped<IMerchantRepository, EfMerchantRepository>();
|
|
services.AddScoped<IMerchantCategoryRepository, EfMerchantCategoryRepository>();
|
|
services.AddScoped<IStoreRepository, EfStoreRepository>();
|
|
services.AddScoped<IProductRepository, EfProductRepository>();
|
|
services.AddScoped<IOrderRepository, EfOrderRepository>();
|
|
services.AddScoped<IPaymentRepository, EfPaymentRepository>();
|
|
services.AddScoped<IDeliveryRepository, EfDeliveryRepository>();
|
|
services.AddScoped<ITenantRepository, EfTenantRepository>();
|
|
services.AddScoped<ITenantPackageRepository, EfTenantPackageRepository>();
|
|
services.AddScoped<ISubscriptionRepository, EfSubscriptionRepository>();
|
|
services.AddScoped<IBillingRepository, EfBillingRepository>();
|
|
services.AddScoped<IInventoryRepository, EfInventoryRepository>();
|
|
services.AddScoped<IOperationLogRepository, EfOperationLogRepository>();
|
|
|
|
// 1. 商户导出服务
|
|
services.AddScoped<IMerchantExportService, MerchantExportService>();
|
|
|
|
// 2. (空行后) 门店配置服务
|
|
services.AddScoped<IGeoJsonValidationService, GeoJsonValidationService>();
|
|
services.AddScoped<IDeliveryZoneService, DeliveryZoneService>();
|
|
services.AddScoped<IStoreFeeCalculationService, StoreFeeCalculationService>();
|
|
services.AddScoped<IStoreSchedulerService, StoreSchedulerService>();
|
|
|
|
// 3. (空行后) 初始化配置与种子
|
|
services.AddOptions<AppSeedOptions>()
|
|
.Bind(configuration.GetSection(AppSeedOptions.SectionName))
|
|
.ValidateDataAnnotations();
|
|
|
|
services.AddHostedService<AppDataSeeder>();
|
|
|
|
return services;
|
|
}
|
|
}
|