dbmsv2 init...1
This commit is contained in:
parent
5de8920a2e
commit
740a8ce897
@ -3,12 +3,9 @@
|
||||
namespace App\Controllers\Admin\Customer;
|
||||
|
||||
use App\Entities\Customer\ClientEntity;
|
||||
use App\Entities\Customer\ServiceEntity;
|
||||
use App\Helpers\Customer\ClientHelper;
|
||||
|
||||
use App\Helpers\Customer\ServiceHelper;
|
||||
use App\Helpers\Equipment\ServerHelper;
|
||||
use App\Services\Customer\ClientService;
|
||||
use App\Services\Customer\ServiceService;
|
||||
use App\Services\Equipment\ServerService;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
@ -74,7 +71,7 @@ class ClientController extends CustomerController
|
||||
//Index,FieldForm관련.
|
||||
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
{
|
||||
switch ($this->getAction()) {
|
||||
switch ($this->getService()->getAction()) {
|
||||
// case 'create_form':
|
||||
// case 'modify_form':
|
||||
case 'detail':
|
||||
@ -83,9 +80,9 @@ class ClientController extends CustomerController
|
||||
$this->getService()->getHelper()->setViewDatas($this->getViewDatas());
|
||||
$actionTemplate = $this->request->getVar('ActionTemplate') ?? $actionTemplate ?? 'client';
|
||||
if ($actionTemplate) {
|
||||
$view_file = $this->view_path . $actionTemplate . DIRECTORY_SEPARATOR . $this->getAction();
|
||||
$view_file = $this->view_path . $actionTemplate . DIRECTORY_SEPARATOR . $this->getService()->getAction();
|
||||
} else {
|
||||
$view_file = $this->view_path . $this->getAction();
|
||||
$view_file = $this->view_path . $this->getService()->getAction();
|
||||
}
|
||||
$result = view($view_file, ['viewDatas' => $this->getViewDatas()]);
|
||||
break;
|
||||
@ -98,13 +95,13 @@ class ClientController extends CustomerController
|
||||
public function detail(mixed $uid): RedirectResponse|string
|
||||
{
|
||||
try {
|
||||
$this->setAction(__FUNCTION__);
|
||||
$this->setFormFields();
|
||||
$this->setFormFilters();
|
||||
$this->setFormRules();
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
$this->getService()->setFormFields();
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
//기본값정의
|
||||
$this->setFormDatas($this->request->getGet());
|
||||
$this->setFormOptions();
|
||||
$this->getService()->setFormOptions();
|
||||
//일괄작업용 Fields정의
|
||||
$entity = $this->getService()->getEntity($uid);
|
||||
if (!($entity instanceof ClientEntity)) {
|
||||
@ -121,8 +118,8 @@ class ClientController extends CustomerController
|
||||
$this->serviceEntities = $this->getService()->getServiceService()->getEntities(['clientinfo_uid' => $entity->getPK()]);
|
||||
$this->entity = $entity;
|
||||
helper(['form']);
|
||||
$this->serviceHelper = new ServiceHelper();
|
||||
$this->serverHelper = new ServerHelper();
|
||||
$this->serviceService = new ServiceService();
|
||||
$this->serverServicer = new ServerService();
|
||||
return $this->getResultSuccess();
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
|
||||
@ -43,16 +43,16 @@ class PaymentController extends CustomerController
|
||||
}
|
||||
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
{
|
||||
switch ($this->getAction()) {
|
||||
switch ($this->getService()->getAction()) {
|
||||
case 'invoice':
|
||||
$this->service = $this->getService();
|
||||
$this->control = $this->getService()->getControlDatas();
|
||||
$this->getService()->getHelper()->setViewDatas($this->getViewDatas());
|
||||
$actionTemplate = $this->request->getVar('ActionTemplate') ?? $actionTemplate ?? 'payment';
|
||||
if ($actionTemplate) {
|
||||
$view_file = $this->view_path . $actionTemplate . DIRECTORY_SEPARATOR . $this->getAction();
|
||||
$view_file = $this->view_path . $actionTemplate . DIRECTORY_SEPARATOR . $this->getService()->getAction();
|
||||
} else {
|
||||
$view_file = $this->view_path . $this->getAction();
|
||||
$view_file = $this->view_path . $this->getService()->getAction();
|
||||
}
|
||||
$result = view($view_file, ['viewDatas' => $this->getViewDatas()]);
|
||||
break;
|
||||
@ -130,10 +130,10 @@ class PaymentController extends CustomerController
|
||||
public function invoice(): RedirectResponse|string
|
||||
{
|
||||
try {
|
||||
$this->setAction(__FUNCTION__);
|
||||
$this->setFormFields();
|
||||
$this->setFormFilters();
|
||||
$this->setFormRules();
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
$this->getService()->setFormFields();
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
$this->invoice_process();
|
||||
return $this->getResultSuccess();
|
||||
} catch (\Exception $e) {
|
||||
|
||||
@ -3,8 +3,6 @@
|
||||
namespace App\Controllers\Admin\Customer;
|
||||
|
||||
use App\Entities\Customer\ServiceEntity;
|
||||
use App\Helpers\Customer\ServiceHelper;
|
||||
|
||||
use App\Services\Customer\PaymentService;
|
||||
use App\Services\Customer\ServiceService;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
@ -41,7 +39,7 @@ class ServiceController extends CustomerController
|
||||
//Index,FieldForm관련
|
||||
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
{
|
||||
switch ($this->getAction()) {
|
||||
switch ($this->getService()->getAction()) {
|
||||
// case 'create_form':
|
||||
// case 'modify_form':
|
||||
case 'view':
|
||||
@ -51,9 +49,9 @@ class ServiceController extends CustomerController
|
||||
$this->getService()->getHelper()->setViewDatas($this->getViewDatas());
|
||||
$actionTemplate = $this->request->getVar('ActionTemplate') ?? $actionTemplate ?? 'service';
|
||||
if ($actionTemplate) {
|
||||
$view_file = $this->view_path . $actionTemplate . DIRECTORY_SEPARATOR . $this->getAction();
|
||||
$view_file = $this->view_path . $actionTemplate . DIRECTORY_SEPARATOR . $this->getService()->getAction();
|
||||
} else {
|
||||
$view_file = $this->view_path . $this->getAction();
|
||||
$view_file = $this->view_path . $this->getService()->getAction();
|
||||
}
|
||||
$result = view($view_file, ['viewDatas' => $this->getViewDatas()]);
|
||||
break;
|
||||
|
||||
@ -30,7 +30,7 @@ class ServerController extends EquipmentController
|
||||
//Index,FieldForm관련
|
||||
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
{
|
||||
switch ($this->getAction()) {
|
||||
switch ($this->getService()->getAction()) {
|
||||
case 'view':
|
||||
case 'index':
|
||||
$this->service = $this->getService();
|
||||
@ -38,9 +38,9 @@ class ServerController extends EquipmentController
|
||||
$this->getService()->getHelper()->setViewDatas($this->getViewDatas());
|
||||
$actionTemplate = $this->request->getVar('ActionTemplate') ?? $actionTemplate ?? 'server';
|
||||
if ($actionTemplate) {
|
||||
$view_file = $this->view_path . $actionTemplate . DIRECTORY_SEPARATOR . $this->getAction();
|
||||
$view_file = $this->view_path . $actionTemplate . DIRECTORY_SEPARATOR . $this->getService()->getAction();
|
||||
} else {
|
||||
$view_file = $this->view_path . $this->getAction();
|
||||
$view_file = $this->view_path . $this->getService()->getAction();
|
||||
}
|
||||
$result = view($view_file, ['viewDatas' => $this->getViewDatas()]);
|
||||
break;
|
||||
|
||||
@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Controllers\Admin\Equipment;
|
||||
|
||||
use App\Helpers\Equipment\ServerPartHelper;
|
||||
|
||||
use App\Services\Equipment\ServerPartService;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
@ -27,19 +25,4 @@ class ServerPartController extends EquipmentController
|
||||
return $this->_service;
|
||||
}
|
||||
//Index,FieldForm관련
|
||||
public function getFormOption(string $field, array $options = []): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'part_uid':
|
||||
$options = $this->getService()->getFormOption($this->request->getVar('type'));
|
||||
break;
|
||||
default:
|
||||
$options = parent::getFormOption($field, $options);
|
||||
break;
|
||||
}
|
||||
if (!is_array($options)) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 {$field}의 options 값이 array가 아닙니다.\n" . var_export($options, true));
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,16 +39,16 @@ class Home extends AdminController
|
||||
}
|
||||
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
{
|
||||
switch ($this->getAction()) {
|
||||
switch ($this->getService()->getAction()) {
|
||||
case 'index':
|
||||
$this->service = $this->getService();
|
||||
$this->control = $this->getService()->getControlDatas();
|
||||
$this->getService()->getHelper()->setViewDatas($this->getViewDatas());
|
||||
$actionTemplate = $this->request->getVar('ActionTemplate') ?? $actionTemplate;
|
||||
if ($actionTemplate) {
|
||||
$view_file = $this->view_path . $actionTemplate . DIRECTORY_SEPARATOR . $this->getAction();
|
||||
$view_file = $this->view_path . $actionTemplate . DIRECTORY_SEPARATOR . $this->getService()->getAction();
|
||||
} else {
|
||||
$view_file = $this->view_path . $this->getAction();
|
||||
$view_file = $this->view_path . $this->getService()->getAction();
|
||||
}
|
||||
$result = view($view_file, ['viewDatas' => $this->getViewDatas()]);
|
||||
break;
|
||||
@ -62,10 +62,10 @@ class Home extends AdminController
|
||||
//Index,FieldForm관련
|
||||
public function index(): RedirectResponse|string
|
||||
{
|
||||
$this->setAction(__FUNCTION__);
|
||||
$this->setFormFields();
|
||||
$this->setFormFilters();
|
||||
$this->setFormRules();
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
$this->getService()->setFormFields();
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormOptions();
|
||||
//Total 서버 현황
|
||||
$this->totalCounts = $this->getService()->getTotalCountsByType();
|
||||
//interval을 기준으로 최근 신규 서비스정보 가져오기
|
||||
|
||||
@ -31,7 +31,7 @@ class SearchController extends AdminController
|
||||
}
|
||||
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
{
|
||||
switch ($this->getAction()) {
|
||||
switch ($this->getService()->getAction()) {
|
||||
case 'index':
|
||||
$result = parent::getResultSuccess($message, $this->request->getVar('ActionTemplate') ?? $actionTemplate ?? 'search');
|
||||
break;
|
||||
|
||||
@ -36,7 +36,7 @@ class UserController extends AdminController
|
||||
//Index,FieldForm관련
|
||||
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
{
|
||||
switch ($this->getAction()) {
|
||||
switch ($this->getService()->getAction()) {
|
||||
case 'profile_modify_form':
|
||||
$this->service = $this->getService();
|
||||
$this->control = $this->getService()->getControlDatas();
|
||||
@ -50,7 +50,7 @@ class UserController extends AdminController
|
||||
$result = view($view_file, ['viewDatas' => $this->getViewDatas()]);
|
||||
break;
|
||||
case 'profile_modify':
|
||||
$this->getMyLogService()->save($this->getService()->getClassName(), $this->getAction(), $message, $this->getMyAuth()->getUIDByAuthInfo());
|
||||
$this->getMyLogService()->save($this->getService()->getClassName(), $this->getService()->getAction(), $message, $this->getMyAuth()->getUIDByAuthInfo());
|
||||
$result = $this->view($this->entity->getPK());
|
||||
break;
|
||||
default:
|
||||
@ -76,11 +76,11 @@ class UserController extends AdminController
|
||||
final public function profile_form(mixed $uid): RedirectResponse|string
|
||||
{
|
||||
try {
|
||||
$this->setAction(__FUNCTION__);
|
||||
$this->setFormFields();
|
||||
$this->setFormFilters();
|
||||
$this->setFormRules();
|
||||
$this->setFormOptions();
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
$this->getService()->setFormFields();
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
$this->getService()->setFormOptions();
|
||||
//기본값정의
|
||||
$this->setFormDatas($this->request->getGet());
|
||||
//기존 Entity 가져오기
|
||||
@ -102,10 +102,10 @@ class UserController extends AdminController
|
||||
$db = \Config\Database::connect();
|
||||
$this->_db->transStart();
|
||||
try {
|
||||
$this->setAction(__FUNCTION__);
|
||||
$this->setFormFields();
|
||||
$this->setFormFilters();
|
||||
$this->setFormRules();
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
$this->getService()->setFormFields();
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
//전달값정의
|
||||
$this->setFormDatas($this->request->getPost());
|
||||
$this->doValidations();
|
||||
|
||||
@ -33,7 +33,7 @@ abstract class AuthController extends CommonController
|
||||
}
|
||||
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
{
|
||||
switch ($this->getAction()) {
|
||||
switch ($this->getService()->getAction()) {
|
||||
case 'create': //Login처리
|
||||
$result = redirect()->to($this->getMyAuth()->popPreviousUrl())->with('error', $message);
|
||||
break;
|
||||
@ -55,11 +55,11 @@ abstract class AuthController extends CommonController
|
||||
public function login_form(): RedirectResponse|string
|
||||
{
|
||||
try {
|
||||
$this->setAction(__FUNCTION__);
|
||||
$this->setFormFields();
|
||||
$this->setFormFilters();
|
||||
$this->setFormRules();
|
||||
$this->setFormOptions();
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
$this->getService()->setFormFields();
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
$this->getService()->setFormOptions();
|
||||
//기본값정의
|
||||
$this->setFormDatas($this->request->getGet());
|
||||
$this->login_form_process();
|
||||
@ -77,10 +77,10 @@ abstract class AuthController extends CommonController
|
||||
$db = \Config\Database::connect();
|
||||
$db->transStart();
|
||||
try {
|
||||
$this->setAction(__FUNCTION__);
|
||||
$this->setFormFields();
|
||||
$this->setFormFilters();
|
||||
$this->setFormRules();
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
$this->getService()->setFormFields();
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
//전달값정의
|
||||
$this->setFormDatas($this->request->getPost());
|
||||
$this->doValidations();
|
||||
|
||||
@ -65,89 +65,6 @@ abstract class CommonController extends BaseController
|
||||
return $this->_myLogService;
|
||||
}
|
||||
//Index,FieldForm관련
|
||||
final protected function setAction(string $action): void
|
||||
{
|
||||
$this->getService()->setControlDatas('action', $action);
|
||||
}
|
||||
final protected function getAction(): string
|
||||
{
|
||||
if (!$this->getService()->getControlDatas('action')) {
|
||||
throw new \Exception("action이 정의되지 않았습니다.");
|
||||
}
|
||||
return $this->getService()->getControlDatas('action');
|
||||
}
|
||||
//FormFields정의
|
||||
final protected function getFormFields($fields = []): array
|
||||
{
|
||||
return array_merge($fields, $this->getService()->getControlDatas('actionFields'));
|
||||
}
|
||||
final protected function setFormFields(?array $fields = null): void
|
||||
{
|
||||
switch ($this->getAction()) {
|
||||
case 'index':
|
||||
$actionFields = $this->getService()->getIndexFields();
|
||||
break;
|
||||
case 'view':
|
||||
$actionFields = $this->getService()->getViewFields();
|
||||
break;
|
||||
default:
|
||||
$actionFields = $this->getService()->getFormFields();
|
||||
break;
|
||||
}
|
||||
$this->getService()->setControlDatas('actionFields', is_array($fields) ? $fields : $actionFields);
|
||||
}
|
||||
final protected function getFormFilters($filters = []): array
|
||||
{
|
||||
return array_merge($filters, $this->getService()->getControlDatas('actionFilters'));
|
||||
}
|
||||
final protected function setFormFilters(?array $filters = null): void
|
||||
{
|
||||
switch ($this->getAction()) {
|
||||
case 'index':
|
||||
$actionFilters = $this->getService()->getIndexFilters();
|
||||
break;
|
||||
case 'view':
|
||||
$actionFilters = $this->getService()->getViewFilters();
|
||||
break;
|
||||
default:
|
||||
$actionFilters = $this->getService()->getFormFilters();
|
||||
break;
|
||||
}
|
||||
$this->getService()->setControlDatas('actionFilters', is_array($filters) ? $filters : $actionFilters);
|
||||
}
|
||||
//FormRules정의
|
||||
final protected function getFormRules(array $rules = []): array
|
||||
{
|
||||
foreach ($this->getService()->getControlDatas('field_rules') as $field => $rule) {
|
||||
$rules[$field] = $rule;
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
final protected function setFormRules(): void
|
||||
{
|
||||
$rules = [];
|
||||
foreach ($this->getService()->getControlDatas('actionFields') as $field) {
|
||||
$rules = $this->getFormRule($field, $rules);
|
||||
}
|
||||
$this->getService()->setControlDatas('field_rules', $rules);
|
||||
}
|
||||
//FormOptions정의
|
||||
final protected function getFormOptions(array $options = []): array
|
||||
{
|
||||
foreach ($this->getService()->getControlDatas('field_optons') as $field => $option) {
|
||||
$options[$field] = $option;
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
final protected function setFormOptions(): void
|
||||
{
|
||||
//기존 Filter Options 가져와서 field에 해당하는 option이 없으면 field를 key로 배열추가 후 다시 filter_options 전체 적용
|
||||
$options = [];
|
||||
foreach ($this->getService()->getControlDatas('actionFilters') as $field) {
|
||||
$options[$field] = $this->getFormOption($field, $options);
|
||||
}
|
||||
$this->getService()->setControlDatas('field_optons', $options);
|
||||
}
|
||||
//FormDatas 전달값,Default값
|
||||
final protected function getFormDatas(): array
|
||||
{
|
||||
@ -178,33 +95,6 @@ abstract class CommonController extends BaseController
|
||||
}
|
||||
//공통 필수기능
|
||||
//FieldForm관련용
|
||||
protected function getFormRule(string $field, array $rules = []): array
|
||||
{
|
||||
if (is_array($field)) {
|
||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||
}
|
||||
switch ($field) {
|
||||
default:
|
||||
$rules[$field] = $this->getService()->getFormRule($this->getAction(), $field);
|
||||
break;
|
||||
}
|
||||
if (!is_array($rules)) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 {$field}의 Rules 값이 array가 아닙니다.\n" . var_export($rules, true));
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
protected function getFormOption(string $field, array $options = []): array
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
$options = $this->getService()->getFormOption($field, $options);
|
||||
break;
|
||||
}
|
||||
if (!is_array($options)) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 {$field}의 options 값이 array가 아닙니다.\n" . var_export($options, true));
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
//FormData Field별 전달값 처리
|
||||
protected function setFormData(string $field, array $requestDatas, array $formDatas): array
|
||||
{
|
||||
@ -253,9 +143,9 @@ abstract class CommonController extends BaseController
|
||||
$this->getService()->getHelper()->setViewDatas($this->getViewDatas());
|
||||
$actionTemplate = $this->request->getVar('ActionTemplate') ?? $actionTemplate;
|
||||
if ($actionTemplate) {
|
||||
$view_file = $this->view_path . $actionTemplate . DIRECTORY_SEPARATOR . $this->getAction();
|
||||
$view_file = $this->view_path . $actionTemplate . DIRECTORY_SEPARATOR . $this->getService()->getAction();
|
||||
} else {
|
||||
$view_file = $this->view_path . $this->getAction();
|
||||
$view_file = $this->view_path . $this->getService()->getAction();
|
||||
}
|
||||
$result = view($view_file, ['viewDatas' => $this->getViewDatas()]);
|
||||
break;
|
||||
@ -271,11 +161,11 @@ abstract class CommonController extends BaseController
|
||||
public function create_form(): RedirectResponse|string
|
||||
{
|
||||
try {
|
||||
$this->setAction(__FUNCTION__);
|
||||
$this->setFormFields();
|
||||
$this->setFormFilters();
|
||||
$this->setFormRules();
|
||||
$this->setFormOptions();
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
$this->getService()->setFormFields();
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
$this->getService()->setFormOptions();
|
||||
//기본값정의
|
||||
$this->setFormDatas($this->request->getGet());
|
||||
$this->create_form_process();
|
||||
@ -296,10 +186,10 @@ abstract class CommonController extends BaseController
|
||||
$db = \Config\Database::connect();
|
||||
$db->transStart();
|
||||
try {
|
||||
$this->setAction(__FUNCTION__);
|
||||
$this->setFormFields();
|
||||
$this->setFormFilters();
|
||||
$this->setFormRules();
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
$this->getService()->setFormFields();
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
//전달값정의
|
||||
$this->setFormDatas($this->request->getPost());
|
||||
$this->doValidations();
|
||||
@ -319,11 +209,11 @@ abstract class CommonController extends BaseController
|
||||
public function modify_form(mixed $uid): RedirectResponse|string
|
||||
{
|
||||
try {
|
||||
$this->setAction(__FUNCTION__);
|
||||
$this->setFormFields();
|
||||
$this->setFormFilters();
|
||||
$this->setFormRules();
|
||||
$this->setFormOptions();
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
$this->getService()->setFormFields();
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
$this->getService()->setFormOptions();
|
||||
//기본값정의
|
||||
$this->setFormDatas($this->request->getGet());
|
||||
//기존 Entity 가져오기
|
||||
@ -349,10 +239,10 @@ abstract class CommonController extends BaseController
|
||||
$db = \Config\Database::connect();
|
||||
$db->transStart();
|
||||
try {
|
||||
$this->setAction(__FUNCTION__);
|
||||
$this->setFormFields();
|
||||
$this->setFormFilters();
|
||||
$this->setFormRules();
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
$this->getService()->setFormFields();
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
//전달값정의
|
||||
$this->setFormDatas($this->request->getPost());
|
||||
$this->doValidations();
|
||||
@ -380,9 +270,11 @@ abstract class CommonController extends BaseController
|
||||
$db = \Config\Database::connect();
|
||||
$db->transStart();
|
||||
try {
|
||||
$this->setAction(__FUNCTION__);
|
||||
$this->setFormFields([$field]);
|
||||
$this->setFormRules();
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
$this->getService()->setFormFields([$field]);
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
$this->getService()->setFormOptions();
|
||||
//기본값정의
|
||||
$this->setFormDatas($this->request->getGet());
|
||||
$this->doValidations();
|
||||
@ -431,10 +323,12 @@ abstract class CommonController extends BaseController
|
||||
$db = \Config\Database::connect();
|
||||
$db->transStart();
|
||||
try {
|
||||
$this->setAction(__FUNCTION__);
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
list($selectedFields, $formDatas, $uids) = $this->batchjob_pre_process();
|
||||
$this->setFormFields($selectedFields);
|
||||
$this->setFormRules();
|
||||
$this->getService()->setFormFields($selectedFields);
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
$this->getService()->setFormOptions();
|
||||
//기본값정의
|
||||
$this->setFormDatas($this->request->getPost());
|
||||
$this->doValidations();
|
||||
@ -467,7 +361,7 @@ abstract class CommonController extends BaseController
|
||||
$db = \Config\Database::connect();
|
||||
$db->transStart();
|
||||
try {
|
||||
$this->setAction(__FUNCTION__);
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
//기존 Entity 가져오기
|
||||
$entity = $this->getService()->getEntity($uid);
|
||||
if (!$entity) {
|
||||
@ -501,7 +395,7 @@ abstract class CommonController extends BaseController
|
||||
$db = \Config\Database::connect();
|
||||
$db->transStart();
|
||||
try {
|
||||
$this->setAction(__FUNCTION__);
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
$uids = $this->batchjob_delete_pre_process();
|
||||
$entities = [];
|
||||
foreach ($uids as $uid) {
|
||||
@ -529,11 +423,11 @@ abstract class CommonController extends BaseController
|
||||
public function view(string $uid): RedirectResponse|string
|
||||
{
|
||||
try {
|
||||
$this->setAction(__FUNCTION__);
|
||||
$this->setFormFields();
|
||||
$this->setFormFilters();
|
||||
$this->setFormRules();
|
||||
$this->setFormOptions();
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
$this->getService()->setFormFields();
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
$this->getService()->setFormOptions();
|
||||
//기본값정의
|
||||
$this->setFormDatas($this->request->getGet());
|
||||
//기존 Entity 가져오기
|
||||
@ -614,13 +508,13 @@ abstract class CommonController extends BaseController
|
||||
public function index(): RedirectResponse|string
|
||||
{
|
||||
try {
|
||||
$this->setAction(__FUNCTION__);
|
||||
$this->setFormFields();
|
||||
$this->setFormFilters();
|
||||
$this->setFormRules();
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
$this->getService()->setFormFields();
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
$this->getService()->setFormOptions();
|
||||
//기본값정의
|
||||
$this->setFormDatas($this->request->getGet());
|
||||
$this->setFormOptions();
|
||||
//일괄작업용 Fields정의
|
||||
$this->getService()->setControlDatas('batchjob_fields', $this->getService()->getBatchjobFields());
|
||||
//일괄작업용 버튼정의
|
||||
@ -673,11 +567,11 @@ abstract class CommonController extends BaseController
|
||||
public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse|string
|
||||
{
|
||||
try {
|
||||
$this->setAction(__FUNCTION__);
|
||||
$this->setFormFields();
|
||||
$this->setFormFilters();
|
||||
$this->setFormRules();
|
||||
$this->setFormOptions();
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
$this->getService()->setFormFields();
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
$this->getService()->setFormOptions();
|
||||
//URL처리
|
||||
// $this->uri = $this->request->getUri();
|
||||
switch ($output_type) {
|
||||
|
||||
@ -41,6 +41,13 @@ abstract class CommonService
|
||||
}
|
||||
$this->_control[$key] = $values;
|
||||
}
|
||||
final protected function getModel(): mixed
|
||||
{
|
||||
if (!$this->_model) {
|
||||
throw new \Exception("Model이 정의되지 않았습니다. " . __METHOD__);
|
||||
}
|
||||
return $this->_model;
|
||||
}
|
||||
final protected function addClassName(string $className): void
|
||||
{
|
||||
$this->_classNames[] = $className;
|
||||
@ -49,12 +56,80 @@ abstract class CommonService
|
||||
{
|
||||
return implode($delimeter, $this->_classNames);
|
||||
}
|
||||
final protected function getModel(): mixed
|
||||
final public function setAction(string $action): void
|
||||
{
|
||||
if (!$this->_model) {
|
||||
throw new \Exception("Model이 정의되지 않았습니다. " . __METHOD__);
|
||||
$this->setControlDatas('action', $action);
|
||||
}
|
||||
return $this->_model;
|
||||
final public function getAction(): string
|
||||
{
|
||||
if (!$this->getControlDatas('action')) {
|
||||
throw new \Exception("action이 정의되지 않았습니다.");
|
||||
}
|
||||
return $this->getControlDatas('action');
|
||||
}
|
||||
//FormFields정의
|
||||
final public function setFormFields(?array $fields = null): void
|
||||
{
|
||||
switch ($this->getAction()) {
|
||||
case 'index':
|
||||
$actionFields = $this->getIndexFields();
|
||||
break;
|
||||
case 'view':
|
||||
$actionFields = $this->getViewFields();
|
||||
break;
|
||||
default:
|
||||
$actionFields = $this->getFormFields();
|
||||
break;
|
||||
}
|
||||
$this->setControlDatas('actionFields', is_array($fields) ? $fields : $actionFields);
|
||||
}
|
||||
final public function setFormFilters(?array $filters = null): void
|
||||
{
|
||||
switch ($this->getAction()) {
|
||||
case 'index':
|
||||
$actionFilters = $this->getIndexFilters();
|
||||
break;
|
||||
case 'view':
|
||||
$actionFilters = $this->getViewFilters();
|
||||
break;
|
||||
default:
|
||||
$actionFilters = $this->getFormFilters();
|
||||
break;
|
||||
}
|
||||
$this->setControlDatas('actionFilters', is_array($filters) ? $filters : $actionFilters);
|
||||
}
|
||||
//FormRules정의
|
||||
final public function getFormRules(array $rules = []): array
|
||||
{
|
||||
foreach ($this->getControlDatas('field_rules') as $field => $rule) {
|
||||
$rules[$field] = $rule;
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
final public function setFormRules(): void
|
||||
{
|
||||
$rules = [];
|
||||
foreach ($this->getControlDatas('actionFields') as $field) {
|
||||
$rules[$field] = $this->getFormRule($this->getAction(), $field);
|
||||
}
|
||||
$this->setControlDatas('field_rules', $rules);
|
||||
}
|
||||
//FormOptions정의
|
||||
final protected function getFormOptions(array $options = []): array
|
||||
{
|
||||
foreach ($this->getControlDatas('field_optons') as $field => $option) {
|
||||
$options[$field] = $option;
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
final public function setFormOptions(): void
|
||||
{
|
||||
//기존 Filter Options 가져와서 field에 해당하는 option이 없으면 field를 key로 배열추가 후 다시 filter_options 전체 적용
|
||||
$options = [];
|
||||
foreach ($this->getControlDatas('actionFilters') as $field) {
|
||||
$options[$field] = $this->getFormOption($field, $options);
|
||||
}
|
||||
$this->setControlDatas('field_optons', $options);
|
||||
}
|
||||
//Entity별로 작업처리시
|
||||
protected function getEntity_process(object $entity): mixed
|
||||
|
||||
@ -92,9 +92,9 @@
|
||||
<div><?= $serviceEntity->getCode() ?></div>
|
||||
<div><?= $serviceEntity->getServerEntity()->getCode() ?></div>
|
||||
</td>
|
||||
<td><?= $viewDatas['serviceHelper']->getFieldView('site', $serviceEntity->getSite(), $viewDatas) ?></td>
|
||||
<td><?= $viewDatas['serviceHelper']->getFieldView('location', $serviceEntity->getLocation(), $viewDatas) ?></td>
|
||||
<td><?= $viewDatas['serviceHelper']->getFieldView('type', $serviceEntity->getType(), $viewDatas) ?></td>
|
||||
<td><?= $viewDatas['serviceService']->getHelper()->getFieldView('site', $serviceEntity->getSite(), $viewDatas) ?></td>
|
||||
<td><?= $viewDatas['serviceService']->getHelper()->getFieldView('location', $serviceEntity->getLocation(), $viewDatas) ?></td>
|
||||
<td><?= $viewDatas['serviceService']->getHelper()->getFieldView('type', $serviceEntity->getType(), $viewDatas) ?></td>
|
||||
<td>CPU</td>
|
||||
<td>메모리</td>
|
||||
<td>저장장치</td>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user