Files
chat/backend/app/schemas/moment.py
T
2026-06-13 07:33:46 +08:00

49 lines
1.1 KiB
Python

"""朋友圈相关 Schema"""
from datetime import datetime
from pydantic import BaseModel, Field
class MomentCreate(BaseModel):
content: str = Field(..., min_length=1, max_length=1000)
images: list[str] | None = Field(None, max_length=9)
visibility: str = Field("friends", pattern="^(public|friends|private)$")
class MomentRead(BaseModel):
id: str
user_id: str
username: str
nickname: str | None = None
avatar_url: str | None = None
content: str
images: list[str] = []
visibility: str
like_count: int = 0
is_liked: bool = False
comment_count: int = 0
created_at: datetime
model_config = {"from_attributes": True}
class MomentCommentCreate(BaseModel):
content: str = Field(..., min_length=1, max_length=500)
reply_to_id: str | None = None
class MomentCommentRead(BaseModel):
id: str
moment_id: str
user_id: str
username: str
nickname: str | None = None
avatar_url: str | None = None
content: str
reply_to_id: str | None = None
reply_to_username: str | None = None
created_at: datetime
model_config = {"from_attributes": True}