-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Node Entity Configuration (#32)
Co-authored-by: NikolaVetnic <[email protected]>
- Loading branch information
1 parent
24c0491
commit 7885103
Showing
26 changed files
with
321 additions
and
144 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/FileIdConverter.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,9 @@ | ||
using BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
namespace BuildingBlocks.Api.Converters; | ||
|
||
public class FileIdConverter : IRegister | ||
{ | ||
public void Register(TypeAdapterConfig config) => | ||
config.NewConfig<FileAssetId, FileAssetId>().ConstructUsing(src => FileAssetId.Of(src.Value)); | ||
} |
9 changes: 9 additions & 0 deletions
9
Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/NodeIdConverter.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,9 @@ | ||
using BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
namespace BuildingBlocks.Api.Converters; | ||
|
||
public class NodeIdConverter : IRegister | ||
{ | ||
public void Register(TypeAdapterConfig config) => | ||
config.NewConfig<NodeId, NodeId>().ConstructUsing(src => NodeId.Of(src.Value)); | ||
} |
9 changes: 9 additions & 0 deletions
9
Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/NoteIdConverter.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,9 @@ | ||
using BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
namespace BuildingBlocks.Api.Converters; | ||
|
||
public class NoteIdConverter : IRegister | ||
{ | ||
public void Register(TypeAdapterConfig config) => | ||
config.NewConfig<NoteId, NoteId>().ConstructUsing(src => NoteId.Of(src.Value)); | ||
} |
9 changes: 9 additions & 0 deletions
9
Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/ReminderIdConverter.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,9 @@ | ||
using BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
namespace BuildingBlocks.Api.Converters; | ||
|
||
public class ReminderIdConverter : IRegister | ||
{ | ||
public void Register(TypeAdapterConfig config) => | ||
config.NewConfig<ReminderId, ReminderId>().ConstructUsing(src => ReminderId.Of(src.Value)); | ||
} |
9 changes: 9 additions & 0 deletions
9
Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/TimelineIdConverter.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,9 @@ | ||
using BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
namespace BuildingBlocks.Api.Converters; | ||
|
||
public class TimelineIdConverter : IRegister | ||
{ | ||
public void Register(TypeAdapterConfig config) => | ||
config.NewConfig<TimelineId, TimelineId>().ConstructUsing(src => TimelineId.Of(src.Value)); | ||
} |
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 @@ | ||
global using Mapster; |
9 changes: 3 additions & 6 deletions
9
Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/FileAssetId.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,13 +1,10 @@ | ||
using System.Text.Json.Serialization; | ||
namespace BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
namespace BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
[JsonConverter(typeof(FileAssetIdJsonConverter))] | ||
public record FileAssetId : StronglyTypedId | ||
public class FileAssetId : StronglyTypedId | ||
{ | ||
private FileAssetId(Guid value) : base(value) { } | ||
|
||
public static FileAssetId Of(Guid value) => new(value); | ||
|
||
private class FileAssetIdJsonConverter : StronglyTypedIdJsonConverter<FileAssetId>; | ||
public override string ToString() => Value.ToString(); | ||
} |
11 changes: 4 additions & 7 deletions
11
Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/NodeId.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,13 +1,10 @@ | ||
using System.Text.Json.Serialization; | ||
namespace BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
namespace BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
[JsonConverter(typeof(NodeIdJsonConverter))] | ||
public record NodeId : StronglyTypedId | ||
public class NodeId : StronglyTypedId | ||
{ | ||
private NodeId(Guid value) : base(value) { } | ||
|
||
public static NodeId Of(Guid value) => new(value); | ||
|
||
private class NodeIdJsonConverter : StronglyTypedIdJsonConverter<NodeId>; | ||
public override string ToString() => Value.ToString(); | ||
} |
11 changes: 4 additions & 7 deletions
11
Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/NoteId.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,13 +1,10 @@ | ||
using System.Text.Json.Serialization; | ||
namespace BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
namespace BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
[JsonConverter(typeof(NoteIdJsonConverter))] | ||
public record NoteId : StronglyTypedId | ||
public class NoteId : StronglyTypedId | ||
{ | ||
private NoteId(Guid value) : base(value) { } | ||
|
||
public static NoteId Of(Guid value) => new(value); | ||
|
||
private class NoteIdJsonConverter : StronglyTypedIdJsonConverter<NoteId>; | ||
public override string ToString() => Value.ToString(); | ||
} |
9 changes: 3 additions & 6 deletions
9
Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/ReminderId.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,13 +1,10 @@ | ||
using System.Text.Json.Serialization; | ||
namespace BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
namespace BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
[JsonConverter(typeof(ReminderIdJsonConverter))] | ||
public record ReminderId : StronglyTypedId | ||
public class ReminderId : StronglyTypedId | ||
{ | ||
private ReminderId(Guid value) : base(value) { } | ||
|
||
public static ReminderId Of(Guid value) => new(value); | ||
|
||
private class ReminderIdJsonConverter : StronglyTypedIdJsonConverter<ReminderId>; | ||
public override string ToString() => Value.ToString(); | ||
} |
9 changes: 3 additions & 6 deletions
9
Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/TimelineId.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,13 +1,10 @@ | ||
using System.Text.Json.Serialization; | ||
namespace BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
namespace BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
[JsonConverter(typeof(TimelineIdJsonConverter))] | ||
public record TimelineId : StronglyTypedId | ||
public class TimelineId : StronglyTypedId | ||
{ | ||
private TimelineId(Guid value) : base(value) { } | ||
|
||
public static TimelineId Of(Guid value) => new(value); | ||
|
||
private class TimelineIdJsonConverter : StronglyTypedIdJsonConverter<TimelineId>; | ||
public override string ToString() => Value.ToString(); | ||
} |
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
44 changes: 28 additions & 16 deletions
44
Backend/src/Modules/Nodes/Nodes.Infrastructure/Data/Configurations/NodeConfiguration.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,16 +1,28 @@ | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Nodes.Infrastructure.Data.Configurations; | ||
|
||
public class NodeConfiguration : IEntityTypeConfiguration<Node> | ||
{ | ||
public void Configure(EntityTypeBuilder<Node> builder) | ||
{ | ||
builder.HasKey(n => n.Id); | ||
builder.Property(n => n.Id).HasConversion( | ||
nodeId => nodeId.Value, | ||
dbId => NodeId.Of(dbId)); | ||
|
||
// ToDo: Add remaining Node configuration commands | ||
} | ||
} | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Nodes.Infrastructure.Data.Configurations; | ||
|
||
public class NodeConfiguration : IEntityTypeConfiguration<Node> | ||
{ | ||
public void Configure(EntityTypeBuilder<Node> builder) | ||
{ | ||
builder.HasKey(n => n.Id); | ||
builder.Property(n => n.Id).HasConversion( | ||
nodeId => nodeId.Value, | ||
dbId => NodeId.Of(dbId)); | ||
|
||
builder.Property(n => n.Title) | ||
.IsRequired() | ||
.HasMaxLength(100); | ||
|
||
builder.Property(n => n.Description) | ||
.IsRequired() | ||
.HasMaxLength(500); | ||
|
||
builder.Property(n => n.Importance) | ||
.IsRequired(); | ||
|
||
builder.Property(n => n.Phase) | ||
.IsRequired(); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
...odes.Infrastructure/Data/Migrations/20241228182710_ApplyNewNodeConfigurations.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.