vhost init...4

This commit is contained in:
최준흠 2024-05-20 20:56:44 +09:00
parent 47f1a7c648
commit f9bb28c62c
4 changed files with 18 additions and 27 deletions

View File

@ -27,7 +27,7 @@ class ProductCell extends BaseCell
foreach ($this->getProductDeviceModel()->getEntitys( foreach ($this->getProductDeviceModel()->getEntitys(
['product_uid' => $cellDatas['entity']->getPrimaryKey()] ['product_uid' => $cellDatas['entity']->getPrimaryKey()]
) as $productDevieceEntity) { ) as $productDevieceEntity) {
$cellDatas['defaults'][$productDevieceEntity->device_uid] = $productDevieceEntity; $cellDatas['defaults'][] = $productDevieceEntity->device_uid;
} }
} }
$cellDatas['device'] = []; $cellDatas['device'] = [];

View File

@ -92,7 +92,7 @@ class ProductController extends AdminController
} }
//가상서버 //가상서버
protected function virtual_process(ProductEntity $entity): array protected function virtual_process(ProductEntity $entity)
{ {
//가상서버정보 //가상서버정보
$protudctDatas = array( $protudctDatas = array(
@ -129,11 +129,10 @@ class ProductController extends AdminController
$protudctDatas['name'] = implode(" ", $titles); $protudctDatas['name'] = implode(" ", $titles);
$protudctDatas['content'] = implode("\n", $titles); $protudctDatas['content'] = implode("\n", $titles);
$product = $this->getModel()->create($protudctDatas); $product = $this->getModel()->create($protudctDatas);
return array();
//return $this->add_procedure($product, 1, $this->_viewDatas['fieldDatas']['paymentday']); //return $this->add_procedure($product, 1, $this->_viewDatas['fieldDatas']['paymentday']);
} }
//주문처리 //주문처리
protected function device_process(ProductEntity $entity): array protected function device_process(ProductEntity $entity)
{ {
switch ($this->_viewDatas['fieldDatas']['category']) { switch ($this->_viewDatas['fieldDatas']['category']) {
case 'virtual': case 'virtual':
@ -141,23 +140,23 @@ class ProductController extends AdminController
break; break;
case 'beremetal': case 'beremetal':
//상품관련 tw_product_device 기존정보 삭제처리 //상품관련 tw_product_device 기존정보 삭제처리
foreach ($this->getProductDeviceModel()->getEntitys( $productDeviceEntitys = $this->getProductDeviceModel()->getEntitys(['product_uid' => $entity->getPrimaryKey()]);
['product_uid' => $entity->getPrimaryKey()] foreach ($productDeviceEntitys as $productDeviceEntity) {
) as $productDeviceEntity) { $this->getProductDeviceModel()->delete($productDeviceEntity->getPrimaryKey());
$this->getProductDeviceModel()->delete($productDeviceEntity);
} }
//상품관련 tw_product_device 기존정보 생성처리 //상품관련 tw_product_device 기존정보 생성처리
$devices = [];
foreach (['server', 'cpu', 'memory', 'disk', 'nic', 'publicip', 'os'] as $field) { foreach (['server', 'cpu', 'memory', 'disk', 'nic', 'publicip', 'os'] as $field) {
$formDatas = ['product_uid' => $entity->getPrimaryKey()]; $device_uids = $this->request->getPost($field) ?: [];
$formDatas['device_uid'] = $this->request->getPost($field); // dd($device_uids);
$formDatas['device_cnt'] = $this->request->getPost($field . "_cnt") ?: 1; foreach ($device_uids as $device_uid) {
if ($formDatas['product_uid'] && $formDatas['device_uid']) { $formDatas = ['product_uid' => $entity->getPrimaryKey()];
$devices[$field] = $this->getProductDeviceModel()->create($formDatas); $formDatas['device_uid'] = $device_uid;
$formDatas['device_cnt'] = $this->request->getPost($field . "_cnt") ?: 1;
if ($formDatas['product_uid'] && $formDatas['device_uid']) {
$this->getProductDeviceModel()->create($formDatas);
}
} }
} }
// dd($devices);
return $devices;
break; break;
default: default:
throw new \Exception($this->_viewDatas['fieldDatas']['category'] . "는 알수없는 상품 구분입니다. 다시 확인 부탁드립니다."); throw new \Exception($this->_viewDatas['fieldDatas']['category'] . "는 알수없는 상품 구분입니다. 다시 확인 부탁드립니다.");
@ -170,7 +169,7 @@ class ProductController extends AdminController
{ {
$this->_viewDatas['fieldDatas']['price'] = $this->calculate_price(); $this->_viewDatas['fieldDatas']['price'] = $this->calculate_price();
$entity = parent::insert_process(); $entity = parent::insert_process();
$entity->setDevices($this->device_process($entity)); $this->device_process($entity);
return $entity; return $entity;
} }
//Update관련 //Update관련
@ -178,7 +177,7 @@ class ProductController extends AdminController
{ {
$this->_viewDatas['fieldDatas']['price'] = $this->calculate_price(); $this->_viewDatas['fieldDatas']['price'] = $this->calculate_price();
$entity = parent::update_process($entity); $entity = parent::update_process($entity);
$entity->setDevices($this->device_process($entity)); $this->device_process($entity);
// dd($entity); // dd($entity);
return $entity; return $entity;
} }

View File

@ -42,12 +42,4 @@ class ProductEntity extends BaseEntity
} }
return $price; return $price;
} }
public function getDevices(): array
{
return $this->_devices;
}
public function setDevices(array $devices)
{
$this->_devices = $devices;
}
} }

View File

@ -8,7 +8,7 @@
<?php foreach ($cellDatas['device']['categorys'] as $category) : ?> <?php foreach ($cellDatas['device']['categorys'] as $category) : ?>
<td> <td>
<?= form_dropdown( <?= form_dropdown(
$category, $category . '[]',
$cellDatas['device']['options'][$category], $cellDatas['device']['options'][$category],
$cellDatas['defaults'], $cellDatas['defaults'],
[ [