dbmsv2 init...1

This commit is contained in:
choi.jh 2025-08-22 15:58:40 +09:00
parent 0dcd8a0740
commit a4aad8e45e
8 changed files with 45 additions and 44 deletions

View File

@ -365,18 +365,13 @@ define('DEFAULT_LIST_PERPAGE', $_ENV['LIST_PERPAGE'] ?? $_SERVER['LIST_PERPAGE']
//신규서비스 Interval
define('SERVICE_NEW_INTERVAL', $_ENV['SERVICE_NEW_INTERVAL'] ?? $_SERVER['SERVICE_NEW_INTERVAL'] ?? 7);
//사이트 접두사 정의
define(
'SITE_PREFIX',
[
'prime' => $_ENV['PREFIX_Client'] ?? $_SERVER['PREFIX_Client'] ?? 'PIC',
'itsolution' => $_ENV['PREFIX_Client'] ?? $_SERVER['PREFIX_Client'] ?? 'IIC',
'gdidc' => $_ENV['PREFIX_Client'] ?? $_SERVER['PREFIX_Client'] ?? 'GIC',
],
);
//서머 쳩렾 아이템 정의
//서버아이템 정의
define("SERVER_LINK_ITEMS", [
'CPU' => "CPU정보",
'RAM' => "RAM정보",
'DISK' => "DISK정보",
'OS' => "OS정보",
'SOFTWARE' => "기타SW정보",
'IP' => "IP정보",
'CS' => "CS정보",
'PART' => "부품정보",
]);

View File

@ -42,6 +42,15 @@ class ClientController extends CustomerController
// 관리자 UID는 현재 인증된 사용자로 설정
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
parent::create_process($formDatas);
// 생성 후, Client 코드값 재정의
$prefix = env("Client.Prefix.site.{$formDatas['site']}", false);
if (!$prefix) {
throw new \Exception(__METHOD__ . "에서 code의 prefix가 정의되지 않았습니다.");
}
$this->getService()->modify(
$this->entity,
['code' => $prefix . $this->entity->getPK()]
);
}
//수정관련
protected function modify_process(mixed $entity, array $formDatas): void

View File

@ -8,7 +8,7 @@ use Psr\Log\LoggerInterface;
use App\Helpers\Equipment\LineHelper;
use App\Services\Equipment\LineService;
use App\Services\Equipment\IpService;
use App\Services\Equipment\IPService;
class LineController extends EquipmentController
{
@ -36,7 +36,7 @@ class LineController extends EquipmentController
}
return $this->_helper;
}
final public function getIpService(): IpService
final public function getIPService(): IpService
{
if (!$this->_ipService) {
$this->_ipService = new IpService();
@ -56,7 +56,7 @@ class LineController extends EquipmentController
parent::create_process($formDatas);
//Prefixed IP to array 자동 등록
foreach ($this->getHelper()->cidrToIpRange($formDatas['bandwith']) as $ip) {
$this->getIpService()->createByLineInfo($this->entity, $ip);
$this->getIPService()->createByLineInfo($this->entity, $ip);
}
}
}

View File

@ -54,7 +54,12 @@ class ServerController extends EquipmentController
//생성
protected function create_form_process(): void
{
$this->setDefaultValue('code', $this->getService()->getLastestCode());
$format = env("Server.Prefix.code.format", false);
if (!$format) {
throw new \Exception(__METHOD__ . "에서 code의 format이 정의되지 않았습니다.");
}
$default = (int)env("Server.Default.code", 0);
$this->setDefaultValue('code', $this->getService()->getLastestCode($format, $default));
parent::create_form_process();
}
}

File diff suppressed because one or more lines are too long

View File

@ -66,12 +66,4 @@ class ClientModel extends CustomerModel
}
return $rule;
}
//입력후 코드처리
protected function create_process(array $formDatas): ClientEntity
{
$entity = parent::create_process($formDatas);
// 생성 후, 추가 작업이 필요할 경우 여기에 작성
$formDatas = ['code' => SITE_PREFIX[$formDatas['site']] . $entity->getPK()];
return $this->modify($entity, $formDatas);
}
}

View File

@ -59,10 +59,10 @@ class ServerModel extends EquipmentModel
}
//create용 장비코드 마지막번호 가져오기
final public function getLastestCode(int $default = 1): string
final public function getLastestCode(string $format, int $default): string
{
$entity = $this->selectMax($this->primaryKey)->first();
$pk = (int) ($entity->getPK() ?? $default); // 정수로 강제 변환
return sprintf("%s-M%03d", date('ymd'), $pk);
return sprintf($format, date('ymd'), $pk + 1);
}
}

View File

@ -140,9 +140,9 @@ class ServerService extends EquipmentService
return $options;
}
//create용 장비코드 마지막번호 가져오기
final public function getLastestCode(int $default = 1): string
final public function getLastestCode(string $format, int $default): string
{
return $this->getModel()->getLastestCode($default);
return $this->getModel()->getLastestCode($format, $default);
}
//List 검색용
//OrderBy 처리