Files
life-echo/api/app/features/user/schemas.py
Sully 53e0065e3e refactor(api): TOML 配置 SSOT、统一错误契约、Auth/事务加固与可观测性 (#33)
配置 SSOT(TOML + .env)
统一错误契约
Auth 与事务边界
Redis / Celery 可靠性:业务 Redis(DB/0)与 Celery broker/backend(DB/1)显式拆分;连接池、sync client
可观测性(OpenTelemetry + LGTM)
2026-05-22 13:44:50 +08:00

72 lines
1.8 KiB
Python

from typing import Literal, Optional
from pydantic import BaseModel, Field
LanguagePreference = Literal["zh", "en"]
class UserProfileResponse(BaseModel):
id: str
phone: str
email: Optional[str] = None
nickname: str
avatar_url: Optional[str] = None
subscription_type: str
created_at: str
birth_year: Optional[int] = None
birth_place: Optional[str] = None
grew_up_place: Optional[str] = None
occupation: Optional[str] = None
language_preference: LanguagePreference = "zh"
class UpdateUserProfileRequest(BaseModel):
birth_year: Optional[int] = None
birth_place: Optional[str] = None
grew_up_place: Optional[str] = None
occupation: Optional[str] = None
class TestSubscriptionRequest(BaseModel):
action: Literal["activate", "deactivate"]
plan_id: Optional[str] = "pro"
class TestSubscriptionResponse(BaseModel):
success: bool
message: str
subscription_type: str
class SubmitFeedbackRequest(BaseModel):
"""提交反馈请求"""
content: str = Field(min_length=1, max_length=2000, description="反馈内容")
contact: Optional[str] = Field(None, max_length=100, description="联系方式(可选)")
class FeedbackResponse(BaseModel):
"""反馈响应"""
id: str
message: str
# 与前端约定:请求体必须携带该固定口令,防止误触清空。
PURGE_USER_DATA_CONFIRMATION = "我确认永久删除我的全部回忆与对话数据"
class PurgeUserDataRequest(BaseModel):
"""清空账号下全部业务数据(保留登录账号与手机号等;并清空出生年/出生地等档案字段)。"""
confirmation: str = Field(
...,
min_length=1,
description=f"必须为「{PURGE_USER_DATA_CONFIRMATION}",
)
class PurgeUserDataResponse(BaseModel):
success: bool
message: str