SPMS_API/SPMS.Infrastructure/DependencyInjection.cs
seonkyu.kim 0911fc763a feat: 통계 API 구현 (8.1~8.5) (#132)
- POST /v1/in/stats/daily: 기간별 일별 통계
- POST /v1/in/stats/summary: 대시보드 요약 통계
- POST /v1/in/stats/message: 메시지별 발송 통계
- POST /v1/in/stats/hourly: 시간대별 발송 추이
- POST /v1/in/stats/device: 디바이스 분포 통계
- IDailyStatRepository, DailyStatRepository 신규
- IPushSendLogRepository 통계 메서드 확장

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 23:08:04 +09:00

88 lines
3.7 KiB
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using SPMS.Application.Interfaces;
using SPMS.Application.Settings;
using SPMS.Domain.Interfaces;
using SPMS.Infrastructure.Auth;
using SPMS.Infrastructure.Caching;
using SPMS.Infrastructure.Messaging;
using SPMS.Infrastructure.Persistence;
using SPMS.Infrastructure.Push;
using SPMS.Infrastructure.Persistence.Repositories;
using SPMS.Infrastructure.Security;
using SPMS.Infrastructure.Services;
using SPMS.Infrastructure.Workers;
namespace SPMS.Infrastructure;
public static class DependencyInjection
{
public static IServiceCollection AddInfrastructure(
this IServiceCollection services,
IConfiguration configuration)
{
// DbContext
var connectionString = configuration.GetConnectionString("DefaultConnection");
services.AddDbContext<AppDbContext>(options =>
options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)));
// UnitOfWork & Repositories
services.AddScoped<IUnitOfWork, UnitOfWork>();
services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
services.AddScoped<IServiceRepository, ServiceRepository>();
services.AddScoped<IAdminRepository, AdminRepository>();
services.AddScoped<INoticeRepository, NoticeRepository>();
services.AddScoped<IBannerRepository, BannerRepository>();
services.AddScoped<IFaqRepository, FaqRepository>();
services.AddScoped<IAppConfigRepository, AppConfigRepository>();
services.AddScoped<IDeviceRepository, DeviceRepository>();
services.AddScoped<IFileRepository, FileRepository>();
services.AddScoped<IMessageRepository, MessageRepository>();
services.AddScoped<IPushSendLogRepository, PushSendLogRepository>();
services.AddScoped<IDailyStatRepository, DailyStatRepository>();
// External Services
services.AddScoped<IJwtService, JwtService>();
services.AddSingleton<IE2EEService, E2EEService>();
services.AddSingleton<ICredentialEncryptionService, CredentialEncryptionService>();
// File Storage
services.AddSingleton<IFileStorageService, LocalFileStorageService>();
// Redis
services.Configure<RedisSettings>(configuration.GetSection(RedisSettings.SectionName));
services.AddSingleton<RedisConnection>();
services.AddSingleton<IDuplicateChecker, DuplicateChecker>();
services.AddSingleton<IScheduleCancelStore, ScheduleCancelStore>();
services.AddSingleton<IBulkJobStore, BulkJobStore>();
// RabbitMQ
services.Configure<RabbitMQSettings>(configuration.GetSection(RabbitMQSettings.SectionName));
services.AddSingleton<RabbitMQConnection>();
services.AddSingleton<RabbitMQInitializer>();
services.AddHostedService(sp => sp.GetRequiredService<RabbitMQInitializer>());
services.AddScoped<IPushQueueService, PushQueueService>();
// Push Senders
services.AddSingleton<IFcmSender, FcmSender>();
services.AddHttpClient("ApnsSender")
.ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler
{
EnableMultipleHttp2Connections = true
});
services.AddSingleton<IApnsSender, ApnsSender>();
// Workers
services.AddHostedService<PushWorker>();
services.AddHostedService<ScheduleWorker>();
// Token Store & Email Service
services.AddMemoryCache();
services.AddSingleton<ITokenStore, InMemoryTokenStore>();
services.AddSingleton<IEmailService, ConsoleEmailService>();
return services;
}
}