71 lines
1.9 KiB
Python
71 lines
1.9 KiB
Python
"""用户Schema"""
|
|
from typing import Optional, List
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class UserBase(BaseModel):
|
|
"""用户基础Schema"""
|
|
username: str = Field(..., description="用户名")
|
|
real_name: Optional[str] = Field(None, description="真实姓名")
|
|
phone: Optional[str] = Field(None, description="联系电话")
|
|
role: str = Field(..., description="角色")
|
|
region_id: Optional[str] = Field(None, description="所属区域ID")
|
|
is_active: bool = Field(True, description="是否激活")
|
|
|
|
|
|
class UserCreate(UserBase):
|
|
"""创建用户"""
|
|
pass
|
|
|
|
|
|
class UserUpdate(BaseModel):
|
|
"""更新用户"""
|
|
real_name: Optional[str] = Field(None, description="真实姓名")
|
|
phone: Optional[str] = Field(None, description="联系电话")
|
|
role: Optional[str] = Field(None, description="角色")
|
|
region_id: Optional[str] = Field(None, description="所属区域ID")
|
|
is_active: Optional[bool] = Field(None, description="是否激活")
|
|
|
|
|
|
class UserResponse(UserBase):
|
|
"""用户响应"""
|
|
id: str
|
|
create_at: Optional[str] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class UserListResponse(BaseModel):
|
|
"""用户列表响应"""
|
|
items: List[UserResponse]
|
|
total: int
|
|
page: int
|
|
pageSize: int
|
|
totalPages: int
|
|
|
|
|
|
class LoginRequest(BaseModel):
|
|
"""登录请求"""
|
|
username: str = Field(..., description="用户名")
|
|
password: str = Field(..., description="密码")
|
|
|
|
|
|
class LoginResponse(BaseModel):
|
|
"""登录响应"""
|
|
token: str
|
|
refreshToken: str
|
|
expiresIn: int
|
|
userInfo: dict
|
|
|
|
|
|
class ChangePasswordRequest(BaseModel):
|
|
"""修改密码请求"""
|
|
oldPassword: str = Field(..., description="旧密码")
|
|
newPassword: str = Field(..., description="新密码")
|
|
|
|
|
|
class ResetPasswordRequest(BaseModel):
|
|
"""重置密码请求"""
|
|
userId: str = Field(..., description="用户ID")
|