22 lines
1.0 KiB
Python
22 lines
1.0 KiB
Python
from sqlalchemy import String, Boolean, Integer
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
from .base import Base, TimestampMixin, MYSQL_TABLE_ARGS
|
|
from .enums import StatusEnum
|
|
|
|
|
|
class User(Base, TimestampMixin):
|
|
__tablename__ = "sys_user"
|
|
__table_args__ = MYSQL_TABLE_ARGS
|
|
|
|
user_id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
username: Mapped[str] = mapped_column(String(50), unique=True, nullable=False)
|
|
display_name: Mapped[str] = mapped_column(String(50), nullable=False)
|
|
email: Mapped[str | None] = mapped_column(String(100), unique=True)
|
|
phone: Mapped[str | None] = mapped_column(String(30), unique=True)
|
|
password_hash: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
avatar: Mapped[str | None] = mapped_column(String(255))
|
|
status: Mapped[int] = mapped_column(Integer, default=StatusEnum.ENABLED, nullable=False)
|
|
is_deleted: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)
|
|
|
|
roles = relationship("UserRole", back_populates="user")
|