refactor(controller): ProfileController vereinfacht und Standardprofil-Antwort hinzugefügt
- Basisklasse CRUDControllerBaseWithErrorHandling entfernt - Statisches Standard-Profilobjekt für Test-/Demo-Zwecke eingeführt - Generisches CRUD-Verhalten durch einfachen GET-Endpunkt ersetzt - Fehlerbehandlung mit Logging und HTTP-500-Antwort verbessert
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
using DigitalData.Core.API;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using WorkFlow.API.Attributes;
|
using WorkFlow.API.Attributes;
|
||||||
using WorkFlow.Application.Contracts;
|
using WorkFlow.Application.Contracts;
|
||||||
using WorkFlow.Application.DTO.Profile;
|
|
||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
|
|
||||||
namespace WorkFlow.API.Controllers;
|
namespace WorkFlow.API.Controllers;
|
||||||
@@ -12,9 +10,41 @@ namespace WorkFlow.API.Controllers;
|
|||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class ProfileController : CRUDControllerBaseWithErrorHandling<IProfileService, ProfileCreateDto, ProfileDto, ProfileUpdateDto, Profile, int>
|
public class ProfileController : ControllerBase
|
||||||
{
|
{
|
||||||
public ProfileController(ILogger<ProfileController> logger, IProfileService service) : base(logger, service)
|
public static readonly Profile Default = new ()
|
||||||
{
|
{
|
||||||
|
Id = 1,
|
||||||
|
TypeId = 1,
|
||||||
|
Caption = "VA Freigabe",
|
||||||
|
Subtitle = "Freigabe in Rolle Verantwortlich",
|
||||||
|
CountObj = 2,
|
||||||
|
ForeColor = "Yellow",
|
||||||
|
BackColor = "Black"
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly ILogger<ProfileController> _logger;
|
||||||
|
|
||||||
|
private readonly IProfileService _service;
|
||||||
|
public ProfileController(ILogger<ProfileController> logger, IProfileService service)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_service = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Authorize]
|
||||||
|
public IActionResult GetAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Ok(Default);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "{Message}", ex.Message);
|
||||||
|
return StatusCode(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user