dbmsv4/app/Controllers/Admin/BoardController.php
2025-11-20 15:26:33 +09:00

117 lines
3.4 KiB
PHP

<?php
namespace App\Controllers\Admin;
use App\Entities\UserEntity;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class BoardController extends AdminController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
if ($this->service === null) {
$this->service = service('boardservice');
}
$this->addActionPaths('board');
}
//Action작업관련
protected function action_init_process(string $action): void
{
$fields = [
'category',
'worker_uid',
'title',
'status',
'content',
];
$filters = [
'user_uid',
'worker_uid',
'category',
'status',
];
$indexFilter = $filters;
$batchjobFilters = ['user_uid', 'category', 'status'];
switch ($action) {
case 'create':
case 'create_form':
break;
case 'modify':
case 'modify_form':
$fields = [...$fields, 'status'];
break;
case 'view':
$fields = [
'category',
'worker_uid',
'title',
'status',
'created_at',
'content'
];
break;
case 'index':
$fields = [
'category',
'worker_uid',
'title',
'status',
'created_at'
];
break;
case 'download':
$fields = [
'category',
'worker_uid',
'title',
'status',
'created_at',
'content'
];
break;
default:
throw new \Exception("[{$action}] 지원하지 않는 action입니다.");
// break;
}
$this->service->getFormService()->setFormFields($fields);
$this->service->getFormService()->setFormRules($action, $fields);
$this->service->getFormService()->setFormFilters($filters);
$this->service->getFormService()->setFormOptions($filters);
$this->service->getFormService()->setIndexFilters($indexFilter);
$this->service->getFormService()->setBatchjobFilters($batchjobFilters);
parent::action_init_process($action);
}
protected function getEntityClass(): string
{
return UserEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
// public function notice(): ResponseInterface
// {
// $this->getService()->setAction(__FUNCTION__);
// $this->getService()->setFormFields();
// //전달값정의
// $this->getService()->setFormDatas($this->request->getGet());
// $formDatas = $this->getSErvice()->getFormDatas();
// return $this->response->setJSON($this->getService()->getLatest(
// array_key_exists('category', $formDatas) && $formDatas['category'] ? $formDatas['category'] : BOARD['CATEGORY']['NOTICE'],
// ));
// }
// public function reqeusttask(): ResponseInterface
// {
// $this->getService()->setAction(__FUNCTION__);
// $this->getService()->setFormFields();
// //전달값정의
// $this->getService()->setFormDatas($this->request->getGet());
// $formDatas = $this->getSErvice()->getFormDatas();
// return $this->response->setJSON($this->getService()->getLatest(
// array_key_exists('category', $formDatas) && $formDatas['category'] ? $formDatas['category'] : BOARD['CATEGORY']['NOTICE'],
// ['worker_uid' => $this->getMyAuth()->getUIDByAuthInfo()]
// ));
// }
}