refactor(invite): 移除 DEV 造数/重置接口(seed-fake、dev-reset)不入库
评审意见:POST/DELETE /invite/seed-fake、POST /invite/dev-reset 三个接口标注 [DEV]、 且 dev-reset 无鉴权,是本地测试用的造数/重置口子,不应合进 main。 删掉两处: - app/api/v1/invite.py: 三个端点 handler - app/repositories/invite.py: seed_fake_invitees / clear_fake_invitees / dev_reset_test_account 保留 is_compared 好友已比价状态、发奖改「比价并下单」、每日兑换定时器锁北京时区等产品改动。 纯删除,不影响其余接口(/me /invitees /bind /landing-track 均在)。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -122,57 +122,6 @@ def my_invitees(
|
||||
)
|
||||
|
||||
|
||||
@router.post("/seed-fake", summary="[DEV] 给自己塞虚拟好友(测在途/好友列表 UI,仅非生产)")
|
||||
def seed_fake_invitees(
|
||||
user: CurrentUser, db: DbSession, pending: int = 3, compared: int = 2
|
||||
) -> dict:
|
||||
"""造 pending 个未比价 + compared 个已比价的虚拟好友。生产环境(is_prod)直接 404。
|
||||
|
||||
未比价 → 上"在途列表 / 好友列表去提醒";已比价 → 好友列表"邀请成功"、并发真实邀请奖励金
|
||||
(可提现余额/累计提现也有数)。清理见 DELETE /seed-fake。
|
||||
"""
|
||||
if settings.is_prod:
|
||||
from fastapi import HTTPException
|
||||
raise HTTPException(status_code=404, detail="Not Found")
|
||||
n = invite_repo.seed_fake_invitees(db, user.id, pending=max(0, pending), compared=max(0, compared))
|
||||
return {"status": "ok", "created": n, "pending": pending, "compared": compared}
|
||||
|
||||
|
||||
@router.delete("/seed-fake", summary="[DEV] 清掉自己的虚拟好友(仅非生产)")
|
||||
def clear_fake_invitees(user: CurrentUser, db: DbSession) -> dict:
|
||||
if settings.is_prod:
|
||||
from fastapi import HTTPException
|
||||
raise HTTPException(status_code=404, detail="Not Found")
|
||||
n = invite_repo.clear_fake_invitees(db, user.id)
|
||||
return {"status": "ok", "removed": n}
|
||||
|
||||
|
||||
@router.post("/dev-reset", summary="[DEV] 把固定测试号打回出厂态,便于反复当新用户测发奖(仅非生产)")
|
||||
def dev_reset(db: DbSession) -> dict:
|
||||
"""把 TEST_ACCOUNT_PHONE 这个固定测试号清成"从没被邀请/没下过单"的新用户态。
|
||||
|
||||
⚠️ 无需鉴权(它只按配置里的测试号操作,不依赖登录态,方便测试脚本第一步直接调)。
|
||||
双重门控:生产环境(is_prod)404;测试号总开关(TEST_ACCOUNT_PHONE)没配置 → 400。
|
||||
故它永远只能动那一个配置好的测试号,动不了任意真实用户。
|
||||
|
||||
清什么见 repositories/invite.dev_reset_test_account(全清 + 刷 created_at 骗过 72h 闸)。
|
||||
调完该测试号即可再次绑定 + 下单上报,重新触发一次邀请发奖。
|
||||
"""
|
||||
from fastapi import HTTPException
|
||||
|
||||
if settings.is_prod:
|
||||
raise HTTPException(status_code=404, detail="Not Found")
|
||||
phone = settings.test_account_phone
|
||||
if not phone:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="测试号未启用:请在 .env 配 TEST_ACCOUNT_PHONE=11111111111 并重启服务",
|
||||
)
|
||||
cleared = invite_repo.dev_reset_test_account(db, phone)
|
||||
logger.info("invite dev-reset phone=%s cleared=%s", phone, cleared)
|
||||
return {"status": "ok", "phone": phone, "cleared": cleared}
|
||||
|
||||
|
||||
@router.post(
|
||||
"/landing-track",
|
||||
response_model=LandingTrackOut,
|
||||
|
||||
Reference in New Issue
Block a user