refactor: update protobuf imports and add HTTP annotations

This commit is contained in:
masoodafar-web
2025-12-08 04:43:03 +03:30
parent fd3c17ac23
commit ca28678e8f
25 changed files with 207 additions and 53 deletions

View File

@@ -1,5 +1,5 @@
using Foursat.BackOffice.BFF.ClubMembership.Protobuf;
using Foursat.BackOffice.BFF.ClubMembership.Protos;
using GetAllClubMembershipsRequest = CMSMicroservice.Protobuf.Protos.ClubMembership.GetAllClubMembershipsRequest;
namespace BackOffice.BFF.Application.ClubMembershipCQ.Queries.GetAllClubMembers;

View File

@@ -1,4 +1,4 @@
using BackOffice.BFF.Commission.Protobuf;
using Foursat.BackOffice.BFF.Commission.Protos;
using Google.Protobuf.WellKnownTypes;
namespace BackOffice.BFF.Application.CommissionCQ.Commands.ProcessWithdrawal;

View File

@@ -1,4 +1,4 @@
using BackOffice.BFF.Configuration.Protobuf;
using Foursat.BackOffice.BFF.Configuration.Protos;
using Google.Protobuf.WellKnownTypes;
namespace BackOffice.BFF.Application.ConfigurationCQ.Commands.CreateOrUpdateConfiguration;

View File

@@ -1,4 +1,4 @@
using BackOffice.BFF.Configuration.Protobuf;
using Foursat.BackOffice.BFF.Configuration.Protos;
namespace BackOffice.BFF.Application.ConfigurationCQ.Commands.DeactivateConfiguration;

View File

@@ -1,5 +1,5 @@
using BackOffice.BFF.Application.Common.Interfaces;
using BackOffice.BFF.Configuration.Protobuf;
using Foursat.BackOffice.BFF.Configuration.Protos;
using Google.Protobuf.WellKnownTypes;
using MediatR;
using Microsoft.Extensions.Logging;

View File

@@ -1,4 +1,4 @@
using BackOffice.BFF.Configuration.Protobuf;
using Foursat.BackOffice.BFF.Configuration.Protos;
namespace BackOffice.BFF.Application.ConfigurationCQ.Queries.GetAllConfigurations;

View File

@@ -1,5 +1,5 @@
using BackOffice.BFF.Application.Common.Interfaces;
using BackOffice.BFF.Configuration.Protobuf;
using Foursat.BackOffice.BFF.Configuration.Protos;
using MediatR;
using Microsoft.Extensions.Logging;

View File

@@ -5,7 +5,7 @@ public record GetNetworkTreeQuery : IRequest<GetNetworkTreeResponseDto>
/// <summary>
/// شناسه کاربر ریشه (Root)
/// </summary>
public long RootUserId { get; init; }
public long UserId { get; init; }
/// <summary>
/// حداکثر عمق درخت (اختیاری، پیش‌فرض: 5)

View File

@@ -14,6 +14,7 @@ public class GetNetworkTreeQueryHandler : IRequestHandler<GetNetworkTreeQuery, G
public async Task<GetNetworkTreeResponseDto> Handle(GetNetworkTreeQuery request, CancellationToken cancellationToken)
{
var x=request.Adapt<GetNetworkTreeRequest>();
var response = await _context.NetworkMemberships.GetNetworkTreeAsync(
request.Adapt<GetNetworkTreeRequest>(),
cancellationToken: cancellationToken);

View File

@@ -28,20 +28,20 @@ public class NetworkTreeNodeDto
/// <summary>
/// موقعیت در شبکه (0=Left, 1=Right)
/// </summary>
public int NetworkLeg { get; set; }
public int? NetworkLeg { get; set; }
/// <summary>
/// سطح در شبکه
/// </summary>
public int NetworkLevel { get; set; }
public int? NetworkLevel { get; set; }
/// <summary>
/// وضعیت فعال/غیرفعال
/// </summary>
public bool IsActive { get; set; }
public bool? IsActive { get; set; }
/// <summary>
/// تاریخ عضویت
/// </summary>
public DateTime JoinedAt { get; set; }
public DateTime? JoinedAt { get; set; }
}

View File

@@ -7,7 +7,7 @@
<ItemGroup>
<PackageReference Include="Afrino.FMSMicroservice.Protobuf" Version="0.0.122" />
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.144" />
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.145" />
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.54.0" />

View File

@@ -43,6 +43,11 @@
<ProjectReference Include="..\Protobufs\BackOffice.BFF.UserRole.Protobuf\BackOffice.BFF.UserRole.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.Category.Protobuf\BackOffice.BFF.Category.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.ManualPayment.Protobuf\BackOffice.BFF.ManualPayment.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.ClubMembership.Protobuf\BackOffice.BFF.ClubMembership.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.Commission.Protobuf\BackOffice.BFF.Commission.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.Configuration.Protobuf\BackOffice.BFF.Configuration.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.NetworkMembership.Protobuf\BackOffice.BFF.NetworkMembership.Protobuf.csproj" />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.PublicMessage.Protobuf\BackOffice.BFF.PublicMessage.Protobuf.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="..\.dockerignore">

View File

@@ -1,7 +1,7 @@
using BackOffice.BFF.WebApi.Common.Services;
using BackOffice.BFF.Application.ClubMembershipCQ.Commands.ActivateClub;
using BackOffice.BFF.Application.ClubMembershipCQ.Queries.GetAllClubMembers;
using CMSMicroservice.Protobuf.Protos.ClubMembership;
using Foursat.BackOffice.BFF.ClubMembership.Protos;
using Google.Protobuf.WellKnownTypes;
namespace BackOffice.BFF.WebApi.Services;

View File

@@ -8,7 +8,7 @@ using BackOffice.BFF.Application.CommissionCQ.Queries.GetWithdrawalReports;
using BackOffice.BFF.Application.CommissionCQ.Commands.ApproveWithdrawal;
using BackOffice.BFF.Application.CommissionCQ.Commands.RejectWithdrawal;
// using BackOffice.BFF.Application.CommissionCQ.Commands.ProcessWithdrawal; // Excluded - needs proto fix
using CMSMicroservice.Protobuf.Protos.Commission;
using Foursat.BackOffice.BFF.Commission.Protos;
using Google.Protobuf.WellKnownTypes;
namespace BackOffice.BFF.WebApi.Services;

View File

@@ -1,14 +1,10 @@
using CMSMicroservice.Protobuf.Protos.Configuration;
using BackOffice.BFF.WebApi.Common.Services;
using BackOffice.BFF.Application.ConfigurationCQ.Commands.CreateOrUpdateConfiguration;
using BackOffice.BFF.Application.ConfigurationCQ.Commands.DeactivateConfiguration;
using BackOffice.BFF.Application.ConfigurationCQ.Queries.GetAllConfigurations;
using Foursat.BackOffice.BFF.Configuration.Protos;
using Grpc.Core;
using Google.Protobuf.WellKnownTypes;
using BFFConfigRequest = BackOffice.BFF.Configuration.Protobuf.CreateOrUpdateConfigurationRequest;
using BFFDeactivateRequest = BackOffice.BFF.Configuration.Protobuf.DeactivateConfigurationRequest;
using BFFGetAllRequest = BackOffice.BFF.Configuration.Protobuf.GetAllConfigurationsRequest;
using BFFGetAllResponse = BackOffice.BFF.Configuration.Protobuf.GetAllConfigurationsResponse;
namespace BackOffice.BFF.WebApi.Services;

View File

@@ -2,7 +2,7 @@ using BackOffice.BFF.WebApi.Common.Services;
using BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetUserNetworkInfo;
using BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkTree;
using BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkHistory;
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
using Foursat.BackOffice.BFF.NetworkMembership.Protos;
namespace BackOffice.BFF.WebApi.Services;
@@ -28,6 +28,7 @@ public class NetworkMembershipService : NetworkMembershipContract.NetworkMembers
GetNetworkTreeRequest request,
ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<GetNetworkTreeRequest, GetNetworkTreeQuery, GetNetworkTreeResponse>(
request,
context);

View File

@@ -11,7 +11,8 @@
},
"GrpcChannelOptions": {
"FMSMSAddress": "https://dl.afrino.co",
"CMSMSAddress": "http://cms-svc:80"
// "CMSMSAddress": "http://cms-svc:80"
"CMSMSAddress": "https://cms.foursat.afrino.co"
},
"Authentication": {
"Authority": "https://ids.domain.com/",

View File

@@ -20,10 +20,11 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" />
<PackageReference Include="Google.Api.CommonProtos" Version="2.10.0" />
</ItemGroup>
<ItemGroup>
<Protobuf Include="Protos\clubmembership.proto" GrpcServices="Client" AdditionalImportDirs="..\BackOffice.BFF.Common.Protobuf\Protos"/>
<Protobuf Include="Protos\clubmembership.proto" ProtoRoot="Protos\" GrpcServices="Server" AdditionalImportDirs="..\BackOffice.BFF.Common.Protobuf\Protos"/>
</ItemGroup>
<ItemGroup>

View File

@@ -6,18 +6,50 @@ import "public_messages.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";
option csharp_namespace = "Foursat.BackOffice.BFF.ClubMembership.Protobuf";
option csharp_namespace = "Foursat.BackOffice.BFF.ClubMembership.Protos";
service ClubMembershipContract
{
rpc ActivateClubMembership(ActivateClubMembershipRequest) returns (google.protobuf.Empty);
rpc DeactivateClubMembership(DeactivateClubMembershipRequest) returns (google.protobuf.Empty);
rpc AssignFeatureToMembership(AssignFeatureToMembershipRequest) returns (google.protobuf.Empty);
rpc GetClubMembership(GetClubMembershipRequest) returns (GetClubMembershipResponse);
rpc GetAllClubMemberships(GetAllClubMembershipsRequest) returns (GetAllClubMembershipsResponse);
rpc GetClubMembershipHistory(GetClubMembershipHistoryRequest) returns (GetClubMembershipHistoryResponse);
rpc GetClubStatistics(GetClubStatisticsRequest) returns (GetClubStatisticsResponse);
rpc ActivateClubMembership(ActivateClubMembershipRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
post: "/ActivateClubMembership"
body: "*"
};
};
rpc DeactivateClubMembership(DeactivateClubMembershipRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
post: "/DeactivateClubMembership"
body: "*"
};
};
rpc AssignFeatureToMembership(AssignFeatureToMembershipRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
post: "/AssignFeatureToMembership"
body: "*"
};
};
rpc GetClubMembership(GetClubMembershipRequest) returns (GetClubMembershipResponse){
option (google.api.http) = {
get: "/GetClubMembership"
};
};
rpc GetAllClubMemberships(GetAllClubMembershipsRequest) returns (GetAllClubMembershipsResponse){
option (google.api.http) = {
get: "/GetAllClubMemberships"
};
};
rpc GetClubMembershipHistory(GetClubMembershipHistoryRequest) returns (GetClubMembershipHistoryResponse){
option (google.api.http) = {
get: "/GetClubMembershipHistory"
};
};
rpc GetClubStatistics(GetClubStatisticsRequest) returns (GetClubStatisticsResponse){
option (google.api.http) = {
get: "/GetClubStatistics"
};
};
}
// Activate Command

View File

@@ -24,7 +24,7 @@
</ItemGroup>
<ItemGroup>
<Protobuf Include="Protos\commission.proto" GrpcServices="Client" AdditionalImportDirs="..\BackOffice.BFF.Common.Protobuf\Protos"/>
<Protobuf Include="Protos\commission.proto" ProtoRoot="Protos\" GrpcServices="Server" AdditionalImportDirs="..\BackOffice.BFF.Common.Protobuf\Protos"/>
</ItemGroup>
<ItemGroup>

View File

@@ -6,49 +6,109 @@ import "public_messages.proto";
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.Commission.Protobuf";
option csharp_namespace = "Foursat.BackOffice.BFF.Commission.Protos";
service CommissionContract
{
// Commands
rpc CalculateWeeklyBalances(CalculateWeeklyBalancesRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
post: "/CalculateWeeklyBalances"
body: "*"
};
};
rpc CalculateWeeklyCommissionPool(CalculateWeeklyCommissionPoolRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
post: "/CalculateWeeklyCommissionPool"
body: "*"
};
};
rpc ProcessUserPayouts(ProcessUserPayoutsRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
post: "/ProcessUserPayouts"
body: "*"
};
};
rpc RequestWithdrawal(RequestWithdrawalRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
post: "/RequestWithdrawal"
body: "*"
};
};
rpc ProcessWithdrawal(ProcessWithdrawalRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
post: "/ProcessWithdrawal"
body: "*"
};
};
// Queries
rpc GetWeeklyCommissionPool(GetWeeklyCommissionPoolRequest) returns (GetWeeklyCommissionPoolResponse){
option (google.api.http) = {
get: "/GetWeeklyCommissionPool"
};
};
rpc GetUserCommissionPayouts(GetUserCommissionPayoutsRequest) returns (GetUserCommissionPayoutsResponse){
option (google.api.http) = {
get: "/GetUserCommissionPayouts"
};
};
rpc GetCommissionPayoutHistory(GetCommissionPayoutHistoryRequest) returns (GetCommissionPayoutHistoryResponse){
option (google.api.http) = {
get: "/GetCommissionPayoutHistory"
};
};
rpc GetUserWeeklyBalances(GetUserWeeklyBalancesRequest) returns (GetUserWeeklyBalancesResponse){
option (google.api.http) = {
get: "/GetUserWeeklyBalances"
};
};
rpc GetAllWeeklyPools(GetAllWeeklyPoolsRequest) returns (GetAllWeeklyPoolsResponse){
option (google.api.http) = {
get: "/GetAllWeeklyPools"
};
};
rpc GetWithdrawalRequests(GetWithdrawalRequestsRequest) returns (GetWithdrawalRequestsResponse){
option (google.api.http) = {
get: "/GetWithdrawalRequests"
};
};
rpc ApproveWithdrawal(ApproveWithdrawalRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
post: "/ApproveWithdrawal"
body: "*"
};
};
rpc RejectWithdrawal(RejectWithdrawalRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
post: "/RejectWithdrawal"
body: "*"
};
};
// Worker Control APIs
rpc TriggerWeeklyCalculation(TriggerWeeklyCalculationRequest) returns (TriggerWeeklyCalculationResponse){
option (google.api.http) = {
post: "/TriggerWeeklyCalculation"
body: "*"
};
};
rpc GetWorkerStatus(GetWorkerStatusRequest) returns (GetWorkerStatusResponse){
option (google.api.http) = {
get: "/GetWorkerStatus"
};
};
rpc GetWorkerExecutionLogs(GetWorkerExecutionLogsRequest) returns (GetWorkerExecutionLogsResponse){
option (google.api.http) = {
get: "/GetWorkerExecutionLogs"
};
};
rpc GetWithdrawalReports(GetWithdrawalReportsRequest) returns (GetWithdrawalReportsResponse){
option (google.api.http) = {
get: "/GetWithdrawalReports"
};
};
}

View File

@@ -20,10 +20,11 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" />
<PackageReference Include="Google.Api.CommonProtos" Version="2.10.0" />
</ItemGroup>
<ItemGroup>
<Protobuf Include="Protos\configuration.proto" GrpcServices="Client" AdditionalImportDirs="..\BackOffice.BFF.Common.Protobuf\Protos"/>
<Protobuf Include="Protos\configuration.proto" ProtoRoot="Protos\" GrpcServices="Server" AdditionalImportDirs="..\BackOffice.BFF.Common.Protobuf\Protos"/>
</ItemGroup>
<ItemGroup>

View File

@@ -6,16 +6,39 @@ import "public_messages.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";
option csharp_namespace = "Foursat.BackOffice.BFF.Configuration.Protobuf";
option csharp_namespace = "Foursat.BackOffice.BFF.Configuration.Protos";
service ConfigurationContract
{
rpc CreateOrUpdateConfiguration(CreateOrUpdateConfigurationRequest) returns (google.protobuf.Empty);
rpc DeactivateConfiguration(DeactivateConfigurationRequest) returns (google.protobuf.Empty);
rpc GetConfigurationByKey(GetConfigurationByKeyRequest) returns (GetConfigurationByKeyResponse);
rpc GetAllConfigurations(GetAllConfigurationsRequest) returns (GetAllConfigurationsResponse);
rpc GetConfigurationHistory(GetConfigurationHistoryRequest) returns (GetConfigurationHistoryResponse);
rpc CreateOrUpdateConfiguration(CreateOrUpdateConfigurationRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
post: "/CreateOrUpdateConfiguration"
body: "*"
};
};
rpc DeactivateConfiguration(DeactivateConfigurationRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
post: "/DeactivateConfiguration"
body: "*"
};
};
rpc GetConfigurationByKey(GetConfigurationByKeyRequest) returns (GetConfigurationByKeyResponse){
option (google.api.http) = {
get: "/GetConfigurationByKey"
};
};
rpc GetAllConfigurations(GetAllConfigurationsRequest) returns (GetAllConfigurationsResponse){
option (google.api.http) = {
get: "/GetAllConfigurations"
};
};
rpc GetConfigurationHistory(GetConfigurationHistoryRequest) returns (GetConfigurationHistoryResponse){
option (google.api.http) = {
get: "/GetConfigurationHistory"
};
};
}
// CreateOrUpdate Command

View File

@@ -20,10 +20,11 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" />
<PackageReference Include="Google.Api.CommonProtos" Version="2.10.0" />
</ItemGroup>
<ItemGroup>
<Protobuf Include="Protos\networkmembership.proto" GrpcServices="Client" AdditionalImportDirs="..\BackOffice.BFF.Common.Protobuf\Protos"/>
<Protobuf Include="Protos\networkmembership.proto" ProtoRoot="Protos\" GrpcServices="Server" AdditionalImportDirs="..\BackOffice.BFF.Common.Protobuf\Protos"/>
</ItemGroup>
<ItemGroup>

View File

@@ -6,18 +6,50 @@ import "public_messages.proto";
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.NetworkMembership.Protobuf";
option csharp_namespace = "Foursat.BackOffice.BFF.NetworkMembership.Protos";
service NetworkMembershipContract
{
rpc JoinNetwork(JoinNetworkRequest) returns (google.protobuf.Empty);
rpc ChangeNetworkParent(ChangeNetworkParentRequest) returns (google.protobuf.Empty);
rpc RemoveFromNetwork(RemoveFromNetworkRequest) returns (google.protobuf.Empty);
rpc GetUserNetwork(GetUserNetworkRequest) returns (GetUserNetworkResponse);
rpc GetNetworkTree(GetNetworkTreeRequest) returns (GetNetworkTreeResponse);
rpc GetNetworkMembershipHistory(GetNetworkMembershipHistoryRequest) returns (GetNetworkMembershipHistoryResponse);
rpc GetNetworkStatistics(GetNetworkStatisticsRequest) returns (GetNetworkStatisticsResponse);
rpc JoinNetwork(JoinNetworkRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
post: "/JoinNetwork"
body: "*"
};
};
rpc ChangeNetworkParent(ChangeNetworkParentRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
post: "/ChangeNetworkParent"
body: "*"
};
};
rpc RemoveFromNetwork(RemoveFromNetworkRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
delete: "/RemoveFromNetwork"
body: "*"
};
};
rpc GetUserNetwork(GetUserNetworkRequest) returns (GetUserNetworkResponse){
option (google.api.http) = {
get: "/GetUserNetwork"
};
};
rpc GetNetworkTree(GetNetworkTreeRequest) returns (GetNetworkTreeResponse){
option (google.api.http) = {
get: "/GetNetworkTree"
};
};
rpc GetNetworkMembershipHistory(GetNetworkMembershipHistoryRequest) returns (GetNetworkMembershipHistoryResponse){
option (google.api.http) = {
get: "/GetNetworkMembershipHistory"
};
};
rpc GetNetworkStatistics(GetNetworkStatisticsRequest) returns (GetNetworkStatisticsResponse){
option (google.api.http) = {
get: "/GetNetworkStatistics"
};
};
}
// JoinNetwork Command
@@ -72,7 +104,7 @@ message GetUserNetworkResponse
// GetNetworkTree Query
message GetNetworkTreeRequest
{
int64 root_user_id = 1;
int64 user_id = 1;
google.protobuf.Int32Value max_depth = 2;
google.protobuf.BoolValue only_active = 3;
}
@@ -87,9 +119,9 @@ message NetworkTreeNodeModel
int64 user_id = 1;
string user_name = 2;
google.protobuf.Int64Value parent_id = 3;
int32 network_leg = 4;
int32 network_level = 5;
bool is_active = 6;
google.protobuf.Int32Value network_leg = 4;
google.protobuf.Int32Value network_level = 5;
google.protobuf.BoolValue is_active = 6;
google.protobuf.Timestamp joined_at = 7;
}