73e1971cc3
- Added DiscountProductImage entity and related configurations for product image gallery. - Created commands and queries for managing product images. - Developed GetAllDiscountOrders API for admin order management with various filters. - Implemented VAT calculation service and integrated it into order processing. - Created Sales Reports API with support for daily, weekly, and monthly reports. - Completed gRPC services for BackOffice.BFF to expose new APIs. - Updated Proto files and project references accordingly.
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.7 | Foursat.BackOffice.BFF.ClubMembership.Protos | باشگاه مشتریان |
| BackOffice.BFF.Commission.Protobuf | 0.0.13 | Foursat.BackOffice.BFF.Commission.Protos | کمیسیون |
| BackOffice.BFF.Configuration.Protobuf | 1.0.20 | BackOffice.BFF.Configuration.Protobuf.Protos | تنظیمات + AppVersion |
| BackOffice.BFF.NetworkMembership.Protobuf | 0.0.11 | 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