feat: Add gRPC API Layer - Phase 6 Integration
Added Protobuf definitions and gRPC services for all CQ layers:
Protobuf Files (4):
- configuration.proto: 2 Commands + 3 Queries (5 RPCs)
- clubmembership.proto: 3 Commands + 3 Queries (6 RPCs)
- networkmembership.proto: 3 Commands + 3 Queries (6 RPCs)
- commission.proto: 5 Commands + 4 Queries (9 RPCs)
gRPC Services (4):
- ConfigurationService: SetConfigurationValue, Deactivate, GetByKey, GetAll, GetHistory
- ClubMembershipService: Activate, Deactivate, AssignFeature, Get, GetAll, GetHistory
- NetworkMembershipService: Join, Move, Remove, GetPosition, GetTree, GetHistory
- CommissionService: Calculate+Process+Withdraw (5 commands), Get queries (4)
Features:
- HTTP transcoding enabled via google.api.http annotations
- Auto-registration via ConfigureGrpcEndpoints
- MetaData pagination support
- Request/Response DTOs for all endpoints
- Integration with MediatR CQRS handlers
Total: 4 proto files, 4 service classes, 26 RPC endpoints
Build: ✅ Successful (0 errors)
This commit is contained in:
@@ -43,6 +43,11 @@
|
||||
<Protobuf Include="Protos\category.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||
<Protobuf Include="Protos\tag.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||
<Protobuf Include="Protos\pruducttag.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||
<!-- Network Club Commission System - Phase 6 -->
|
||||
<Protobuf Include="Protos\configuration.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||
<Protobuf Include="Protos\clubmembership.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||
<Protobuf Include="Protos\networkmembership.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||
<Protobuf Include="Protos\commission.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PushToFoursatNuget" AfterTargets="Pack">
|
||||
|
||||
166
src/CMSMicroservice.Protobuf/Protos/clubmembership.proto
Normal file
166
src/CMSMicroservice.Protobuf/Protos/clubmembership.proto
Normal file
@@ -0,0 +1,166 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package clubmembership;
|
||||
|
||||
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 = "CMSMicroservice.Protobuf.Protos.ClubMembership";
|
||||
|
||||
service ClubMembershipContract
|
||||
{
|
||||
rpc ActivateClubMembership(ActivateClubMembershipRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
post: "/ClubMembership/Activate"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc DeactivateClubMembership(DeactivateClubMembershipRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
post: "/ClubMembership/Deactivate"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc AssignFeatureToMembership(AssignFeatureToMembershipRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
post: "/ClubMembership/AssignFeature"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc GetClubMembership(GetClubMembershipRequest) returns (GetClubMembershipResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/ClubMembership/Get"
|
||||
};
|
||||
};
|
||||
rpc GetAllClubMemberships(GetAllClubMembershipsRequest) returns (GetAllClubMembershipsResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/ClubMembership/GetAll"
|
||||
};
|
||||
};
|
||||
rpc GetClubMembershipHistory(GetClubMembershipHistoryRequest) returns (GetClubMembershipHistoryResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/ClubMembership/GetHistory"
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
// Activate Command
|
||||
message ActivateClubMembershipRequest
|
||||
{
|
||||
int64 user_id = 1;
|
||||
int64 package_id = 2;
|
||||
google.protobuf.StringValue activation_code = 3;
|
||||
int32 duration_months = 4;
|
||||
}
|
||||
|
||||
// Deactivate Command
|
||||
message DeactivateClubMembershipRequest
|
||||
{
|
||||
int64 user_id = 1;
|
||||
string reason = 2;
|
||||
}
|
||||
|
||||
// AssignFeature Command
|
||||
message AssignFeatureToMembershipRequest
|
||||
{
|
||||
int64 user_id = 1;
|
||||
int64 product_id = 2;
|
||||
google.protobuf.Int32Value quantity = 3;
|
||||
google.protobuf.Int32Value duration_days = 4;
|
||||
}
|
||||
|
||||
// Get Query
|
||||
message GetClubMembershipRequest
|
||||
{
|
||||
int64 user_id = 1;
|
||||
}
|
||||
|
||||
message GetClubMembershipResponse
|
||||
{
|
||||
int64 id = 1;
|
||||
int64 user_id = 2;
|
||||
int64 package_id = 3;
|
||||
string package_name = 4;
|
||||
string activation_code = 5;
|
||||
google.protobuf.Timestamp activated_at = 6;
|
||||
google.protobuf.Timestamp expires_at = 7;
|
||||
bool is_active = 8;
|
||||
google.protobuf.Timestamp created = 9;
|
||||
repeated MembershipFeatureModel features = 10;
|
||||
}
|
||||
|
||||
message MembershipFeatureModel
|
||||
{
|
||||
int64 product_id = 1;
|
||||
string product_name = 2;
|
||||
int32 quantity = 3;
|
||||
google.protobuf.Timestamp expires_at = 4;
|
||||
bool is_active = 5;
|
||||
}
|
||||
|
||||
// GetAll Query
|
||||
message GetAllClubMembershipsRequest
|
||||
{
|
||||
google.protobuf.Int64Value user_id = 1;
|
||||
google.protobuf.Int64Value package_id = 2;
|
||||
google.protobuf.BoolValue is_active = 3;
|
||||
google.protobuf.BoolValue is_expired = 4;
|
||||
int32 page_index = 5;
|
||||
int32 page_size = 6;
|
||||
}
|
||||
|
||||
message GetAllClubMembershipsResponse
|
||||
{
|
||||
messages.MetaData meta_data = 1;
|
||||
repeated ClubMembershipModel models = 2;
|
||||
}
|
||||
|
||||
message ClubMembershipModel
|
||||
{
|
||||
int64 id = 1;
|
||||
int64 user_id = 2;
|
||||
string user_name = 3;
|
||||
int64 package_id = 4;
|
||||
string package_name = 5;
|
||||
string activation_code = 6;
|
||||
google.protobuf.Timestamp activated_at = 7;
|
||||
google.protobuf.Timestamp expires_at = 8;
|
||||
bool is_active = 9;
|
||||
bool is_expired = 10;
|
||||
google.protobuf.Timestamp created = 11;
|
||||
}
|
||||
|
||||
// GetHistory Query
|
||||
message GetClubMembershipHistoryRequest
|
||||
{
|
||||
google.protobuf.Int64Value user_id = 1;
|
||||
google.protobuf.Int64Value package_id = 2;
|
||||
int32 page_index = 3;
|
||||
int32 page_size = 4;
|
||||
}
|
||||
|
||||
message GetClubMembershipHistoryResponse
|
||||
{
|
||||
messages.MetaData meta_data = 1;
|
||||
repeated ClubMembershipHistoryModel models = 2;
|
||||
}
|
||||
|
||||
message ClubMembershipHistoryModel
|
||||
{
|
||||
int64 id = 1;
|
||||
int64 club_membership_id = 2;
|
||||
int64 user_id = 3;
|
||||
google.protobuf.Int64Value old_package_id = 4;
|
||||
google.protobuf.Int64Value new_package_id = 5;
|
||||
google.protobuf.Timestamp old_activated_at = 6;
|
||||
google.protobuf.Timestamp new_activated_at = 7;
|
||||
google.protobuf.Timestamp old_expires_at = 8;
|
||||
google.protobuf.Timestamp new_expires_at = 9;
|
||||
int32 action = 10; // ClubMembershipAction enum
|
||||
string performed_by = 11;
|
||||
string reason = 12;
|
||||
google.protobuf.Timestamp created = 13;
|
||||
}
|
||||
220
src/CMSMicroservice.Protobuf/Protos/commission.proto
Normal file
220
src/CMSMicroservice.Protobuf/Protos/commission.proto
Normal file
@@ -0,0 +1,220 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package commission;
|
||||
|
||||
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 = "CMSMicroservice.Protobuf.Protos.Commission";
|
||||
|
||||
service CommissionContract
|
||||
{
|
||||
// Commands
|
||||
rpc CalculateWeeklyBalances(CalculateWeeklyBalancesRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
post: "/Commission/CalculateWeeklyBalances"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc CalculateWeeklyCommissionPool(CalculateWeeklyCommissionPoolRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
post: "/Commission/CalculateWeeklyPool"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc ProcessUserPayouts(ProcessUserPayoutsRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
post: "/Commission/ProcessPayouts"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc RequestWithdrawal(RequestWithdrawalRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
post: "/Commission/RequestWithdrawal"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc ProcessWithdrawal(ProcessWithdrawalRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
post: "/Commission/ProcessWithdrawal"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
|
||||
// Queries
|
||||
rpc GetWeeklyCommissionPool(GetWeeklyCommissionPoolRequest) returns (GetWeeklyCommissionPoolResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/Commission/GetWeeklyPool"
|
||||
};
|
||||
};
|
||||
rpc GetUserCommissionPayouts(GetUserCommissionPayoutsRequest) returns (GetUserCommissionPayoutsResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/Commission/GetUserPayouts"
|
||||
};
|
||||
};
|
||||
rpc GetCommissionPayoutHistory(GetCommissionPayoutHistoryRequest) returns (GetCommissionPayoutHistoryResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/Commission/GetPayoutHistory"
|
||||
};
|
||||
};
|
||||
rpc GetUserWeeklyBalances(GetUserWeeklyBalancesRequest) returns (GetUserWeeklyBalancesResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/Commission/GetUserWeeklyBalances"
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
// ============ Commands ============
|
||||
|
||||
// CalculateWeeklyBalances Command
|
||||
message CalculateWeeklyBalancesRequest
|
||||
{
|
||||
string week_number = 1; // Format: "YYYY-Www" (e.g., "2025-W01")
|
||||
bool force_recalculate = 2;
|
||||
}
|
||||
|
||||
// CalculateWeeklyCommissionPool Command
|
||||
message CalculateWeeklyCommissionPoolRequest
|
||||
{
|
||||
string week_number = 1;
|
||||
}
|
||||
|
||||
// ProcessUserPayouts Command
|
||||
message ProcessUserPayoutsRequest
|
||||
{
|
||||
string week_number = 1;
|
||||
bool force_reprocess = 2;
|
||||
}
|
||||
|
||||
// RequestWithdrawal Command
|
||||
message RequestWithdrawalRequest
|
||||
{
|
||||
int64 payout_id = 1;
|
||||
int32 withdrawal_method = 2; // WithdrawalMethod enum: Cash=0, Diamond=1
|
||||
google.protobuf.StringValue iban_number = 3; // Required for Cash method
|
||||
}
|
||||
|
||||
// ProcessWithdrawal Command
|
||||
message ProcessWithdrawalRequest
|
||||
{
|
||||
int64 payout_id = 1;
|
||||
bool is_approved = 2;
|
||||
google.protobuf.StringValue reason = 3; // Required for rejection
|
||||
}
|
||||
|
||||
// ============ Queries ============
|
||||
|
||||
// GetWeeklyCommissionPool Query
|
||||
message GetWeeklyCommissionPoolRequest
|
||||
{
|
||||
string week_number = 1;
|
||||
}
|
||||
|
||||
message GetWeeklyCommissionPoolResponse
|
||||
{
|
||||
int64 id = 1;
|
||||
string week_number = 2;
|
||||
int64 total_pool_amount = 3; // Rials
|
||||
int32 total_balances = 4;
|
||||
int64 value_per_balance = 5; // Rials per balance
|
||||
bool is_calculated = 6;
|
||||
google.protobuf.Timestamp calculated_at = 7;
|
||||
google.protobuf.Timestamp created = 8;
|
||||
}
|
||||
|
||||
// GetUserCommissionPayouts Query
|
||||
message GetUserCommissionPayoutsRequest
|
||||
{
|
||||
google.protobuf.Int64Value user_id = 1;
|
||||
google.protobuf.Int32Value status = 2; // CommissionPayoutStatus enum
|
||||
google.protobuf.StringValue week_number = 3;
|
||||
int32 page_index = 4;
|
||||
int32 page_size = 5;
|
||||
}
|
||||
|
||||
message GetUserCommissionPayoutsResponse
|
||||
{
|
||||
messages.MetaData meta_data = 1;
|
||||
repeated UserCommissionPayoutModel models = 2;
|
||||
}
|
||||
|
||||
message UserCommissionPayoutModel
|
||||
{
|
||||
int64 id = 1;
|
||||
int64 user_id = 2;
|
||||
string user_name = 3;
|
||||
string week_number = 4;
|
||||
int32 balances_earned = 5;
|
||||
int64 value_per_balance = 6;
|
||||
int64 total_amount = 7;
|
||||
int32 status = 8; // CommissionPayoutStatus enum
|
||||
google.protobuf.Int32Value withdrawal_method = 9;
|
||||
string iban_number = 10;
|
||||
google.protobuf.Timestamp created = 11;
|
||||
google.protobuf.Timestamp last_modified = 12;
|
||||
}
|
||||
|
||||
// GetCommissionPayoutHistory Query
|
||||
message GetCommissionPayoutHistoryRequest
|
||||
{
|
||||
google.protobuf.Int64Value payout_id = 1;
|
||||
google.protobuf.Int64Value user_id = 2;
|
||||
google.protobuf.StringValue week_number = 3;
|
||||
int32 page_index = 4;
|
||||
int32 page_size = 5;
|
||||
}
|
||||
|
||||
message GetCommissionPayoutHistoryResponse
|
||||
{
|
||||
messages.MetaData meta_data = 1;
|
||||
repeated CommissionPayoutHistoryModel models = 2;
|
||||
}
|
||||
|
||||
message CommissionPayoutHistoryModel
|
||||
{
|
||||
int64 id = 1;
|
||||
int64 payout_id = 2;
|
||||
int64 user_id = 3;
|
||||
string week_number = 4;
|
||||
int64 amount_before = 5;
|
||||
int64 amount_after = 6;
|
||||
int32 old_status = 7; // CommissionPayoutStatus enum
|
||||
int32 new_status = 8;
|
||||
int32 action = 9; // CommissionPayoutAction enum
|
||||
string performed_by = 10;
|
||||
string reason = 11;
|
||||
google.protobuf.Timestamp created = 12;
|
||||
}
|
||||
|
||||
// GetUserWeeklyBalances Query
|
||||
message GetUserWeeklyBalancesRequest
|
||||
{
|
||||
google.protobuf.Int64Value user_id = 1;
|
||||
google.protobuf.StringValue week_number = 2;
|
||||
bool only_active = 3; // Only non-expired balances
|
||||
int32 page_index = 4;
|
||||
int32 page_size = 5;
|
||||
}
|
||||
|
||||
message GetUserWeeklyBalancesResponse
|
||||
{
|
||||
messages.MetaData meta_data = 1;
|
||||
repeated UserWeeklyBalanceModel models = 2;
|
||||
}
|
||||
|
||||
message UserWeeklyBalanceModel
|
||||
{
|
||||
int64 id = 1;
|
||||
int64 user_id = 2;
|
||||
string week_number = 3;
|
||||
int32 left_leg_balances = 4;
|
||||
int32 right_leg_balances = 5;
|
||||
int32 total_balances = 6;
|
||||
int64 weekly_pool_contribution = 7;
|
||||
google.protobuf.Timestamp calculated_at = 8;
|
||||
bool is_expired = 9;
|
||||
google.protobuf.Timestamp created = 10;
|
||||
}
|
||||
133
src/CMSMicroservice.Protobuf/Protos/configuration.proto
Normal file
133
src/CMSMicroservice.Protobuf/Protos/configuration.proto
Normal file
@@ -0,0 +1,133 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package configuration;
|
||||
|
||||
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 = "CMSMicroservice.Protobuf.Protos.Configuration";
|
||||
|
||||
service ConfigurationContract
|
||||
{
|
||||
rpc CreateOrUpdateConfiguration(CreateOrUpdateConfigurationRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
post: "/Configuration/CreateOrUpdate"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc DeactivateConfiguration(DeactivateConfigurationRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
post: "/Configuration/Deactivate"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc GetConfigurationByKey(GetConfigurationByKeyRequest) returns (GetConfigurationByKeyResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/Configuration/GetByKey"
|
||||
};
|
||||
};
|
||||
rpc GetAllConfigurations(GetAllConfigurationsRequest) returns (GetAllConfigurationsResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/Configuration/GetAll"
|
||||
};
|
||||
};
|
||||
rpc GetConfigurationHistory(GetConfigurationHistoryRequest) returns (GetConfigurationHistoryResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/Configuration/GetHistory"
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
// CreateOrUpdate Command
|
||||
message CreateOrUpdateConfigurationRequest
|
||||
{
|
||||
string key = 1;
|
||||
string value = 2;
|
||||
google.protobuf.StringValue description = 3;
|
||||
int32 scope = 4; // ConfigurationScope enum: System=0, Network=1, Club=2, Commission=3
|
||||
}
|
||||
|
||||
// Deactivate Command
|
||||
message DeactivateConfigurationRequest
|
||||
{
|
||||
string key = 1;
|
||||
google.protobuf.StringValue reason = 2;
|
||||
}
|
||||
|
||||
// GetByKey Query
|
||||
message GetConfigurationByKeyRequest
|
||||
{
|
||||
string key = 1;
|
||||
}
|
||||
|
||||
message GetConfigurationByKeyResponse
|
||||
{
|
||||
int64 id = 1;
|
||||
string key = 2;
|
||||
string value = 3;
|
||||
string description = 4;
|
||||
int32 scope = 5;
|
||||
bool is_active = 6;
|
||||
google.protobuf.Timestamp created = 7;
|
||||
google.protobuf.Timestamp last_modified = 8;
|
||||
}
|
||||
|
||||
// GetAll Query
|
||||
message GetAllConfigurationsRequest
|
||||
{
|
||||
google.protobuf.Int32Value scope = 1;
|
||||
google.protobuf.BoolValue is_active = 2;
|
||||
int32 page_index = 3;
|
||||
int32 page_size = 4;
|
||||
}
|
||||
|
||||
message GetAllConfigurationsResponse
|
||||
{
|
||||
messages.MetaData meta_data = 1;
|
||||
repeated ConfigurationModel models = 2;
|
||||
}
|
||||
|
||||
message ConfigurationModel
|
||||
{
|
||||
int64 id = 1;
|
||||
string key = 2;
|
||||
string value = 3;
|
||||
string description = 4;
|
||||
int32 scope = 5;
|
||||
bool is_active = 6;
|
||||
google.protobuf.Timestamp created = 7;
|
||||
}
|
||||
|
||||
// GetHistory Query
|
||||
message GetConfigurationHistoryRequest
|
||||
{
|
||||
google.protobuf.Int64Value configuration_id = 1;
|
||||
google.protobuf.StringValue key = 2;
|
||||
int32 page_index = 3;
|
||||
int32 page_size = 4;
|
||||
}
|
||||
|
||||
message GetConfigurationHistoryResponse
|
||||
{
|
||||
messages.MetaData meta_data = 1;
|
||||
repeated ConfigurationHistoryModel models = 2;
|
||||
}
|
||||
|
||||
message ConfigurationHistoryModel
|
||||
{
|
||||
int64 id = 1;
|
||||
int64 configuration_id = 2;
|
||||
string key = 3;
|
||||
string old_value = 4;
|
||||
string new_value = 5;
|
||||
string old_description = 6;
|
||||
string new_description = 7;
|
||||
int32 old_scope = 8;
|
||||
int32 new_scope = 9;
|
||||
string performed_by = 10;
|
||||
string reason = 11;
|
||||
google.protobuf.Timestamp created = 12;
|
||||
}
|
||||
152
src/CMSMicroservice.Protobuf/Protos/networkmembership.proto
Normal file
152
src/CMSMicroservice.Protobuf/Protos/networkmembership.proto
Normal file
@@ -0,0 +1,152 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package networkmembership;
|
||||
|
||||
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 = "CMSMicroservice.Protobuf.Protos.NetworkMembership";
|
||||
|
||||
service NetworkMembershipContract
|
||||
{
|
||||
rpc JoinNetwork(JoinNetworkRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
post: "/NetworkMembership/Join"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc ChangeNetworkParent(ChangeNetworkParentRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
post: "/NetworkMembership/ChangeParent"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc RemoveFromNetwork(RemoveFromNetworkRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
post: "/NetworkMembership/Remove"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc GetUserNetwork(GetUserNetworkRequest) returns (GetUserNetworkResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/NetworkMembership/GetUserNetwork"
|
||||
};
|
||||
};
|
||||
rpc GetNetworkTree(GetNetworkTreeRequest) returns (GetNetworkTreeResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/NetworkMembership/GetNetworkTree"
|
||||
};
|
||||
};
|
||||
rpc GetNetworkMembershipHistory(GetNetworkMembershipHistoryRequest) returns (GetNetworkMembershipHistoryResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/NetworkMembership/GetHistory"
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
// JoinNetwork Command
|
||||
message JoinNetworkRequest
|
||||
{
|
||||
int64 user_id = 1;
|
||||
int64 parent_id = 2;
|
||||
int32 leg = 3; // NetworkLeg enum: Left=0, Right=1
|
||||
google.protobuf.StringValue referral_code = 4;
|
||||
}
|
||||
|
||||
// ChangeParent Command
|
||||
message ChangeNetworkParentRequest
|
||||
{
|
||||
int64 user_id = 1;
|
||||
int64 new_parent_id = 2;
|
||||
int32 new_leg = 3; // NetworkLeg enum
|
||||
string reason = 4;
|
||||
}
|
||||
|
||||
// Remove Command
|
||||
message RemoveFromNetworkRequest
|
||||
{
|
||||
int64 user_id = 1;
|
||||
string reason = 2;
|
||||
}
|
||||
|
||||
// GetUserNetwork Query
|
||||
message GetUserNetworkRequest
|
||||
{
|
||||
int64 user_id = 1;
|
||||
}
|
||||
|
||||
message GetUserNetworkResponse
|
||||
{
|
||||
int64 id = 1;
|
||||
int64 user_id = 2;
|
||||
string user_name = 3;
|
||||
google.protobuf.Int64Value parent_id = 4;
|
||||
string parent_name = 5;
|
||||
int32 network_leg = 6; // NetworkLeg enum
|
||||
google.protobuf.Int64Value left_child_id = 7;
|
||||
string left_child_name = 8;
|
||||
google.protobuf.Int64Value right_child_id = 9;
|
||||
string right_child_name = 10;
|
||||
int32 network_level = 11;
|
||||
string referral_code = 12;
|
||||
google.protobuf.Timestamp joined_at = 13;
|
||||
google.protobuf.Timestamp created = 14;
|
||||
}
|
||||
|
||||
// GetNetworkTree Query
|
||||
message GetNetworkTreeRequest
|
||||
{
|
||||
int64 root_user_id = 1;
|
||||
google.protobuf.Int32Value max_depth = 2;
|
||||
google.protobuf.BoolValue only_active = 3;
|
||||
}
|
||||
|
||||
message GetNetworkTreeResponse
|
||||
{
|
||||
repeated NetworkTreeNodeModel nodes = 1;
|
||||
}
|
||||
|
||||
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.Timestamp joined_at = 7;
|
||||
}
|
||||
|
||||
// GetHistory Query
|
||||
message GetNetworkMembershipHistoryRequest
|
||||
{
|
||||
google.protobuf.Int64Value user_id = 1;
|
||||
google.protobuf.Int64Value parent_id = 2;
|
||||
int32 page_index = 3;
|
||||
int32 page_size = 4;
|
||||
}
|
||||
|
||||
message GetNetworkMembershipHistoryResponse
|
||||
{
|
||||
messages.MetaData meta_data = 1;
|
||||
repeated NetworkMembershipHistoryModel models = 2;
|
||||
}
|
||||
|
||||
message NetworkMembershipHistoryModel
|
||||
{
|
||||
int64 id = 1;
|
||||
int64 user_id = 2;
|
||||
google.protobuf.Int64Value old_parent_id = 3;
|
||||
google.protobuf.Int64Value new_parent_id = 4;
|
||||
google.protobuf.Int32Value old_network_leg = 5;
|
||||
google.protobuf.Int32Value new_network_leg = 6;
|
||||
google.protobuf.Int32Value old_network_level = 7;
|
||||
google.protobuf.Int32Value new_network_level = 8;
|
||||
int32 action = 9; // NetworkMembershipAction enum
|
||||
string performed_by = 10;
|
||||
string reason = 11;
|
||||
google.protobuf.Timestamp created = 12;
|
||||
}
|
||||
50
src/CMSMicroservice.WebApi/Services/ClubMembershipService.cs
Normal file
50
src/CMSMicroservice.WebApi/Services/ClubMembershipService.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using CMSMicroservice.Protobuf.Protos.ClubMembership;
|
||||
using CMSMicroservice.WebApi.Common.Services;
|
||||
using CMSMicroservice.Application.ClubMembershipCQ.Commands.ActivateClubMembership;
|
||||
using CMSMicroservice.Application.ClubMembershipCQ.Commands.DeactivateClubMembership;
|
||||
using CMSMicroservice.Application.ClubMembershipCQ.Commands.AssignClubFeature;
|
||||
using CMSMicroservice.Application.ClubMembershipCQ.Queries.GetClubMembership;
|
||||
using CMSMicroservice.Application.ClubMembershipCQ.Queries.GetAllClubMemberships;
|
||||
using CMSMicroservice.Application.ClubMembershipCQ.Queries.GetClubMembershipHistory;
|
||||
|
||||
namespace CMSMicroservice.WebApi.Services;
|
||||
|
||||
public class ClubMembershipService : ClubMembershipContract.ClubMembershipContractBase
|
||||
{
|
||||
private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;
|
||||
|
||||
public ClubMembershipService(IDispatchRequestToCQRS dispatchRequestToCQRS)
|
||||
{
|
||||
_dispatchRequestToCQRS = dispatchRequestToCQRS;
|
||||
}
|
||||
|
||||
public override async Task<Empty> ActivateClubMembership(ActivateClubMembershipRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<ActivateClubMembershipRequest, ActivateClubMembershipCommand>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<Empty> DeactivateClubMembership(DeactivateClubMembershipRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<DeactivateClubMembershipRequest, DeactivateClubMembershipCommand>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<Empty> AssignFeatureToMembership(AssignFeatureToMembershipRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<AssignFeatureToMembershipRequest, AssignClubFeatureCommand>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<GetClubMembershipResponse> GetClubMembership(GetClubMembershipRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetClubMembershipRequest, GetClubMembershipQuery, GetClubMembershipResponse>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<GetAllClubMembershipsResponse> GetAllClubMemberships(GetAllClubMembershipsRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetAllClubMembershipsRequest, GetAllClubMembershipsQuery, GetAllClubMembershipsResponse>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<GetClubMembershipHistoryResponse> GetClubMembershipHistory(GetClubMembershipHistoryRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetClubMembershipHistoryRequest, GetClubMembershipHistoryQuery, GetClubMembershipHistoryResponse>(request, context);
|
||||
}
|
||||
}
|
||||
70
src/CMSMicroservice.WebApi/Services/CommissionService.cs
Normal file
70
src/CMSMicroservice.WebApi/Services/CommissionService.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
using CMSMicroservice.WebApi.Common.Services;
|
||||
using CMSMicroservice.Application.CommissionCQ.Commands.CalculateWeeklyBalances;
|
||||
using CMSMicroservice.Application.CommissionCQ.Commands.CalculateWeeklyCommissionPool;
|
||||
using CMSMicroservice.Application.CommissionCQ.Commands.ProcessUserPayouts;
|
||||
using CMSMicroservice.Application.CommissionCQ.Commands.RequestWithdrawal;
|
||||
using CMSMicroservice.Application.CommissionCQ.Commands.ProcessWithdrawal;
|
||||
using CMSMicroservice.Application.CommissionCQ.Queries.GetWeeklyCommissionPool;
|
||||
using CMSMicroservice.Application.CommissionCQ.Queries.GetUserCommissionPayouts;
|
||||
using CMSMicroservice.Application.CommissionCQ.Queries.GetCommissionPayoutHistory;
|
||||
using CMSMicroservice.Application.CommissionCQ.Queries.GetUserWeeklyBalances;
|
||||
|
||||
namespace CMSMicroservice.WebApi.Services;
|
||||
|
||||
public class CommissionService : CommissionContract.CommissionContractBase
|
||||
{
|
||||
private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;
|
||||
|
||||
public CommissionService(IDispatchRequestToCQRS dispatchRequestToCQRS)
|
||||
{
|
||||
_dispatchRequestToCQRS = dispatchRequestToCQRS;
|
||||
}
|
||||
|
||||
// Commands
|
||||
public override async Task<Empty> CalculateWeeklyBalances(CalculateWeeklyBalancesRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<CalculateWeeklyBalancesRequest, CalculateWeeklyBalancesCommand>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<Empty> CalculateWeeklyCommissionPool(CalculateWeeklyCommissionPoolRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<CalculateWeeklyCommissionPoolRequest, CalculateWeeklyCommissionPoolCommand>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<Empty> ProcessUserPayouts(ProcessUserPayoutsRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<ProcessUserPayoutsRequest, ProcessUserPayoutsCommand>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<Empty> RequestWithdrawal(RequestWithdrawalRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<RequestWithdrawalRequest, RequestWithdrawalCommand>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<Empty> ProcessWithdrawal(ProcessWithdrawalRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<ProcessWithdrawalRequest, ProcessWithdrawalCommand>(request, context);
|
||||
}
|
||||
|
||||
// Queries
|
||||
public override async Task<GetWeeklyCommissionPoolResponse> GetWeeklyCommissionPool(GetWeeklyCommissionPoolRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetWeeklyCommissionPoolRequest, GetWeeklyCommissionPoolQuery, GetWeeklyCommissionPoolResponse>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<GetUserCommissionPayoutsResponse> GetUserCommissionPayouts(GetUserCommissionPayoutsRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetUserCommissionPayoutsRequest, GetUserCommissionPayoutsQuery, GetUserCommissionPayoutsResponse>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<GetCommissionPayoutHistoryResponse> GetCommissionPayoutHistory(GetCommissionPayoutHistoryRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetCommissionPayoutHistoryRequest, GetCommissionPayoutHistoryQuery, GetCommissionPayoutHistoryResponse>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<GetUserWeeklyBalancesResponse> GetUserWeeklyBalances(GetUserWeeklyBalancesRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetUserWeeklyBalancesRequest, GetUserWeeklyBalancesQuery, GetUserWeeklyBalancesResponse>(request, context);
|
||||
}
|
||||
}
|
||||
44
src/CMSMicroservice.WebApi/Services/ConfigurationService.cs
Normal file
44
src/CMSMicroservice.WebApi/Services/ConfigurationService.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using CMSMicroservice.Protobuf.Protos.Configuration;
|
||||
using CMSMicroservice.WebApi.Common.Services;
|
||||
using CMSMicroservice.Application.ConfigurationCQ.Commands.SetConfigurationValue;
|
||||
using CMSMicroservice.Application.ConfigurationCQ.Commands.DeactivateConfiguration;
|
||||
using CMSMicroservice.Application.ConfigurationCQ.Queries.GetConfigurationByKey;
|
||||
using CMSMicroservice.Application.ConfigurationCQ.Queries.GetAllConfigurations;
|
||||
using CMSMicroservice.Application.ConfigurationCQ.Queries.GetConfigurationHistory;
|
||||
|
||||
namespace CMSMicroservice.WebApi.Services;
|
||||
|
||||
public class ConfigurationService : ConfigurationContract.ConfigurationContractBase
|
||||
{
|
||||
private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;
|
||||
|
||||
public ConfigurationService(IDispatchRequestToCQRS dispatchRequestToCQRS)
|
||||
{
|
||||
_dispatchRequestToCQRS = dispatchRequestToCQRS;
|
||||
}
|
||||
|
||||
public override async Task<Empty> CreateOrUpdateConfiguration(CreateOrUpdateConfigurationRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<CreateOrUpdateConfigurationRequest, SetConfigurationValueCommand>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<Empty> DeactivateConfiguration(DeactivateConfigurationRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<DeactivateConfigurationRequest, DeactivateConfigurationCommand>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<GetConfigurationByKeyResponse> GetConfigurationByKey(GetConfigurationByKeyRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetConfigurationByKeyRequest, GetConfigurationByKeyQuery, GetConfigurationByKeyResponse>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<GetAllConfigurationsResponse> GetAllConfigurations(GetAllConfigurationsRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetAllConfigurationsRequest, GetAllConfigurationsQuery, GetAllConfigurationsResponse>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<GetConfigurationHistoryResponse> GetConfigurationHistory(GetConfigurationHistoryRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetConfigurationHistoryRequest, GetConfigurationHistoryQuery, GetConfigurationHistoryResponse>(request, context);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
|
||||
using CMSMicroservice.WebApi.Common.Services;
|
||||
using CMSMicroservice.Application.NetworkMembershipCQ.Commands.JoinNetwork;
|
||||
using CMSMicroservice.Application.NetworkMembershipCQ.Commands.MoveInNetwork;
|
||||
using CMSMicroservice.Application.NetworkMembershipCQ.Commands.RemoveFromNetwork;
|
||||
using CMSMicroservice.Application.NetworkMembershipCQ.Queries.GetUserNetworkPosition;
|
||||
using CMSMicroservice.Application.NetworkMembershipCQ.Queries.GetNetworkTree;
|
||||
using CMSMicroservice.Application.NetworkMembershipCQ.Queries.GetNetworkMembershipHistory;
|
||||
|
||||
namespace CMSMicroservice.WebApi.Services;
|
||||
|
||||
public class NetworkMembershipService : NetworkMembershipContract.NetworkMembershipContractBase
|
||||
{
|
||||
private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;
|
||||
|
||||
public NetworkMembershipService(IDispatchRequestToCQRS dispatchRequestToCQRS)
|
||||
{
|
||||
_dispatchRequestToCQRS = dispatchRequestToCQRS;
|
||||
}
|
||||
|
||||
public override async Task<Empty> JoinNetwork(JoinNetworkRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<JoinNetworkRequest, JoinNetworkCommand>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<Empty> ChangeNetworkParent(ChangeNetworkParentRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<ChangeNetworkParentRequest, MoveInNetworkCommand>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<Empty> RemoveFromNetwork(RemoveFromNetworkRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<RemoveFromNetworkRequest, RemoveFromNetworkCommand>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<GetUserNetworkResponse> GetUserNetwork(GetUserNetworkRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetUserNetworkRequest, GetUserNetworkPositionQuery, GetUserNetworkResponse>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<GetNetworkTreeResponse> GetNetworkTree(GetNetworkTreeRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetNetworkTreeRequest, GetNetworkTreeQuery, GetNetworkTreeResponse>(request, context);
|
||||
}
|
||||
|
||||
public override async Task<GetNetworkMembershipHistoryResponse> GetNetworkMembershipHistory(GetNetworkMembershipHistoryRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetNetworkMembershipHistoryRequest, GetNetworkMembershipHistoryQuery, GetNetworkMembershipHistoryResponse>(request, context);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user