Initial commit: stock market platform

This commit is contained in:
admin
2026-06-11 01:41:47 +08:00
commit 63718906e9
62 changed files with 8962 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
from pydantic import BaseModel, EmailStr, field_validator
import re
class RegisterRequest(BaseModel):
username: str
email: EmailStr
password: str
@field_validator("username")
@classmethod
def username_alphanumeric(cls, v: str) -> str:
if not re.match(r"^[a-zA-Z0-9_]{3,20}$", v):
raise ValueError("用户名只能包含字母、数字、下划线长度3-20位")
return v
@field_validator("password")
@classmethod
def password_min_length(cls, v: str) -> str:
if len(v) < 6:
raise ValueError("密码至少6位")
return v
class LoginRequest(BaseModel):
username: str
password: str
class TokenResponse(BaseModel):
access_token: str
refresh_token: str
token_type: str = "bearer"
class RefreshRequest(BaseModel):
refresh_token: str
class UserOut(BaseModel):
id: int
username: str
email: str
is_active: bool
is_admin: bool
model_config = {"from_attributes": True}