""" @model StorefrontCmsModel (Backend/app/models/StorefrontCmsModel.py) @purpose CMS configuration tables for Storefront Settings, Footer Info, Mega Menu, and Catalog Filter buckets — each keyed by a string PK for O(1) upsert. """ from sqlalchemy import Column, String, JSON, DateTime, Text from sqlalchemy.sql import func from app.models.db_base import Base class StorefrontSettings(Base): """ Key → JSON-value store for branding & store configuration. Examples: store_name, logo_url, primary_wordmark_url, support_phone, currency_code, advance_percent, favicon_url, theme_color. """ __tablename__ = "storefront_settings" key = Column(String(128), primary_key=True, index=True) value = Column(JSON, nullable=False) updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now()) updated_by = Column(String(64), nullable=True) class StorefrontMegaMenu(Base): """ Per-nav-key JSON blob for mega menu configuration. nav_key values: 'shop', 'deals', 'products' """ __tablename__ = "storefront_mega_menu" nav_key = Column(String(32), primary_key=True, index=True) # 'shop' | 'deals' | 'products' groups = Column(JSON, nullable=True) # list of {title, links:[{label,href}]} promo = Column(JSON, nullable=True) # {image_url, badge, title, href} featured_category_ids = Column(JSON, nullable=True) # list of category_id strings updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now()) class StorefrontCatalogFilters(Base): """ Shop catalog filter configuration. filter_key: 'default' for the global config. """ __tablename__ = "storefront_catalog_filters" filter_key = Column(String(32), primary_key=True, index=True, default="default") highlights = Column(JSON, nullable=True) # [{label, value, icon}] price_ranges = Column(JSON, nullable=True) # [{label, min, max}] updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now()) class StorefrontFooterInfo(Base): """ Footer contact information, social links, navigation columns, and payment icons. Single-row table keyed by 'default'. """ __tablename__ = "storefront_footer_info" id = Column(String(16), primary_key=True, index=True, default="default") phone = Column(String(32), nullable=True) email = Column(String(128), nullable=True) address = Column(Text, nullable=True) copyright = Column(String(255), nullable=True) social_links = Column(JSON, nullable=True) # [{platform, url, icon}] columns = Column(JSON, nullable=True) # [{title, links:[{label,href}]}] payment_methods = Column(JSON, nullable=True) # [{name, icon_url}] updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())