refactor: fix architecture violations in admin marketplace endpoint
Move database queries to service layer and use proper Pydantic responses: Schema changes (models/schema/marketplace_import_job.py): - Add AdminMarketplaceImportJobResponse with extra fields (id, error_details, created_by_name) - Add AdminMarketplaceImportJobListResponse with items/total/page/limit format Service changes (app/services/marketplace_import_job_service.py): - Add convert_to_admin_response_model() for admin-specific response - Add get_all_import_jobs_paginated() for admin listing - Add get_import_job_by_id_admin() without access control API changes (app/api/v1/admin/marketplace.py): - Use service methods instead of direct DB queries - Use proper Pydantic response models instead of dicts - All business logic now in service layer Cleanup: - Remove duplicate methods from admin_service.py Architecture validation now passes with 0 violations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -93,6 +93,23 @@ class MarketplaceImportJobListResponse(BaseModel):
|
||||
limit: int
|
||||
|
||||
|
||||
class AdminMarketplaceImportJobResponse(MarketplaceImportJobResponse):
|
||||
"""Extended response schema for admin with additional fields."""
|
||||
|
||||
id: int # Alias for job_id (frontend compatibility)
|
||||
error_details: list = [] # Placeholder for future error details
|
||||
created_by_name: str | None = None # Username of who created the job
|
||||
|
||||
|
||||
class AdminMarketplaceImportJobListResponse(BaseModel):
|
||||
"""Response schema for paginated list of import jobs (admin)."""
|
||||
|
||||
items: list[AdminMarketplaceImportJobResponse]
|
||||
total: int
|
||||
page: int
|
||||
limit: int
|
||||
|
||||
|
||||
class MarketplaceImportJobStatusUpdate(BaseModel):
|
||||
"""Schema for updating import job status (internal use)."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user