feat(note): add image upload functionality for notes

- Implemented a new endpoint in the Note controller to handle image uploads associated with notes.
- Added the `uploadImage` method in NoteService to manage image storage and return public URLs.
- Updated API routes to include the new image upload endpoint, enhancing note management capabilities.
This commit is contained in:
nepiedg
2026-04-20 10:27:54 +00:00
parent 9cc82df980
commit 69eb3e5019
4 changed files with 84 additions and 0 deletions
+23
View File
@@ -178,4 +178,27 @@ class Note extends BaseController
return Response::error($e->getMessage(), $e->getCode() ?: 500);
}
}
/**
* 上传笔记图片
* POST /note/v1/item/image/:id
*/
public function image(Request $request, int $id)
{
try {
if ($id <= 0) {
return Response::error('笔记 ID 不正确', 400);
}
$file = $request->file('image');
if (!$file) {
return Response::error('图片文件不能为空', 400);
}
$result = $this->noteService->uploadImage($this->getCurrentNoteUserId(), $id, $file);
return Response::success($result, '上传成功');
} catch (\Throwable $e) {
return Response::error($e->getMessage(), $e->getCode() ?: 500);
}
}
}