fix: 게시판 코드 기반 조회 라우트 추가

- BoardController에 showByCode(string $code) 메서드 추가
- GET /api/v1/boards/{code} 라우트 등록
- 기존 ID 기반 조회와 코드 기반 조회 분리

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-01-27 15:24:35 +09:00
parent dd8a744d12
commit a9cdf004e3
2 changed files with 19 additions and 0 deletions

View File

@@ -106,6 +106,22 @@ public function tenantBoards()
}, __('message.fetched')); }, __('message.fetched'));
} }
/**
* 게시판 상세 조회 (코드 기반)
*/
public function showByCode(string $code)
{
return ApiResponse::handle(function () use ($code) {
$board = $this->boardService->getBoardByCode($code);
if (! $board) {
abort(404, __('error.board.not_found'));
}
return $board;
}, __('message.fetched'));
}
/** /**
* 게시판 필드 목록 조회 * 게시판 필드 목록 조회
*/ */

View File

@@ -1462,6 +1462,9 @@
Route::post('/{code}/posts/{postId}/comments', [PostController::class, 'storeComment'])->name('v1.boards.posts.comments.store'); // 댓글 작성 Route::post('/{code}/posts/{postId}/comments', [PostController::class, 'storeComment'])->name('v1.boards.posts.comments.store'); // 댓글 작성
Route::put('/{code}/posts/{postId}/comments/{commentId}', [PostController::class, 'updateComment'])->name('v1.boards.posts.comments.update'); // 댓글 수정 Route::put('/{code}/posts/{postId}/comments/{commentId}', [PostController::class, 'updateComment'])->name('v1.boards.posts.comments.update'); // 댓글 수정
Route::delete('/{code}/posts/{postId}/comments/{commentId}', [PostController::class, 'destroyComment'])->name('v1.boards.posts.comments.destroy'); // 댓글 삭제 Route::delete('/{code}/posts/{postId}/comments/{commentId}', [PostController::class, 'destroyComment'])->name('v1.boards.posts.comments.destroy'); // 댓글 삭제
// 게시판 상세 (코드 기반) - 가장 마지막에 배치 (catch-all)
Route::get('/{code}', [BoardController::class, 'showByCode'])->name('v1.boards.show_by_code');
}); });
// 게시글 API (사용자 중심) // 게시글 API (사용자 중심)