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

@@ -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>
);