2022-12-14 09:53:10 +03:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2023-05-11 07:55:26 +03:00
|
|
|
|
using RhSolutions.Models;
|
2022-12-14 09:53:10 +03:00
|
|
|
|
using RhSolutions.Api.Services;
|
2023-09-19 14:56:55 +03:00
|
|
|
|
using RhSolutions.Api.Middleware;
|
2023-10-10 22:26:16 +03:00
|
|
|
|
using RhSolutions.QueryModifiers;
|
2023-12-30 14:43:25 +03:00
|
|
|
|
using RhSolutions.QueryModifiers.DrinkingWaterHeatingFittings;
|
|
|
|
|
using RhSolutions.QueryModifiers.DrinkingWaterHeatingPipes;
|
2024-01-14 23:03:52 +03:00
|
|
|
|
using Microsoft.OpenApi.Models;
|
|
|
|
|
using System.Reflection;
|
2022-12-14 09:53:10 +03:00
|
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
2023-12-30 14:43:25 +03:00
|
|
|
|
string dbHost = builder.Configuration["DB_HOST"] ?? "localhost",
|
|
|
|
|
dbPort = builder.Configuration["DB_PORT"] ?? "5000",
|
|
|
|
|
dbName = builder.Configuration["DB_DATABASE"] ?? "rhsolutions",
|
|
|
|
|
dbUser = builder.Configuration["DB_USER"] ?? "chebser",
|
|
|
|
|
dbPassword = builder.Configuration["DB_PASSWORD"] ?? "Rehau-987";
|
2022-12-14 09:53:10 +03:00
|
|
|
|
|
|
|
|
|
string connectionString = builder.Configuration["ConnectionsStrings:RhSolutionsLocal"]
|
|
|
|
|
?? $"Host={dbHost};Port={dbPort};Database={dbName};Username={dbUser};Password={dbPassword}";
|
|
|
|
|
|
|
|
|
|
builder.Services.AddDbContext<RhSolutionsContext>(opts =>
|
|
|
|
|
{
|
|
|
|
|
opts.UseNpgsql(connectionString);
|
|
|
|
|
if (builder.Environment.IsDevelopment())
|
|
|
|
|
{
|
|
|
|
|
opts.EnableSensitiveDataLogging(true);
|
|
|
|
|
}
|
|
|
|
|
});
|
2023-09-19 14:56:55 +03:00
|
|
|
|
builder.Services.AddScoped<IPricelistParser, ClosedXMLParser>()
|
2023-12-30 14:43:25 +03:00
|
|
|
|
.AddScoped<IProductTypePredicter, ProductTypePredicter>();
|
2022-12-14 09:53:10 +03:00
|
|
|
|
builder.Services.AddControllers();
|
|
|
|
|
|
2024-01-12 15:22:14 +03:00
|
|
|
|
builder.Services.AddKeyedTransient<IProductQueryModifier, Sleeve>("Монтажная гильза")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, SupportingClip>("Желоб")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, TPiece>("Тройник RAUTITAN")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, ThreadTPieceExternal>("Тройник RAUTITAN резьбовой наружный")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, ThreadTPieceInternal>("Тройник RAUTITAN резьбовой внутренний")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, AdapterExternal>("Переходник на наружную резьбу")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, AdapterInternal>("Переходник на внутреннюю резьбу")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, AdapterScrewcap>("Переходник с накидной гайкой")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, ThreadElbowExternal>("Угольник с наружной резьбой")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, ThreadElbowInternal>("Угольник с внутренней резьбой")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, ThreadElbowWallExternal>("Угольник настенный наружный")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, ThreadElbowWallInternal>("Угольник настенный внутренний")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, ThreadElbowDoubleWallInternal>("Проточный настенный угольник")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, ScrewcapElbow>("Угольник с накидной гайкой")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, Coupling>("Муфта соединительная")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, Elbow>("Угольник RAUTITAN")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, BendFormerHeating>("Фиксатор поворота отопление")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, BendFormerSanitary>("Фиксатор поворота водоснабжение")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, ConnectionBend>("Трубка Г-образная")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, ConnectionTee>("Трубка Т-образная")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, EuroconeFlex>("Резьбозажимное flex")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, EuroconeStabil>("Резьбозажимное stabil")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, EuroconeAdapter>("Переходник на евроконус")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, EuroconeConnectionBend>("Резьбозажимное для трубки")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, Nippel>("Ниппель")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, DummyPlug>("Заглушка труб RAUTITAN")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, FlexPipe>("Flex")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, PinkPipe>("Pink")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, StabilPipe>("Stabil")
|
|
|
|
|
.AddKeyedTransient<IProductQueryModifier, BlackPipe>("Black");
|
2023-12-30 14:43:25 +03:00
|
|
|
|
|
2024-01-14 23:03:52 +03:00
|
|
|
|
builder.Services.AddSwaggerGen(options =>
|
|
|
|
|
{
|
|
|
|
|
options.SwaggerDoc("v1", new OpenApiInfo
|
|
|
|
|
{
|
|
|
|
|
Version = "v1",
|
|
|
|
|
Title = "RhSolutions API",
|
|
|
|
|
Description = "API к базе данных артикулов РЕХАУ для поиска с помощью ML.NET и полнотестового поиска PostgreSQL",
|
|
|
|
|
Contact = new OpenApiContact
|
|
|
|
|
{
|
|
|
|
|
Name = "Serghei Cebotari",
|
|
|
|
|
Url = new Uri("https://cebotari.ru/"),
|
|
|
|
|
Email = @"serghei@cebotari.ru"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
|
|
|
|
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
|
|
|
|
|
});
|
2024-01-14 16:03:42 +03:00
|
|
|
|
|
2022-12-14 09:53:10 +03:00
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
|
|
app.MapControllers();
|
2023-09-19 14:56:55 +03:00
|
|
|
|
app.UseMiddleware<QueryModifier>();
|
2024-01-14 16:03:42 +03:00
|
|
|
|
app.UseSwagger().UseSwaggerUI(options =>
|
|
|
|
|
{
|
|
|
|
|
options.SwaggerEndpoint("/swagger/v1/swagger.json", "v1");
|
|
|
|
|
options.RoutePrefix = string.Empty;
|
|
|
|
|
});
|
2022-12-14 09:53:10 +03:00
|
|
|
|
|
|
|
|
|
var context = app.Services.CreateScope().ServiceProvider
|
|
|
|
|
.GetRequiredService<RhSolutionsContext>();
|
2024-01-14 16:03:42 +03:00
|
|
|
|
|
2022-12-14 09:53:10 +03:00
|
|
|
|
app.Run();
|