Compare commits

...

18 Commits

Author SHA1 Message Date
masoodafar-web 0336120193 chore: Update production workflow to use Nexus registry (no proxy needed)
Build and Deploy to Production / build-and-deploy (push) Failing after 0s
- Changed Dockerfile base images to use 194.5.195.53:32082 (Nexus)
- Updated workflow to use docker-sshpass image from Nexus
- Removed HTTP_PROXY/HTTPS_PROXY dependencies
- Changed deploy method to SSH instead of kubeconfig
- Registry: 194.5.195.53:30080 (Gitea internal)
- K8S Server: 45.149.79.127 (Production)
2026-01-29 22:04:31 +03:30
masoodafar-web 721207f6a0 feat: update GetUserWeeklyBalances response structure and mappings
Build and Deploy / build (push) Successful in 1m47s
Build and Deploy to Production / build-and-deploy (push) Successful in 2m22s
2025-12-27 22:10:30 +03:30
masoodafar-web ce7683c736 feat: enhance GetWithdrawalRequests response structure and update related mappings
Build and Deploy / build (push) Failing after 1m11s
2025-12-27 21:52:50 +03:30
masoodafar-web f5e7d0c882 feat: add mapping for ProcessWithdrawalRequest to ProcessWithdrawalCommand
Build and Deploy / build (push) Successful in 1m39s
Build and Deploy to Production / build-and-deploy (push) Successful in 1m45s
2025-12-27 07:23:00 +03:30
masoodafar-web 86d1370535 feat: implement mapping for GetUserPayoutsResponseDto to GetUserCommissionPayoutsResponse
Build and Deploy / build (push) Successful in 1m58s
2025-12-27 06:45:59 +03:30
masoodafar-web 92aebb42b5 feat: add mapping for MediatR.Unit to Google.Protobuf.Empty
Build and Deploy / build (push) Successful in 1m48s
2025-12-27 02:38:02 +03:30
masoodafar-web c7fc30c83e feat: update Foursat.CMSMicroservice.Protobuf package version and add mapping for GetAllWeeklyPoolsResponse
Build and Deploy / build (push) Successful in 1m48s
2025-12-26 09:44:58 +03:30
masoodafar-web 4c5cff1a9a fix: update CMSMSAddress to remove port from URL
Build and Deploy / build (push) Successful in 1m44s
2025-12-26 07:34:21 +03:30
masoodafar-web 6bc45e4486 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
2025-12-26 06:07:24 +03:30
masoodafar-web 8f34f0f650 fix: update CMSMSAddress to use secure URL
Build and Deploy to Production / build-and-deploy (push) Successful in 2m17s
2025-12-25 02:22:45 +03:30
masoodafar-web 554d1a65f2 feat: add production appsettings configuration for JWT and Seq
Build and Deploy to Production / build-and-deploy (push) Successful in 2m31s
2025-12-25 02:07:19 +03:30
admin f695290577 fix: correct dockerfile path and registry
Build and Deploy to Production / build-and-deploy (push) Successful in 1m45s
2025-12-23 22:32:25 +00:00
admin 13352879b9 fix: correct dockerfile path and registry
Build and Deploy to Production / build-and-deploy (push) Has been cancelled
2025-12-23 22:32:19 +00:00
admin 464b3e0c1d ci: re-trigger production build
Build and Deploy to Production / build-and-deploy (push) Failing after 17s
2025-12-23 22:31:03 +00:00
admin e627220c98 feat: add production deployment workflow
Build and Deploy to Production / build-and-deploy (push) Failing after 12s
2025-12-23 22:19:23 +00:00
admin 5f7f2a3355 fix: update appsettings for production K8s 2025-12-23 22:16:11 +00:00
admin b8b8a72e57 fix: update appsettings for production K8s 2025-12-23 22:15:51 +00:00
admin b223e37782 fix: update appsettings for production K8s 2025-12-23 22:15:31 +00:00
24 changed files with 625 additions and 95 deletions
+68
View File
@@ -0,0 +1,68 @@
name: Build and Deploy to Production
on:
push:
branches:
- production
env:
REGISTRY: 194.5.195.53:30080
IMAGE_NAME: admin/backoffice-bff
K8S_SERVER: 45.149.79.127
jobs:
build-and-deploy:
runs-on: ubuntu-latest
container:
image: 194.5.195.53:32082/docker-sshpass:latest
options: --privileged
steps:
- name: Start Docker daemon
run: |
mkdir -p /etc/docker
cat > /etc/docker/daemon.json << 'DAEMON'
{
"insecure-registries": ["194.5.195.53:30080", "194.5.195.53:32082"]
}
DAEMON
echo "🚀 Starting Docker daemon..."
dockerd &
for i in $(seq 1 90); do
if docker info >/dev/null 2>&1; then
echo "✅ Docker daemon is ready (attempt $i)"
docker version
break
else
echo "⏳ Waiting for Docker daemon... (attempt $i/90)"
sleep 2
fi
done
if ! docker info >/dev/null 2>&1; then
echo "❌ Docker daemon failed to start"
exit 1
fi
- name: Checkout code
run: |
git clone --depth 1 --branch production http://gitea-svc:3000/admin/BackOffice.BFF.git .
- name: Build Docker Image
run: |
cd src
docker build -f BackOffice.BFF.WebApi/Dockerfile \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:prod \
.
- name: Push to Registry
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ env.REGISTRY }} -u admin --password-stdin
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:prod
- name: Deploy to Production
run: |
sshpass -p "${{ secrets.K8S_SSH_PASSWORD }}" ssh -o StrictHostKeyChecking=no root@${{ env.K8S_SERVER }} \
"kubectl rollout restart deployment/backoffice-bff && kubectl rollout status deployment/backoffice-bff --timeout=5m" || echo "Deployment pending"
@@ -10,10 +10,15 @@ public record UserWeeklyBalanceDto
{
public long Id { get; init; }
public long UserId { get; init; }
public string UserFullName { get; init; } = string.Empty;
public long WeekDefinitionId { get; init; }
public string WeekDisplayName { get; init; } = string.Empty;
public int LeftLegBalances { get; init; }
public int RightLegBalances { get; init; }
public int LeftLegNewMembers { get; init; }
public int LeftLegCarryover { get; init; }
public int LeftLegTotal { get; init; }
public int RightLegNewMembers { get; init; }
public int RightLegCarryover { get; init; }
public int RightLegTotal { get; init; }
public int TotalBalances { get; init; }
public long WeeklyPoolContribution { get; init; }
public DateTime? CalculatedAt { get; init; }
@@ -37,6 +37,35 @@ public class GetWithdrawalRequestsQueryHandler : IRequestHandler<GetWithdrawalRe
}
var response = await _context.Commissions.GetWithdrawalRequestsAsync(grpcRequest, cancellationToken: cancellationToken);
return response.Adapt<GetWithdrawalRequestsResponseDto>();
return new GetWithdrawalRequestsResponseDto
{
MetaData = new MetaDataDto
{
TotalCount = (int)(response.MetaData?.TotalCount ?? 0),
PageSize = (int)(response.MetaData?.PageSize ?? request.PageSize),
CurrentPage = (int)(response.MetaData?.CurrentPage ?? request.PageIndex),
TotalPages = (int)(response.MetaData?.TotalPage ?? 0)
},
Models = response.Models.Select(m => new WithdrawalRequestDto
{
Id = m.Id,
UserId = m.UserId,
UserName = m.UserName,
WeekDefinitionId = m.WeekDefinitionId,
Amount = m.Amount,
Status = m.Status,
WithdrawalMethod = m.WithdrawalMethod,
IbanNumber = m.IbanNumber,
RequestedAt = m.RequestedAt?.ToDateTime() ?? DateTime.MinValue,
ProcessedAt = m.ProcessedAt?.ToDateTime(),
ProcessedBy = m.ProcessedBy,
Reason = m.Reason,
Created = m.Created?.ToDateTime() ?? DateTime.MinValue,
BankReferenceId = m.BankReferenceId,
BankTrackingCode = m.BankTrackingCode,
PaymentFailureReason = m.PaymentFailureReason
}).ToList()
};
}
}
@@ -11,18 +11,19 @@ public record WithdrawalRequestDto
public long Id { get; init; }
public long UserId { get; init; }
public string UserName { get; init; } = string.Empty;
public string PhoneNumber { get; init; } = string.Empty;
public long WeekDefinitionId { get; init; }
public long Amount { get; init; }
public int Status { get; init; }
public string Method { get; init; } = "Bank";
public string? BankAccount { get; init; }
public string? BankName { get; init; }
public int WithdrawalMethod { get; init; }
public string? IbanNumber { get; init; }
public DateTime RequestedAt { get; init; }
public DateTime? ProcessedAt { get; init; }
public string? ProcessedBy { get; init; }
public string? Reason { get; init; }
public DateTime Created { get; init; }
public string? BankReferenceId { get; init; }
public string? BankTrackingCode { get; init; }
public string? PaymentFailureReason { get; init; }
public DateTime RequestDate { get; init; }
public DateTime? ProcessedDate { get; init; }
public string? AdminNote { get; init; }
}
public record MetaDataDto
@@ -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;
@@ -66,5 +67,8 @@ public interface IApplicationContractContext
// Manual Payments (Admin) - BackOffice BFF gRPC
ManualPaymentContract.ManualPaymentContractClient ManualPayments { get; }
// App Version Management
AppVersionContract.AppVersionContractClient AppVersions { get; }
#endregion
}
@@ -1,5 +1,9 @@
using BackOffice.BFF.Application.CommissionCQ.Queries.GetWeeklyPool;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetAllWeeklyPools;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetUserWeeklyBalances;
using CMSMicroservice.Protobuf.Protos.Commission;
using WeeklyPoolsMetaDataDto = BackOffice.BFF.Application.CommissionCQ.Queries.GetAllWeeklyPools.MetaDataDto;
using UserBalancesMetaDataDto = BackOffice.BFF.Application.CommissionCQ.Queries.GetUserWeeklyBalances.MetaDataDto;
namespace BackOffice.BFF.Application.Common.Mappings;
@@ -7,7 +11,7 @@ public class CommissionProfile : IRegister
{
void IRegister.Register(TypeAdapterConfig config)
{
config.NewConfig< GetWeeklyCommissionPoolResponse,GetWeeklyPoolResponseDto>()
config.NewConfig<GetWeeklyCommissionPoolResponse, GetWeeklyPoolResponseDto>()
.Map(dest => dest.Id, src => src.Id)
.Map(dest => dest.CalculatedAt, src => src.CalculatedAt)
.Map(dest => dest.IsCalculated, src => src.IsCalculated)
@@ -15,9 +19,63 @@ public class CommissionProfile : IRegister
.Map(dest => dest.TotalPoolAmount, src => src.TotalPoolAmount)
.Map(dest => dest.ValuePerBalance, src => src.ValuePerBalance)
.Map(dest => dest.TotalBalances, src => src.TotalBalances)
.Map(dest => dest.Created, src => src.Created.ToDateTimeOffset())
;
.Map(dest => dest.Created, src => src.Created.ToDateTimeOffset());
// CMS GetAllWeeklyPoolsResponse -> GetAllWeeklyPoolsResponseDto
config.NewConfig<GetAllWeeklyPoolsResponse, GetAllWeeklyPoolsResponseDto>()
.MapWith(src => new GetAllWeeklyPoolsResponseDto
{
MetaData = new WeeklyPoolsMetaDataDto
{
TotalCount = (int)src.MetaData.TotalCount,
PageSize = (int)src.MetaData.PageSize,
CurrentPage = (int)src.MetaData.CurrentPage,
TotalPages = (int)src.MetaData.TotalPage
},
Models = src.Models.Select(m => new WeeklyCommissionPoolDto
{
Id = m.Id,
WeekDefinitionId = m.WeekDefinitionId,
WeekDisplayName = m.WeekDisplayName,
TotalPoolAmount = m.TotalPoolAmount,
TotalBalances = m.TotalBalances,
ValuePerBalance = m.ValuePerBalance,
IsCalculated = m.IsCalculated,
CalculatedAt = m.CalculatedAt != null ? m.CalculatedAt.ToDateTime() : null,
Created = m.Created.ToDateTime()
}).ToList()
});
// CMS GetUserWeeklyBalancesResponse -> GetUserWeeklyBalancesResponseDto
config.NewConfig<GetUserWeeklyBalancesResponse, GetUserWeeklyBalancesResponseDto>()
.MapWith(src => new GetUserWeeklyBalancesResponseDto
{
MetaData = new UserBalancesMetaDataDto
{
TotalCount = (int)src.MetaData.TotalCount,
PageSize = (int)src.MetaData.PageSize,
CurrentPage = (int)src.MetaData.CurrentPage,
TotalPages = (int)src.MetaData.TotalPage
},
Models = src.Models.Select(m => new UserWeeklyBalanceDto
{
Id = m.Id,
UserId = m.UserId,
UserFullName = m.UserFullName ?? string.Empty,
WeekDefinitionId = m.WeekDefinitionId,
WeekDisplayName = m.WeekDisplayName ?? string.Empty,
LeftLegNewMembers = m.LeftLegNewMembers,
LeftLegCarryover = m.LeftLegCarryover,
LeftLegTotal = m.LeftLegTotal,
RightLegNewMembers = m.RightLegNewMembers,
RightLegCarryover = m.RightLegCarryover,
RightLegTotal = m.RightLegTotal,
TotalBalances = m.TotalBalances,
WeeklyPoolContribution = m.WeeklyPoolContribution,
CalculatedAt = m.CalculatedAt != null ? m.CalculatedAt.ToDateTime() : null,
IsExpired = m.IsExpired,
Created = m.Created.ToDateTime()
}).ToList()
});
}
}
@@ -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; }
}
@@ -7,7 +7,7 @@
<ItemGroup>
<PackageReference Include="Afrino.FMSMicroservice.Protobuf" Version="0.0.122" />
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.156" />
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.162" />
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.54.0" />
@@ -24,6 +24,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;
// BFF Protobuf contracts
@@ -93,5 +94,8 @@ public class ApplicationContractContext : IApplicationContractContext
// Manual Payments (Admin)
public ManualPaymentContract.ManualPaymentContractClient ManualPayments => GetService<ManualPaymentContract.ManualPaymentContractClient>();
// App Version Management
public AppVersionContract.AppVersionContractClient AppVersions => GetService<AppVersionContract.AppVersionContractClient>();
#endregion
}
@@ -0,0 +1,42 @@
using BackOffice.BFF.Application.ConfigurationCQ.Commands.UpdateAppVersion;
using BackOffice.BFF.Application.ConfigurationCQ.Queries.GetAllAppVersions;
using Google.Protobuf.WellKnownTypes;
using ProtoDto = BackOffice.BFF.Configuration.Protobuf.Protos.AppVersion;
namespace BackOffice.BFF.WebApi.Common.Mappings;
public class AppVersionProfile : IRegister
{
void IRegister.Register(TypeAdapterConfig config)
{
// Request -> Query mappings
config.NewConfig<ProtoDto.GetAllAppVersionsRequest, GetAllAppVersionsQuery>()
.Map(dest => dest.IncludeInactive, src => src.IncludeInactive);
// Request -> Command mappings
config.NewConfig<ProtoDto.UpdateAppVersionRequest, UpdateAppVersionCommand>()
.Map(dest => dest.AppName, src => src.AppName)
.Map(dest => dest.CurrentVersion, src => src.CurrentVersion)
.Map(dest => dest.MinRequiredVersion, src => src.MinRequiredVersion)
.Map(dest => dest.RequiresFullCacheClear, src => src.RequiresFullCacheClear)
.Map(dest => dest.UpdateMessage, src => src.UpdateMessage)
.Map(dest => dest.ReleaseNotes, src => src.ReleaseNotes)
.Map(dest => dest.UpdateReason, src => src.UpdateReason);
// Response mappings
config.NewConfig<GetAllAppVersionsResponseDto, ProtoDto.GetAllAppVersionsResponse>()
.Map(dest => dest.Items, src => src.Items);
config.NewConfig<AppVersionItemDto, ProtoDto.AppVersionItem>()
.Map(dest => dest.Id, src => src.Id)
.Map(dest => dest.AppName, src => src.AppName)
.Map(dest => dest.CurrentVersion, src => src.CurrentVersion)
.Map(dest => dest.MinRequiredVersion, src => src.MinRequiredVersion)
.Map(dest => dest.RequiresFullCacheClear, src => src.RequiresFullCacheClear)
.Map(dest => dest.UpdateMessage, src => src.UpdateMessage ?? string.Empty)
.Map(dest => dest.ReleaseNotes, src => src.ReleaseNotes ?? string.Empty)
.Map(dest => dest.IsActive, src => src.IsActive)
.Map(dest => dest.Created, src => Timestamp.FromDateTimeOffset(src.Created))
.Map(dest => dest.LastModified, src => Timestamp.FromDateTimeOffset(src.LastModified));
}
}
@@ -3,6 +3,8 @@ using BackOffice.BFF.Application.CommissionCQ.Queries.GetAllWeeklyPools;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetUserWeeklyBalances;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetAvailableWeeks;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetUserPayouts;
using BackOffice.BFF.Application.CommissionCQ.Queries.GetWithdrawalRequests;
using BackOffice.BFF.Application.CommissionCQ.Commands.ProcessWithdrawal;
using Foursat.BackOffice.BFF.Commission.Protos;
using System.Collections.Generic;
@@ -12,6 +14,12 @@ public class CommissionProfile : IRegister
{
void IRegister.Register(TypeAdapterConfig config)
{
// ProcessWithdrawalRequest -> ProcessWithdrawalCommand
config.NewConfig<ProcessWithdrawalRequest, ProcessWithdrawalCommand>()
.Map(dest => dest.WithdrawalId, src => src.PayoutId)
.Map(dest => dest.IsApproved, src => src.IsApproved)
.Map(dest => dest.Reason, src => src.Reason);
// GetUserCommissionPayoutsRequest -> GetUserPayoutsQuery
config.NewConfig<GetUserCommissionPayoutsRequest, GetUserPayoutsQuery>()
.MapWith(src => new GetUserPayoutsQuery
@@ -68,34 +76,8 @@ public class CommissionProfile : IRegister
});
// GetUserPayoutsResponseDto -> GetUserCommissionPayoutsResponse
// config.NewConfig<GetUserPayoutsResponseDto, GetUserCommissionPayoutsResponse>()
// .MapWith(src => new GetUserCommissionPayoutsResponse
// {
// MetaData = new BackOffice.BFF.Protobuf.Common.MetaData
// {
// CurrentPage = src.MetaData.CurrentPage,
// PageSize = src.MetaData.PageSize,
// TotalCount = src.MetaData.TotalCount,
// TotalPage = src.MetaData.TotalPage
// },
// Models = { (src.Models ?? new List<GetUserPayoutsResponseModel>()).Select(m => new UserCommissionPayoutModel
// {
// Id = m.Id,
// UserId = m.UserId,
// UserName = m.UserName,
// WeekNumber = m.WeekNumber,
// BalancesEarned = m.BalancesEarned,
// ValuePerBalance = m.ValuePerBalance,
// TotalAmount = m.TotalAmount,
// Status = m.Status,
// WithdrawalMethod = m.WithdrawalMethod,
// IbanNumber = m.IbanNumber,
// Created = Timestamp.FromDateTime(DateTime.SpecifyKind(m.Created, DateTimeKind.Utc)),
// LastModified = m.LastModified.HasValue
// ? Timestamp.FromDateTime(DateTime.SpecifyKind(m.LastModified.Value, DateTimeKind.Utc))
// : null
// }) }
// });
config.NewConfig<GetUserPayoutsResponseDto, GetUserCommissionPayoutsResponse>()
.MapWith(src => MapPayoutsResponse(src));
// GetAllWeeklyPoolsResponseDto -> GetAllWeeklyPoolsResponse
config.NewConfig<GetAllWeeklyPoolsResponseDto, GetAllWeeklyPoolsResponse>()
@@ -139,10 +121,15 @@ public class CommissionProfile : IRegister
{
Id = m.Id,
UserId = m.UserId,
UserFullName = m.UserFullName ?? string.Empty,
WeekDefinitionId = m.WeekDefinitionId,
WeekDisplayName = m.WeekDisplayName ?? string.Empty,
LeftLegBalances = m.LeftLegBalances,
RightLegBalances = m.RightLegBalances,
LeftLegNewMembers = m.LeftLegNewMembers,
LeftLegCarryover = m.LeftLegCarryover,
LeftLegTotal = m.LeftLegTotal,
RightLegNewMembers = m.RightLegNewMembers,
RightLegCarryover = m.RightLegCarryover,
RightLegTotal = m.RightLegTotal,
TotalBalances = m.TotalBalances,
WeeklyPoolContribution = m.WeeklyPoolContribution,
CalculatedAt = m.CalculatedAt.HasValue
@@ -154,33 +141,38 @@ public class CommissionProfile : IRegister
});
// GetWithdrawalRequestsResponseDto -> GetWithdrawalRequestsResponse
// config.NewConfig<GetWithdrawalRequestsResponseDto, GetWithdrawalRequestsResponse>()
// .MapWith(src => new GetWithdrawalRequestsResponse
// {
// MetaData = new BackOffice.BFF.Protobuf.Common.MetaData
// {
// CurrentPage = src.MetaData.CurrentPage,
// PageSize = src.MetaData.PageSize,
// TotalCount = src.MetaData.TotalCount,
// TotalPage = src.MetaData.TotalPages
// },
// Models = { src.Models.Select(m => new WithdrawalRequestModel
// {
// Id = m.Id,
// UserId = m.UserId,
// UserName = m.UserName ?? string.Empty,
// Amount = m.Amount,
// Status = m.Status,
// StatusDisplay = m.StatusDisplay ?? string.Empty,
// RequestedAt = Timestamp.FromDateTime(DateTime.SpecifyKind(m.RequestedAt, DateTimeKind.Utc)),
// ProcessedAt = m.ProcessedAt.HasValue
// ? Timestamp.FromDateTime(DateTime.SpecifyKind(m.ProcessedAt.Value, DateTimeKind.Utc))
// : null,
// ProcessedBy = m.ProcessedBy,
// ProcessedByName = m.ProcessedByName ?? string.Empty,
// RejectionReason = m.RejectionReason ?? string.Empty
// }) }
// });
config.NewConfig<GetWithdrawalRequestsResponseDto, GetWithdrawalRequestsResponse>()
.MapWith(src => new GetWithdrawalRequestsResponse
{
MetaData = new BackOffice.BFF.Protobuf.Common.MetaData
{
CurrentPage = src.MetaData.CurrentPage,
PageSize = src.MetaData.PageSize,
TotalCount = src.MetaData.TotalCount,
TotalPage = src.MetaData.TotalPages
},
Models = { src.Models.Select(m => new WithdrawalRequestModel
{
Id = m.Id,
UserId = m.UserId,
UserName = m.UserName ?? string.Empty,
WeekDefinitionId = m.WeekDefinitionId,
Amount = m.Amount,
Status = m.Status,
WithdrawalMethod = m.WithdrawalMethod,
IbanNumber = m.IbanNumber ?? string.Empty,
RequestedAt = Timestamp.FromDateTime(DateTime.SpecifyKind(m.RequestedAt, DateTimeKind.Utc)),
ProcessedAt = m.ProcessedAt.HasValue
? Timestamp.FromDateTime(DateTime.SpecifyKind(m.ProcessedAt.Value, DateTimeKind.Utc))
: null,
ProcessedBy = m.ProcessedBy ?? string.Empty,
Reason = m.Reason ?? string.Empty,
Created = Timestamp.FromDateTime(DateTime.SpecifyKind(m.Created, DateTimeKind.Utc)),
BankReferenceId = m.BankReferenceId ?? string.Empty,
BankTrackingCode = m.BankTrackingCode ?? string.Empty,
PaymentFailureReason = m.PaymentFailureReason ?? string.Empty
}) }
});
// GetWithdrawalReportsResponseDto -> GetWithdrawalReportsResponse
// config.NewConfig<GetWithdrawalReportsResponseDto, GetWithdrawalReportsResponse>()
@@ -237,4 +229,39 @@ public class CommissionProfile : IRegister
DisplayText = dto.DisplayText
};
}
private static GetUserCommissionPayoutsResponse MapPayoutsResponse(GetUserPayoutsResponseDto src)
{
var response = new GetUserCommissionPayoutsResponse
{
MetaData = new BackOffice.BFF.Protobuf.Common.MetaData
{
CurrentPage = src.MetaData.CurrentPage,
PageSize = src.MetaData.PageSize,
TotalCount = src.MetaData.TotalCount,
TotalPage = src.MetaData.TotalPage
}
};
foreach (var m in src.Models ?? new List<GetUserPayoutsResponseModel>())
{
response.Models.Add(new UserCommissionPayoutModel
{
Id = m.Id,
UserId = m.UserId,
UserName = m.UserName ?? "",
WeekDefinitionId = m.WeekDefinitionId,
WeekDisplayName = m.WeekDisplayName ?? "",
BalancesEarned = m.BalancesEarned,
ValuePerBalance = m.ValuePerBalance,
TotalAmount = m.TotalAmount,
Status = m.Status,
WithdrawalMethod = m.WithdrawalMethod,
IbanNumber = m.IbanNumber ?? "",
Created = Timestamp.FromDateTime(DateTime.SpecifyKind(m.Created, DateTimeKind.Utc))
});
}
return response;
}
}
@@ -60,5 +60,9 @@ public class GeneralMapping : IRegister
config.NewConfig<byte[], Google.Protobuf.ByteString>()
.MapWith(src => Google.Protobuf.ByteString.CopyFrom(src));
// MediatR Unit to Google.Protobuf.Empty
config.NewConfig<MediatR.Unit, Google.Protobuf.WellKnownTypes.Empty>()
.MapWith(_ => new Google.Protobuf.WellKnownTypes.Empty());
}
}
+2 -2
View File
@@ -1,10 +1,10 @@
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
FROM 194.5.195.53:32082/dotnet/aspnet:9.0 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
FROM 194.5.195.53:32082/dotnet/sdk:9.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["BackOffice.BFF.WebApi/NuGet.config", "NuGet.config"]
@@ -0,0 +1,55 @@
using BackOffice.BFF.WebApi.Common.Services;
using BackOffice.BFF.Application.ConfigurationCQ.Commands.UpdateAppVersion;
using BackOffice.BFF.Application.ConfigurationCQ.Queries.GetAllAppVersions;
using BackOffice.BFF.Configuration.Protobuf.Protos.AppVersion;
namespace BackOffice.BFF.WebApi.Services;
public class AppVersionService : AppVersionContract.AppVersionContractBase
{
private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;
public AppVersionService(IDispatchRequestToCQRS dispatchRequestToCQRS)
{
_dispatchRequestToCQRS = dispatchRequestToCQRS;
}
[RequiresPermission(PermissionNames.SettingsView)]
public override async Task<GetAllAppVersionsResponse> GetAllAppVersions(
GetAllAppVersionsRequest request,
ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<GetAllAppVersionsRequest, GetAllAppVersionsQuery, GetAllAppVersionsResponse>(
request,
context);
}
[RequiresPermission(PermissionNames.SettingsView)]
public override async Task<GetAppVersionResponse> GetAppVersion(
GetAppVersionRequest request,
ServerCallContext context)
{
// For single app version, we use GetAll and filter
var allVersionsResponse = await _dispatchRequestToCQRS.Handle<GetAllAppVersionsRequest, GetAllAppVersionsQuery, GetAllAppVersionsResponse>(
new GetAllAppVersionsRequest { IncludeInactive = false },
context);
var item = allVersionsResponse.Items.FirstOrDefault(x => x.AppName == request.AppName);
return new GetAppVersionResponse
{
Found = item != null,
Item = item
};
}
[RequiresPermission(PermissionNames.SettingsManageConfiguration)]
public override async Task<Empty> UpdateAppVersion(
UpdateAppVersionRequest request,
ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<UpdateAppVersionRequest, UpdateAppVersionCommand, Empty>(
request,
context);
}
}
@@ -11,8 +11,7 @@
},
"GrpcChannelOptions": {
"FMSMSAddress": "https://dl.afrino.co",
"CMSMSAddress": "https://cms.kbs1.ir"
// "CMSMSAddress": "https://localhost:32846"
"CMSMSAddress": "http://cms-svc"
},
"Authentication": {
"Authority": "https://ids.domain.com/",
@@ -21,9 +20,7 @@
"Kavenegar": {
"Sender": "1000001110100",
"ApiKey": "497263626F32626A48685A6137524C4F78575A766E4C74694A556B79317648424964655030682B554545413D"
}
}
,
},
"Seq": {
"ServerUrl": "http://seq-svc:5341",
"ApiKey": ""
+2 -4
View File
@@ -11,9 +11,7 @@
},
"GrpcChannelOptions": {
"FMSMSAddress": "https://dl.afrino.co",
"CMSMSAddress": "https://cms.kbs1.ir"
// "CMSMSAddress": "https://cms.foursat.afrino.co"
// "CMSMSAddress": "https://localhost:32846"
"CMSMSAddress": "http://cms-svc"
},
"Authentication": {
"Authority": "https://ids.domain.com/",
@@ -24,7 +22,7 @@
"ApiKey": "497263626F32626A48685A6137524C4F78575A766E4C74694A556B79317648424964655030682B554545413D"
},
"Seq": {
"ServerUrl": "https://seq.afrino.co",
"ServerUrl": "http://seq-svc:5341",
"ApiKey": ""
}
}
@@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
<PackageId>Foursat.BackOffice.BFF.Commission.Protobuf</PackageId>
<Version>0.0.13</Version>
<Version>0.0.15</Version>
<Authors>FourSat</Authors>
<Company>FourSat</Company>
<Product>BackOffice.BFF.Commission.Protobuf</Product>
@@ -279,15 +279,20 @@ message UserWeeklyBalanceModel
{
int64 id = 1;
int64 user_id = 2;
int64 week_definition_id = 3;
string week_display_name = 4;
int32 left_leg_balances = 5;
int32 right_leg_balances = 6;
int32 total_balances = 7;
int64 weekly_pool_contribution = 8;
google.protobuf.Timestamp calculated_at = 9;
bool is_expired = 10;
google.protobuf.Timestamp created = 11;
string user_full_name = 3; // نام کامل کاربر
int64 week_definition_id = 4;
string week_display_name = 5;
int32 left_leg_new_members = 6; // اعضای جدید چپ این هفته
int32 left_leg_carryover = 7; // باقیمانده چپ از هفته قبل
int32 left_leg_total = 8; // مجموع چپ (NewMembers + Carryover)
int32 right_leg_new_members = 9; // اعضای جدید راست این هفته
int32 right_leg_carryover = 10; // باقیمانده راست از هفته قبل
int32 right_leg_total = 11; // مجموع راست (NewMembers + Carryover)
int32 total_balances = 12; // تعداد تعادل = MIN(چپ, راست)
int64 weekly_pool_contribution = 13;
google.protobuf.Timestamp calculated_at = 14;
bool is_expired = 15;
google.protobuf.Timestamp created = 16;
}
// GetAllWeeklyPools Query
@@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
<PackageId>Foursat.BackOffice.BFF.Configuration.Protobuf</PackageId>
<Version>1.0.7</Version>
<Version>1.0.20</Version>
<Authors>FourSat</Authors>
<Company>FourSat</Company>
<Product>Foursat.BackOffice.BFF.Configuration.Protobuf</Product>
@@ -25,6 +25,7 @@
<ItemGroup>
<Protobuf Include="Protos\configuration.proto" ProtoRoot="Protos\" GrpcServices="Both" AdditionalImportDirs="..\BackOffice.BFF.Common.Protobuf\Protos"/>
<Protobuf Include="Protos\appversion.proto" ProtoRoot="Protos\" GrpcServices="Both" AdditionalImportDirs="..\BackOffice.BFF.Common.Protobuf\Protos"/>
</ItemGroup>
<ItemGroup>
@@ -0,0 +1,88 @@
syntax = "proto3";
package appversion;
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";
option csharp_namespace = "BackOffice.BFF.Configuration.Protobuf.Protos.AppVersion";
// Service for managing app versions (admin panel)
service AppVersionContract
{
// Get all app versions
rpc GetAllAppVersions(GetAllAppVersionsRequest) returns (GetAllAppVersionsResponse){
option (google.api.http) = {
get: "/AppVersion/GetAll"
};
};
// Get single app version
rpc GetAppVersion(GetAppVersionRequest) returns (GetAppVersionResponse){
option (google.api.http) = {
get: "/AppVersion/Get"
};
};
// Update/Create app version
rpc UpdateAppVersion(UpdateAppVersionRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
post: "/AppVersion/Update"
body: "*"
};
};
}
// Request to get all app versions
message GetAllAppVersionsRequest
{
bool include_inactive = 1;
}
// Response with all app versions
message GetAllAppVersionsResponse
{
repeated AppVersionItem items = 1;
}
// Request to get single app version
message GetAppVersionRequest
{
string app_name = 1;
}
// Response with version info
message GetAppVersionResponse
{
bool found = 1;
AppVersionItem item = 2;
}
// Request to update/create app version
message UpdateAppVersionRequest
{
string app_name = 1;
string current_version = 2;
google.protobuf.StringValue min_required_version = 3;
bool requires_full_cache_clear = 4;
google.protobuf.StringValue update_message = 5;
google.protobuf.StringValue release_notes = 6;
google.protobuf.StringValue update_reason = 7; // For admin logs
}
// App version item
message AppVersionItem
{
int64 id = 1;
string app_name = 2;
string current_version = 3;
string min_required_version = 4;
bool requires_full_cache_clear = 5;
string update_message = 6;
string release_notes = 7;
bool is_active = 8;
google.protobuf.Timestamp created = 9;
google.protobuf.Timestamp last_modified = 10;
}