from datetime import datetime

from sqlalchemy import DateTime, ForeignKey, Integer, String, func
from sqlalchemy.orm import Mapped, mapped_column

from app.database import Base


class Oem(Base):
    __tablename__ = "oem"

    id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
    user_id: Mapped[int] = mapped_column(
        Integer, ForeignKey("users.id", ondelete="RESTRICT"), nullable=False, index=True
    )
    software_name: Mapped[str] = mapped_column(String(128), default="", server_default="")
    logo_path: Mapped[str | None] = mapped_column(String(512), nullable=True)
    wechat: Mapped[str | None] = mapped_column(String(128), nullable=True)
    qq: Mapped[str | None] = mapped_column(String(128), nullable=True)
    wechat_qrcode: Mapped[str | None] = mapped_column(String(512), nullable=True)
    qq_qrcode: Mapped[str | None] = mapped_column(String(512), nullable=True)
    description: Mapped[str | None] = mapped_column(String(255), nullable=True)
    created_at: Mapped[datetime] = mapped_column(
        DateTime(timezone=True), server_default=func.now()
    )
    updated_at: Mapped[datetime] = mapped_column(
        DateTime(timezone=True), server_default=func.now(), onupdate=func.now()
    )
