153 lines
4.2 KiB
Markdown
153 lines
4.2 KiB
Markdown
# Customer Methods Implementation Checklist
|
|
*چکلیست پیادهسازی متدهای Customer*
|
|
|
|
## 📋 ProductsService Customer Methods
|
|
|
|
### ✅ آمادهسازی پایه
|
|
- [x] Proto contracts تعریف شده
|
|
- [x] Service class ایجاد شده
|
|
- [x] Method signatures صحیح
|
|
|
|
### 🔄 نیاز به پیادهسازی
|
|
- [ ] **GetProductsForCustomer**
|
|
- [ ] اتصال به GetProductsQuery از Application layer
|
|
- [ ] فیلتر محصولات فعال (IsActive = true)
|
|
- [ ] Pagination support
|
|
- [ ] تبدیل Domain models به Proto responses
|
|
|
|
- [ ] **GetProductByIdForCustomer**
|
|
- [ ] اتصال به GetProductByIdQuery
|
|
- [ ] بررسی دسترسی مشتری
|
|
- [ ] Error handling برای محصول ناموجود
|
|
|
|
- [ ] **GetProductsByCategoryForCustomer**
|
|
- [ ] اتصال به GetProductsByCategoryQuery
|
|
- [ ] فیلتر بر اساس دستهبندی
|
|
- [ ] Category validation
|
|
|
|
---
|
|
|
|
## 📋 UserOrderService Customer Methods
|
|
|
|
### ✅ آمادهسازی پایه
|
|
- [x] Proto contracts تعریف شده
|
|
- [x] Service class ایجاد شده
|
|
- [x] Method signatures صحیح
|
|
|
|
### 🔄 نیاز به پیادهسازی
|
|
- [ ] **CreateNewOrderForCustomer**
|
|
- [ ] اتصال به CreateOrderCommand از Application layer
|
|
- [ ] Order validation logic
|
|
- [ ] Cart items validation
|
|
- [ ] Customer validation
|
|
- [ ] Error handling
|
|
|
|
- [ ] **GetOrderHistoryForCustomer**
|
|
- [ ] اتصال به GetOrdersQuery
|
|
- [ ] فیلتر بر اساس CustomerId
|
|
- [ ] Pagination support
|
|
|
|
- [ ] **GetOrderDetailForCustomer**
|
|
- [ ] اتصال به GetOrderByIdQuery
|
|
- [ ] بررسی ownership (سفارش متعلق به همین مشتری)
|
|
- [ ] Security check
|
|
|
|
- [ ] **CancelOrderForCustomer**
|
|
- [ ] اتصال به CancelOrderCommand
|
|
- [ ] Business rules validation
|
|
- [ ] Order status checks
|
|
|
|
---
|
|
|
|
## 📋 UserCartsService (تکمیل شده ✅)
|
|
|
|
- [x] **AddNewUserCartForCustomer** - از CMS Application استفاده میکند
|
|
- [x] **UpdateUserCartForCustomer** - از CMS Application استفاده میکند
|
|
- [x] **RemoveUserCartForCustomer** - از CMS Application استفاده میکند
|
|
- [x] **GetUserCartForCustomer** - از CMS Application استفاده میکند
|
|
|
|
---
|
|
|
|
## 🔧 راهنمای پیادهسازی
|
|
|
|
### الگوی کلی برای Customer Methods:
|
|
```csharp
|
|
public override async Task<TResponse> MethodNameForCustomer(
|
|
TRequest request, ServerCallContext context)
|
|
{
|
|
try
|
|
{
|
|
// 1. Validation
|
|
if (/* invalid input */)
|
|
throw new RpcException(new Status(StatusCode.InvalidArgument, "Invalid input"));
|
|
|
|
// 2. استفاده از Application layer
|
|
var command/query = new TCommand/TQuery
|
|
{
|
|
/* map from request */
|
|
};
|
|
|
|
var result = await _dispatcher.DispatchAsync(command/query);
|
|
|
|
// 3. تبدیل به Proto response
|
|
return new TResponse
|
|
{
|
|
/* map from result */
|
|
};
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new RpcException(new Status(StatusCode.Internal, ex.Message));
|
|
}
|
|
}
|
|
```
|
|
|
|
### نکات مهم:
|
|
- همیشه از `IDispatchRequestToCQRS` استفاده کنید
|
|
- Proto dependencies را در Application layer قرار ندهید
|
|
- Error handling مناسب پیادهسازی کنید
|
|
- Customer authorization را بررسی کنید
|
|
|
|
---
|
|
|
|
## ⚡ Quick Commands
|
|
|
|
### Build & Test:
|
|
```bash
|
|
# Build
|
|
cd /home/masoud/Apps/project/FourSat/CMS/src
|
|
dotnet build CMS.sln
|
|
|
|
# Run
|
|
cd CMSMicroservice.WebApi
|
|
dotnet run
|
|
|
|
# Test specific endpoint
|
|
curl -X GET "http://localhost:32847/Customer/Products/GetProductsForCustomer"
|
|
```
|
|
|
|
### Swagger Access:
|
|
```
|
|
http://localhost:32847/swagger/index.html
|
|
```
|
|
|
|
---
|
|
|
|
## 📅 اولویتبندی کار
|
|
|
|
### Week 1: Products Customer Methods
|
|
1. GetProductsForCustomer (اولویت بالا)
|
|
2. GetProductByIdForCustomer
|
|
3. GetProductsByCategoryForCustomer
|
|
|
|
### Week 2: Orders Customer Methods
|
|
1. CreateNewOrderForCustomer (اولویت بالا)
|
|
2. GetOrderHistoryForCustomer
|
|
3. GetOrderDetailForCustomer
|
|
4. CancelOrderForCustomer
|
|
|
|
### Week 3: Testing & Polish
|
|
1. Unit tests
|
|
2. Integration tests
|
|
3. Performance optimization
|
|
4. Documentation updates |