feat(note): add audio upload and sharing functionality
- Introduced `note_audio` table for storing audio attachments related to notes. - Implemented audio upload endpoint in `Note` controller to handle audio file uploads. - Added sharing functionality with `note_share` table to manage share tokens and view counts. - Updated API routes to include endpoints for audio uploads and share creation. - Enhanced documentation to reflect new audio and sharing features.
This commit is contained in:
@@ -8,6 +8,7 @@ use app\note\controller\BaseController;
|
||||
use app\note\service\NoteService;
|
||||
use think\App;
|
||||
use think\exception\ValidateException;
|
||||
use think\Request;
|
||||
|
||||
/**
|
||||
* 笔记控制器
|
||||
@@ -153,4 +154,28 @@ class Note extends BaseController
|
||||
return Response::error($e->getMessage(), $e->getCode() ?: 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传笔记录音
|
||||
* POST /note/v1/item/audio/:id
|
||||
*/
|
||||
public function audio(Request $request, int $id)
|
||||
{
|
||||
try {
|
||||
if ($id <= 0) {
|
||||
return Response::error('笔记 ID 不正确', 400);
|
||||
}
|
||||
|
||||
$file = $request->file('audio');
|
||||
if (!$file) {
|
||||
return Response::error('录音文件不能为空', 400);
|
||||
}
|
||||
|
||||
$durationMs = (int) $request->post('audio_duration_ms', 0);
|
||||
$result = $this->noteService->uploadAudio($this->getCurrentNoteUserId(), $id, $file, $durationMs);
|
||||
return Response::success($result, '上传成功');
|
||||
} catch (\Throwable $e) {
|
||||
return Response::error($e->getMessage(), $e->getCode() ?: 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user