002e99f6bf
- Added PersianDateTimeService for converting Gregorian dates to Persian format in the BackOffice frontend. - Updated multiple frontend pages (Dashboard, UserPayouts, WorkerControl, UserNetworkInfo) to utilize the new Persian date service. - Enhanced GetUserNetworkPositionDto with 28+ new fields for comprehensive user network data. - Updated GetUserNetworkPositionQueryHandler to include new methods for calculating network statistics. - Modified Protobuf messages to accommodate the new fields, increasing from 14 to 42. - Refined week number calculation algorithm to ensure consistency across C# and SQL implementations. - Created new CSV and Excel files for binary plan calculations. - Ensured all changes are tested and validated for accuracy and performance.
2.9 KiB
2.9 KiB
BackOffice.BFF
Backend For Frontend layer برای BackOffice UI
📋 خلاصه
BackOffice.BFF لایه واسط بین BackOffice UI و CMS microservices است که:
- درخواستهای UI را aggregate میکند
- قراردادهای gRPC اختصاصی ارائه میدهد
- منطق سطح BFF را پیادهسازی میکند
🏗️ معماری
Protobuf Projects (Own Contracts)
BackOffice.BFF از قراردادهای Protobuf اختصاصی خودش استفاده میکند:
| Project | Version | Namespace | Purpose |
|---|---|---|---|
| BackOffice.BFF.ClubMembership.Protobuf | 0.0.6 | Foursat.BackOffice.BFF.ClubMembership.Protos | باشگاه مشتریان |
| BackOffice.BFF.Commission.Protobuf | 0.0.6 | Foursat.BackOffice.BFF.Commission.Protos | کمیسیون |
| BackOffice.BFF.Configuration.Protobuf | 1.0.6 | Foursat.BackOffice.BFF.Configuration.Protos | تنظیمات |
| BackOffice.BFF.NetworkMembership.Protobuf | 0.0.6 | Foursat.BackOffice.BFF.NetworkMembership.Protos | شبکه |
تغییر معماری (۱۷ آذر ۱۴۰۴):
- ❌ قبلا: استفاده مستقیم از
CMSMicroservice.Protobuf(Anti-Pattern) - ✅ حالا: Protobuf اختصاصی با namespace مجزا
- ✅ مزایا: جدایی concerns، versioning مستقل، کاهش coupling
GrpcServices Mode
همه پروژههای Protobuf با GrpcServices="Both" پیکربندی شدهاند:
- Server: Base classes برای پیادهسازی در BFF
- Client: Client classes برای استفاده در BackOffice UI
HTTP Annotations (Swagger)
همه 33 endpoint با HTTP annotations پیادهسازی شدهاند:
import "google/api/annotations.proto";
rpc GetClubMembershipById(GetClubMembershipByIdRequest) returns (GetClubMembershipByIdResponse) {
option (google.api.http) = { get: "/GetClubMembershipById" };
}
Package: Google.Api.CommonProtos v2.10.0
🔧 Mapster Configuration
Immutable Type Handling
Protobuf messages دارای فیلدهای immutable هستند. از MapWith() استفاده کنید:
config.NewConfig<GetNetworkTreeResponseDto, GetNetworkTreeResponse>()
.MapWith(src => new GetNetworkTreeResponse {
Items = { src.Items.Select(x => new NetworkTreeNodeModel {
UserId = x.UserId,
FirstName = x.FirstName,
// ...
}) }
});
Profiles:
- NetworkMembershipProfile.cs
- ProductsProfile.cs
📦 Package Publishing
برای publish به GitLab registry:
cd BackOffice.BFF.{Module}.Protobuf
dotnet pack -c Release
# Auto-push via PushToFourSat target
Registry: https://git.afrino.co/api/packages/FourSat/nuget