刘涛 8c0a5f489d Initial commit: hulai admin API backend
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-22 22:01:23 +08:00

54 行
2.1 KiB
Python

from __future__ import annotations
from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey, JSON
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func
from app.database import Base
class Brand(Base):
__tablename__ = "brand"
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(String(100), nullable=False)
full_name = Column(String(255))
domain = Column(String(100))
url = Column(String(255))
slogan_emotional = Column(String(255))
slogan_functional = Column(String(255))
icp_entity = Column(String(255))
icp = Column(String(100))
icp_url = Column(String(255))
e_contract = Column(String(255))
cta_buttons = Column(JSON) # {primary, secondary, pricing, customize, contact}
conversion_path = Column(JSON) # list of {step, label, to}
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
trust_stats = relationship("BrandTrustStat", back_populates="brand", cascade="all, delete-orphan", order_by="BrandTrustStat.sort_order")
differentiators = relationship("BrandDifferentiator", back_populates="brand", cascade="all, delete-orphan", order_by="BrandDifferentiator.sort_order")
class BrandTrustStat(Base):
__tablename__ = "brand_trust_stats"
id = Column(Integer, primary_key=True, autoincrement=True)
brand_id = Column(Integer, ForeignKey("brand.id", ondelete="CASCADE"), nullable=False)
value = Column(String(50), nullable=False)
unit = Column(String(20))
label = Column(String(100), nullable=False)
sort_order = Column(Integer, default=0)
brand = relationship("Brand", back_populates="trust_stats")
class BrandDifferentiator(Base):
__tablename__ = "brand_differentiators"
id = Column(Integer, primary_key=True, autoincrement=True)
brand_id = Column(Integer, ForeignKey("brand.id", ondelete="CASCADE"), nullable=False)
title = Column(String(100), nullable=False)
description = Column(Text)
sort_order = Column(Integer, default=0)
brand = relationship("Brand", back_populates="differentiators")