only(['search', 'is_notice', 'status']); $perPage = (int) request()->get('per_page', 15); return $this->postService->getPostsBySystemBoardCode($code, $filters, $perPage); }, __('message.fetched')); } /** * 시스템 게시판 게시글 상세 조회 */ public function show(string $code, int $id) { return ApiResponse::handle(function () use ($code, $id) { $post = $this->postService->getPostBySystemBoardCodeAndId($code, $id); if (! $post) { abort(404, __('error.post.not_found')); } // 조회수 증가 $post->increment('views'); // 커스텀 필드 값 추가 $post->custom_field_values = $this->postService->getCustomFieldValues($id); return $post; }, __('message.fetched')); } /** * 시스템 게시판 게시글 작성 */ public function store(PostStoreRequest $request, string $code) { return ApiResponse::handle(function () use ($request, $code) { return $this->postService->createPostBySystemBoardCode($code, $request->validated()); }, __('message.created')); } /** * 시스템 게시판 게시글 수정 */ public function update(PostUpdateRequest $request, string $code, int $id) { return ApiResponse::handle(function () use ($request, $code, $id) { $post = $this->postService->updatePostBySystemBoardCode($code, $id, $request->validated()); if (! $post) { abort(404, __('error.post.not_found')); } return $post; }, __('message.updated')); } /** * 시스템 게시판 게시글 삭제 */ public function destroy(string $code, int $id) { return ApiResponse::handle(function () use ($code, $id) { $deleted = $this->postService->deletePostBySystemBoardCode($code, $id); if (! $deleted) { abort(404, __('error.post.not_found')); } return ['deleted' => true]; }, __('message.deleted')); } /** * 시스템 게시판 게시글 댓글 목록 조회 */ public function comments(string $code, int $postId) { return ApiResponse::handle(function () use ($postId) { return $this->postService->getComments($postId); }, __('message.fetched')); } /** * 시스템 게시판 게시글 댓글 작성 */ public function storeComment(CommentStoreRequest $request, string $code, int $postId) { return ApiResponse::handle(function () use ($request, $postId) { return $this->postService->createComment($postId, $request->validated()); }, __('message.created')); } /** * 시스템 게시판 게시글 댓글 수정 */ public function updateComment(CommentStoreRequest $request, string $code, int $postId, int $commentId) { return ApiResponse::handle(function () use ($request, $commentId) { $comment = $this->postService->updateComment($commentId, $request->validated()); if (! $comment) { abort(404, __('error.comment.not_found')); } return $comment; }, __('message.updated')); } /** * 시스템 게시판 게시글 댓글 삭제 */ public function destroyComment(string $code, int $postId, int $commentId) { return ApiResponse::handle(function () use ($commentId) { $deleted = $this->postService->deleteComment($commentId); if (! $deleted) { abort(404, __('error.comment.not_found')); } return ['deleted' => true]; }, __('message.deleted')); } }