baodan/api/insurance/models/system_setting.py

26 lines
981 B
Python

"""系统配置模型。"""
from sqlalchemy import Column, String, Text, BigInteger, TIMESTAMP, func
from insurance.db.compat import db
class SystemSetting(db.Model):
"""系统配置表。"""
__tablename__ = "system_settings"
id = Column(BigInteger, primary_key=True, autoincrement=True)
key = Column(String(100), unique=True, nullable=False, comment="配置键")
value = Column(Text, nullable=False, comment="配置值")
description = Column(String(500), nullable=True, comment="描述")
updated_by = Column(String(50), nullable=True, comment="更新人")
updated_at = Column(TIMESTAMP, server_default=func.now(), onupdate=func.now())
def to_dict(self):
return {
"id": self.id,
"key": self.key,
"value": self.value,
"description": self.description,
"updatedBy": self.updated_by,
"updatedAt": self.updated_at.isoformat() if self.updated_at else None,
}