Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/api/v1/endpoints/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ async def change_article_name(article_id: int = Body(...), article_name: str = B

@router.post("/changeNote", response_model=dict)
async def change_note(note_id: int = Body(...), note_title: Optional[str] = Body(default=None), note_content: Optional[str] = Body(default=None), db: AsyncSession = Depends(get_db), user: dict = Depends(get_current_user)):
if len(note_title) > 100:
if note_title and len(note_title) > 100:
raise HTTPException(status_code=405, detail="Invalid note title, longer than 100")
user_id = user.get("id")
await crud_change_note(user_id, note_id, note_title, note_content, db)
Expand Down
6 changes: 3 additions & 3 deletions app/api/v1/endpoints/note.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from fastapi import APIRouter, HTTPException, Depends
from fastapi import APIRouter, HTTPException, Depends, Body
from sqlalchemy.ext.asyncio import AsyncSession
from app.schemas.note import NoteCreate, NoteUpdate, NoteFind
from app.utils.get_db import get_db
Expand All @@ -21,8 +21,8 @@ async def delete_note(note_id: int, db: AsyncSession = Depends(get_db), current_
raise HTTPException(status_code=404, detail="Note not found")
return {"msg": "Note deleted successfully"}

@router.put("/{note_id}", response_model=dict)
async def update_note(note_id: int, content: Optional[str] = None, title: Optional[str] = None,db: AsyncSession = Depends(get_db)):
@router.post("/{note_id}", response_model=dict)
async def update_note(note_id: int, content: Optional[str] = Body(default=None), title: Optional[str] = Body(default=None), db: AsyncSession = Depends(get_db)):
if content is None and title is None:
raise HTTPException(status_code=400, detail="At least one field must be provided for update")
note = NoteUpdate(id=note_id, content=content, title=title)
Expand Down