Compare commits

...

13 Commits

Author SHA1 Message Date
Developer 02
d6b08c3c30 refactor: CRUD-Services und -Interfaces für alle außer Module und ModuleOfUser von IService und Service vererbt
- Vererbung von IService und Service auf alle CRUD-Services und -Interfaces angewendet, mit Ausnahme von Module und ModuleOfUser.
2024-08-14 19:08:43 +02:00
Developer 02
a5002a3038 refactor: Basis-DTO für alle Erstellungs-, Lese- und Aktualisierungs-DTOs außer Module und ModuleOfUser vererbt
- Vererbung von BaseDTO auf alle Erstellungs-, Lese- und Aktualisierungs-DTOs angewendet, mit Ausnahme von Module und ModuleOfUser.
2024-08-14 19:05:15 +02:00
Developer 02
a2077c58ca refactor: BaseEntity-Vererbung für alle Entitäten außer Module und ModuleOfUser
- BaseEntity-Vererbung auf alle Entitäten angewendet, außer für Module und ModuleOfUser.
2024-08-14 18:56:56 +02:00
Developer 02
36d763d5e5 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.
2024-08-14 18:49:59 +02:00
Developer 02
4746d63aea feat: Benutzerspaltennamen in detaillierte und grundlegende Kategorien unterteilt
- Benutzerspaltennamen wurden in "detailliert" und "grundlegend" unterteilt.
- Standardmäßig wird "grundlegend" verwendet, aber auf der "Benutzer"-Seite wird die "detaillierte" Ansicht über das [column]-Attribut hinzugefügt.
2024-08-14 13:57:52 +02:00
Developer 02
491c7b6514 feat: Gruppierungskommentare bearbeitbar gemacht 2024-08-14 13:34:27 +02:00
Developer 02
2c9a81c90a fix: Entfernen der überflüssigen '1' nach dem </mat-tab-group>-Tag 2024-08-14 11:26:44 +02:00
Developer 02
153f818d12 refactor: Schaltflächen in der Nav-Bar neu anordnen
- 'Zu Fotos hinzufügen'-Schaltfläche nach oben verschoben und Reihenfolge der anderen Schaltflächen angepasst.
- Sichtbarkeitslogik und Tooltips der Schaltflächen bei Bedarf aktualisiert.
2024-08-14 11:18:56 +02:00
Developer 02
c8ca3abebe fix: behebe ExpressionChangedAfterItHasBeenCheckedError bei Nav-Bar-Buttons
- Ersetze dynamisches `[matTooltipClass]="tooltipClass"` durch statisches `matTooltipClass="pt-3"`, um den Fehler `ExpressionChangedAfterItHasBeenCheckedError` zu beheben.
2024-08-14 11:15:53 +02:00
Developer 02
3f7a60f04d fix: rename AD Sync label to "AD Sync" 2024-08-14 11:06:21 +02:00
Developer 02
2423263413 fix: AD Sync- und Internal-Checkboxen bei der Gruppenerstellung deaktivieren 2024-08-14 10:22:41 +02:00
Developer 02
3c7f81987c fix: prevent editing of system groups 2024-08-14 09:27:18 +02:00
Developer 02
f031b131eb feat: Button basierend auf ButtonVisibilityService bedingt anzeigen
- `anyVisible` Methode in `ButtonVisibilityService` hinzugefügt, um zu prüfen, ob irgendein Button sichtbar ist.
- Nav-Menü-Komponente aktualisiert, um die Sichtbarkeit des Buttons mit `ButtonVisibilityService` bedingt festzulegen.
2024-08-14 09:02:44 +02:00
43 changed files with 369 additions and 195 deletions

View File

@@ -31,13 +31,13 @@
</div>
<div class="row">
<div [ngClass]="checkBoxBSClass(3)">
<mat-checkbox [formControl]="adSync">Ad Sync</mat-checkbox>
<mat-checkbox [disabled]="true">AD Sync</mat-checkbox>
</div>
<div [ngClass]="checkBoxBSClass(3)">
<mat-checkbox [formControl]="internal">Internal</mat-checkbox>
<mat-checkbox [(ngModel)]="checked" [disabled]="true">Internal</mat-checkbox>
</div>
<div [ngClass]="checkBoxBSClass(2)">
<mat-checkbox [formControl]="active">Active</mat-checkbox>
<mat-checkbox [formControl]="active" [disabled]="true">Active</mat-checkbox>
</div>
<div class="col d-flex justify-content-center me-4 my-2">
<button mat-fab extended (click)="delete()">

View File

@@ -1,4 +1,4 @@
import { Component, signal } from '@angular/core';
import { Component, model, signal } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormControl, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
import { MatFormFieldModule } from '@angular/material/form-field';
@@ -26,8 +26,6 @@ import Swal from 'sweetalert2';
export class GroupFormComponent {
readonly groupname = new FormControl('', [Validators.required]);
readonly ecmFkId = new FormControl<number>(1, [Validators.required]);
readonly adSync = new FormControl<boolean>(false);
readonly internal = new FormControl<boolean>(true);
readonly active = new FormControl<boolean>(true);
errorMessage = signal('');
@@ -36,6 +34,8 @@ export class GroupFormComponent {
public readonly buttonBSClass: string = "d-flex justify-content-center mx-1 my-2"
public readonly checkBoxBSClass: (colCount: number | undefined) => string = (colCount: number = 2) => `col-${colCount} d-flex justify-content-left mx-1 my-2`
readonly checked = model(true);
constructor(private uService: UserService, private rService: RefreshService, private gService: GroupService) {
merge(
this.groupname.statusChanges, this.groupname.valueChanges,
@@ -44,7 +44,6 @@ export class GroupFormComponent {
.subscribe(() => this.updateErrorMessage());
}
updateErrorMessage() {
if (this.groupname.hasError('required')) {
this.errorMessage.set('Wert eingeben');
@@ -58,8 +57,8 @@ export class GroupFormComponent {
this.gService.create({
name: this.groupname.value!,
ecmFkId: (this.ecmFkId.value!),
adSync: this.adSync.value!,
internal: this.internal.value!,
adSync: false,
internal: true,
active: this.active.value!
}).subscribe({
next: () => {
@@ -78,8 +77,6 @@ export class GroupFormComponent {
delete() {
this.groupname.setValue('')
this.ecmFkId.setValue(1)
this.adSync.setValue(false)
this.internal.setValue(true)
this.active.setValue(true)
}
}
}

View File

@@ -30,22 +30,22 @@
<!-- Right menu -->
<div class="navbar-collapse justify-content-end me-5">
<a class="navbar-brand" [routerLink]="['/']">User Manager Portal</a>
<button *ngIf="isLogedIn()" class="btn" (click)="this.updateService.toggleEditability()" [ngStyle]="{ 'visibility': updateService.isVisible ? 'visible' : 'hidden' }" matTooltip="strg + L" matTooltipPosition="below" [matTooltipClass]="tooltipClass" [matTooltipDisabled]="!updateService.isVisible">
<mat-icon class="scale-pulse">{{ updateService.isEditable ? 'lock_open' : 'lock' }}</mat-icon>
</button>
<button *ngIf="isLogedIn()" class="btn" (click)="updateService.executeAll()" [ngStyle]="{ 'visibility': updateService.isVisible ? 'visible' : 'hidden' }" matTooltip="strg + S" matTooltipPosition="below" [matTooltipClass]="tooltipClass" [matTooltipDisabled]="!updateService.isVisible">
<mat-icon class="scale-pulse" [matBadge]="updateActCount === 0 ? '' : updateActCount">save</mat-icon>
</button>
<button *ngIf="isLogedIn()" class="btn" (click)="creationService.openDialog()" [ngStyle]="{ 'visibility': creationService.isVisible ? 'visible' : 'hidden' }" matTooltip="strg + C" matTooltipPosition="below" [matTooltipClass]="tooltipClass" [matTooltipDisabled]="!creationService.isVisible">
<button *ngIf="isLogedIn()" class="btn" (click)="creationService.openDialog()" [ngStyle]="{ 'visibility': creationService.isVisible ? 'visible' : 'hidden' }" matTooltip="strg + C" matTooltipPosition="below" matTooltipClass="pt-3" [matTooltipDisabled]="!creationService.isVisible">
<mat-icon class="scale-pulse">add_to_photos</mat-icon>
</button>
<button *ngIf="isLogedIn()" class="btn" (click)="transferService.executeAll()" [ngStyle]="{ 'visibility': transferService.isVisible ? 'visible' : 'hidden' }" matTooltip="strg + " matTooltipPosition="below" [matTooltipClass]="tooltipClass" [matTooltipDisabled]="!transferService.isVisible">
<button *ngIf="isLogedIn()" class="btn" (click)="this.updateService.toggleEditability()" [ngStyle]="{ 'visibility': updateService.isVisible ? 'visible' : 'hidden' }" matTooltip="strg + L" matTooltipPosition="below" [matTooltipDisabled]="!updateService.isVisible">
<mat-icon class="scale-pulse">{{ updateService.isEditable ? 'lock_open' : 'lock' }}</mat-icon>
</button>
<button *ngIf="isLogedIn()" class="btn" (click)="updateService.executeAll()" [ngStyle]="{ 'visibility': updateService.isVisible ? 'visible' : 'hidden' }" matTooltip="strg + S" matTooltipPosition="below" matTooltipClass="pt-3" [matTooltipDisabled]="!updateService.isVisible">
<mat-icon class="scale-pulse" [matBadge]="updateActCount === 0 ? '' : updateActCount">save</mat-icon>
</button>
<button *ngIf="isLogedIn()" class="btn" (click)="transferService.executeAll()" [ngStyle]="{ 'visibility': transferService.isVisible ? 'visible' : 'hidden' }" matTooltip="strg + ␣" matTooltipPosition="below" [matTooltipDisabled]="!transferService.isVisible">
<mat-icon class="move-left-right">swap_horiz</mat-icon>
</button>
<button *ngIf="isLogedIn()" class="btn" (click)="refreshService.executeAll()" [ngStyle]="{ 'visibility': refreshService.isVisible ? 'visible' : 'hidden' }" matTooltip="strg + R" matTooltipPosition="below" [matTooltipClass]="tooltipClass" [matTooltipDisabled]="!refreshService.isVisible">
<button *ngIf="isLogedIn()" class="btn" (click)="refreshService.executeAll()" [ngStyle]="{ 'visibility': refreshService.isVisible ? 'visible' : 'hidden' }" matTooltip="strg + R" matTooltipPosition="below" matTooltipClass="pt-3" [matTooltipDisabled]="!refreshService.isVisible">
<mat-icon class="turn-360">sync</mat-icon>
</button>
<button *ngIf="isLogedIn()" class="btn" (click)="showInfo()">
<button *ngIf="isLogedIn()" [ngStyle]="{ 'visibility': buttonVisibilityService.anyVisible ? 'visible' : 'hidden' }" class="btn" (click)="showInfo()">
<mat-icon class="scale-pulse">contact_support</mat-icon>
</button>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse"

View File

@@ -8,6 +8,7 @@ import { ColorModeBttnComponent } from '../common/color-mode-bttn/color-mode-btt
import { MatIconModule } from '@angular/material/icon';
import { RefreshService } from '../../services/button/refresh.service';
import { CreationService } from '../../services/button/creation.service';
import { ButtonVisibilityService } from '../../services/button/button-visibility.service';
import { UpdateService, UpdateEvent } from '../../services/button/update.service';
import { TransferService } from '../../services/button/transfer.service';
import { MatBadgeModule } from '@angular/material/badge';
@@ -34,7 +35,7 @@ export class NavMenuComponent {
isChecked = true;
constructor(private dialog: MatDialog, private authService: AuthenticationService, public refreshService: RefreshService, public creationService: CreationService, public updateService: UpdateService, public transferService: TransferService) {
constructor(private dialog: MatDialog, private authService: AuthenticationService, public refreshService: RefreshService, public creationService: CreationService, public updateService: UpdateService, public transferService: TransferService, public buttonVisibilityService: ButtonVisibilityService) {
this.authService.isAuthenticated().then().catch()
this.updateActCount = this.updateService.totalCount;
this.updateService.addChangeListener(UpdateEvent.CountChange, () => {
@@ -73,11 +74,6 @@ export class NavMenuComponent {
@ViewChildren(MatTooltip) tooltips: QueryList<MatTooltip> | undefined;
private __tooltip_timeout_set = false;
private __shift_tooltip: boolean = true;
get tooltipClass() {
this.__shift_tooltip = !this.__shift_tooltip;
return this.__shift_tooltip ? "pt-3" : "";
}
showInfo() {
this.tooltips?.forEach(t => {

View File

@@ -26,7 +26,7 @@ export class UserTableComponent extends BaseTableComponent<User, UserService> {
gosService: GroupOfUserService,
service: UserService,
cModeService: ColorModeService) {
super(service, env.columnNames.user, cModeService)
super(service, env.columnNames.user.basic, cModeService)
this.mosService = mosService;
this.gosService = gosService;
}

View File

@@ -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>

View File

@@ -22,7 +22,7 @@ export class GroupComponent extends BasePageComponent implements AfterViewInit {
cellEditing: GuiCellEdit = {
enabled: true,
cellEdit: (value: any, item: Group, index: number) => {
if (!this.updateService.isEditable)
if (!this.updateService.isEditable || !item.internal)
return false;
this.updateService.setAsync("group_" + item.id!.toString(), async () => {

View File

@@ -26,7 +26,7 @@
<mat-tab label="Rechte Gruppe">
<app-group-table #rightGroups] [columns]="groupRightColumns" [onSelectedRows]="rightGroupOnSelectedRows"></app-group-table>
</mat-tab>
</mat-tab-group>1
</mat-tab-group>
</div>
<!-- (1, 4): assigned users -->
<div class="col-3">

View File

@@ -4,7 +4,7 @@
<mat-tab-group>
<mat-tab label="Benutzer">
<app-user-table #userTable [onSelectedRows]="usersOnSelectedRows"
[cellEditing]="cellEditing"></app-user-table>
[cellEditing]="cellEditing" [columns]="detailed_user_columns"></app-user-table>
</mat-tab>
</mat-tab-group>
</div>

View File

@@ -9,6 +9,7 @@ import { BasePageComponent } from '../base-page/base-page.component';
import { User } from '../../models/user-management.api.models';
import { firstValueFrom, forkJoin } from 'rxjs';
import Swal from 'sweetalert2';
import { env } from '../../../environments/environment'
@Component({
standalone: true,
@@ -97,4 +98,8 @@ export class UserComponent extends BasePageComponent implements AfterViewInit {
}
});
}
public get detailed_user_columns() {
return env.columnNames.user.detailed
}
}

View File

@@ -34,4 +34,11 @@ export class ButtonVisibilityService {
}
}
}
get anyVisible(): boolean {
for (const key in this._buttons)
if (this._buttons[key].isVisible)
return true;
return false;
}
}

View File

@@ -16,23 +16,72 @@ export const env = {
loginCheck: "/auth/check"
},
columnNames: {
user: [
{
header: 'Benutzername',
field: 'username'
},
{
header: 'Vorname',
field: 'prename'
},
{
header: 'Name',
field: 'name'
},
{
header: 'E-email',
field: 'email'
}],
user: {
basic: [
{
header: 'Benutzername',
field: 'username'
},
{
header: 'Vorname',
field: 'prename'
},
{
header: 'Name',
field: 'name'
},
{
header: 'E-email',
field: 'email'
}
],
detailed: [
{
header: 'Benutzername',
field: 'username'
},
{
header: 'Vorname',
field: 'prename'
},
{
header: 'Name',
field: 'name'
},
{
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'
}
]
},
group: {
complete: [
{
@@ -41,7 +90,11 @@ export const env = {
},
{
header: "Kommentar",
field: (group: any) => group.comment ?? ""
field: "comment"
},
{
header: "Active",
field: (group: any) => group.active ? "✓" : ""
},
{
header: "AD Sync",
@@ -50,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: [
@@ -125,4 +194,4 @@ export const env = {
]
},
config_url: "/assets/config.json"
};
};

View File

@@ -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;
};
}
}
}

View File

@@ -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)
{
}

View File

@@ -0,0 +1,19 @@
using DigitalData.UserManager.Domain.Entities;
using DigitalData.Core.Abstractions.Application;
using DigitalData.UserManager.Application.DTOs.User;
using DigitalData.UserManager.Application.DTOs.Base;
namespace DigitalData.UserManager.Application.Contracts
{
public interface IBaseService<TCreateDto, TReadDto, TUpdateDto, TBaseEntity> : ICRUDService<TCreateDto, TReadDto, TUpdateDto, TBaseEntity, int>
where TCreateDto : BaseCreateDto
where TReadDto : class
where TUpdateDto : BaseUpdateDto
where TBaseEntity : BaseEntity
{
public Func<Task<UserReadDto?>> UserFactoryAsync { set; }
public Task<UserReadDto?> GetUserAsync();
}
}

View File

@@ -2,10 +2,11 @@
using DigitalData.UserManager.Application.DTOs.GroupOfUser;
using DigitalData.UserManager.Domain.Entities;
using DigitalData.Core.DTO;
using DigitalData.UserManager.Application.Services;
namespace DigitalData.UserManager.Application.Contracts
{
public interface IGroupOfUserService : ICRUDService<GroupOfUserCreateDto, GroupOfUserReadDto, GroupOfUserUpdateDto, GroupOfUser, int>
public interface IGroupOfUserService : IBaseService<GroupOfUserCreateDto, GroupOfUserReadDto, GroupOfUserUpdateDto, GroupOfUser>
{
Task<Result> DeleteAsyncByGroupUserId(int groupId, int userId);

View File

@@ -1,11 +1,10 @@
using DigitalData.Core.Abstractions.Application;
using DigitalData.UserManager.Application.DTOs.Group;
using DigitalData.UserManager.Application.DTOs.Group;
using DigitalData.UserManager.Domain.Entities;
using DigitalData.Core.DTO;
namespace DigitalData.UserManager.Application.Contracts
{
public interface IGroupService : ICRUDService<GroupCreateDto, GroupReadDto, GroupUpdateDto, Group, int>
public interface IGroupService : IBaseService<GroupCreateDto, GroupReadDto, GroupUpdateDto, Group>
{
Task<DataResult<int>> CreateAsync(DirectoryGroupDto dirGroup);
}

View File

@@ -2,10 +2,11 @@
using DigitalData.UserManager.Application.DTOs.UserRep;
using DigitalData.UserManager.Domain.Entities;
using DigitalData.Core.DTO;
using DigitalData.UserManager.Application.Services;
namespace DigitalData.UserManager.Application.Contracts
{
public interface IUserRepService : ICRUDService<UserRepCreateDto, UserRepReadDto, UserRepUpdateDto, UserRep, int>
public interface IUserRepService : IBaseService<UserRepCreateDto, UserRepReadDto, UserRepUpdateDto, UserRep>
{
Task<DataResult<IEnumerable<UserRepReadDto>>> ReadAllAsync(bool withUser = false, bool withRepGroup = false, bool withRightGroup = false, bool withRepUser = false, int? userId = null);
}

View File

@@ -1,11 +1,10 @@
using DigitalData.Core.Abstractions.Application;
using DigitalData.UserManager.Application.DTOs.User;
using DigitalData.UserManager.Application.DTOs.User;
using DigitalData.UserManager.Domain.Entities;
using DigitalData.Core.DTO;
namespace DigitalData.UserManager.Application.Contracts
{
public interface IUserService : ICRUDService<UserCreateDto, UserReadDto, UserUpdateDto, User, int>
public interface IUserService : IBaseService<UserCreateDto, UserReadDto, UserUpdateDto, User>
{
Task<DataResult<IEnumerable<UserReadDto>>> ReadByModuleIdAsync(int moduleId);

View File

@@ -0,0 +1,7 @@
namespace DigitalData.UserManager.Application.DTOs.Base
{
public record BaseCreateDto()
{
public string AddedWho { get; set; } = "UNAUTHORIZED";
}
}

View File

@@ -0,0 +1,6 @@
using DigitalData.Core.DTO;
namespace DigitalData.UserManager.Application.DTOs.Base
{
public record BaseReadDto(int Id, string? AddedWho, DateTime? AddedWhen, string? ChangedWho, DateTime? ChangedWhen) : BaseDTO<int>(Id);
}

View File

@@ -0,0 +1,7 @@
namespace DigitalData.UserManager.Application.DTOs.Base
{
public record BaseUpdateDto()
{
public string ChangedWho { get; set; } = "UNAUTHORIZED";
}
}

View File

@@ -1,4 +1,6 @@
namespace DigitalData.UserManager.Application.DTOs.Group
using DigitalData.UserManager.Application.DTOs.Base;
namespace DigitalData.UserManager.Application.DTOs.Group
{
public record GroupCreateDto
(
@@ -7,8 +9,6 @@
bool? Internal,
bool? Active,
string? Comment,
string? AddedWho,
string? ChangedWho,
int EcmFkId
);
) : BaseCreateDto();
}

View File

@@ -1,4 +1,6 @@
namespace DigitalData.UserManager.Application.DTOs.Group
using DigitalData.UserManager.Application.DTOs.Base;
namespace DigitalData.UserManager.Application.DTOs.Group
{
public record GroupReadDto
(
@@ -9,6 +11,8 @@
bool? Active,
string? Comment,
string? AddedWho,
string? ChangedWho
);
DateTime? AddedWhen,
string? ChangedWho,
DateTime? ChangedWhen
) : BaseReadDto(Id, AddedWho, AddedWhen, ChangedWho, ChangedWhen);
}

View File

@@ -1,4 +1,6 @@
namespace DigitalData.UserManager.Application.DTOs.Group
using DigitalData.UserManager.Application.DTOs.Base;
namespace DigitalData.UserManager.Application.DTOs.Group
{
public record GroupUpdateDto
(
@@ -9,5 +11,5 @@
bool? Active,
string? Comment,
string? ChangedWho
);
) : BaseUpdateDto();
}

View File

@@ -1,9 +1,10 @@
namespace DigitalData.UserManager.Application.DTOs.GroupOfUser
using DigitalData.UserManager.Application.DTOs.Base;
namespace DigitalData.UserManager.Application.DTOs.GroupOfUser
{
public record GroupOfUserCreateDto(
int UserId,
int GroupId,
string? Comment,
string? AddedWho
);
string? Comment
) : BaseCreateDto();
}

View File

@@ -1,4 +1,5 @@
using DigitalData.UserManager.Application.DTOs.Group;
using DigitalData.UserManager.Application.DTOs.Base;
using DigitalData.UserManager.Application.DTOs.Group;
using DigitalData.UserManager.Application.DTOs.User;
namespace DigitalData.UserManager.Application.DTOs.GroupOfUser
@@ -11,6 +12,8 @@ namespace DigitalData.UserManager.Application.DTOs.GroupOfUser
string AddedWho,
string? ChangedWho,
UserReadDto User,
GroupReadDto Group
);
GroupReadDto Group,
DateTime? AddedWhen,
DateTime? ChangedWhen
) : BaseReadDto(Id, AddedWho, AddedWhen, ChangedWho, ChangedWhen);
}

View File

@@ -1,10 +1,11 @@
namespace DigitalData.UserManager.Application.DTOs.GroupOfUser
using DigitalData.UserManager.Application.DTOs.Base;
namespace DigitalData.UserManager.Application.DTOs.GroupOfUser
{
public record GroupOfUserUpdateDto(
int Id,
int? UserId,
int? GroupId,
string? Comment,
string? ChangedWho
);
string? Comment
) : BaseUpdateDto();
}

View File

@@ -1,6 +1,8 @@
namespace DigitalData.UserManager.Application.DTOs.User
using DigitalData.UserManager.Application.DTOs.Base;
namespace DigitalData.UserManager.Application.DTOs.User
{
public record class UserCreateDto
public record class UserCreateDto() : BaseCreateDto()
{
public string? Prename { get; init; }
public string? Name { get; init; }
@@ -11,7 +13,6 @@
public string? Comment { get; init; }
public bool? Deleted { get; init; }
public string DateFormat { get; init; } = "dd.MM.yyyy";
public string AddedWho { get; init; } = "DEFAULT";
public string? ChangedWho { get; init; }
public bool Active { get; init; } = true;
}

View File

@@ -1,4 +1,6 @@
namespace DigitalData.UserManager.Application.DTOs.User
using DigitalData.UserManager.Application.DTOs.Base;
namespace DigitalData.UserManager.Application.DTOs.User
{
public record UserUpdateDto(
int Id,
@@ -11,8 +13,6 @@
string? Comment,
bool? Deleted,
string? DateFormat,
string? AddedWho,
string? ChangedWho,
bool? Active
);
) : BaseUpdateDto();
}

View File

@@ -1,4 +1,6 @@
namespace DigitalData.UserManager.Application.DTOs.UserRep
using DigitalData.UserManager.Application.DTOs.Base;
namespace DigitalData.UserManager.Application.DTOs.UserRep
{
public record UserRepCreateDto(
int UserId,
@@ -6,5 +8,5 @@
int RightGroupId,
string AddedWho,
int RepUserId
);
) : BaseCreateDto();
}

View File

@@ -1,4 +1,5 @@
using DigitalData.UserManager.Application.DTOs.Group;
using DigitalData.UserManager.Application.DTOs.Base;
using DigitalData.UserManager.Application.DTOs.Group;
using DigitalData.UserManager.Application.DTOs.User;
namespace DigitalData.UserManager.Application.DTOs.UserRep
@@ -9,10 +10,13 @@ namespace DigitalData.UserManager.Application.DTOs.UserRep
int? RepGroupId,
int RightGroupId,
string AddedWho,
string ChangedWho,
int? RepUserId,
UserReadDto? User,
GroupReadDto? RepGroup,
GroupReadDto? RightGroup,
UserReadDto? RepUser
);
UserReadDto? RepUser,
DateTime? AddedWhen,
DateTime? ChangedWhen
) : BaseReadDto(Id, AddedWho, AddedWhen, ChangedWho, ChangedWhen);
}

View File

@@ -1,9 +1,11 @@
namespace DigitalData.UserManager.Application.DTOs.UserRep
using DigitalData.UserManager.Application.DTOs.Base;
namespace DigitalData.UserManager.Application.DTOs.UserRep
{
public record UserRepUpdateDto(
int UserId,
int? RepGroupId,
int RightGroupId,
int RepUserId
);
) : BaseUpdateDto();
}

View File

@@ -0,0 +1,51 @@
using AutoMapper;
using DigitalData.Core.Abstractions.Infrastructure;
using DigitalData.Core.Application;
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;
namespace DigitalData.UserManager.Application.Services
{
public class BaseService<TCRUDRepository, TCreateDto, TReadDto, TUpdateDto, TBaseEntity> : CRUDService<TCRUDRepository, TCreateDto, TReadDto, TUpdateDto, TBaseEntity, int>, IBaseService<TCreateDto, TReadDto, TUpdateDto, TBaseEntity>
where TCRUDRepository : ICRUDRepository<TBaseEntity, int>
where TCreateDto : BaseCreateDto
where TReadDto : class
where TUpdateDto : BaseUpdateDto
where TBaseEntity : BaseEntity
{
public BaseService(TCRUDRepository repository, IMapper mapper) : base(repository, mapper)
{
}
private Lazy<Task<UserReadDto?>>? _lazyUserAsync = null;
public Func<Task<UserReadDto?>> UserFactoryAsync { set => _lazyUserAsync = new Lazy<Task<UserReadDto?>>(value); }
public async Task<UserReadDto?> GetUserAsync() => _lazyUserAsync is null ? null : await _lazyUserAsync.Value;
public override async Task<DataResult<int>> CreateAsync(TCreateDto createDto)
{
var user = await GetUserAsync();
if(user is not null)
{
createDto.AddedWho = user.Username;
}
return await base.CreateAsync(createDto);
}
public override async Task<Result> UpdateAsync(TUpdateDto updateDto)
{
var user = await GetUserAsync();
if (user is not null)
{
updateDto.ChangedWho = user.Username;
}
return await base.UpdateAsync(updateDto);
}
}
}

View File

@@ -8,7 +8,7 @@ using DigitalData.UserManager.Infrastructure.Contracts;
namespace DigitalData.UserManager.Application.Services
{
public class GroupOfUserService : CRUDService<IGroupOfUserRepository, GroupOfUserCreateDto, GroupOfUserReadDto, GroupOfUserUpdateDto, GroupOfUser, int>, IGroupOfUserService
public class GroupOfUserService : BaseService<IGroupOfUserRepository, GroupOfUserCreateDto, GroupOfUserReadDto, GroupOfUserUpdateDto, GroupOfUser>, IGroupOfUserService
{
public GroupOfUserService(IGroupOfUserRepository repository, IMapper mapper) : base(repository, mapper)
{

View File

@@ -1,5 +1,4 @@
using AutoMapper;
using DigitalData.Core.Application;
using DigitalData.Core.DTO;
using DigitalData.UserManager.Application.Contracts;
using DigitalData.UserManager.Application.DTOs.Group;
@@ -9,7 +8,7 @@ using Microsoft.Extensions.Localization;
namespace DigitalData.UserManager.Application.Services
{
public class GroupService : CRUDService<IGroupRepository, GroupCreateDto, GroupReadDto, GroupUpdateDto, Group, int>, IGroupService
public class GroupService : BaseService<IGroupRepository, GroupCreateDto, GroupReadDto, GroupUpdateDto, Group>, IGroupService
{
private readonly IStringLocalizer<Resource> _localizer;
public GroupService(IGroupRepository repository, IStringLocalizer<Resource> localizer, IMapper mapper) : base(repository, mapper)
@@ -17,15 +16,14 @@ namespace DigitalData.UserManager.Application.Services
_localizer = localizer;
}
public override Task<DataResult<int>> CreateAsync(GroupCreateDto createDto)
{
return base.CreateAsync(createDto);
}
public async Task<DataResult<int>> CreateAsync(DirectoryGroupDto adGroup)
{
var group = _mapper.MapOrThrow<Group>(adGroup);
//set the user
var user = await GetUserAsync();
group.AddedWho = user?.AddedWho ?? "UNAUTHORIZED";
if (await HasEntity(group.Id))
return Result.Fail<int>().Message(_localizer[Key.GroupAlreadyExists.ToString()]);

View File

@@ -9,7 +9,7 @@ using Microsoft.Extensions.Localization;
namespace DigitalData.UserManager.Application.Services
{
public class UserRepService : CRUDService<IUserRepRepository, UserRepCreateDto, UserRepReadDto, UserRepUpdateDto, UserRep, int>, IUserRepService
public class UserRepService : BaseService<IUserRepRepository, UserRepCreateDto, UserRepReadDto, UserRepUpdateDto, UserRep>, IUserRepService
{
public UserRepService(IUserRepRepository repository, IStringLocalizer<Resource> localizer, IMapper mapper) : base(repository, mapper)
{

View File

@@ -9,7 +9,7 @@ using Microsoft.Extensions.Localization;
namespace DigitalData.UserManager.Application.Services
{
public class UserService : CRUDService<IUserRepository, UserCreateDto, UserReadDto, UserUpdateDto, User, int>, IUserService
public class UserService : BaseService<IUserRepository, UserCreateDto, UserReadDto, UserUpdateDto, User>, IUserService
{
private readonly IStringLocalizer<Resource> _localizer;
public UserService(IUserRepository repository, IStringLocalizer<Resource> localizer, IMapper mapper) : base(repository, mapper)

View File

@@ -0,0 +1,29 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace DigitalData.UserManager.Domain.Entities
{
public class BaseEntity
{
[Column("GUID")]
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[StringLength(50)]
[Column("ADDED_WHO")]
public string? AddedWho { get; set; }
[StringLength(50)]
[Column("CHANGED_WHO")]
public string? ChangedWho { get; set; }
[Column("ADDED_WHEN", TypeName = "datetime")]
[DefaultValue("GETDATE()")]
public DateTime AddedWhen { get; set; } = DateTime.Now;
[Column("CHANGED_WHEN", TypeName = "datetime")]
public DateTime? ChangedWhen { get; set; }
}
}

View File

@@ -5,13 +5,8 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace DigitalData.UserManager.Domain.Entities
{
[Table("TBDD_GROUPS", Schema = "dbo")]
public class Group
public class Group : BaseEntity
{
[Column("GUID")]
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[StringLength(50)]
public string? Name { get; set; }
@@ -31,27 +26,9 @@ namespace DigitalData.UserManager.Domain.Entities
[StringLength(200)]
public string? Comment { get; set; }
[StringLength(50)]
[DefaultValue("DEFAULT")]
[Column("ADDED_WHO")]
public string? AddedWho { get; set; }
[StringLength(50)]
[Column("CHANGED_WHO")]
public string? ChangedWho { get; set; }
[Required]
[Column("ECM_FK_ID")]
[DefaultValue(0)]
public int EcmFkId { get; set; }
#region IGNORED COLUMNS
//[Column(TypeName = "datetime")]
//[DefaultValue("GETDATE()")]
//public DateTime? AddedWhen { get; set; }
//[Column(TypeName = "datetime")]
//public DateTime? ChangedWhen { get; set; }
#endregion
}
}

View File

@@ -5,13 +5,8 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace DigitalData.UserManager.Domain.Entities
{
[Table("TBDD_GROUPS_USER", Schema = "dbo")]
public class GroupOfUser
public class GroupOfUser : BaseEntity
{
[Column("GUID")]
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Required]
[Column("USER_ID")]
public int UserId { get; set; }
@@ -23,27 +18,10 @@ namespace DigitalData.UserManager.Domain.Entities
[StringLength(200)]
public string? Comment { get; set; }
[StringLength(50)]
[DefaultValue("DEFAULT")]
[Column("ADDED_WHO")]
public string AddedWho { get; set; } = "DEFAULT";
[StringLength(50)]
[Column("CHANGED_WHO")]
public string? ChangedWho { get; set; }
[ForeignKey("UserId")]
public virtual User? User { get; set; }
[ForeignKey("GroupId")]
public virtual Group? Group { get; set; }
#region IGNORED COLUMN
//[DefaultValue("getdate()")]
//public DateTime? AddedWhen { get; set; }
//public DateTime? ChangedWhen { get; set; }
#endregion
}
}

View File

@@ -5,13 +5,8 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace DigitalData.UserManager.Domain.Entities
{
[Table("TBDD_USER", Schema = "dbo")]
public class User
public class User : BaseEntity
{
[Column("GUID")]
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Column("PRENAME")]
[StringLength(50)]
public string? Prename { get; set; }
@@ -52,16 +47,6 @@ namespace DigitalData.UserManager.Domain.Entities
[DefaultValue("dd.MM.yyyy")]
public string DateFormat { get; set; }
[Required]
[Column("ADDED_WHO")]
[StringLength(50)]
[DefaultValue("DEFAULT")]
public string AddedWho { get; set; }
[Column("CHANGED_WHO")]
[StringLength(50)]
public string? ChangedWho { get; set; }
[Required]
[Column("ACTIVE")]
public bool Active { get; set; }
@@ -87,14 +72,6 @@ namespace DigitalData.UserManager.Domain.Entities
//[Column("DELETED_WHO")]
//[StringLength(50)]
//public string? DeletedWho { get; set; }
//[Required]
//[Column("ADDED_WHEN")]
//[DefaultValue("getdate()")]
//public DateTime? AddedWhen { get; set; }
//[Column("CHANGED_WHEN")]
//public DateTime? ChangedWhen { get; set; }
#endregion
}
}

View File

@@ -5,13 +5,8 @@ using System.ComponentModel;
namespace DigitalData.UserManager.Domain.Entities
{
[Table("TBDD_USER_REPRESENTATION", Schema = "dbo")]
public class UserRep
public class UserRep : BaseEntity
{
[Column("GUID")]
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Required]
[Column("USER_ID")]
public int UserId { get; set; }
@@ -23,16 +18,6 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("RIGHT_GROUP")]
public int RightGroupId { get; set; }
[Required]
[StringLength(50)]
[DefaultValue("DEFAULT")]
[Column("ADDED_WHO")]
public string AddedWho { get; set; }
[StringLength(50)]
[Column("CHANGED_WHO")]
public string? ChangedWho { get; set; }
[Column("REPR_USER")]
public int? RepUserId { get; set; }