backend phase 0: foundation, cross-cutting seams & starter cleanup
Remove the Order demo (entity/feature/repo/config/gRPC/proto) and the three pre-marketplace migrations; regenerate a fresh InitialBaseline migration. Stand up the REST surface (PingController + System/Ping CQRS) proving the Mediator -> behaviors -> OperationResult -> ApiResult envelope end to end. Close wiring gaps: register LoggingBehavior (outermost) and add the built-in rate limiter (per-IP global + otp/auth/sensitive policies), placed before authentication. Add current-user + audit plumbing: ICurrentUser (HttpContext + null impls), rename BaseEntity audit fields to CreatedAt/ModifiedAt (DateTimeOffset) + CreatedById/ModifiedById, stamped by a new AuditFieldInterceptor. Introduce five cross-cutting seams (IDateTimeProvider, IFieldEncryptor, ICacheService, IObjectStorage, INotificationDispatcher) with in-memory/local mocks registered via AddCrossCuttingSeams. Add Baya.Test.Foundation (encryptor, audit interceptor, ping handler) and update docs, contracts (swagger.v1.json), handoff, report, and mocks registry.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
namespace Baya.Domain.Common;
|
||||
namespace Baya.Domain.Common;
|
||||
|
||||
public interface IEntity
|
||||
{
|
||||
@@ -6,11 +6,21 @@ public interface IEntity
|
||||
|
||||
public interface ITimeModification
|
||||
{
|
||||
DateTime CreatedTime { get; set; }
|
||||
DateTime? ModifiedDate { get; set; }
|
||||
DateTimeOffset CreatedAt { get; set; }
|
||||
DateTimeOffset? ModifiedAt { get; set; }
|
||||
}
|
||||
|
||||
public abstract class BaseEntity<TKey> : IEntity, ITimeModification
|
||||
/// <summary>
|
||||
/// An entity whose create/modify timestamps and the acting user are stamped automatically by the
|
||||
/// SaveChanges audit interceptor — handlers must never set these fields themselves.
|
||||
/// </summary>
|
||||
public interface IAuditableEntity : ITimeModification
|
||||
{
|
||||
int? CreatedById { get; set; }
|
||||
int? ModifiedById { get; set; }
|
||||
}
|
||||
|
||||
public abstract class BaseEntity<TKey> : IEntity, IAuditableEntity
|
||||
{
|
||||
public TKey Id { get; protected set; }
|
||||
|
||||
@@ -49,11 +59,13 @@ public abstract class BaseEntity<TKey> : IEntity, ITimeModification
|
||||
return (GetType().ToString() + Id).GetHashCode();
|
||||
}
|
||||
|
||||
public DateTime CreatedTime { get; set; }
|
||||
public DateTime? ModifiedDate { get; set; }
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
public DateTimeOffset? ModifiedAt { get; set; }
|
||||
public int? CreatedById { get; set; }
|
||||
public int? ModifiedById { get; set; }
|
||||
}
|
||||
|
||||
public abstract class BaseEntity : BaseEntity<int>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
using Baya.Domain.Common;
|
||||
|
||||
namespace Baya.Domain.Entities.Order;
|
||||
|
||||
public class Order:BaseEntity
|
||||
{
|
||||
public string OrderName { get; set; }
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
#region Navigation Properties
|
||||
|
||||
public User.User User { get; set; }
|
||||
public int UserId { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -19,11 +19,4 @@ public class User:IdentityUser<int>,IEntity
|
||||
public ICollection<UserClaim> Claims { get; set; }
|
||||
public ICollection<UserToken> Tokens { get; set; }
|
||||
public ICollection<UserRefreshToken> UserRefreshTokens { get; set; }
|
||||
|
||||
#region Navigation Properties
|
||||
|
||||
public IList<Order.Order> Orders { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -1,16 +1,10 @@
|
||||
using Baya.Domain.Common;
|
||||
using Baya.Domain.Common;
|
||||
|
||||
namespace Baya.Domain.Entities.User;
|
||||
|
||||
public class UserRefreshToken:BaseEntity<Guid>
|
||||
{
|
||||
public UserRefreshToken()
|
||||
{
|
||||
CreatedAt=DateTime.Now;
|
||||
}
|
||||
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public bool IsValid { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user