feat(bff): Add App Version management endpoints
Build and Deploy to Production / build-and-deploy (push) Successful in 1m47s

- Add appversion.proto with GetAll, Get, Update RPCs
- Add GetAllAppVersionsQuery and handler
- Add UpdateAppVersionCommand and handler
- Add AppVersionService gRPC service
- Add AppVersionProfile for Mapster mappings
- Update IApplicationContractContext with AppVersions client
- Bump Configuration.Protobuf to 1.0.20
This commit is contained in:
masoodafar-web
2025-12-26 06:07:24 +03:30
parent 8f34f0f650
commit 6bc45e4486
12 changed files with 340 additions and 2 deletions
@@ -23,6 +23,7 @@ using CMSMicroservice.Protobuf.Protos.Configuration;
using CMSMicroservice.Protobuf.Protos.DiscountOrder;
using CMSMicroservice.Protobuf.Protos.ManualPayment;
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
using CMSMicroservice.Protobuf.Protos.AppVersion;
namespace BackOffice.BFF.Application.Common.Interfaces;
@@ -65,6 +66,9 @@ public interface IApplicationContractContext
// Manual Payments (Admin) - BackOffice BFF gRPC
ManualPaymentContract.ManualPaymentContractClient ManualPayments { get; }
// App Version Management
AppVersionContract.AppVersionContractClient AppVersions { get; }
#endregion
}
@@ -0,0 +1,39 @@
namespace BackOffice.BFF.Application.ConfigurationCQ.Commands.UpdateAppVersion;
public class UpdateAppVersionCommand : IRequest<Unit>
{
/// <summary>
/// نام اپلیکیشن (FrontOffice, BackOffice, Mobile)
/// </summary>
public string AppName { get; set; } = string.Empty;
/// <summary>
/// ورژن فعلی
/// </summary>
public string CurrentVersion { get; set; } = string.Empty;
/// <summary>
/// حداقل ورژن مورد نیاز
/// </summary>
public string? MinRequiredVersion { get; set; }
/// <summary>
/// آیا نیاز به پاک کردن کامل کش دارد؟
/// </summary>
public bool RequiresFullCacheClear { get; set; }
/// <summary>
/// پیام آپدیت برای کاربران
/// </summary>
public string? UpdateMessage { get; set; }
/// <summary>
/// یادداشت‌های نسخه
/// </summary>
public string? ReleaseNotes { get; set; }
/// <summary>
/// دلیل آپدیت (برای لاگ ادمین)
/// </summary>
public string? UpdateReason { get; set; }
}
@@ -0,0 +1,39 @@
using CMSMicroservice.Protobuf.Protos.AppVersion;
namespace BackOffice.BFF.Application.ConfigurationCQ.Commands.UpdateAppVersion;
public class UpdateAppVersionCommandHandler : IRequestHandler<UpdateAppVersionCommand, Unit>
{
private readonly IApplicationContractContext _context;
public UpdateAppVersionCommandHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<Unit> Handle(UpdateAppVersionCommand request, CancellationToken cancellationToken)
{
var cmsRequest = new UpdateAppVersionRequest
{
AppName = request.AppName,
CurrentVersion = request.CurrentVersion,
RequiresFullCacheClear = request.RequiresFullCacheClear
};
if (!string.IsNullOrEmpty(request.MinRequiredVersion))
cmsRequest.MinRequiredVersion = request.MinRequiredVersion;
if (!string.IsNullOrEmpty(request.UpdateMessage))
cmsRequest.UpdateMessage = request.UpdateMessage;
if (!string.IsNullOrEmpty(request.ReleaseNotes))
cmsRequest.ReleaseNotes = request.ReleaseNotes;
if (!string.IsNullOrEmpty(request.UpdateReason))
cmsRequest.UpdateReason = request.UpdateReason;
await _context.AppVersions.UpdateAppVersionAsync(cmsRequest, cancellationToken: cancellationToken);
return Unit.Value;
}
}
@@ -0,0 +1,6 @@
namespace BackOffice.BFF.Application.ConfigurationCQ.Queries.GetAllAppVersions;
public class GetAllAppVersionsQuery : IRequest<GetAllAppVersionsResponseDto>
{
public bool IncludeInactive { get; set; }
}
@@ -0,0 +1,40 @@
using CMSMicroservice.Protobuf.Protos.AppVersion;
namespace BackOffice.BFF.Application.ConfigurationCQ.Queries.GetAllAppVersions;
public class GetAllAppVersionsQueryHandler : IRequestHandler<GetAllAppVersionsQuery, GetAllAppVersionsResponseDto>
{
private readonly IApplicationContractContext _context;
public GetAllAppVersionsQueryHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<GetAllAppVersionsResponseDto> Handle(GetAllAppVersionsQuery request, CancellationToken cancellationToken)
{
var cmsRequest = new GetAllAppVersionsRequest
{
IncludeInactive = request.IncludeInactive
};
var response = await _context.AppVersions.GetAllAppVersionsAsync(cmsRequest, cancellationToken: cancellationToken);
return new GetAllAppVersionsResponseDto
{
Items = response.Items.Select(item => new AppVersionItemDto
{
Id = item.Id,
AppName = item.AppName,
CurrentVersion = item.CurrentVersion,
MinRequiredVersion = item.MinRequiredVersion,
RequiresFullCacheClear = item.RequiresFullCacheClear,
UpdateMessage = item.UpdateMessage,
ReleaseNotes = item.ReleaseNotes,
IsActive = item.IsActive,
Created = item.Created?.ToDateTimeOffset() ?? DateTimeOffset.MinValue,
LastModified = item.LastModified?.ToDateTimeOffset() ?? DateTimeOffset.MinValue
}).ToList()
};
}
}
@@ -0,0 +1,20 @@
namespace BackOffice.BFF.Application.ConfigurationCQ.Queries.GetAllAppVersions;
public class GetAllAppVersionsResponseDto
{
public List<AppVersionItemDto> Items { get; set; } = new();
}
public class AppVersionItemDto
{
public long Id { get; set; }
public string AppName { get; set; } = string.Empty;
public string CurrentVersion { get; set; } = string.Empty;
public string MinRequiredVersion { get; set; } = string.Empty;
public bool RequiresFullCacheClear { get; set; }
public string? UpdateMessage { get; set; }
public string? ReleaseNotes { get; set; }
public bool IsActive { get; set; }
public DateTimeOffset Created { get; set; }
public DateTimeOffset LastModified { get; set; }
}