3d07461ef5
- User 新增 force_onboarding 列(仿 debug_trace_enabled)+ 迁移 user_force_onboarding。
- POST /admin/api/users/{id}/force-onboarding(operator 角色 + 审计 user.force_onboarding.set)。
- UserOut(/me 与登录响应)带出该字段;/api/v1/user/onboarding/complete 走完即自动清回 false,只触发一次。
- 测试:admin 设置+审计+角色守卫、走完引导自动清标记。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: zzhyyyyy <2685922758@qq.com>
Reviewed-on: #43
Co-authored-by: zhuzihao <zhuzihao@wonderable.ai>
Co-committed-by: zhuzihao <zhuzihao@wonderable.ai>
66 lines
2.0 KiB
Python
66 lines
2.0 KiB
Python
"""admin 用户管理 schemas。"""
|
|
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
from typing import Literal
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class AdminUserListItem(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
phone: str
|
|
nickname: str | None = None
|
|
register_channel: str
|
|
status: str
|
|
debug_trace_enabled: bool = False
|
|
# 运营「一键开启新手引导」:true=该用户下次启动 App 被强制重走引导(走完自动清回 false)
|
|
force_onboarding: bool = False
|
|
wechat_openid: str | None = None
|
|
created_at: datetime
|
|
last_login_at: datetime
|
|
|
|
|
|
class AdminUserOverview(BaseModel):
|
|
"""用户 360 概览:基础资料 + 钱包余额 + 各项 count(历史明细走各自分页接口)。"""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
user: AdminUserListItem
|
|
coin_balance: int
|
|
cash_balance_cents: int
|
|
total_coin_earned: int
|
|
comparison_total: int
|
|
comparison_success: int
|
|
withdraw_total: int
|
|
withdraw_success_cents: int
|
|
feedback_total: int
|
|
|
|
|
|
class GrantCoinsRequest(BaseModel):
|
|
amount: int = Field(..., description="金币变动:正=增加,负=扣减(不可为 0)")
|
|
reason: str = Field(..., min_length=1, max_length=128, description="操作原因(必填,入审计)")
|
|
|
|
|
|
class GrantCashRequest(BaseModel):
|
|
amount_cents: int = Field(..., description="现金变动(分):正=增加,负=扣减(不可为 0)")
|
|
reason: str = Field(..., min_length=1, max_length=128, description="操作原因(必填,入审计)")
|
|
|
|
|
|
class SetUserStatusRequest(BaseModel):
|
|
status: Literal["active", "disabled"] = Field(
|
|
..., description="active=解封 / disabled=封禁(注销 deleted 不走此接口)"
|
|
)
|
|
|
|
|
|
class SetDebugTraceRequest(BaseModel):
|
|
enabled: bool = Field(..., description="是否给该用户开「复制调试链接」权限")
|
|
|
|
|
|
class SetForceOnboardingRequest(BaseModel):
|
|
enabled: bool = Field(
|
|
..., description="true=一键开启(强制该用户下次启动 App 重走新手引导)/ false=取消"
|
|
)
|