Files
CosScene/server/app/services/notification_service.py
T
2026-05-09 16:40:29 +08:00

26 lines
515 B
Python

from sqlalchemy.ext.asyncio import AsyncSession
from app.models.notification import Notification
async def send_notification(
db: AsyncSession,
user_id: int,
type: str,
title: str,
content: str | None = None,
ref_type: str | None = None,
ref_id: int | None = None,
):
n = Notification(
user_id=user_id,
type=type,
title=title,
content=content,
ref_type=ref_type,
ref_id=ref_id,
)
db.add(n)
await db.flush()
return n