dbmsv2 init...1
This commit is contained in:
parent
a4aad8e45e
commit
8ae2cfd40e
@ -365,6 +365,19 @@ 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("PAYMENT", [
|
||||
'BILLING' => [
|
||||
'METHOD_MONTH' => 'month',
|
||||
'METHOD_ONETIME' => 'onetime'
|
||||
],
|
||||
'PAY' => [
|
||||
'METHOD_ACCOUNT' => 'account',
|
||||
'METHOD_COUPON' => 'coupon',
|
||||
'METHOD_POINT' => 'point'
|
||||
]
|
||||
]);
|
||||
|
||||
//서버아이템 정의
|
||||
define("SERVER_LINK_ITEMS", [
|
||||
'CPU' => "CPU정보",
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
"settings": {
|
||||
"width": 3000,
|
||||
"height": 3000,
|
||||
"scrollTop": -1555.0603,
|
||||
"scrollLeft": -563.9615,
|
||||
"scrollTop": -1510.0603,
|
||||
"scrollLeft": -1100.9615,
|
||||
"zoomLevel": 1,
|
||||
"show": 511,
|
||||
"database": 4,
|
||||
"databaseName": "",
|
||||
"canvasType": "@dineug/erd-editor/builtin-schema-sql",
|
||||
"canvasType": "ERD",
|
||||
"language": 1,
|
||||
"tableNameCase": 4,
|
||||
"columnNameCase": 2,
|
||||
|
||||
@ -17,4 +17,12 @@ class ServerEntity extends EquipmentEntity
|
||||
{
|
||||
return $this->attributes['code'];
|
||||
}
|
||||
public function getClientInfoUID(): int|null
|
||||
{
|
||||
return $this->attributes['clientinfo_uid'];
|
||||
}
|
||||
public function getServiceInfoUID(): int|null
|
||||
{
|
||||
return $this->attributes['serviceinfo_uid'];
|
||||
}
|
||||
}
|
||||
|
||||
11
app/Entities/Equipment/ServerPartEntity.php
Normal file
11
app/Entities/Equipment/ServerPartEntity.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities\Equipment;
|
||||
|
||||
use App\Models\Equipment\ServerPartModel;
|
||||
|
||||
class ServerPartEntity extends EquipmentEntity
|
||||
{
|
||||
const PK = ServerPartModel::PK;
|
||||
const TITLE = ServerPartModel::TITLE;
|
||||
}
|
||||
48
app/Models/Equipment/ServerPartModel.php
Normal file
48
app/Models/Equipment/ServerPartModel.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Equipment;
|
||||
|
||||
use App\Entities\Equipment\ServerPartEntity;
|
||||
|
||||
class ServerPartModel extends EquipmentModel
|
||||
{
|
||||
const TABLE = "serverinfo_partinfo";
|
||||
const PK = "uid";
|
||||
const TITLE = "partinfo_uio";
|
||||
protected $table = self::TABLE;
|
||||
protected $primaryKey = self::PK;
|
||||
protected $returnType = ServerPartEntity::class;
|
||||
protected $allowedFields = [
|
||||
"partinfo_uid",
|
||||
"serverinfo_uid",
|
||||
"serviceinfo_uid",
|
||||
"billing_method",
|
||||
"cnt",
|
||||
"extra",
|
||||
];
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
final public function getFormFieldRule(string $action, string $field): string
|
||||
{
|
||||
if (is_array($field)) {
|
||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||
}
|
||||
switch ($field) {
|
||||
case "partinfo_uid":
|
||||
case "serverinfo_uid":
|
||||
case "billing_method":
|
||||
case "cnt":
|
||||
$rule = "required|numeric";
|
||||
break;
|
||||
case "serviceinfo_uid":
|
||||
$rule = "permit_empty|numeric";
|
||||
break;
|
||||
default:
|
||||
$rule = parent::getFormFieldRule($action, $field);
|
||||
break;
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
}
|
||||
@ -2,8 +2,9 @@
|
||||
|
||||
namespace App\Services\Equipment;
|
||||
|
||||
use App\Entities\Equipment\PartEntity;
|
||||
use App\Entities\Equipment\ServerEntity;
|
||||
use App\Models\Equipment\ServerModel;
|
||||
use App\Models\Equipment\ServerPartModel;
|
||||
use App\Services\Equipment\EquipmentService;
|
||||
|
||||
class ServerService extends EquipmentService
|
||||
@ -11,6 +12,9 @@ class ServerService extends EquipmentService
|
||||
private ?PartService $_partService = null;
|
||||
private ?IPService $_ipService = null;
|
||||
private ?CSService $_csService = null;
|
||||
private ?ServerPartModel $_serverPartModel = null;
|
||||
const BasePartLists = ['cpu', 'ram', 'disk', 'os'];
|
||||
const AddtionalPartLists = ['ram', 'disk', 'db', 'software', 'ip', 'cs'];
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(new ServerModel());
|
||||
@ -89,6 +93,13 @@ class ServerService extends EquipmentService
|
||||
}
|
||||
return $this->_csService;
|
||||
}
|
||||
final public function getServerPartModel(): ServerPartModel
|
||||
{
|
||||
if (!$this->_serverPartModel) {
|
||||
$this->_serverPartModel = new ServerPartModel();
|
||||
}
|
||||
return $this->_serverPartModel;
|
||||
}
|
||||
//기본 기능부분
|
||||
//FieldForm관련용
|
||||
public function getFormFieldOption(string $field, array $options = []): array
|
||||
@ -144,6 +155,52 @@ class ServerService extends EquipmentService
|
||||
{
|
||||
return $this->getModel()->getLastestCode($format, $default);
|
||||
}
|
||||
private function getConvertedFormDatas(array $formDatas): array
|
||||
{
|
||||
$convertedFormDatas = [];
|
||||
$convertedFormDatas['code'] = $formDatas['code'];
|
||||
$convertedFormDatas['type'] = $formDatas['type'];
|
||||
$convertedFormDatas['title'] = $formDatas['title'];
|
||||
$convertedFormDatas['price'] = $formDatas['price'];
|
||||
$convertedFormDatas['manufactur_at'] = $formDatas['manufactur_at'];
|
||||
if (array_key_exists('format_at', $formDatas) && $formDatas['format_at']) {
|
||||
$convertedFormDatas['format_at'] = $formDatas['format_at'];
|
||||
}
|
||||
$convertedFormDatas['status'] = $formDatas['status'];
|
||||
return $convertedFormDatas;
|
||||
}
|
||||
private function getPartLinkFormDatas(ServerEntity $entity, array $formDatas): array
|
||||
{
|
||||
$partFormDatas = [];
|
||||
$partFormDatas["serverinfo_uid"] = $entity->getPK();
|
||||
if ($entity->getServiceInfoUID()) { //서비스정보가 있다면
|
||||
$partFormDatas["serviceinfo_uid"] = $entity->getServiceInfoUID();
|
||||
}
|
||||
$partFormDatas["billing_method"] = PAYMENT['BILLING']['METHOD_MONTH'];
|
||||
$partLinkFormDatas = [];
|
||||
foreach (self::BasePartLists as $field) {
|
||||
$partFormDatas["partinfo_uid"] = $formDatas["partinfo_{$field}_uid"];
|
||||
$partFormDatas["cnt"] = array_key_exists("partinfo_{$field}_cnt", $formDatas) ? $formDatas["partinfo_{$field}_cnt"] : 1;
|
||||
$partFormDatas["extra"] = array_key_exists("partinfo_{$field}_extra", $formDatas) ? $formDatas["partinfo_{$field}_extra"] : "";
|
||||
//part별로 link용 추가
|
||||
$partLinkFormDatas[] = $partFormDatas;
|
||||
}
|
||||
return $partLinkFormDatas;
|
||||
}
|
||||
|
||||
public function create(array $formDatas): ServerEntity
|
||||
{
|
||||
//입력된 데이터를 기준으로 서버정보 재정의
|
||||
$convertedFormDatas = $this->getConvertedFormDatas($formDatas);
|
||||
$entity = parent::create($convertedFormDatas);
|
||||
//파트정보 가져오기
|
||||
$partLinkFormDatas = $this->getPartLinkFormDatas($entity, $formDatas);
|
||||
foreach ($partLinkFormDatas as $partLinkFormData) {
|
||||
$this->getServerPartModel()->create($partLinkFormData);
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(mixed $field = null, mixed $value = null): void
|
||||
|
||||
Loading…
Reference in New Issue
Block a user