接入服务号模板推送通知

This commit is contained in:
stu2not
2026-06-22 14:34:20 +08:00
parent 8aeb813a68
commit 0fb4ebee8a
16 changed files with 1025 additions and 3 deletions

View File

@@ -224,6 +224,44 @@ class Parent(Base):
updated_at: Mapped[Optional[datetime]] = mapped_column(DateTime, server_default=text("CURRENT_TIMESTAMP"))
class ParentWechatAccount(Base):
__tablename__ = "parent_wechat_accounts"
__table_args__ = (
UniqueConstraint("app_id", "openid", name="uq_parent_wechat_app_openid"),
UniqueConstraint("user_id", "account_type", name="uq_parent_wechat_user_type"),
Index("idx_parent_wechat_user", "user_id"),
Index("idx_parent_wechat_unionid", "unionid"),
{'mysql_charset': 'utf8mb4', 'mysql_collate': 'utf8mb4_unicode_ci'}
)
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
user_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("parents.user_id"), nullable=False)
app_id: Mapped[str] = mapped_column(String(64), nullable=False)
account_type: Mapped[str] = mapped_column(String(32), nullable=False)
openid: Mapped[str] = mapped_column(String(64), nullable=False)
unionid: Mapped[Optional[str]] = mapped_column(String(64))
subscribed: Mapped[int] = mapped_column(Integer, server_default="0")
created_at: Mapped[Optional[datetime]] = mapped_column(DateTime, server_default=text("CURRENT_TIMESTAMP"))
updated_at: Mapped[Optional[datetime]] = mapped_column(DateTime, server_default=text("CURRENT_TIMESTAMP"))
class WechatMpBindState(Base):
__tablename__ = "wechat_mp_bind_states"
__table_args__ = (
Index("idx_wechat_mp_bind_user", "user_id"),
Index("idx_wechat_mp_bind_expires", "expires_at"),
{'mysql_charset': 'utf8mb4', 'mysql_collate': 'utf8mb4_unicode_ci'}
)
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
state: Mapped[str] = mapped_column(String(128), unique=True, nullable=False)
user_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("parents.user_id"), nullable=False)
expires_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
consumed_at: Mapped[Optional[datetime]] = mapped_column(DateTime)
created_at: Mapped[Optional[datetime]] = mapped_column(DateTime, server_default=text("CURRENT_TIMESTAMP"))
updated_at: Mapped[Optional[datetime]] = mapped_column(DateTime, server_default=text("CURRENT_TIMESTAMP"))
class Child(Base):
__tablename__ = "children"