- Backend: FastAPI + MongoDB + Redis (카테고리, 할일 CRUD, 파일 첨부, 검색, 대시보드) - Frontend: Next.js 15 + Tailwind + React Query + Zustand - 통합 TodoModal: 생성/수정 모달 통합, 탭 구조 (기본/태그와 첨부) - 간트차트: 카테고리별 할일 타임라인 시각화 - TodoCard: 제목/카테고리/우선순위/태그/첨부 한줄 표시 - Docker Compose 배포 (Frontend:3010, Backend:8010, MongoDB:27021, Redis:6391) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
57 lines
1.5 KiB
Python
57 lines
1.5 KiB
Python
from typing import List
|
|
|
|
from fastapi import APIRouter, Depends, File, UploadFile, status
|
|
from fastapi.responses import FileResponse
|
|
|
|
from app.database import get_database
|
|
from app.models.todo import Attachment
|
|
from app.services.file_service import FileService
|
|
|
|
router = APIRouter(prefix="/api/todos", tags=["attachments"])
|
|
|
|
|
|
def _get_service(db=Depends(get_database)) -> FileService:
|
|
return FileService(db)
|
|
|
|
|
|
@router.post(
|
|
"/{todo_id}/attachments",
|
|
response_model=list[Attachment],
|
|
status_code=status.HTTP_201_CREATED,
|
|
)
|
|
async def upload_attachments(
|
|
todo_id: str,
|
|
files: List[UploadFile] = File(...),
|
|
service: FileService = Depends(_get_service),
|
|
):
|
|
"""파일 업로드 (최대 5개, 파일당 10MB)"""
|
|
return await service.upload_files(todo_id, files)
|
|
|
|
|
|
@router.get("/{todo_id}/attachments/{attachment_id}/download")
|
|
async def download_attachment(
|
|
todo_id: str,
|
|
attachment_id: str,
|
|
service: FileService = Depends(_get_service),
|
|
):
|
|
"""파일 다운로드"""
|
|
file_path, filename = await service.get_file_info(todo_id, attachment_id)
|
|
return FileResponse(
|
|
path=str(file_path),
|
|
filename=filename,
|
|
media_type="application/octet-stream",
|
|
)
|
|
|
|
|
|
@router.delete(
|
|
"/{todo_id}/attachments/{attachment_id}",
|
|
status_code=status.HTTP_204_NO_CONTENT,
|
|
)
|
|
async def delete_attachment(
|
|
todo_id: str,
|
|
attachment_id: str,
|
|
service: FileService = Depends(_get_service),
|
|
):
|
|
"""첨부파일 삭제"""
|
|
await service.delete_attachment(todo_id, attachment_id)
|