refactor(api): TOML 配置 SSOT、统一错误契约、Auth/事务加固与可观测性 (#33)
配置 SSOT(TOML + .env) 统一错误契约 Auth 与事务边界 Redis / Celery 可靠性:业务 Redis(DB/0)与 Celery broker/backend(DB/1)显式拆分;连接池、sync client 可观测性(OpenTelemetry + LGTM)
This commit is contained in:
@@ -6,11 +6,11 @@ LanguagePreference = Literal["zh", "en"]
|
||||
|
||||
|
||||
class RegisterRequest(BaseModel):
|
||||
phone: str = Field(..., min_length=11, max_length=11, description="手机号(11位)")
|
||||
password: str = Field(..., min_length=6, description="密码(至少6位)")
|
||||
nickname: str = Field(..., min_length=1, max_length=50, description="昵称")
|
||||
phone: str = Field(min_length=11, max_length=11, description="手机号(11位)")
|
||||
password: str = Field(min_length=6, description="密码(至少6位)")
|
||||
nickname: str = Field(min_length=1, max_length=50, description="昵称")
|
||||
email: Optional[str] = Field(None, description="邮箱(可选)")
|
||||
agreed_to_terms: bool = Field(..., description="是否同意用户协议和隐私政策")
|
||||
agreed_to_terms: bool = Field(description="是否同意用户协议和隐私政策")
|
||||
language: Optional[LanguagePreference] = Field(
|
||||
None,
|
||||
description="device language at signup; only used when creating a new user",
|
||||
@@ -18,9 +18,9 @@ class RegisterRequest(BaseModel):
|
||||
|
||||
|
||||
class LoginRequest(BaseModel):
|
||||
phone: str = Field(..., min_length=11, max_length=11, description="手机号(11位)")
|
||||
password: str = Field(..., min_length=1, description="密码")
|
||||
agreed_to_terms: bool = Field(..., description="是否同意用户协议和隐私政策")
|
||||
phone: str = Field(min_length=11, max_length=11, description="手机号(11位)")
|
||||
password: str = Field(min_length=1, description="密码")
|
||||
agreed_to_terms: bool = Field(description="是否同意用户协议和隐私政策")
|
||||
|
||||
|
||||
class TokenResponse(BaseModel):
|
||||
@@ -30,7 +30,7 @@ class TokenResponse(BaseModel):
|
||||
|
||||
|
||||
class RefreshTokenRequest(BaseModel):
|
||||
refresh_token: str = Field(..., description="刷新令牌")
|
||||
refresh_token: str = Field(description="刷新令牌")
|
||||
|
||||
|
||||
class UserResponse(BaseModel):
|
||||
@@ -45,7 +45,7 @@ class UserResponse(BaseModel):
|
||||
|
||||
|
||||
class SendSmsRequest(BaseModel):
|
||||
phone: str = Field(..., min_length=11, max_length=11, description="手机号(11位)")
|
||||
phone: str = Field(min_length=11, max_length=11, description="手机号(11位)")
|
||||
purpose: str = Field(
|
||||
..., description="用途:register/login/reset_password/change_phone"
|
||||
)
|
||||
@@ -58,9 +58,9 @@ class SendSmsResponse(BaseModel):
|
||||
|
||||
|
||||
class SmsLoginRequest(BaseModel):
|
||||
phone: str = Field(..., min_length=11, max_length=11, description="手机号(11位)")
|
||||
code: str = Field(..., min_length=6, max_length=6, description="验证码(6位)")
|
||||
agreed_to_terms: bool = Field(..., description="是否同意用户协议和隐私政策")
|
||||
phone: str = Field(min_length=11, max_length=11, description="手机号(11位)")
|
||||
code: str = Field(min_length=6, max_length=6, description="验证码(6位)")
|
||||
agreed_to_terms: bool = Field(description="是否同意用户协议和隐私政策")
|
||||
nickname: Optional[str] = Field(
|
||||
None, max_length=50, description="昵称(注册时必填,登录时可选)"
|
||||
)
|
||||
@@ -73,8 +73,8 @@ class SmsLoginRequest(BaseModel):
|
||||
class MockSmsLoginRequest(BaseModel):
|
||||
"""开发/评测专用:与 MOCK_SMS_LOGIN_ENABLED 联用,跳过短信校验。"""
|
||||
|
||||
phone: str = Field(..., min_length=11, max_length=11, description="手机号(11位)")
|
||||
agreed_to_terms: bool = Field(..., description="是否同意用户协议和隐私政策")
|
||||
phone: str = Field(min_length=11, max_length=11, description="手机号(11位)")
|
||||
agreed_to_terms: bool = Field(description="是否同意用户协议和隐私政策")
|
||||
nickname: Optional[str] = Field(
|
||||
None, max_length=50, description="新用户昵称(可选)"
|
||||
)
|
||||
@@ -85,12 +85,12 @@ class MockSmsLoginRequest(BaseModel):
|
||||
|
||||
|
||||
class SmsRegisterRequest(BaseModel):
|
||||
phone: str = Field(..., min_length=11, max_length=11, description="手机号(11位)")
|
||||
code: str = Field(..., min_length=6, max_length=6, description="验证码(6位)")
|
||||
password: str = Field(..., min_length=6, description="密码(至少6位)")
|
||||
nickname: str = Field(..., min_length=1, max_length=50, description="昵称")
|
||||
phone: str = Field(min_length=11, max_length=11, description="手机号(11位)")
|
||||
code: str = Field(min_length=6, max_length=6, description="验证码(6位)")
|
||||
password: str = Field(min_length=6, description="密码(至少6位)")
|
||||
nickname: str = Field(min_length=1, max_length=50, description="昵称")
|
||||
email: Optional[str] = Field(None, description="邮箱(可选)")
|
||||
agreed_to_terms: bool = Field(..., description="是否同意用户协议和隐私政策")
|
||||
agreed_to_terms: bool = Field(description="是否同意用户协议和隐私政策")
|
||||
language: Optional[LanguagePreference] = Field(
|
||||
None,
|
||||
description="device language at signup; only used when creating a new user",
|
||||
@@ -98,21 +98,21 @@ class SmsRegisterRequest(BaseModel):
|
||||
|
||||
|
||||
class ResetPasswordRequest(BaseModel):
|
||||
phone: str = Field(..., min_length=11, max_length=11, description="手机号(11位)")
|
||||
code: str = Field(..., min_length=6, max_length=6, description="验证码(6位)")
|
||||
new_password: str = Field(..., min_length=6, description="新密码(至少6位)")
|
||||
phone: str = Field(min_length=11, max_length=11, description="手机号(11位)")
|
||||
code: str = Field(min_length=6, max_length=6, description="验证码(6位)")
|
||||
new_password: str = Field(min_length=6, description="新密码(至少6位)")
|
||||
|
||||
|
||||
class ChangePasswordRequest(BaseModel):
|
||||
old_password: str = Field(..., min_length=1, description="旧密码")
|
||||
new_password: str = Field(..., min_length=6, description="新密码(至少6位)")
|
||||
old_password: str = Field(min_length=1, description="旧密码")
|
||||
new_password: str = Field(min_length=6, description="新密码(至少6位)")
|
||||
|
||||
|
||||
class ChangePhoneRequest(BaseModel):
|
||||
new_phone: str = Field(
|
||||
..., min_length=11, max_length=11, description="新手机号(11位)"
|
||||
)
|
||||
code: str = Field(..., min_length=6, max_length=6, description="验证码(6位)")
|
||||
code: str = Field(min_length=6, max_length=6, description="验证码(6位)")
|
||||
|
||||
|
||||
class UpdateNicknameRequest(BaseModel):
|
||||
|
||||
Reference in New Issue
Block a user