TT-003: complete request-module integration into modular platform

- integrated request-module into module registry
- moved backend into modules/request-module
- added manifest.json and module.py
- implemented dynamic router mounting
- implemented dynamic static mounting
- removed direct dependencies from platform core
- verified startup with request-module
- verified startup without request-module
- added implementation_report_003.md
This commit is contained in:
2026-08-06 16:31:27 +03:00
parent c97e6a42f7
commit 6c86f0f571
180 changed files with 204885 additions and 25 deletions
@@ -0,0 +1,76 @@
"""Notification routes."""
from fastapi import APIRouter, Depends, HTTPException, status, Query
from sqlalchemy.orm import Session
from typing import List, Optional
from request_app.core.database import get_db
from request_app.core.auth import get_current_user_id
from request_app.schemas.reference import NotificationResponse, NotificationListResponse
from request_app.services.notification_service import NotificationService
router = APIRouter(prefix="/notifications", tags=["Notifications"])
@router.get("", response_model=NotificationListResponse)
async def get_notifications(
is_read: Optional[int] = Query(None, description="Filter by read status (0 or 1)"),
token: str = Depends(get_current_user_id),
db: Session = Depends(get_db)
):
"""Get current user's notifications."""
service = NotificationService(db)
notifications = service.get_user_notifications(token, is_read)
# Count unread
unread_count = sum(1 for n in notifications if n.is_read == 0)
return NotificationListResponse(
notifications=notifications,
total=len(notifications),
unread_count=unread_count
)
@router.put("/{notification_id}/read", response_model=NotificationResponse)
async def mark_as_read(
notification_id: int,
token: str = Depends(get_current_user_id),
db: Session = Depends(get_db)
):
"""Mark notification as read."""
service = NotificationService(db)
try:
return service.mark_as_read(notification_id, token)
except ValueError as e:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=str(e))
@router.put("/read-all")
async def mark_all_as_read(
token: str = Depends(get_current_user_id),
db: Session = Depends(get_db)
):
"""Mark all notifications as read."""
service = NotificationService(db)
updated = service.mark_all_as_read(token)
return {"message": f"Marked {updated} notifications as read"}
@router.delete("/{notification_id}", status_code=status.HTTP_204_NO_CONTENT)
async def delete_notification(
notification_id: int,
token: str = Depends(get_current_user_id),
db: Session = Depends(get_db)
):
"""Delete notification."""
service = NotificationService(db)
if not service.delete_notification(notification_id, token):
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail="Notification not found"
)