From 00805c8b4e57c6215de8ed8a657678997b0682a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Mon, 31 Jul 2023 19:36:41 +0900 Subject: [PATCH] servermgrv2 init... --- app/Backend/BaseBackend.php | 19 ++++++++++++++++--- app/Backend/BoardBackend.php | 8 ++++---- app/Backend/BoardConfigBackend.php | 1 - app/Backend/UserBackend.php | 1 - app/Backend/UserSNSBackend.php | 1 - app/Config/Routes.php | 15 --------------- app/Config/Services.php | 7 ------- app/Controllers/BaseController.php | 8 ++++---- app/Models/BaseModel.php | 14 +++++++------- app/Models/BoardConfigModel.php | 4 ++-- app/Models/UserModel.php | 2 +- app/Views/layouts/admin/left_menu.php | 1 - 12 files changed, 34 insertions(+), 47 deletions(-) diff --git a/app/Backend/BaseBackend.php b/app/Backend/BaseBackend.php index 3ae6eb8..498c041 100644 --- a/app/Backend/BaseBackend.php +++ b/app/Backend/BaseBackend.php @@ -2,9 +2,8 @@ namespace App\Backend; -use App\Models\UserModel; use App\Entities\BaseEntity; -use CodeIgniter\HTTP\Files\UploadedFile; +use App\Models\UserModel; abstract class BaseBackend { @@ -25,7 +24,7 @@ abstract class BaseBackend } //User모델 - final protected function getUserModel(): UserModel + final public function getUserModel(): UserModel { return is_null($this->_userModel) ? new UserModel() : $this->_userModel; } @@ -35,6 +34,20 @@ abstract class BaseBackend return $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]); } + //transaction관련 + final public function transStart($isTest = false) + { + $this->_model->transStart($isTest); + } + final public function transComplete() + { + $this->_model->transComplete(); + } + final public function transRollback() + { + $this->_model->transRollback(); + } + //초기화 final public function getFields(string $action) { diff --git a/app/Backend/BoardBackend.php b/app/Backend/BoardBackend.php index 3cb7f2a..0cc30ba 100644 --- a/app/Backend/BoardBackend.php +++ b/app/Backend/BoardBackend.php @@ -2,9 +2,8 @@ namespace App\Backend; -use App\Models\BoardModel; -use App\Entities\BoardEntity; use App\Models\BoardConfigModel; +use App\Models\BoardModel; class BoardBackend extends BaseHierarchyBackend { @@ -37,11 +36,12 @@ class BoardBackend extends BaseHierarchyBackend } return $options; } + //View관련 public function view($entity) { - // view_cnt에 추가하기위함 + //view_cnt에 추가하기위함 $this->_model->increaseViewCount($entity->getPrimaryKey()); return parent::view($entity); - } + } } diff --git a/app/Backend/BoardConfigBackend.php b/app/Backend/BoardConfigBackend.php index 6453eb0..70428b6 100644 --- a/app/Backend/BoardConfigBackend.php +++ b/app/Backend/BoardConfigBackend.php @@ -3,7 +3,6 @@ namespace App\Backend; use App\Models\BoardConfigModel; -use App\Entities\BoardConfigEntity; class BoardConfigBackend extends BaseBackend { diff --git a/app/Backend/UserBackend.php b/app/Backend/UserBackend.php index 073e2e8..3618566 100644 --- a/app/Backend/UserBackend.php +++ b/app/Backend/UserBackend.php @@ -3,7 +3,6 @@ namespace App\Backend; use App\Models\UserModel; -use App\Entities\UserEntity; class UserBackend extends BaseBackend { diff --git a/app/Backend/UserSNSBackend.php b/app/Backend/UserSNSBackend.php index b3e1cc5..cb8da34 100644 --- a/app/Backend/UserSNSBackend.php +++ b/app/Backend/UserSNSBackend.php @@ -3,7 +3,6 @@ namespace App\Backend; use App\Models\UserSNSModel; -use App\Entities\UserSNSEntity; class UserSNSBackend extends BaseBackend { diff --git a/app/Config/Routes.php b/app/Config/Routes.php index aedba0a..0a684af 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -91,21 +91,6 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au $routes->post('batchjob', 'BoardController::batchjob'); $routes->get('download/(:any)/(:num)', 'BoardController::download/$1/$2'); }); - $routes->group('hpilo', static function ($routes) { - $routes->get('', 'HPILOController::index'); - $routes->get('excel', 'HPILOController::excel'); - $routes->get('insert', 'HPILOController::insert_form'); - $routes->post('insert', 'HPILOController::insert'); - $routes->get('update/(:num)', 'HPILOController::update_form/$1'); - $routes->post('update/(:num)', 'HPILOController::update/$1'); - $routes->get('view/(:num)', 'HPILOController::view/$1'); - $routes->get('delete/(:num)', 'HPILOController::delete/$1', ['filter' => 'authFilter:master']); - $routes->get('toggle/(:num)/(:hash)', 'HPILOController::toggle/$1/$2'); - $routes->post('batchjob', 'HPILOController::batchjob'); - $routes->get('console/(:num)', 'HPILOController::console/$1'); - $routes->get('reset/(:num)/(:alpha)', 'HPILOController::reset/$1/$2'); - $routes->get('reload/(:num)', 'HPILOController::reload/$1'); - }); }); $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($routes) { $routes->get('/', 'Home::index'); diff --git a/app/Config/Services.php b/app/Config/Services.php index dcaf32e..9c71556 100644 --- a/app/Config/Services.php +++ b/app/Config/Services.php @@ -57,11 +57,4 @@ class Services extends BaseService } return new \App\Backend\BoardConfigBackend(); } - public static function hpilo($getShared = true) - { - if ($getShared) { - return static::getSharedInstance('hpilo'); - } - return new \App\Backend\HPILOBackend(); - } } diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index ceb7d21..7464dda 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -311,8 +311,8 @@ abstract class BaseController extends Controller $uids = $this->request->getVar('batchjob_uids') ?: throw new \Exception($this->_viewDatas['title'] . '에서 변경할 항목(uid)이 선택되지 않았습니다.'); $cnt = 1; - //Transaction manully 시작 - $this->_backend->transBegin(); + //Transaction 시작 + $this->_backend->transStart(); foreach ($uids as $uid) { try { $entity = $this->_viewDatas['entity'] = $this->_backend->getEntity($uid); @@ -324,7 +324,7 @@ abstract class BaseController extends Controller } $cnt++; } - //Transaction manully Commit + //Transaction Commit $this->_backend->transCommit(); $msg = sprintf( "%s에서 총:%s개의 %s 완료하였습니다.", @@ -333,7 +333,7 @@ abstract class BaseController extends Controller __FUNCTION__ ); } catch (\Exception $e) { - //Transaction manully Rollback + //Transaction Rollback $this->_backend->transRollback(); log_message('error', sprintf("---------batchjob 작업결과--------\n%s\n", implode("\n", $batchjobs))); return sprintf( diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index 4c90b1b..2ad10bc 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -2,8 +2,8 @@ namespace App\Models; -use CodeIgniter\Model; use App\Entities\BaseEntity; +use CodeIgniter\Model; abstract class BaseModel extends Model { @@ -153,7 +153,7 @@ abstract class BaseModel extends Model } break; case "user_uid": //입력데이터로 있을시 추가, 없을시는 입력의 경우에만 자동으로 추가 - if (array_key_exists($field, $formDatas) && $formDatas[$field]) { + if (array_key_exists($field, $formDatas) && !is_null($formDatas[$field])) { $entity->$field = $formDatas[$field]; } elseif ($action == 'create' && $this->_session->get(SESSION_NAMES["ISLOGIN"])) { $auth = $this->_session->get(SESSION_NAMES["AUTH"]); @@ -163,17 +163,17 @@ abstract class BaseModel extends Model case "passwd": // echo var_export($this->validationRules, true); // exit; - if (array_key_exists($field, $formDatas) && $formDatas[$field]) { + if (array_key_exists($field, $formDatas) && !is_null($formDatas[$field])) { $entity->$field = password_hash($formDatas[$field], PASSWORD_DEFAULT); } break; case "content": - if (array_key_exists($field, $formDatas) && $formDatas[$field]) { + if (array_key_exists($field, $formDatas) && !is_null($formDatas[$field])) { $entity->$field = htmlentities($formDatas[$field]); } break; default: - if (array_key_exists($field, $formDatas) && $formDatas[$field]) { + if (array_key_exists($field, $formDatas) && !is_null($formDatas[$field])) { $entity->$field = $formDatas[$field]; } break; @@ -181,7 +181,7 @@ abstract class BaseModel extends Model return $entity; } - private function save_process($entity) + final protected function save_process($entity) { // echo var_export($entity, true); // exit; @@ -189,7 +189,7 @@ abstract class BaseModel extends Model if (!$this->save($entity)) { log_message("error", __FUNCTION__ . "에서 호출:" . $this->getLastQuery()); log_message("error", implode("\n", $this->errors())); - throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . var_export($this->errors(), true)); + throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . $this->getLastQuery() . "\n" . var_export($this->errors(), true)); } //primaryKey가 자동입력이면 if ($this->useAutoIncrement) { diff --git a/app/Models/BoardConfigModel.php b/app/Models/BoardConfigModel.php index 35f824a..8793943 100644 --- a/app/Models/BoardConfigModel.php +++ b/app/Models/BoardConfigModel.php @@ -89,13 +89,13 @@ class BoardConfigModel extends BaseModel case "isupload": case "isdownload": case "isaccess": - if (array_key_exists($field, $formDatas) && $formDatas[$field]) { + if (array_key_exists($field, $formDatas) && !is_null($formDatas[$field])) { $entity->$field = is_array($formDatas[$field]) ? implode("|", $formDatas[$field]) : $formDatas[$field]; } break; case "head": case "tail": - if (array_key_exists($field, $formDatas) && $formDatas[$field]) { + if (array_key_exists($field, $formDatas) && !is_null($formDatas[$field])) { $entity->$field = htmlentities($formDatas[$field]); } break; diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php index 3771568..3f4b76e 100644 --- a/app/Models/UserModel.php +++ b/app/Models/UserModel.php @@ -81,7 +81,7 @@ class UserModel extends BaseModel { switch ($field) { case "role": - if (array_key_exists($field, $formDatas) && $formDatas[$field]) { + if (array_key_exists($field, $formDatas) && !is_null($formDatas[$field])) { $entity->$field = is_array($formDatas[$field]) ? implode("|", $formDatas[$field]) : $formDatas[$field]; } break; diff --git a/app/Views/layouts/admin/left_menu.php b/app/Views/layouts/admin/left_menu.php index 8b2d095..03a3677 100644 --- a/app/Views/layouts/admin/left_menu.php +++ b/app/Views/layouts/admin/left_menu.php @@ -5,6 +5,5 @@
include($layout['path'] . '/left_menu/base'); ?> include($layout['path'] . '/left_menu/board'); ?> - include($layout['path'] . '/left_menu/hpilo'); ?>
\ No newline at end of file