40 lines
1.6 KiB
Python
40 lines
1.6 KiB
Python
"""
|
|
系统配置模型
|
|
"""
|
|
from sqlalchemy import Column, Integer, String, Text, DateTime, Enum, func, Boolean
|
|
from enum import Enum as PyEnum
|
|
from .base import Base
|
|
|
|
|
|
class ConfigType(PyEnum):
|
|
"""配置类型"""
|
|
STRING = "STRING"
|
|
NUMBER = "NUMBER"
|
|
BOOLEAN = "BOOLEAN"
|
|
JSON = "JSON"
|
|
|
|
|
|
class ConfigCategory(PyEnum):
|
|
"""配置分类"""
|
|
GAME_ECONOMY = "GAME_ECONOMY" # 游戏经济配置
|
|
GAME_LOGIC = "GAME_LOGIC" # 游戏逻辑配置
|
|
SYSTEM_OPERATIONS = "SYSTEM_OPERATIONS" # 系统运维配置
|
|
UI_DISPLAY = "UI_DISPLAY" # 界面显示配置
|
|
|
|
|
|
class SystemConfig(Base):
|
|
"""系统配置表"""
|
|
__tablename__ = "system_configs"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True, index=True)
|
|
config_key = Column(String(64), unique=True, index=True, nullable=False, comment="配置键")
|
|
config_value = Column(Text, nullable=False, comment="配置值")
|
|
config_type = Column(Enum(ConfigType, native_enum=True), default=ConfigType.STRING, comment="配置类型")
|
|
category = Column(Enum(ConfigCategory, native_enum=True), default=ConfigCategory.SYSTEM_OPERATIONS, comment="配置分类")
|
|
description = Column(String(255), comment="配置描述")
|
|
is_editable = Column(Boolean, default=True, comment="是否可编辑")
|
|
is_public = Column(Boolean, default=False, comment="是否对前端公开")
|
|
display_order = Column(Integer, default=0, comment="显示顺序")
|
|
created_at = Column(DateTime, server_default=func.now(), comment="创建时间")
|
|
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), comment="更新时间")
|