system_config.py 1.3 KB

123456789101112131415161718192021222324252627
  1. """
  2. 系统配置模型
  3. """
  4. from datetime import datetime
  5. from app.utils.timezone import beijing_now_naive
  6. from sqlalchemy import Column, Integer, String, DateTime, Boolean, Text
  7. from app.database import Base
  8. class SystemConfig(Base):
  9. """系统配置表 - 纵表设计"""
  10. __tablename__ = "system_config"
  11. id = Column(Integer, primary_key=True, autoincrement=True, comment="主键ID")
  12. config_key = Column(String(100), nullable=False, comment="配置键名")
  13. config_value = Column(Text, nullable=True, comment="配置值")
  14. config_type = Column(String(20), default="string", comment="类型: int/string/bool/json")
  15. app_name = Column(String(50), nullable=True, comment="所属应用(backend-admin/backend-client)")
  16. description = Column(String(255), nullable=True, comment="配置描述")
  17. is_system = Column(Boolean, default=False, comment="是否系统配置")
  18. is_editable = Column(Boolean, default=True, comment="是否可编辑")
  19. is_deleted = Column(Boolean, default=False, comment="是否删除: 0-否, 1-是")
  20. created_at = Column(DateTime, default=beijing_now_naive, comment="创建时间")
  21. updated_at = Column(DateTime, default=beijing_now_naive, onupdate=beijing_now_naive, comment="更新时间")
  22. def __repr__(self):
  23. return f"<SystemConfig(id={self.id}, config_key='{self.config_key}')>"