import_log.py 870 B

123456789101112131415161718192021222324252627282930313233
  1. from pydantic import BaseModel
  2. from typing import Optional, Dict, List, Any
  3. from datetime import datetime
  4. # Request schema for mapping
  5. class ImportMapping(BaseModel):
  6. start_row: int = 1
  7. # Mapping from database field (key) to Excel column index/name (value)
  8. # e.g. {"mobile": "A", "name": "B", "english_name": "C"} or {"mobile": 0, "name": 1}
  9. mapping: Dict[str, Any]
  10. class ImportLogBase(BaseModel):
  11. filename: str
  12. total_count: int
  13. success_count: int
  14. fail_count: int
  15. result_data: Optional[List[Dict[str, Any]]] = None
  16. class ImportLogCreate(ImportLogBase):
  17. created_by: int
  18. class ImportLog(ImportLogBase):
  19. id: int
  20. created_at: datetime
  21. created_by: Optional[int]
  22. class Config:
  23. from_attributes = True
  24. class ImportPreview(BaseModel):
  25. headers: List[str]
  26. preview_data: List[List[Any]] # First few rows