35 lines
1.4 KiB
Python
35 lines
1.4 KiB
Python
"""
|
|
Tool_OCR - User Model
|
|
User authentication and management
|
|
"""
|
|
|
|
from sqlalchemy import Column, Integer, String, DateTime, Boolean
|
|
from sqlalchemy.orm import relationship
|
|
from datetime import datetime
|
|
|
|
from app.core.database import Base
|
|
|
|
|
|
class User(Base):
|
|
"""User model for JWT authentication"""
|
|
|
|
__tablename__ = "paddle_ocr_users"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
username = Column(String(50), unique=True, nullable=False, index=True)
|
|
email = Column(String(100), unique=True, nullable=False, index=True)
|
|
password_hash = Column(String(255), nullable=False)
|
|
full_name = Column(String(100), nullable=True)
|
|
is_active = Column(Boolean, default=True, nullable=False)
|
|
is_admin = Column(Boolean, default=False, nullable=False)
|
|
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
|
|
|
|
# Relationships
|
|
ocr_batches = relationship("OCRBatch", back_populates="user", cascade="all, delete-orphan")
|
|
export_rules = relationship("ExportRule", back_populates="user", cascade="all, delete-orphan")
|
|
translation_configs = relationship("TranslationConfig", back_populates="user", cascade="all, delete-orphan")
|
|
|
|
def __repr__(self):
|
|
return f"<User(id={self.id}, username='{self.username}', email='{self.email}')>"
|