dbmsv4 init...1

This commit is contained in:
최준흠 2025-11-26 14:52:50 +09:00
parent 6bc04300a0
commit 8cfcd91e2e
50 changed files with 595 additions and 182 deletions

View File

@ -15,10 +15,7 @@ abstract class AbstractCRUDController extends AbstractWebController
{
// 💡 핵심 1: 각 자식 클래스가 사용할 Entity 클래스 경로를 반환하도록 강제
// 이 메서드는 자식 클래스에서 반드시 구현되어야 합니다.
abstract protected function getEntityClass(): string;
// --- 생성 (Create) ---
protected function create_form_process(array $formDatas = []): array
{
//초기 기본 Default값 지정
@ -64,7 +61,7 @@ abstract class AbstractCRUDController extends AbstractWebController
$this->action_init_process($action);
$entity = $this->create_process();
// 💡 동적으로 가져온 Entity 클래스 이름으로 instanceof 검사
$entityClass = $this->getEntityClass();
$entityClass = $this->service->getEntityClass();
if (!$entity instanceof $entityClass) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 {$entityClass}만 가능");
}
@ -97,7 +94,7 @@ abstract class AbstractCRUDController extends AbstractWebController
try {
$entity = $this->modify_form_process($uid);
// 💡 동적으로 가져온 Entity 클래스 이름으로 instanceof 검사
$entityClass = $this->getEntityClass();
$entityClass = $this->service->getEntityClass();
if (!$entity instanceof $entityClass) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 {$entityClass}만 가능");
}
@ -131,7 +128,7 @@ abstract class AbstractCRUDController extends AbstractWebController
$this->action_init_process($action);
$entity = $this->modify_process($uid);
// 💡 동적으로 가져온 Entity 클래스 이름으로 instanceof 검사
$entityClass = $this->getEntityClass();
$entityClass = $this->service->getEntityClass();
if (!$entity instanceof $entityClass) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 {$entityClass}만 가능");
}
@ -158,7 +155,7 @@ abstract class AbstractCRUDController extends AbstractWebController
try {
$entity = $this->delete_process($uid);
// 💡 동적으로 가져온 Entity 클래스 이름으로 instanceof 검사
$entityClass = $this->getEntityClass();
$entityClass = $this->service->getEntityClass();
if (!$entity instanceof $entityClass) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 {$entityClass}만 가능");
}
@ -194,7 +191,7 @@ abstract class AbstractCRUDController extends AbstractWebController
$this->action_init_process($action);
$entity = $this->view_process($uid);
// 💡 동적으로 가져온 Entity 클래스 이름으로 instanceof 검사
$entityClass = $this->getEntityClass();
$entityClass = $this->service->getEntityClass();
if (!$entity instanceof $entityClass) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 {$entityClass}만 가능");
}

View File

@ -18,10 +18,6 @@ class BoardController extends AdminController
$this->addActionPaths('board');
}
//Action작업관련
protected function getEntityClass(): string
{
return BoardEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
public function latest(string $category): ResponseInterface

View File

@ -17,10 +17,6 @@ class AccountController extends CustomerController
}
$this->addActionPaths('account');
}
protected function getEntityClass(): string
{
return AccountEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
}

View File

@ -18,10 +18,6 @@ class ClientController extends CustomerController
}
$this->addActionPaths('client');
}
protected function getEntityClass(): string
{
return ClientEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
//고객 상세정보

View File

@ -17,10 +17,6 @@ class CouponController extends CustomerController
}
$this->addActionPaths('coupon');
}
protected function getEntityClass(): string
{
return CouponEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
}

View File

@ -17,10 +17,6 @@ class PointController extends CustomerController
}
$this->addActionPaths('point');
}
protected function getEntityClass(): string
{
return PointEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
}

View File

@ -19,10 +19,6 @@ class ServiceController extends CustomerController
$this->addActionPaths('service');
$this->layouts['javascripts'][] = '<script src="/js/admin/clipboard.js"></script>';
}
protected function getEntityClass(): string
{
return ServiceEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
public function create_form_process(array $formDatas = []): array

View File

@ -18,10 +18,6 @@ class LineController extends EquipmentController
}
$this->addActionPaths('line');
}
protected function getEntityClass(): string
{
return LineEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
}

View File

@ -19,10 +19,6 @@ class ServerController extends EquipmentController
$this->addActionPaths('server');
$this->layouts['javascripts'][] = '<script src="/js/admin/clipboard.js"></script>';
}
protected function getEntityClass(): string
{
return ServerEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
public function create_form_process(array $formDatas = []): array

View File

@ -17,10 +17,6 @@ class ServerPartController extends EquipmentController
}
$this->addActionPaths('serverpart');
}
protected function getEntityClass(): string
{
return ServerPartEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
protected function create_form_process(array $formDatas = []): array

View File

@ -17,10 +17,6 @@ class MylogController extends AdminController
}
$this->addActionPaths('mylog');
}
protected function getEntityClass(): string
{
return MylogEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
}

View File

@ -17,10 +17,6 @@ class CPUController extends PartController
}
$this->addActionPaths('cpu');
}
protected function getEntityClass(): string
{
return CPUEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
}

View File

@ -17,10 +17,6 @@ class CSController extends PartController
}
$this->addActionPaths('cs');
}
protected function getEntityClass(): string
{
return CSEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
}

View File

@ -17,10 +17,6 @@ class DISKController extends PartController
}
$this->addActionPaths('disk');
}
protected function getEntityClass(): string
{
return DISKEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
}

View File

@ -17,10 +17,6 @@ class IPController extends PartController
}
$this->addActionPaths('ip');
}
protected function getEntityClass(): string
{
return IPEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
}

View File

@ -17,10 +17,6 @@ class RAMController extends PartController
}
$this->addActionPaths('ram');
}
protected function getEntityClass(): string
{
return RAMEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
}

View File

@ -17,10 +17,6 @@ class SOFTWAREController extends PartController
}
$this->addActionPaths('software');
}
protected function getEntityClass(): string
{
return SOFTWAREEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
}

View File

@ -17,10 +17,6 @@ class SWITCHController extends PartController
}
$this->addActionPaths('switch');
}
protected function getEntityClass(): string
{
return SWITCHEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
}

View File

@ -21,10 +21,6 @@ class PaymentController extends AdminController
$this->addActionPaths('payment');
}
//Action작업관련
protected function getEntityClass(): string
{
return PaymentEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
//일회성 추가용

View File

@ -18,10 +18,6 @@ class SearchController extends AdminController
$this->addActionPaths('service');
}
//Action작업관련
protected function getEntityClass(): string
{
return ServiceEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
protected function index_entities_process(array $entities = []): array

View File

@ -18,10 +18,6 @@ class UserController extends AdminController
$this->addActionPaths('user');
}
//Action작업관련
protected function getEntityClass(): string
{
return UserEntity::class;
}
//기본 함수 작업
//Custom 추가 함수
}

View File

@ -9,15 +9,15 @@ class CPUEntity extends PartEntity
const PK = CPUModel::PK;
const TITLE = CPUModel::TITLE;
//기본기능
final public function getUsed(): int
{
return $this->attributes['used'];
}
final public function getStock(): int
public function getStock(): int
{
return $this->attributes['stock'];
}
final public function getAvailable(): int
public function getUsed(): int
{
return $this->attributes['used'];
}
public function getAvailable(): int
{
return $this->getStock() - $this->getUsed();
}

View File

@ -22,4 +22,13 @@ class CSEntity extends PartEntity
{
return $this->attributes['domain'] ?? null;
}
//abstract 선언처리용
public function getUsed(): int
{
return 0;
}
public function getAvailable(): int
{
return 0;
}
}

View File

@ -9,11 +9,7 @@ class DISKEntity extends PartEntity
const PK = DISKModel::PK;
const TITLE = DISKModel::TITLE;
//기본기능
final public function getUsed(): int
{
return $this->attributes['used'];
}
final public function getStock(): int
public function getStock(): int
{
return $this->attributes['stock'];
}
@ -21,7 +17,11 @@ class DISKEntity extends PartEntity
{
return intval($this->attributes['format'] ?? 0);
}
final public function getAvailable(): int
public function getUsed(): int
{
return $this->attributes['used'];
}
public function getAvailable(): int
{
return $this->getStock() - $this->getUsed() - $this->getFormat();
}

View File

@ -8,11 +8,11 @@ class IPEntity extends PartEntity
{
const PK = IPModel::PK;
const TITLE = IPModel::TITLE;
final public function getLineInfoUID(): int|null
public function getLineInfoUID(): int|null
{
return $this->attributes['lineinfo_uid'] ?? null;
}
final public function getOldClientInfoUID(): int|null
public function getOldClientInfoUID(): int|null
{
return $this->attributes['old_clientinfo_uid'] ?? null;
}
@ -21,4 +21,13 @@ class IPEntity extends PartEntity
{
return $this->attributes['ip'];
}
//abstract 선언처리용
public function getUsed(): int
{
return 0;
}
public function getAvailable(): int
{
return 0;
}
}

View File

@ -10,6 +10,8 @@ abstract class PartEntity extends CommonEntity
{
parent::__construct($data);
}
abstract public function getAvailable(): int;
abstract public function getUsed(): int;
final public function getClientInfoUID(): int|null
{
return $this->attributes['clientinfo_uid'];

View File

@ -9,15 +9,15 @@ class RAMEntity extends PartEntity
const PK = RAMModel::PK;
const TITLE = RAMModel::TITLE;
//기본기능
final public function getUsed(): int
{
return $this->attributes['used'];
}
final public function getStock(): int
public function getStock(): int
{
return $this->attributes['stock'];
}
final public function getAvailable(): int
public function getUsed(): int
{
return $this->attributes['used'];
}
public function getAvailable(): int
{
return $this->getStock() - $this->getUsed();
}

View File

@ -9,15 +9,15 @@ class SOFTWAREEntity extends PartEntity
const PK = SOFTWAREModel::PK;
const TITLE = SOFTWAREModel::TITLE;
//기본기능
final public function getUsed(): int
{
return $this->attributes['used'];
}
final public function getStock(): int
public function getStock(): int
{
return $this->attributes['stock'];
}
final public function getAvailable(): int
public function getUsed(): int
{
return $this->attributes['used'];
}
public function getAvailable(): int
{
return $this->getStock() - $this->getUsed();
}

View File

@ -8,8 +8,17 @@ class SWITCHEntity extends PartEntity
{
const PK = SWITCHModel::PK;
const TITLE = SWITCHModel::TITLE;
final public function getCode(): string
public function getCode(): string
{
return $this->attributes['code'] ?? "";
}
//abstract 선언처리용
public function getUsed(): int
{
return 0;
}
public function getAvailable(): int
{
return 0;
}
}

View File

@ -7,6 +7,7 @@ use App\Entities\BoardEntity;
use App\Forms\BoardForm;
use App\Helpers\BoardHelper;
use App\Models\BoardModel;
use RuntimeException;
class BoardService extends CommonService
{
@ -25,6 +26,10 @@ class BoardService extends CommonService
{
return new BoardDTO($formDatas);
}
public function getEntityClass(): string
{
return BoardEntity::class;
}
public function getFormService(): BoardForm
{
if ($this->_form === null) {
@ -122,11 +127,19 @@ class BoardService extends CommonService
}
protected function create_process(array $formDatas): BoardEntity
{
return new BoardEntity($formDatas);
$entity = parent::create_process($formDatas);
if (!$entity instanceof BoardEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 BoardEntity만 가능");
}
return $entity;
}
protected function modify_process($uid, array $formDatas): BoardEntity
{
return parent::modify_process($uid, $formDatas);
$entity = parent::modify_process($uid, $formDatas);
if (!$entity instanceof BoardEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 BoardEntity만 가능");
}
return $entity;
}
//List 검색용
//FormFilter 조건절 처리

View File

@ -18,8 +18,10 @@ abstract class CommonService
private array $_classPaths = [];
protected $title = null;
protected function __construct(protected CommonModel $model) {}
abstract public function action_init_process(string $action, array $formDatas = []): void;
abstract protected function getDTOClass(): string;
abstract public function createDTO(array $formDatas): CommonDTO;
abstract public function getEntityClass(): string;
abstract public function getFormService(): mixed;
abstract public function getHelper(): mixed;
final protected function addClassPaths(string $path): void
@ -30,12 +32,17 @@ abstract class CommonService
{
return $isArray ? $this->_classPaths : implode($delimeter, $this->_classPaths);
}
abstract public function action_init_process(string $action, array $formDatas = []): void;
final public function getNextPK(): int
{
$pkField = $this->model->getPKField();
$row = $this->model->selectMax($pkField)->get()->getRow();
return isset($row->{$pkField}) ? ((int)$row->{$pkField} + 1) : 1;
}
/**
* 단일 엔티티를 조회합니다.
* @return CommonEntity|null CommonEntity 인스턴스 또는 찾지 못했을 경우 null
*/
final public function getEntity(string|int|array $where, ?string $message = null): ?CommonEntity
public function getEntity(string|int|array $where, ?string $message = null): ?CommonEntity
{
try {
$entity = is_array($where) ? $this->model->where($where)->first() : $this->model->find($where);
@ -64,7 +71,7 @@ abstract class CommonService
throw new \Exception($errorMessage, $e->getCode(), $e);
}
}
final public function getEntities(?array $where = null, array $columns = ['*']): array
public function getEntities(?array $where = null, array $columns = ['*']): array
{
try {
$entities = $this->getEntities_process($where, $columns);
@ -88,13 +95,6 @@ abstract class CommonService
throw new \Exception($errorMessage, $e->getCode(), $e);
}
}
final public function getNextPK(): int
{
$pkField = $this->model->getPKField();
$row = $this->model->selectMax($pkField)->get()->getRow();
return isset($row->{$pkField}) ? ((int)$row->{$pkField} + 1) : 1;
}
//Entity관련
protected function getEntity_process(CommonEntity $entity): CommonEntity
{
@ -153,16 +153,23 @@ abstract class CommonService
// INSERT 시 Entity의 PK는 0 또는 NULL이어야 함 (DB가 ID를 생성하도록)
$initialPK = $entity->getPK();
$result = $this->model->save($entity);
// 최종적으로 DB에 반영된 PK를 반환받습니다. (UPDATE이면 기존 PK, INSERT이면 새 PK)
$finalPK = $this->handle_save_result($result, $initialPK);
// handle_save_result에서 확인된 최종 PK를 사용하여 DB에서 최신 엔티티를 가져옴
return $this->getEntity($finalPK);
}
//생성용
abstract protected function create_process(array $formDatas): CommonEntity;
protected function create_process(array $formDatas): CommonEntity
{
// 💡 동적으로 가져온 Entity 클래스 이름으로 instanceof 검사
$entityClass = $this->getEntityClass();
$entity = new $entityClass($formDatas);
if (!$entity instanceof $entityClass) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 {$entityClass}만 가능");
}
return $this->save_process($entity);
}
final public function create(object $dto): CommonEntity
{
//DTO 타입 체크 로직을 일반화
@ -170,15 +177,13 @@ abstract class CommonService
if (!$dto instanceof $dtoClass) {
throw new RuntimeException(__METHOD__ . "에서 오류발생: " . get_class($dto) . "는 사용할 수 없습니다. ({$dtoClass} 필요)");
}
$formDatas = $dto->toArray();
if (!$this->getFormService()->validate($formDatas)) {
throw new ValidationException(implode("\n", service('validation')->getErrors()));
}
// NOTE: create_process에서 엔티티를 생성할 때, 자동 증가(AUTO_INCREMENT) 필드는
// DB가 처리하도록 NULL이나 빈 값(0)으로 두는 것이 일반적입니다.
$entity = $this->create_process($formDatas);
return $this->save_process($entity);
return $this->create_process($formDatas);
}
//수정용
@ -188,17 +193,13 @@ abstract class CommonService
if (!$entity) {
throw new \Exception(__METHOD__ . "에서 오류발생: {$uid}에 해당하는 정보을 찾을수 없습니다.");
}
$pkField = $this->model->getPKField();
// DTO 데이터에서 PK 필드가 있다면 제거하여, fill()에서 기존 PK를 덮어쓰지 않도록 합니다.
if (isset($formDatas[$pkField])) {
unset($formDatas[$pkField]);
}
// 1. 데이터를 Entity에 채웁니다.
$entity->fill($formDatas);
// 2. (핵심 방어) fill() 작업이 Entity의 PK를 훼손했더라도,
// 기존 $uid 값을 사용하여 Entity의 PK를 강제로 복원합니다.
// 이것이 Model::save()가 UPDATE를 실행하도록 보장하는 최종 방어선입니다.
@ -207,10 +208,8 @@ abstract class CommonService
log_message('warning', "modify_process: Entity PK 훼손 감지. '{$currentPK}' 대신 원본 UID '{$uid}'로 강제 복원.");
$entity->{$pkField} = $uid;
}
log_message('debug', "save_process 진입 전 Entity PK: " . $entity->getPK() . " (기대값: {$uid})");
return $entity;
return $this->save_process($entity);
}
final public function modify(string|int $uid, object $dto): CommonEntity
{
@ -219,13 +218,11 @@ abstract class CommonService
if (!$dto instanceof $dtoClass) {
throw new RuntimeException(__METHOD__ . "에서 오류발생: " . get_class($dto) . "는 사용할 수 없습니다. ({$dtoClass} 필요)");
}
$formDatas = $dto->toArray();
if (!$this->getFormService()->validate($formDatas)) {
throw new ValidationException(implode("\n", service('validation')->getErrors()));
}
$entity = $this->modify_process($uid, $formDatas);
return $this->save_process($entity);
return $this->modify_process($uid, $formDatas);
}
//배치 작업용 수정
@ -247,8 +244,7 @@ abstract class CommonService
if (!$this->getFormService()->validate($formDatas)) {
throw new ValidationException(implode("\n", service('validation')->getErrors()));
}
$entity = $this->batchjob_process($uid, $formDatas);
return $this->save_process($entity);
return $this->batchjob_process($uid, $formDatas);
}
//삭제용 (일반)
@ -287,7 +283,6 @@ abstract class CommonService
final public function batchjob_delete(string|int $uid): CommonEntity
{
$entity = $this->batchjob_delete_process($uid);
$result = $this->model->delete($entity->getPK());
log_message('debug', $this->model->getLastQuery());
if ($result === false) {

View File

@ -26,6 +26,10 @@ class AccountService extends CustomerService
{
return new AccountDTO($formDatas);
}
public function getEntityClass(): string
{
return AccountEntity::class;
}
public function getFormService(): AccountForm
{
if ($this->_form === null) {
@ -112,7 +116,11 @@ class AccountService extends CustomerService
}
protected function create_process(array $formDatas): AccountEntity
{
return new AccountEntity($formDatas);
$entity = parent::create_process($formDatas);
if (!$entity instanceof AccountEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 AccountEntity만 가능");
}
return $entity;
}
protected function modify_process($uid, array $formDatas): AccountEntity
{

View File

@ -26,6 +26,10 @@ class ClientService extends CustomerService
{
return new ClientDTO($formDatas);
}
public function getEntityClass(): string
{
return ClientEntity::class;
}
public function getFormService(): ClientForm
{
if ($this->_form === null) {
@ -112,7 +116,11 @@ class ClientService extends CustomerService
}
protected function create_process(array $formDatas): ClientEntity
{
return new ClientEntity($formDatas);
$entity = parent::create_process($formDatas);
if (!$entity instanceof ClientEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ClientEntity만 가능");
}
return $entity;
}
protected function modify_process($uid, array $formDatas): ClientEntity
{

View File

@ -26,6 +26,10 @@ class CouponService extends CustomerService
{
return new CouponDTO($formDatas);
}
public function getEntityClass(): string
{
return CouponEntity::class;
}
public function getFormService(): CouponForm
{
if ($this->_form === null) {
@ -103,7 +107,11 @@ class CouponService extends CustomerService
}
protected function create_process(array $formDatas): CouponEntity
{
return new CouponEntity($formDatas);
$entity = parent::create_process($formDatas);
if (!$entity instanceof CouponEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CouponEntity만 가능");
}
return $entity;
}
protected function modify_process($uid, array $formDatas): CouponEntity
{

View File

@ -26,6 +26,10 @@ class PointService extends CustomerService
{
return new PointDTO($formDatas);
}
public function getEntityClass(): string
{
return PointEntity::class;
}
public function getFormService(): PointForm
{
if ($this->_form === null) {
@ -103,7 +107,11 @@ class PointService extends CustomerService
}
protected function create_process(array $formDatas): PointEntity
{
return new PointEntity($formDatas);
$entity = parent::create_process($formDatas);
if (!$entity instanceof PointEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PointEntity만 가능");
}
return $entity;
}
protected function modify_process($uid, array $formDatas): PointEntity
{

View File

@ -28,6 +28,10 @@ class ServiceService extends CustomerService
{
return new ServiceDTO($formDatas);
}
public function getEntityClass(): string
{
return ServiceEntity::class;
}
public function getFormService(): ServiceForm
{
if ($this->_form === null) {
@ -129,7 +133,11 @@ class ServiceService extends CustomerService
}
protected function create_process(array $formDatas): ServiceEntity
{
return new ServiceEntity($formDatas);
$entity = parent::create_process($formDatas);
if (!$entity instanceof ServiceEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServiceEntity만 가능");
}
return $entity;
}
protected function modify_process($uid, array $formDatas): ServiceEntity
{

View File

@ -26,6 +26,10 @@ class LineService extends EquipmentService
{
return new LineDTO($formDatas);
}
public function getEntityClass(): string
{
return LineEntity::class;
}
public function getFormService(): LineForm
{
if ($this->_form === null) {
@ -98,7 +102,11 @@ class LineService extends EquipmentService
}
protected function create_process(array $formDatas): LineEntity
{
return new LineEntity($formDatas);
$entity = parent::create_process($formDatas);
if (!$entity instanceof LineEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 LineEntity만 가능");
}
return $entity;
}
protected function modify_process($uid, array $formDatas): LineEntity
{

View File

@ -3,12 +3,13 @@
namespace App\Services\Equipment;
use App\DTOs\Equipment\ServerPartDTO;
use App\DTOs\UserDTO;
use App\Entities\Equipment\ServerEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\Part\PartEntity;
use App\Forms\Equipment\ServerPartForm;
use App\Helpers\Equipment\ServerPartHelper;
use App\Models\Equipment\ServerPartModel;
use App\Services\CommonService;
use App\Services\Part\PartService;
use RuntimeException;
class ServerPartService extends EquipmentService
@ -28,6 +29,10 @@ class ServerPartService extends EquipmentService
{
return new ServerPartDTO($formDatas);
}
public function getEntityClass(): string
{
return ServerPartEntity::class;
}
public function getFormService(): ServerPartForm
{
if ($this->_form === null) {
@ -100,33 +105,40 @@ class ServerPartService extends EquipmentService
$this->getFormService()->setIndexFilters($indexFilter);
$this->getFormService()->setBatchjobFilters($batchjobFilters);
}
//기본 기능부분
private function getPartService(string $type): CommonService
//각 파트별 서비스
private function getPartService(string $type): PartService
{
return service('part_' . strtolower($type) . 'service');
}
//기본 기능부분
protected function getEntity_process(mixed $entity): ServerPartEntity
{
return $entity;
}
protected function create_process(array $formDatas): ServerPartEntity
{
if (!array_key_exists('title', $formDatas)) {
if (!array_key_exists('type', $formDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생:부품형식이 지정되지 않았습니다.");
}
$formDatas['title'] = $this->getPartService($formDatas['type']->getTitle());
if (!array_key_exists('type', $formDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생:부품형식이 지정되지 않았습니다.");
}
return new ServerPartEntity($formDatas);
//각 파트정보 가져오기
$partEntity = $this->getPartService($formDatas['type'])->getEntity($formDatas['part_uid']);
//서버파트정보 Title 설정용
$formDatas['title'] = $partEntity->getTitle();
$entity = parent::create_process($formDatas);
if (!$entity instanceof ServerPartEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능");
}
return $entity;
}
protected function modify_process($uid, array $formDatas): ServerPartEntity
{
if (!array_key_exists('title', $formDatas)) {
if (!array_key_exists('type', $formDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생:부품형식이 지정되지 않았습니다.");
}
$formDatas['title'] = $this->getPartService($formDatas['type']->getTitle());
if (!array_key_exists('type', $formDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생:부품형식이 지정되지 않았습니다.");
}
//각 파트정보 가져오기
$partEntity = $this->getPartService($formDatas['type'])->getEntity($formDatas['part_uid']);
//서버파트정보 Title 설정용
$formDatas['title'] = $partEntity->getTitle();
$entity = parent::modify_process($uid, $formDatas);
if (!$entity instanceof ServerPartEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능");
@ -136,4 +148,34 @@ class ServerPartService extends EquipmentService
//List 검색용
//FormFilter 조건절 처리
//검색어조건절처리
//서버추가시 서버파트 자동추가용
public function attachToServer(ServerEntity $serverEntity): void
{
//*서버의 Title 대소문자구분 필요->서버의 Title로 구분해서 기본부품 추가
foreach (SERVERPART['SERVER_PARTTYPES'] as $parttype) {
//해당 server_type의 정의된 상수값이 있으면
if (array_key_exists($serverEntity->getTitle(), SERVERPART[$parttype])) {
foreach (SERVERPART[$parttype][$serverEntity->getTitle()] as $part) {
//해당 파트정보 가져오기
$partEntity = $this->getPartService($parttype)->getEntity($part['UID']);
if (!$partEntity instanceof PartEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: {$part['UID']} 서버 정보를 찾을수 없습니다.");
}
//서버파트정보 생성
$formDatas = [];
$formDatas['serverinfo_uid'] = $serverEntity->getPK();
$formDatas["part_uid"] = $partEntity->getPK();
$formDatas['billing'] = PAYMENT['BILLING']['BASE'];
$formDatas['type'] = $parttype;
$formDatas['title'] = $partEntity->getTitle(); //파트 제목
$formDatas['amount'] = $partEntity->getPrice(); //파트 금액
$formDatas['cnt'] = $part["CNT"];
$formDatas['extra'] = $part["EXTRA"];
$entity = $this->model->create($formDatas);
$this->getPartService($entity->getType())->attachToServerPart($entity);
}
}
}
}
}

View File

@ -26,6 +26,10 @@ class ServerService extends EquipmentService
{
return new ServerDTO($formDatas);
}
public function getEntityClass(): string
{
return ServerEntity::class;
}
public function getFormService(): ServerForm
{
if ($this->_form === null) {
@ -120,7 +124,13 @@ class ServerService extends EquipmentService
}
protected function create_process(array $formDatas): ServerEntity
{
return new ServerEntity($formDatas);
$entity = parent::create_process($formDatas);
if (!$entity instanceof ServerEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능");
}
//서버추가시 서버파트 자동추가용
service('equipment_serverpartservice')->attachToServer($entity);
return $entity;
}
protected function modify_process($uid, array $formDatas): ServerEntity
{

View File

@ -28,6 +28,10 @@ class MylogService extends CommonService implements PipelineStepInterface
{
return new MylogDTO($formDatas);
}
public function getEntityClass(): string
{
return MylogEntity::class;
}
public function getFormService(): MylogForm
{
if ($this->_form === null) {
@ -113,10 +117,18 @@ class MylogService extends CommonService implements PipelineStepInterface
}
protected function create_process(array $formDatas): MylogEntity
{
return new MylogEntity($formDatas);
$entity = parent::create_process($formDatas);
if (!$entity instanceof MylogEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 MylogEntity만 가능");
}
return $entity;
}
protected function modify_process($uid, array $formDatas): MyLogEntity
protected function modify_process($uid, array $formDatas): MylogEntity
{
return parent::modify_process($uid, $formDatas);
$entity = parent::modify_process($uid, $formDatas);
if (!$entity instanceof MylogEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 MylogEntity만 가능");
}
return $entity;
}
}

View File

@ -26,6 +26,10 @@ class CPUService extends PartService
{
return new CPUDTO($formDatas);
}
public function getEntityClass(): string
{
return CPUEntity::class;
}
public function getFormService(): CPUForm
{
if ($this->_form === null) {
@ -95,7 +99,11 @@ class CPUService extends PartService
}
protected function create_process(array $formDatas): CPUEntity
{
return new CPUEntity($formDatas);
$entity = parent::create_process($formDatas);
if (!$entity instanceof CPUEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능");
}
return $entity;
}
protected function modify_process($uid, array $formDatas): CPUEntity
{
@ -108,4 +116,10 @@ class CPUService extends PartService
//List 검색용
//FormFilter 조건절 처리
//검색어조건절처리
//OrderBy 처리
public function setOrderBy(mixed $field = null, mixed $value = null): void
{
$this->model->orderBy('title ASC');
parent::setOrderBy($field, $value);
}
}

View File

@ -3,6 +3,7 @@
namespace App\Services\Part;
use App\DTOs\Part\CSDTO;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\Part\CSEntity;
use App\Forms\Part\CSForm;
use App\Helpers\Part\CSHelper;
@ -26,6 +27,10 @@ class CSService extends PartService
{
return new CSDTO($formDatas);
}
public function getEntityClass(): string
{
return CSEntity::class;
}
public function getFormService(): CSForm
{
if ($this->_form === null) {
@ -122,7 +127,11 @@ class CSService extends PartService
}
protected function create_process(array $formDatas): CSEntity
{
return new CSEntity($formDatas);
$entity = parent::create_process($formDatas);
if (!$entity instanceof CSEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CSEntity만 가능");
}
return $entity;
}
protected function modify_process($uid, array $formDatas): CSEntity
{
@ -141,4 +150,49 @@ class CSService extends PartService
$this->model->orderBy("INET_ATON(ip) ASC");
parent::setOrderBy($field, $value);
}
//서버파트관련 작업
public function attachToServerPart(ServerPartEntity $serverPartEntity): CSEntity
{
$formDatas = [];
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
$formDatas['status'] = STATUS['OCCUPIED'];
if (!array_key_exists('status', $formDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: CS상태가 설정되지 않았습니다.");
}
//CS정보가져오기
$entity = $this->getEntity($serverPartEntity->getPartUID());
if (!$entity instanceof CSEntity) {
throw new \Exception(message: "{$serverPartEntity->getPartUID()}에 해당하는 CS정보를 찾을수없습니다.");
}
//CS정보에서 해당하는 CS가 있으면 가져와서 사용중인지 체크 후 수정
$entity = $this->getEntity($serverPartEntity->getPartUID());
if ($entity instanceof CSEntity) {
if ($entity->getStatus() !== STATUS['AVAILABLE']) {
throw new \Exception(__METHOD__ . ":에서 오류발생: {$serverPartEntity->getTitle()}는 사용중입니다.");
}
$entity = $this->model->modify($entity, $formDatas);
}
return $entity;
}
public function detachFromServerPart(ServerPartEntity $serverPartEntity): CSEntity
{
$formDatas = [];
$formDatas['clientinfo_uid'] = null;
$formDatas['serviceinfo_uid'] = null;
$formDatas['serverinfo_uid'] = null;
$formDatas['status'] = STATUS['AVAILABLE'];
if (!array_key_exists('status', $formDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: CS상태가 설정되지 않았습니다.");
}
//CS정보가져오기
$entity = $this->getEntity($serverPartEntity->getPartUID());
if (!$entity instanceof CSEntity) {
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 CS정보를 찾을수없습니다.");
}
//CS정보 수정
return $this->model->modify($entity, $formDatas);
}
}

View File

@ -26,6 +26,10 @@ class DISKService extends PartService
{
return new DISKDTO($formDatas);
}
public function getEntityClass(): string
{
return DISKEntity::class;
}
public function getFormService(): DISKForm
{
if ($this->_form === null) {
@ -97,7 +101,11 @@ class DISKService extends PartService
}
protected function create_process(array $formDatas): DISKEntity
{
return new DISKEntity($formDatas);
$entity = parent::create_process($formDatas);
if (!$entity instanceof DISKEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 DISKEntity만 가능");
}
return $entity;
}
protected function modify_process($uid, array $formDatas): DISKEntity
{
@ -110,4 +118,10 @@ class DISKService extends PartService
//List 검색용
//FormFilter 조건절 처리
//검색어조건절처리
//OrderBy 처리
public function setOrderBy(mixed $field = null, mixed $value = null): void
{
$this->model->orderBy('title ASC');
parent::setOrderBy($field, $value);
}
}

View File

@ -3,6 +3,8 @@
namespace App\Services\Part;
use App\DTOs\Part\IPDTO;
use App\Entities\Equipment\ServerEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\Part\IPEntity;
use App\Forms\Part\IPForm;
use App\Helpers\Part\IPHelper;
@ -26,6 +28,10 @@ class IPService extends PartService
{
return new IPDTO($formDatas);
}
public function getEntityClass(): string
{
return IPEntity::class;
}
public function getFormService(): IPForm
{
if ($this->_form === null) {
@ -113,7 +119,11 @@ class IPService extends PartService
}
protected function create_process(array $formDatas): IPEntity
{
return new IPEntity($formDatas);
$entity = parent::create_process($formDatas);
if (!$entity instanceof IPEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 IPEntity만 가능");
}
return $entity;
}
protected function modify_process($uid, array $formDatas): IPEntity
{
@ -132,4 +142,74 @@ class IPService extends PartService
$this->model->orderBy("INET_ATON(ip) ASC");
parent::setOrderBy($field, $value);
}
//서버관련 작업
public function attachToServer(ServerEntity $serverEntity, array $formDatas = []): IPEntity
{
$formDatas = [];
$formDatas['clientinfo_uid'] = $serverEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $serverEntity->getServiceInfoUID();
$formDatas['serverinfo_uid'] = $serverEntity->getPK();
$formDatas['status'] = STATUS['OCCUPIED'];
//IP정보에서 해당하는 IP가 있으면 가져와서 사용중인지 체크 후 수정
$entity = $this->getEntity(['ip' => $serverEntity->getIP()]);
if (!$entity instanceof IPEntity) {
throw new \Exception("{$serverEntity->getIP()}에 해당하는 IP정보를 찾을수없습니다.");
}
if ($entity->getStatus() !== STATUS['AVAILABLE']) {
throw new \Exception(__METHOD__ . ":에서 오류발생: {$serverEntity->getTitle()}는 사용중입니다.");
}
return $this->model->modify($entity, $formDatas);
}
public function detachFromServer(ServerEntity $serverEntity): IPEntity
{
$formDatas = [];
$formDatas['clientinfo_uid'] = null;
$formDatas['serviceinfo_uid'] = null;
$formDatas['serverinfo_uid'] = null;
$formDatas['old_clientinfo_uid'] = $serverEntity->getClientInfoUID() ?? null;
$formDatas['status'] = STATUS['AVAILABLE'];
//IP정보가져오기
$entity = $this->getEntity(['ip' => $serverEntity->getIP()]);
if (!$entity instanceof IPEntity) {
throw new \Exception("{$serverEntity->getIP()}에 해당하는 IP정보를 찾을수없습니다.");
}
//IP정보 수정
return $this->model->modify($entity, $formDatas);
}
//서버파트관련 작업
public function attachToServerPart(ServerPartEntity $serverPartEntity): IPEntity
{
$formDatas = [];
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
$formDatas['status'] = STATUS['OCCUPIED'];
//IP정보에서 해당하는 IP가 있으면 가져와서 사용중인지 체크 후 수정
$entity = $this->getEntity($serverPartEntity->getPartUID());
if ($entity instanceof IPEntity) {
if ($entity->getStatus() !== STATUS['AVAILABLE']) {
throw new \Exception(__METHOD__ . ":에서 오류발생: {$entity->getTitle()}는 사용중입니다.");
}
$entity = $this->model->modify($entity, $formDatas);
}
return $entity;
}
public function detachFromServerPart(ServerPartEntity $serverPartEntity): IPEntity
{
$formDatas = [];
$formDatas['clientinfo_uid'] = null;
$formDatas['serviceinfo_uid'] = null;
$formDatas['serverinfo_uid'] = null;
$formDatas['old_clientinfo_uid'] = $serverPartEntity->getClientInfoUID() ?? null;
$formDatas['status'] = STATUS['AVAILABLE'];
//IP정보가져오기
$entity = $this->getEntity($serverPartEntity->getPartUID());
if (!$entity instanceof IPEntity) {
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 IP정보를 찾을수없습니다.");
}
//IP정보 수정
return $this->model->modify($entity, $formDatas);
}
}

View File

@ -2,6 +2,8 @@
namespace App\Services\Part;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\Part\PartEntity;
use App\Models\CommonModel;
use App\Services\CommonService;
@ -12,4 +14,38 @@ abstract class PartService extends CommonService
parent::__construct($model);
$this->addClassPaths('Part');
}
public function getEntity(string|int|array $where, ?string $message = null): ?PartEntity
{
return parent::getEntity($where, $message);
}
//서버파트관련 작업
public function attachToServerPart(ServerPartEntity $serverPartEntity): mixed
{
//부품정보가져오기
$entity = $this->getEntity($serverPartEntity->getPartUID());
if (!$entity) {
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
}
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
if ($entity->getAvailable() < $serverPartEntity->getCnt()) {
throw new \Exception("현재 사용가능 갯수[{$entity->getAvailable()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
}
return $this->model->modify($entity, ['used' => $entity->getUsed() + $serverPartEntity->getCnt()]);
}
public function detachFromServerPart(ServerPartEntity $serverPartEntity): mixed
{
//부품정보가져오기
$entity = $this->getEntity($serverPartEntity->getPartUID());
if (!$entity) {
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
}
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
if ($entity->getUsed() < $serverPartEntity->getCnt()) {
throw new \Exception("현재 사용된 갯수[{$entity->getUsed()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
}
$entity = $this->model->modify($entity, ['used' => $entity->getUsed() - $serverPartEntity->getCnt()]);
// dd($entity);
return $entity;
}
}

View File

@ -26,6 +26,10 @@ class RAMService extends PartService
{
return new RAMDTO($formDatas);
}
public function getEntityClass(): string
{
return RAMEntity::class;
}
public function getFormService(): RAMForm
{
if ($this->_form === null) {
@ -95,7 +99,11 @@ class RAMService extends PartService
}
protected function create_process(array $formDatas): RAMEntity
{
return new RAMEntity($formDatas);
$entity = parent::create_process($formDatas);
if (!$entity instanceof RAMEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 RAMEntity만 가능");
}
return $entity;
}
protected function modify_process($uid, array $formDatas): RAMEntity
{
@ -108,4 +116,10 @@ class RAMService extends PartService
//List 검색용
//FormFilter 조건절 처리
//검색어조건절처리
//OrderBy 처리
public function setOrderBy(mixed $field = null, mixed $value = null): void
{
$this->model->orderBy('title ASC');
parent::setOrderBy($field, $value);
}
}

View File

@ -26,6 +26,10 @@ class SOFTWAREService extends PartService
{
return new SOFTWAREDTO($formDatas);
}
public function getEntityClass(): string
{
return SOFTWAREEntity::class;
}
public function getFormService(): SOFTWAREForm
{
if ($this->_form === null) {
@ -95,7 +99,11 @@ class SOFTWAREService extends PartService
}
protected function create_process(array $formDatas): SOFTWAREEntity
{
return new SOFTWAREEntity($formDatas);
$entity = parent::create_process($formDatas);
if (!$entity instanceof SOFTWAREEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SOFTWAREEntity만 가능");
}
return $entity;
}
protected function modify_process($uid, array $formDatas): SOFTWAREEntity
{
@ -108,4 +116,10 @@ class SOFTWAREService extends PartService
//List 검색용
//FormFilter 조건절 처리
//검색어조건절처리
//OrderBy 처리
public function setOrderBy(mixed $field = null, mixed $value = null): void
{
$this->model->orderBy('title ASC');
parent::setOrderBy($field, $value);
}
}

View File

@ -3,6 +3,8 @@
namespace App\Services\Part;
use App\DTOs\Part\SWITCHDTO;
use App\Entities\Equipment\ServerEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\Part\SWITCHEntity;
use App\Forms\Part\SWITCHForm;
use App\Helpers\Part\SWITCHHelper;
@ -26,6 +28,10 @@ class SWITCHService extends PartService
{
return new SWITCHDTO($formDatas);
}
public function getEntityClass(): string
{
return SWITCHEntity::class;
}
public function getFormService(): SWITCHForm
{
if ($this->_form === null) {
@ -114,7 +120,11 @@ class SWITCHService extends PartService
}
protected function create_process(array $formDatas): SWITCHEntity
{
return new SWITCHEntity($formDatas);
$entity = parent::create_process($formDatas);
if (!$entity instanceof SWITCHEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SWITCHEntity만 가능");
}
return $entity;
}
protected function modify_process($uid, array $formDatas): SWITCHEntity
{
@ -127,4 +137,91 @@ class SWITCHService extends PartService
//List 검색용
//FormFilter 조건절 처리
//검색어조건절처리
//OrderBy 처리
public function setOrderBy(mixed $field = null, mixed $value = null): void
{
$this->model->orderBy('code ASC');
parent::setOrderBy($field, $value);
}
//서버관련 작업
public function attachToServer(ServerEntity $serverEntity, array $formDatas = []): SWITCHEntity
{
$formDatas = [];
$formDatas['clientinfo_uid'] = $serverEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $serverEntity->getServiceInfoUID();
$formDatas['serverinfo_uid'] = $serverEntity->getPK();
$formDatas['status'] = STATUS['OCCUPIED'];
if (!array_key_exists('status', $formDatas)) {
throw new \Exception(__METHOD__ . ":에서 오류발생: Switch상태가 설정되지 않았습니다.");
}
//Switch정보에서 해당하는 IP가 있으면 가져와서 사용중인지 체크 후 수정
$entity = $this->getEntity($serverEntity->getSwitchInfoUID());
if (!$entity instanceof SWITCHEntity) {
throw new \Exception("{$serverEntity->getSwitchInfoUID()}에 해당하는 Switch정보를 찾을수없습니다.");
}
if ($entity->getStatus() !== STATUS['AVAILABLE']) {
throw new \Exception(__METHOD__ . ":에서 오류발생: {$serverEntity->getTitle()}는 사용중입니다.");
}
return $this->model->modify($entity, $formDatas);
}
public function detachFromServer(ServerEntity $serverEntity): SWITCHEntity
{
$formDatas = [];
$formDatas['clientinfo_uid'] = null;
$formDatas['serviceinfo_uid'] = null;
$formDatas['serverinfo_uid'] = null;
$formDatas['old_clientinfo_uid'] = $serverEntity->getClientInfoUID() ?? null;
$formDatas['status'] = STATUS['AVAILABLE'];
if (!array_key_exists('status', $formDatas)) {
throw new \Exception(__METHOD__ . ":에서 오류발생: Switch상태가 설정되지 않았습니다.");
}
//Switch정보가져오기
$entity = $this->getEntity($serverEntity->getSwitchInfoUID());
if (!$entity instanceof SWITCHEntity) {
throw new \Exception("{$serverEntity->getSwitchInfoUID()}에 해당하는 Switch정보를 찾을수없습니다.");
}
//Switch정보 수정
return $this->model->modify($entity, $formDatas);
}
//서버파트관련 작업
public function attachToServerPart(ServerPartEntity $serverPartEntity): SWITCHEntity
{
$formDatas = [];
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
$formDatas['status'] = STATUS['OCCUPIED'];
if (!array_key_exists('status', $formDatas)) {
throw new \Exception(__METHOD__ . ":에서 오류발생: Switch상태가 설정되지 않았습니다.");
}
//SWITCH정보에서 해당하는 SWITCH가 있으면 가져와서 사용중인지 체크 후 수정
$entity = $this->getEntity($serverPartEntity->getPartUID());
if ($entity instanceof SWITCHEntity) {
if ($entity->getStatus() !== STATUS['AVAILABLE']) {
throw new \Exception(__METHOD__ . ":에서 오류발생: {$entity->getTitle()}는 사용중입니다.");
}
$entity = $this->model->modify($entity, $formDatas);
}
return $entity;
}
public function detachFromServerPart(ServerPartEntity $serverPartEntity): SWITCHEntity
{
$formDatas = [];
$formDatas['clientinfo_uid'] = null;
$formDatas['serviceinfo_uid'] = null;
$formDatas['serverinfo_uid'] = null;
$formDatas['old_clientinfo_uid'] = $serverPartEntity->getClientInfoUID() ?? null;
$formDatas['status'] = STATUS['AVAILABLE'];
if (!array_key_exists('status', $formDatas)) {
throw new \Exception(__METHOD__ . ":에서 오류발생: Switch상태가 설정되지 않았습니다.");
}
//Switch정보가져와서 있으면 수정
$entity = $this->getEntity($serverPartEntity->getPartUID());
if (!$entity instanceof SWITCHEntity) {
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 Switch정보를 찾을수없습니다.");
}
//Switch정보 수정
return $this->model->modify($entity, $formDatas);
}
}

View File

@ -25,6 +25,10 @@ class PaymentService extends CommonService
{
return PaymentDTO::class;
}
public function getEntityClass(): string
{
return PaymentEntity::class;
}
public function createDTO(array $formDatas): PaymentDTO
{
return new PaymentDTO($formDatas);
@ -130,11 +134,19 @@ class PaymentService extends CommonService
}
protected function create_process(array $formDatas): PaymentEntity
{
return new PaymentEntity($formDatas);
$entity = parent::create_process($formDatas);
if (!$entity instanceof PaymentEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PaymentEntity만 가능");
}
return $entity;
}
protected function modify_process($uid, array $formDatas): PaymentEntity
{
return parent::modify_process($uid, $formDatas);
$entity = parent::modify_process($uid, $formDatas);
if (!$entity instanceof PaymentEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PaymentEntity만 가능");
}
return $entity;
}
//List 검색용
//FormFilter 조건절 처리

View File

@ -26,6 +26,10 @@ class UserService extends CommonService
{
return new UserDTO($formDatas);
}
public function getEntityClass(): string
{
return UserEntity::class;
}
public function getFormService(): UserForm
{
if ($this->_form === null) {
@ -102,7 +106,11 @@ class UserService extends CommonService
if (isset($formDatas['confirmpassword'])) {
unset($formDatas['confirmpassword']);
}
return new UserEntity($formDatas);
$entity = parent::create_process($formDatas);
if (!$entity instanceof UserEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 UserEntity만 가능");
}
return $entity;
}
protected function modify_process($uid, array $formDatas): UserEntity
{
@ -110,7 +118,11 @@ class UserService extends CommonService
if (isset($formDatas['confirmpassword'])) {
unset($formDatas['confirmpassword']);
}
return parent::modify_process($uid, $formDatas);
$entity = parent::modify_process($uid, $formDatas);
if (!$entity instanceof UserEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 UserEntity만 가능");
}
return $entity;
}
//List 검색용
//FormFilter 조건절 처리