首次提交by MimoCode

This commit is contained in:
tang1219
2026-06-15 14:50:15 +08:00
parent 584b31da50
commit ead13f863c
166 changed files with 14908 additions and 1 deletions
+39
View File
@@ -0,0 +1,39 @@
from typing import Optional, List
from sqlalchemy.ext.asyncio import AsyncSession
from app.models.notification import Notification
from app.repositories.notification import NotificationRepository
class NotificationService:
def __init__(self, db: AsyncSession):
self.db = db
self.repo = NotificationRepository(db)
async def get_notifications(
self,
user_id: Optional[int] = None,
is_read: Optional[bool] = None,
type: Optional[str] = None,
page: int = 1,
page_size: int = 20
) -> List[Notification]:
return await self.repo.get_list(
user_id=user_id,
is_read=is_read,
type=type,
page=page,
page_size=page_size
)
async def create_notification(self, data: dict) -> Notification:
return await self.repo.create(data)
async def mark_as_read(self, notification_id: int) -> bool:
return await self.repo.mark_as_read(notification_id)
async def mark_all_as_read(self, user_id: int) -> int:
return await self.repo.mark_all_as_read(user_id)
async def delete_notification(self, notification_id: int) -> bool:
return await self.repo.delete(notification_id)