diff --git a/src/Volo.Abp.Ddd.Domain/Volo.Abp.Ddd.Domain.csproj b/src/Volo.Abp.Ddd.Domain/Volo.Abp.Ddd.Domain.csproj index 582e812143..d01d1110cd 100644 --- a/src/Volo.Abp.Ddd.Domain/Volo.Abp.Ddd.Domain.csproj +++ b/src/Volo.Abp.Ddd.Domain/Volo.Abp.Ddd.Domain.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/AbpDddDomainModule.cs b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/AbpDddDomainModule.cs index f840fbc126..b8e306dbb5 100644 --- a/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/AbpDddDomainModule.cs +++ b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/AbpDddDomainModule.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Auditing; using Volo.Abp.Data; using Volo.Abp.EventBus; using Volo.Abp.Guids; @@ -11,6 +12,7 @@ using Volo.Abp.Uow; namespace Volo.Abp.Domain { [DependsOn( + typeof(AbpAuditingModule), typeof(AbpDataModule), typeof(AbpEventBusModule), typeof(AbpGuidsModule), diff --git a/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/AggregateRoot.cs b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/AggregateRoot.cs index cb6f0f4de1..8382a2dcd4 100644 --- a/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/AggregateRoot.cs +++ b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/AggregateRoot.cs @@ -1,22 +1,23 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel.DataAnnotations.Schema; namespace Volo.Abp.Domain.Entities { - /// - public abstract class AggregateRoot : IAggregateRoot + [Serializable] + public abstract class AggregateRoot : Entity, IAggregateRoot { - [NotMapped] //TODO: Better to handle in EF Core layer? + [NotMapped] //TODO: Better to handle in EF Core layer, or just use get/set methods instead of a property? public virtual ICollection DomainEvents => _domainEvents ?? (_domainEvents = new Collection()); private ICollection _domainEvents; } - /// + [Serializable] public abstract class AggregateRoot : Entity, IAggregateRoot { - [NotMapped] //TODO: Better to handle in EF Core layer? + [NotMapped] //TODO: Better to handle in EF Core layer, or just use get/set methods instead of a property?? public virtual ICollection DomainEvents => _domainEvents ?? (_domainEvents = new Collection()); private ICollection _domainEvents; diff --git a/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRoot.cs b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRoot.cs new file mode 100644 index 0000000000..8b56f86054 --- /dev/null +++ b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRoot.cs @@ -0,0 +1,32 @@ +using System; +using Volo.Abp.Auditing; + +namespace Volo.Abp.Domain.Entities.Auditing +{ + /// + /// This class can be used to simplify implementing for aggregate roots. + /// + [Serializable] + public abstract class AuditedAggregateRoot : CreationAuditedAggregateRoot, IAudited + { + /// + public virtual DateTime? LastModificationTime { get; set; } + + /// + public virtual long? LastModifierUserId { get; set; } + } + + /// + /// This class can be used to simplify implementing for aggregate roots. + /// + /// Type of the primary key of the entity + [Serializable] + public abstract class AuditedAggregateRoot : CreationAuditedAggregateRoot, IAudited + { + /// + public virtual DateTime? LastModificationTime { get; set; } + + /// + public virtual long? LastModifierUserId { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRootWithUser.cs b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRootWithUser.cs new file mode 100644 index 0000000000..95812c3160 --- /dev/null +++ b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedAggregateRootWithUser.cs @@ -0,0 +1,36 @@ +using System; +using Volo.Abp.Auditing; + +namespace Volo.Abp.Domain.Entities.Auditing +{ + /// + /// This class can be used to simplify implementing for aggregate roots. + /// + /// Type of the user + [Serializable] + public abstract class AuditedAggregateRootWithUser : AuditedAggregateRoot, IAudited + where TUser : IEntity + { + /// + public virtual TUser CreatorUser { get; set; } + + /// + public virtual TUser LastModifierUser { get; set; } + } + + /// + /// This class can be used to simplify implementing for aggregate roots. + /// + /// Type of the primary key of the entity + /// Type of the user + [Serializable] + public abstract class AuditedAggregateRootWithUser : AuditedAggregateRoot, IAudited + where TUser : IEntity + { + /// + public virtual TUser CreatorUser { get; set; } + + /// + public virtual TUser LastModifierUser { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntity.cs b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntity.cs new file mode 100644 index 0000000000..5c518a41ab --- /dev/null +++ b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntity.cs @@ -0,0 +1,32 @@ +using System; +using Volo.Abp.Auditing; + +namespace Volo.Abp.Domain.Entities.Auditing +{ + /// + /// This class can be used to simplify implementing . + /// + [Serializable] + public abstract class AuditedEntity : CreationAuditedEntity, IAudited + { + /// + public virtual DateTime? LastModificationTime { get; set; } + + /// + public virtual long? LastModifierUserId { get; set; } + } + + /// + /// This class can be used to simplify implementing . + /// + /// Type of the primary key of the entity + [Serializable] + public abstract class AuditedEntity : CreationAuditedEntity, IAudited + { + /// + public virtual DateTime? LastModificationTime { get; set; } + + /// + public virtual long? LastModifierUserId { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntityWithUser.cs b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntityWithUser.cs new file mode 100644 index 0000000000..be410c89ee --- /dev/null +++ b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/AuditedEntityWithUser.cs @@ -0,0 +1,36 @@ +using System; +using Volo.Abp.Auditing; + +namespace Volo.Abp.Domain.Entities.Auditing +{ + /// + /// This class can be used to simplify implementing . + /// + /// Type of the user + [Serializable] + public abstract class AuditedEntityWithUser : AuditedEntity, IAudited + where TUser : IEntity + { + /// + public virtual TUser CreatorUser { get; set; } + + /// + public virtual TUser LastModifierUser { get; set; } + } + + /// + /// This class can be used to simplify implementing . + /// + /// Type of the primary key of the entity + /// Type of the user + [Serializable] + public abstract class AuditedEntityWithUser : AuditedEntity, IAudited + where TUser : IEntity + { + /// + public virtual TUser CreatorUser { get; set; } + + /// + public virtual TUser LastModifierUser { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRoot.cs b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRoot.cs new file mode 100644 index 0000000000..d22534fc9b --- /dev/null +++ b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRoot.cs @@ -0,0 +1,32 @@ +using System; +using Volo.Abp.Auditing; + +namespace Volo.Abp.Domain.Entities.Auditing +{ + /// + /// This class can be used to simplify implementing for aggregate roots. + /// + [Serializable] + public abstract class CreationAuditedAggregateRoot : AggregateRoot, ICreationAudited + { + /// + public virtual DateTime CreationTime { get; set; } + + /// + public virtual long? CreatorUserId { get; set; } + } + + /// + /// This class can be used to simplify implementing for aggregate roots. + /// + /// Type of the primary key of the entity + [Serializable] + public abstract class CreationAuditedAggregateRoot : AggregateRoot, ICreationAudited + { + /// + public virtual DateTime CreationTime { get; set; } + + /// + public virtual long? CreatorUserId { get; set; } + } +} diff --git a/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRootWithUser.cs b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRootWithUser.cs new file mode 100644 index 0000000000..1487dbeedc --- /dev/null +++ b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedAggregateRootWithUser.cs @@ -0,0 +1,28 @@ +using System; +using Volo.Abp.Auditing; + +namespace Volo.Abp.Domain.Entities.Auditing +{ + /// + /// This class can be used to simplify implementing for aggregate roots. + /// + /// Type of the user + [Serializable] + public abstract class CreationAuditedAggregateRootWithUser : CreationAuditedAggregateRoot, ICreationAudited + { + /// + public virtual TUser CreatorUser { get; set; } + } + + /// + /// This class can be used to simplify implementing for aggregate roots. + /// + /// Type of the primary key of the entity + /// Type of the user + [Serializable] + public abstract class CreationAuditedAggregateRootWithUser : CreationAuditedAggregateRoot, ICreationAudited + { + /// + public virtual TUser CreatorUser { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntity.cs b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntity.cs new file mode 100644 index 0000000000..e470a1ee39 --- /dev/null +++ b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntity.cs @@ -0,0 +1,32 @@ +using System; +using Volo.Abp.Auditing; + +namespace Volo.Abp.Domain.Entities.Auditing +{ + /// + /// This class can be used to simplify implementing for an entity. + /// + [Serializable] + public abstract class CreationAuditedEntity : Entity, ICreationAudited + { + /// + public virtual DateTime CreationTime { get; set; } + + /// + public virtual long? CreatorUserId { get; set; } + } + + /// + /// This class can be used to simplify implementing for an entity. + /// + /// Type of the primary key of the entity + [Serializable] + public abstract class CreationAuditedEntity : Entity, ICreationAudited + { + /// + public virtual DateTime CreationTime { get; set; } + + /// + public virtual long? CreatorUserId { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntityWithUser.cs b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntityWithUser.cs new file mode 100644 index 0000000000..9c01bffcba --- /dev/null +++ b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/CreationAuditedEntityWithUser.cs @@ -0,0 +1,28 @@ +using System; +using Volo.Abp.Auditing; + +namespace Volo.Abp.Domain.Entities.Auditing +{ + /// + /// This class can be used to simplify implementing . + /// + /// Type of the user + [Serializable] + public abstract class CreationAuditedEntityWithUser : CreationAuditedEntity, ICreationAudited + { + /// + public virtual TUser CreatorUser { get; set; } + } + + /// + /// This class can be used to simplify implementing . + /// + /// Type of the primary key of the entity + /// Type of the user + [Serializable] + public abstract class CreationAuditedEntityWithUser : CreationAuditedEntity, ICreationAudited + { + /// + public virtual TUser CreatorUser { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRoot.cs b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRoot.cs new file mode 100644 index 0000000000..824d8a4c94 --- /dev/null +++ b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRoot.cs @@ -0,0 +1,38 @@ +using System; +using Volo.Abp.Auditing; + +namespace Volo.Abp.Domain.Entities.Auditing +{ + /// + /// Implements to be a base class for full-audited aggregate roots. + /// + [Serializable] + public abstract class FullAuditedAggregateRoot : AuditedAggregateRoot, IFullAudited + { + /// + public virtual bool IsDeleted { get; set; } + + /// + public virtual long? DeleterUserId { get; set; } + + /// + public virtual DateTime? DeletionTime { get; set; } + } + + /// + /// Implements to be a base class for full-audited aggregate roots. + /// + /// Type of the primary key of the entity + [Serializable] + public abstract class FullAuditedAggregateRoot : AuditedAggregateRoot, IFullAudited + { + /// + public virtual bool IsDeleted { get; set; } + + /// + public virtual long? DeleterUserId { get; set; } + + /// + public virtual DateTime? DeletionTime { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRootWithUser.cs b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRootWithUser.cs new file mode 100644 index 0000000000..c99f24cfa0 --- /dev/null +++ b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedAggregateRootWithUser.cs @@ -0,0 +1,42 @@ +using System; +using Volo.Abp.Auditing; + +namespace Volo.Abp.Domain.Entities.Auditing +{ + /// + /// Implements to be a base class for full-audited aggregate roots. + /// + /// Type of the user + [Serializable] + public abstract class FullAuditedAggregateRootWithUser : FullAuditedAggregateRoot, IFullAudited + where TUser : IEntity + { + /// + public virtual TUser DeleterUser { get; set; } + + /// + public TUser CreatorUser { get; set; } + + /// + public TUser LastModifierUser { get; set; } + } + + /// + /// Implements to be a base class for full-audited aggregate roots. + /// + /// Type of the primary key of the entity + /// Type of the user + [Serializable] + public abstract class FullAuditedAggregateRootWithUser : FullAuditedAggregateRoot, IFullAudited + where TUser : IEntity + { + /// + public virtual TUser DeleterUser { get; set; } + + /// + public TUser CreatorUser { get; set; } + + /// + public TUser LastModifierUser { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntity.cs b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntity.cs new file mode 100644 index 0000000000..4318d52544 --- /dev/null +++ b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntity.cs @@ -0,0 +1,38 @@ +using System; +using Volo.Abp.Auditing; + +namespace Volo.Abp.Domain.Entities.Auditing +{ + /// + /// Implements to be a base class for full-audited entities. + /// + [Serializable] + public abstract class FullAuditedEntity : AuditedEntity, IFullAudited + { + /// + public virtual bool IsDeleted { get; set; } + + /// + public virtual long? DeleterUserId { get; set; } + + /// + public virtual DateTime? DeletionTime { get; set; } + } + + /// + /// Implements to be a base class for full-audited entities. + /// + /// Type of the primary key of the entity + [Serializable] + public abstract class FullAuditedEntity : AuditedEntity, IFullAudited + { + /// + public virtual bool IsDeleted { get; set; } + + /// + public virtual long? DeleterUserId { get; set; } + + /// + public virtual DateTime? DeletionTime { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntityWithUser.cs b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntityWithUser.cs new file mode 100644 index 0000000000..683cb2dd5c --- /dev/null +++ b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Auditing/FullAuditedEntityWithUser.cs @@ -0,0 +1,42 @@ +using System; +using Volo.Abp.Auditing; + +namespace Volo.Abp.Domain.Entities.Auditing +{ + /// + /// Implements to be a base class for full-audited entities. + /// + /// Type of the user + [Serializable] + public abstract class FullAuditedEntityWithUser : FullAuditedEntity, IFullAudited + where TUser : IEntity + { + /// + public virtual TUser DeleterUser { get; set; } + + /// + public TUser CreatorUser { get; set; } + + /// + public TUser LastModifierUser { get; set; } + } + + /// + /// Implements to be a base class for full-audited entities. + /// + /// Type of the primary key of the entity + /// Type of the user + [Serializable] + public abstract class FullAuditedEntityWithUser : FullAuditedEntity, IFullAudited + where TUser : IEntity + { + /// + public virtual TUser DeleterUser { get; set; } + + /// + public TUser CreatorUser { get; set; } + + /// + public TUser LastModifierUser { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Entity.cs b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Entity.cs index 638ff0d3e1..25e6fdd443 100644 --- a/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Entity.cs +++ b/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Entity.cs @@ -5,6 +5,7 @@ using Volo.Abp.MultiTenancy; namespace Volo.Abp.Domain.Entities { /// + [Serializable] public abstract class Entity : IEntity { /// @@ -15,6 +16,7 @@ namespace Volo.Abp.Domain.Entities } /// + [Serializable] public abstract class Entity : Entity, IEntity { ///