Implementación inicial del sistema de automatización de redes sociales
- Estructura completa del proyecto con FastAPI - Modelos de base de datos (productos, servicios, posts, calendario, interacciones) - Publishers para X, Threads, Instagram, Facebook - Generador de contenido con DeepSeek API - Worker de Celery con tareas programadas - Dashboard básico con templates HTML - Docker Compose para despliegue - Documentación completa Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
80
app/models/product.py
Normal file
80
app/models/product.py
Normal file
@@ -0,0 +1,80 @@
|
||||
"""
|
||||
Modelo de Producto - Catálogo de equipos de cómputo e impresoras 3D.
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
from sqlalchemy import Column, Integer, String, Text, Float, Boolean, DateTime, JSON
|
||||
from sqlalchemy.dialects.postgresql import ARRAY
|
||||
|
||||
from app.core.database import Base
|
||||
|
||||
|
||||
class Product(Base):
|
||||
"""Modelo para productos del catálogo."""
|
||||
|
||||
__tablename__ = "products"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
|
||||
# Información básica
|
||||
name = Column(String(255), nullable=False, index=True)
|
||||
description = Column(Text, nullable=True)
|
||||
short_description = Column(String(500), nullable=True) # Para posts
|
||||
|
||||
# Categorización
|
||||
category = Column(String(100), nullable=False, index=True) # laptop, desktop, impresora_3d, etc.
|
||||
subcategory = Column(String(100), nullable=True)
|
||||
brand = Column(String(100), nullable=True)
|
||||
model = Column(String(100), nullable=True)
|
||||
|
||||
# Precio y stock
|
||||
price = Column(Float, nullable=False)
|
||||
price_usd = Column(Float, nullable=True) # Precio en dólares (opcional)
|
||||
stock = Column(Integer, default=0)
|
||||
is_available = Column(Boolean, default=True)
|
||||
|
||||
# Especificaciones técnicas (JSON flexible)
|
||||
specs = Column(JSON, nullable=True)
|
||||
# Ejemplo: {"cpu": "Intel i7", "ram": "16GB", "storage": "512GB SSD"}
|
||||
|
||||
# Imágenes
|
||||
images = Column(ARRAY(String), nullable=True) # URLs de imágenes
|
||||
main_image = Column(String(500), nullable=True)
|
||||
|
||||
# SEO y marketing
|
||||
tags = Column(ARRAY(String), nullable=True) # Tags para búsqueda
|
||||
highlights = Column(ARRAY(String), nullable=True) # Puntos destacados
|
||||
|
||||
# Control de publicación
|
||||
is_featured = Column(Boolean, default=False) # Producto destacado
|
||||
last_posted_at = Column(DateTime, nullable=True) # Última vez que se publicó
|
||||
|
||||
# Timestamps
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Product {self.name}>"
|
||||
|
||||
def to_dict(self):
|
||||
"""Convertir a diccionario."""
|
||||
return {
|
||||
"id": self.id,
|
||||
"name": self.name,
|
||||
"description": self.description,
|
||||
"short_description": self.short_description,
|
||||
"category": self.category,
|
||||
"subcategory": self.subcategory,
|
||||
"brand": self.brand,
|
||||
"model": self.model,
|
||||
"price": self.price,
|
||||
"stock": self.stock,
|
||||
"is_available": self.is_available,
|
||||
"specs": self.specs,
|
||||
"images": self.images,
|
||||
"main_image": self.main_image,
|
||||
"tags": self.tags,
|
||||
"highlights": self.highlights,
|
||||
"is_featured": self.is_featured,
|
||||
"created_at": self.created_at.isoformat() if self.created_at else None
|
||||
}
|
||||
Reference in New Issue
Block a user