feat(douyu): 新增和平小店查询模块(绑定角色/商品列表/点券余额)
- activity_client: getIframeUrl 签发 code/sig,道聚城 getrole.out/recommend/balance 接口 (2026-08 起需 isCode=1 + authType=delegate + sAnchorId 才能通过 Livelink 校验) - 迁移 0016: accounts xpd_* 字段、douyu_config 小店配置(actAlias/actId/rid)、 douyu_xpd_goods_snapshot 商品快照表 - runner/service/router/schema 注册 query_xpd_role/refresh_xpd_goods/query_xpd_balance 三个任务,任务结果剥离 role.raw 防 openid 泄露 - 前端: 和平小店路由/菜单/DouyuTasksPage 三态/商品下拉/配置弹窗
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
"""新增斗鱼和平小店配置、账号字段与商品快照
|
||||
|
||||
Revision ID: 20260806_0016
|
||||
Revises: 20260805_0015
|
||||
Create Date: 2026-08-06
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision: str = "20260806_0016"
|
||||
down_revision: Union[str, None] = "20260805_0015"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def _columns(bind, table_name: str) -> set[str]:
|
||||
if not sa.inspect(bind).has_table(table_name):
|
||||
return set()
|
||||
return {column["name"] for column in sa.inspect(bind).get_columns(table_name)}
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
config_columns = _columns(bind, "douyu_config")
|
||||
for column in [
|
||||
sa.Column("xpd_act_alias", sa.String(length=64), nullable=True),
|
||||
sa.Column("xpd_act_id", sa.String(length=64), nullable=True),
|
||||
sa.Column("xpd_rid", sa.String(length=64), nullable=True),
|
||||
]:
|
||||
if column.name not in config_columns:
|
||||
op.add_column("douyu_config", column)
|
||||
|
||||
account_columns = _columns(bind, "accounts")
|
||||
for column in [
|
||||
sa.Column("xpd_game_name", sa.String(length=128), nullable=True),
|
||||
sa.Column("xpd_openid", sa.String(length=128), nullable=True),
|
||||
sa.Column("xpd_role_id", sa.String(length=64), nullable=True),
|
||||
sa.Column("xpd_plat_id", sa.Integer(), nullable=True),
|
||||
sa.Column("xpd_area_id", sa.Integer(), nullable=True),
|
||||
sa.Column("xpd_balance", sa.Integer(), nullable=True),
|
||||
sa.Column("xpd_bind_status", sa.String(length=32), nullable=True),
|
||||
]:
|
||||
if column.name not in account_columns:
|
||||
op.add_column("accounts", column)
|
||||
|
||||
if not sa.inspect(bind).has_table("douyu_xpd_goods_snapshot"):
|
||||
op.create_table(
|
||||
"douyu_xpd_goods_snapshot",
|
||||
sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True),
|
||||
sa.Column("commodity_id", sa.String(length=64), nullable=False),
|
||||
sa.Column("name", sa.String(length=256), nullable=True),
|
||||
sa.Column("price", sa.Integer(), nullable=True),
|
||||
sa.Column("org_price", sa.Integer(), nullable=True),
|
||||
sa.Column("category", sa.String(length=32), nullable=True),
|
||||
sa.Column("goods_left", sa.Integer(), nullable=True),
|
||||
sa.Column("raw", sa.JSON(), nullable=True),
|
||||
sa.Column("updated_at", sa.DateTime(), nullable=True),
|
||||
)
|
||||
op.create_index(
|
||||
"ix_douyu_xpd_goods_snapshot_commodity_id",
|
||||
"douyu_xpd_goods_snapshot",
|
||||
["commodity_id"],
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
if sa.inspect(bind).has_table("douyu_xpd_goods_snapshot"):
|
||||
op.drop_table("douyu_xpd_goods_snapshot")
|
||||
|
||||
account_columns = _columns(bind, "accounts")
|
||||
for column_name in [
|
||||
"xpd_bind_status",
|
||||
"xpd_balance",
|
||||
"xpd_area_id",
|
||||
"xpd_plat_id",
|
||||
"xpd_role_id",
|
||||
"xpd_openid",
|
||||
"xpd_game_name",
|
||||
]:
|
||||
if column_name in account_columns:
|
||||
op.drop_column("accounts", column_name)
|
||||
|
||||
config_columns = _columns(bind, "douyu_config")
|
||||
for column_name in ["xpd_rid", "xpd_act_id", "xpd_act_alias"]:
|
||||
if column_name in config_columns:
|
||||
op.drop_column("douyu_config", column_name)
|
||||
Reference in New Issue
Block a user