dbms_init...1
This commit is contained in:
parent
112f304d09
commit
052f0e2145
@ -3,12 +3,13 @@
|
|||||||
namespace App\Controllers\Admin\Customer;
|
namespace App\Controllers\Admin\Customer;
|
||||||
|
|
||||||
use App\Controllers\Admin\AdminController;
|
use App\Controllers\Admin\AdminController;
|
||||||
|
use App\Entities\Equipment\Part\IpEntity;
|
||||||
|
use App\Services\Customer\ClientService;
|
||||||
use CodeIgniter\HTTP\RequestInterface;
|
use CodeIgniter\HTTP\RequestInterface;
|
||||||
|
|
||||||
use CodeIgniter\HTTP\ResponseInterface;
|
use CodeIgniter\HTTP\ResponseInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
use App\Services\Customer\ClientService;
|
|
||||||
|
|
||||||
abstract class CustomerController extends AdminController
|
abstract class CustomerController extends AdminController
|
||||||
{
|
{
|
||||||
private ?ClientService $_clientService = null;
|
private ?ClientService $_clientService = null;
|
||||||
@ -30,9 +31,23 @@ abstract class CustomerController extends AdminController
|
|||||||
{
|
{
|
||||||
//$item_type(CPU,RAM,STORAGE등)에 따라 선언된 getFormFieldOption용
|
//$item_type(CPU,RAM,STORAGE등)에 따라 선언된 getFormFieldOption용
|
||||||
foreach (SERVICE_ITEM_TYPES as $item_type => $label) {
|
foreach (SERVICE_ITEM_TYPES as $item_type => $label) {
|
||||||
|
if ($item_type == 'IP') {
|
||||||
|
$occupied_ips = [];
|
||||||
|
$forbidden_ips = [];
|
||||||
|
}
|
||||||
$options = [];
|
$options = [];
|
||||||
foreach ($this->getService()->getEquipmentService($item_type)->getEntities() as $entity) {
|
foreach ($this->getService()->getEquipmentService($item_type)->getEntities() as $entity) {
|
||||||
$options[$entity->getPK()] = $entity->getTitle();
|
$options[$entity->getPK()] = $entity->getTitle();
|
||||||
|
if ($item_type == 'IP') {
|
||||||
|
if ($entity->getStatus() === IpEntity::STATUS_OCCUPIED) {
|
||||||
|
$occupied_ips[] = $entity->getPK();
|
||||||
|
}
|
||||||
|
if ($entity->getStatus() === IpEntity::STATUS_FORBIDDEN) {
|
||||||
|
$forbidden_ips[] = $entity->getPK();
|
||||||
|
}
|
||||||
|
$this->occupied_ips = $occupied_ips;
|
||||||
|
$this->forbidden_ips = $forbidden_ips;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->setFilterFieldOption($item_type, $options);
|
$this->setFilterFieldOption($item_type, $options);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -107,7 +107,7 @@ class ServicePaymentController extends CustomerController
|
|||||||
private function getServices(ServiceEntity $serviceEntity): array
|
private function getServices(ServiceEntity $serviceEntity): array
|
||||||
{
|
{
|
||||||
$temps = [
|
$temps = [
|
||||||
'serial' => $serviceEntity->getSerialCode(),
|
'code' => $serviceEntity->getTitle(),
|
||||||
'billing_at' => $serviceEntity->getBillingAt(),
|
'billing_at' => $serviceEntity->getBillingAt(),
|
||||||
'items' => []
|
'items' => []
|
||||||
];
|
];
|
||||||
|
|||||||
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Controllers\Admin\Equipment\Part;
|
namespace App\Controllers\Admin\Equipment\Part;
|
||||||
|
|
||||||
use CodeIgniter\HTTP\RequestInterface;
|
|
||||||
use CodeIgniter\HTTP\ResponseInterface;
|
|
||||||
use Psr\Log\LoggerInterface;
|
|
||||||
|
|
||||||
use App\Helpers\Equipment\Part\IpHelper;
|
use App\Helpers\Equipment\Part\IpHelper;
|
||||||
use App\Services\Equipment\Part\IpService;
|
use App\Services\Equipment\Part\IpService;
|
||||||
|
|
||||||
use App\Services\Equipment\Part\LineService;
|
use App\Services\Equipment\Part\LineService;
|
||||||
|
use CodeIgniter\HTTP\RequestInterface;
|
||||||
|
|
||||||
|
use CodeIgniter\HTTP\ResponseInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class IpController extends PartController
|
class IpController extends PartController
|
||||||
{
|
{
|
||||||
|
|||||||
@ -25,7 +25,7 @@ class ServiceEntity extends CustomerEntity
|
|||||||
$this->_ownerEntity = $ownerEntity;
|
$this->_ownerEntity = $ownerEntity;
|
||||||
}
|
}
|
||||||
//타 객체정의 부분
|
//타 객체정의 부분
|
||||||
public function getSerialCode(): string
|
public function getTitle(): string
|
||||||
{
|
{
|
||||||
return "S" . $this->getPK();
|
return "S" . $this->getPK();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,4 +8,7 @@ class IpEntity extends PartEntity
|
|||||||
{
|
{
|
||||||
const PK = IpModel::PK;
|
const PK = IpModel::PK;
|
||||||
const TITLE = IpModel::TITLE;
|
const TITLE = IpModel::TITLE;
|
||||||
|
const STATUS_AVAILABLE = "default";
|
||||||
|
const STATUS_OCCUPIED = "occupied";
|
||||||
|
const STATUS_FORBIDDEN = "forbidden";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,6 +29,22 @@ class ServiceItemHelper extends CustomerHelper
|
|||||||
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
|
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'IP':
|
||||||
|
if (!is_array($viewDatas['control']['filter_optons'][$field])) {
|
||||||
|
throw new \Exception(__METHOD__ . "에서 {$field}의 field_options가 array형태가 아닙니다.");
|
||||||
|
}
|
||||||
|
//CodeIgniter 4의 form_dropdown()은 options 배열로만 값을 받기 때문에, disabled 속성 같은 개별 옵션에 대한 HTML 속성 추가는 기본적으로 지원하지 않습니다.
|
||||||
|
$form_temps = ["<select name=\"{$field}\" class=\"select-field\"" . (isset($extras['onChange']) ? " onChange=\"{$extras['onChange']}\"" : "") . ">"];
|
||||||
|
$form_temps[] = "<option value=\"\">" . lang($viewDatas['class_path'] . '.label.' . $field) . " 선택</option>";
|
||||||
|
foreach ($viewDatas['control']['filter_optons'][$field] as $key => $label) {
|
||||||
|
$disabled = in_array($key, $viewDatas['occupied_ips']) || in_array($key, $viewDatas['forbidden_ips']) ? 'disabled="disabled"' : '';
|
||||||
|
$selected = ($value === $key) ? 'selected="selected"' : '';
|
||||||
|
$form_temps[] = "<option value=\"{$key}\"{$selected} {$disabled}>{$label}</option>";
|
||||||
|
}
|
||||||
|
$form_temps[] = '</select>';
|
||||||
|
$form = implode("", $form_temps);
|
||||||
|
//dd($viewDatas['occupied_ips']);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
|
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -16,8 +16,8 @@ return [
|
|||||||
"STATUS" => [
|
"STATUS" => [
|
||||||
'default' => "사용가능",
|
'default' => "사용가능",
|
||||||
"pause" => "일시정지",
|
"pause" => "일시정지",
|
||||||
"occupied" => "사용중",
|
"occupied" => "서비스중",
|
||||||
"forbidden" => "사용금지됨",
|
"forbidden" => "금지됨",
|
||||||
"delete" => "삭제",
|
"delete" => "삭제",
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@ -8,14 +8,13 @@ class ServiceModel extends CustomerModel
|
|||||||
{
|
{
|
||||||
const TABLE = "serviceinfo";
|
const TABLE = "serviceinfo";
|
||||||
const PK = "uid";
|
const PK = "uid";
|
||||||
const TITLE = "title";
|
const TITLE = "uid";
|
||||||
protected $table = self::TABLE;
|
protected $table = self::TABLE;
|
||||||
protected $primaryKey = self::PK;
|
protected $primaryKey = self::PK;
|
||||||
protected $returnType = ServiceEntity::class;
|
protected $returnType = ServiceEntity::class;
|
||||||
protected $allowedFields = [
|
protected $allowedFields = [
|
||||||
"clientinfo_uid",
|
"clientinfo_uid",
|
||||||
"ownerinfo_uid",
|
"ownerinfo_uid",
|
||||||
"title",
|
|
||||||
"type",
|
"type",
|
||||||
"location",
|
"location",
|
||||||
"switch",
|
"switch",
|
||||||
@ -40,7 +39,6 @@ class ServiceModel extends CustomerModel
|
|||||||
case "ownerinfo_uid":
|
case "ownerinfo_uid":
|
||||||
$rule = "required|numeric";
|
$rule = "required|numeric";
|
||||||
break;
|
break;
|
||||||
case "title":
|
|
||||||
case "type":
|
case "type":
|
||||||
case "location":
|
case "location":
|
||||||
case "switch":
|
case "switch":
|
||||||
|
|||||||
49
app/Services/Customer/ServiceItem/ServiceItemIpService.php
Normal file
49
app/Services/Customer/ServiceItem/ServiceItemIpService.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Customer\ServiceItem;
|
||||||
|
|
||||||
|
use App\Entities\Equipment\Part\IpEntity;
|
||||||
|
use App\Services\Equipment\Part\IpService;
|
||||||
|
use CodeIgniter\HTTP\IncomingRequest;
|
||||||
|
|
||||||
|
class ServiceItemIpService extends ServiceItemService
|
||||||
|
{
|
||||||
|
protected ?IncomingRequest $request = null;
|
||||||
|
private ?IpService $_ipService = null;
|
||||||
|
public function __construct(?IncomingRequest $request = null)
|
||||||
|
{
|
||||||
|
parent::__construct($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIpService(): IpService
|
||||||
|
{
|
||||||
|
if (!$this->_ipService) {
|
||||||
|
$this->_ipService = new IpService($this->request);
|
||||||
|
}
|
||||||
|
return $this->_ipService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(array $formDatas, mixed $entity = null): ServiceItemEntity
|
||||||
|
{
|
||||||
|
//ip의 경우 서비스중으로 설정작업
|
||||||
|
$entity = parent::create($formDatas, $entity);
|
||||||
|
$this->getIpService()->setStatus($formDatas['code'], IpEntity::STATUS_OCCUPIED);
|
||||||
|
}
|
||||||
|
public function modify(mixed $entity, array $formDatas): ServiceEntity
|
||||||
|
{
|
||||||
|
//code가 기존과 다를경우 //toggle,batchjob의 경우 $formDatas에 code가 없을수도 있음
|
||||||
|
if (array_key_exists('code', $formDatas) && $formDatas['code'] !== $entity->getCode()) {
|
||||||
|
//code의 경우 기존code는 사용가능으로 설정작업
|
||||||
|
$this->getCodeService()->setStatus($entity->getCode(), IpEntity::STATUS_AVAILABLE);
|
||||||
|
//coded의 경우 변경된 code는 서비스중으로 설정작업
|
||||||
|
$this->getCodeService()->setStatus($formDatas['code'], IpEntity::STATUS_OCCUPIED);
|
||||||
|
}
|
||||||
|
return parent::modify($entity, $formDatas);
|
||||||
|
}
|
||||||
|
final public function delete(mixed $entity): bool
|
||||||
|
{
|
||||||
|
//code의 경우 기존code는 사용가능으로 설정작업
|
||||||
|
$this->getCodeService()->setStatus($entity->getCode(), IpEntity::STATUS_AVAILABLE);
|
||||||
|
return parent::delete($entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,12 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Services\Customer;
|
namespace App\Services\Customer\ServiceItem;
|
||||||
|
|
||||||
use CodeIgniter\HTTP\IncomingRequest;
|
|
||||||
|
|
||||||
use App\Models\Customer\ServiceItemModel;
|
|
||||||
use App\Entities\Customer\ServiceItemEntity;
|
use App\Entities\Customer\ServiceItemEntity;
|
||||||
|
use App\Models\Customer\ServiceItemModel;
|
||||||
|
use App\Services\Customer\CustomerService;
|
||||||
|
use App\Services\Customer\ServicePaymentService;
|
||||||
use App\Services\Customer\ServiceService;
|
use App\Services\Customer\ServiceService;
|
||||||
|
use CodeIgniter\HTTP\IncomingRequest;
|
||||||
|
|
||||||
class ServiceItemService extends CustomerService
|
class ServiceItemService extends CustomerService
|
||||||
{
|
{
|
||||||
@ -88,3 +89,29 @@ class ServiceItemService extends CustomerService
|
|||||||
return parent::delete($entity);
|
return parent::delete($entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// public function create(array $formDatas, mixed $entity = null): ServiceEntity
|
||||||
|
// {
|
||||||
|
// //code의 경우 서비스중으로 설정작업
|
||||||
|
// $this->getCodeService()->setStatus($formDatas['code'], CodeEntity::STATUS_OCCUPIED);
|
||||||
|
// return parent::create($formDatas, $entity);
|
||||||
|
// }
|
||||||
|
// public function modify(mixed $entity, array $formDatas): ServiceEntity
|
||||||
|
// {
|
||||||
|
// //code가 기존과 다를경우 //toggle,batchjob의 경우 $formDatas에 code가 없을수도 있음
|
||||||
|
// if (array_key_exists('code', $formDatas) && $formDatas['code'] !== $entity->getCode()) {
|
||||||
|
// //code의 경우 기존code는 사용가능으로 설정작업
|
||||||
|
// $this->getCodeService()->setStatus($entity->getCode(), CodeEntity::STATUS_AVAILABLE);
|
||||||
|
// //coded의 경우 변경된 code는 서비스중으로 설정작업
|
||||||
|
// $this->getCodeService()->setStatus($formDatas['code'], CodeEntity::STATUS_OCCUPIED);
|
||||||
|
// }
|
||||||
|
// return parent::modify($entity, $formDatas);
|
||||||
|
// }
|
||||||
|
// final public function delete(mixed $entity): bool
|
||||||
|
// {
|
||||||
|
// //code의 경우 기존code는 사용가능으로 설정작업
|
||||||
|
// $this->getCodeService()->setStatus($entity->getCode(), CodeEntity::STATUS_AVAILABLE);
|
||||||
|
// return parent::delete($entity);
|
||||||
|
// }
|
||||||
@ -8,7 +8,6 @@ use CodeIgniter\HTTP\IncomingRequest;
|
|||||||
|
|
||||||
use App\Entities\Equipment\CodeEntity;
|
use App\Entities\Equipment\CodeEntity;
|
||||||
use App\Services\Equipment\CodeService;
|
use App\Services\Equipment\CodeService;
|
||||||
use PhpOffice\PhpSpreadsheet\Calculation\Web\Service;
|
|
||||||
|
|
||||||
class ServiceService extends CustomerService
|
class ServiceService extends CustomerService
|
||||||
{
|
{
|
||||||
@ -32,7 +31,6 @@ class ServiceService extends CustomerService
|
|||||||
return [
|
return [
|
||||||
"clientinfo_uid",
|
"clientinfo_uid",
|
||||||
"ownerinfo_uid",
|
"ownerinfo_uid",
|
||||||
"title",
|
|
||||||
"type",
|
"type",
|
||||||
"location",
|
"location",
|
||||||
"switch",
|
"switch",
|
||||||
@ -53,7 +51,7 @@ class ServiceService extends CustomerService
|
|||||||
}
|
}
|
||||||
public function getIndexFields(): array
|
public function getIndexFields(): array
|
||||||
{
|
{
|
||||||
return ['clientinfo_uid', 'ownerinfo_uid', 'title', 'type', 'location', 'switch', 'code', 'raid', 'billing_at', 'start_at', 'updated_at', 'status'];
|
return ['clientinfo_uid', 'ownerinfo_uid', 'type', 'location', 'switch', 'code', 'raid', 'billing_at', 'start_at', 'updated_at', 'status'];
|
||||||
}
|
}
|
||||||
public function getCodeService(): CodeService
|
public function getCodeService(): CodeService
|
||||||
{
|
{
|
||||||
|
|||||||
@ -52,4 +52,15 @@ class IpService extends PartService
|
|||||||
$formDatas['status'] = DEFAULTS['STATUS'];
|
$formDatas['status'] = DEFAULTS['STATUS'];
|
||||||
return $this->create($formDatas, new IpEntity());
|
return $this->create($formDatas, new IpEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//상태변경
|
||||||
|
public function setStatus(int $uid, string $status): IpEntity
|
||||||
|
{
|
||||||
|
//code의 경우 사용가능/사용중으로 설정작업
|
||||||
|
$entity = $this->getEntity($uid);
|
||||||
|
if (!$entity) {
|
||||||
|
throw new \Exception("{$uid}에 대한 IP정보를 찾을수 없습니다.");
|
||||||
|
}
|
||||||
|
return $this->getModel()->modify($entity, ['status' => $status]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
<table class="table table-bordered text-center">
|
<table class="table table-bordered text-center">
|
||||||
<?php foreach ($entity['services'] as $service): ?>
|
<?php foreach ($entity['services'] as $service): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>서비스: <?= $service['serial'] ?></th>
|
<th>서비스: <?= $service['code'] ?></th>
|
||||||
<th class="text-end">지급기한: <?= $service['billing_at'] ?></th>
|
<th class="text-end">지급기한: <?= $service['billing_at'] ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -42,8 +42,8 @@
|
|||||||
<td>
|
<td>
|
||||||
<ol>
|
<ol>
|
||||||
<?php foreach ($service['items'] as $item): ?>
|
<?php foreach ($service['items'] as $item): ?>
|
||||||
<li class="text-start"><?= $item['item_type'] ?> :<?= $item['item_uid'] ?> [<?= number_format($item['amount']) ?>원]<\ /li>
|
<li class="text-start"><?= $item['item_type'] ?> :<?= $item['item_uid'] ?> [<?= number_format($item['amount']) ?>원]</li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ol>
|
</ol>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user