dbmsv4 init...3
This commit is contained in:
parent
59ca55c8dd
commit
9a0b2eee5a
@ -88,7 +88,9 @@ class ServiceController extends CustomerController
|
||||
//대체서버 생성
|
||||
public function alternative_create(int $uid): string|RedirectResponse
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
try {
|
||||
$db->transException(true)->transStart();
|
||||
//추가할 대체서버 정의
|
||||
$serverinfo_uid = $this->request->getGet('serverinfo_uid');
|
||||
if (!$serverinfo_uid) {
|
||||
@ -101,8 +103,11 @@ class ServiceController extends CustomerController
|
||||
}
|
||||
//대체서버 추가
|
||||
service('equipment_serverservice')->attatchToService($entity, $serverinfo_uid);
|
||||
// 트랜잭션 완료 및 커밋
|
||||
$db->transComplete();
|
||||
return $this->action_redirect_process('info', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 대체서버 추가가 완료되었습니다.");
|
||||
} catch (\Throwable $e) {
|
||||
$db->transRollback(); // 예외 발생 시 수동으로 롤백
|
||||
return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 대체서버 추가 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
@ -136,7 +141,9 @@ class ServiceController extends CustomerController
|
||||
//대체서버 해지
|
||||
public function alternative_delete(int $uid): string|RedirectResponse
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
try {
|
||||
$db->transException(true)->transStart();
|
||||
//해지할 대체서버 정의
|
||||
$serverinfo_uid = $this->request->getGet('serverinfo_uid');
|
||||
if (!$serverinfo_uid) {
|
||||
@ -149,8 +156,11 @@ class ServiceController extends CustomerController
|
||||
}
|
||||
//대체서버 해지
|
||||
service('equipment_serverservice')->deatchFromService($serverinfo_uid);
|
||||
// 트랜잭션 완료 및 커밋
|
||||
$db->transComplete();
|
||||
return $this->action_redirect_process('info', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 대체서버 해지가 완료되었습니다.");
|
||||
} catch (\Throwable $e) {
|
||||
$db->transRollback(); // 예외 발생 시 수동으로 롤백
|
||||
return $this->action_redirect_process('error', static::class . '->' . __FUNCTION__ . "에서 {$this->getTitle()} 대체서버 해지 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -123,28 +123,26 @@ abstract class CommonForm
|
||||
}
|
||||
$dynamicRules = [];
|
||||
$dynamicLabels = []; // 레이블 배열 추가
|
||||
try {
|
||||
foreach ($this->getFormRules() as $field => $rule) {
|
||||
list($field, $rule) = $this->getValidationRule($field, $rule);
|
||||
$dynamicRules[$field] = $rule; // 규칙만 저장
|
||||
$dynamicLabels[$field] = $this->getFormFields()[$field];
|
||||
}
|
||||
if (!count($dynamicRules)) {
|
||||
log_message('debug', 'Validate Rules: ' . var_export($this->getFormRules(), true));
|
||||
log_message('debug', 'Validate Dynamic Rules: ' . var_export($dynamicRules, true));
|
||||
log_message('debug', 'Validate Data: ' . var_export($formDatas, true));
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 지정된 Form RULE이 없습니다.");
|
||||
}
|
||||
// setRules의 세 번째 인자로 레이블 전달
|
||||
$this->_validation->setRules($dynamicRules, [], $dynamicLabels);
|
||||
$result = $this->_validation->run($formDatas);
|
||||
if ($result === false) {
|
||||
$message = static::class . '->' . __FUNCTION__ . "에서 데이터 검증 오류발생: " . var_export($this->_validation->getErrors(), true);
|
||||
log_message('debug', $message);
|
||||
throw new RuntimeException($message);
|
||||
} else {
|
||||
log_message('debug', 'Validate Run Succeeded.');
|
||||
if ($this->_validation->run($formDatas)) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 데이터 검증 오류발생: " . var_export($this->_validation->getErrors(), true));
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
log_message('debug', 'Validate Rules: ' . var_export($this->getFormRules(), true));
|
||||
log_message('debug', 'Validate Dynamic Rules: ' . var_export($dynamicRules, true));
|
||||
log_message('debug', 'Validate Data: ' . var_export($formDatas, true));
|
||||
throw new RuntimeException($e->getMessage());
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
//필수함수
|
||||
|
||||
@ -14,6 +14,12 @@ class IPForm extends PartForm
|
||||
case "lineinfo_uid":
|
||||
$rule = "required|numeric";
|
||||
break;
|
||||
case "old_clientinfo_uid":
|
||||
case "clientinfo_uid":
|
||||
case "serviceinfo_uid":
|
||||
case "serverinfo_uid":
|
||||
$rule = "permit_empty|numeric";
|
||||
break;
|
||||
case "ip": //ipv4 , ipv6 , both(ipv4,ipv6)
|
||||
$rule = sprintf("required|trim|valid_ip[both]%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
break;
|
||||
|
||||
@ -64,10 +64,7 @@ class GoogleService extends AuthService
|
||||
{
|
||||
try {
|
||||
//입력값 검증
|
||||
if (!$this->getFormService()->validate($formDatas)) {
|
||||
throw new ValidationException(implode("\n", service('validation')->getErrors()));
|
||||
}
|
||||
|
||||
$this->getFormService()->validate($formDatas);
|
||||
$this->socket->setToken($formDatas['access_code']);
|
||||
$sns_entity = $this->socket->signup();
|
||||
// local db 사용와의 연결 확인
|
||||
|
||||
@ -61,9 +61,7 @@ class LocalService extends AuthService
|
||||
protected function login_process(array $formDatas): UserEntity
|
||||
{
|
||||
//입력값 검증
|
||||
if (!$this->getFormService()->validate($formDatas)) {
|
||||
throw new ValidationException(implode("\n", service('validation')->getErrors()));
|
||||
}
|
||||
$this->getFormService()->validate($formDatas);
|
||||
//로그인 정보확인
|
||||
$entity = $this->getEntity(['id' => $formDatas['id'], 'status' => 'AVAILABLE']);
|
||||
if (!$entity instanceof UserEntity) {
|
||||
|
||||
@ -7,6 +7,7 @@ use App\Entities\CommonEntity;
|
||||
use App\Libraries\AuthContext;
|
||||
use App\Models\CommonModel;
|
||||
use App\Services\Equipment\ServerService;
|
||||
use App\Services\Part\IPService;
|
||||
use CodeIgniter\Database\Exceptions\DatabaseException;
|
||||
use CodeIgniter\Validation\Exceptions\ValidationException;
|
||||
use RuntimeException;
|
||||
@ -179,9 +180,7 @@ abstract class CommonService
|
||||
protected function create_process(array $formDatas): object
|
||||
{
|
||||
// 데이터 검증
|
||||
if (!$this->getFormService()->validate($formDatas)) {
|
||||
throw new ValidationException(implode("\n", service('validation')->getErrors()));
|
||||
}
|
||||
$this->getFormService()->validate($formDatas);
|
||||
// 💡 동적으로 가져온 Entity 클래스 이름으로 instanceof 검사
|
||||
$entityClass = $this->getEntityClass();
|
||||
$entity = new $entityClass($formDatas);
|
||||
@ -225,19 +224,8 @@ abstract class CommonService
|
||||
$fields = array_keys($formDatas);
|
||||
$this->getFormService()->setFormFields($fields);
|
||||
$this->getFormService()->setFormRules('modify', $fields);
|
||||
// if (static::class === PaymentService::class) {
|
||||
// var_dump($this->getFormService()->getFormRules());
|
||||
// echo "<HR>";
|
||||
// var_dump($formDatas);
|
||||
// dd($entity->toArray());
|
||||
// echo "<HR>";
|
||||
// }
|
||||
// 데이터 검증
|
||||
if (!$this->getFormService()->validate($formDatas)) {
|
||||
throw new ValidationException(
|
||||
implode("\n", service('validation')->getErrors())
|
||||
);
|
||||
}
|
||||
$this->getFormService()->validate($formDatas);
|
||||
//PK 추가
|
||||
$pkField = $this->getPKField();
|
||||
if (!isset($formDatas[$pkField]) && !empty($entity->getPK())) {
|
||||
|
||||
@ -2,13 +2,14 @@
|
||||
|
||||
namespace App\Services\Equipment;
|
||||
|
||||
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\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 CodeIgniter\Database\Exceptions\DatabaseException;
|
||||
use RuntimeException;
|
||||
|
||||
class ServerService extends EquipmentService
|
||||
{
|
||||
@ -309,6 +310,7 @@ class ServerService extends EquipmentService
|
||||
$formDatas["switchinfo_uid"] = NULL;
|
||||
$formDatas["ip"] = NULL;
|
||||
$formDatas['status'] = $formDatas['status'] ?? STATUS['AVAILABLE'];
|
||||
parent::modify_process($entity, $formDatas);
|
||||
$entity = parent::modify_process($entity, $formDatas);
|
||||
throw new RuntimeException(var_export($entity, true));
|
||||
}
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ class IPService extends PartType3Service
|
||||
{
|
||||
/** @var IPEntity $entity IDE에 entity type알려주기*/
|
||||
$entity = $this->getPartEntityByServer($serverEntity);
|
||||
$formDatas['old_clientinfo_uid'] = $entity->getClientInfoUID();
|
||||
$formDatas['old_clientinfo_uid'] = $entity->getClientInfoUID() ?? $serverEntity->getClientInfoUID();
|
||||
$entity = parent::detachFromServer($serverEntity, $formDatas);
|
||||
return $entity;
|
||||
}
|
||||
|
||||
@ -37,7 +37,8 @@ abstract class PartType3Service extends PartType2Service
|
||||
$formDatas['status'] = STATUS['AVAILABLE'];
|
||||
//파트정보가져오기
|
||||
$entity = $this->getPartEntityByServer($serverEntity);
|
||||
//파트정보 수정
|
||||
return parent::modify_process($entity, $formDatas);
|
||||
$entity = parent::modify_process($entity, $formDatas);
|
||||
// dd($entity);
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
use App\Entities\Customer\Wallet\CouponEntity;
|
||||
<div class="rounded border border-gray p-2 mt-3">
|
||||
<div style="font-size:15px">미지급 1회성정보</div>
|
||||
<table class="table table-bordered table-hover table-striped">
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<th style="width: 250px">
|
||||
<?= $serverCellDatas['serviceEntity']->getServerInfoUID() == $entity->getPK() ? "📌" : "<a href=\"/admin/customer/service/changeServer/{$serverCellDatas['serviceEntity']->getPK()}?serverinfo_uid={$entity->getPK()}\">✔️</a>" ?>
|
||||
<?= $serverCellDatas['serverPartHelper']->getFieldView('SERVER', "", ['serverEntity' => $entity]) ?>
|
||||
<a href="/admin/customer/service/terminateServer/{$serverCellDatas['serviceEntity']->getPK()}?serverinfo_uid={$entity->getPK()}">❌</a>
|
||||
<?= "<a href=\"/admin/customer/service/terminateServer/{$serverCellDatas['serviceEntity']->getPK()}?serverinfo_uid={$entity->getPK()}\">❌</a>" ?>
|
||||
</th>
|
||||
<th style=" width: 250px">
|
||||
<?= $serverCellDatas['serverPartHelper']->getListButton('CPU', 'CPU', ['serverinfo_uid' => $entity->getPK()]) ?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user