feat: add full project - backend, frontend, docker, specs and configs

This commit is contained in:
MatheusAlves96 2026-04-20 23:59:45 -03:00
parent b77c7d5a01
commit e6cb06255b
24489 changed files with 61341 additions and 36 deletions

View file

@ -0,0 +1,91 @@
import uuid
from app.extensions import db
class Property(db.Model):
__tablename__ = "properties"
id = db.Column(db.UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
title = db.Column(db.String(200), nullable=False)
slug = db.Column(db.String(220), unique=True, nullable=False, index=True)
address = db.Column(db.String(300), nullable=True)
price = db.Column(db.Numeric(12, 2), nullable=False)
condo_fee = db.Column(db.Numeric(10, 2), nullable=True)
type = db.Column(
db.Enum("venda", "aluguel", name="property_type"),
nullable=False,
)
subtype_id = db.Column(
db.Integer,
db.ForeignKey("property_types.id", ondelete="SET NULL"),
nullable=True,
index=True,
)
bedrooms = db.Column(db.Integer, nullable=False, default=0)
bathrooms = db.Column(db.Integer, nullable=False, default=0)
parking_spots = db.Column(db.Integer, nullable=False, default=0)
parking_spots_covered = db.Column(db.Integer, nullable=False, default=0)
area_m2 = db.Column(db.Integer, nullable=False)
city_id = db.Column(
db.Integer,
db.ForeignKey("cities.id", ondelete="SET NULL"),
nullable=True,
index=True,
)
neighborhood_id = db.Column(
db.Integer,
db.ForeignKey("neighborhoods.id", ondelete="SET NULL"),
nullable=True,
index=True,
)
is_featured = db.Column(db.Boolean, nullable=False, default=False)
is_active = db.Column(db.Boolean, nullable=False, default=True)
code = db.Column(db.String(30), unique=True, nullable=True)
description = db.Column(db.Text, nullable=True)
iptu_anual = db.Column(db.Numeric(12, 2), nullable=True)
imobiliaria_id = db.Column(
db.Integer,
db.ForeignKey("imobiliarias.id", ondelete="SET NULL"),
nullable=True,
index=True,
)
created_at = db.Column(db.DateTime, nullable=False, server_default=db.func.now())
photos = db.relationship(
"PropertyPhoto",
backref="property",
order_by="PropertyPhoto.display_order",
cascade="all, delete-orphan",
lazy="select",
)
subtype = db.relationship("PropertyType", foreign_keys=[subtype_id], lazy="joined")
city = db.relationship("City", foreign_keys=[city_id], lazy="joined")
neighborhood = db.relationship(
"Neighborhood", foreign_keys=[neighborhood_id], lazy="joined"
)
amenities = db.relationship(
"Amenity",
secondary="property_amenity",
lazy="select",
)
def __repr__(self) -> str:
return f"<Property {self.slug!r}>"
class PropertyPhoto(db.Model):
__tablename__ = "property_photos"
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
property_id = db.Column(
db.UUID(as_uuid=True),
db.ForeignKey("properties.id", ondelete="CASCADE"),
nullable=False,
)
url = db.Column(db.String(500), nullable=False)
alt_text = db.Column(db.String(200), nullable=False, default="")
display_order = db.Column(db.Integer, nullable=False, default=0)
def __repr__(self) -> str:
return f"<PropertyPhoto property_id={self.property_id!r} order={self.display_order}>"