67 lines
1.7 KiB
PHP
67 lines
1.7 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Controllers\Api\V1;
|
||
|
|
|
||
|
|
use App\Helpers\ApiResponse;
|
||
|
|
use App\Http\Controllers\Controller;
|
||
|
|
use App\Services\Boards\BoardService;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 시스템 게시판 API 컨트롤러
|
||
|
|
*
|
||
|
|
* 시스템 게시판 (is_system=true, tenant_id=null):
|
||
|
|
* - 본사에서 생성/관리하는 게시판
|
||
|
|
* - 모든 테넌트에서 읽기 가능
|
||
|
|
* - URL: /api/v1/system-boards/{code}
|
||
|
|
*/
|
||
|
|
class SystemBoardController extends Controller
|
||
|
|
{
|
||
|
|
public function __construct(
|
||
|
|
protected BoardService $boardService
|
||
|
|
) {}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 시스템 게시판 목록 조회
|
||
|
|
*/
|
||
|
|
public function index()
|
||
|
|
{
|
||
|
|
return ApiResponse::handle(function () {
|
||
|
|
$filters = request()->only(['board_type', 'search']);
|
||
|
|
|
||
|
|
return $this->boardService->getSystemBoards($filters);
|
||
|
|
}, __('message.fetched'));
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 시스템 게시판 상세 조회 (code 기반)
|
||
|
|
*/
|
||
|
|
public function show(string $code)
|
||
|
|
{
|
||
|
|
return ApiResponse::handle(function () use ($code) {
|
||
|
|
$board = $this->boardService->getSystemBoardByCode($code);
|
||
|
|
|
||
|
|
if (! $board) {
|
||
|
|
abort(404, __('error.board.not_found'));
|
||
|
|
}
|
||
|
|
|
||
|
|
return $board->load('customFields');
|
||
|
|
}, __('message.fetched'));
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 시스템 게시판 필드 목록 조회
|
||
|
|
*/
|
||
|
|
public function fields(string $code)
|
||
|
|
{
|
||
|
|
return ApiResponse::handle(function () use ($code) {
|
||
|
|
$board = $this->boardService->getSystemBoardByCode($code);
|
||
|
|
|
||
|
|
if (! $board) {
|
||
|
|
abort(404, __('error.board.not_found'));
|
||
|
|
}
|
||
|
|
|
||
|
|
return $this->boardService->getBoardFields($board->id);
|
||
|
|
}, __('message.fetched'));
|
||
|
|
}
|
||
|
|
}
|