feat(bff): Add App Version management endpoints
Build and Deploy to Production / build-and-deploy (push) Successful in 1m47s
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:
@@ -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
|
||||
}
|
||||
|
||||
+39
@@ -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; }
|
||||
}
|
||||
+39
@@ -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;
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
namespace BackOffice.BFF.Application.ConfigurationCQ.Queries.GetAllAppVersions;
|
||||
|
||||
public class GetAllAppVersionsQuery : IRequest<GetAllAppVersionsResponseDto>
|
||||
{
|
||||
public bool IncludeInactive { get; set; }
|
||||
}
|
||||
+40
@@ -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()
|
||||
};
|
||||
}
|
||||
}
|
||||
+20
@@ -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; }
|
||||
}
|
||||
Reference in New Issue
Block a user