30 lines
864 B
Python
30 lines
864 B
Python
from pydantic import BaseModel, Field
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
|
|
class UserImageBase(BaseModel):
|
|
"""用户形象基础模式"""
|
|
image_url: str = Field(..., description="图片URL")
|
|
is_default: bool = Field(False, description="是否为默认形象")
|
|
|
|
class UserImageCreate(UserImageBase):
|
|
"""创建用户形象请求"""
|
|
pass
|
|
|
|
class UserImageInDB(UserImageBase):
|
|
"""数据库中的用户形象数据"""
|
|
id: int
|
|
user_id: int
|
|
create_time: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
class UserImage(UserImageInDB):
|
|
"""用户形象响应模式"""
|
|
pass
|
|
|
|
class UserImageUpdate(BaseModel):
|
|
"""更新用户形象请求"""
|
|
image_url: Optional[str] = Field(None, description="图片URL")
|
|
is_default: Optional[bool] = Field(None, description="是否为默认形象") |