feat(ProfileController): Hinzufügen von ProfileController mit GET-Endpunkt unter Verwendung von MediatR
- Implementiert die Aktion `GetAsync` zum Abrufen von Profildaten über MediatR - Fügt die Attribute `[Authorize]` und `[APIKeyAuth]` für den gesicherten Zugriff hinzu - Protokolliert Ausnahmen und gibt entsprechende HTTP-Statuscodes zurück
This commit is contained in:
parent
c08c5aacf3
commit
fe358623da
@ -1,8 +1,8 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WorkFlow.API.Attributes;
|
||||
using WorkFlow.Application.Contracts;
|
||||
using WorkFlow.Domain.Entities;
|
||||
using WorkFlow.Application.Profiles;
|
||||
|
||||
namespace WorkFlow.API.Controllers;
|
||||
|
||||
@ -12,56 +12,23 @@ namespace WorkFlow.API.Controllers;
|
||||
[Authorize]
|
||||
public class ProfileController : ControllerBase
|
||||
{
|
||||
public static readonly Profile Default = new()
|
||||
{
|
||||
Id = 1,
|
||||
TypeId = 1,
|
||||
Caption = "VA Freigabe",
|
||||
Subtitle = "Freigabe in Rolle Verantwortlich",
|
||||
CountObj = 2,
|
||||
ForeColor = "Yellow",
|
||||
BackColor = "Black",
|
||||
Objects = new ProfileObject[]
|
||||
{
|
||||
new()
|
||||
{
|
||||
ObjStateId = 3,
|
||||
ObjectId = 21601,
|
||||
Headline1 = "Aveco Holding",
|
||||
Headline2 = "Digital Data",
|
||||
Subline1 = null,
|
||||
Subline2 = "25 4711",
|
||||
CmdCheckIn = ""
|
||||
},
|
||||
new()
|
||||
{
|
||||
ObjStateId = 4,
|
||||
ObjectId = 21600,
|
||||
Headline1 = "Aveco",
|
||||
Headline2 = "Hammer AF",
|
||||
Subline1 = null,
|
||||
Subline2 = "456875",
|
||||
CmdCheckIn = ""
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private readonly ILogger<ProfileController> _logger;
|
||||
|
||||
private readonly IProfileService _service;
|
||||
public ProfileController(ILogger<ProfileController> logger, IProfileService service)
|
||||
private readonly IMediator _mediator;
|
||||
|
||||
public ProfileController(ILogger<ProfileController> logger, IMediator mediator)
|
||||
{
|
||||
_logger = logger;
|
||||
_service = service;
|
||||
_mediator = mediator;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize]
|
||||
public IActionResult GetAsync()
|
||||
public IActionResult GetAsync([FromQuery] ReadProfile profileQ)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Ok(Default);
|
||||
var profile = _mediator.Send(profileQ);
|
||||
return profile is null ? NotFound() : Ok(profile);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -69,5 +36,4 @@ public class ProfileController : ControllerBase
|
||||
return StatusCode(500);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -27,8 +27,12 @@ try
|
||||
var config = builder.Configuration;
|
||||
|
||||
// Add NLogger
|
||||
builder.Logging.ClearProviders();
|
||||
builder.Host.UseNLog();
|
||||
builder.Logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
|
||||
if (!builder.Environment.IsDevelopment())
|
||||
{
|
||||
builder.Logging.ClearProviders();
|
||||
builder.Host.UseNLog();
|
||||
}
|
||||
|
||||
// Add services to the container
|
||||
var cnn_str = config.GetConnectionString("Default") ?? throw new("Default connection string not found.");
|
||||
|
||||
@ -78,14 +78,7 @@
|
||||
}
|
||||
},
|
||||
"AuthClientParams": {
|
||||
"Url": "https://localhost:7192/auth-hub",
|
||||
"PublicKeys": [
|
||||
{
|
||||
"Issuer": "auth.digitaldata.works",
|
||||
"Audience": "work-flow.digitaldata.works",
|
||||
"Content": "-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3QCd7dH/xOUITFZbitMa/xnh8a0LyL6ZBvSRAwkI9ceplTRSHJXoM1oB+xtjWE1kOuHVLe941Tm03szS4+/rHIm0Ejva/KKlv7sPFAHE/pWuoPS303vOHgI4HAFcuwywA8CghUWzaaK5LU/Hl8srWwxBHv5hKIUjJFJygeAIENvFOZ1gFbB3MPEC99PiPOwAmfl4tMQUmSsFyspl/RWVi7bTv26ZE+m3KPcWppmvmYjXlSitxRaySxnfFvpca/qWfd/uUUg2KWKtpAwWVkqr0qD9v3TyKSgHoGDsrFpwSx8qufUJSinmZ1u/0iKl6TXeHubYS4C4SUSVjOWXymI2ZQIDAQAB-----END PUBLIC KEY-----"
|
||||
}
|
||||
],
|
||||
"Url": "http://172.24.12.39:9090/auth-hub",
|
||||
"RetryDelay": "00:00:05"
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user