bc10432f52
- user.invite_code 列 + invite_relation 表(invitee_user_id 唯一 = 幂等防重复发奖) - GET /api/v1/invite/me(我的码+分享链接+战绩)、POST /api/v1/invite/bind - 复用 wallet.grant_coins 同事务发币;自邀屏蔽 / 无效码 / 新用户闸(注册72h内才发) - alembic 迁移(11a1d08c6f55 -> invite_code_and_relation)+ 8 个测试(钱路/幂等/并发兜底全覆盖) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
26 lines
1.0 KiB
Python
26 lines
1.0 KiB
Python
"""邀请相关 API 收发模型。"""
|
|
from __future__ import annotations
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class InviteInfoOut(BaseModel):
|
|
invite_code: str # 我的邀请码
|
|
share_url: str # 落地页链接(含 ?ref=),前端据此生成二维码 + 复制分享
|
|
invited_count: int # 已成功邀请人数
|
|
coins_earned: int # 累计从邀请获得的金币
|
|
|
|
|
|
class BindInviteIn(BaseModel):
|
|
invite_code: str = Field(..., min_length=4, max_length=16, description="邀请人的邀请码")
|
|
channel: str = Field(
|
|
"clipboard", max_length=16,
|
|
description="归因来源:clipboard(首启读剪贴板自动) / manual(用户手动填)",
|
|
)
|
|
|
|
|
|
class BindInviteOut(BaseModel):
|
|
status: str # success / already_bound / invalid_code / self_invite / not_eligible
|
|
coins_awarded: int # 本次给当前用户(被邀请人)发的金币
|
|
message: str # 给前端直接展示的文案
|