Files
mindfulness/server/app/db/models/push_preference.py
2026-02-03 17:43:58 +08:00

64 lines
1.7 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.
from __future__ import annotations
from datetime import datetime
from sqlalchemy import Boolean, DateTime, JSON, SmallInteger, String, func
from sqlalchemy.orm import Mapped, mapped_column
from app.db.base import Base
class PushPreference(Base):
"""
用户推送偏好(以 client_user_id 为主键)。
"""
__tablename__ = "push_preferences"
client_user_id: Mapped[str] = mapped_column(
String(length=64),
primary_key=True,
comment="客户端用户标识UUID",
)
enabled: Mapped[bool] = mapped_column(
Boolean,
nullable=False,
server_default="0",
comment="是否开启每日提醒enabled=false 或 times_per_day=0 均视为关闭)",
)
times_per_day: Mapped[int] = mapped_column(
SmallInteger,
nullable=False,
server_default="0",
comment="每天推送次数05",
)
timezone: Mapped[str | None] = mapped_column(
String(length=64),
nullable=True,
comment="IANA 时区(例如 Asia/Shanghai来自客户端上报",
)
locale: Mapped[str | None] = mapped_column(
String(length=32),
nullable=True,
comment="客户端语言(例如 zh-CN/en/zh-TW用于文案语言选择",
)
user_profile_json: Mapped[dict | None] = mapped_column(
JSON,
nullable=True,
comment="用户画像V1.2;可选)。用于 Push 场景推荐文案生成。",
)
updated_at: Mapped[datetime] = mapped_column(
DateTime,
nullable=False,
server_default=func.now(),
server_onupdate=func.now(),
comment="更新时间",
)