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:
+7
@@ -0,0 +1,7 @@
|
||||
namespace CMSMicroservice.Application.UserWalletHistoryCQ.Queries.GetUserWalletHistory;
|
||||
public record GetUserWalletHistoryQuery : IRequest<GetUserWalletHistoryResponseDto>
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; init; }
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
namespace CMSMicroservice.Application.UserWalletHistoryCQ.Queries.GetUserWalletHistory;
|
||||
public class GetUserWalletHistoryQueryHandler : IRequestHandler<GetUserWalletHistoryQuery, GetUserWalletHistoryResponseDto>
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
|
||||
public GetUserWalletHistoryQueryHandler(IApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetUserWalletHistoryResponseDto> Handle(GetUserWalletHistoryQuery request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _context.UserWalletHistories
|
||||
.AsNoTracking()
|
||||
.Where(x => x.Id == request.Id)
|
||||
.ProjectToType<GetUserWalletHistoryResponseDto>()
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
|
||||
return response ?? throw new NotFoundException(nameof(UserWalletHistory), request.Id);
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
namespace CMSMicroservice.Application.UserWalletHistoryCQ.Queries.GetUserWalletHistory;
|
||||
public class GetUserWalletHistoryQueryValidator : AbstractValidator<GetUserWalletHistoryQuery>
|
||||
{
|
||||
public GetUserWalletHistoryQueryValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<GetUserWalletHistoryQuery>.CreateWithOptions((GetUserWalletHistoryQuery)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
namespace CMSMicroservice.Application.UserWalletHistoryCQ.Queries.GetUserWalletHistory;
|
||||
public class GetUserWalletHistoryResponseDto
|
||||
{
|
||||
//شناسه
|
||||
public long Id { get; set; }
|
||||
//شناسه کیف پول
|
||||
public long WalletId { get; set; }
|
||||
//موجودی
|
||||
public long CurrentBalance { get; set; }
|
||||
//تغییر موجودی
|
||||
public long ChangeValue { get; set; }
|
||||
//موجودی جاری شبکه
|
||||
public long CurrentNetworkBalance { get; set; }
|
||||
//تغییر موجودی شبکه
|
||||
public long ChangeNerworkValue { get; set; }
|
||||
//افزایشی؟
|
||||
public bool IsIncrease { get; set; }
|
||||
//شناسه ارجاع
|
||||
public long? RefrenceId { get; set; }
|
||||
//تاریخ ایجاد
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user