dbmsv2 init...1
This commit is contained in:
parent
37a859fb57
commit
9aaae852cd
@ -365,7 +365,7 @@ define('DEFAULT_LIST_PERPAGE', $_ENV['LIST_PERPAGE'] ?? $_SERVER['LIST_PERPAGE']
|
|||||||
|
|
||||||
//STATUS
|
//STATUS
|
||||||
define("STATUS", [
|
define("STATUS", [
|
||||||
'AVAIABLE' => "available",
|
'AVAILABLE' => "available",
|
||||||
'FORBIDDEN' => "forbidden",
|
'FORBIDDEN' => "forbidden",
|
||||||
'OCCUPIED' => "occupied",
|
'OCCUPIED' => "occupied",
|
||||||
'SUCCESS' => "success",
|
'SUCCESS' => "success",
|
||||||
@ -387,8 +387,8 @@ define("SERVICE", [
|
|||||||
//서버파트 관련
|
//서버파트 관련
|
||||||
define("SERVERPART", [
|
define("SERVERPART", [
|
||||||
"CNT_RANGE" => array_combine(range(1, 10), range(1, 10)),
|
"CNT_RANGE" => array_combine(range(1, 10), range(1, 10)),
|
||||||
"SERVER_PARTTTYPES" => ['CPU', 'RAM', 'DISK'],
|
"SERVER_PARTTYPES" => ['CPU', 'RAM', 'DISK'],
|
||||||
"SERVICE_PARTTTYPES" => ['SWITCH', 'IP', 'OS', 'SOFTWARE'],
|
"SERVICE_PARTTYPES" => ['SWITCH', 'IP', 'OS', 'SOFTWARE', 'CS'],
|
||||||
"PARTTYPES" => ['CPU', 'RAM', 'DISK', 'OS', 'DB', 'SOFTWARE', 'SWITCH', 'IP', 'CS'],
|
"PARTTYPES" => ['CPU', 'RAM', 'DISK', 'OS', 'DB', 'SOFTWARE', 'SWITCH', 'IP', 'CS'],
|
||||||
]);
|
]);
|
||||||
//결제 관련
|
//결제 관련
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
namespace App\Entities\Customer;
|
namespace App\Entities\Customer;
|
||||||
|
|
||||||
use App\Entities\Equipment\ServerEntity;
|
use App\Entities\Equipment\ServerEntity;
|
||||||
use App\Entities\Equipment\SwitchEntity;
|
|
||||||
use App\Models\Customer\ServiceModel;
|
use App\Models\Customer\ServiceModel;
|
||||||
|
|
||||||
class ServiceEntity extends CustomerEntity
|
class ServiceEntity extends CustomerEntity
|
||||||
@ -11,9 +10,10 @@ class ServiceEntity extends CustomerEntity
|
|||||||
const PK = ServiceModel::PK;
|
const PK = ServiceModel::PK;
|
||||||
const TITLE = ServiceModel::TITLE;
|
const TITLE = ServiceModel::TITLE;
|
||||||
const DEFAULT_STATUS = STATUS['NORMAL'];
|
const DEFAULT_STATUS = STATUS['NORMAL'];
|
||||||
public function setServerEntity(ServerEntity $entity): void
|
public function setServerEntity(ServerEntity $entity): ServiceEntity
|
||||||
{
|
{
|
||||||
$this->attributes['serverEntity'] = $entity;
|
$this->attributes['serverEntity'] = $entity;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
public function getServerEntity(): ServerEntity
|
public function getServerEntity(): ServerEntity
|
||||||
{
|
{
|
||||||
|
|||||||
@ -8,5 +8,5 @@ class CSEntity extends EquipmentEntity
|
|||||||
{
|
{
|
||||||
const PK = CSModel::PK;
|
const PK = CSModel::PK;
|
||||||
const TITLE = CSModel::TITLE;
|
const TITLE = CSModel::TITLE;
|
||||||
const DEFAULT_STATUS = STATUS['AVAIABLE'];
|
const DEFAULT_STATUS = STATUS['AVAILABLE'];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ class IPEntity extends EquipmentEntity
|
|||||||
{
|
{
|
||||||
const PK = IPModel::PK;
|
const PK = IPModel::PK;
|
||||||
const TITLE = IPModel::TITLE;
|
const TITLE = IPModel::TITLE;
|
||||||
const DEFAULT_STATUS = STATUS['AVAIABLE'];
|
const DEFAULT_STATUS = STATUS['AVAILABLE'];
|
||||||
public function getIP(): string
|
public function getIP(): string
|
||||||
{
|
{
|
||||||
return $this->attributes['ip'];
|
return $this->attributes['ip'];
|
||||||
|
|||||||
@ -8,7 +8,7 @@ class LineEntity extends EquipmentEntity
|
|||||||
{
|
{
|
||||||
const PK = LineModel::PK;
|
const PK = LineModel::PK;
|
||||||
const TITLE = LineModel::TITLE;
|
const TITLE = LineModel::TITLE;
|
||||||
const DEFAULT_STATUS = STATUS['AVAIABLE'];
|
const DEFAULT_STATUS = STATUS['AVAILABLE'];
|
||||||
public function getBandwith(): string
|
public function getBandwith(): string
|
||||||
{
|
{
|
||||||
return $this->attributes['bandwith'];
|
return $this->attributes['bandwith'];
|
||||||
|
|||||||
@ -8,7 +8,7 @@ class PartEntity extends EquipmentEntity
|
|||||||
{
|
{
|
||||||
const PK = PartModel::PK;
|
const PK = PartModel::PK;
|
||||||
const TITLE = PartModel::TITLE;
|
const TITLE = PartModel::TITLE;
|
||||||
const DEFAULT_STATUS = STATUS['AVAIABLE'];
|
const DEFAULT_STATUS = STATUS['AVAILABLE'];
|
||||||
|
|
||||||
public function getType(): string
|
public function getType(): string
|
||||||
{
|
{
|
||||||
|
|||||||
@ -9,8 +9,8 @@ class ServerEntity extends EquipmentEntity
|
|||||||
{
|
{
|
||||||
const PK = ServerModel::PK;
|
const PK = ServerModel::PK;
|
||||||
const TITLE = ServerModel::TITLE;
|
const TITLE = ServerModel::TITLE;
|
||||||
const DEFAULT_STATUS = STATUS['AVAIABLE'];
|
const DEFAULT_STATUS = STATUS['AVAILABLE'];
|
||||||
public function addServerPartEntity(string $partType, ServerPartEntity $entity): void
|
public function addServerPartEntity(string $partType, ServerPartEntity $entity): ServerEntity
|
||||||
{
|
{
|
||||||
if (!array_key_exists('serverPartEntities', $this->attributes)) {
|
if (!array_key_exists('serverPartEntities', $this->attributes)) {
|
||||||
$this->attributes['serverPartEntities'] = [];
|
$this->attributes['serverPartEntities'] = [];
|
||||||
@ -19,13 +19,15 @@ class ServerEntity extends EquipmentEntity
|
|||||||
$this->attributes['serverPartEntities'][$partType] = [];
|
$this->attributes['serverPartEntities'][$partType] = [];
|
||||||
}
|
}
|
||||||
$this->attributes['serverPartEntities'][$partType][] = $entity;
|
$this->attributes['serverPartEntities'][$partType][] = $entity;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
public function setServerPartEntities(string $partType, array $serverPartEntities): void
|
public function setServerPartEntities(string $partType, array $serverPartEntities): ServerEntity
|
||||||
{
|
{
|
||||||
if (!array_key_exists('serverPartEntities', $this->attributes)) {
|
if (!array_key_exists('serverPartEntities', $this->attributes)) {
|
||||||
$this->attributes['serverPartEntities'] = [];
|
$this->attributes['serverPartEntities'] = [];
|
||||||
}
|
}
|
||||||
$this->attributes['serverPartEntities'][$partType] = $serverPartEntities;
|
$this->attributes['serverPartEntities'][$partType] = $serverPartEntities;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
public function getServerPartEntities(string $partType): array
|
public function getServerPartEntities(string $partType): array
|
||||||
{
|
{
|
||||||
|
|||||||
@ -10,9 +10,10 @@ class ServerPartEntity extends EquipmentEntity
|
|||||||
const TITLE = ServerPartModel::TITLE;
|
const TITLE = ServerPartModel::TITLE;
|
||||||
const DEFAULT_STATUS = null;
|
const DEFAULT_STATUS = null;
|
||||||
|
|
||||||
public function setPartEntity(mixed $entity): void
|
public function setPartEntity(mixed $entity): ServerPartEntity
|
||||||
{
|
{
|
||||||
$this->attributes['partEntity'] = $entity;
|
$this->attributes['partEntity'] = $entity;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
public function getPartEntity(): mixed
|
public function getPartEntity(): mixed
|
||||||
{
|
{
|
||||||
|
|||||||
@ -8,7 +8,7 @@ class SwitchEntity extends EquipmentEntity
|
|||||||
{
|
{
|
||||||
const PK = SwitchModel::PK;
|
const PK = SwitchModel::PK;
|
||||||
const TITLE = SwitchModel::TITLE;
|
const TITLE = SwitchModel::TITLE;
|
||||||
const DEFAULT_STATUS = STATUS['AVAIABLE'];
|
const DEFAULT_STATUS = STATUS['AVAILABLE'];
|
||||||
|
|
||||||
public function getCode(): string
|
public function getCode(): string
|
||||||
{
|
{
|
||||||
|
|||||||
@ -22,7 +22,7 @@ return [
|
|||||||
"KT-CS" => "KT-CS",
|
"KT-CS" => "KT-CS",
|
||||||
],
|
],
|
||||||
"STATUS" => [
|
"STATUS" => [
|
||||||
STATUS['AVAIABLE'] => "사용가능",
|
STATUS['AVAILABLE'] => "사용가능",
|
||||||
STATUS['OCCUPIED'] => "서비스중",
|
STATUS['OCCUPIED'] => "서비스중",
|
||||||
STATUS['FORBIDDEN'] => "사용불가",
|
STATUS['FORBIDDEN'] => "사용불가",
|
||||||
],
|
],
|
||||||
|
|||||||
@ -16,7 +16,7 @@ return [
|
|||||||
'deleted_at' => "삭제일",
|
'deleted_at' => "삭제일",
|
||||||
],
|
],
|
||||||
"STATUS" => [
|
"STATUS" => [
|
||||||
STATUS['AVAIABLE'] => "사용가능",
|
STATUS['AVAILABLE'] => "사용가능",
|
||||||
STATUS['OCCUPIED'] => "서비스중",
|
STATUS['OCCUPIED'] => "서비스중",
|
||||||
STATUS['FORBIDDEN'] => "사용불가",
|
STATUS['FORBIDDEN'] => "사용불가",
|
||||||
],
|
],
|
||||||
|
|||||||
@ -18,7 +18,7 @@ return [
|
|||||||
"dedicated" => "전용",
|
"dedicated" => "전용",
|
||||||
],
|
],
|
||||||
"STATUS" => [
|
"STATUS" => [
|
||||||
STATUS['AVAIABLE'] => "사용가능",
|
STATUS['AVAILABLE'] => "사용가능",
|
||||||
STATUS['OCCUPIED'] => "서비스중",
|
STATUS['OCCUPIED'] => "서비스중",
|
||||||
STATUS['FORBIDDEN'] => "사용불가",
|
STATUS['FORBIDDEN'] => "사용불가",
|
||||||
],
|
],
|
||||||
|
|||||||
@ -20,7 +20,7 @@ return [
|
|||||||
"SOFTWARE" => "소프트웨어",
|
"SOFTWARE" => "소프트웨어",
|
||||||
],
|
],
|
||||||
"STATUS" => [
|
"STATUS" => [
|
||||||
STATUS['AVAIABLE'] => "사용가능",
|
STATUS['AVAILABLE'] => "사용가능",
|
||||||
STATUS['FORBIDDEN'] => "사용불가",
|
STATUS['FORBIDDEN'] => "사용불가",
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@ -42,7 +42,7 @@ return [
|
|||||||
"etc" => "조립",
|
"etc" => "조립",
|
||||||
],
|
],
|
||||||
"STATUS" => [
|
"STATUS" => [
|
||||||
STATUS['AVAIABLE'] => "사용가능",
|
STATUS['AVAILABLE'] => "사용가능",
|
||||||
STATUS['OCCUPIED'] => "서비스중",
|
STATUS['OCCUPIED'] => "서비스중",
|
||||||
STATUS['FORBIDDEN'] => "사용불가",
|
STATUS['FORBIDDEN'] => "사용불가",
|
||||||
],
|
],
|
||||||
|
|||||||
@ -12,7 +12,7 @@ return [
|
|||||||
'deleted_at' => "삭제일",
|
'deleted_at' => "삭제일",
|
||||||
],
|
],
|
||||||
"STATUS" => [
|
"STATUS" => [
|
||||||
STATUS['AVAIABLE'] => "사용가능",
|
STATUS['AVAILABLE'] => "사용가능",
|
||||||
STATUS['OCCUPIED'] => "서비스중",
|
STATUS['OCCUPIED'] => "서비스중",
|
||||||
STATUS['FORBIDDEN'] => "사용불가",
|
STATUS['FORBIDDEN'] => "사용불가",
|
||||||
],
|
],
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
namespace App\Services\Customer;
|
namespace App\Services\Customer;
|
||||||
|
|
||||||
use App\Entities\Customer\ServiceEntity;
|
use App\Entities\Customer\ServiceEntity;
|
||||||
|
use App\Entities\Equipment\ServerEntity;
|
||||||
use App\Models\Customer\ServiceModel;
|
use App\Models\Customer\ServiceModel;
|
||||||
use App\Services\Equipment\ServerService;
|
use App\Services\Equipment\ServerService;
|
||||||
use App\Traits\IPTrait;
|
use App\Traits\IPTrait;
|
||||||
@ -92,11 +93,11 @@ class ServiceService extends CustomerService
|
|||||||
protected function getEntity_process(mixed $entity): ServiceEntity
|
protected function getEntity_process(mixed $entity): ServiceEntity
|
||||||
{
|
{
|
||||||
//서버정보 정의
|
//서버정보 정의
|
||||||
$serverEntityy = $this->getServerService()->getEntity(['serviceinfo_uid' => $entity->getPK()]);
|
$serverEntity = $this->getServerService()->getEntity(['serviceinfo_uid' => $entity->getPK()]);
|
||||||
if ($serverEntityy !== null) {
|
if (!($serverEntity instanceof ServerEntity)) {
|
||||||
$entity->setServerEntity($serverEntityy);
|
throw new \Exception("{$entity->getPK()}에 해당하는 서버정보를 찾을수없습니다.");
|
||||||
}
|
}
|
||||||
return $entity;
|
return $entity->setServerEntity($serverEntity);
|
||||||
}
|
}
|
||||||
//기본 기능부분
|
//기본 기능부분
|
||||||
public function getFormOption(string $field, array $options = []): array
|
public function getFormOption(string $field, array $options = []): array
|
||||||
@ -166,63 +167,50 @@ class ServiceService extends CustomerService
|
|||||||
return $this->getModel()->query($sql, [$billing_at, $status]);
|
return $this->getModel()->query($sql, [$billing_at, $status]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//서버설정용
|
//서버정보 상태설정용
|
||||||
private function setServerEntity(ServiceEntity $entity, array $formDatas): ServiceEntity
|
private function setServer_process(ServiceEntity $entity, string $status): ServerEntity
|
||||||
{
|
{
|
||||||
//서버경우 서비스중으로 설정
|
//서버경우 서비스중으로 설정
|
||||||
$serverEntity = $this->getServerService()->getEntity($formDatas['serverinfo_uid']);
|
$serverEntity = $this->getServerService()->getEntity(['serviceinfo_uid' => $entity->getPK()]);
|
||||||
if (!$serverEntity) {
|
if (!($serverEntity instanceof ServerEntity)) {
|
||||||
throw new \Exception("{$formDatas['serverinfo_uid']}에 대한 서버정보를 찾을수 없습니다.");
|
throw new \Exception("{$entity->getPK()}에 해당하는 서버정보를 찾을수없습니다.");
|
||||||
}
|
}
|
||||||
$serverFormDatas = [];
|
//서버정보 상태수정
|
||||||
$serverFormDatas["clientinfo_uid"] = $entity->getClientInfoUID();
|
$serverEntity = $this->getServerService()->modify(
|
||||||
$serverFormDatas["serviceinfo_uid"] = $entity->getPK();
|
$serverEntity,
|
||||||
$serverFormDatas["status"] = STATUS['OCCUPIED'];
|
['serviceEntity' => $entity, 'status' => $status],
|
||||||
$serverEntity = $this->getServerService()->modify($serverEntity, $serverFormDatas);
|
);
|
||||||
$entity->setServerEntity($serverEntity);
|
return $serverEntity;
|
||||||
return $entity;
|
|
||||||
}
|
|
||||||
private function unsetServerEntity(ServiceEntity $entity): ServiceEntity
|
|
||||||
{
|
|
||||||
//기존 Server정보와 다른경우 사용가능상태로 변경
|
|
||||||
$serverEntity = $entity->getServerEntity();
|
|
||||||
if ($serverEntity !== null) {
|
|
||||||
$serverFormDatas = [];
|
|
||||||
$serverFormDatas["clientinfo_uid"] = null;
|
|
||||||
$serverFormDatas["serviceinfo_uid"] = null;
|
|
||||||
$serverFormDatas["status"] = STATUS['AVAIABLE'];
|
|
||||||
$serverEntity = $this->getServerService()->modify($serverEntity, $serverFormDatas);
|
|
||||||
$entity->setServerEntity($serverEntity);
|
|
||||||
}
|
|
||||||
return $entity;
|
|
||||||
}
|
}
|
||||||
//생성
|
//생성
|
||||||
public function create(array $formDatas): ServiceEntity
|
public function create(array $formDatas): ServiceEntity
|
||||||
{
|
{
|
||||||
$entity = parent::create($formDatas);
|
|
||||||
if (!array_key_exists('serverinfo_uid', $formDatas)) {
|
if (!array_key_exists('serverinfo_uid', $formDatas)) {
|
||||||
throw new \Exception("서버가 지정되지 않았습니다.");
|
throw new \Exception("서버가 지정되지 않았습니다.");
|
||||||
}
|
}
|
||||||
//신규정보 Enable
|
$entity = parent::create($formDatas);
|
||||||
return $this->setServerEntity($entity, $formDatas);
|
$serverEntity = $this->setServer_process($entity, STATUS['OCCUPIED']);
|
||||||
|
return $entity->setServerEntity($serverEntity);
|
||||||
}
|
}
|
||||||
//수정
|
//수정
|
||||||
public function modify(mixed $entity, array $formDatas): ServiceEntity
|
public function modify(mixed $entity, array $formDatas): ServiceEntity
|
||||||
{
|
{
|
||||||
if (!array_key_exists('serverinfo_uid', $formDatas)) {
|
if (!array_key_exists('serverinfo_uid', $formDatas)) {
|
||||||
throw new \Exception("서버가 지정되지 않았습니다.");
|
throw new \Exception("신규 서버가 지정되지 않았습니다.");
|
||||||
}
|
}
|
||||||
//기존정보 Disable
|
//기존서버정보 사용가능으로 설정
|
||||||
$entity = $this->unsetServerEntity($entity);
|
$this->setServer_process($entity, STATUS['AVAILABLE']);
|
||||||
//신규정보 Enable
|
//서비스 정보수정
|
||||||
$this->setServerEntity($entity, $formDatas);
|
$entity = parent::modify($entity, $formDatas);
|
||||||
return parent::modify($entity, $formDatas);
|
//신규서버정보 사용중으로 설정
|
||||||
|
$serverEntity = $this->setServer_process($entity, STATUS['OCCUPIED']);
|
||||||
|
return $entity->setServerEntity($serverEntity);
|
||||||
}
|
}
|
||||||
//삭제
|
//삭제
|
||||||
public function delete(mixed $entity): ServiceEntity
|
public function delete(mixed $entity): ServiceEntity
|
||||||
{
|
{
|
||||||
//기존정보 Disable
|
//기존서버정보 사용가능으로 설정
|
||||||
$entity = $this->unsetServerEntity($entity);
|
$this->setServer_process($entity, STATUS['AVAILABLE']);
|
||||||
return parent::delete($entity);
|
return parent::delete($entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -140,7 +140,7 @@ class ServerPartService extends EquipmentService
|
|||||||
}
|
}
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
private function action_process(ServerPartEntity $entity, mixed $part_uid, string $status): mixed
|
private function setPart_process(ServerPartEntity $entity, mixed $part_uid, string $status): mixed
|
||||||
{
|
{
|
||||||
//Type에 따른 부품서비스 정의
|
//Type에 따른 부품서비스 정의
|
||||||
switch ($entity->getType()) {
|
switch ($entity->getType()) {
|
||||||
@ -170,14 +170,15 @@ class ServerPartService extends EquipmentService
|
|||||||
case 'SWITCH':
|
case 'SWITCH':
|
||||||
case 'CS':
|
case 'CS':
|
||||||
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
||||||
if ($status === STATUS['OCCUPIED']) {
|
if ($formDatas['status'] === STATUS['AVAILABLE']) {
|
||||||
$formDatas['clientinfo_uid'] = $entity->getClientInfoUID();
|
//사용가능
|
||||||
$formDatas['serviceinfo_uid'] = $entity->getServiceInfoUID();
|
|
||||||
$formDatas['serverinfo_uid'] = $entity->getServerInfoUID();
|
|
||||||
} else {
|
|
||||||
$formDatas['clientinfo_uid'] = null;
|
$formDatas['clientinfo_uid'] = null;
|
||||||
$formDatas['serviceinfo_uid'] = null;
|
$formDatas['serviceinfo_uid'] = null;
|
||||||
$formDatas['serverinfo_uid'] = null;
|
$formDatas['serverinfo_uid'] = null;
|
||||||
|
} else {
|
||||||
|
$formDatas['clientinfo_uid'] = $entity->getClientInfoUID();
|
||||||
|
$formDatas['serviceinfo_uid'] = $entity->getServiceInfoUID();
|
||||||
|
$formDatas['serverinfo_uid'] = $entity->getServerInfoUID();
|
||||||
}
|
}
|
||||||
$formDatas['part_uid'] = $part_uid;
|
$formDatas['part_uid'] = $part_uid;
|
||||||
$formDatas['status'] = $status;
|
$formDatas['status'] = $status;
|
||||||
@ -189,28 +190,72 @@ class ServerPartService extends EquipmentService
|
|||||||
//부품연결정보생성
|
//부품연결정보생성
|
||||||
public function create(array $formDatas): ServerPartEntity
|
public function create(array $formDatas): ServerPartEntity
|
||||||
{
|
{
|
||||||
|
//서버정보가져오기
|
||||||
|
$serverEntity = null;
|
||||||
|
if (array_key_exists('serverEntity', $formDatas)) {
|
||||||
|
$serverEntity = $formDatas['serverEntity'];
|
||||||
|
} else {
|
||||||
|
if (!array_key_exists('serverinfo_uid', $formDatas)) {
|
||||||
|
throw new \Exception("서버 정보가 지정되지 않았습니다.");
|
||||||
|
}
|
||||||
|
$serverEntity = $this->getServiceService()->getEntity($formDatas['serviceinfo_uid']);
|
||||||
|
}
|
||||||
|
if (!($serverEntity instanceof ServerEntity)) {
|
||||||
|
throw new \Exception("서버 정보가 지정되지 않았습니다.");
|
||||||
|
}
|
||||||
|
$formDatas["clientinfo_uid"] = $serverEntity->getClientInfoUID();
|
||||||
|
$formDatas["serviceinfo_uid"] = $serverEntity->getServiceInfoUID();
|
||||||
|
$formDatas["serverinfo_uid"] = $serverEntity->getPK();
|
||||||
$entity = parent::create($formDatas);
|
$entity = parent::create($formDatas);
|
||||||
//부품연결정보에 부품정보 정의
|
//부품연결정보에 부품정보 정의
|
||||||
$entity->setPartEntity($this->action_process($entity, $entity->getPartUID(), STATUS['OCCUPIED']));
|
return $entity->setPartEntity($this->setPart_process(
|
||||||
return $entity;
|
$entity,
|
||||||
|
$formDatas['part_uid'],
|
||||||
|
STATUS['OCCUPIED']
|
||||||
|
));
|
||||||
}
|
}
|
||||||
//수정
|
//수정
|
||||||
public function modify(mixed $entity, array $formDatas): ServerPartEntity
|
public function modify(mixed $entity, array $formDatas): ServerPartEntity
|
||||||
{
|
{
|
||||||
//기존과 신규의 Type이 같고, 기존 Part_UID와 신규 Part_UID가 다르면 부품정보에 서버정보 설정 및 서비스,고객정보 정의 기존 Part정보 사용가능으로 변경
|
//서버정보가져오기
|
||||||
if ($entity->getType() == $formDatas['type'] && $entity->getPartUID() != $formDatas['part_uid']) {
|
$serverEntity = null;
|
||||||
$entity->setPartEntity($this->action_process($entity, $entity->getPartUID(), STATUS['AVAIABLE']));
|
if (array_key_exists('serverEntity', $formDatas)) {
|
||||||
|
$serverEntity = $formDatas['serverEntity'];
|
||||||
|
} else {
|
||||||
|
if (!array_key_exists('serverinfo_uid', $formDatas)) {
|
||||||
|
throw new \Exception("서버 정보가 지정되지 않았습니다.");
|
||||||
|
}
|
||||||
|
$serverEntity = $this->getServiceService()->getEntity($formDatas['serviceinfo_uid']);
|
||||||
|
}
|
||||||
|
if (!($serverEntity instanceof ServerEntity)) {
|
||||||
|
throw new \Exception("서버 정보가 지정되지 않았습니다.");
|
||||||
|
}
|
||||||
|
if ($formDatas['status'] === STATUS['OCCUPIED']) {
|
||||||
|
$formDatas["clientinfo_uid"] = $serverEntity->getClientInfoUID();
|
||||||
|
$formDatas["serviceinfo_uid"] = $serverEntity->getServiceInfoUID();
|
||||||
|
$formDatas["serverinfo_uid"] = $serverEntity->getPK();
|
||||||
|
} else {
|
||||||
|
$formDatas["clientinfo_uid"] = null;
|
||||||
|
$formDatas["serviceinfo_uid"] = null;
|
||||||
|
$formDatas["serverinfo_uid"] = null;
|
||||||
|
}
|
||||||
|
//기존 Part_UID와 신규 Part_UID가 다르면 기존 Part정보 사용가능으로 변경
|
||||||
|
if ($entity->getPartUID() != $formDatas['part_uid']) {
|
||||||
|
$this->setPart_process($entity, $entity->getPartUID(), STATUS['AVAILABLE']);
|
||||||
}
|
}
|
||||||
//기존 정보변경
|
//기존 정보변경
|
||||||
$entity = parent::modify($entity, $formDatas);
|
$entity = parent::modify($entity, $formDatas);
|
||||||
//기존과 신규의 Type이 같고, 기존 Part_UID와 신규 Part_UID가 다르면 부품정보에 서버정보 설정 및 서비스,고객정보 정의 Part정보 사용중으로 변경
|
//부품연결정보에 부품정보 정의
|
||||||
$entity->setPartEntity($this->action_process($entity, $formDatas['part_uid'], STATUS['OCCUPIED']));
|
return $entity->setPartEntity($this->setPart_process(
|
||||||
return $entity;
|
$entity,
|
||||||
|
$formDatas['part_uid'],
|
||||||
|
STATUS['OCCUPIED']
|
||||||
|
));
|
||||||
}
|
}
|
||||||
//삭제
|
//삭제
|
||||||
public function delete(mixed $entity): ServerPartEntity
|
public function delete(mixed $entity): ServerPartEntity
|
||||||
{
|
{
|
||||||
$this->action_process($entity, $entity->getPartUID(), STATUS['AVAIABLE']);
|
$this->setPart_process($entity, $entity->getPartUID(), STATUS['AVAILABLE']);
|
||||||
return parent::delete($entity);
|
return parent::delete($entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Services\Equipment;
|
namespace App\Services\Equipment;
|
||||||
|
|
||||||
|
use App\Entities\Customer\ServiceEntity;
|
||||||
use App\Entities\Equipment\ServerEntity;
|
use App\Entities\Equipment\ServerEntity;
|
||||||
use App\Models\Equipment\ServerModel;
|
use App\Models\Equipment\ServerModel;
|
||||||
use App\Services\Equipment\EquipmentService;
|
use App\Services\Equipment\EquipmentService;
|
||||||
@ -83,7 +84,7 @@ class ServerService extends EquipmentService
|
|||||||
//부품연결정보 정의
|
//부품연결정보 정의
|
||||||
foreach (SERVERPART['PARTTYPES'] as $partType) {
|
foreach (SERVERPART['PARTTYPES'] as $partType) {
|
||||||
foreach ($this->getServerPartService()->getEntities(['serverinfo_uid' => $entity->getPK(), 'type' => $partType]) as $serverPartEntity) {
|
foreach ($this->getServerPartService()->getEntities(['serverinfo_uid' => $entity->getPK(), 'type' => $partType]) as $serverPartEntity) {
|
||||||
$entity->addServerPartEntity($partType, $serverPartEntity);
|
$entity = $entity->addServerPartEntity($partType, $serverPartEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
@ -137,55 +138,47 @@ class ServerService extends EquipmentService
|
|||||||
{
|
{
|
||||||
$entity = parent::create($formDatas);
|
$entity = parent::create($formDatas);
|
||||||
//신규 ServerPart정보 생성
|
//신규 ServerPart정보 생성
|
||||||
foreach (SERVERPART['PARTTYPES'] as $partType) {
|
foreach (SERVERPART['SERVER_PARTTYPES'] as $partType) {
|
||||||
if (array_key_exists($partType, $formDatas)) {
|
$serverPartFormDatas = [];
|
||||||
$serverPartFormDatas = [];
|
$serverPartFormDatas['serverEntity'] = $entity;
|
||||||
$serverPartFormDatas["part_uid"] = $formDatas[$partType];
|
$serverPartFormDatas['type'] = $partType;
|
||||||
$serverPartFormDatas["clientinfo_uid"] = $entity->getClientInfoUID();
|
$serverPartFormDatas['part_uid'] = $partType . "_uid";
|
||||||
$serverPartFormDatas["serviceinfo_uid"] = $entity->getServiceInfoUID();
|
$serverPartFormDatas["billing"] = array_key_exists("{$partType}_billing", $formDatas) ? $formDatas["{$partType}_billing"] : null;
|
||||||
$serverPartFormDatas["serverinfo_uid"] = $entity->getPK();
|
$serverPartFormDatas["amount"] = array_key_exists("{$partType}_amount", $formDatas) ? $formDatas["{$partType}_amount"] : 0;
|
||||||
$serverPartFormDatas["type"] = $partType;
|
$serverPartFormDatas["cnt"] = array_key_exists("{$partType}_cnt", $formDatas) ? $formDatas["{$partType}_cnt"] : 1;
|
||||||
$serverPartFormDatas["billing"] = null;
|
$serverPartFormDatas["extra"] = array_key_exists("{$partType}_extra", $formDatas) ? $formDatas["{$partType}_extra"] : null;
|
||||||
$serverPartFormDatas["amount"] = 0;
|
$this->getServerPartService()->create($serverPartFormDatas);
|
||||||
$serverPartFormDatas["cnt"] = array_key_exists("{$partType}_cnt", $formDatas) ? $formDatas["{$partType}_cnt"] : 1;
|
|
||||||
$serverPartFormDatas["extra"] = array_key_exists("{$partType}_extra", $formDatas) ? $formDatas["{$partType}_extra"] : null;
|
|
||||||
$serverPartEntity = $this->getServerPartService()->create($serverPartFormDatas);
|
|
||||||
$entity->addServerPartEntity($serverPartEntity->getType(), $serverPartEntity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $entity;
|
return $entity->getEntity_process($entity);
|
||||||
}
|
}
|
||||||
//Service별 수정
|
//Service별 수정
|
||||||
public function modify(mixed $entity, array $formDatas): ServerEntity
|
public function modify(mixed $entity, array $formDatas): ServerEntity
|
||||||
{
|
{
|
||||||
$entity = parent::modify($entity, $formDatas);
|
//서비스정보가져오기
|
||||||
if (!array_key_exists('status', $formDatas)) {
|
$serviceEntity = null;
|
||||||
throw new \Exception(__METHOD__ . "에서 상태정보가 정의되지 않았습니다.");
|
if (array_key_exists('serviceEntity', $formDatas)) {
|
||||||
}
|
$serviceEntity = $formDatas['serviceEntity'];
|
||||||
//부품연결정보에 서버정보 설정 및 서비스,고객정보 정의
|
|
||||||
$partFormDatas = [
|
|
||||||
'serverinfo_uid' => $entity->getPK(),
|
|
||||||
'status' => $formDatas['status'],
|
|
||||||
];
|
|
||||||
if ($partFormDatas['status'] === STATUS['OCCUPIED']) {
|
|
||||||
$partFormDatas['clientinfo_uid'] = $entity->getClientInfoUID();
|
|
||||||
$partFormDatas['serviceinfo_uid'] = $entity->getServiceInfoUID();
|
|
||||||
foreach ($this->getServerPartService()->getEntities(['serverinfo_uid' => $entity->getPK()]) as $serverPartEntity) {
|
|
||||||
$entity->addServerPartEntity(
|
|
||||||
$serverPartEntity->getType(),
|
|
||||||
$this->getServerPartService()->modify($serverPartEntity, $partFormDatas)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$partFormDatas['clientinfo_uid'] = null;
|
if (!array_key_exists('serviceinfo_uid', $formDatas)) {
|
||||||
$partFormDatas['serviceinfo_uid'] = null;
|
throw new \Exception("서비스 정보가 지정되지 않았습니다.");
|
||||||
$entities = [];
|
|
||||||
foreach ($this->getServerPartService()->getEntities(['serverinfo_uid' => $entity->getPK()]) as $serverPartEntity) {
|
|
||||||
$entities[] = $this->getServerPartService()->modify($serverPartEntity, $partFormDatas);
|
|
||||||
}
|
}
|
||||||
$entity->setServerPartEntities($entities);
|
$serviceEntity = $this->getServiceService()->getEntity($formDatas['serviceinfo_uid']);
|
||||||
}
|
}
|
||||||
return $entity;
|
if (!($serviceEntity instanceof ServiceEntity)) {
|
||||||
|
throw new \Exception("서비스 정보가 지정되지 않았습니다.");
|
||||||
|
}
|
||||||
|
//서비스상태에 따라
|
||||||
|
if ($formDatas['status'] === STATUS['AVAILABLE']) {
|
||||||
|
//사용가능
|
||||||
|
$formDatas["clientinfo_uid"] = null;
|
||||||
|
$formDatas["serviceinfo_uid"] = null;
|
||||||
|
} else {
|
||||||
|
//사용중 , 일시정지
|
||||||
|
$formDatas["clientinfo_uid"] = $serviceEntity->getClientInfoUID();
|
||||||
|
$formDatas["serviceinfo_uid"] = $serviceEntity->getPK();
|
||||||
|
}
|
||||||
|
//서버정보수정
|
||||||
|
return $this->getEntity_process(parent::modify($entity, $formDatas));
|
||||||
}
|
}
|
||||||
//삭제
|
//삭제
|
||||||
public function delete(mixed $entity): ServerEntity
|
public function delete(mixed $entity): ServerEntity
|
||||||
|
|||||||
@ -48,10 +48,10 @@ class UserService extends CommonService
|
|||||||
}
|
}
|
||||||
//기본 기능부분
|
//기본 기능부분
|
||||||
|
|
||||||
public function create(array $formDatas): UserEntity
|
public function create(array $formDatas, mixed $parentEntity = null): UserEntity
|
||||||
{
|
{
|
||||||
$formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $formDatas['role']);
|
$formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $formDatas['role']);
|
||||||
return parent::create($formDatas);
|
return parent::create($formDatas, $parentEntity);
|
||||||
}
|
}
|
||||||
public function modify(mixed $entity, array $formDatas): UserEntity
|
public function modify(mixed $entity, array $formDatas): UserEntity
|
||||||
{
|
{
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<table class="table table-bordered">
|
<table class="table table-bordered">
|
||||||
<?php foreach (SERVERPART['SERVER_PARTTTYPES'] as $field): ?>
|
<?php foreach (SERVERPART['SERVER_PARTTYPES'] as $field): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?></th>
|
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?></th>
|
||||||
<td nowrap class="text-start">
|
<td nowrap class="text-start">
|
||||||
|
|||||||
@ -81,7 +81,7 @@
|
|||||||
<td><?= $viewDatas['helper']->getFieldView('status', $entity->status, $viewDatas) ?></td>
|
<td><?= $viewDatas['helper']->getFieldView('status', $entity->status, $viewDatas) ?></td>
|
||||||
<td nowrap>
|
<td nowrap>
|
||||||
<table class="table table-bordered table-striped m-0 p-0">
|
<table class="table table-bordered table-striped m-0 p-0">
|
||||||
<?php foreach (SERVERPART['SERVER_PARTTTYPES'] as $partType): ?>
|
<?php foreach (SERVERPART['SERVER_PARTTYPES'] as $partType): ?>
|
||||||
<tr class="m-0 p-0">
|
<tr class="m-0 p-0">
|
||||||
<th class="text-end m-0 p-0"><?= $viewDatas['helper']->getListButton($partType, $partType, $viewDatas) ?></th>
|
<th class="text-end m-0 p-0"><?= $viewDatas['helper']->getListButton($partType, $partType, $viewDatas) ?></th>
|
||||||
<td class="text-start m-0 p-0"><?= $viewDatas['helper']->getFieldView($partType, "", $viewDatas) ?></td>
|
<td class="text-start m-0 p-0"><?= $viewDatas['helper']->getFieldView($partType, "", $viewDatas) ?></td>
|
||||||
|
|||||||
@ -86,7 +86,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td nowrap>
|
<td nowrap>
|
||||||
<table class="table table-bordered table-striped m-0 p-0">
|
<table class="table table-bordered table-striped m-0 p-0">
|
||||||
<?php foreach (SERVERPART['SERVICE_PARTTTYPES'] as $partType): ?>
|
<?php foreach (SERVERPART['SERVICE_PARTTYPES'] as $partType): ?>
|
||||||
<tr class="m-0 p-0">
|
<tr class="m-0 p-0">
|
||||||
<th class="m-0 p-0"><?= $viewDatas['helper']->getListButton($partType, $partType, $viewDatas) ?></th>
|
<th class="m-0 p-0"><?= $viewDatas['helper']->getListButton($partType, $partType, $viewDatas) ?></th>
|
||||||
<td class="m-0 p-0"><?= $viewDatas['helper']->getFieldView($partType, "", $viewDatas) ?></td>
|
<td class="m-0 p-0"><?= $viewDatas['helper']->getFieldView($partType, "", $viewDatas) ?></td>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user