dbmsv4 init...2

This commit is contained in:
최준흠 2025-11-29 22:55:56 +09:00
parent c1b4350d94
commit 10f9c77fd0
20 changed files with 289 additions and 344 deletions

View File

@ -2,12 +2,13 @@
namespace App\Services;
use App\DTOs\BoardDTO;
use App\Entities\BoardEntity;
use App\Forms\BoardForm;
use App\Helpers\BoardHelper;
use App\Models\BoardModel;
use RuntimeException;
use App\Models\BoardModel;
use App\Helpers\BoardHelper;
use App\Forms\BoardForm;
use App\Entities\CommonEntity;
use App\Entities\BoardEntity;
use App\DTOs\BoardDTO;
class BoardService extends CommonService
{
@ -127,19 +128,11 @@ class BoardService extends CommonService
}
protected function create_process(array $formDatas): BoardEntity
{
$entity = parent::create_process($formDatas);
if (!$entity instanceof BoardEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 BoardEntity만 가능");
return parent::create_process($formDatas);
}
return $entity;
}
protected function modify_process($uid, array $formDatas): BoardEntity
protected function modify_process(object $entity, array $formDatas): BoardEntity
{
$entity = parent::modify_process($uid, $formDatas);
if (!$entity instanceof BoardEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 BoardEntity만 가능");
}
return $entity;
return parent::modify_process($entity, $formDatas);
}
//List 검색용
//FormFilter 조건절 처리

View File

@ -9,6 +9,7 @@ use App\Models\CommonModel;
use CodeIgniter\Database\Exceptions\DatabaseException;
use CodeIgniter\Validation\Exceptions\ValidationException;
use RuntimeException;
use SebastianBergmann\Type\ObjectType;
/**
* @template TEntity of CommonEntity
@ -55,7 +56,7 @@ abstract class CommonService
{
return $entity;
}
public function getEntity(string|int|array $where, ?string $message = null): ?CommonEntity
public function getEntity(string|int|array $where, ?string $message = null): ?object
{
try {
$entity = is_array($where) ? $this->model->where($where)->first() : $this->model->find($where);
@ -97,18 +98,16 @@ abstract class CommonService
}
/** @var array<\App\Entities\CommonEntity> $results */
$results = $this->model->select(implode(',', $columns))->findAll();
if (is_null($results)) {
$results = [];
}
foreach ($results as $entity) {
$entities[$entity->getPK()] = $this->getEntity_process($entity);
}
log_message('debug', $this->model->getLastQuery());
foreach ($results as $entity) {
$entities[] = $entity;
}
return $entities;
}
public function getEntities(?array $where = null, array $columns = ['*'], array $entities = []): array
{
try {
/** @var array<\App\Entities\CommonEntity> $entities */
$entities = $this->getEntities_process($where, $columns, $entities);
return $entities;
} catch (DatabaseException $e) {
@ -160,7 +159,7 @@ abstract class CommonService
return $pk;
}
protected function save_process(CommonEntity $entity): CommonEntity
protected function save_process(CommonEntity $entity): object
{
// INSERT 시 Entity의 PK는 0 또는 NULL이어야 함 (DB가 ID를 생성하도록)
$initialPK = $entity->getPK();
@ -172,12 +171,14 @@ abstract class CommonService
}
//생성용
protected function create_process(array $formDatas): CommonEntity
protected function create_process(array $formDatas): object
{
//FormData 검증
if (!$this->getFormService()->validate($formDatas)) {
throw new ValidationException(implode("\n", service('validation')->getErrors()));
}
//관리자 정보추가용
$formDatas['user_uid'] = $this->getAuthContext()->getUID();
// 💡 동적으로 가져온 Entity 클래스 이름으로 instanceof 검사
$entityClass = $this->getEntityClass();
$entity = new $entityClass($formDatas);
@ -218,17 +219,12 @@ abstract class CommonService
}
//수정용
protected function modify_process(string|int $uid, array $formDatas): CommonEntity
protected function modify_process(object $entity, array $formDatas): object
{
//FormData 검증
if (!$this->getFormService()->validate($formDatas)) {
throw new ValidationException(implode("\n", service('validation')->getErrors()));
}
//기존 Entity가져오기
$entity = $this->getEntity($uid);
if (!$entity) {
throw new \Exception(__METHOD__ . "에서 오류발생: {$uid}에 해당하는 정보을 찾을수 없습니다.");
}
$pkField = $this->model->getPKField();
// DTO 데이터에서 PK 필드가 있다면 제거하여, fill()에서 기존 PK를 덮어쓰지 않도록 합니다.
if (isset($formDatas[$pkField])) {
@ -236,15 +232,8 @@ abstract class CommonService
}
// 1. 데이터를 Entity에 채웁니다.
$entity->fill($formDatas);
// 2. (핵심 방어) fill() 작업이 Entity의 PK를 훼손했더라도,
// 기존 $uid 값을 사용하여 Entity의 PK를 강제로 복원합니다.
// 이것이 Model::save()가 UPDATE를 실행하도록 보장하는 최종 방어선입니다.
$currentPK = $entity->getPK();
if ($currentPK != $uid) {
log_message('warning', "modify_process: Entity PK 훼손 감지. '{$currentPK}' 대신 원본 UID '{$uid}'로 강제 복원.");
$entity->{$pkField} = $uid;
}
log_message('debug', "save_process 진입 전 Entity PK: " . $entity->getPK() . " (기대값: {$uid})");
//관리자 정보추가용
$formDatas['user_uid'] = $this->getAuthContext()->getUID();
return $this->save_process($entity);
}
final public function modify(string|int $uid, object $dto): CommonEntity
@ -258,7 +247,7 @@ abstract class CommonService
if (!$dto instanceof $dtoClass) {
throw new RuntimeException(__METHOD__ . "에서 오류발생: " . get_class($dto) . "는 사용할 수 없습니다. ({$dtoClass} 필요)");
}
$entity = $this->modify_process($uid, $dto->toArray());
$entity = $this->modify_process($this->getEntity($uid), $dto->toArray());
// 트랜잭션 완료 및 커밋
$db->transComplete();
return $entity;
@ -280,7 +269,7 @@ abstract class CommonService
protected function batchjob_process(string|int $uid, array $formDatas): CommonEntity
{
// modify_process를 호출하여 로직 재사용 (PK 로드 및 PK 제거/방어 로직 포함)
$entity = $this->modify_process($uid, $formDatas);
$entity = $this->modify_process($this->getEntity($uid), $formDatas);
return $entity;
}
final public function batchjob(array $uids, object $dto): array

View File

@ -2,12 +2,13 @@
namespace App\Services\Customer;
use App\DTOs\Customer\AccountDTO;
use App\Entities\Customer\AccountEntity;
use App\Forms\Customer\AccountForm;
use App\Helpers\Customer\AccountHelper;
use App\Models\Customer\AccountModel;
use RuntimeException;
use App\Models\Customer\AccountModel;
use App\Helpers\Customer\AccountHelper;
use App\Forms\Customer\AccountForm;
use App\Entities\Customer\AccountEntity;
use App\Entities\CommonEntity;
use App\DTOs\Customer\AccountDTO;
class AccountService extends CustomerService
{
@ -116,19 +117,11 @@ class AccountService extends CustomerService
}
protected function create_process(array $formDatas): AccountEntity
{
$entity = parent::create_process($formDatas);
if (!$entity instanceof AccountEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 AccountEntity만 가능");
return parent::create_process($formDatas);
}
return $entity;
}
protected function modify_process($uid, array $formDatas): AccountEntity
protected function modify_process(object $entity, array $formDatas): AccountEntity
{
$entity = parent::modify_process($uid, $formDatas);
if (!$entity instanceof AccountEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 AccountEntity만 가능");
}
return $entity;
return parent::modify_process($entity, $formDatas);
}
//List 검색용
//FormFilter 조건절 처리

View File

@ -2,12 +2,13 @@
namespace App\Services\Customer;
use App\DTOs\Customer\ClientDTO;
use App\Entities\Customer\ClientEntity;
use App\Forms\Customer\ClientForm;
use App\Helpers\Customer\ClientHelper;
use App\Models\Customer\ClientModel;
use RuntimeException;
use App\Models\Customer\ClientModel;
use App\Helpers\Customer\ClientHelper;
use App\Forms\Customer\ClientForm;
use App\Entities\Customer\ClientEntity;
use App\Entities\CommonEntity;
use App\DTOs\Customer\ClientDTO;
class ClientService extends CustomerService
{
@ -116,19 +117,11 @@ class ClientService extends CustomerService
}
protected function create_process(array $formDatas): ClientEntity
{
$entity = parent::create_process($formDatas);
if (!$entity instanceof ClientEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ClientEntity만 가능");
return parent::create_process($formDatas);
}
return $entity;
}
protected function modify_process($uid, array $formDatas): ClientEntity
protected function modify_process(object $entity, array $formDatas): ClientEntity
{
$entity = parent::modify_process($uid, $formDatas);
if (!$entity instanceof ClientEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ClientEntity만 가능");
}
return $entity;
return parent::modify_process($entity, $formDatas);
}
//List 검색용
//FormFilter 조건절 처리

View File

@ -2,12 +2,13 @@
namespace App\Services\Customer;
use App\DTOs\Customer\CouponDTO;
use App\Entities\Customer\CouponEntity;
use App\Forms\Customer\CouponForm;
use App\Helpers\Customer\CouponHelper;
use App\Models\Customer\CouponModel;
use RuntimeException;
use App\Models\Customer\CouponModel;
use App\Helpers\Customer\CouponHelper;
use App\Forms\Customer\CouponForm;
use App\Entities\Customer\CouponEntity;
use App\Entities\CommonEntity;
use App\DTOs\Customer\CouponDTO;
class CouponService extends CustomerService
{
@ -107,19 +108,11 @@ class CouponService extends CustomerService
}
protected function create_process(array $formDatas): CouponEntity
{
$entity = parent::create_process($formDatas);
if (!$entity instanceof CouponEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CouponEntity만 가능");
return parent::create_process($formDatas);
}
return $entity;
}
protected function modify_process($uid, array $formDatas): CouponEntity
protected function modify_process(object $entity, array $formDatas): CouponEntity
{
$entity = parent::modify_process($uid, $formDatas);
if (!$entity instanceof CouponEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CouponEntity만 가능");
}
return $entity;
return parent::modify_process($entity, $formDatas);
}
//List 검색용
//FormFilter 조건절 처리

View File

@ -2,12 +2,13 @@
namespace App\Services\Customer;
use App\DTOs\Customer\PointDTO;
use App\Entities\Customer\PointEntity;
use App\Forms\Customer\PointForm;
use App\Helpers\Customer\PointHelper;
use App\Models\Customer\PointModel;
use RuntimeException;
use App\Models\Customer\PointModel;
use App\Helpers\Customer\PointHelper;
use App\Forms\Customer\PointForm;
use App\Entities\Customer\PointEntity;
use App\Entities\CommonEntity;
use App\DTOs\Customer\PointDTO;
class PointService extends CustomerService
{
@ -107,19 +108,11 @@ class PointService extends CustomerService
}
protected function create_process(array $formDatas): PointEntity
{
$entity = parent::create_process($formDatas);
if (!$entity instanceof PointEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PointEntity만 가능");
return parent::create_process($formDatas);
}
return $entity;
}
protected function modify_process($uid, array $formDatas): PointEntity
protected function modify_process(object $entity, array $formDatas): PointEntity
{
$entity = parent::modify_process($uid, $formDatas);
if (!$entity instanceof PointEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PointEntity만 가능");
}
return $entity;
return parent::modify_process($entity, $formDatas);
}
//List 검색용
//FormFilter 조건절 처리

View File

@ -2,14 +2,15 @@
namespace App\Services\Customer;
use App\DTOs\Customer\ServiceDTO;
use App\Entities\Customer\ServiceEntity;
use App\Forms\Customer\ServiceForm;
use App\Helpers\Customer\ServiceHelper;
use App\Models\Customer\ServiceModel;
use DateTimeImmutable;
use DateTimeZone;
use RuntimeException;
use DateTimeZone;
use DateTimeImmutable;
use App\Models\Customer\ServiceModel;
use App\Helpers\Customer\ServiceHelper;
use App\Forms\Customer\ServiceForm;
use App\Entities\Customer\ServiceEntity;
use App\Entities\CommonEntity;
use App\DTOs\Customer\ServiceDTO;
class ServiceService extends CustomerService
{
@ -138,23 +139,24 @@ class ServiceService extends CustomerService
if (!$entity instanceof ServiceEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServiceEntity만 가능");
}
//서비스추가시 자동추가용
//서비스추가시 호출
service('equipment_serverservice')->attachToService($entity);
$paymentEntity = service('paymentservice')->attachToService($entity);
//서비스정보에 결제정보 연결하기
$formDatas = ['payment_uid' => $paymentEntity->getPK()];
//action 초기화
$fields = array_keys($formDatas);
$this->getFormService()->setFormFields($fields);
$this->getFormService()->setFormRules('modify', $fields);
return $this->modify_process($entity->getPK(), $formDatas);
service('paymentservice')->createByService($entity);
return $entity;
}
protected function modify_process($uid, array $formDatas): ServiceEntity
protected function modify_process(object $entity, array $formDatas): ServiceEntity
{
$entity = parent::modify_process($uid, $formDatas);
$oldEntity = clone $entity;
$entity = parent::modify_process($entity, $formDatas);
if (!$entity instanceof ServiceEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServiceEntity만 가능");
}
//서비스수정시 호출
if ($oldEntity->getServerInfoUID() !== $entity->getServerInfoUID()) {
service('equipment_serverservice')->detachFromService($oldEntity);
service('equipment_serverservice')->attachToService($entity);
}
service('paymentservice')->modifyByService($oldEntity, $entity);
return $entity;
}
//List 검색용

View File

@ -2,12 +2,13 @@
namespace App\Services\Equipment;
use App\DTOs\Equipment\LineDTO;
use App\Entities\Equipment\LineEntity;
use App\Forms\Equipment\LineForm;
use App\Helpers\Equipment\LineHelper;
use App\Models\Equipment\LineModel;
use RuntimeException;
use App\Models\Equipment\LineModel;
use App\Helpers\Equipment\LineHelper;
use App\Forms\Equipment\LineForm;
use App\Entities\Equipment\LineEntity;
use App\Entities\CommonEntity;
use App\DTOs\Equipment\LineDTO;
class LineService extends EquipmentService
{
@ -102,19 +103,11 @@ class LineService extends EquipmentService
}
protected function create_process(array $formDatas): LineEntity
{
$entity = parent::create_process($formDatas);
if (!$entity instanceof LineEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 LineEntity만 가능");
return parent::create_process($formDatas);
}
return $entity;
}
protected function modify_process($uid, array $formDatas): LineEntity
protected function modify_process(object $entity, array $formDatas): LineEntity
{
$entity = parent::modify_process($uid, $formDatas);
if (!$entity instanceof LineEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 LineEntity만 가능");
}
return $entity;
return parent::modify_process($entity, $formDatas);
}
//List 검색용
//FormFilter 조건절 처리

View File

@ -2,15 +2,16 @@
namespace App\Services\Equipment;
use App\DTOs\Equipment\ServerPartDTO;
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\Part\PartService;
use RuntimeException;
use App\Services\Part\PartService;
use App\Models\Equipment\ServerPartModel;
use App\Helpers\Equipment\ServerPartHelper;
use App\Forms\Equipment\ServerPartForm;
use App\Entities\Part\PartEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\Equipment\ServerEntity;
use App\Entities\CommonEntity;
use App\DTOs\Equipment\ServerPartDTO;
class ServerPartService extends EquipmentService
{
@ -133,7 +134,7 @@ class ServerPartService extends EquipmentService
$this->getPartService($entity->getType())->attachToServerPart($entity);
return $entity;
}
protected function modify_process($uid, array $formDatas): ServerPartEntity
protected function modify_process(object $entity, array $formDatas): ServerPartEntity
{
if (!array_key_exists('type', $formDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생:부품형식이 지정되지 않았습니다.");
@ -143,11 +144,7 @@ class ServerPartService extends EquipmentService
//해당 파트정보 Title 설정용
$formDatas['title'] = $partEntity->getTitle();
//서버파트 수정
$entity = parent::modify_process($uid, $formDatas);
if (!$entity instanceof ServerPartEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능");
}
return $entity;
return parent::modify_process($entity, $formDatas);
}
//List 검색용
//FormFilter 조건절 처리

View File

@ -2,13 +2,14 @@
namespace App\Services\Equipment;
use App\DTOs\Equipment\ServerDTO;
use App\Entities\Customer\ServiceEntity;
use App\Entities\Equipment\ServerEntity;
use App\Forms\Equipment\ServerForm;
use App\Helpers\Equipment\ServerHelper;
use App\Models\Equipment\ServerModel;
use RuntimeException;
use App\Models\Equipment\ServerModel;
use App\Helpers\Equipment\ServerHelper;
use App\Forms\Equipment\ServerForm;
use App\Entities\Equipment\ServerEntity;
use App\Entities\Customer\ServiceEntity;
use App\Entities\CommonEntity;
use App\DTOs\Equipment\ServerDTO;
class ServerService extends EquipmentService
{
@ -135,9 +136,9 @@ class ServerService extends EquipmentService
service('equipment_serverpartservice')->attachToServer($entity);
return $entity;
}
protected function modify_process($uid, array $formDatas): ServerEntity
protected function modify_process(object $entity, array $formDatas): ServerEntity
{
$entity = parent::modify_process($uid, $formDatas);
$entity = parent::modify_process($entity, $formDatas);
if (!$entity instanceof ServerEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능");
}
@ -251,23 +252,27 @@ class ServerService extends EquipmentService
}
//OrderBy 처리
//서비스추가시 서버정보 자동추가용
public function attachToService(ServiceEntity $serviceEntity): ServerEntity
//서비스관련
public function attachToService(ServiceEntity $serviceEntity): void
{
//서버파트정보 생성
$formDatas = [];
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
$formDatas["clientinfo_uid"] = $serviceEntity->getClientInfoUID();
$formDatas['user_uid'] = $this->getAuthContext()->getUID();
$formDatas['status'] = STATUS['OCCUPIED'];
//action 초기화
$fields = array_keys($formDatas);
$this->getFormService()->setFormFields($fields);
$this->getFormService()->setFormRules('modify', $fields);
$entity = $this->modify_process($serviceEntity->getServerInfoUID(), $formDatas);
if (!$entity instanceof ServerEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: Return Type은 ServerEntity만 가능합니다.");
parent::modify_process($serviceEntity, $formDatas);
}
return $entity;
public function detachFromService(ServiceEntity $serviceEntity): void
{
$formDatas = [];
$formDatas['serviceinfo_uid'] = NULL;
$formDatas["clientinfo_uid"] = NULL;
$formDatas['status'] = STATUS['AVAILABLE'];
$fields = array_keys($formDatas);
$this->getFormService()->setFormFields($fields);
$this->getFormService()->setFormRules('modify', $fields);
parent::modify_process($serviceEntity, $formDatas);
}
}

View File

@ -2,14 +2,15 @@
namespace App\Services;
use App\DTOs\MylogDTO;
use App\Entities\MylogEntity;
use App\Forms\MylogForm;
use App\Helpers\MylogHelper;
use App\Libraries\OperationContext;
use App\Libraries\PipelineStepInterface;
use App\Models\MylogModel;
use RuntimeException;
use App\Models\MylogModel;
use App\Libraries\PipelineStepInterface;
use App\Libraries\OperationContext;
use App\Helpers\MylogHelper;
use App\Forms\MylogForm;
use App\Entities\MylogEntity;
use App\Entities\CommonEntity;
use App\DTOs\MylogDTO;
class MylogService extends CommonService implements PipelineStepInterface
{
@ -117,18 +118,10 @@ class MylogService extends CommonService implements PipelineStepInterface
}
protected function create_process(array $formDatas): MylogEntity
{
$entity = parent::create_process($formDatas);
if (!$entity instanceof MylogEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 MylogEntity만 가능");
return parent::create_process($formDatas);
}
return $entity;
}
protected function modify_process($uid, array $formDatas): MylogEntity
protected function modify_process(object $entity, array $formDatas): MylogEntity
{
$entity = parent::modify_process($uid, $formDatas);
if (!$entity instanceof MylogEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 MylogEntity만 가능");
}
return $entity;
return parent::modify_process($entity, $formDatas);
}
}

View File

@ -2,13 +2,14 @@
namespace App\Services\Part;
use App\DTOs\Part\CPUDTO;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\Part\CPUEntity;
use App\Forms\Part\CPUForm;
use App\Helpers\Part\CPUHelper;
use App\Models\Part\CPUModel;
use RuntimeException;
use App\Models\Part\CPUModel;
use App\Helpers\Part\CPUHelper;
use App\Forms\Part\CPUForm;
use App\Entities\Part\CPUEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\CommonEntity;
use App\DTOs\Part\CPUDTO;
class CPUService extends PartType1Service
{
@ -100,19 +101,11 @@ class CPUService extends PartType1Service
}
protected function create_process(array $formDatas): CPUEntity
{
$entity = parent::create_process($formDatas);
if (!$entity instanceof CPUEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능");
return parent::create_process($formDatas);
}
return $entity;
}
protected function modify_process($uid, array $formDatas): CPUEntity
protected function modify_process(object $entity, array $formDatas): CPUEntity
{
$entity = parent::modify_process($uid, $formDatas);
if (!$entity instanceof CPUEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능");
}
return $entity;
return parent::modify_process($entity, $formDatas);
}
//List 검색용
//FormFilter 조건절 처리

View File

@ -2,13 +2,14 @@
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;
use App\Models\Part\CSModel;
use RuntimeException;
use App\Models\Part\CSModel;
use App\Helpers\Part\CSHelper;
use App\Forms\Part\CSForm;
use App\Entities\Part\CSEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\CommonEntity;
use App\DTOs\Part\CSDTO;
class CSService extends PartType2Service
{
@ -127,19 +128,11 @@ class CSService extends PartType2Service
}
protected function create_process(array $formDatas): CSEntity
{
$entity = parent::create_process($formDatas);
if (!$entity instanceof CSEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CSEntity만 가능");
return parent::create_process($formDatas);
}
return $entity;
}
protected function modify_process($uid, array $formDatas): CSEntity
protected function modify_process(object $entity, array $formDatas): CSEntity
{
$entity = parent::modify_process($uid, $formDatas);
if (!$entity instanceof CSEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CSEntity만 가능");
}
return $entity;
return parent::modify_process($entity, $formDatas);
}
//List 검색용
//FormFilter 조건절 처리

View File

@ -2,13 +2,14 @@
namespace App\Services\Part;
use App\DTOs\Part\DISKDTO;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\Part\DISKEntity;
use App\Forms\Part\DISKForm;
use App\Helpers\Part\DISKHelper;
use App\Models\Part\DISKModel;
use RuntimeException;
use App\Models\Part\DISKModel;
use App\Helpers\Part\DISKHelper;
use App\Forms\Part\DISKForm;
use App\Entities\Part\DISKEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\CommonEntity;
use App\DTOs\Part\DISKDTO;
class DISKService extends PartType1Service
{
@ -102,19 +103,11 @@ class DISKService extends PartType1Service
}
protected function create_process(array $formDatas): DISKEntity
{
$entity = parent::create_process($formDatas);
if (!$entity instanceof DISKEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 DISKEntity만 가능");
return parent::create_process($formDatas);
}
return $entity;
}
protected function modify_process($uid, array $formDatas): DISKEntity
protected function modify_process(object $entity, array $formDatas): DISKEntity
{
$entity = parent::modify_process($uid, $formDatas);
if (!$entity instanceof DISKEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 DISKEntity만 가능");
}
return $entity;
return parent::modify_process($entity, $formDatas);
}
//List 검색용
//FormFilter 조건절 처리

View File

@ -2,14 +2,15 @@
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;
use App\Models\Part\IPModel;
use RuntimeException;
use App\Models\Part\IPModel;
use App\Helpers\Part\IPHelper;
use App\Forms\Part\IPForm;
use App\Entities\Part\IPEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\Equipment\ServerEntity;
use App\Entities\CommonEntity;
use App\DTOs\Part\IPDTO;
class IPService extends PartType3Service
{
@ -119,19 +120,11 @@ class IPService extends PartType3Service
}
protected function create_process(array $formDatas): IPEntity
{
$entity = parent::create_process($formDatas);
if (!$entity instanceof IPEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 IPEntity만 가능");
return parent::create_process($formDatas);
}
return $entity;
}
protected function modify_process($uid, array $formDatas): IPEntity
protected function modify_process(object $entity, array $formDatas): IPEntity
{
$entity = parent::modify_process($uid, $formDatas);
if (!$entity instanceof IPEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 IPEntity만 가능");
}
return $entity;
return parent::modify_process($entity, $formDatas);
}
//List 검색용
//FormFilter 조건절 처리

View File

@ -2,13 +2,14 @@
namespace App\Services\Part;
use App\DTOs\Part\RAMDTO;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\Part\RAMEntity;
use App\Forms\Part\RAMForm;
use App\Helpers\Part\RAMHelper;
use App\Models\Part\RAMModel;
use RuntimeException;
use App\Models\Part\RAMModel;
use App\Helpers\Part\RAMHelper;
use App\Forms\Part\RAMForm;
use App\Entities\Part\RAMEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\CommonEntity;
use App\DTOs\Part\RAMDTO;
class RAMService extends PartType1Service
{
@ -100,19 +101,11 @@ class RAMService extends PartType1Service
}
protected function create_process(array $formDatas): RAMEntity
{
$entity = parent::create_process($formDatas);
if (!$entity instanceof RAMEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 RAMEntity만 가능");
return parent::create_process($formDatas);
}
return $entity;
}
protected function modify_process($uid, array $formDatas): RAMEntity
protected function modify_process(object $entity, array $formDatas): RAMEntity
{
$entity = parent::modify_process($uid, $formDatas);
if (!$entity instanceof RAMEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 RAMEntity만 가능");
}
return $entity;
return parent::modify_process($entity, $formDatas);
}
//List 검색용
//FormFilter 조건절 처리

View File

@ -2,13 +2,14 @@
namespace App\Services\Part;
use App\DTOs\Part\SOFTWAREDTO;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\Part\SOFTWAREEntity;
use App\Forms\Part\SOFTWAREForm;
use App\Helpers\Part\SOFTWAREHelper;
use App\Models\Part\SOFTWAREModel;
use RuntimeException;
use App\Models\Part\SOFTWAREModel;
use App\Helpers\Part\SOFTWAREHelper;
use App\Forms\Part\SOFTWAREForm;
use App\Entities\Part\SOFTWAREEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\CommonEntity;
use App\DTOs\Part\SOFTWAREDTO;
class SOFTWAREService extends PartType1Service
{
@ -100,19 +101,11 @@ class SOFTWAREService extends PartType1Service
}
protected function create_process(array $formDatas): SOFTWAREEntity
{
$entity = parent::create_process($formDatas);
if (!$entity instanceof SOFTWAREEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SOFTWAREEntity만 가능");
return parent::create_process($formDatas);
}
return $entity;
}
protected function modify_process($uid, array $formDatas): SOFTWAREEntity
protected function modify_process(object $entity, array $formDatas): SOFTWAREEntity
{
$entity = parent::modify_process($uid, $formDatas);
if (!$entity instanceof SOFTWAREEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SOFTWAREEntity만 가능");
}
return $entity;
return parent::modify_process($entity, $formDatas);
}
//List 검색용
//FormFilter 조건절 처리

View File

@ -2,14 +2,15 @@
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;
use App\Models\Part\SWITCHModel;
use RuntimeException;
use App\Models\Part\SWITCHModel;
use App\Helpers\Part\SWITCHHelper;
use App\Forms\Part\SWITCHForm;
use App\Entities\Part\SWITCHEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\Equipment\ServerEntity;
use App\Entities\CommonEntity;
use App\DTOs\Part\SWITCHDTO;
class SWITCHService extends PartType3Service
{
@ -120,19 +121,11 @@ class SWITCHService extends PartType3Service
}
protected function create_process(array $formDatas): SWITCHEntity
{
$entity = parent::create_process($formDatas);
if (!$entity instanceof SWITCHEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SWITCHEntity만 가능");
return parent::create_process($formDatas);
}
return $entity;
}
protected function modify_process($uid, array $formDatas): SWITCHEntity
protected function modify_process(object $entity, array $formDatas): SWITCHEntity
{
$entity = parent::modify_process($uid, $formDatas);
if (!$entity instanceof SWITCHEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SWITCHEntity만 가능");
}
return $entity;
return parent::modify_process($entity, $formDatas);
}
//List 검색용
//FormFilter 조건절 처리

View File

@ -2,15 +2,17 @@
namespace App\Services;
use App\DTOs\PaymentDTO;
use App\Entities\Customer\ClientEntity;
use App\Entities\Customer\ServiceEntity;
use App\Entities\Equipment\ServerEntity;
use App\Entities\PaymentEntity;
use App\Forms\PaymentForm;
use App\Helpers\PaymentHelper;
use App\Models\PaymentModel;
use RuntimeException;
use DateTime;
use App\Models\PaymentModel;
use App\Helpers\PaymentHelper;
use App\Forms\PaymentForm;
use App\Entities\PaymentEntity;
use App\Entities\Equipment\ServerEntity;
use App\Entities\Customer\ServiceEntity;
use App\Entities\Customer\ClientEntity;
use App\Entities\CommonEntity;
use App\DTOs\PaymentDTO;
class PaymentService extends CommonService
{
@ -141,11 +143,17 @@ class PaymentService extends CommonService
if (!array_key_exists('title', $formDatas)) {
throw new RuntimeException(__METHOD__ . '에서 오류발생: 결제 제목이 정의되지 않았습니다.');
}
if (!array_key_exists('amount', $formDatas)) {
throw new RuntimeException(__METHOD__ . '에서 오류발생: 청구금액이 정의되지 않았습니다.');
}
if (!array_key_exists('billing', $formDatas)) {
throw new RuntimeException(__METHOD__ . '에서 오류발생: 결제방식이 정의되지 않았습니다.');
throw new RuntimeException(__METHOD__ . '에서 오류발생: 청구방법이 정의되지 않았습니다.');
}
if (!array_key_exists('billing_at', $formDatas)) {
throw new RuntimeException(__METHOD__ . '에서 오류발생: 결제일이 정의되지 않았습니다.');
throw new RuntimeException(__METHOD__ . '에서 오류발생: 지급기한일이 정의되지 않았습니다.');
}
if (!array_key_exists('pay', $formDatas)) {
throw new RuntimeException(__METHOD__ . '에서 오류발생: 지급방법이 정의되지 않았습니다.');
}
if (!array_key_exists('status', $formDatas)) {
throw new RuntimeException(__METHOD__ . '에서 오류발생: 결제상태가 정의되지 않았습니다.');
@ -158,7 +166,6 @@ class PaymentService extends CommonService
//서버파트정보 생성
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
$formDatas["clientinfo_uid"] = $serviceEntity->getClientInfoUID();
$formDatas['user_uid'] = $this->getAuthContext()->getUID();
$formDatas['amount'] = $serviceEntity->getAmount();
$entity = parent::create_process($formDatas);
if (!$entity instanceof PaymentEntity) {
@ -166,14 +173,30 @@ class PaymentService extends CommonService
}
return $entity;
}
protected function modify_process($uid, array $formDatas): PaymentEntity
protected function modify_process(object $entity, array $formDatas): PaymentEntity
{
throw new RuntimeException(__METHOD__ . "에서 오류발생: 결제정보는 수정이 불가합니다.");
// $entity = parent::modify_process($uid, $formDatas);
// if (!$entity instanceof PaymentEntity) {
// throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PaymentEntity만 가능");
// }
// return $entity;
if (!array_key_exists('serviceinfo_uid', $formDatas)) {
throw new RuntimeException(__METHOD__ . '에서 오류발생: 서비스정보가 정의되지 않았습니다.');
}
if (!array_key_exists('title', $formDatas)) {
throw new RuntimeException(__METHOD__ . '에서 오류발생: 결제 제목이 정의되지 않았습니다.');
}
if (!array_key_exists('amount', $formDatas)) {
throw new RuntimeException(__METHOD__ . '에서 오류발생: 청구금액이 정의되지 않았습니다.');
}
if (!array_key_exists('billing', $formDatas)) {
throw new RuntimeException(__METHOD__ . '에서 오류발생: 청구방법이 정의되지 않았습니다.');
}
if (!array_key_exists('billing_at', $formDatas)) {
throw new RuntimeException(__METHOD__ . '에서 오류발생: 지급기한일이 정의되지 않았습니다.');
}
if (!array_key_exists('pay', $formDatas)) {
throw new RuntimeException(__METHOD__ . '에서 오류발생: 지급방법이 정의되지 않았습니다.');
}
if (!array_key_exists('status', $formDatas)) {
throw new RuntimeException(__METHOD__ . '에서 오류발생: 결제상태가 정의되지 않았습니다.');
}
return parent::modify_process($entity, $formDatas);
}
//List 검색용
//FormFilter 조건절 처리
@ -248,8 +271,8 @@ class PaymentService extends CommonService
return $rows;
}
//서비스추가시 결제정보 자동추가용
public function attachToService(ServiceEntity $serviceEntity): PaymentEntity
//서비스관련
public function createByService(ServiceEntity $serviceEntity): void
{
//서버파트정보 생성
$formDatas = [];
@ -257,20 +280,46 @@ class PaymentService extends CommonService
$formDatas['title'] = sprintf(
"%s %s 서비스비용",
$serviceEntity->getTitle(),
date("Y년/m월")
DateTime::createFromFormat('Y-m-d', $serviceEntity->getBillingAt())->format('Y년 m월')
);
$formDatas['billing'] = PAYMENT['BILLING']['MONTH'];
$formDatas['billing_at'] = $serviceEntity->getBillingAt();
$formDatas['pay'] = PAYMENT['PAY']['ACCOUNT'];
$formDatas['status'] = STATUS['UNPAID'];
//action 초기화
$fields = array_keys($formDatas);
$this->getFormService()->setFormFields($fields);
$this->getFormService()->setFormRules('create', $fields);
$entity = $this->create_process($formDatas);
if (!$entity instanceof PaymentEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: Return Type은 PaymentEntity만 가능합니다.");
$this->create_process($formDatas);
}
return $entity;
public function modifyByService(ServiceEntity $oldServiceEntity, ServiceEntity $serviceEntity): void
{
//수정 전 서비스정보와 수정후 서비스정보의 결제일이 다를경우 수정 전 서비스정보의 결제일을 기준으로 결제정보를 찾은 후 수정 후 정보로 변경한다.
$billing_at = $serviceEntity->getBillingAt();
if ($oldServiceEntity->getBillingAt() !== $serviceEntity->getBillingAt()) {
$billing_at = $oldServiceEntity->getBillingAt();
}
//기존 Entity가져오기
$entity = $this->getEntity(['serviceinifo_uid' => $serviceEntity->getPK(), 'billing_at' => $billing_at]);
if (!$entity) {
throw new \Exception(__METHOD__ . "에서 오류발생: 해당하는 결제정보을 찾을수 없습니다.");
}
//이미 지불이 완료된 결제정보인 경우
if ($entity->getStatus() === STATUS['PAID']) {
throw new \Exception(__METHOD__ . "에서 오류발생: 해당하는 결제정보는 이미 결제처리가 완료되어 수정이 불가합니다.");
}
//서버파트정보 생성
$formDatas = [];
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
$formDatas['title'] = sprintf(
"%s %s 서비스비용",
$serviceEntity->getTitle(),
DateTime::createFromFormat('Y-m-d', $serviceEntity->getBillingAt())->format('Y년 m월')
);
$fields = array_keys($formDatas);
$this->getFormService()->setFormFields($fields);
$this->getFormService()->setFormRules('modify', $fields);
$this->modify_process($entity, $formDatas);
}
}

View File

@ -2,12 +2,13 @@
namespace App\Services;
use App\DTOs\UserDTO;
use App\Entities\UserEntity;
use App\Forms\UserForm;
use App\Helpers\UserHelper;
use App\Models\UserModel;
use RuntimeException;
use App\Models\UserModel;
use App\Helpers\UserHelper;
use App\Forms\UserForm;
use App\Entities\UserEntity;
use App\Entities\CommonEntity;
use App\DTOs\UserDTO;
class UserService extends CommonService
{
@ -112,13 +113,13 @@ class UserService extends CommonService
}
return $entity;
}
protected function modify_process($uid, array $formDatas): UserEntity
protected function modify_process(object $entity, array $formDatas): UserEntity
{
//confirmpassword 필드는 Entity에 필요없으므로 제거
if (isset($formDatas['confirmpassword'])) {
unset($formDatas['confirmpassword']);
}
$entity = parent::modify_process($uid, $formDatas);
$entity = parent::modify_process($entity, $formDatas);
if (!$entity instanceof UserEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 UserEntity만 가능");
}