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


class Base(DeclarativeBase):
    pass


class Category(Base):
    __abstract__ = True
    code: Mapped[str] = mapped_column(String(255), primary_key=True)
    designation: Mapped[str] = mapped_column(String(255))

    def __eq__(self, other):
        return self.code == other.code

    def __hash__(self):
        return hash(self.code)


class User(Base):
    __abstract__ = True
    password_hash: Mapped[str] = mapped_column(String(255))
    username: Mapped[str] = mapped_column(String(255))
    postalcode: Mapped[str] = mapped_column(String(15), default=' ')
    city: Mapped[str] = mapped_column(String(255))
    street: Mapped[str] = mapped_column(String(255))
    land: Mapped[str] = mapped_column(String(255))
    iso_code: Mapped[str] = mapped_column(String(4))

    email: Mapped[str] = mapped_column(String(255))
    telefon: Mapped[str] = mapped_column(String(255))
