dbmsv4 init...3

This commit is contained in:
최준흠 2025-12-12 17:37:42 +09:00
parent ecf833d439
commit f4308015d5
10 changed files with 52 additions and 56 deletions

View File

@ -52,6 +52,7 @@ class ClientController extends CustomerController
} }
} }
//비고사항 변경
public function history(int $uid): RedirectResponse|string public function history(int $uid): RedirectResponse|string
{ {
try { try {
@ -59,7 +60,7 @@ class ClientController extends CustomerController
if (!$history) { if (!$history) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 비고가 정의되지 않았습니다."); throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 비고가 정의되지 않았습니다.");
} }
$this->addViewDatas('entity', $this->service->modify($uid, $history)); $this->addViewDatas('entity', $this->service->modify($uid, ['history' => $history]));
return $this->action_redirect_process('info', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 비고설정이 완료되었습니다."); return $this->action_redirect_process('info', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 비고설정이 완료되었습니다.");
} catch (\Throwable $e) { } catch (\Throwable $e) {
return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 비고설정 오류:" . $e->getMessage()); return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 비고설정 오류:" . $e->getMessage());

View File

@ -43,6 +43,7 @@ class ServiceController extends CustomerController
parent::index_process($action); parent::index_process($action);
} }
//비고사항 변경
public function history(int $uid): RedirectResponse|string public function history(int $uid): RedirectResponse|string
{ {
try { try {
@ -50,12 +51,14 @@ class ServiceController extends CustomerController
if (!$history) { if (!$history) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 비고가 정의되지 않았습니다."); throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 비고가 정의되지 않았습니다.");
} }
$this->addViewDatas('entity', parent::modify_process($uid, $this->request->getPost())); $this->addViewDatas('entity', $this->service->modify($uid, ['history' => $history]));
return $this->action_redirect_process('info', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 비고설정이 완료되었습니다."); return $this->action_redirect_process('info', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 비고설정이 완료되었습니다.");
} catch (\Throwable $e) { } catch (\Throwable $e) {
return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 비고설정 오류:" . $e->getMessage()); return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 비고설정 오류:" . $e->getMessage());
} }
} }
//결제일 변경
public function billingat(int $uid): RedirectResponse|string public function billingat(int $uid): RedirectResponse|string
{ {
try { try {
@ -63,14 +66,14 @@ class ServiceController extends CustomerController
if (!$billing_at) { if (!$billing_at) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 결제일이 정의되지 않았습니다."); throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 결제일이 정의되지 않았습니다.");
} }
$this->addViewDatas('entity', parent::modify_process($uid, $this->request->getPost())); $this->addViewDatas('entity', $this->service->modify($uid, ['billing_at' => $billing_at]));
return $this->action_redirect_process('info', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 결제일 변경이 완료되었습니다."); return $this->action_redirect_process('info', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 결제일 변경이 완료되었습니다.");
} catch (\Throwable $e) { } catch (\Throwable $e) {
return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 결제일 변경 오류:" . $e->getMessage()); return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 결제일 변경 오류:" . $e->getMessage());
} }
} }
//대체서버 추가 //대체서버 생성폼
public function alternative_create_form(int $uid): string|RedirectResponse public function alternative_create_form(int $uid): string|RedirectResponse
{ {
try { try {
@ -80,6 +83,7 @@ class ServiceController extends CustomerController
return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 대체서버 추가폼 오류:" . $e->getMessage()); return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 대체서버 추가폼 오류:" . $e->getMessage());
} }
} }
//대체서버 생성
public function alternative_create(int $uid): string|RedirectResponse public function alternative_create(int $uid): string|RedirectResponse
{ {
try { try {
@ -123,6 +127,8 @@ class ServiceController extends CustomerController
return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 메인서버 설정 오류:" . $e->getMessage()); return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 메인서버 설정 오류:" . $e->getMessage());
} }
} }
//대체서버 해지
public function alternative_delete(int $uid): string|RedirectResponse public function alternative_delete(int $uid): string|RedirectResponse
{ {
try { try {

View File

@ -2,7 +2,6 @@
namespace App\Controllers\Admin\Equipment; namespace App\Controllers\Admin\Equipment;
use App\Entities\Equipment\CHASSISEntity;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;

View File

@ -2,11 +2,11 @@
namespace App\Forms; namespace App\Forms;
use App\Entities\CommonEntity;
use RuntimeException; use RuntimeException;
abstract class CommonForm abstract class CommonForm
{ {
private $_validation = null;
private array $_attributes = []; private array $_attributes = [];
private array $_formFields = []; private array $_formFields = [];
private array $_formRules = []; private array $_formRules = [];
@ -16,7 +16,10 @@ abstract class CommonForm
private array $_formOptions = []; private array $_formOptions = [];
private array $_actionButtons = ['view' => ICONS['SEARCH'], 'delete' => ICONS['DELETE']]; private array $_actionButtons = ['view' => ICONS['SEARCH'], 'delete' => ICONS['DELETE']];
private array $_batchjobButtons = ['batchjob' => '일괄처리', 'batchjob_delete' => '일괄삭제']; private array $_batchjobButtons = ['batchjob' => '일괄처리', 'batchjob_delete' => '일괄삭제'];
protected function __construct() {} protected function __construct()
{
$this->_validation = service('validation');
}
final public function setAttributes(array $attributes): void final public function setAttributes(array $attributes): void
{ {
$this->_attributes = $attributes; $this->_attributes = $attributes;
@ -113,21 +116,11 @@ abstract class CommonForm
return $this->_batchjobButtons; return $this->_batchjobButtons;
} }
//Validation용 //Validation용
// final public function validate(array $formDatas): bool
// {
// $validation = service('validation');
// $dynamicRules = [];
// foreach ($this->getFormRules() as $field => $rule) {
// //field별 추가 커스텀 룰 적용
// list($field, $rule) = $this->getValidationRule($field, $rule);
// $dynamicRules[$field] = ['rules' => $rule, 'label' => $this->getFormFields()[$field]];
// }
// $validation->setRules($dynamicRules);
// return $validation->run($formDatas);
// }
final public function validate(array $formDatas): bool final public function validate(array $formDatas): bool
{ {
$validation = service('validation'); if ($this->_validation === null) {
$this->_validation = service('validation');
}
$dynamicRules = []; $dynamicRules = [];
$dynamicLabels = []; // 레이블 배열 추가 $dynamicLabels = []; // 레이블 배열 추가
if (!count($this->getFormRules())) { if (!count($this->getFormRules())) {
@ -142,12 +135,12 @@ abstract class CommonForm
log_message('debug', 'Rules: ' . var_export($dynamicRules, true)); log_message('debug', 'Rules: ' . var_export($dynamicRules, true));
log_message('debug', 'Data: ' . var_export($formDatas, true)); log_message('debug', 'Data: ' . var_export($formDatas, true));
// setRules의 세 번째 인자로 레이블 전달 // setRules의 세 번째 인자로 레이블 전달
$validation->setRules($dynamicRules, [], $dynamicLabels); $this->_validation->setRules($dynamicRules, [], $dynamicLabels);
// run()에는 데이터만 전달 (setRules에서 이미 설정됨) // run()에는 데이터만 전달 (setRules에서 이미 설정됨)
$result = $validation->run($formDatas); $result = $this->_validation->run($formDatas);
if ($result === false) { if ($result === false) {
$message = __METHOD__ . "에서 데이터 검증 오류발생: " . var_export($validation->getErrors(), true); $message = __METHOD__ . "에서 데이터 검증 오류발생: " . var_export($this->_validation->getErrors(), true);
log_message('debug', $message); log_message('debug', $message);
throw new RuntimeException($message); throw new RuntimeException($message);
} else { } else {

View File

@ -3,10 +3,7 @@
namespace App\Services\Customer; namespace App\Services\Customer;
use App\DTOs\Customer\ServiceDTO; use App\DTOs\Customer\ServiceDTO;
use App\Entities\CommonEntity;
use App\Entities\Customer\ServiceEntity; use App\Entities\Customer\ServiceEntity;
use App\Entities\Equipment\ServerEntity;
use App\Entities\PaymentEntity;
use App\Forms\Customer\ServiceForm; use App\Forms\Customer\ServiceForm;
use App\Helpers\Customer\ServiceHelper; use App\Helpers\Customer\ServiceHelper;
use App\Models\Customer\ServiceModel; use App\Models\Customer\ServiceModel;
@ -176,22 +173,27 @@ class ServiceService extends CustomerService
return $date->format('Y-m-d'); return $date->format('Y-m-d');
} }
// 서비스금액관련처리 // 서비스금액관련처리
private function updateAmount(ServiceEntity $entity): ServiceEntity private function saveAmount(ServiceEntity $entity): ServiceEntity
{ {
//총 서비스금액 구하기 //총 서비스금액 구하기
$server_amount = service('equipment_serverservice')->getCalculatedAmount($entity->getServerInfoUID()); $server_amount = service('equipment_serverservice')->getCalculatedAmount($entity->getServerInfoUID());
//기본:서버금액(서버비+서버파트(월비용))+상면비+회선비-할인액 //기본:서버금액(서버비+서버파트(월비용))+상면비+회선비-할인액
$caculatedAmount = (int)$server_amount + $entity->getRack() + $entity->getLine() - $entity->getSale(); $entity->amount = (int)$server_amount + $entity->getRack() + $entity->getLine() - $entity->getSale();
//총 서비스금액 설정 //총 서비스금액 설정 및 저장
return parent::modify_process($entity, ['amount' => $caculatedAmount]); if (!$this->model->save($entity)) {
// 저장 실패 시 예외 처리
$errors = $this->model->errors();
throw new RuntimeException("금액 업데이트 중 DB 저장 오류: " . implode(', ', $errors));
}
return $entity;
} }
final public function updateAmountByPK(int $uid): ServiceEntity final public function saveAmountByPK(int $uid): ServiceEntity
{ {
$entity = $this->getEntity($uid); $entity = $this->getEntity($uid);
if (!$entity instanceof ServiceEntity) { if (!$entity instanceof ServiceEntity) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 ServiceEntity만 가능"); throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 ServiceEntity만 가능");
} }
return $this->updateAmount($entity); return $this->saveAmount($entity);
} }
//기본 기능부분 //기본 기능부분
protected function getEntity_process(mixed $entity): ServiceEntity protected function getEntity_process(mixed $entity): ServiceEntity
@ -200,10 +202,6 @@ class ServiceService extends CustomerService
} }
protected function create_process(array $formDatas): ServiceEntity protected function create_process(array $formDatas): ServiceEntity
{ {
//필수항목검사
if (!array_key_exists('serverinfo_uid', $formDatas)) {
throw new RuntimeException(__METHOD__ . '에서 오류발생: 서버정보가 정의되지 않았습니다.');
}
//서비스코드생성 //서비스코드생성
$formDatas['code'] = $formDatas['site'] . "_s" . uniqid(); $formDatas['code'] = $formDatas['site'] . "_s" . uniqid();
//서비스 생성 //서비스 생성
@ -214,17 +212,13 @@ class ServiceService extends CustomerService
//서버정보 연결 //서버정보 연결
service('equipment_serverservice')->attachToService($entity, $entity->getServerInfoUID()); service('equipment_serverservice')->attachToService($entity, $entity->getServerInfoUID());
//서비스비용 설정 //서비스비용 설정
$entity = $this->updateAmount($entity); $entity = $this->saveAmount($entity);
//결제정보 생성 //결제정보 생성
service('paymentservice')->createByService($entity); service('paymentservice')->createByService($entity);
return $entity; return $entity;
} }
protected function modify_process($entity, array $formDatas): ServiceEntity protected function modify_process($entity, array $formDatas): ServiceEntity
{ {
//필수항목검사
if (!array_key_exists('serverinfo_uid', $formDatas)) {
throw new RuntimeException(__METHOD__ . '에서 오류발생: 서버정보가 정의되지 않았습니다.');
}
//변경전 정보 //변경전 정보
$oldEntity = clone $entity; $oldEntity = clone $entity;
//서비스 수정 //서비스 수정
@ -237,7 +231,7 @@ class ServiceService extends CustomerService
service('equipment_serverservice')->attachToService($entity, $entity->getServerInfoUID()); service('equipment_serverservice')->attachToService($entity, $entity->getServerInfoUID());
} }
//서비스비용 설정 //서비스비용 설정
$entity = $this->updateAmount($entity); $entity = $this->saveAmount($entity);
//결제정보 생성 //결제정보 생성
service('paymentservice')->modifyByService($entity); service('paymentservice')->modifyByService($entity);
return $entity; return $entity;

View File

@ -135,7 +135,7 @@ class ServerPartService extends EquipmentService
if ($entity->getServiceInfoUID() !== null) { if ($entity->getServiceInfoUID() !== null) {
//Billing형식이 Month이면 서비스 금액설정 호출 //Billing형식이 Month이면 서비스 금액설정 호출
if ($entity->getBilling() == PAYMENT['BILLING']['MONTH']) { if ($entity->getBilling() == PAYMENT['BILLING']['MONTH']) {
service('customer_serviceservice')->updateAmountByPK($entity->getServiceInfoUID()); service('customer_serviceservice')->saveAmountByPK($entity->getServiceInfoUID());
} }
//Billing형식이 Onetime이면 일회성결제 추가 //Billing형식이 Onetime이면 일회성결제 추가
if ($entity->getBilling() == PAYMENT['BILLING']['ONETIME']) { if ($entity->getBilling() == PAYMENT['BILLING']['ONETIME']) {
@ -159,7 +159,7 @@ class ServerPartService extends EquipmentService
if ($entity->getServiceInfoUID() !== null) { if ($entity->getServiceInfoUID() !== null) {
//월비용 서버파트 인경우 서비스 금액 재설정 //월비용 서버파트 인경우 서비스 금액 재설정
if ($entity->getBilling() == PAYMENT['BILLING']['MONTH']) { if ($entity->getBilling() == PAYMENT['BILLING']['MONTH']) {
service('customer_serviceservice')->updateAmountByPK($entity->getServiceInfoUID()); service('customer_serviceservice')->saveAmountByPK($entity->getServiceInfoUID());
} }
//Billing형식이 Onetime이면 일회성결제 수정 (필요없는듯 하여 주석처리) //Billing형식이 Onetime이면 일회성결제 수정 (필요없는듯 하여 주석처리)
// if ($entity->getBilling() == PAYMENT['BILLING']['ONETIME']) { // if ($entity->getBilling() == PAYMENT['BILLING']['ONETIME']) {
@ -176,7 +176,7 @@ class ServerPartService extends EquipmentService
if ($entity->getServiceInfoUID() !== null) { if ($entity->getServiceInfoUID() !== null) {
//월비용 서버파트 인경우 서비스 금액 재설정 //월비용 서버파트 인경우 서비스 금액 재설정
if ($entity->getBilling() == PAYMENT['BILLING']['MONTH']) { if ($entity->getBilling() == PAYMENT['BILLING']['MONTH']) {
service('customer_serviceservice')->updateAmountByPK($entity->getServiceInfoUID()); service('customer_serviceservice')->saveAmountByPK($entity->getServiceInfoUID());
} }
//Billing형식이 Onetime이면 일회성결제 수정 (필요없는듯 하여 주석처리) //Billing형식이 Onetime이면 일회성결제 수정 (필요없는듯 하여 주석처리)
// if ($entity->getBilling() == PAYMENT['BILLING']['ONETIME']) { // if ($entity->getBilling() == PAYMENT['BILLING']['ONETIME']) {

View File

@ -249,7 +249,7 @@ class ServerService extends EquipmentService
service('equipment_chassisservice')->attachToServer($entity); service('equipment_chassisservice')->attachToServer($entity);
} }
if ($entity->getServiceInfoUID() !== null) { //서비스가 정의 되어 있으면 if ($entity->getServiceInfoUID() !== null) { //서비스가 정의 되어 있으면
service('customer_serviceservice')->updateAmountByPK($entity->getServiceInfoUID()); service('customer_serviceservice')->saveAmountByPK($entity->getServiceInfoUID());
} }
return $entity; return $entity;
} }

View File

@ -98,9 +98,12 @@ class MylogService extends CommonService implements PipelineStepInterface
$message = "[{$context->action}_{$status}] Steps Executed: " . count($context->pipelineDatas); $message = "[{$context->action}_{$status}] Steps Executed: " . count($context->pipelineDatas);
} }
log_message('debug', $message); log_message('debug', $message);
$formDatas = []; $this->create([
$formDatas['user'] = $context->auth->getUID(); 'title' => "{$context->action} 작업 {$status} 로그",
$this->create(new MylogDTO()); 'content' => $message,
'status' => $status,
'user_uid' => $context->auth->getUID(),
]);
} }
// PipelineStep 구현은 이 예시에서는 사용하지 않습니다. (로그는 Executor가 감쌈) // PipelineStep 구현은 이 예시에서는 사용하지 않습니다. (로그는 Executor가 감쌈)

View File

@ -138,8 +138,8 @@
} }
loadNotices(); // 최초 로드 loadNotices(); // 최초 로드
loadrequesttasks(); // 최초 로드 loadrequesttasks(); // 최초 로드
setInterval(loadNotices, 10000); // 10초마다 갱신 setInterval(loadNotices, 60000); // 60초마다 갱신
setInterval(loadrequesttasks, 10000); // 10초마다 갱신 setInterval(loadrequesttasks, 60000); // 60초마다 갱신
}); });
</script> </script>
<!-- top end --> <!-- top end -->

View File

@ -12,23 +12,23 @@ function getTotalPrice() {
} }
// 공통 업데이트 함수 // 공통 업데이트 함수
function updateAmount() { function setAmount() {
if (amountInput) { if (amountInput) {
amountInput.value = getTotalPrice(); amountInput.value = getTotalPrice();
} }
} }
// 이벤트 리스너 등록 // 이벤트 리스너 등록
if (rackSelect) rackSelect.addEventListener("change", updateAmount); if (rackSelect) rackSelect.addEventListener("change", setAmount);
if (lineSelect) lineSelect.addEventListener("change", updateAmount); if (lineSelect) lineSelect.addEventListener("change", setAmount);
// ✅ select2는 전용 이벤트 사용 // ✅ select2는 전용 이벤트 사용
if (serverSelect) { if (serverSelect) {
$(serverSelect).on("select2:select", function () { $(serverSelect).on("select2:select", function () {
updateAmount(); setAmount();
if (titleInput) { if (titleInput) {
titleInput.value = serverSelect?.options[serverSelect.selectedIndex]?.text || ""; titleInput.value = serverSelect?.options[serverSelect.selectedIndex]?.text || "";
} }
}); });
} }
//페이지 로드 시 초기 실행 //페이지 로드 시 초기 실행
document.addEventListener("DOMContentLoaded", updateAmount); document.addEventListener("DOMContentLoaded", setAmount);