33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
"""
|
||
系统配置模型
|
||
"""
|
||
from sqlalchemy import Column, Integer, String, DateTime, Boolean, Text, JSON
|
||
from sqlalchemy.sql import func
|
||
|
||
from .base import Base
|
||
|
||
|
||
class SystemConfig(Base):
|
||
"""系统配置表"""
|
||
__tablename__ = "system_configs"
|
||
|
||
id = Column(Integer, primary_key=True, autoincrement=True, comment="配置 ID")
|
||
|
||
# 配置键值
|
||
config_key = Column(String(100), unique=True, nullable=False, index=True, comment="配置键")
|
||
config_value = Column(JSON, nullable=False, comment="配置值(JSON 格式)")
|
||
config_type = Column(String(50), comment="配置类型(schedule/limit/probability等)")
|
||
|
||
# 描述信息
|
||
description = Column(Text, comment="配置描述")
|
||
|
||
# 状态
|
||
is_active = Column(Boolean, default=True, comment="是否启用")
|
||
|
||
# 时间戳
|
||
created_at = Column(DateTime, server_default=func.now(), comment="创建时间")
|
||
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), comment="更新时间")
|
||
|
||
def __repr__(self):
|
||
return f"<SystemConfig(id={self.id}, key='{self.config_key}')>"
|