Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use uuids instead of guid #494

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ namespace MangoAPI.BusinessLogic.ApiCommands.Messages;

public class SendMessageRequest
{
[DefaultValue("hello world")] public string Text { get; set; }
[DefaultValue("hello world")]
public string Text { get; set; }

[DefaultValue("a8747c37-c5ef-4a87-943c-3ee3ae0a2871")]
public Guid ChatId { get; set; }

[DefaultValue("John Doe")] public string InReplyToUser { get; set; }
[DefaultValue("John Doe")]
public string InReplyToUser { get; set; }

[DefaultValue("Hello world!")] public string InReplyToText { get; set; }

[DefaultValue("2021-08-01T00:00:00.0000000")]
public DateTime? CreatedAt { get; set; }
[DefaultValue("Hello world!")]
public string InReplyToText { get; set; }

public IFormFile Attachment { get; set; }
}
3 changes: 2 additions & 1 deletion MangoAPI.Domain/Entities/ChatEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using MangoAPI.Domain.Enums;
using System;
using System.Collections.Generic;
using Uuids;

namespace MangoAPI.Domain.Entities;

Expand Down Expand Up @@ -56,7 +57,7 @@ private ChatEntity(

_messages = new List<MessageEntity>();
_chatUsers = new List<UserChatEntity>();
Id = Guid.NewGuid();
Id = Uuid.NewMySqlOptimized().ToGuidByteLayout();

new ChatEntityValidator().ValidateAndThrow(this);
}
Expand Down
3 changes: 2 additions & 1 deletion MangoAPI.Domain/Entities/MessageEntity.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using FluentValidation;
using System;
using Uuids;

namespace MangoAPI.Domain.Entities;

Expand Down Expand Up @@ -33,7 +34,7 @@ private MessageEntity()

private MessageEntity(Guid userId, Guid chatId, string text)
{
Id = Guid.NewGuid();
Id = Uuid.NewMySqlOptimized().ToGuidByteLayout();
UserId = userId;
ChatId = chatId;
Text = text;
Expand Down
3 changes: 2 additions & 1 deletion MangoAPI.Domain/Entities/PersonalInformationEntity.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using FluentValidation;
using System;
using Uuids;

namespace MangoAPI.Domain.Entities;

Expand Down Expand Up @@ -29,7 +30,7 @@ private PersonalInformationEntity()

private PersonalInformationEntity(Guid userId)
{
Id = Guid.NewGuid();
Id = Uuid.NewMySqlOptimized().ToGuidByteLayout();
UserId = userId;
CreatedAt = DateTime.UtcNow;

Expand Down
3 changes: 2 additions & 1 deletion MangoAPI.Domain/Entities/SessionEntity.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using FluentValidation;
using System;
using Uuids;

namespace MangoAPI.Domain.Entities;

Expand All @@ -23,7 +24,7 @@ private SessionEntity()

private SessionEntity(Guid userId, DateTime expiresAt)
{
Id = Guid.NewGuid();
Id = Uuid.NewMySqlOptimized().ToGuidByteLayout();
CreatedAt = DateTime.UtcNow;
UserId = userId;
ExpiresAt = expiresAt;
Expand Down
3 changes: 2 additions & 1 deletion MangoAPI.Domain/Entities/UserEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using MangoAPI.Domain.Enums;
using System;
using Uuids;

namespace MangoAPI.Domain.Entities;

Expand Down Expand Up @@ -55,7 +56,7 @@ private UserEntity(
string imageFileName,
DisplayNameColour displayNameColour)
{
Id = Guid.NewGuid();
Id = Uuid.NewMySqlOptimized().ToGuidByteLayout();
_sessions = new List<SessionEntity>();
_messages = new List<MessageEntity>();
_userChats = new List<UserChatEntity>();
Expand Down
1 change: 1 addition & 0 deletions MangoAPI.Domain/MangoAPI.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="FluentAssertions" Version="6.10.0" />
<PackageReference Include="Uuids" Version="2.0.0" />
</ItemGroup>
</Project>