dbmsv4 init...1

This commit is contained in:
최준흠 2025-12-04 10:43:19 +09:00
parent d94c03b672
commit 747f42c6b0
16 changed files with 332 additions and 19 deletions

View File

@ -16,7 +16,7 @@ $routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes)
$routes->cli('collect', 'Collector::execute');
});
$routes->group('', ['namespace' => 'App\Controllers'], function ($routes) {
$routes->get('/', 'Home::welcome');
$routes->get('/', 'Home::index');
$routes->group('auth', ['namespace' => 'App\Controllers\Auth'], function ($routes) {
$routes->get('login', 'LocalController::login_form');
$routes->post('login', 'LocalController::login');
@ -26,7 +26,7 @@ $routes->group('', ['namespace' => 'App\Controllers'], function ($routes) {
});
//Admin 관련
$routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'authFilter:manager'], function ($routes) {
$routes->get('/', 'Home::welcome');
$routes->get('/', 'Home::index');
$routes->group('user', function ($routes) {
$routes->get('/', 'UserController::index');
$routes->get('create', 'UserController::create_form');
@ -244,6 +244,19 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->post('batchjob_delete', 'CSController::batchjob_delete');
$routes->get('download/(:alpha)', 'CSController::download/$1');
});
$routes->group('chassis', function ($routes) {
$routes->get('/', 'CHASSISController::index');
$routes->get('create', 'CHASSISController::create_form');
$routes->post('create', 'CHASSISController::create');
$routes->get('modify/(:num)', 'CHASSISController::modify_form/$1');
$routes->post('modify/(:num)', 'CHASSISController::modify/$1');
$routes->get('view/(:num)', 'CHASSISController::view/$1');
$routes->get('delete/(:num)', 'CHASSISController::delete/$1');
$routes->get('toggle/(:num)/(:any)', 'CHASSISController::toggle/$1/$2');
$routes->post('batchjob', 'CHASSISController::batchjob');
$routes->post('batchjob_delete', 'CHASSISController::batchjob_delete');
$routes->get('download/(:alpha)', 'CHASSISController::download/$1');
});
$routes->group('cpu', function ($routes) {
$routes->get('/', 'CPUController::index');
$routes->get('create', 'CPUController::create_form');

View File

@ -14,6 +14,7 @@ use App\Services\Equipment\LineService;
use App\Services\Equipment\ServerPartService;
use App\Services\Equipment\ServerService;
use App\Services\MylogService;
use App\Services\Part\CHASSISService;
use App\Services\Part\CPUService;
use App\Services\Part\CSService;
use App\Services\Part\DISKService;
@ -194,6 +195,15 @@ class Services extends BaseService
);
}
//Part
public static function part_chassisservice($getShared = true): CHASSISService
{
if ($getShared) {
return static::getSharedInstance(__FUNCTION__);
}
return new CHASSISService(
new \App\Models\Part\CHASSISModel(),
);
}
public static function part_cpuservice($getShared = true): CPUService
{
if ($getShared) {

View File

@ -9,22 +9,30 @@ use Psr\Log\LoggerInterface;
class Home extends AbstractWebController
{
private $_layout = 'admin';
protected $layouts = [];
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
if ($this->service === null) {
$this->service = service('customer_serviceservice');
}
$this->addActionPaths('home');
$this->addActionPaths($this->_layout);
$this->layouts = LAYOUTS[$this->_layout];
}
protected function action_init_process(string $action, array $formDatas = []): void
{
// $this->service->action_init_process($action, $entity);
$this->service->action_init_process($action, $formDatas);
parent::action_init_process($action, $formDatas);
$this->addViewDatas('layout', LAYOUTS['admin']);
$this->addViewDatas('layout', $this->layouts);
$this->addViewDatas('helper', $this->service->getHelper());
$this->addViewDatas('formFields', $this->service->getFormService()->getFormFields());
$this->addViewDatas('formRules', $this->service->getFormService()->getFormRules());
$this->addViewDatas('formFilters', $this->service->getFormService()->getFormFilters());
$this->addViewDatas('formOptions', $this->service->getFormService()->getFormOptions());
}
//Index,FieldForm관련
public function welcome(): string
public function index(): string
{
$action = __FUNCTION__;
$this->action_init_process($action);
@ -45,6 +53,6 @@ class Home extends AbstractWebController
}
$this->addViewDatas('unPaidTotalCount', $unPaidTotalCount);
$this->addViewDatas('unPaidTotalAmount', $unPaidTotalAmount);
return $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate'));
return $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate') ?? "welcome");
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Controllers\Admin\Part;
use App\Entities\Part\CHASSISEntity;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class CHASSISController extends PartController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
if ($this->service === null) {
$this->service = service('part_chassisservice');
}
$this->addActionPaths('chassis');
}
//기본 함수 작업
//Custom 추가 함수
}

View File

@ -0,0 +1,20 @@
<?php
namespace App\DTOs\Part;
use App\DTOs\CommonDTO;
class CHASSISDTO extends CommonDTO
{
public ?int $uid = null;
public ?string $title = null;
public ?int $price = null;
public ?string $used = null;
public ?int $stock = null;
public ?string $status = null;
public function __construct(array $datas = [])
{
parent::__construct($datas);
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Entities\Part;
use App\Models\Part\CHASSISModel;
class CHASSISEntity extends PartEntity
{
const PK = CHASSISModel::PK;
const TITLE = CHASSISModel::TITLE;
//기본기능
public function getStock(): int
{
return $this->attributes['stock'];
}
public function getUsed(): int
{
return $this->attributes['used'];
}
public function getAvailable(): int
{
return $this->getStock() - $this->getUsed();
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace App\Forms\Part;
class CHASSISForm extends PartForm
{
public function __construct()
{
parent::__construct();
}
public function getFormRule(string $action, string $field): string
{
switch ($field) {
case "used":
$rule = "required|numeric";
break;
default:
$rule = parent::getFormRule($action, $field);
break;
}
return $rule;
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace App\Helpers\Part;
class CHASSISHelper extends PartHelper
{
public function __construct()
{
parent::__construct();
}
}

View File

@ -0,0 +1,18 @@
<?php
return [
'title' => "서버샷시정보",
'label' => [
'title' => "모델명",
'price' => "기본가",
'used' => "사용갯수",
'stock' => "재고",
'status' => "상태",
'updated_at' => "수정일",
'created_at' => "작성일",
'deleted_at' => "삭제일",
],
"STATUS" => [
STATUS['AVAILABLE'] => "사용가능",
STATUS['FORBIDDEN'] => "사용불가",
],
];

View File

@ -0,0 +1,29 @@
<?php
namespace App\Models\Part;
use App\Entities\Part\CHASSISEntity;
class CHASSISModel extends PartModel
{
const TABLE = "chassisinfo";
const PK = "uid";
const TITLE = "title";
protected $table = self::TABLE;
protected $primaryKey = self::PK;
// protected $useAutoIncrement = false;
protected $returnType = CHASSISEntity::class;
protected $allowedFields = [
"uid",
"title",
"price",
"used",
"stock",
"status",
"updated_at"
];
public function __construct()
{
parent::__construct();
}
}

View File

@ -2,14 +2,12 @@
namespace App\Services;
use RuntimeException;
use App\Models\MylogModel;
use App\Libraries\PipelineStepInterface;
use App\Libraries\OperationContext;
use App\Helpers\MylogHelper;
use App\Forms\MylogForm;
use App\Entities\MylogEntity;
use App\Entities\CommonEntity;
use App\DTOs\MylogDTO;
class MylogService extends CommonService implements PipelineStepInterface
@ -50,7 +48,7 @@ class MylogService extends CommonService implements PipelineStepInterface
public function action_init_process(string $action, array $formDatas = []): void
{
$fields = ['title', 'content'];
$filters = [];
$filters = ['user_uid'];
$indexFilter = $filters;
$batchjobFilters = $filters;
switch ($action) {

View File

@ -0,0 +1,140 @@
<?php
namespace App\Services\Part;
use App\Models\Part\CHASSISModel;
use App\Helpers\Part\CHASSISHelper;
use App\Forms\Part\CHASSISForm;
use App\Entities\Part\CHASSISEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\DTOs\Part\CHASSISDTO;
class CHASSISService extends PartType1Service
{
private $_form = null;
private $_helper = null;
public function __construct(CHASSISModel $model)
{
parent::__construct($model);
$this->addClassPaths('CHASSIS');
}
protected function getDTOClass(): string
{
return CHASSISDTO::class;
}
public function createDTO(array $formDatas): CHASSISDTO
{
return new CHASSISDTO($formDatas);
}
public function getEntityClass(): string
{
return CHASSISEntity::class;
}
public function getFormService(): CHASSISForm
{
if ($this->_form === null) {
$this->_form = new CHASSISForm();
$this->_form->setAttributes([
'pk_field' => $this->model->getPKField(),
'title_field' => $this->model->getTitleField(),
'table' => $this->model->getTable(),
'useAutoIncrement' => $this->model->useAutoIncrement(),
'class_path' => $this->getClassPaths(false)
]);
}
return $this->_form;
}
public function getHelper(): CHASSISHelper
{
if ($this->_helper === null) {
$this->_helper = new CHASSISHelper();
$this->_helper->setAttributes([
'pk_field' => $this->model->getPKField(),
'title_field' => $this->model->getTitleField(),
'table' => $this->model->getTable(),
'useAutoIncrement' => $this->model->useAutoIncrement(),
'class_path' => $this->getClassPaths(false)
]);
}
return $this->_helper;
}
public function action_init_process(string $action, array $formDatas = []): void
{
$fields = [
"title",
"price",
"stock",
];
$filters = [
"status",
];
$indexFilter = $filters;
$batchjobFilters = ['status'];
switch ($action) {
case 'create':
case 'create_form':
case 'modify':
case 'modify_form':
$fields = [...$fields, 'status'];
break;
case 'view':
$fields = [...$fields, 'status', 'created_at'];
break;
case 'index':
case 'download':
$fields = [...$fields, 'status', 'created_at'];
break;
}
$this->getFormService()->setFormFields($fields);
$this->getFormService()->setFormRules($action, $fields);
$this->getFormService()->setFormFilters($filters);
$this->getFormService()->setFormOptions($action, $filters, $formDatas);
$this->getFormService()->setIndexFilters($indexFilter);
$this->getFormService()->setBatchjobFilters($batchjobFilters);
}
//기본 기능부분
protected function getEntity_process(mixed $entity): CHASSISEntity
{
return $entity;
}
protected function create_process(array $formDatas): CHASSISEntity
{
return parent::create_process($formDatas);
}
protected function modify_process($entity, array $formDatas): CHASSISEntity
{
return parent::modify_process($entity, $formDatas);
}
//List 검색용
//FormFilter 조건절 처리
//검색어조건절처리
//OrderBy 처리
public function setOrderBy(mixed $field = null, mixed $value = null): void
{
$this->model->orderBy('title ASC');
parent::setOrderBy($field, $value);
}
//서버파트관련 작업
//파트정보가져오기
public function getPartEntityByServerPart(ServerPartEntity $serverPartEntity): CHASSISEntity
{
//IP정보에서 해당하는 IP가 있으면 가져와서 사용중인지 체크 후 수정
$entity = $this->getEntity($serverPartEntity->getPartUID());
if (!$entity instanceof CHASSISEntity) {
throw new \Exception(message: "{$serverPartEntity->getPartUID()}에 해당하는 CHASSISEntity정보를 찾을수없습니다.");
}
return $entity;
}
public function attachToServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): CHASSISEntity
{
/** @var CHASSISEntity $entity IDE에 entity type알려주기*/
$entity = parent::attachToServerPart($serverPartEntity, $formDatas);
return $entity;
}
public function detachFromServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): CHASSISEntity
{
/** @var CHASSISEntity $entity IDE에 entity type알려주기*/
$entity = parent::detachFromServerPart($serverPartEntity, $formDatas);
return $entity;
}
}

View File

@ -2,13 +2,11 @@
namespace App\Services\Part;
use RuntimeException;
use App\Models\Part\CPUModel;
use App\Helpers\Part\CPUHelper;
use App\Forms\Part\CPUForm;
use App\Entities\Part\CPUEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\CommonEntity;
use App\DTOs\Part\CPUDTO;
class CPUService extends PartType1Service

View File

@ -24,13 +24,9 @@
<?php $viewDatas['entity'] = $entity ?>
<tr class="text-center">
<td><?= SITES[$entity->getSite()] ?></td>
<td nowrap><?= $viewDatas['service']->getHelper()->getFieldView('clientinfo_uid', $entity->getClientInfoUID(), $viewDatas) ?></td>
<td class="text-start"><?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", [
'serverinfo_uid' => $entity->getServerInfoUID(),
'types' => SERVERPART['SERVICE_PARTTYPES'],
'template' => 'partlist_service'
]) ?></td>
<td nowrap><?= $viewDatas['service']->getHelper()->getFieldView('user_uid', $entity->getUserUID(), $viewDatas) ?></td>
<td nowrap><?= $viewDatas['helper']->getFieldView('clientinfo_uid', $entity->getClientInfoUID(), $viewDatas) ?></td>
<td class="text-start"><?= $viewDatas['helper']->getFieldView('serverinfo_uid', $entity->getServerInfoUID(), $viewDatas) ?></td>
<td nowrap><?= $viewDatas['helper']->getFieldView('user_uid', $entity->getUserUID(), $viewDatas) ?></td>
</tr>
<?php endforeach ?>
</tbody>

View File

@ -14,6 +14,9 @@
<div class="accordion-item">
<a href="/admin/part/cs"><?= ICONS['SERVICE_ITEM_DEFENCE'] ?>CS정보</a>
</div>
<div class="accordion-item">
<a href="/admin/part/chassis"><?= ICONS['SETUP'] ?>서버샷시정보</a>
</div>
<div class="accordion-item">
<a href="/admin/part/cpu"><?= ICONS['SERVER_ITEM_CPU'] ?>CPU정보</a>
</div>