Добавил основу rest api

This commit is contained in:
Максим Яковлев 2024-05-26 16:27:14 +04:00
parent 8263aea8db
commit 3faf7264f9
9 changed files with 164 additions and 1 deletions

View File

@ -15,7 +15,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceStationBusinessLogic
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceStationExecutorApp", "ServiceStationExecutorApp\ServiceStationExecutorApp.csproj", "{937B647F-2060-4352-87F0-8B230EC998F9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStationGuarantorApp", "ServiceStationGuarantorApp\ServiceStationGuarantorApp.csproj", "{444BECA0-9537-436B-9DE2-7D22125406E6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceStationGuarantorApp", "ServiceStationGuarantorApp\ServiceStationGuarantorApp.csproj", "{444BECA0-9537-436B-9DE2-7D22125406E6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStationRestApi", "ServiceStationRestApi\ServiceStationRestApi.csproj", "{393E20E0-C17B-4AE0-9A54-5DF1805C9335}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -51,6 +53,10 @@ Global
{444BECA0-9537-436B-9DE2-7D22125406E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{444BECA0-9537-436B-9DE2-7D22125406E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{444BECA0-9537-436B-9DE2-7D22125406E6}.Release|Any CPU.Build.0 = Release|Any CPU
{393E20E0-C17B-4AE0-9A54-5DF1805C9335}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{393E20E0-C17B-4AE0-9A54-5DF1805C9335}.Debug|Any CPU.Build.0 = Debug|Any CPU
{393E20E0-C17B-4AE0-9A54-5DF1805C9335}.Release|Any CPU.ActiveCfg = Release|Any CPU
{393E20E0-C17B-4AE0-9A54-5DF1805C9335}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,11 @@
using Microsoft.AspNetCore.Mvc;
namespace ServiceStationRestApi.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class MainController : Controller
{
}
}

View File

@ -0,0 +1,11 @@
using Microsoft.AspNetCore.Mvc;
namespace ServiceStationRestApi.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class ReportController : Controller
{
}
}

View File

@ -0,0 +1,51 @@
using Microsoft.OpenApi.Models;
using ServiceStationBusinessLogic.BusinessLogics;
using ServiceStationContracts.BusinessLogicsContracts;
using ServiceStationContracts.StoragesContracts;
using ServiceStationDatabaseImplement.Implements;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Logging.SetMinimumLevel(LogLevel.Trace);
builder.Logging.AddLog4Net("log4net.config");
builder.Services.AddTransient<ICarStorage, CarStorage>();
builder.Services.AddTransient<IDefectStorage, DefectStorage>();
builder.Services.AddTransient<IExecutorStorage, ExecutorStorage>();
builder.Services.AddTransient<ITechnicalWorkStorage, TechnicalWorkStorage>();
builder.Services.AddTransient<ICarLogic, CarLogic>();
builder.Services.AddTransient<IDefectLogic, DefectLogic>();
builder.Services.AddTransient<IExecutorLogic, ExecutorLogic>();
builder.Services.AddTransient<ITechnicalWorkLogic, TechnicalWorkLogic>();
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo
{
Title = "ServiceStation",
Version = "v1"
});
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "ServiceStation v1"));
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();

View File

@ -0,0 +1,31 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:10546",
"sslPort": 44332
}
},
"profiles": {
"ServiceStationRestApi": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7288;http://localhost:5076",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ServiceStationBusinessLogic\ServiceStationBusinessLogic.csproj" />
<ProjectReference Include="..\ServiceStationContracts\ServiceStationContracts.csproj" />
<ProjectReference Include="..\ServiceStationDatabaseImplement\ServiceStationDatabaseImplement.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="logs/AutomobilePlantRestApi.log" />
<appendToFile value="true" />
<maximumFileSize value="100KB" />
<maxSizeRollBackups value="2" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %5level %logger.%method [%line] - MESSAGE: %message%newline %exception" />
</layout>
</appender>
<root>
<level value="TRACE" />
<appender-ref ref="RollingFile" />
</root>
</log4net>