61 lines
1.9 KiB
Python
61 lines
1.9 KiB
Python
# packages/v1/administrativo/models/ato_parte_model.py
|
|
# Gerado a partir da DDL da tabela 'ato_parte'
|
|
|
|
from sqlalchemy import (
|
|
Column,
|
|
BigInteger,
|
|
String,
|
|
DateTime,
|
|
ForeignKey,
|
|
)
|
|
|
|
from sqlalchemy.sql import func
|
|
|
|
# Importa Base do MySQL (assumindo que o caminho 'database.mysql' é o correto)
|
|
from database.mysql import Base
|
|
|
|
|
|
class AtoParte(Base):
|
|
"""
|
|
Representa o modelo da tabela 'ato_parte' no banco de dados MySQL.
|
|
Mapeia a DDL fornecida.
|
|
"""
|
|
|
|
__tablename__ = "ato_parte"
|
|
|
|
# ato_parte_id bigint NOT NULL AUTO_INCREMENT, PRIMARY KEY
|
|
ato_parte_id = Column(BigInteger, primary_key=True, autoincrement=True)
|
|
|
|
# ato_principal_id bigint NOT NULL, FOREIGN KEY
|
|
# Mapeamento da chave estrangeira
|
|
ato_principal_id = Column(
|
|
BigInteger, ForeignKey("ato_principal.ato_principal_id"), nullable=False
|
|
)
|
|
|
|
# nome varchar(255) NOT NULL (Nome completo da parte envolvida no ato.)
|
|
nome = Column(String(255), nullable=False)
|
|
|
|
# telefone varchar(20) DEFAULT NULL (Telefone da parte com DDI e DDD.)
|
|
telefone = Column(String(20), nullable=True)
|
|
|
|
# cpf_cnpj varchar(20) NOT NULL (CPF ou CNPJ da parte, contendo apenas números.)
|
|
cpf_cnpj = Column(String(20), nullable=False)
|
|
|
|
# created_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
created_at = Column(DateTime, server_default=func.now(), nullable=False)
|
|
|
|
# updated_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
|
updated_at = Column(
|
|
DateTime,
|
|
server_default=func.now(), # Default CURRENT_TIMESTAMP
|
|
onupdate=func.now(), # ON UPDATE CURRENT_TIMESTAMP
|
|
nullable=False,
|
|
)
|
|
|
|
def __repr__(self):
|
|
"""Representação legível do objeto."""
|
|
return (
|
|
f"<AtoParte(ato_parte_id={self.ato_parte_id}, "
|
|
f"ato_principal_id={self.ato_principal_id}, "
|
|
f"nome='{self.nome}')>"
|
|
)
|