refactor: rename UserWalletChangeLog→UserWalletHistory, add History interceptor & migration
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 9m11s
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 9m11s
- Rename UserWalletChangeLog to UserWalletHistory across 54+ files (entities, configs, DTOs, commands, queries, protos, services) - Rename 34 files and 11 directories accordingly - Rename proto file userwalletchangelog.proto → userwallethistory.proto - Add IHasHistory<T> generic interface for history auto-tracking - Implement IHasHistory<PackageHistory> on Package entity - Add HistoryTrackingSaveChangesInterceptor (reflection-based, auto-fills Old* values from OriginalValues) - Wire interceptor in DI and ApplicationDbContext - Add EF migration Q27_HistoryTables_And_RenameWalletHistory: * RenameTable UserWalletChangeLogs → UserWalletHistories (preserves data) * Rename PK, FK constraints and indexes via sp_rename * CreateTable ClubMembershipCycleHistories + PackageHistories
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
namespace CMSMicroservice.Domain.Common;
|
||||
|
||||
/// <summary>
|
||||
/// اینترفیس مارکر برای entityهایی که تاریخچه تغییرات خودکار دارند (Q27).
|
||||
/// هر entity که این اینترفیس رو implement کنه، در SaveChanges interceptor
|
||||
/// بهصورت خودکار یک snapshot از تغییرات ثبت میشه.
|
||||
/// </summary>
|
||||
/// <typeparam name="THistory">نوع entity تاریخچه (مثلاً PackageHistory)</typeparam>
|
||||
public interface IHasHistory<THistory> where THistory : BaseAuditableEntity, new()
|
||||
{
|
||||
/// <summary>
|
||||
/// ساخت snapshot تاریخچه از وضعیت فعلی entity.
|
||||
/// اطلاعات Original (قبل از تغییر) و Current (بعد از تغییر) باید مقایسه شوند.
|
||||
/// </summary>
|
||||
/// <param name="action">نوع عملیات (Created, Updated, etc.) — as string to be generic</param>
|
||||
/// <param name="performedBy">چه کسی انجام داده</param>
|
||||
/// <returns>یک رکورد تاریخچه آماده ذخیره</returns>
|
||||
THistory CreateHistorySnapshot(string action, string? performedBy);
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
using CMSMicroservice.Domain.Common;
|
||||
using CMSMicroservice.Domain.Enums;
|
||||
|
||||
namespace CMSMicroservice.Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// پکیج — هر پکیج قیمت، ویژگیها و تنظیمات مستقل دارد
|
||||
/// </summary>
|
||||
public class Package : BaseAuditableEntity
|
||||
public class Package : BaseAuditableEntity, IHasHistory<History.PackageHistory>
|
||||
{
|
||||
// === فیلدهای فعلی (حفظ) ===
|
||||
|
||||
@@ -76,4 +79,23 @@ public class Package : BaseAuditableEntity
|
||||
|
||||
/// <summary>تاریخچه تغییرات پکیج (Q27)</summary>
|
||||
public virtual ICollection<History.PackageHistory>? PackageHistories { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ساخت snapshot تاریخچه — Q27 auto-tracking
|
||||
/// </summary>
|
||||
public History.PackageHistory CreateHistorySnapshot(string action, string? performedBy)
|
||||
{
|
||||
return new History.PackageHistory
|
||||
{
|
||||
PackageId = Id,
|
||||
NewPrice = Price,
|
||||
NewActivationFee = ActivationFee,
|
||||
NewMagicMultiplier = MagicWalletMultiplier,
|
||||
NewMagicMaxDeposit = MagicWalletMaxDeposit,
|
||||
NewMaxBalancesPerLeg = MaxBalancesPerLeg,
|
||||
NewIsActive = IsActive,
|
||||
Action = Enum.TryParse<PackageAction>(action, out var a) ? a : PackageAction.Updated,
|
||||
PerformedBy = performedBy
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,6 @@ public class UserWallet : BaseAuditableEntity
|
||||
|
||||
#endregion
|
||||
|
||||
//UserWalletChangeLog Collection Navigation Reference
|
||||
public virtual ICollection<UserWalletChangeLog> UserWalletChangeLogs { get; set; }
|
||||
//UserWalletHistory Collection Navigation Reference
|
||||
public virtual ICollection<UserWalletHistory> UserWalletHistories { get; set; }
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
namespace CMSMicroservice.Domain.Entities;
|
||||
//آدرس کاربر
|
||||
public class UserWalletChangeLog : BaseAuditableEntity
|
||||
public class UserWalletHistory : BaseAuditableEntity
|
||||
{
|
||||
//شناسه کیف پول
|
||||
public long WalletId { get; set; }
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
namespace CMSMicroservice.Domain.Events;
|
||||
public class CreateNewUserWalletChangeLogEvent : BaseEvent
|
||||
{
|
||||
public CreateNewUserWalletChangeLogEvent(UserWalletChangeLog item)
|
||||
{
|
||||
}
|
||||
public UserWalletChangeLog Item { get; }
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
namespace CMSMicroservice.Domain.Events;
|
||||
public class DeleteUserWalletChangeLogEvent : BaseEvent
|
||||
{
|
||||
public DeleteUserWalletChangeLogEvent(UserWalletChangeLog item)
|
||||
{
|
||||
}
|
||||
public UserWalletChangeLog Item { get; }
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
namespace CMSMicroservice.Domain.Events;
|
||||
public class UpdateUserWalletChangeLogEvent : BaseEvent
|
||||
{
|
||||
public UpdateUserWalletChangeLogEvent(UserWalletChangeLog item)
|
||||
{
|
||||
}
|
||||
public UserWalletChangeLog Item { get; }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
namespace CMSMicroservice.Domain.Events;
|
||||
public class CreateNewUserWalletHistoryEvent : BaseEvent
|
||||
{
|
||||
public CreateNewUserWalletHistoryEvent(UserWalletHistory item)
|
||||
{
|
||||
}
|
||||
public UserWalletHistory Item { get; }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
namespace CMSMicroservice.Domain.Events;
|
||||
public class DeleteUserWalletHistoryEvent : BaseEvent
|
||||
{
|
||||
public DeleteUserWalletHistoryEvent(UserWalletHistory item)
|
||||
{
|
||||
}
|
||||
public UserWalletHistory Item { get; }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
namespace CMSMicroservice.Domain.Events;
|
||||
public class UpdateUserWalletHistoryEvent : BaseEvent
|
||||
{
|
||||
public UpdateUserWalletHistoryEvent(UserWalletHistory item)
|
||||
{
|
||||
}
|
||||
public UserWalletHistory Item { get; }
|
||||
}
|
||||
Reference in New Issue
Block a user