feat: Basis-DTOs, Service und Controller für automatische Metadatenverwaltung hinzugefügt
- Basis-DTOs für Lese-, Erstellungs- und Aktualisierungsvorgänge erstellt, um die Felder "hinzugefügt von", "hinzugefügt am", "geändert von" und "geändert am" automatisch über Middleware zu ergänzen. - Diese Basiskomponenten in die Gruppenstruktur integriert.
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
<div class="container-fluid text-center">
|
||||
<div class="row m-0 p-0">
|
||||
<div class="col-6">
|
||||
<div class="col-7">
|
||||
<mat-tab-group>
|
||||
<mat-tab label="Gruppen">
|
||||
<app-group-table #groupTable [onSelectedRows]="groupsOnSelectedRows" [cellEditing]="cellEditing"></app-group-table>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="col-5">
|
||||
<mat-tab-group>
|
||||
<mat-tab label="Benutzer">
|
||||
<app-user-table #userTable [initData]="initWithoutData"></app-user-table>
|
||||
|
||||
@@ -51,6 +51,34 @@ export const env = {
|
||||
{
|
||||
header: 'E-email',
|
||||
field: 'email'
|
||||
},
|
||||
{
|
||||
header:'Kommentar',
|
||||
field: 'comment'
|
||||
},
|
||||
{
|
||||
header: 'DatumsFormat',
|
||||
field: 'dateFormat'
|
||||
},
|
||||
{
|
||||
header: 'Kürzel',
|
||||
field: 'shortname'
|
||||
},
|
||||
{
|
||||
header: 'Hinzugefügt<br>wer',
|
||||
field: 'addedWho'
|
||||
},
|
||||
{
|
||||
header: 'Hinzugefügt<br>wann',
|
||||
field: 'addedWhen'
|
||||
},
|
||||
{
|
||||
header: 'Geändert<br>wer',
|
||||
field: 'changedWho'
|
||||
},
|
||||
{
|
||||
header: 'Geändert<br>wann',
|
||||
field: 'changedWhen'
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -65,8 +93,8 @@ export const env = {
|
||||
field: "comment"
|
||||
},
|
||||
{
|
||||
header: "Kommentar",
|
||||
field: "comment"
|
||||
header: "Active",
|
||||
field: (group: any) => group.active ? "✓" : ""
|
||||
},
|
||||
{
|
||||
header: "AD Sync",
|
||||
@@ -75,6 +103,22 @@ export const env = {
|
||||
{
|
||||
header: "Internal",
|
||||
field: (group: any) => group.internal ? "✓" : ""
|
||||
},
|
||||
{
|
||||
header: 'Hinzugefügt<br>wer',
|
||||
field: (g: any) => g.addedWho
|
||||
},
|
||||
{
|
||||
header: 'Hinzugefügt<br>wann',
|
||||
field: (g: any) => new Date(g.addedWhen).toLocaleString('de-DE', { day: '2-digit', month: '2-digit', year: '2-digit', hour: '2-digit', minute: '2-digit' }).replace(',', '')
|
||||
},
|
||||
{
|
||||
header: 'Geändert<br>wer',
|
||||
field: 'changedWho'
|
||||
},
|
||||
{
|
||||
header: 'Geändert<br>wann',
|
||||
field: (g: any) => new Date(g.changedWhen).toLocaleString('de-DE', { day: '2-digit', month: '2-digit', year: '2-digit', hour: '2-digit', minute: '2-digit' }).replace(',', '')
|
||||
}
|
||||
],
|
||||
representative: [
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
using DigitalData.Core.API;
|
||||
using DigitalData.Core.DTO;
|
||||
using DigitalData.UserManager.Application.Contracts;
|
||||
using DigitalData.UserManager.Application.DTOs.Base;
|
||||
using DigitalData.UserManager.Application.DTOs.User;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace DigitalData.UserManager.API.Controllers
|
||||
{
|
||||
[Authorize]
|
||||
public class BaseAuthController<TCRUDService, TCreateDto, TReadDto, TUpdateDto, TBaseEntity> : CRUDControllerBaseWithErrorHandling<TCRUDService, TCreateDto, TReadDto, TUpdateDto, TBaseEntity, int>
|
||||
where TCRUDService : IBaseService<TCreateDto, TReadDto, TUpdateDto, TBaseEntity>
|
||||
where TCreateDto : BaseCreateDto
|
||||
where TReadDto : class
|
||||
where TUpdateDto : BaseUpdateDto
|
||||
where TBaseEntity : BaseEntity
|
||||
{
|
||||
private readonly Lazy<int?> _lUserId;
|
||||
|
||||
public BaseAuthController(ILogger logger, TCRUDService service, IUserService userService) : base(logger, service)
|
||||
{
|
||||
_lUserId = new(() =>
|
||||
{
|
||||
var idSt = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
bool hasId = int.TryParse(idSt, out int id);
|
||||
return hasId ? id : null;
|
||||
});
|
||||
|
||||
service.UserFactoryAsync = async () =>
|
||||
{
|
||||
var id = _lUserId.Value;
|
||||
|
||||
return id is int intId
|
||||
? await userService.ReadByIdAsync(intId).ThenAsync(
|
||||
Success: res => res,
|
||||
Fail: UserReadDto? (m, n) =>
|
||||
{
|
||||
_logger.LogNotice(n);
|
||||
return null;
|
||||
})
|
||||
: null;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
using DigitalData.Core.API;
|
||||
using DigitalData.Core.DTO;
|
||||
using DigitalData.UserManager.Application.Contracts;
|
||||
using DigitalData.UserManager.Application.DTOs.Group;
|
||||
@@ -9,9 +8,9 @@ using Microsoft.AspNetCore.Mvc;
|
||||
namespace DigitalData.UserManager.API.Controllers
|
||||
{
|
||||
[Authorize]
|
||||
public class GroupController : CRUDControllerBaseWithErrorHandling<IGroupService, GroupCreateDto, GroupReadDto, GroupUpdateDto, Group, int>
|
||||
public class GroupController : BaseAuthController<IGroupService, GroupCreateDto, GroupReadDto, GroupUpdateDto, Group>
|
||||
{
|
||||
public GroupController(ILogger<GroupController> logger, IGroupService service) : base(logger, service)
|
||||
public GroupController(ILogger<GroupController> logger, IGroupService service, IUserService userService) : base(logger, service, userService)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user