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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user