first things
This commit is contained in:
57
SearchWebApi/Controllers/LookupController.cs
Normal file
57
SearchWebApi/Controllers/LookupController.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using BusinessLogic.LookupLogic.Interfaces;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FwSearchApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class LookupController : ControllerBase
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly ILogger<LookupController> _logger;
|
||||
private readonly ILookupLogic _lookupLogic;
|
||||
|
||||
public LookupController(IConfiguration configuration, ILogger<LookupController> logger, ILookupLogic lookupLogic)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_logger = logger;
|
||||
_lookupLogic = lookupLogic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("GetAllLookups")]
|
||||
public async Task<JsonResult> GetAllLookups()
|
||||
{
|
||||
var result = await _lookupLogic.GetAllLookups();
|
||||
_logger.LogInformation($"Lookups zur Verf<72>gung gestellt von {nameof(GetAllLookups)}");
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("GetCategoriesById")]
|
||||
public async Task<JsonResult> GetLookupCategoriesById(long id)
|
||||
{
|
||||
var result = await _lookupLogic.GetLookupCategoryById(id);
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("GetCategoriesByName")]
|
||||
public async Task<JsonResult> GetLookupCategoriesByName(string categoryName)
|
||||
{
|
||||
var result = await _lookupLogic.GetLookupCategoryByName(categoryName);
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("GetActiveCategories")]
|
||||
public async Task<JsonResult> GetActiveLookupCategories()
|
||||
{
|
||||
var result = await _lookupLogic.GetActiveLookupCategories();
|
||||
return new JsonResult(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
46
SearchWebApi/Controllers/SearchController.cs
Normal file
46
SearchWebApi/Controllers/SearchController.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Threading.Tasks;
|
||||
using SearchLogic;
|
||||
using Datamodels.SearchModels;
|
||||
using System.Collections.Generic;
|
||||
using Datamodels.DatabaseModels;
|
||||
|
||||
namespace FwSearchApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class SearchController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<SearchController> _logger;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly ISearchLogic _searchLogic;
|
||||
|
||||
public SearchController(ILogger<SearchController> logger, IConfiguration configuration, ISearchLogic searchLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_configuration = configuration;
|
||||
_searchLogic = searchLogic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is for Test only
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
[Route("GetAddresses")]
|
||||
public async Task<JsonResult> GetAllAddresses()
|
||||
{
|
||||
var result = await _searchLogic.GetAllAddresses();
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("GetFilteredData")]
|
||||
public async Task<JsonResult> GetFilteredData([FromBody] FilterModel filter, [FromQuery] long skip = 0, [FromQuery] long take = -1)
|
||||
{
|
||||
var result = await _searchLogic.GetFilteredData(filter, skip, take);
|
||||
return new JsonResult(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
42
SearchWebApi/Program.cs
Normal file
42
SearchWebApi/Program.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
|
||||
namespace FwSearchApi
|
||||
{
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static IConfiguration Configuration { get; } = new ConfigurationBuilder()
|
||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: true, reloadOnChange: true)
|
||||
.Build();
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(Configuration)
|
||||
.CreateLogger();
|
||||
try {
|
||||
CreateWebHostBuilder(args).Build().Run();
|
||||
}
|
||||
finally{
|
||||
Log.CloseAndFlush();
|
||||
}
|
||||
}
|
||||
|
||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
||||
WebHost.CreateDefaultBuilder(args)
|
||||
.UseConfiguration(Configuration)
|
||||
.UseStartup<Startup>()
|
||||
.UseSerilog()
|
||||
.SuppressStatusMessages(true);
|
||||
}
|
||||
}
|
||||
29
SearchWebApi/Properties/launchSettings.json
Normal file
29
SearchWebApi/Properties/launchSettings.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:20693",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchUrl": "weatherforecast",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"FeatureWerkAPIs": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "weatherforecast",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "http://localhost:5000"
|
||||
}
|
||||
}
|
||||
}
|
||||
25
SearchWebApi/SearchWebApi.csproj
Normal file
25
SearchWebApi/SearchWebApi.csproj
Normal file
@@ -0,0 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.16" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.4" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.1.4" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.1.4" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.1.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BusinessLogic\LookupLogic\LookupLogic.csproj" />
|
||||
<ProjectReference Include="..\BusinessLogic\SearchLogic\SearchLogic.csproj" />
|
||||
<ProjectReference Include="..\Datamodels\Datamodels.csproj" />
|
||||
<ProjectReference Include="..\Repositories\Repositories.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
||||
76
SearchWebApi/Startup.cs
Normal file
76
SearchWebApi/Startup.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.HttpsPolicy;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Repositories;
|
||||
using Repositories.Interfaces;
|
||||
using BusinessLogic.LookupLogic;
|
||||
using BusinessLogic.LookupLogic.Interfaces;
|
||||
using SearchLogic;
|
||||
|
||||
namespace FwSearchApi
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
|
||||
readonly ILogger<Startup> _logger;
|
||||
public IConfiguration _configuration { get; }
|
||||
|
||||
public Startup(IConfiguration configuration, ILogger<Startup> logger)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_logger = logger;
|
||||
_logger.LogInformation("Starting up FeatureWerk Search API");
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddControllers().AddNewtonsoftJson((options) =>
|
||||
{
|
||||
// keine Optionen hier
|
||||
});
|
||||
|
||||
services.AddTransient<ILookupLogic, FwLookupLogic>();
|
||||
services.AddTransient<IFwMariaLookupRepo, FwMariaLookupRepo>();
|
||||
services.AddTransient<IFwMariaSearchRepo, FwMariaSearchRepo>();
|
||||
services.AddTransient<ISearchLogic, SearchLogic.SearchLogic>();
|
||||
services.AddSwaggerGen();
|
||||
|
||||
_logger.LogInformation("Services for FeatureWerkAPIs configured");
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseSwagger();
|
||||
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "FeatureWerk Search API V1");
|
||||
});
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapControllers();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
40
SearchWebApi/appsettings.Development.json
Normal file
40
SearchWebApi/appsettings.Development.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Warning",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"mariadb": "SERVER=localhost;DATABASE=textor_test;PORT=3333;USER=root;PASSWORD=$64,rf1209",
|
||||
"postgres": "",
|
||||
"sqlserver": "",
|
||||
"oracle": ""
|
||||
},
|
||||
"GeneralSettings": {
|
||||
"DbToUse": "mariadb"
|
||||
},
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
"Default": "Information",
|
||||
"Override": {
|
||||
"System": "Information",
|
||||
"Microsoft": "Warning"
|
||||
}
|
||||
},
|
||||
"WriteTo": [
|
||||
{ "Name": "File",
|
||||
"Args": {
|
||||
"path": "/tmp/FwSearchApi.log",
|
||||
"rollingInterval": "Day"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enrich": ["FromLogContext", "WithMachineName"],
|
||||
"Properties": {
|
||||
"Appname": "FeatureWerkSearchAPI",
|
||||
"Environment": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
10
SearchWebApi/appsettings.json
Normal file
10
SearchWebApi/appsettings.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Information",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
Reference in New Issue
Block a user