dbmsv2 init...1
This commit is contained in:
parent
dca85a817b
commit
bac640cc08
@ -48,7 +48,7 @@ class PaymentController extends CustomerController
|
||||
}
|
||||
return $this->_clientService;
|
||||
}
|
||||
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
protected function getResultSuccess_process(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
{
|
||||
switch ($this->getAction()) {
|
||||
case 'invoice':
|
||||
@ -63,7 +63,7 @@ class PaymentController extends CustomerController
|
||||
$result = view($view_file, ['viewDatas' => $this->getViewDatas()]);
|
||||
break;
|
||||
default:
|
||||
$result = parent::getResultSuccess($message, $actionTemplate);
|
||||
$result = parent::getResultSuccess_process($message, $actionTemplate);
|
||||
break;
|
||||
}
|
||||
return $result;
|
||||
@ -141,9 +141,9 @@ class PaymentController extends CustomerController
|
||||
//각 Field 초기화
|
||||
$this->initAction($this->getService()->getFormFields());
|
||||
$this->invoice_process();
|
||||
return $this->getResultSuccess();
|
||||
return $this->getResultSuccess_process();
|
||||
} catch (\Exception $e) {
|
||||
return $this->getResultFail($e->getMessage());
|
||||
return $this->getResultFail_process($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Controllers\Admin\Equipment;
|
||||
|
||||
use App\Entities\Equipment\IPEntity;
|
||||
use App\Entities\Equipment\ServerEntity;
|
||||
use App\Entities\Equipment\ServerPartEntity;
|
||||
use App\Helpers\Equipment\ServerHelper;
|
||||
|
||||
use App\Services\Equipment\ServerService;
|
||||
@ -51,104 +49,20 @@ class ServerController extends EquipmentController
|
||||
parent::create_form_process();
|
||||
}
|
||||
//추가 파트정보 생성
|
||||
private function getFormDatasForServerInfo(array $formDatas): array
|
||||
{
|
||||
$tempDatas = [
|
||||
"code" => $formDatas['code'],
|
||||
"type" => $formDatas['type'],
|
||||
"title" => $formDatas['title'],
|
||||
"price" => $formDatas['price'],
|
||||
"amount" => $formDatas['amount'],
|
||||
"manufactur_at" => $formDatas['manufactur_at'],
|
||||
"format_at" => $formDatas['format_at'],
|
||||
"status" => $formDatas['status'],
|
||||
];
|
||||
return $formDatas;
|
||||
}
|
||||
private function getFormDatasForServerPartInfo(ServerEntity $entity, string $partType): array
|
||||
{
|
||||
$formDatas = [
|
||||
"partinfo_uid" => $this->request->getPost(["serverpartinfo_{$partType}_uid"]),
|
||||
"serverinfo_uid" => $entity->getPK(),
|
||||
"serviceinfo_uid" => $entity->getServiceInfoUID(),
|
||||
"type" => $partType,
|
||||
"billing" => ServerPartENtity::DEFAULT_BILLING,
|
||||
"amount" => $this->request->getPost("amount") ?? 0,
|
||||
"cnt" => $this->request->getPost("serverpartinfo_{$partType}_uid_cnt") ?? 1,
|
||||
"extra" => $this->request->getPost("serverpartinfo_{$partType}_uid_extra") ?? ""
|
||||
];
|
||||
return $formDatas;
|
||||
}
|
||||
private function getFormDatasForIPInfo(ServerEntity $entity, string $status): array
|
||||
{
|
||||
$formDatas = [
|
||||
"serverinfo_uid" => $entity->getPK(),
|
||||
"clientinfo_uid" => $entity->getClientInfoUID(),
|
||||
"serviceinfo_uid" => $entity->getServiceInfoUID(),
|
||||
"status" => $status
|
||||
];
|
||||
return $formDatas;
|
||||
}
|
||||
|
||||
//생성
|
||||
private function createServerPartInfo(ServerEntity $entity): ServerEntity
|
||||
{
|
||||
foreach (SERVER['PARTTYPES'] as $partType) {
|
||||
$serverPartEnty = $this->getService()->getServerPartService()->create(
|
||||
$this->getFormDatasForServerPartInfo($entity, $partType)
|
||||
);
|
||||
$entity->setServerPartEntity($partType, $serverPartEnty);
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
private function setIpInfo(ServerEntity $entity): ServerEntity
|
||||
{
|
||||
//기존 Entity 가져오기
|
||||
$ipinfo_uid = $this->request->getPost("ipinfo_uid");
|
||||
$ipEntity = $this->getService()->getIPService()->getEntity($ipinfo_uid);
|
||||
if (!$ipEntity) {
|
||||
throw new \Exception("{$ipinfo_uid}에 대한 정보를 찾을수 없습니다.");
|
||||
}
|
||||
$formDatas = $this->getFormDatasForIPInfo($entity, $ipEntity::STATUS_OCCUPIED);
|
||||
$ipEntity = $this->getService()->getIPService()->modify($ipEntity, $formDatas);
|
||||
$entity->addIPEntity($ipEntity);
|
||||
return $entity;
|
||||
}
|
||||
protected function create_process(array $formDatas): ServerEntity
|
||||
{
|
||||
//코드 패턴체크
|
||||
$this->getService()->codeCheck($formDatas);
|
||||
$entity = parent::create_process($this->getFormDatasForServerInfo($formDatas));
|
||||
//ServerPart정보 생성 후 ServerEntity에 설정
|
||||
$entity = $this->createServerPartInfo($entity);
|
||||
//IP정보 속성 수정후 ServerEntity에 설정
|
||||
$entity = $this->setIpInfo($entity);
|
||||
return $entity;
|
||||
return parent::create_process($formDatas);
|
||||
}
|
||||
|
||||
//수정
|
||||
private function modifyServerPartInfo(ServerEntity $entity): ServerEntity
|
||||
{
|
||||
foreach (SERVER['PARTTYPES'] as $partType) {
|
||||
$serverPartEnty = $entity->getServerPartEntity($partType);
|
||||
if ($serverPartEnty) {
|
||||
$serverPartEnty = $this->getService()->getServerPartService()->modify(
|
||||
$serverPartEnty,
|
||||
$this->getFormDatasForServerPartInfo($entity, $partType)
|
||||
);
|
||||
}
|
||||
$entity->setServerPartEntity($partType, $serverPartEnty);
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
protected function modify_process(mixed $entity, array $formDatas): ServerEntity
|
||||
{
|
||||
//코드 패턴체크
|
||||
$this->getService()->codeCheck($formDatas);
|
||||
$entity = parent::modify_process($entity, $this->getFormDatasForServerInfo($formDatas));
|
||||
//ServerPart정보 생성 후 ServerEntity에 설정
|
||||
$entity = $this->modifyServerPartInfo($entity);
|
||||
//IP정보 속성 수정후 ServerEntity에 설정
|
||||
$entity = $this->setIpInfo($entity);
|
||||
return $entity;
|
||||
return parent::modify_process($entity, $formDatas);
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ class Home extends AdminController
|
||||
}
|
||||
return $this->_PaymentService;
|
||||
}
|
||||
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
protected function getResultSuccess_process(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
{
|
||||
switch ($this->getAction()) {
|
||||
case 'index':
|
||||
@ -59,7 +59,7 @@ class Home extends AdminController
|
||||
$result = view($view_file, ['viewDatas' => $this->getViewDatas()]);
|
||||
break;
|
||||
default:
|
||||
$result = parent::getResultSuccess($message, $actionTemplate);
|
||||
$result = parent::getResultSuccess_process($message, $actionTemplate);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
@ -82,6 +82,6 @@ class Home extends AdminController
|
||||
$this->unPaids = $this->getPaymentService()->getUnPaidCount();
|
||||
$this->unPaidCount = count($this->unPaids);
|
||||
helper(['form']);
|
||||
return $this->getResultSuccess();
|
||||
return $this->getResultSuccess_process();
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@ use App\Helpers\Customer\ServiceHelper;
|
||||
use App\Services\Customer\ServicePaymentService;
|
||||
|
||||
use App\Services\Customer\ServiceService;
|
||||
use App\Services\Equipment\CodeService;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
@ -14,8 +13,6 @@ use Psr\Log\LoggerInterface;
|
||||
|
||||
class SearchController extends AdminController
|
||||
{
|
||||
private ?CodeService $_codeService = null;
|
||||
private ?ServicePaymentService $_servicePaymentService = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
@ -39,28 +36,14 @@ class SearchController extends AdminController
|
||||
}
|
||||
return $this->_helper;
|
||||
}
|
||||
public function getCodeService(): CodeService
|
||||
{
|
||||
if (!$this->_codeService) {
|
||||
$this->_codeService = new CodeService();
|
||||
}
|
||||
return $this->_codeService;
|
||||
}
|
||||
public function getServicePaymentService(): ServicePaymentService
|
||||
{
|
||||
if (!$this->_servicePaymentService) {
|
||||
$this->_servicePaymentService = new ServicePaymentService();
|
||||
}
|
||||
return $this->_servicePaymentService;
|
||||
}
|
||||
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
protected function getResultSuccess_process(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
{
|
||||
switch ($this->getAction()) {
|
||||
case 'index':
|
||||
$result = parent::getResultSuccess($message, $this->request->getVar('ActionTemplate') ?? $actionTemplate ?? 'search');
|
||||
$result = parent::getResultSuccess_process($message, $this->request->getVar('ActionTemplate') ?? $actionTemplate ?? 'search');
|
||||
break;
|
||||
default:
|
||||
$result = parent::getResultSuccess($message, $actionTemplate);
|
||||
$result = parent::getResultSuccess_process($message, $actionTemplate);
|
||||
break;
|
||||
}
|
||||
return $result;
|
||||
|
||||
@ -41,7 +41,7 @@ class UserController extends AdminController
|
||||
return $this->_helper;
|
||||
}
|
||||
//Index,FieldForm관련
|
||||
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
protected function getResultSuccess_process(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
{
|
||||
switch ($this->getAction()) {
|
||||
case 'profile_modify':
|
||||
@ -60,7 +60,7 @@ class UserController extends AdminController
|
||||
$result = view($view_file, ['viewDatas' => $this->getViewDatas()]);
|
||||
break;
|
||||
default:
|
||||
$result = parent::getResultSuccess($message, $actionTemplate);
|
||||
$result = parent::getResultSuccess_process($message, $actionTemplate);
|
||||
break;
|
||||
}
|
||||
return $result;
|
||||
@ -95,9 +95,9 @@ class UserController extends AdminController
|
||||
}
|
||||
$this->modify_form_process($entity);
|
||||
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
return $this->getResultSuccess();
|
||||
return $this->getResultSuccess_process();
|
||||
} catch (\Exception $e) {
|
||||
return $this->getResultFail($e->getMessage());
|
||||
return $this->getResultFail_process($e->getMessage());
|
||||
}
|
||||
}
|
||||
final public function profile_modify(int $uid): RedirectResponse|string
|
||||
@ -119,10 +119,10 @@ class UserController extends AdminController
|
||||
}
|
||||
$this->modify_process($entity, $formDatas);
|
||||
$this->_db->transCommit();
|
||||
return $this->getResultSuccess();
|
||||
return $this->getResultSuccess_process();
|
||||
} catch (\Exception $e) {
|
||||
$this->_db->transRollback();
|
||||
return $this->getResultFail($e->getMessage());
|
||||
return $this->getResultFail_process($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,21 +29,21 @@ abstract class AuthController extends CommonController
|
||||
}
|
||||
return $this->_helper;
|
||||
}
|
||||
protected function getResultFail(string $message = MESSAGES["FAILED"]): RedirectResponse
|
||||
protected function getResultFail_process(string $message = MESSAGES["FAILED"]): RedirectResponse
|
||||
{
|
||||
if ($this->request->getMethod() === 'POST') {
|
||||
return redirect()->back()->withInput()->with('error', $message);
|
||||
}
|
||||
return redirect()->to($this->getMyAuth()->popPreviousUrl())->with('error', $message);
|
||||
}
|
||||
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
protected function getResultSuccess_process(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
{
|
||||
switch ($this->getAction()) {
|
||||
case 'create': //Login처리
|
||||
$result = redirect()->to($this->getMyAuth()->popPreviousUrl())->with('error', $message);
|
||||
break;
|
||||
default:
|
||||
$result = parent::getResultSuccess($message, $actionTemplate);
|
||||
$result = parent::getResultSuccess_process($message, $actionTemplate);
|
||||
break;
|
||||
}
|
||||
return $result;
|
||||
|
||||
@ -189,9 +189,9 @@ abstract class CommonController extends BaseController
|
||||
//actionFilters에 해당하는 값이 있을 경우 정의
|
||||
helper(['form']);
|
||||
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
return $this->getResultSuccess();
|
||||
return $this->getResultSuccess_process();
|
||||
} catch (\Exception $e) {
|
||||
return $this->getResultFail($e->getMessage());
|
||||
return $this->getResultFail_process($e->getMessage());
|
||||
}
|
||||
}
|
||||
final public function create(): RedirectResponse|string
|
||||
@ -207,10 +207,10 @@ abstract class CommonController extends BaseController
|
||||
$formDatas = $this->create_validate_process($formDatas);
|
||||
$this->entity = $this->create_process($formDatas);
|
||||
$this->_db->transCommit();
|
||||
return $this->getResultSuccess();
|
||||
return $this->getResultSuccess_process();
|
||||
} catch (\Exception $e) {
|
||||
$this->_db->transRollback();
|
||||
return $this->getResultFail($e->getMessage());
|
||||
return $this->getResultFail_process($e->getMessage());
|
||||
}
|
||||
}
|
||||
//수정 기본기능
|
||||
@ -229,9 +229,9 @@ abstract class CommonController extends BaseController
|
||||
$this->entity = $this->modify_form_process($entity);
|
||||
helper(['form']);
|
||||
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
return $this->getResultSuccess();
|
||||
return $this->getResultSuccess_process();
|
||||
} catch (\Exception $e) {
|
||||
return $this->getResultFail($e->getMessage());
|
||||
return $this->getResultFail_process($e->getMessage());
|
||||
}
|
||||
}
|
||||
final public function modify(int $uid): RedirectResponse|string
|
||||
@ -253,10 +253,10 @@ abstract class CommonController extends BaseController
|
||||
$formDatas = $this->modify_validate_process($formDatas);
|
||||
$this->entity = $this->modify_process($entity, $formDatas);
|
||||
$this->_db->transCommit();
|
||||
return $this->getResultSuccess();
|
||||
return $this->getResultSuccess_process();
|
||||
} catch (\Exception $e) {
|
||||
$this->_db->transRollback();
|
||||
return $this->getResultFail($e->getMessage());
|
||||
return $this->getResultFail_process($e->getMessage());
|
||||
}
|
||||
}
|
||||
//단일필드작업기능
|
||||
@ -281,10 +281,10 @@ abstract class CommonController extends BaseController
|
||||
// dd($formDatas);
|
||||
$this->entity = $this->toggle_process($entity, $formDatas);
|
||||
$this->_db->transCommit();
|
||||
return $this->getResultSuccess();
|
||||
return $this->getResultSuccess_process();
|
||||
} catch (\Exception $e) {
|
||||
$this->_db->transRollback();
|
||||
return $this->getResultFail($e->getMessage());
|
||||
return $this->getResultFail_process($e->getMessage());
|
||||
}
|
||||
}
|
||||
//일괄처리작업기능
|
||||
@ -335,10 +335,10 @@ abstract class CommonController extends BaseController
|
||||
$this->entities = $entities;
|
||||
$this->_db->transCommit();
|
||||
LogCollector::debug(sprintf("%s에서 총 %s개중 %s개 일괄작업을 완료하였습니다.", __METHOD__, count($uids), count($this->entities)));
|
||||
return $this->getResultSuccess();
|
||||
return $this->getResultSuccess_process();
|
||||
} catch (\Exception $e) {
|
||||
$this->_db->transRollback();
|
||||
return $this->getResultFail($e->getMessage());
|
||||
return $this->getResultFail_process($e->getMessage());
|
||||
}
|
||||
}
|
||||
final public function delete(mixed $uid): RedirectResponse|string
|
||||
@ -355,10 +355,10 @@ abstract class CommonController extends BaseController
|
||||
}
|
||||
$this->delete_process($entity);
|
||||
$this->_db->transCommit();
|
||||
return $this->getResultSuccess();
|
||||
return $this->getResultSuccess_process();
|
||||
} catch (\Exception $e) {
|
||||
$this->_db->transRollback();
|
||||
return $this->getResultFail($e->getMessage());
|
||||
return $this->getResultFail_process($e->getMessage());
|
||||
}
|
||||
}
|
||||
//일괄삭제
|
||||
@ -386,10 +386,10 @@ abstract class CommonController extends BaseController
|
||||
$this->entities = $entities;
|
||||
$this->_db->transCommit();
|
||||
LogCollector::debug(sprintf("%s에서 총 %s개중 %s개 일괄삭제를 완료하였습니다.", __METHOD__, count($uids), count($this->entities)));
|
||||
return $this->getResultSuccess();
|
||||
return $this->getResultSuccess_process();
|
||||
} catch (\Exception $e) {
|
||||
$this->_db->transRollback();
|
||||
return $this->getResultFail($e->getMessage());
|
||||
return $this->getResultFail_process($e->getMessage());
|
||||
}
|
||||
}
|
||||
final public function view(string $uid): RedirectResponse|string
|
||||
@ -408,9 +408,9 @@ abstract class CommonController extends BaseController
|
||||
$this->entity = $this->view_process($entity);
|
||||
helper(['form']);
|
||||
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
return $this->getResultSuccess();
|
||||
return $this->getResultSuccess_process();
|
||||
} catch (\Exception $e) {
|
||||
return $this->getResultFail($e->getMessage());
|
||||
return $this->getResultFail_process($e->getMessage());
|
||||
}
|
||||
}
|
||||
//OUPUT Document 관련
|
||||
@ -446,7 +446,7 @@ abstract class CommonController extends BaseController
|
||||
case 'pdf':
|
||||
helper(['form']);
|
||||
$this->index_process();
|
||||
$html = $this->getResultSuccess();
|
||||
$html = $this->getResultSuccess_process();
|
||||
//data loading
|
||||
$reader = new Html();
|
||||
$loaded_data = $reader->loadFromString($html);
|
||||
@ -468,7 +468,7 @@ abstract class CommonController extends BaseController
|
||||
}
|
||||
return $this->response->download($full_path, null)->setFileName($file_name);
|
||||
} catch (\Exception $e) {
|
||||
return $this->getResultFail($e->getMessage());
|
||||
return $this->getResultFail_process($e->getMessage());
|
||||
}
|
||||
}
|
||||
//공통 기본 기능
|
||||
@ -514,7 +514,7 @@ abstract class CommonController extends BaseController
|
||||
return $validation;
|
||||
}
|
||||
//Process Result처리
|
||||
protected function getResultFail(string $message = MESSAGES["FAILED"]): RedirectResponse
|
||||
protected function getResultFail_process(string $message = MESSAGES["FAILED"]): RedirectResponse
|
||||
{
|
||||
LogCollector::debug($message);
|
||||
$this->getMyLogService()->save($this->getService()->getClassName(), $this->getAction(), $message, $this->getMyAuth()->getUIDByAuthInfo());
|
||||
@ -523,7 +523,7 @@ abstract class CommonController extends BaseController
|
||||
}
|
||||
return redirect()->to($this->getMyAuth()->popPreviousUrl())->with('error', $message);
|
||||
}
|
||||
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
protected function getResultSuccess_process(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
{
|
||||
helper(['form']);
|
||||
switch ($this->getControlDatas('action')) {
|
||||
@ -711,10 +711,10 @@ abstract class CommonController extends BaseController
|
||||
$this->getService()->setOffset(($this->page - 1) * $this->per_page);
|
||||
$this->index_condition_process();
|
||||
$this->entities = $this->index_process();
|
||||
return $this->getResultSuccess();
|
||||
return $this->getResultSuccess_process();
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
// return $this->getResultFail($e->getMessage());
|
||||
// return $this->getResultFail_process($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ class ServerEntity extends EquipmentEntity
|
||||
const STATUS_FORBIDDEN = "forbidden";
|
||||
const DEFAULT_STATUS = self::STATUS_AVAILABLE;
|
||||
|
||||
public function setServerPartEntity(string $partType, ServerPartENtity $entity): void
|
||||
public function addServerPartEntity(string $partType, ServerPartENtity $entity): void
|
||||
{
|
||||
if (!array_key_exists('serverPartEntities', $this->attributes)) {
|
||||
$this->attributes['serverPartEntities'] = [];
|
||||
|
||||
@ -22,14 +22,40 @@ class ServerHelper extends EquipmentHelper
|
||||
case 'CPU':
|
||||
case 'RAM':
|
||||
case 'DISK':
|
||||
echo $field . ":" . $viewDatas['entity']->getServerPartEntity($field)->getPartInfoUID();
|
||||
case 'OS':
|
||||
case 'SOFTWARE':
|
||||
case 'DB':
|
||||
$form = $this->form_dropdown_custom($field, old($field) ?? (array_key_exists('entity', $viewDatas) ? $viewDatas['entity']->getServerPartEntity($field)->getPartInfoUID() : null), $viewDatas, $extras);
|
||||
$form .= " " . form_dropdown("{$field}_cnt", $viewDatas['serverpartinfo_cnt_range'], old("{$field}_cnt") ?? $viewDatas['entity']->getServerPartEntity($field)->getCnt() ?? 1) . "개";
|
||||
$form = $this->form_dropdown_custom(
|
||||
$field,
|
||||
old($field) ?? (array_key_exists('entity', $viewDatas) ? $viewDatas['entity']->getServerPartEntity($field)->getPartInfoUID() : null),
|
||||
$viewDatas,
|
||||
$extras
|
||||
);
|
||||
$cntValue = old("{$field}_cnt");
|
||||
if ($cntValue === null) {
|
||||
$cntValue = isset($viewDatas['entity'])
|
||||
? ($viewDatas['entity']->getServerPartEntity($field)?->getCnt() ?? 1)
|
||||
: 1;
|
||||
}
|
||||
$form .= " " . form_dropdown(
|
||||
"{$field}_cnt",
|
||||
$viewDatas['serverpartinfo_cnt_range'],
|
||||
$cntValue
|
||||
) . "개";
|
||||
if (in_array($field, ['DISK'])) {
|
||||
$form .= form_dropdown("{$field}_extra", $viewDatas['serverpartinfo_extra_options'], old("{$field}_extra") ?? $viewDatas['entity']->getServerPartEntity($field)->getExtra() ?? 1);
|
||||
$extraValue = old("{$field}_extra");
|
||||
|
||||
if ($extraValue === null) {
|
||||
$extraValue = isset($viewDatas['entity'])
|
||||
? ($viewDatas['entity']->getServerPartEntity($field)?->getExtra() ?? 1)
|
||||
: 1;
|
||||
}
|
||||
|
||||
$form .= form_dropdown(
|
||||
"{$field}_extra",
|
||||
$viewDatas['serverpartinfo_extra_options'],
|
||||
$extraValue
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'ipinfo_uid':
|
||||
@ -99,4 +125,40 @@ class ServerHelper extends EquipmentHelper
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function getListButton(string $action, string $label, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
switch ($action) {
|
||||
case 'modify':
|
||||
if (!$this->getMyAuth()->isAccessRole(['security'])) {
|
||||
$action = $viewDatas['entity']->getCode();
|
||||
} else {
|
||||
$action = parent::getListButton($action, $viewDatas['entity']->getCode(), $viewDatas, $extras);
|
||||
}
|
||||
break;
|
||||
case 'create':
|
||||
case 'delete':
|
||||
case 'batchjob':
|
||||
case 'batchjob_delete':
|
||||
$action = !$this->getMyAuth()->isAccessRole(['security']) ? "" : parent::getListButton($action, $label, $viewDatas, $extras);
|
||||
break;
|
||||
case 'history':
|
||||
$extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras];
|
||||
$action = form_label(
|
||||
ICONS['HISTORY'],
|
||||
$action,
|
||||
[
|
||||
"data-src" => "/admin/customer/clienthistory?clientinfo_uid={$viewDatas['entity']->getPK()}",
|
||||
"data-bs-toggle" => "modal",
|
||||
"data-bs-target" => "#index_action_form",
|
||||
...$extras
|
||||
]
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$action = parent::getListButton($action, $label, $viewDatas, $extras);
|
||||
break;
|
||||
}
|
||||
return $action;
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,6 +74,7 @@ abstract class CommonModel extends Model
|
||||
$data[8] = chr(ord($data[8]) & 0x3f | 0x80); // variant 10
|
||||
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
|
||||
}
|
||||
//기본 기능
|
||||
public function getFormFieldRule(string $action, string $field): string
|
||||
{
|
||||
if (is_array($field)) {
|
||||
@ -112,18 +113,16 @@ abstract class CommonModel extends Model
|
||||
return $rule;
|
||||
}
|
||||
// create, modify 직전 작업용 작업
|
||||
protected function convert_process(string $action, string $field, array $formDatas): mixed
|
||||
protected function convertFormDatas(string $action, string $field, array $formDatas): mixed
|
||||
{
|
||||
$convertedData = null;
|
||||
// 필드 값 존재 여부 확인
|
||||
$hasValue = array_key_exists($field, $formDatas);
|
||||
$value = $hasValue ? $formDatas[$field] : null;
|
||||
$value = array_key_exists($field, $formDatas) ? $formDatas[$field] : null;
|
||||
switch ($field) {
|
||||
case $this->getPKField():
|
||||
// PK 값이 없으면 UUID-like 값 생성
|
||||
if (!$hasValue || empty($value)) {
|
||||
// 수동입력인 경우
|
||||
if (!$this->useAutoIncrement) {
|
||||
$randomBytes = bin2hex(random_bytes(32));
|
||||
$convertedData = sprintf(
|
||||
$value = sprintf(
|
||||
'%08s-%04s-%04x-%04x-%12s',
|
||||
substr($randomBytes, 0, 8),
|
||||
substr($randomBytes, 8, 4),
|
||||
@ -131,8 +130,6 @@ abstract class CommonModel extends Model
|
||||
substr($randomBytes, 16, 4),
|
||||
substr($randomBytes, 20, 12)
|
||||
);
|
||||
} else {
|
||||
$convertedData = $value;
|
||||
}
|
||||
break;
|
||||
case "editor":
|
||||
@ -142,43 +139,33 @@ abstract class CommonModel extends Model
|
||||
case "history":
|
||||
// textarea 계열은 XSS 방지
|
||||
if ($value === '' || $value === null) {
|
||||
$convertedData = null; // 기본적으로 null
|
||||
//값이 없거나 빈데이터면 아무것도 하지 않음
|
||||
} elseif ($value === ' ') {
|
||||
$convertedData = ''; // 공백 하나 → 의도적인 빈칸 저장
|
||||
$value = ''; // 공백 하나를 넣어서 의도적인 빈칸 저장
|
||||
} else {
|
||||
$convertedData = htmlentities($value, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if ($value === '' || $value === null) {
|
||||
if ($action === 'insert') {
|
||||
// INSERT → unset 해서 DB default 사용
|
||||
return null;
|
||||
}
|
||||
if ($action === 'update') {
|
||||
// UPDATE → 기본은 null 처리
|
||||
$convertedData = null;
|
||||
}
|
||||
} elseif ($value === ' ') {
|
||||
// 공백 하나 → 빈칸으로 저장
|
||||
$convertedData = '';
|
||||
} else {
|
||||
$convertedData = $value;
|
||||
$value = htmlentities($value, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $convertedData;
|
||||
return $value;
|
||||
}
|
||||
|
||||
protected function create_process(array $formDatas): mixed
|
||||
public function create(array $formDatas): mixed
|
||||
{
|
||||
$pkField = $this->getPKField();
|
||||
// primaryKey가 자동입력이 아니면
|
||||
if (!$this->useAutoIncrement) {
|
||||
$formDatas[$pkField] = $this->generateUUID();
|
||||
// LogCollector::debug("입력내용");
|
||||
// LogCollector::debug(var_export($formDatas, true));
|
||||
$convertedFormDatas = [];
|
||||
foreach ($this->allowedFields as $field) {
|
||||
$value = $this->convertFormDatas(
|
||||
__FUNCTION__,
|
||||
$field,
|
||||
$formDatas
|
||||
);
|
||||
if ($value !== null) {
|
||||
$convertedFormDatas[$field] = $value;
|
||||
}
|
||||
}
|
||||
// 최종 저장 시 오류 발생하면
|
||||
if (!$this->save($formDatas)) {
|
||||
if (!$this->save($convertedFormDatas)) {
|
||||
$message = sprintf(
|
||||
"\n------%s 오류-----\n%s\n%s\n------------------------------\n",
|
||||
__METHOD__,
|
||||
@ -192,26 +179,33 @@ abstract class CommonModel extends Model
|
||||
if (!class_exists($this->returnType)) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 returnType: {$this->returnType}이 정의되지 않았습니다.");
|
||||
}
|
||||
$entity = new $this->returnType($formDatas);
|
||||
$entity = new $this->returnType($convertedFormDatas);
|
||||
// primaryKey가 자동입력이면
|
||||
if ($this->useAutoIncrement) {
|
||||
$pkField = $this->getPKField();
|
||||
$entity->$pkField = $this->getInsertID();
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
final public function create(array $formDatas): mixed
|
||||
public function modify(mixed $entity, array $formDatas): mixed
|
||||
{
|
||||
// LogCollector::debug("입력내용");
|
||||
// 저장하기 전에 데이터 값 변경이 필요한 Field
|
||||
// LogCollector::debug("[{$entity->getPK()}/{$entity->getTitle()}] 변경 전 내용");
|
||||
// LogCollector::debug(var_export($formDatas, true));
|
||||
foreach (array_keys($formDatas) as $field) {
|
||||
if (array_key_exists($field, $formDatas)) {
|
||||
$formDatas[$field] = $this->convert_process(__FUNCTION__, $field, $formDatas);
|
||||
// LogCollector::debug(var_export($entity->toArray(), true));
|
||||
|
||||
foreach ($this->allowedFields as $field) {
|
||||
$value = $this->convertFormDatas(
|
||||
__FUNCTION__,
|
||||
$field,
|
||||
$formDatas
|
||||
);
|
||||
if ($value !== null) {
|
||||
$entity->$field = $value;
|
||||
}
|
||||
}
|
||||
return $this->create_process($formDatas);
|
||||
}
|
||||
protected function modify_process(mixed $entity): mixed
|
||||
{
|
||||
//수정일추가
|
||||
$entity->setUpdatedAt(date("Y-m-d H:i:s"));
|
||||
// 최종 저장 시 오류 발생하면
|
||||
if (!$this->save($entity)) {
|
||||
$message = sprintf(
|
||||
@ -224,22 +218,4 @@ abstract class CommonModel extends Model
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
final public function modify(mixed $entity, array $formDatas): mixed
|
||||
{
|
||||
// 저장하기 전에 데이터 값 변경이 필요한 Field
|
||||
// LogCollector::debug("[{$entity->getPK()}/{$entity->getTitle()}] 변경 전 내용");
|
||||
// LogCollector::debug(var_export($formDatas, true));
|
||||
// LogCollector::debug(var_export($entity->toArray(), true));
|
||||
foreach (array_keys($formDatas) as $field) {
|
||||
if (array_key_exists($field, $formDatas)) {
|
||||
$entity->$field = $this->convert_process(__FUNCTION__, $field, $formDatas);
|
||||
}
|
||||
}
|
||||
//수정일추가
|
||||
$entity->setUpdatedAt(date("Y-m-d H:i:s"));
|
||||
// LogCollector::debug("[{$entity->getPK()}/{$entity->getTitle()}] 변경 후 내용");
|
||||
// LogCollector::debug(var_export($entity->toArray(), true));
|
||||
// dd($entity);
|
||||
return $this->modify_process($entity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@ class AccountModel extends CustomerModel
|
||||
"issue_at",
|
||||
"amount",
|
||||
"status",
|
||||
"updated_at"
|
||||
];
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@ -25,7 +25,8 @@ class ClientModel extends CustomerModel
|
||||
"account_balance",
|
||||
"coupon_balance",
|
||||
"point_balance",
|
||||
"status"
|
||||
"status",
|
||||
"updated_at"
|
||||
];
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@ -18,6 +18,7 @@ class CouponModel extends CustomerModel
|
||||
"title",
|
||||
"cnt",
|
||||
"status",
|
||||
"updated_at"
|
||||
];
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@ -22,7 +22,8 @@ class PaymentModel extends CustomerModel
|
||||
"billing",
|
||||
"billing_at",
|
||||
"pay",
|
||||
"status"
|
||||
"status",
|
||||
"updated_at"
|
||||
];
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@ -18,6 +18,7 @@ class PointModel extends CustomerModel
|
||||
"title",
|
||||
"amount",
|
||||
"status",
|
||||
"updated_at"
|
||||
];
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@ -27,6 +27,7 @@ class ServiceModel extends CustomerModel
|
||||
"end_at",
|
||||
"history",
|
||||
"status",
|
||||
"updated_at"
|
||||
];
|
||||
public function __construct()
|
||||
{
|
||||
@ -66,7 +67,7 @@ class ServiceModel extends CustomerModel
|
||||
return $rule;
|
||||
}
|
||||
//입력전 코드처리
|
||||
protected function create_process(array $formDatas): ServiceEntity
|
||||
protected function create_process(array $formDatas): string|int
|
||||
{
|
||||
$formDatas['code'] = "s" . time();
|
||||
return parent::create_process($formDatas);
|
||||
|
||||
@ -23,6 +23,7 @@ class CSModel extends EquipmentModel
|
||||
"price",
|
||||
'amount',
|
||||
"status",
|
||||
"updated_at"
|
||||
];
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@ -22,6 +22,7 @@ class IPModel extends EquipmentModel
|
||||
"price",
|
||||
"amount",
|
||||
"status",
|
||||
"updated_at"
|
||||
];
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@ -19,6 +19,7 @@ class LineModel extends EquipmentModel
|
||||
"start_at",
|
||||
"end_at",
|
||||
"status",
|
||||
"updated_at"
|
||||
];
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@ -17,6 +17,7 @@ class PartModel extends EquipmentModel
|
||||
"title",
|
||||
"price",
|
||||
"status",
|
||||
"updated_at"
|
||||
];
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@ -24,6 +24,7 @@ class ServerModel extends EquipmentModel
|
||||
"manufactur_at",
|
||||
"format_at",
|
||||
"status",
|
||||
"updated_at"
|
||||
];
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@ -16,10 +16,12 @@ class ServerPartModel extends EquipmentModel
|
||||
"partinfo_uid",
|
||||
"serverinfo_uid",
|
||||
"serviceinfo_uid",
|
||||
"type",
|
||||
"billing",
|
||||
"amount",
|
||||
"cnt",
|
||||
"extra",
|
||||
"updated_at"
|
||||
];
|
||||
public function __construct()
|
||||
{
|
||||
@ -41,6 +43,9 @@ class ServerPartModel extends EquipmentModel
|
||||
case "serviceinfo_uid":
|
||||
$rule = "permit_empty|numeric";
|
||||
break;
|
||||
case "type":
|
||||
$rule = "required|trim|string";
|
||||
break;
|
||||
default:
|
||||
$rule = parent::getFormFieldRule($action, $field);
|
||||
break;
|
||||
|
||||
@ -19,6 +19,7 @@ class SwitchModel extends EquipmentModel
|
||||
"serverinfo_uid",
|
||||
"code",
|
||||
"status",
|
||||
"updated_at"
|
||||
];
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@ -55,19 +55,21 @@ class UserModel extends CommonModel
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
protected function convert_process(string $action, string $field, array $formDatas): mixed
|
||||
protected function convertFormDatas(string $action, string $field, array $formDatas): mixed
|
||||
{
|
||||
// 필드 값 존재 여부 확인
|
||||
$value = array_key_exists($field, $formDatas) ? $formDatas[$field] : null;
|
||||
switch ($field) {
|
||||
case "passwd":
|
||||
$convertedData = password_hash($formDatas[$field], PASSWORD_DEFAULT);
|
||||
$value = password_hash($value, PASSWORD_DEFAULT);
|
||||
break;
|
||||
case "confirmpassword":
|
||||
$convertedData = password_hash($formDatas[$field], PASSWORD_DEFAULT);
|
||||
$value = password_hash($value, PASSWORD_DEFAULT);
|
||||
break;
|
||||
default:
|
||||
$convertedData = parent::convert_process($action, $field, $formDatas);
|
||||
$value = parent::convertFormDatas($action, $field, $formDatas);
|
||||
break;
|
||||
}
|
||||
return $convertedData;
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,11 +44,6 @@ abstract class CommonService
|
||||
}
|
||||
return $this->_model;
|
||||
}
|
||||
//Entity별로 작업처리시
|
||||
protected function getEntity_process(mixed $entity): mixed
|
||||
{
|
||||
return $entity;
|
||||
}
|
||||
final public function getEntity(mixed $where, ?string $message = null): mixed
|
||||
{
|
||||
try {
|
||||
@ -66,20 +61,6 @@ abstract class CommonService
|
||||
throw new \Exception($message);
|
||||
}
|
||||
}
|
||||
//entities를 가져오는 조건
|
||||
protected function getEntities_process(mixed $where = null, array $columns = ['*']): array
|
||||
{
|
||||
if ($where) {
|
||||
$this->getModel()->where($where);
|
||||
}
|
||||
//출력순서 정의
|
||||
$this->setOrderBy();
|
||||
$entities = [];
|
||||
foreach ($this->getModel()->select(implode(',', $columns))->findAll() as $entity) {
|
||||
$entities[$entity->getPK()] = $this->getEntity_process($entity);
|
||||
}
|
||||
return $entities;
|
||||
}
|
||||
final public function getEntities(mixed $where = null, array $columns = ['*']): array
|
||||
{
|
||||
try {
|
||||
@ -98,6 +79,37 @@ abstract class CommonService
|
||||
throw new \Exception($message);
|
||||
}
|
||||
} //
|
||||
//삭제
|
||||
final public function delete(mixed $entity): mixed
|
||||
{
|
||||
$result = $this->getModel()->delete($entity->getPK());
|
||||
if (!$result) {
|
||||
$message = sprintf(
|
||||
"\n------%s SQL오류-----\n%s\n------------------------------\n",
|
||||
__FUNCTION__,
|
||||
$this->getModel()->getLastQuery()
|
||||
);
|
||||
LogCollector::error($message);
|
||||
throw new \Exception($message);
|
||||
}
|
||||
LogCollector::info("[{$entity->getTitle()}]" . MESSAGES["DELETED"] . ":");
|
||||
return $entity;
|
||||
}
|
||||
//Index용
|
||||
final public function getTotalCount(): int
|
||||
{
|
||||
return $this->getModel()->countAllResults(false);
|
||||
}
|
||||
//Limit처리
|
||||
final public function setLimit(int $per_page): void
|
||||
{
|
||||
$this->getModel()->limit($per_page);
|
||||
}
|
||||
//Offset처리
|
||||
final public function setOffset(int $offset): void
|
||||
{
|
||||
$this->getModel()->offset($offset);
|
||||
}
|
||||
final public function isIPAddress(string $ip, $type = false): bool
|
||||
{
|
||||
switch ($type) {
|
||||
@ -116,8 +128,27 @@ abstract class CommonService
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
//기본 기능부분
|
||||
|
||||
//기본기능
|
||||
//개별기능
|
||||
//Entity별로 작업처리시
|
||||
protected function getEntity_process(mixed $entity): mixed
|
||||
{
|
||||
return $entity;
|
||||
}
|
||||
//entities를 가져오는 조건
|
||||
protected function getEntities_process(mixed $where = null, array $columns = ['*']): array
|
||||
{
|
||||
if ($where) {
|
||||
$this->getModel()->where($where);
|
||||
}
|
||||
//출력순서 정의
|
||||
$this->setOrderBy();
|
||||
$entities = [];
|
||||
foreach ($this->getModel()->select(implode(',', $columns))->findAll() as $entity) {
|
||||
$entities[$entity->getPK()] = $this->getEntity_process($entity);
|
||||
}
|
||||
return $entities;
|
||||
}
|
||||
//FieldForm관련용
|
||||
public function getViewFields(): array
|
||||
{
|
||||
@ -162,49 +193,21 @@ abstract class CommonService
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
//생성
|
||||
public function create(array $formDatas): mixed
|
||||
{
|
||||
$entity = $this->getModel()->create($formDatas);
|
||||
LogCollector::info("[{$entity->getTitle()}]" . MESSAGES["CREATED"] . ":");
|
||||
return $entity;
|
||||
}
|
||||
//수정
|
||||
public function modify(mixed $entity, array $formDatas): mixed
|
||||
{
|
||||
$entity = $this->getModel()->modify($entity, $formDatas);
|
||||
LogCollector::info("[{$entity->getTitle()}]" . MESSAGES["UPDATED"] . ":");
|
||||
return $entity;
|
||||
}
|
||||
public function delete(mixed $entity): mixed
|
||||
{
|
||||
$result = $this->getModel()->delete($entity->getPK());
|
||||
if (!$result) {
|
||||
$message = sprintf(
|
||||
"\n------%s SQL오류-----\n%s\n------------------------------\n",
|
||||
__FUNCTION__,
|
||||
$this->getModel()->getLastQuery()
|
||||
);
|
||||
LogCollector::error($message);
|
||||
throw new \Exception($message);
|
||||
}
|
||||
LogCollector::info("[{$entity->getTitle()}]" . MESSAGES["DELETED"] . ":");
|
||||
return $entity;
|
||||
}
|
||||
|
||||
//List 검색용
|
||||
final public function getTotalCount(): int
|
||||
{
|
||||
return $this->getModel()->countAllResults(false);
|
||||
}
|
||||
//Limit처리
|
||||
final public function setLimit(int $per_page): void
|
||||
{
|
||||
$this->getModel()->limit($per_page);
|
||||
}
|
||||
//Offset처리
|
||||
final public function setOffset(int $offset): void
|
||||
{
|
||||
$this->getModel()->offset($offset);
|
||||
}
|
||||
////Index 검색용
|
||||
//FormFilter 조건절 처리
|
||||
public function index_condition_filterField(string $field, mixed $filter_value): void
|
||||
{
|
||||
|
||||
@ -4,6 +4,7 @@ namespace App\Services\Equipment;
|
||||
|
||||
use App\Entities\Equipment\IPEntity;
|
||||
use App\Entities\Equipment\LineEntity;
|
||||
use App\Entities\Equipment\ServerEntity;
|
||||
use App\Models\Equipment\IPModel;
|
||||
use App\Services\Equipment\EquipmentService;
|
||||
use App\Services\Equipment\LineService;
|
||||
@ -87,6 +88,7 @@ class IPService extends EquipmentService
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
//회선정보에 따른 IP생성
|
||||
public function createByLineInfo(LineEntity $entity, string $ip): IPEntity
|
||||
{
|
||||
$formDatas = [
|
||||
@ -96,6 +98,32 @@ class IPService extends EquipmentService
|
||||
];
|
||||
return $this->create($formDatas);
|
||||
}
|
||||
private function getFormDatasByServer(ServerEntity $serverEntity, array $formDatas): array
|
||||
{
|
||||
$temps = [
|
||||
"serverinfo_uid" => $serverEntity->getPK(),
|
||||
"clientinfo_uid" => $serverEntity->getClientInfoUID(),
|
||||
"serviceinfo_uid" => $serverEntity->getServiceInfoUID(),
|
||||
"status" => IPEntity::STATUS_OCCUPIED
|
||||
];
|
||||
return $temps;
|
||||
}
|
||||
//생성
|
||||
public function createByServer(ServerEntity $serverEntity, array $formDatas): IPEntity
|
||||
{
|
||||
$entity = $this->getEntity($formDatas("ipinfo_uid"));
|
||||
if (!$entity) {
|
||||
throw new \Exception("{$formDatas("ipinfo_uid")}에 대한 IP정보를 찾을수 없습니다.");
|
||||
}
|
||||
$entity = parent::modify(
|
||||
$entity,
|
||||
$this->getFormDatasByServer(
|
||||
$serverEntity,
|
||||
$formDatas
|
||||
)
|
||||
);
|
||||
return $entity;
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(mixed $field = null, mixed $value = null): void
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services\Equipment;
|
||||
|
||||
use App\Entities\Equipment\ServerEntity;
|
||||
use App\Entities\Equipment\ServerPartEntity;
|
||||
use App\Models\Equipment\ServerPartModel;
|
||||
use App\Services\Equipment\EquipmentService;
|
||||
@ -21,6 +22,7 @@ class ServerPartService extends EquipmentService
|
||||
"partinfo_uid",
|
||||
"serverinfo_uid",
|
||||
"serviceinfo_uid",
|
||||
"type",
|
||||
"billing",
|
||||
"amount",
|
||||
"cnt",
|
||||
@ -30,6 +32,7 @@ class ServerPartService extends EquipmentService
|
||||
"partinfo_uid",
|
||||
"serverinfo_uid",
|
||||
"serviceinfo_uid",
|
||||
"type"
|
||||
],
|
||||
];
|
||||
}
|
||||
@ -86,4 +89,34 @@ class ServerPartService extends EquipmentService
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
private function getFormDatasByServer(ServerEntity $serverEntity, string $partType, array $formDatas): array
|
||||
{
|
||||
$temps = [
|
||||
"partinfo_uid" => $formDatas(["serverpartinfo_{$partType}_uid"]),
|
||||
"serverinfo_uid" => $serverEntity->getPK(),
|
||||
"serviceinfo_uid" => $serverEntity->getServiceInfoUID(),
|
||||
"type" => $partType,
|
||||
"billing" => $formDatas['billing'] ?? ServerPartENtity::DEFAULT_BILLING,
|
||||
"amount" => $formDatas["amount"] ?? 0,
|
||||
"cnt" => $formDatas["serverpartinfo_{$partType}_uid_cnt"] ?? 1,
|
||||
"extra" => $formDatas["serverpartinfo_{$partType}_uid_extra"] ?? ""
|
||||
];
|
||||
return $temps;
|
||||
}
|
||||
//생성
|
||||
public function createByServer(ServerEntity $serverEntity, array $formDatas): array
|
||||
{
|
||||
$entities = [];
|
||||
foreach (SERVER['PARTTYPES'] as $partType) {
|
||||
$entities[] = parent::create(
|
||||
$this->getFormDatasByServer(
|
||||
$serverEntity,
|
||||
$partType,
|
||||
$formDatas
|
||||
)
|
||||
);
|
||||
}
|
||||
return $entities;
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,13 +133,17 @@ class ServerService extends EquipmentService
|
||||
foreach (SERVER['PARTTYPES'] as $partType) {
|
||||
$serverPartEnty = $this->getServerPartService()->getEntity(['serverinfo_uid' => $entity->getPK(), 'type' => $partType]);
|
||||
if ($serverPartEnty) {
|
||||
$entity->setServerPartEntity($partType, $serverPartEnty);
|
||||
$entity->addServerPartEntity($partType, $serverPartEnty);
|
||||
}
|
||||
}
|
||||
//서버 IP정보 정의
|
||||
$entity->setIPEntities($this->getIPService()->getEntities(['serverinfo_uid' => $entity->getPK()]));
|
||||
foreach ($this->getIPService()->getEntities(['serverinfo_uid' => $entity->getPK()]) as $ipEntity) {
|
||||
$entity->addIPEntity($ipEntity);
|
||||
}
|
||||
//서버 CS정보 정의
|
||||
$entity->setCSEntities($this->getCSService()->getEntities(['serverinfo_uid' => $entity->getPK()]));
|
||||
foreach ($this->getCSService()->getEntities(['serverinfo_uid' => $entity->getPK()]) as $csEntity) {
|
||||
$entity->addCSEntity($csEntity);
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
//기본 기능부분
|
||||
@ -196,6 +200,19 @@ class ServerService extends EquipmentService
|
||||
throw new \Exception("Server코드[{$formDatas['code']}의 형식이 맞지않습니다");
|
||||
}
|
||||
}
|
||||
//생성
|
||||
public function create(array $formDatas): ServerEntity
|
||||
{
|
||||
$entity = parent::create($formDatas);
|
||||
//ServerPart정보 생성
|
||||
foreach ($this->getServerPartService()->createByServer($entity, $formDatas) as $serverPartEntity) {
|
||||
$entity->addServerPartEntity($serverPartEntity->getType(), $serverPartEntity);
|
||||
};
|
||||
//IP정보 생성
|
||||
$entity->addIPEntity($this->getIPService()->createByServer($entity, $formDatas));
|
||||
return $entity;
|
||||
}
|
||||
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(mixed $field = null, mixed $value = null): void
|
||||
|
||||
@ -77,6 +77,7 @@ class MyLogService extends CommonService
|
||||
'title' => sprintf("%s->%s %s", $class, $method, $title),
|
||||
'content' => LogCollector::dump(),
|
||||
];
|
||||
// dd($formDatas);
|
||||
LogCollector::clear();
|
||||
return $this->create($formDatas);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user