From a546215f45d6869f0a9b9da446f7675f689bf5f4 Mon Sep 17 00:00:00 2001 From: kent Date: Mon, 29 Dec 2025 10:12:29 +0900 Subject: [PATCH] =?UTF-8?q?fix(board,menu):=20=ED=85=8C=EB=84=8C=ED=8A=B8?= =?UTF-8?q?=20=EA=B2=8C=EC=8B=9C=ED=8C=90=20=EC=88=98=EC=A0=95=20=EB=B0=8F?= =?UTF-8?q?=20=EB=A9=94=EB=89=B4=20=ED=8E=98=EC=9D=B4=EC=A7=80=EB=84=A4?= =?UTF-8?q?=EC=9D=B4=EC=85=98=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 테넌트 게시판 수정 404 오류: - BoardService.getBoardById()에 $systemOnly 파라미터 추가 - BoardController.edit()에서 systemOnly=false로 테넌트 게시판 조회 가능 - Api/Admin/BoardController에서 show/update 메서드 테넌트 게시판 지원 - updateAnyBoard() 메서드 사용하여 시스템/테넌트 게시판 공통 수정 메뉴 페이지네이션 쿠키 값 미적용 오류: - HTMX 요청 시 htmx:configRequest 이벤트로 쿠키 값 적용 - pagination_per_page 쿠키에서 per_page 값 읽어서 요청 파라미터에 설정 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../Controllers/Api/Admin/BoardController.php | 35 ++++++++++++++---- app/Http/Controllers/BoardController.php | 3 +- app/Services/BoardService.php | 11 ++++-- resources/views/menus/index.blade.php | 37 +++++++++++++++++++ 4 files changed, 75 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/Api/Admin/BoardController.php b/app/Http/Controllers/Api/Admin/BoardController.php index 4e741844..0d9d78e5 100644 --- a/app/Http/Controllers/Api/Admin/BoardController.php +++ b/app/Http/Controllers/Api/Admin/BoardController.php @@ -58,7 +58,8 @@ public function stats(): JsonResponse */ public function show(int $id): JsonResponse { - $board = $this->boardService->getBoardById($id, true); + // systemOnly=false: 테넌트 게시판도 조회 가능 + $board = $this->boardService->getBoardById($id, true, false); if (! $board) { return response()->json([ @@ -109,7 +110,7 @@ public function store(Request $request): JsonResponse } /** - * 게시판 수정 + * 게시판 수정 (시스템/테넌트 공통) */ public function update(Request $request, int $id): JsonResponse { @@ -126,15 +127,35 @@ public function update(Request $request, int $id): JsonResponse 'is_active' => 'nullable|boolean', ]); - // 코드 중복 체크 (자신 제외) - if ($this->boardService->isCodeExists($validated['board_code'], $id)) { + // 기존 게시판 조회 (systemOnly=false) + $board = $this->boardService->getBoardById($id, true, false); + + if (! $board) { return response()->json([ 'success' => false, - 'message' => '이미 사용 중인 게시판 코드입니다.', - ], 422); + 'message' => '게시판을 찾을 수 없습니다.', + ], 404); } - $this->boardService->updateBoard($id, $validated); + // 코드 중복 체크 (자신 제외, 시스템/테넌트 구분) + if ($board->is_system) { + if ($this->boardService->isCodeExists($validated['board_code'], $id)) { + return response()->json([ + 'success' => false, + 'message' => '이미 사용 중인 게시판 코드입니다.', + ], 422); + } + } else { + if ($this->boardService->isTenantCodeExists($validated['board_code'], $board->tenant_id, $id)) { + return response()->json([ + 'success' => false, + 'message' => '해당 테넌트에서 이미 사용 중인 게시판 코드입니다.', + ], 422); + } + } + + // 시스템/테넌트 공통 수정 메서드 사용 + $this->boardService->updateAnyBoard($id, $validated); return response()->json([ 'success' => true, diff --git a/app/Http/Controllers/BoardController.php b/app/Http/Controllers/BoardController.php index 21b7a531..59c5b6f1 100644 --- a/app/Http/Controllers/BoardController.php +++ b/app/Http/Controllers/BoardController.php @@ -35,7 +35,8 @@ public function create(): View */ public function edit(int $id): View { - $board = $this->boardService->getBoardById($id, true); + // systemOnly=false: 테넌트 게시판도 수정 가능 + $board = $this->boardService->getBoardById($id, true, false); if (! $board) { abort(404, '게시판을 찾을 수 없습니다.'); diff --git a/app/Services/BoardService.php b/app/Services/BoardService.php index 07c34ffc..8dd0d1ef 100644 --- a/app/Services/BoardService.php +++ b/app/Services/BoardService.php @@ -76,14 +76,19 @@ public function getActiveBoardList(): Collection /** * 특정 게시판 조회 + * + * @param bool $systemOnly true면 시스템 게시판만, false면 모든 게시판 */ - public function getBoardById(int $id, bool $withTrashed = false): ?Board + public function getBoardById(int $id, bool $withTrashed = false, bool $systemOnly = true): ?Board { $query = Board::query() - ->systemOnly() - ->with('fields') + ->with(['fields', 'tenant:id,code,company_name']) ->withCount('fields'); + if ($systemOnly) { + $query->systemOnly(); + } + if ($withTrashed) { $query->withTrashed(); } diff --git a/resources/views/menus/index.blade.php b/resources/views/menus/index.blade.php index a6a9582f..5a0b510f 100644 --- a/resources/views/menus/index.blade.php +++ b/resources/views/menus/index.blade.php @@ -89,6 +89,9 @@ class="bg-gray-800 hover:bg-gray-900 text-white px-4 py-2 rounded-lg transition
+ + +
@@ -122,6 +125,40 @@ class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none foc + {{-- 쿠키에서 per_page 값 로드 (htmx:configRequest 이벤트로 요청 직전에 적용) --}} + +