Spaces:
Sleeping
Sleeping
Download database/models.py from DarkLofi/construtech-api: direct link, hf CLI and curl.
- Browser
- Download file 1.92 kB
-
https://huggingface.co/spaces/DarkLofi/construtech-api/resolve/main/database/models.py
- Command line
-
hf download hf://spaces/DarkLofi/construtech-api/database/models.py
-
curl -L -o models.py https://huggingface.co/spaces/DarkLofi/construtech-api/resolve/main/database/models.py
1.92 kB
| from sqlalchemy import Column, Integer, String, Float, ForeignKey, DateTime | |
| from sqlalchemy.orm import declarative_base, relationship | |
| import datetime | |
| Base = declarative_base() | |
| class Obra(Base): | |
| __tablename__ = "obras" | |
| id = Column(Integer, primary_key=True, index=True) | |
| nome = Column(String, index=True) | |
| descricao = Column(String) | |
| data_inicio = Column(DateTime, default=datetime.datetime.utcnow) | |
| class MaterialPadrao(Base): | |
| __tablename__ = "materiais_padrao" | |
| id = Column(Integer, primary_key=True, index=True) | |
| nome = Column(String, index=True) | |
| unidade_medida = Column(String) # ex: un, kg, m3, saco | |
| precos = relationship("PrecoHistorico", back_populates="material") | |
| class PrecoHistorico(Base): | |
| __tablename__ = "precos_historicos" | |
| id = Column(Integer, primary_key=True, index=True) | |
| material_id = Column(Integer, ForeignKey("materiais_padrao.id")) | |
| preco = Column(Float) | |
| loja = Column(String) # ex: Leroy Merlin, C&C | |
| data_coleta = Column(DateTime, default=datetime.datetime.utcnow) | |
| material = relationship("MaterialPadrao", back_populates="precos") | |
| class Estoque(Base): | |
| __tablename__ = "estoque" | |
| id = Column(Integer, primary_key=True, index=True) | |
| obra_id = Column(Integer, ForeignKey("obras.id")) | |
| material_id = Column(Integer, ForeignKey("materiais_padrao.id")) | |
| quantidade_atual = Column(Float, default=0.0) | |
| estoque_seguranca = Column(Float, default=10.0) # Alerta quando bater nesse nível | |
| class Ocorrencia(Base): | |
| __tablename__ = "ocorrencias" | |
| id = Column(Integer, primary_key=True, index=True) | |
| obra_id = Column(Integer, ForeignKey("obras.id")) | |
| descricao = Column(String) # ex: "Falta de cimento", "Chuva forte" | |
| tipo = Column(String) # "clima", "suprimento", "acidente" | |
| atraso_estimado_dias = Column(Integer, default=0) | |
| data_registro = Column(DateTime, default=datetime.datetime.utcnow) | |