update
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
# 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 پیادهسازی شدهاند:
|
||||
```protobuf
|
||||
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()` استفاده کنید:
|
||||
|
||||
```csharp
|
||||
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:
|
||||
|
||||
```bash
|
||||
cd BackOffice.BFF.{Module}.Protobuf
|
||||
dotnet pack -c Release
|
||||
# Auto-push via PushToFourSat target
|
||||
```
|
||||
|
||||
**Registry**: https://git.afrino.co/api/packages/FourSat/nuget
|
||||
|
||||
## 🔗 Related Docs
|
||||
|
||||
- [Architecture Patterns](../../../02-ARCHITECTURE/README.md)
|
||||
- [API Coverage](api-coverage.md)
|
||||
- [Protobuf Dependencies](protobuf-dependencies.md)
|
||||
Reference in New Issue
Block a user