Files
loom/backend/app/models/lobster_config.py
T
2026-04-24 17:46:03 +08:00

30 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""龙虾 Agent 运行时配置(单行表 id=1,运行期可改)。
- 该表最多 1 行;服务端在首次读时自动 upsert。
- 字段为空/NULL 时 fallback 到 `.env`(`settings.LOBSTER_*`),做到 "UI 配 > .env 兜底"。
- api_key / callback_secret 走 Fernet 加密存储。
"""
from __future__ import annotations
from sqlalchemy import Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from app.db.base import Base, TimestampMixin
class LobsterConfig(Base, TimestampMixin):
__tablename__ = "lobster_config"
# 单例:固定 id = 1
id: Mapped[int] = mapped_column(primary_key=True, default=1)
api_base: Mapped[str | None] = mapped_column(String(255), nullable=True)
# Fernet 密文(可为空,表示使用 .env 或未配置走 mock)
api_key_cipher: Mapped[str | None] = mapped_column(Text, nullable=True)
callback_secret_cipher: Mapped[str | None] = mapped_column(Text, nullable=True)
timeout_seconds: Mapped[int | None] = mapped_column(Integer, nullable=True)
poll_interval_seconds: Mapped[int | None] = mapped_column(Integer, nullable=True)
note: Mapped[str | None] = mapped_column(String(255), nullable=True)