Compare commits

...

10 Commits

Author SHA1 Message Date
Developer 02
968ff8349f feat(UserRep): Required-Attribut für ValidFrom und ValidTo hinzugefügt. 2024-11-06 17:13:09 +01:00
Developer 02
770921011a feat: Füge die Spalten ValidFrom und ValidTo zur UserRep-DTO hinzu. 2024-11-06 17:11:38 +01:00
Developer 02
a9bc4f90ac feat: Füge die Spalten ValidFrom und ValidTo zur UserRep-Entität hinzu. 2024-11-06 16:32:47 +01:00
Developer 02
6e5ba82869 fix(user-representation): UserRep.addedWho nullable machen, um die Annahme des aktuellen Benutzers durch die API zu ermöglichen 2024-11-06 16:26:21 +01:00
Developer 02
fb3dedadc5 refactor: Ersetze fetchData-Aufrufe durch fetchByUser- und fetchByGroup-Methoden in UserRepresentationComponent, um Fehler zu vermeiden. 2024-11-06 15:46:27 +01:00
Developer 02
8cf2183cd6 refactor(user-representation): Umbenennung von 'slUserRepId' in 'slRepId' 2024-11-06 15:37:48 +01:00
Developer 02
881d2ccac8 refactor(user-representation): Umbenennung von 'userRepOnSelectedRows' in 'repOnSelectedRows' 2024-11-06 15:34:51 +01:00
Developer 02
deacd1a8c6 fix: Parameter in den ReadAllAsync-Methoden in UserRepController und UserRepService explizit benennen 2024-11-06 14:57:14 +01:00
Developer 02
616862391e feat: fetchByUser und fetchByGroup Methoden in UserRepTableComponent zur gezielten Datenabfrage hinzugefügt 2024-11-06 11:15:21 +01:00
Developer 02
296f29cf82 refactor: redundante Funktion entfernen und Logik zur Verarbeitung ausgewählter Zeilen in UserRepresentationComponent konsolidieren 2024-11-06 10:52:19 +01:00
10 changed files with 64 additions and 52 deletions

View File

@@ -31,4 +31,12 @@ export class UserRepTableComponent extends BaseTableComponent<UserRep, UserRepSe
error: (error: any) => { } error: (error: any) => { }
}); });
} }
public fetchByUser(id: number): void {
this.fetchData(id, undefined);
}
public fetchByGroup(id: number): void {
this.fetchData(undefined, id);
}
} }

View File

@@ -64,7 +64,7 @@ export interface UserRep {
userId?: number, userId?: number,
repGroupId?: number, repGroupId?: number,
groupId?: number, groupId?: number,
addedWho: string, addedWho?: string,
repUser?: User repUser?: User
user?: User, user?: User,
repGroup?: Group, repGroup?: Group,

View File

@@ -27,7 +27,7 @@
<div class="col-3"> <div class="col-3">
<mat-tab-group> <mat-tab-group>
<mat-tab label="{{useRepLabel}}"> <mat-tab label="{{useRepLabel}}">
<app-user-rep-table #userReps [initData]="initWithoutData" [onSelectedRows]="userRepOnSelectedRows"></app-user-rep-table> <app-user-rep-table #userReps [initData]="initWithoutData" [onSelectedRows]="repOnSelectedRows"></app-user-rep-table>
</mat-tab> </mat-tab>
</mat-tab-group> </mat-tab-group>
</div> </div>

View File

@@ -26,7 +26,7 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
slGroupId?: number; slGroupId?: number;
slRepUserId?: number; slRepUserId?: number;
slRepGroupId?: number; slRepGroupId?: number;
slUserRepId?: number; slRepId?: number;
initWithoutData = () => { } initWithoutData = () => { }
@@ -59,31 +59,24 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
@ViewChild("repGroups") repGroups!: GroupTableComponent; @ViewChild("repGroups") repGroups!: GroupTableComponent;
@ViewChild("userReps") userReps!: UserRepTableComponent; @ViewChild("userReps") userReps!: UserRepTableComponent;
userGroupOnSelectedRows = (rows: GuiSelectedRow[], isUser: boolean = true) => { userOnSelectedRows = (rows: GuiSelectedRow[]) => {
if (rows.length > 0) { if (rows.length > 0) {
if (isUser) { this.useRepLabel = `Vertretungen von ${rows[0].source?.username}`
this.useRepLabel = `Vertretungen von ${rows[0].source?.username}` this.users.safelyUnselectAll();
this.users.safelyUnselectAll(); this.userReps.fetchByUser(rows[0].source?.id);
this.userReps.fetchData(rows[0].source?.id) this.slGroupId = undefined;
this.slGroupId = undefined; this.slUserId = rows[0].source?.id
this.slUserId = rows[0].source?.id
}
else {
this.useRepLabel = `Vertretungen von ${rows[0].source?.name}`
this.groups.safelyUnselectAll();
this.userReps.fetchData(undefined, rows[0].source?.id)
this.slUserId = undefined;
this.slGroupId = rows[0].source?.id
}
} }
} }
userOnSelectedRows = (rows: GuiSelectedRow[]) => {
this.userGroupOnSelectedRows(rows, true);
}
groupOnSelectedRows = (rows: GuiSelectedRow[]) => { groupOnSelectedRows = (rows: GuiSelectedRow[]) => {
this.userGroupOnSelectedRows(rows, false); if (rows.length > 0) {
this.useRepLabel = `Vertretungen von ${rows[0].source?.name}`
this.groups.safelyUnselectAll();
this.userReps.fetchByGroup(rows[0].source?.id);
this.slUserId = undefined;
this.slGroupId = rows[0].source?.id
}
} }
repUserOnSelectedRows = (rows: GuiSelectedRow[]) => { repUserOnSelectedRows = (rows: GuiSelectedRow[]) => {
@@ -107,7 +100,6 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
userId: this.slUserId, userId: this.slUserId,
groupId: this.slGroupId, groupId: this.slGroupId,
repUserId: this.slRepUserId, repUserId: this.slRepUserId,
addedWho: 'DEFAULT'
} }
this.userRepService.create(newUserRep).subscribe({ this.userRepService.create(newUserRep).subscribe({
next: (response) => { next: (response) => {
@@ -115,10 +107,10 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
this.repUsers.safelyUnselectAll() this.repUsers.safelyUnselectAll()
this.repGroups.safelyUnselectAll() this.repGroups.safelyUnselectAll()
if (this.slUserId != undefined) if (this.slUserId)
this.userReps.fetchData(this.slUserId) this.userReps.fetchByUser(this.slUserId)
if (this.slGroupId != undefined) if (this.slGroupId)
this.userReps.fetchData(this.slGroupId) this.userReps.fetchByGroup(this.slGroupId)
}, },
error: (error) => { error: (error) => {
Swal.fire({ Swal.fire({
@@ -158,17 +150,16 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
userId: this.slUserId, userId: this.slUserId,
groupId: this.slGroupId, groupId: this.slGroupId,
repGroupId: this.slRepGroupId, repGroupId: this.slRepGroupId,
addedWho: 'DEFAULT'
} }
this.userRepService.create(newUserRep).subscribe({ this.userRepService.create(newUserRep).subscribe({
next: (res) => { next: (res) => {
this.slRepGroupId = undefined; this.slRepGroupId = undefined;
this.repUsers.safelyUnselectAll() this.repUsers.safelyUnselectAll()
this.groups.safelyUnselectAll() this.groups.safelyUnselectAll()
if (this.slUserId != undefined) if (this.slUserId)
this.userReps.fetchData(this.slUserId) this.userReps.fetchByUser(this.slUserId)
if (this.slGroupId != undefined) if (this.slGroupId)
this.userReps.fetchData(undefined, this.slGroupId) this.userReps.fetchByGroup(this.slGroupId)
}, },
error: (error) => { error: (error) => {
Swal.fire({ Swal.fire({
@@ -187,11 +178,11 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
} }
} }
userRepOnSelectedRows = (rows: GuiSelectedRow[]) => { repOnSelectedRows = (rows: GuiSelectedRow[]) => {
if (rows.length == 0 && this.slUserRepId) { if (rows.length == 0 && this.slRepId) {
this.userRepService.delete(this.slUserRepId).subscribe({ this.userRepService.delete(this.slRepId).subscribe({
next: (res) => { next: (res) => {
this.slUserRepId = undefined; this.slRepId = undefined;
this.userReps.safelyUnselectAll(); this.userReps.safelyUnselectAll();
if (this.slUserId != undefined) if (this.slUserId != undefined)
this.userReps.fetchData(this.slUserId) this.userReps.fetchData(this.slUserId)
@@ -199,7 +190,7 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
this.userReps.fetchData(undefined, this.slGroupId) this.userReps.fetchData(undefined, this.slGroupId)
}, },
error: (err) => { error: (err) => {
this.slUserRepId = undefined; this.slRepId = undefined;
this.repUsers.safelyUnselectAll() this.repUsers.safelyUnselectAll()
Swal.fire({ Swal.fire({
icon: "error", icon: "error",
@@ -210,7 +201,7 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
}) })
} }
else if (rows.length > 0) { else if (rows.length > 0) {
this.slUserRepId = rows[0].source?.id; this.slRepId = rows[0].source?.id;
} }
} }
} }

View File

@@ -19,18 +19,18 @@ namespace DigitalData.UserManager.API.Controllers
{ {
return base.GetAll(); return base.GetAll();
} }
[HttpGet] [HttpGet]
public async Task<IActionResult> GetAll(bool withUser = false, bool withRepGroup = false, bool withGroup = false, bool withRepUser = false, int? userId = null, int? groupId = null) public async Task<IActionResult> GetAll(bool withUser = false, bool withRepGroup = false, bool withGroup = false, bool withRepUser = false, int? userId = null, int? groupId = null)
{ {
try try
{ {
return await _service.ReadAllAsync(withUser, withRepGroup, withGroup, withRepUser, userId, groupId).ThenAsync(Ok, IActionResult (m, n) => return await _service.ReadAllAsync(withUser: withUser, withRepGroup: withRepGroup, withGroup: withGroup, withRepUser: withRepUser,
userId: userId, groupId: groupId).ThenAsync(Ok, IActionResult (m, n) =>
{ {
_logger.LogNotice(n); _logger.LogNotice(n);
return NotFound(); return NotFound();
}); });
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@@ -6,6 +6,8 @@ namespace DigitalData.UserManager.Application.DTOs.UserRep
int? UserId, int? UserId,
int? RepGroupId, int? RepGroupId,
int? GroupId, int? GroupId,
int? RepUserId int? RepUserId,
DateTime? ValidFrom,
DateTime? ValidTo
) : BaseCreateDto(); ) : BaseCreateDto();
} }

View File

@@ -9,9 +9,11 @@ namespace DigitalData.UserManager.Application.DTOs.UserRep
int? UserId, int? UserId,
int? GroupId, int? GroupId,
int? RepUserId, int? RepUserId,
int? RepGroupId, int? RepGroupId,
DateTime ValidFrom,
DateTime ValidTo,
string AddedWho, string AddedWho,
string? ChangedWho, string? ChangedWho,
UserReadDto? User, UserReadDto? User,
GroupReadDto? RepGroup, GroupReadDto? RepGroup,
GroupReadDto? Group, GroupReadDto? Group,

View File

@@ -6,6 +6,8 @@ namespace DigitalData.UserManager.Application.DTOs.UserRep
int? UserId, int? UserId,
int? RepGroupId, int? RepGroupId,
int? GroupId, int? GroupId,
int? RepUserId int? RepUserId,
DateTime? ValidFrom,
DateTime? ValidTo
) : BaseUpdateDto(); ) : BaseUpdateDto();
} }

View File

@@ -1,5 +1,4 @@
using AutoMapper; using AutoMapper;
using DigitalData.Core.Application;
using DigitalData.Core.DTO; using DigitalData.Core.DTO;
using DigitalData.UserManager.Application.Contracts; using DigitalData.UserManager.Application.Contracts;
using DigitalData.UserManager.Application.DTOs.UserRep; using DigitalData.UserManager.Application.DTOs.UserRep;
@@ -17,7 +16,7 @@ namespace DigitalData.UserManager.Application.Services
public async Task<DataResult<IEnumerable<UserRepReadDto>>> ReadAllAsync(bool withUser = false, bool withRepGroup = false, bool withGroup = false, bool withRepUser = false, int? userId = null, int? groupId = null) public async Task<DataResult<IEnumerable<UserRepReadDto>>> ReadAllAsync(bool withUser = false, bool withRepGroup = false, bool withGroup = false, bool withRepUser = false, int? userId = null, int? groupId = null)
{ {
var urs = await _repository.ReadAllAsync(withUser, withRepGroup, withGroup, withRepUser, userId, groupId); var urs = await _repository.ReadAllAsync(withUser: withUser, withRepGroup: withRepGroup, withGroup: withGroup, withRepUser: withRepUser, userId: userId, groupId: groupId);
var urReadDTOs = _mapper.Map<IEnumerable<UserRepReadDto>>(urs); var urReadDTOs = _mapper.Map<IEnumerable<UserRepReadDto>>(urs);
return Result.Success(urReadDTOs); return Result.Success(urReadDTOs);
} }

View File

@@ -1,5 +1,5 @@
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema;
namespace DigitalData.UserManager.Domain.Entities namespace DigitalData.UserManager.Domain.Entities
{ {
@@ -18,6 +18,14 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("REPR_USER")] [Column("REPR_USER")]
public int? RepUserId { get; set; } public int? RepUserId { get; set; }
[Required]
[Column("VALID_FROM")]
public required DateTime ValidFrom { get; set; }
[Required]
[Column("VALID_TO")]
public required DateTime ValidTo { get; set; }
[ForeignKey("UserId")] [ForeignKey("UserId")]
public virtual User? User { get; set; } public virtual User? User { get; set; }