38 lines
717 B
Python
38 lines
717 B
Python
"""
|
|
通知相关的 Pydantic Schema
|
|
"""
|
|
from pydantic import BaseModel, Field
|
|
from typing import Optional, List
|
|
from datetime import datetime
|
|
|
|
|
|
class NotificationBase(BaseModel):
|
|
type: str = "info"
|
|
category: str = "system"
|
|
title: str
|
|
content: Optional[str] = None
|
|
link: Optional[str] = None
|
|
|
|
|
|
class NotificationCreate(NotificationBase):
|
|
user_id: int
|
|
|
|
|
|
class NotificationUpdate(BaseModel):
|
|
is_read: Optional[int] = None
|
|
|
|
|
|
class NotificationResponse(NotificationBase):
|
|
id: int
|
|
user_id: int
|
|
is_read: int
|
|
created_at: datetime
|
|
read_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class UnreadCountResponse(BaseModel):
|
|
unread_count: int
|