from sqlalchemy import Boolean, String
from sqlalchemy.orm import Mapped, mapped_column

from backend.db.models.guid import GUID

from .._model_base import SqlAlchemyBase

class Users(SqlAlchemyBase):
  __tablename__ = 'users'

  id: Mapped[GUID] = mapped_column(GUID, primary_key=True, default=GUID.generate, index=True)
  username: Mapped[str | None] = mapped_column(String, unique=True, index=True, nullable=False)
  password: Mapped[str | None] = mapped_column(String, index=True, nullable=False)
  name: Mapped[str | None] = mapped_column(String, index=True, nullable=True)
  is_admin: Mapped[bool | None] = mapped_column(Boolean, default=False)
  is_lock: Mapped[bool | None] = mapped_column(Boolean, default=False)

  def __repr__(self):
    return f"{self.__class__.__name__}, name: {self.name}, username: {self.username}"
