from pydantic import BaseModel, Field

from app.enums.sms import SmsScene


class SmsSendRequest(BaseModel):
    phone: str = Field(..., pattern=r"^1[3-9]\d{9}$", description="手机号")
    scene: SmsScene = Field(
        ...,
        description=(
            "短信场景："
            "register=注册，"
            "login=短信登录，"
            "common=通用场景，"
            "set_password=设置密码"
        ),
    )
    captcha_token: str | None = Field(None, description="图形验证码令牌，正式环境按配置要求传入")


class SmsVerifyRequest(BaseModel):
    phone: str = Field(..., pattern=r"^1[3-9]\d{9}$", description="手机号")
    scene: SmsScene = Field(
        ...,
        description=(
            "短信场景："
            "register=注册，"
            "login=短信登录，"
            "common=通用场景，"
            "set_password=设置密码"
        ),
    )
    code: str = Field(..., min_length=4, max_length=8, description="验证码")


class SmsResponse(BaseModel):
    message: str
    success: bool