system_config_his.py 1.4 KB

12345678910111213141516171819202122232425262728
  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. from app.models.history_base import HistoryRecord
  9. class SystemConfigHis(HistoryRecord):
  10. """系统配置历史记录表"""
  11. __tablename__ = "system_config_his"
  12. id = Column(Integer, primary_key=True, comment="原表主键ID")
  13. config_key = Column(String(100), nullable=False, comment="配置键名")
  14. config_value = Column(Text, nullable=True, comment="配置值")
  15. config_type = Column(String(20), default="string", comment="类型: int/string/bool/json")
  16. app_name = Column(String(50), nullable=True, comment="所属应用")
  17. description = Column(String(255), nullable=True, comment="配置描述")
  18. is_system = Column(Boolean, default=False, comment="是否系统配置")
  19. is_editable = Column(Boolean, default=True, comment="是否可编辑")
  20. is_deleted = Column(Boolean, default=False, comment="是否删除")
  21. created_at = Column(DateTime, default=beijing_now_naive, comment="创建时间")
  22. updated_at = Column(DateTime, default=beijing_now_naive, comment="更新时间")
  23. def __repr__(self):
  24. return f"<SystemConfigHis(id={self.id}, config_key='{self.config_key}', his_operation='{self.his_operation}')>"