marketplace refactoring

This commit is contained in:
2025-10-04 13:38:10 +02:00
parent 32be301d83
commit c971674ec2
68 changed files with 1102 additions and 1128 deletions

View File

@@ -51,7 +51,7 @@ Response:
Include the JWT token in the Authorization header:
```http
GET /api/v1/product
GET /api/v1/marketplace/product
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...
```

View File

@@ -37,8 +37,8 @@ All API endpoints are versioned using URL path versioning:
- Configuration management
### Products (`/products/`)
- Product CRUD operations
- Product search and filtering
- MarketplaceProduct CRUD operations
- MarketplaceProduct search and filtering
- Bulk operations
### Shops (`/shops/`)
@@ -98,7 +98,7 @@ Content-Type: application/json
Most list endpoints support pagination:
```bash
GET /api/v1/product?skip=0&limit=20
GET /api/v1/marketplace/product?skip=0&limit=20
```
Response includes pagination metadata:
@@ -116,14 +116,14 @@ Response includes pagination metadata:
Many endpoints support filtering and search:
```bash
GET /api/v1/product?search=laptop&category=electronics&min_price=100
GET /api/v1/marketplace/product?search=laptop&category=electronics&min_price=100
```
### Sorting
Use the `sort` parameter with field names:
```bash
GET /api/v1/product?sort=name&order=desc
GET /api/v1/marketplace/product?sort=name&order=desc
```
## Status Codes

View File

@@ -30,7 +30,7 @@ app/exceptions/
├── auth.py # Authentication/authorization exceptions
├── admin.py # Admin operation exceptions
├── marketplace.py # Import/marketplace exceptions
├── product.py # Product management exceptions
├── product.py # MarketplaceProduct management exceptions
├── shop.py # Shop management exceptions
└── stock.py # Stock management exceptions
```
@@ -48,10 +48,10 @@ All custom exceptions return a consistent JSON structure:
```json
{
"error_code": "PRODUCT_NOT_FOUND",
"message": "Product with ID 'ABC123' not found",
"message": "MarketplaceProduct with ID 'ABC123' not found",
"status_code": 404,
"details": {
"resource_type": "Product",
"resource_type": "MarketplaceProduct",
"identifier": "ABC123"
}
}
@@ -360,7 +360,7 @@ def test_get_all_users_non_admin(client, auth_headers):
### Resource Not Found (404)
- `USER_NOT_FOUND`: User with specified ID not found
- `SHOP_NOT_FOUND`: Shop with specified code/ID not found
- `PRODUCT_NOT_FOUND`: Product with specified ID not found
- `PRODUCT_NOT_FOUND`: MarketplaceProduct with specified ID not found
### Business Logic (400)
- `CANNOT_MODIFY_SELF`: Admin cannot modify own account
@@ -370,7 +370,7 @@ def test_get_all_users_non_admin(client, auth_headers):
### Validation (422)
- `VALIDATION_ERROR`: Pydantic request validation failed
- `INVALID_PRODUCT_DATA`: Product data validation failed
- `INVALID_PRODUCT_DATA`: MarketplaceProduct data validation failed
- `INVALID_SHOP_DATA`: Shop data validation failed
### Rate Limiting (429)

View File

@@ -7,11 +7,11 @@ Your API returns consistent error responses with this structure:
```json
{
"error_code": "PRODUCT_NOT_FOUND",
"message": "Product with ID 'ABC123' not found",
"message": "MarketplaceProduct with ID 'ABC123' not found",
"status_code": 404,
"field": "product_id",
"field": "marketplace_product_id",
"details": {
"resource_type": "Product",
"resource_type": "MarketplaceProduct",
"identifier": "ABC123"
}
}
@@ -131,8 +131,8 @@ export const ERROR_MESSAGES = {
TOKEN_EXPIRED: 'Your session has expired. Please log in again.',
USER_NOT_ACTIVE: 'Your account has been deactivated. Contact support.',
// Product errors
PRODUCT_NOT_FOUND: 'Product not found. It may have been removed.',
// MarketplaceProduct errors
PRODUCT_NOT_FOUND: 'MarketplaceProduct not found. It may have been removed.',
PRODUCT_ALREADY_EXISTS: 'A product with this ID already exists.',
INVALID_PRODUCT_DATA: 'Please check the product information and try again.',
@@ -226,7 +226,7 @@ const ProductForm = () => {
try {
await handleApiCall(() => createProduct(formData));
// Success handling
alert('Product created successfully!');
alert('MarketplaceProduct created successfully!');
setFormData({ product_id: '', name: '', price: '' });
} catch (apiError) {
// Handle field-specific errors
@@ -260,7 +260,7 @@ const ProductForm = () => {
)}
<div className="form-field">
<label>Product ID</label>
<label>MarketplaceProduct ID</label>
<input
type="text"
value={formData.product_id}
@@ -273,7 +273,7 @@ const ProductForm = () => {
</div>
<div className="form-field">
<label>Product Name</label>
<label>MarketplaceProduct Name</label>
<input
type="text"
value={formData.name}
@@ -286,7 +286,7 @@ const ProductForm = () => {
</div>
<button type="submit" disabled={isLoading}>
{isLoading ? 'Creating...' : 'Create Product'}
{isLoading ? 'Creating...' : 'Create MarketplaceProduct'}
</button>
</form>
);

View File

@@ -92,8 +92,8 @@ if __name__ == "__main__":
# 4. Create a sample product
print("\n4. Creating a sample product...")
sample_product = {
"product_id": "TEST001",
"title": "Test Product",
"marketplace_product_id": "TEST001",
"title": "Test MarketplaceProduct",
"description": "A test product for demonstration",
"price": "19.99",
"brand": "Test Brand",
@@ -101,7 +101,7 @@ if __name__ == "__main__":
}
product_result = create_product(admin_token, sample_product)
print(f"Product created: {product_result}")
print(f"MarketplaceProduct created: {product_result}")
# 5. Get products list
print("\n5. Getting products list...")
@@ -195,15 +195,15 @@ curl -X GET "http://localhost:8000/products" \
-H "Authorization: Bearer YOUR_JWT_TOKEN_HERE"
```
#### Create a Product
#### Create a MarketplaceProduct
```bash
curl -X POST "http://localhost:8000/products" \
-H "Authorization: Bearer YOUR_JWT_TOKEN_HERE" \
-H "Content-Type: application/json" \
-d '{
"product_id": "TEST001",
"title": "Test Product",
"marketplace_product_id": "TEST001",
"title": "Test MarketplaceProduct",
"description": "A test product for demonstration",
"price": "19.99",
"brand": "Test Brand",

View File

@@ -6,7 +6,7 @@ Welcome to the complete documentation for the Letzshop Import application - a co
Letzshop Import is a powerful web application that enables:
- **Product Management**: Create, update, and manage product catalogs
- **MarketplaceProduct Management**: Create, update, and manage product catalogs
- **Shop Management**: Multi-shop support with individual configurations
- **CSV Import**: Bulk import products from various marketplace formats
- **Stock Management**: Track inventory across multiple locations
@@ -28,7 +28,7 @@ Letzshop Import is a powerful web application that enables:
### 📖 User Guides
- [**User Management**](guides/user-management.md) - Managing users and roles
- [**Product Management**](guides/product-management.md) - Working with products
- [**MarketplaceProduct Management**](guides/product-management.md) - Working with products
- [**CSV Import**](guides/csv-import.md) - Bulk import workflows
- [**Shop Setup**](guides/shop-setup.md) - Configuring shops
@@ -53,7 +53,7 @@ graph TB
Client[Web Client/API Consumer]
API[FastAPI Application]
Auth[Authentication Service]
Products[Product Service]
Products[MarketplaceProduct Service]
Shops[Shop Service]
Import[Import Service]
DB[(PostgreSQL Database)]
@@ -71,7 +71,7 @@ graph TB
## Key Features
=== "Product Management"
=== "MarketplaceProduct Management"
- CRUD operations for products
- GTIN validation and normalization
- Price management with currency support