添加项目文件。

This commit is contained in:
2026-05-09 17:06:30 +08:00
parent c60f5fe117
commit 720ef957d4
378 changed files with 14843 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
namespace IM.DomainCommons
{
public class AggregateRootEntity : BaseEntity, IAggregateRoot, ISoftDelete, IHasCreationTime, IHasDeletionTime, IHasModificationTime
{
public bool IsDeleted { get; private set; }
public DateTimeOffset CreationTime { get; private set; } = DateTime.Now;
public DateTimeOffset? Deletion { get; private set; }
public DateTimeOffset? ModificationTime { get; set; }
public void SoftDelete()
{
Deletion = DateTime.Now;
IsDeleted = true;
}
public void NotifyModified()
{
ModificationTime = DateTime.Now;
}
}
}
+40
View File
@@ -0,0 +1,40 @@
using MassTransit;
using MediatR;
using System.ComponentModel.DataAnnotations.Schema;
namespace IM.DomainCommons
{
public class BaseEntity : IEntity, IDomainEvents
{
/// <summary>
/// 这里使用连续guid,防止数据库性能问题
/// </summary>
public Guid Id { get; private set; } = NewId.NextGuid();
[NotMapped]
public List<INotification> domainEvents = [];
public void AddDomainEvent(INotification eventItem)
{
domainEvents.Add(eventItem);
}
public void AddDomainEventIfAbsent(INotification eventItem)
{
if (!domainEvents.Contains(eventItem))
{
domainEvents.Add(eventItem);
}
}
public void ClearDomainEvents()
{
domainEvents.Clear();
}
public IEnumerable<INotification> GetDomainEvents()
{
return domainEvents;
}
}
}
+10
View File
@@ -0,0 +1,10 @@
namespace IM.DomainCommons
{
public class DomainException : Exception
{
public DomainException(string message) : base(message)
{
}
}
}
+6
View File
@@ -0,0 +1,6 @@
namespace IM.DomainCommons
{
public interface IAggregateRoot
{
}
}
+12
View File
@@ -0,0 +1,12 @@
using MediatR;
namespace IM.DomainCommons
{
public interface IDomainEvents
{
IEnumerable<INotification> GetDomainEvents();
void AddDomainEvent(INotification eventItem);
void AddDomainEventIfAbsent(INotification eventItem);
void ClearDomainEvents();
}
}
+7
View File
@@ -0,0 +1,7 @@
namespace IM.DomainCommons
{
public interface IEntity
{
Guid Id { get; }
}
}
+7
View File
@@ -0,0 +1,7 @@
namespace IM.DomainCommons
{
public interface IHasCreationTime
{
DateTimeOffset CreationTime { get; }
}
}
+7
View File
@@ -0,0 +1,7 @@
namespace IM.DomainCommons
{
public interface IHasDeletionTime
{
DateTimeOffset? Deletion { get; }
}
}
+7
View File
@@ -0,0 +1,7 @@
namespace IM.DomainCommons
{
public interface IHasModificationTime
{
DateTimeOffset? ModificationTime { get; }
}
}
+14
View File
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MediatR" Version="14.1.0" />
<PackageReference Include="NewId" Version="4.0.1" />
</ItemGroup>
</Project>
+8
View File
@@ -0,0 +1,8 @@
namespace IM.DomainCommons
{
public interface ISoftDelete
{
bool IsDeleted { get; }
void SoftDelete();
}
}