23 lines
1.1 KiB
Python
23 lines
1.1 KiB
Python
# app/models/home_module.py
|
|
from sqlalchemy import Column, Integer, String, Boolean, Text, DateTime
|
|
from sqlalchemy.sql import func
|
|
from app.database import Base
|
|
|
|
|
|
class HomeModule(Base):
|
|
__tablename__ = "home_modules"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String(50), nullable=False) # 显示名称
|
|
code = Column(String(30), unique=True, index=True, nullable=False) # 唯一标识
|
|
type = Column(String(20), nullable=False) # 模块类型
|
|
sort_order = Column(Integer, default=0) # 排序权重
|
|
is_enabled = Column(Boolean, default=True) # 是否启用
|
|
is_fixed = Column(Boolean, default=False) # 是否固定(不可删除)
|
|
title = Column(String(100)) # 模块标题
|
|
subtitle = Column(String(200)) # 副标题
|
|
content = Column(Text) # 内容数据(JSON字符串)
|
|
style_config = Column(Text) # 样式配置(JSON字符串)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|