dbmsv4 init...3

This commit is contained in:
최준흠 2025-12-24 14:00:22 +09:00
parent be85092073
commit 397c9b4f78
18 changed files with 205 additions and 113 deletions

View File

@ -435,40 +435,9 @@ define(
define("SERVICE", [ define("SERVICE", [
"NEW_INTERVAL" => $_ENV['SERVICE_NEW_INTERVAL'] ?? $_SERVER['SERVICE_NEW_INTERVAL'] ?? 7, "NEW_INTERVAL" => $_ENV['SERVICE_NEW_INTERVAL'] ?? $_SERVER['SERVICE_NEW_INTERVAL'] ?? 7,
]); ]);
define("SERVER", [ define("SERVER", []);
"TYPES" => [ define("IP", [
"NORMAL" => 'normal', "DEFAULT_PRICE" => 50000
"DEFENCE" => 'defence',
"DEDICATED" => 'dedicated',
"VPN" => 'vpn',
"EVENT" => 'event',
"TEST" => 'test',
"ALTERNATIVE" => 'alternative',
"INHOUSE" => 'inhouse',
"COLOCATION" => 'colocation',
],
"OS" => [
"CENTOS7" => "CentOS7",
"CENTOS8" => "CentOS8",
"CENTOS9" => "CentOS9",
"CENTOS10" => "CentOS10",
"UBUNTU20.04" => "Ubuntu20.04",
"UBUNTU22.04" => "Ubuntu22.04",
"UBUNTU23.04" => "Ubuntu23.04",
"UBUNTU24.04" => "Ubuntu24.04",
"UBUNTU25.04" => "Ubuntu25.04",
"DEBIAN10" => "Debian10",
"DEBIAN11" => "Debian11",
"DEBIAN12" => "Debian12",
"WINDOWS10" => "Windows10",
"WINDOWS11" => "Windows11",
"WINDOWS2008R2" => "Windows2008R2",
"WINDOWS2012R2" => "Windows2012R2",
"WINDOWS2016R2" => "Windows2016R2",
"WINDOWS2019R2" => "Windows2019R2",
"WINDOWS2022R2" => "Windows2022R2",
"WINDOWS2024R2" => "Windows2024R2",
],
]); ]);
//서버파트 관련 //서버파트 관련
define("SERVERPART", [ define("SERVERPART", [

View File

@ -8,6 +8,8 @@ class LineDTO extends CommonDTO
{ {
public ?int $uid = null; public ?int $uid = null;
public string $title = ''; public string $title = '';
public string $type = '';
public string $protocol = '';
public string $bandwith = ''; public string $bandwith = '';
public string $start_at = ''; public string $start_at = '';
public string $end_at = ''; public string $end_at = '';

View File

@ -10,6 +10,7 @@ class IPDTO extends PartDTO
public ?int $serviceinfo_uid = null; public ?int $serviceinfo_uid = null;
public ?int $serverinfo_uid = null; public ?int $serverinfo_uid = null;
public string $ip = ''; public string $ip = '';
public string $content = '';
public function __construct(array $datas = []) public function __construct(array $datas = [])
{ {
parent::__construct($datas); parent::__construct($datas);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -9,6 +9,8 @@ class LineEntity extends EquipmentEntity
const PK = LineModel::PK; const PK = LineModel::PK;
protected $attributes = [ protected $attributes = [
'title' => '', 'title' => '',
'type' => '',
'protocol' => '',
'bandwith' => '', 'bandwith' => '',
'start_at' => 0, 'start_at' => 0,
'end_at' => 0, 'end_at' => 0,
@ -20,7 +22,14 @@ class LineEntity extends EquipmentEntity
parent::__construct($data); parent::__construct($data);
} }
const TITLE = LineModel::TITLE; const TITLE = LineModel::TITLE;
public function getType(): string
{
return $this->attributes['type'] ?? '';
}
public function getProtocol(): string
{
return $this->attributes['protocol'] ?? '';
}
public function getBandwith(): string public function getBandwith(): string
{ {
return $this->attributes['bandwith'] ?? ''; return $this->attributes['bandwith'] ?? '';
@ -29,7 +38,6 @@ class LineEntity extends EquipmentEntity
{ {
return $this->attributes['start_at'] ?? ''; return $this->attributes['start_at'] ?? '';
} }
public function getEndAt(): string public function getEndAt(): string
{ {
return $this->attributes['end_at'] ?? ''; return $this->attributes['end_at'] ?? '';

View File

@ -15,6 +15,7 @@ class IPEntity extends PartType3Entity
'stock' => 0, 'stock' => 0,
'ip' => '', 'ip' => '',
'status' => '', 'status' => '',
'content' => '',
]; ];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
@ -45,4 +46,8 @@ class IPEntity extends PartType3Entity
{ {
return $this->attributes['ip'] ?? ""; return $this->attributes['ip'] ?? "";
} }
public function getContent(): string
{
return $this->attributes['content'] ?? "";
}
} }

View File

@ -12,6 +12,7 @@ class LineForm extends EquipmentForm
{ {
$fields = [ $fields = [
"type", "type",
"protocol",
"title", "title",
"bandwith", "bandwith",
"start_at", "start_at",
@ -19,10 +20,11 @@ class LineForm extends EquipmentForm
]; ];
$filters = [ $filters = [
"type", "type",
"protocol",
"status", "status",
]; ];
$indexFilter = $filters; $indexFilter = $filters;
$batchjobFilters = ['status']; $batchjobFilters = ['type', 'protocol', 'status'];
$actionButtons = ['view' => ICONS['SEARCH']]; $actionButtons = ['view' => ICONS['SEARCH']];
$batchjobButtons = []; $batchjobButtons = [];
switch ($action) { switch ($action) {
@ -54,6 +56,7 @@ class LineForm extends EquipmentForm
switch ($field) { switch ($field) {
case "bandwith": case "bandwith":
case "type": case "type":
case "protocol":
case "status": case "status":
case "start_at": case "start_at":
$formRules[$field] = "required|trim|string"; $formRules[$field] = "required|trim|string";

View File

@ -14,13 +14,15 @@ class IPForm extends PartForm
"lineinfo_uid", "lineinfo_uid",
"ip", "ip",
"price", "price",
'status',
"content",
]; ];
$filters = [ $filters = [
'old_clientinfo_uid',
'clientinfo_uid', 'clientinfo_uid',
'serverinfo_uid', 'serverinfo_uid',
'old_clientinfo_uid',
"lineinfo_uid", "lineinfo_uid",
'status' 'status',
]; ];
$indexFilter = $filters; $indexFilter = $filters;
$batchjobFilters = ['status']; $batchjobFilters = ['status'];
@ -35,23 +37,40 @@ class IPForm extends PartForm
break; break;
case 'view': case 'view':
$fields = [ $fields = [
...$fields,
'clientinfo_uid', 'clientinfo_uid',
'serverinfo_uid', 'serverinfo_uid',
'old_clientinfo_uid', 'lineinfo_uid',
'ip',
'price',
'status', 'status',
'created_at' 'created_at',
'old_clientinfo_uid',
'content',
]; ];
break; break;
case 'index': case 'index':
case 'download':
$fields = [ $fields = [
...$fields,
'clientinfo_uid', 'clientinfo_uid',
'serverinfo_uid', 'serverinfo_uid',
'old_clientinfo_uid', 'lineinfo_uid',
'ip',
'price',
'status', 'status',
'created_at' 'old_clientinfo_uid',
'created_at',
];
break;
case 'download':
$fields = [
'clientinfo_uid',
'serverinfo_uid',
'lineinfo_uid',
'ip',
'price',
'status',
'created_at',
'old_clientinfo_uid',
'content',
]; ];
break; break;
} }

View File

@ -4,6 +4,7 @@ return [
'label' => [ 'label' => [
'title' => "제목", 'title' => "제목",
'type' => "종류", 'type' => "종류",
'protocol' => "PROTOCOL",
'bandwith' => "CIDR대역", 'bandwith' => "CIDR대역",
'price' => "금액", 'price' => "금액",
'status' => "상태", 'status' => "상태",
@ -17,6 +18,12 @@ return [
"normal" => "일반", "normal" => "일반",
"dedicated" => "전용", "dedicated" => "전용",
], ],
"PROTOCOL" => [
"BGP" => "BGP",
"ISPUP" => "ISP Uplink",
"STATIC" => "STATIC",
"PPOE" => "PPOE",
],
"STATUS" => [ "STATUS" => [
STATUS['AVAILABLE'] => "사용가능", STATUS['AVAILABLE'] => "사용가능",
STATUS['OCCUPIED'] => "서비스중", STATUS['OCCUPIED'] => "서비스중",

View File

@ -22,17 +22,38 @@ return [
"serverpartinfo" => "부품정보", "serverpartinfo" => "부품정보",
], ],
"TYPE" => [ "TYPE" => [
SERVER['TYPES']['NORMAL'] => "일반", 'normal' => "일반",
SERVER['TYPES']['DEFENCE'] => "방어", 'defence' => "방어",
SERVER['TYPES']['DEDICATED'] => "전용", 'dedicated' => "전용",
SERVER['TYPES']['VPN'] => "VPN", 'vpn' => "VPN",
SERVER['TYPES']['EVENT'] => "이벤트", 'event' => "이벤트",
SERVER['TYPES']['TEST'] => "테스트", 'test' => "테스트",
SERVER['TYPES']['ALTERNATIVE'] => "대체", 'alternative' => "대체",
SERVER['TYPES']['INHOUSE'] => "자사용", 'inhouse' => "자사용",
SERVER['TYPES']['COLOCATION'] => "코로케이션", 'colocation' => "코로케이션",
],
"OS" => [
"CENTOS7" => "CentOS7",
"CENTOS8" => "CentOS8",
"CENTOS9" => "CentOS9",
"CENTOS10" => "CentOS10",
"UBUNTU20.04" => "Ubuntu20.04",
"UBUNTU22.04" => "Ubuntu22.04",
"UBUNTU23.04" => "Ubuntu23.04",
"UBUNTU24.04" => "Ubuntu24.04",
"UBUNTU25.04" => "Ubuntu25.04",
"DEBIAN10" => "Debian10",
"DEBIAN11" => "Debian11",
"DEBIAN12" => "Debian12",
"WINDOWS10" => "Windows10",
"WINDOWS11" => "Windows11",
"WINDOWS2008R2" => "Windows2008R2",
"WINDOWS2012R2" => "Windows2012R2",
"WINDOWS2016R2" => "Windows2016R2",
"WINDOWS2019R2" => "Windows2019R2",
"WINDOWS2022R2" => "Windows2022R2",
"WINDOWS2024R2" => "Windows2024R2",
], ],
"OS" => SERVER['OS'],
"STATUS" => [ "STATUS" => [
STATUS['AVAILABLE'] => "사용가능", STATUS['AVAILABLE'] => "사용가능",
STATUS['OCCUPIED'] => "서비스중", STATUS['OCCUPIED'] => "서비스중",

View File

@ -8,7 +8,7 @@ return [
'serverinfo_uid' => '서버정보', 'serverinfo_uid' => '서버정보',
'ip' => "IP", 'ip' => "IP",
'price' => "기본가", 'price' => "기본가",
'history' => "사용내역", 'content' => "내용",
'status' => "상태", 'status' => "상태",
'updated_at' => "수정일", 'updated_at' => "수정일",
'created_at' => "작성일", 'created_at' => "작성일",

View File

@ -128,7 +128,7 @@ HDD: SSD 128G * 4
//server_use_status => y이면 사용중 //server_use_status => y이면 사용중
$temps = []; $temps = [];
$temps['code'] = trim($row['server_code']); $temps['code'] = trim($row['server_code']);
$temps['type'] = SERVER['TYPES']['NORMAL']; $temps['type'] = 'normal';
$temps['chassisinfo_uid'] = 1; $temps['chassisinfo_uid'] = 1;
$temps['price'] = trim($row['server_use_status']) === 'y' ? 0 : intval($row['server_cost']); $temps['price'] = trim($row['server_use_status']) === 'y' ? 0 : intval($row['server_cost']);
$temps['status'] = trim($row['server_use_status']) === 'y' ? STATUS['AVAILABLE'] : STATUS['OCCUPIED']; $temps['status'] = trim($row['server_use_status']) === 'y' ? STATUS['AVAILABLE'] : STATUS['OCCUPIED'];

View File

@ -15,6 +15,7 @@ class LineModel extends EquipmentModel
protected $allowedFields = [ protected $allowedFields = [
"uid", "uid",
"type", "type",
"protocol",
"title", "title",
"bandwith", "bandwith",
"start_at", "start_at",

View File

@ -22,6 +22,7 @@ class IPModel extends PartModel
"ip", "ip",
"price", "price",
"status", "status",
"content",
]; ];
public function __construct() public function __construct()
{ {

View File

@ -2,14 +2,17 @@
namespace App\Services\Equipment; namespace App\Services\Equipment;
use App\Models\Equipment\LineModel;
use App\Helpers\Equipment\LineHelper;
use App\Forms\Equipment\LineForm;
use App\Entities\Equipment\LineEntity;
use App\DTOs\Equipment\LineDTO; use App\DTOs\Equipment\LineDTO;
use App\Entities\Equipment\LineEntity;
use App\Forms\Equipment\LineForm;
use App\Helpers\Equipment\LineHelper;
use App\Models\Equipment\LineModel;
use App\Traits\UtilTrait;
use RuntimeException;
class LineService extends EquipmentService class LineService extends EquipmentService
{ {
use UtilTrait;
private $_form = null; private $_form = null;
private $_helper = null; private $_helper = null;
public function __construct(LineModel $model) public function __construct(LineModel $model)
@ -62,6 +65,29 @@ class LineService extends EquipmentService
{ {
return $entity; return $entity;
} }
protected function create_process(array $formDatas): LineEntity
{
if (!$this->isValidCIDRTrait($formDatas['bandwith'])) {
throw new \Exception("{$formDatas['bandwith']}는 CIDR 형식에 부합되지 않습니다.");
}
//Line 등록
$entity = parent::create_process($formDatas);
if (!$entity instanceof LineEntity) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 LineEntity만 가능");
}
//자동추가용
// 1. 기존 설정값 저장 (나중에 복구하기 위함)
$originalTime = ini_get('max_execution_time');
// 2. 이 함수를 위해 시간 늘리기 (예: 5분)
set_time_limit(300);
//IP등록
foreach ($this->cidrToIpRangeTrait($entity->getBandwith()) as $ip) {
service('part_ipservice')->attachToLine($entity, $ip);
}
// 3. 작업 완료 후 기존 설정으로 복구 (선택 사항)
set_time_limit($originalTime);
return $entity;
}
//List 검색용 //List 검색용
//FormFilter 조건절 처리 //FormFilter 조건절 처리
//검색어조건절처리 //검색어조건절처리

View File

@ -3,6 +3,7 @@
namespace App\Services\Part; namespace App\Services\Part;
use App\DTOs\Part\IPDTO; use App\DTOs\Part\IPDTO;
use App\Entities\Equipment\LineEntity;
use App\Entities\Equipment\ServerEntity; use App\Entities\Equipment\ServerEntity;
use App\Entities\Equipment\ServerPartEntity; use App\Entities\Equipment\ServerPartEntity;
use App\Entities\Part\IPEntity; use App\Entities\Part\IPEntity;
@ -65,6 +66,19 @@ class IPService extends PartType3Service
{ {
return $entity; return $entity;
} }
protected function create_process(array $formDatas): IPEntity
{
//IP 기본비용정의
if (!array_key_exists('price', $formDatas)) {
$formDatas['price'] = IP['DEFAULT_PRICE'];
}
//IP 등록
$entity = parent::create_process($formDatas);
if (!$entity instanceof IPEntity) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 IPEntity만 가능");
}
return $entity;
}
//List 검색용 //List 검색용
//FormFilter 조건절 처리 //FormFilter 조건절 처리
//검색어조건절처리 //검색어조건절처리
@ -74,7 +88,19 @@ class IPService extends PartType3Service
$this->model->orderBy("INET_ATON(ip) ASC"); $this->model->orderBy("INET_ATON(ip) ASC");
parent::setOrderBy($field, $value); parent::setOrderBy($field, $value);
} }
//Line관련 작업
public function attachToLine(LineEntity $lineEntity, string $ip): IPEntity
{
$entity = $this->create_process([
'lineinfo_uid' => $lineEntity->getPK(),
'ip' => $ip,
'status' => STATUS['AVAILABLE'],
]);
if (!$entity instanceof IPEntity) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 {$lineEntity->getTitle()}{$ip} 생성을 실패하였습니다.");
}
return $entity;
}
//서버관련 작업 //서버관련 작업
//파트정보가져오기 //파트정보가져오기
public function getPartEntityByServer(ServerEntity $serverEntity, array $formDatas = []): IPEntity public function getPartEntityByServer(ServerEntity $serverEntity, array $formDatas = []): IPEntity

View File

@ -146,7 +146,7 @@ trait UtilTrait
// (EX:192.168.1.0 -> 192.168.001.000) // (EX:192.168.1.0 -> 192.168.001.000)
final public function cidrToIpRangeTrait(string $cidr): array final public function cidrToIpRangeTrait(string $cidr): array
{ {
if (!$this->isValidCIDR($cidr)) { if (!$this->isValidCIDRTrait($cidr)) {
return []; // 유효하지 않으면 빈 배열 반환 return []; // 유효하지 않으면 빈 배열 반환
} }