servermgrv2 init...

This commit is contained in:
최준흠 2023-07-31 19:36:41 +09:00
parent 3e7c095e84
commit 00805c8b4e
12 changed files with 34 additions and 47 deletions

View File

@ -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)
{

View File

@ -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);
}
}
}

View File

@ -3,7 +3,6 @@
namespace App\Backend;
use App\Models\BoardConfigModel;
use App\Entities\BoardConfigEntity;
class BoardConfigBackend extends BaseBackend
{

View File

@ -3,7 +3,6 @@
namespace App\Backend;
use App\Models\UserModel;
use App\Entities\UserEntity;
class UserBackend extends BaseBackend
{

View File

@ -3,7 +3,6 @@
namespace App\Backend;
use App\Models\UserSNSModel;
use App\Entities\UserSNSEntity;
class UserSNSBackend extends BaseBackend
{

View File

@ -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');

View File

@ -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();
}
}

View File

@ -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(

View File

@ -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) {

View File

@ -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;

View File

@ -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;

View File

@ -5,6 +5,5 @@
<div class="accordion accordion-flush">
<?= $this->include($layout['path'] . '/left_menu/base'); ?>
<?= $this->include($layout['path'] . '/left_menu/board'); ?>
<?= $this->include($layout['path'] . '/left_menu/hpilo'); ?>
</div>
</div>