diff --git a/app/Config/Constants.php b/app/Config/Constants.php index 03f57b2..b6e1263 100644 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -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정보", diff --git a/app/Database/dbmsv2.vuerd.json b/app/Database/dbmsv2.vuerd.json index 3d5660f..7320ccc 100644 --- a/app/Database/dbmsv2.vuerd.json +++ b/app/Database/dbmsv2.vuerd.json @@ -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, diff --git a/app/Entities/Equipment/ServerEntity.php b/app/Entities/Equipment/ServerEntity.php index e1e6dcf..0fc8a59 100644 --- a/app/Entities/Equipment/ServerEntity.php +++ b/app/Entities/Equipment/ServerEntity.php @@ -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']; + } } diff --git a/app/Entities/Equipment/ServerPartEntity.php b/app/Entities/Equipment/ServerPartEntity.php new file mode 100644 index 0000000..b509fdd --- /dev/null +++ b/app/Entities/Equipment/ServerPartEntity.php @@ -0,0 +1,11 @@ + 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; + } +} diff --git a/app/Services/Equipment/ServerService.php b/app/Services/Equipment/ServerService.php index 74365ae..d56bac8 100644 --- a/app/Services/Equipment/ServerService.php +++ b/app/Services/Equipment/ServerService.php @@ -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