initial commit

This commit is contained in:
2026-07-21 15:03:40 +07:00
commit 5c20bb8a9e
2752 changed files with 864209 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
namespace Domain.Common;
public class BaseEntity : IHasSequentialId, IHasIsDeleted, IHasAudit
{
public string Id { get; set; } = null!;
public bool IsDeleted { get; set; }
public DateTime? CreatedAtUtc { get; set; }
public string? CreatedById { get; set; }
public DateTime? UpdatedAtUtc { get; set; }
public string? UpdatedById { get; set; }
public BaseEntity()
{
Id = GenerateSequentialGuid();
IsDeleted = false;
}
private static readonly object _lock = new object();
private string GenerateSequentialGuid()
{
byte[] guidArray = Guid.NewGuid().ToByteArray();
DateTime baseDate = new DateTime(1900, 1, 1);
DateTime now = DateTime.UtcNow;
TimeSpan timeSpan = now - baseDate;
byte[] daysArray = BitConverter.GetBytes(timeSpan.Days);
byte[] msecsArray = BitConverter.GetBytes((long)(timeSpan.TotalMilliseconds % 86400000));
if (BitConverter.IsLittleEndian)
{
Array.Reverse(daysArray);
Array.Reverse(msecsArray);
}
lock (_lock)
{
Array.Copy(daysArray, daysArray.Length - 2, guidArray, guidArray.Length - 6, 2);
Array.Copy(msecsArray, msecsArray.Length - 4, guidArray, guidArray.Length - 4, 4);
}
return new Guid(guidArray).ToString();
}
}
+54
View File
@@ -0,0 +1,54 @@
namespace Domain.Common;
public static class Constants
{
public static class LengthConsts
{
public const int S = 50;
public const int M = 255;
public const int L = 2000;
public const int XL = 4000;
}
public static class NameConsts
{
public const int MinLength = 2;
public const int MaxLength = LengthConsts.M;
}
public static class CodeConsts
{
public const int MinLength = 1;
public const int MaxLength = LengthConsts.S;
}
public static class DescriptionConsts
{
public const int MaxLength = LengthConsts.XL;
}
public static class EmailConsts
{
public const int MinLength = 6;
public const int MaxLength = LengthConsts.M;
}
public static class IdConsts
{
public const int MaxLength = LengthConsts.S;
}
public static class PasswordConsts
{
public const int MinLength = 6;
public const int MaxLength = LengthConsts.M;
}
public static class PathConsts
{
public const int MaxLength = LengthConsts.M;
}
public static class TokenConsts
{
public const int MaxLength = LengthConsts.XL;
public const double ExpiryInDays = 30;
}
public static class UserIdConsts
{
public const int MaxLength = 450;
}
}
+9
View File
@@ -0,0 +1,9 @@
namespace Domain.Common;
public interface IHasAudit
{
public DateTime? CreatedAtUtc { get; set; }
public string? CreatedById { get; set; }
public DateTime? UpdatedAtUtc { get; set; }
public string? UpdatedById { get; set; }
}
+7
View File
@@ -0,0 +1,7 @@
namespace Domain.Common;
public interface IHasIsDeleted
{
bool IsDeleted { get; }
}
+6
View File
@@ -0,0 +1,6 @@
namespace Domain.Common;
public interface IHasSequentialId
{
string Id { get; set; }
}