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:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\note\controller\v1;
|
||||
|
||||
use app\api\common\Response;
|
||||
use app\note\controller\BaseController;
|
||||
use app\note\service\NoteService;
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
* 笔记分享控制器
|
||||
*/
|
||||
class Share extends BaseController
|
||||
{
|
||||
protected $noteService;
|
||||
|
||||
public function __construct(App $app)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->noteService = new NoteService();
|
||||
}
|
||||
|
||||
public function create(int $id)
|
||||
{
|
||||
try {
|
||||
if ($id <= 0) {
|
||||
return Response::error('笔记 ID 不正确', 400);
|
||||
}
|
||||
|
||||
$result = $this->noteService->createShare($this->getCurrentNoteUserId(), $id);
|
||||
return Response::success($result, '分享已生成');
|
||||
} catch (\Throwable $e) {
|
||||
return Response::error($e->getMessage(), $e->getCode() ?: 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function read(string $token)
|
||||
{
|
||||
try {
|
||||
if (trim($token) === '') {
|
||||
return Response::error('分享标识不能为空', 400);
|
||||
}
|
||||
|
||||
$result = $this->noteService->getSharedDetail(trim($token));
|
||||
return Response::success($result);
|
||||
} catch (\Throwable $e) {
|
||||
return Response::error($e->getMessage(), $e->getCode() ?: 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user