-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webapi): Combine actorDtos (#1374)
## Description Replaced all actorDtos with one common enduser actordto, and one common serivceowner actordto ## Related Issue(s) ## Verification - [x] **Your** code builds clean without any errors or warnings - [x] Manual testing done (required) - [x] Relevant automated test added (if you find this hard, leave it and we'll help out) ## Documentation - [ ] Documentation is updated (either in `docs`-directory, Altinnpedia or a separate linked PR in [altinn-studio-docs.](https://github.com/Altinn/altinn-studio-docs), if applicable) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a unified `ActorDto` for actor representation across various components, replacing multiple specific actor DTOs. - Added validation for `ActorDto` to ensure proper data integrity based on actor type. - **Bug Fixes** - Updated mappings and properties to reflect the new actor structure, enhancing data consistency across the application. - **Documentation** - Updated Swagger configuration to reflect changes in actor representation. - **Tests** - Added comprehensive unit tests for the new `ActorValidator` to ensure validation rules are correctly enforced. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Amund Myrbostad <amund.myrbostad@digdir.no> Co-authored-by: Magnus Sandgren <5285192+MagnusSandgren@users.noreply.github.com>
- Loading branch information
1 parent
e79dbfa
commit ca18a99
Showing
49 changed files
with
377 additions
and
1,184 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/Common/Actors/ActorDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Digdir.Domain.Dialogporten.Domain.Actors; | ||
|
||
namespace Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.Common.Actors; | ||
|
||
public sealed class ActorDto | ||
{ | ||
/// <summary> | ||
/// The type of actor that sent the transmission. | ||
/// </summary> | ||
public ActorType.Values ActorType { get; set; } | ||
|
||
/// <summary> | ||
/// Specifies the name of the entity that sent the transmission. Mutually exclusive with ActorId. If ActorId | ||
/// is supplied, the name will be automatically populated from the name registries. | ||
/// </summary> | ||
/// <example>Ola Nordmann</example> | ||
public string? ActorName { get; set; } | ||
|
||
/// <summary> | ||
/// The identifier of the person or organization that sent the transmission. Mutually exclusive with ActorName. | ||
/// Might be omitted if ActorType is "ServiceOwner". | ||
/// </summary> | ||
/// <example>urn:altinn:person:identifier-no:12018212345</example> | ||
public string? ActorId { get; set; } | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
...igdir.Domain.Dialogporten.Application/Features/V1/EndUser/Common/Actors/MappingProfile.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using AutoMapper; | ||
using Digdir.Domain.Dialogporten.Application.Common; | ||
using Digdir.Domain.Dialogporten.Domain; | ||
using Digdir.Domain.Dialogporten.Domain.Actors; | ||
|
||
namespace Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.Common.Actors; | ||
|
||
internal sealed class MappingProfile : Profile | ||
{ | ||
public MappingProfile() | ||
{ | ||
|
||
var actorDtoType = typeof(ActorDto); | ||
var actorType = typeof(Actor); | ||
|
||
var derivedActorTypes = DomainAssemblyMarker | ||
.Assembly | ||
.GetTypes() | ||
.Where(x => x.IsClass && !x.IsAbstract && x.IsSubclassOf(actorType)) | ||
.ToList(); | ||
|
||
CreateMap<Actor, ActorDto>() | ||
.ForMember(dest => dest.ActorType, opt => opt.MapFrom(src => src.ActorTypeId)) | ||
.ForMember(dest => dest.ActorId, opt => opt.MapFrom(src => IdentifierMasker.GetMaybeMaskedIdentifier(src.ActorId))); | ||
|
||
foreach (var outputActor in derivedActorTypes) | ||
{ | ||
CreateMap(outputActor, actorDtoType) | ||
.IncludeBase(actorType, actorDtoType); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 3 additions & 7 deletions
10
...ain.Dialogporten.Application/Features/V1/EndUser/DialogSeenLogs/Queries/Get/SeenLogDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
using Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.Common.Actors; | ||
|
||
namespace Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.DialogSeenLogs.Queries.Get; | ||
|
||
public sealed class SeenLogDto | ||
{ | ||
public Guid Id { get; set; } | ||
public DateTimeOffset SeenAt { get; set; } | ||
public SeenLogSeenByActorDto SeenBy { get; set; } = null!; | ||
public ActorDto SeenBy { get; set; } = null!; | ||
|
||
public bool IsViaServiceOwner { get; set; } | ||
public bool IsCurrentEndUser { get; set; } | ||
} | ||
|
||
public sealed class SeenLogSeenByActorDto | ||
{ | ||
public Guid Id { get; set; } | ||
public string ActorName { get; set; } = null!; | ||
public string ActorId { get; set; } = null!; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 3 additions & 8 deletions
11
....Dialogporten.Application/Features/V1/EndUser/DialogSeenLogs/Queries/Search/SeenLogDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,14 @@ | ||
using Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.Common.Actors; | ||
|
||
namespace Digdir.Domain.Dialogporten.Application.Features.V1.EndUser.DialogSeenLogs.Queries.Search; | ||
|
||
public sealed class SeenLogDto | ||
{ | ||
public Guid Id { get; set; } | ||
public DateTimeOffset SeenAt { get; set; } | ||
|
||
public SeenLogSeenByActorDto SeenBy { get; set; } = null!; | ||
public ActorDto SeenBy { get; set; } = null!; | ||
|
||
public bool IsViaServiceOwner { get; set; } | ||
public bool IsCurrentEndUser { get; set; } | ||
} | ||
|
||
public sealed class SeenLogSeenByActorDto | ||
{ | ||
public Guid Id { get; set; } | ||
public string ActorName { get; set; } = null!; | ||
public string ActorId { get; set; } = null!; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.