from .database import Model
from sqlalchemy.orm import mapped_column, Mapped, relationship
from sqlalchemy import String, Boolean, ForeignKey, Date
from sqlalchemy.dialects.mssql import SQL_VARIANT, UNIQUEIDENTIFIER
from uuid import UUID
from datetime import date
class Role(Model):
    __tablename__ = "roles"

    id: Mapped[int] = mapped_column(primary_key=True)
    name: Mapped[str] = mapped_column(String(255),nullable=False)

class User(Model):
    __tablename__ = "users"

    id: Mapped[int] = mapped_column( primary_key=True)
    firstname: Mapped[str] = mapped_column(String(255),nullable=False)
    lastname: Mapped[str] = mapped_column(String(255),nullable=False)
    email: Mapped[str] = mapped_column(String(255),nullable=False)
    hashed_password: Mapped[str] = mapped_column(String(255),nullable=False)
    is_active: Mapped[bool] = mapped_column(Boolean,default=True)
    role_id: Mapped[int] = mapped_column(ForeignKey("roles.id"))
    role: Mapped["Role"] = relationship()


class Object(Model):
    __tablename__ = "vObjects"

    id: Mapped[UUID] = mapped_column(UNIQUEIDENTIFIER, primary_key=True)
    id_parent: Mapped[UUID|None] = mapped_column(UNIQUEIDENTIFIER,nullable=True)
    year: Mapped[int | None] = mapped_column(nullable=False)
    id_city: Mapped[int] = mapped_column(nullable=False)


class Value(Model):
    __tablename__ = "vValues"
    id: Mapped[int] = mapped_column( primary_key=True)
    id_object: Mapped[UUID] = mapped_column(ForeignKey("vObjects.id"))
    id_param:Mapped[int] = mapped_column(nullable=False)
    value:Mapped[str|None] = mapped_column(String(250))
    date_s: Mapped[date] = mapped_column(Date,nullable=False)
    date_po: Mapped[date|None] = mapped_column(Date,nullable=True)
    id_user:Mapped[int] = mapped_column(nullable=False)


# class Parameter(Model):
#     __tablename__ = "vParameters"
