import_log.py 1.5 KB

1234567891011121314151617181920212223242526
  1. from sqlalchemy import Column, Integer, String, DateTime, JSON, ForeignKey
  2. from sqlalchemy.sql import func
  3. from app.core.database import Base
  4. class ImportLog(Base):
  5. __tablename__ = "import_logs"
  6. id = Column(Integer, primary_key=True, index=True)
  7. filename = Column(String(255), nullable=False)
  8. total_count = Column(Integer, default=0)
  9. success_count = Column(Integer, default=0)
  10. fail_count = Column(Integer, default=0)
  11. # Store detailed results, e.g., [{"row": 2, "error": "Mobile duplicate"}, ...]
  12. # Or [{"mobile": "...", "password": "..."}] for success export (be careful with sensitive data, maybe only store errors here and regenerate success file on demand?
  13. # User said "Export successful results with account and initial password".
  14. # We should probably store the success data temporarily or generated file path.
  15. # Storing passwords in plain text in logs is bad practice, but required for "Export initial password".
  16. # We can store an encrypted blob or just the result JSON if the requirement strictly asks for it.
  17. # For now, let's store `details` as a generic JSON which can hold error logs.
  18. # For the success export, we might generate it immediately and return it, or store the success data in this JSON field (encrypted ideally, but simple JSON for this task).
  19. result_data = Column(JSON, nullable=True)
  20. created_by = Column(Integer, ForeignKey("users.id"), nullable=True)
  21. created_at = Column(DateTime(timezone=True), server_default=func.now())