dbms_init...1

This commit is contained in:
choi.jh 2025-07-04 18:36:10 +09:00
parent 0cc866ce80
commit af3ff49682
23 changed files with 251 additions and 269 deletions

View File

@ -331,8 +331,6 @@ define('LAYOUTS', [
'<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">', '<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">',
'<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">', '<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">',
'<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">', '<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">',
'<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css">',
'<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.min.css" />',
'<link rel="stylesheet" href="/css/common/style.css" />', '<link rel="stylesheet" href="/css/common/style.css" />',
], ],
'javascripts' => [ 'javascripts' => [
@ -363,6 +361,7 @@ define('LAYOUTS', [
'<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">', '<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">',
'<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css">', '<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css">',
'<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.min.css" />', '<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.min.css" />',
'<link rel="stylesheet" href="/assets/tagify/dist/tagify.css">',
'<link rel="stylesheet" href="/css/common/style.css" />', '<link rel="stylesheet" href="/css/common/style.css" />',
], ],
'javascripts' => [ 'javascripts' => [
@ -370,6 +369,8 @@ define('LAYOUTS', [
'<script src="//code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>', '<script src="//code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>',
'<script src="//cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>', '<script src="//cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>',
'<script src="//cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>', '<script src="//cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>',
'<script src="/assets/tinymce/tinymce.min.js" referrerpolicy="origin"></script>',
'<script src="/assets/tagify/dist/tagify.js"></script>'
], ],
], ],
]); ]);

View File

@ -299,6 +299,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->post('batchjob', 'DomainController::batchjob'); $routes->post('batchjob', 'DomainController::batchjob');
$routes->post('batchjob_delete', 'DomainController::batchjob_delete'); $routes->post('batchjob_delete', 'DomainController::batchjob_delete');
$routes->get('download/(:alpha)', 'DomainController::download/$1'); $routes->get('download/(:alpha)', 'DomainController::download/$1');
$routes->post('confirm', 'DomainController::confirm');
}); });
}); });
}); });

View File

@ -16,8 +16,6 @@ abstract class AdminController extends CommonController
$this->uri_path = "admin/"; $this->uri_path = "admin/";
$this->view_path = "admin" . DIRECTORY_SEPARATOR; $this->view_path = "admin" . DIRECTORY_SEPARATOR;
$this->content_title = "관리자"; $this->content_title = "관리자";
$this->individualStylesheets = [];
$this->individualScripts = [];
$this->helper = $this->getHelper(); $this->helper = $this->getHelper();
} }
} }

View File

@ -68,33 +68,38 @@ class ServiceController extends CustomerController
} }
//Index,FieldForm관련 //Index,FieldForm관련
//추가관련 //추가관련
protected function create_process(array $formDatas): mixed protected function create_process(array $formDatas): void
{ {
//수정자 정보 자동추가용 //수정자 정보 자동추가용
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo(); $formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
return parent::create_process($formDatas); //부모처리
parent::create_process($formDatas);
} }
//수정관련 //수정관련
protected function modify_process(mixed $entity, array $formDatas): mixed protected function modify_process(mixed $entity, array $formDatas): void
{ {
//수정자 정보 자동추가용 //수정자 정보 자동추가용
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo(); $formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
return parent::modify_process($entity, $formDatas); //부모처리
parent::modify_process($entity, $formDatas);
} }
//View 관련 //View 관련
protected function view_process(mixed $entity): mixed protected function view_process(mixed $entity): void
{ {
//LINE,IP,SERVER등 추가 FilterOption 셋팅용 //LINE,IP,SERVER등 추가 FilterOption 셋팅용
$this->setFilterOptionsByItemType(); $this->setFilterOptionsByItemType();
//각각의 Item항목 정의 //각각의 Item항목 정의
return $this->getService()->setItemEntitiesByService($entity); $this->getService()->setItemEntitiesByService($entity);
//부모처리
parent::view_process($entity);
} }
//Delete 관련 //Delete 관련
protected function delete_process(mixed $entity): mixed protected function delete_process(mixed $entity): void
{ {
//각각의 Item항목 정의 //각각의 Item항목 정의
$entity = $this->getService()->setItemEntitiesByService($entity); $entity = $this->getService()->setItemEntitiesByService($entity);
return parent::delete_process($entity); //부모처리
parent::delete_process($entity);
} }
//List 관련 //List 관련
protected function setWordConditionForList(): void protected function setWordConditionForList(): void
@ -108,17 +113,20 @@ class ServiceController extends CustomerController
} }
} }
} }
protected function index_process(): array protected function index_process(): void
{ {
//서비스별 미납 Count //서비스별 미납 Count
$this->unPaids = $this->getServicePaymentService()->getUnPaidCountByService(); $this->unPaids = $this->getServicePaymentService()->getUnPaidCountByService();
//LINE,IP,SERVER등 추가 FilterOption 셋팅용 //LINE,IP,SERVER등 추가 FilterOption 셋팅용
$this->setFilterOptionsByItemType(); $this->setFilterOptionsByItemType();
//부모함수처리
parent::index_process();
//추가처리
$entities = []; $entities = [];
foreach (parent::index_process() as $entity) { foreach ($this->entities as $entity) {
//각각의 Item항목 정의 //각각의 Item항목 정의
$entities[$entity->getPK()] = $this->getService()->setItemEntitiesByService($entity); $entities[$entity->getPK()] = $this->getService()->setItemEntitiesByService($entity);
} }
return $entities; $this->$entities = $entities;
} }
} }

View File

@ -88,12 +88,13 @@ class ServiceItemController extends CustomerController
} }
//Index,FieldForm관련 //Index,FieldForm관련
protected function create_process(array $formDatas): ServiceItemEntity protected function create_process(array $formDatas): void
{ {
$serviceEntity = $this->getServiceService()->getEntity($formDatas['serviceinfo_uid']); $serviceEntity = $this->getServiceService()->getEntity($formDatas['serviceinfo_uid']);
if (!$serviceEntity) { if (!$serviceEntity) {
throw new \Exception("{$formDatas['serviceinfo_uid']}에 대한 서비스정보를 찾을수 없습니다."); throw new \Exception("{$formDatas['serviceinfo_uid']}에 대한 서비스정보를 찾을수 없습니다.");
} }
return parent::create_process($formDatas); //부모처리
parent::create_process($formDatas);
} }
} }

View File

@ -82,25 +82,28 @@ class ServicePaymentController extends CustomerController
} }
//Index,FieldForm관련 //Index,FieldForm관련
//추가관련 //추가관련
protected function create_process(array $formDatas): mixed protected function create_process(array $formDatas): void
{ {
//수정자 정보 자동추가용 //수정자 정보 자동추가용
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo(); $formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
return parent::create_process($formDatas); //부모처리
parent::create_process($formDatas);
} }
//수정관련 //수정관련
protected function modify_process(mixed $entity, array $formDatas): mixed protected function modify_process(mixed $entity, array $formDatas): void
{ {
//수정자 정보 자동추가용 //수정자 정보 자동추가용
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo(); $formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
return parent::modify_process($entity, $formDatas); //부모처리
parent::modify_process($entity, $formDatas);
} }
//View 관련 //View 관련
protected function view_process(mixed $entity): mixed protected function view_process(mixed $entity): void
{ {
//LINE,IP,SERVER등 추가 FilterOption 셋팅용 //LINE,IP,SERVER등 추가 FilterOption 셋팅용
$this->setFilterOptionsByItemType(); $this->setFilterOptionsByItemType();
return parent::view_process($entity); //부모처리
parent::view_process($entity);
} }
//List 관련 //List 관련
protected function setOrderByForList(): void protected function setOrderByForList(): void
@ -109,11 +112,12 @@ class ServicePaymentController extends CustomerController
$this->getService()->getModel()->orderBy('billing_at', 'ASC', false); $this->getService()->getModel()->orderBy('billing_at', 'ASC', false);
parent::setOrderByForList(); parent::setOrderByForList();
} }
protected function index_process(): array protected function index_process(): void
{ {
//LINE,IP,SERVER등 추가 FilterOption 셋팅용 //LINE,IP,SERVER등 추가 FilterOption 셋팅용
$this->setFilterOptionsByItemType(); $this->setFilterOptionsByItemType();
return parent::index_process(); //부모처리
parent::index_process();
} }
//Invoice 관련 //Invoice 관련
private function getOwnersForInvoice(ClientEntity $ownerEntity): array private function getOwnersForInvoice(ClientEntity $ownerEntity): array
@ -145,7 +149,7 @@ class ServicePaymentController extends CustomerController
]; ];
return $temps; return $temps;
} }
private function invoice_process(): array private function invoice_process(): void
{ {
//변경할 UIDS //변경할 UIDS
$uids = $this->request->getPost('batchjob_uids[]'); $uids = $this->request->getPost('batchjob_uids[]');
@ -187,7 +191,7 @@ class ServicePaymentController extends CustomerController
$entities[$ownerEntity->getPK()]['total_amount'] += $entity->getAmount(); $entities[$ownerEntity->getPK()]['total_amount'] += $entity->getAmount();
} }
// dd($entities); // dd($entities);
return $entities; $this->entities = $entities;
} }
public function invoice(): RedirectResponse|string public function invoice(): RedirectResponse|string
{ {
@ -198,7 +202,7 @@ class ServicePaymentController extends CustomerController
$options = $this->getService()->getServiceItemLinkService($item_type)->getEntities(); $options = $this->getService()->getServiceItemLinkService($item_type)->getEntities();
$this->setFilterFieldOption($item_type, $options); $this->setFilterFieldOption($item_type, $options);
} }
$this->entities = $this->invoice_process(); $this->invoice_process();
return $this->getResultSuccess(); return $this->getResultSuccess();
} catch (\Exception $e) { } catch (\Exception $e) {
return $this->getResultFail($e->getMessage()); return $this->getResultFail($e->getMessage());

View File

@ -5,6 +5,7 @@ namespace App\Controllers\Admin\Equipment\Part;
use App\Helpers\Equipment\Part\DomainHelper; use App\Helpers\Equipment\Part\DomainHelper;
use App\Services\Equipment\Part\DomainService; use App\Services\Equipment\Part\DomainService;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
@ -34,8 +35,58 @@ class DomainController extends PartController
} }
return $this->_helper; return $this->_helper;
} }
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
{
helper(['form']);
switch ($this->getAction()) {
case 'create':
$this->control = $this->getControlDatas();
$this->getHelper()->setViewDatas($this->getViewDatas());
$view_file = $this->view_path . 'domain' . DIRECTORY_SEPARATOR . 'view';
$result = view($view_file, ['viewDatas' => $this->getViewDatas()]);
break;
default:
$result = parent::getResultSuccess($message, $actionTemplate);
break;
}
return $result;
}
//Index,FieldForm관련 //Index,FieldForm관련
protected function create_process(array $formDatas): void
{
$entities = [];
//formDatas는 Json 값으로 넘어온다.
foreach (json_decode($formDatas['domain'], true) as $domain) {
//데이터 검증
$validDatas = $this->doValidate(
$this->getFieldRules(),
['domain' => $domain['value'], 'status' => $formDatas['status']]
);
$entities[] = $this->getService()->create($validDatas);
}
$this->entities = $entities;
}
//도메인 존재여부 검증용
final public function confirm(string $field = "domain"): ResponseInterface
{
try {
//각 Field 초기화:조건항목 Field는 한개만 존재하므로 Field와 Rule을 정의
$this->setAction(__FUNCTION__);
$this->setFormFields([$field]);
$this->setFieldRule($field, $this->getFormFieldRule($this->getAction(), $field));
//입력값정의
$domain = $this->request->getVar($field);
//기존 존재하는 Domain인지 확인용 Entity 가져오기
$entity = $this->getService()->getEntity([$field => $domain], "");
return $this->response
->setContentType('application/json')
->setBody(json_encode(['exists' => true, 'message' => "[{$entity->getTitle()}] 이미 존재하는 도메인입니다."]));
} catch (\Exception $e) {
return $this->response
->setContentType('application/json')
->setBody(json_encode(['exists' => false, 'message' => $e->getMessage()]));
}
}
protected function setOrderByForList(): void protected function setOrderByForList(): void
{ {
//OrderBy 처리 //OrderBy 처리

View File

@ -48,17 +48,17 @@ class LineController extends PartController
//Index,FieldForm관련 //Index,FieldForm관련
//생성 //생성
protected function create_process(array $formDatas): LineEntity protected function create_process(array $formDatas): void
{ {
//Line 등록 //Line 등록
if (!$this->getHelper()->isValidCIDR($formDatas['bandwith'])) { if (!$this->getHelper()->isValidCIDR($formDatas['bandwith'])) {
throw new \Exception("{$formDatas['bandwith']}는 CIDR 형식에 부합되지 않습니다."); throw new \Exception("{$formDatas['bandwith']}는 CIDR 형식에 부합되지 않습니다.");
} }
$entity = parent::create_process($formDatas); //부모처리
parent::create_process($formDatas);
//Prefixed IP to array 등록 //Prefixed IP to array 등록
foreach ($this->getHelper()->cidrToIpRange($formDatas['bandwith']) as $ip) { foreach ($this->getHelper()->cidrToIpRange($formDatas['bandwith']) as $ip) {
$this->getIpService()->createByLineInfo($entity, $ip); $this->getIpService()->createByLineInfo($this->entity, $ip);
} }
return $entity;
} }
} }

View File

@ -36,7 +36,7 @@ class ServerController extends EquipmentController
} }
//Index,FieldForm관련 //Index,FieldForm관련
//View부분 //View부분
protected function view_process(mixed $entity): mixed protected function view_process(mixed $entity): void
{ {
foreach (SERVICE_ITEM_TYPES as $item_type => $label) { foreach (SERVICE_ITEM_TYPES as $item_type => $label) {
$entity->setItemEntities( $entity->setItemEntities(
@ -44,7 +44,8 @@ class ServerController extends EquipmentController
$this->getService()->getEntities(['serviceinfo_uid' => $entity->getPK(), 'item_type' => $item_type]) $this->getService()->getEntities(['serviceinfo_uid' => $entity->getPK(), 'item_type' => $item_type])
); );
} }
return parent::view_process($entity); //부모처리
parent::view_process($entity);
} }
//List부분 //List부분
protected function setOrderByForList(): void protected function setOrderByForList(): void

View File

@ -118,8 +118,8 @@ class UserController extends AdminController
protected function profile_modify_process(mixed $entity, array $formDatas): mixed protected function profile_modify_process(mixed $entity, array $formDatas): mixed
{ {
//데이터 검증 //데이터 검증
$formDatas = $this->doValidate($this->getFieldRules(), $formDatas); $validDatas = $this->doValidate($this->getFieldRules(), $formDatas);
return $this->getService()->modify($entity, $formDatas); return $this->getService()->modify($entity, $validDatas);
} }
final public function profile_modify(int $uid): RedirectResponse|string final public function profile_modify(int $uid): RedirectResponse|string
{ {

View File

@ -41,11 +41,11 @@ class GoogleController extends AuthController
} }
//로그인처리 //로그인처리
protected function create_process(array $formDatas): UserEntity protected function create_process(array $formDatas): void
{ {
if (!array_key_exists('access_code', $formDatas) || !$formDatas['access_code']) { if (!array_key_exists('access_code', $formDatas) || !$formDatas['access_code']) {
throw new \Exception("구글 로그인 실패"); throw new \Exception("구글 로그인 실패");
} }
return $this->getService()->login($formDatas); $this->entity = $this->getService()->login($formDatas);
} }
} }

View File

@ -29,8 +29,8 @@ class LocalController extends AuthController
return ""; return "";
} }
//로그인처리 //로그인처리
protected function create_process(array $formDatas): UserEntity protected function create_process(array $formDatas): void
{ {
return $this->getService()->login($formDatas); $this->entity = $this->getService()->login($formDatas);
} }
} }

View File

@ -218,6 +218,7 @@ abstract class CommonController extends BaseController
if (!$validation) { if (!$validation) {
$validation = service('validation'); $validation = service('validation');
} }
// dd($rules);
foreach ($rules as $field => $rule) { foreach ($rules as $field => $rule) {
$validation = $this->setValidation($validation, $field, $rule); $validation = $this->setValidation($validation, $field, $rule);
} }
@ -242,6 +243,7 @@ abstract class CommonController extends BaseController
} }
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
{ {
helper(['form']);
switch ($this->getAction()) { switch ($this->getAction()) {
case 'create': case 'create':
case 'modify': case 'modify':
@ -295,11 +297,11 @@ abstract class CommonController extends BaseController
return $this->getResultFail($e->getMessage()); return $this->getResultFail($e->getMessage());
} }
} }
protected function create_process(array $formDatas): mixed protected function create_process(array $formDatas): void
{ {
//데이터 검증 //데이터 검증
$formDatas = $this->doValidate($this->getFieldRules(), $formDatas); $validDatas = $this->doValidate($this->getFieldRules(), $formDatas);
return $this->getService()->create($formDatas); $this->entity = $this->getService()->create($validDatas);
} }
final public function create(): RedirectResponse|string final public function create(): RedirectResponse|string
{ {
@ -313,7 +315,7 @@ abstract class CommonController extends BaseController
$formDatas[$field] = $this->request->getPost($field); $formDatas[$field] = $this->request->getPost($field);
} }
// dd($formDatas); // dd($formDatas);
$this->entity = $this->create_process($formDatas); $this->create_process($formDatas);
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
return $this->getResultSuccess(); return $this->getResultSuccess();
} catch (\Exception $e) { } catch (\Exception $e) {
@ -322,9 +324,9 @@ abstract class CommonController extends BaseController
} }
} }
//수정관련 //수정관련
protected function modify_form_process(mixed $entity): mixed protected function modify_form_process(mixed $entity): void
{ {
return $entity; $this->entity = $entity;
} }
final public function modify_form(mixed $uid): RedirectResponse|string final public function modify_form(mixed $uid): RedirectResponse|string
{ {
@ -345,18 +347,18 @@ abstract class CommonController extends BaseController
if (!$entity) { if (!$entity) {
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다."); throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
} }
$this->entity = $this->modify_form_process($entity); $this->modify_form_process($entity);
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []]; $this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
return $this->getResultSuccess(); return $this->getResultSuccess();
} catch (\Exception $e) { } catch (\Exception $e) {
return $this->getResultFail($e->getMessage()); return $this->getResultFail($e->getMessage());
} }
} }
protected function modify_process(mixed $entity, array $formDatas): mixed protected function modify_process(mixed $entity, array $formDatas): void
{ {
//데이터 검증 //데이터 검증
$formDatas = $this->doValidate($this->getFieldRules(), $formDatas); $validDatas = $this->doValidate($this->getFieldRules(), $formDatas);
return $this->getService()->modify($entity, $formDatas); $this->entity = $this->getService()->modify($entity, $validDatas);
} }
final public function modify(int $uid): RedirectResponse|string final public function modify(int $uid): RedirectResponse|string
{ {
@ -375,7 +377,7 @@ abstract class CommonController extends BaseController
if (!$entity) { if (!$entity) {
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다."); throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
} }
$this->entity = $this->modify_process($entity, $formDatas); $this->modify_process($entity, $formDatas);
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
return $this->getResultSuccess(); return $this->getResultSuccess();
} catch (\Exception $e) { } catch (\Exception $e) {
@ -384,10 +386,11 @@ abstract class CommonController extends BaseController
} }
} }
//단일필드작업 //단일필드작업
final protected function toggle_process(mixed $entity, array $formDatas): mixed final protected function toggle_process(mixed $entity, array $formDatas): void
{ {
//modify_process를 호출하여 수정처리 //데이터 검증
return $this->modify_process($entity, $formDatas); $validDatas = $this->doValidate($this->getFieldRules(), $formDatas);
$this->entity = $this->getService()->modify($entity, $validDatas);
} }
final public function toggle(mixed $uid, string $field): RedirectResponse|string final public function toggle(mixed $uid, string $field): RedirectResponse|string
{ {
@ -405,7 +408,7 @@ abstract class CommonController extends BaseController
if (!$entity) { if (!$entity) {
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다."); throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
} }
$this->entity = $this->toggle_process($entity, $formDatas); $this->toggle_process($entity, $formDatas);
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
return $this->getResultSuccess(); return $this->getResultSuccess();
} catch (\Exception $e) { } catch (\Exception $e) {
@ -414,10 +417,21 @@ abstract class CommonController extends BaseController
} }
} }
//일괄처리작업 //일괄처리작업
final protected function batchjob_process(mixed $entity, array $formDatas): mixed final protected function batchjob_process(array $uids, array $formDatas): void
{ {
//modify_process를 호출하여 수정처리 $entities = [];
return $this->modify_process($entity, $formDatas); foreach ($uids as $uid) {
//기존 Entity 가져오기
$entity = $this->getService()->getEntity($uid);
if (!$entity) {
LogCollector::debug(__METHOD__ . "에서 {$uid}에 대한 정보를 찾을수 없습니다.");
} else {
//데이터 검증
$validDatas = $this->doValidate($this->getFieldRules(), $formDatas);
$entities[] = $this->getService()->modify($entity, $validDatas);
}
}
$this->entities = $entities;
} }
final public function batchjob(): RedirectResponse|string final public function batchjob(): RedirectResponse|string
{ {
@ -448,19 +462,9 @@ abstract class CommonController extends BaseController
foreach ($selectedFields as $field) { foreach ($selectedFields as $field) {
$this->setFieldRule($field, $this->getFormFieldRule($this->getAction(), $field)); $this->setFieldRule($field, $this->getFormFieldRule($this->getAction(), $field));
} }
$entities = []; $this->batchjob_process($uids, $formDatas);
foreach ($uids as $uid) {
//기존 Entity 가져오기
$entity = $this->getService()->getEntity($uid);
if (!$entity) {
LogCollector::debug(__METHOD__ . "에서 {$uid}에 대한 정보를 찾을수 없습니다.");
} else {
$entities[] = $this->batchjob_process($entity, $formDatas);
}
}
$this->entities = $entities;
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
LogCollector::debug(sprintf("%s에서 총 %s개중 %s개 일괄작업을 완료하였습니다.", __METHOD__, count($uids), count($entities))); LogCollector::debug(sprintf("%s에서 총 %s개중 %s개 일괄작업을 완료하였습니다.", __METHOD__, count($uids), count($this->entities)));
return $this->getResultSuccess(); return $this->getResultSuccess();
} catch (\Exception $e) { } catch (\Exception $e) {
$this->getService()->getModel()->transRollback(); $this->getService()->getModel()->transRollback();
@ -469,9 +473,9 @@ abstract class CommonController extends BaseController
} }
//삭제,일괄삭제 공통사용 //삭제,일괄삭제 공통사용
protected function delete_process(mixed $entity): mixed protected function delete_process(mixed $entity): void
{ {
return $this->getService()->delete($entity); $this->entity = $this->getService()->delete($entity);
} }
final public function delete(mixed $uid): RedirectResponse|string final public function delete(mixed $uid): RedirectResponse|string
{ {
@ -485,7 +489,7 @@ abstract class CommonController extends BaseController
if (!$entity) { if (!$entity) {
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다."); throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
} }
$this->entity = $this->delete_process($entity); $this->delete_process($entity);
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
return $this->getResultSuccess(); return $this->getResultSuccess();
} catch (\Exception $e) { } catch (\Exception $e) {
@ -494,10 +498,19 @@ abstract class CommonController extends BaseController
} }
} }
//일괄삭제 //일괄삭제
final protected function batchjob_delete_process(mixed $entity): mixed final protected function batchjob_delete_process(array $uids): void
{ {
//delete_process를 호출하여 삭제처리 $entities = [];
return $this->delete_process($entity); foreach ($uids as $uid) {
//기존 Entity 가져오기
$entity = $this->getService()->getEntity($uid);
if (!$entity) {
LogCollector::debug(__METHOD__ . "에서 {$uid}에 대한 정보를 찾을수 없습니다.");
} else {
$entities[] = $this->getService()->delete($entity);
}
}
$this->entities = $entities;
} }
final public function batchjob_delete(): RedirectResponse|string final public function batchjob_delete(): RedirectResponse|string
{ {
@ -511,19 +524,9 @@ abstract class CommonController extends BaseController
} }
//각 Field 초기화:삭제는 다른 초기화 필요없음 //각 Field 초기화:삭제는 다른 초기화 필요없음
$this->setAction(__FUNCTION__); $this->setAction(__FUNCTION__);
$entities = []; $this->batchjob_delete_process($uids);
foreach ($uids as $uid) {
//기존 Entity 가져오기
$entity = $this->getService()->getEntity($uid);
if (!$entity) {
LogCollector::debug(__METHOD__ . "에서 {$uid}에 대한 정보를 찾을수 없습니다.");
} else {
$entities[] = $this->batchjob_delete_process($entity);
}
}
$this->entities = $entities;
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
LogCollector::debug(sprintf("%s에서 총 %s개중 %s개 일괄삭제를 완료하였습니다.", __METHOD__, count($uids), count($entities))); LogCollector::debug(sprintf("%s에서 총 %s개중 %s개 일괄삭제를 완료하였습니다.", __METHOD__, count($uids), count($this->entities)));
return $this->getResultSuccess(); return $this->getResultSuccess();
} catch (\Exception $e) { } catch (\Exception $e) {
$this->getService()->getModel()->transRollback(); $this->getService()->getModel()->transRollback();
@ -532,9 +535,9 @@ abstract class CommonController extends BaseController
} }
//View //View
protected function view_process(mixed $entity): mixed protected function view_process(mixed $entity): void
{ {
return $entity; $this->entity = $entity;
} }
final public function view(string $uid): RedirectResponse|string final public function view(string $uid): RedirectResponse|string
{ {
@ -558,7 +561,7 @@ abstract class CommonController extends BaseController
$this->$field = $value; $this->$field = $value;
} }
} }
$this->entity = $this->view_process($entity); $this->view_process($entity);
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []]; $this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
return $this->getResultSuccess(); return $this->getResultSuccess();
} catch (\Exception $e) { } catch (\Exception $e) {
@ -640,7 +643,7 @@ abstract class CommonController extends BaseController
$this->total_page = $pager->getPageCount($pager_group); $this->total_page = $pager->getPageCount($pager_group);
return $pager->links($pager_group, $template); return $pager->links($pager_group, $template);
} }
protected function index_process(): array protected function index_process(): void
{ {
//조건절 처리 //조건절 처리
$this->setConditionForList(); $this->setConditionForList();
@ -655,7 +658,7 @@ abstract class CommonController extends BaseController
$this->setOrderByForList(); $this->setOrderByForList();
$this->getService()->getModel()->limit($this->per_page); $this->getService()->getModel()->limit($this->per_page);
$this->getService()->getModel()->offset(($this->page - 1) * $this->per_page); $this->getService()->getModel()->offset(($this->page - 1) * $this->per_page);
return $this->getService()->getEntities(); $this->entities = $this->getService()->getEntities();
} }
public function index(): RedirectResponse|string public function index(): RedirectResponse|string
{ {
@ -670,7 +673,7 @@ abstract class CommonController extends BaseController
} }
// 현재 URL을 스택에 저장 // 현재 URL을 스택에 저장
helper(['form']); helper(['form']);
$this->entities = $this->index_process(); $this->index_process();
return $this->getResultSuccess(); return $this->getResultSuccess();
} catch (\Exception $e) { } catch (\Exception $e) {
return $e->getMessage(); return $e->getMessage();
@ -708,8 +711,7 @@ abstract class CommonController extends BaseController
case 'excel': case 'excel':
case 'pdf': case 'pdf':
helper(['form']); helper(['form']);
// string buffer에서 읽어오는 경우 $this->index_process();
$this->entities = $this->index_process();
$html = $this->getResultSuccess(); $html = $this->getResultSuccess();
//data loading //data loading
$reader = new Html(); $reader = new Html();

File diff suppressed because one or more lines are too long

View File

@ -4,8 +4,8 @@
"settings": { "settings": {
"width": 3000, "width": 3000,
"height": 3000, "height": 3000,
"scrollTop": -695.5286, "scrollTop": -1339.1952,
"scrollLeft": -409.6025, "scrollLeft": -710.6025,
"zoomLevel": 0.79, "zoomLevel": 0.79,
"show": 511, "show": 511,
"database": 4, "database": 4,
@ -63,7 +63,6 @@
"wX0DbZb_RcK85hWv9dxcX", "wX0DbZb_RcK85hWv9dxcX",
"anhMCXytE7rcE_drKBPWz", "anhMCXytE7rcE_drKBPWz",
"Wma86GpS3BhikEaHSamgX", "Wma86GpS3BhikEaHSamgX",
"I80TuGxKm3tXIO_EO2PSm",
"o8yw46vm30cC7wl9cRMdo", "o8yw46vm30cC7wl9cRMdo",
"ocWjncqwtYkP02mw4A0-8", "ocWjncqwtYkP02mw4A0-8",
"Hj5AZkoYGvM_syvnqMeOi", "Hj5AZkoYGvM_syvnqMeOi",
@ -717,7 +716,6 @@
"comment": "도메인 정보", "comment": "도메인 정보",
"columnIds": [ "columnIds": [
"XnNj7H0bnTxo_NuZm7BOs", "XnNj7H0bnTxo_NuZm7BOs",
"U3pGwK2LVZA4wQ1xa6EcF",
"w404_rDrrYyt26iqY8Eur", "w404_rDrrYyt26iqY8Eur",
"E8iokQ-rKyw43cNe746kt", "E8iokQ-rKyw43cNe746kt",
"SeMtkfNiltpn4j-M-XkG-", "SeMtkfNiltpn4j-M-XkG-",
@ -745,14 +743,14 @@
], ],
"ui": { "ui": {
"x": 2396.448, "x": 2396.448,
"y": 1019.4062, "y": 1063.71,
"zIndex": 1276, "zIndex": 1276,
"widthName": 63, "widthName": 63,
"widthComment": 65, "widthComment": 65,
"color": "" "color": ""
}, },
"meta": { "meta": {
"updateAt": 1750828790659, "updateAt": 1751612551642,
"createAt": 1748218895681 "createAt": 1748218895681
} }
}, },
@ -796,15 +794,15 @@
"n9ZWAQ9754sZ3MM4IxCAA" "n9ZWAQ9754sZ3MM4IxCAA"
], ],
"ui": { "ui": {
"x": 146.1271, "x": 143.5955,
"y": 927.5572, "y": 908.5701,
"zIndex": 2278, "zIndex": 2278,
"widthName": 110, "widthName": 110,
"widthComment": 60, "widthComment": 60,
"color": "" "color": ""
}, },
"meta": { "meta": {
"updateAt": 1750916226017, "updateAt": 1751612577827,
"createAt": 1748484896313 "createAt": 1748484896313
} }
}, },
@ -6239,7 +6237,7 @@
"default": "", "default": "",
"options": 8, "options": 8,
"ui": { "ui": {
"keys": 2, "keys": 0,
"widthName": 73, "widthName": 73,
"widthComment": 60, "widthComment": 60,
"widthDataType": 60, "widthDataType": 60,
@ -7683,7 +7681,7 @@
"_AcWUYKzNJd-V0fRHq8Cx" "_AcWUYKzNJd-V0fRHq8Cx"
], ],
"x": 2158.5371, "x": 2158.5371,
"y": 648.4446, "y": 662.7779333333333,
"direction": 2 "direction": 2
}, },
"end": { "end": {
@ -7739,7 +7737,7 @@
"_AcWUYKzNJd-V0fRHq8Cx" "_AcWUYKzNJd-V0fRHq8Cx"
], ],
"x": 2158.5371, "x": 2158.5371,
"y": 820.4446, "y": 892.1112666666666,
"direction": 2 "direction": 2
}, },
"end": { "end": {
@ -7767,7 +7765,7 @@
"_AcWUYKzNJd-V0fRHq8Cx" "_AcWUYKzNJd-V0fRHq8Cx"
], ],
"x": 2158.5371, "x": 2158.5371,
"y": 734.4446, "y": 777.4445999999999,
"direction": 2 "direction": 2
}, },
"end": { "end": {
@ -7980,34 +7978,6 @@
"createAt": 1749520727362 "createAt": 1749520727362
} }
}, },
"6oBuPqT-ikPI7X8a05Trv": {
"id": "6oBuPqT-ikPI7X8a05Trv",
"identification": false,
"relationshipType": 16,
"startRelationshipType": 2,
"start": {
"tableId": "JoMB-mb6p6NoHpiAvjD2y",
"columnIds": [
"FMB1Pw8d7ED0xlrEAdVok"
],
"x": 1697.1127,
"y": 1340.0307,
"direction": 1
},
"end": {
"tableId": "B8haiEbPc1lRBWTv1g25G",
"columnIds": [
"O7aGU_LJxCO1NeNVWbB-J"
],
"x": 1457.1138999999998,
"y": 1366.5724666666667,
"direction": 2
},
"meta": {
"updateAt": 1749527376196,
"createAt": 1749527376196
}
},
"Hj5AZkoYGvM_syvnqMeOi": { "Hj5AZkoYGvM_syvnqMeOi": {
"id": "Hj5AZkoYGvM_syvnqMeOi", "id": "Hj5AZkoYGvM_syvnqMeOi",
"identification": false, "identification": false,
@ -8027,8 +7997,8 @@
"columnIds": [ "columnIds": [
"ZWV8iXrgQovfYTm32QGbZ" "ZWV8iXrgQovfYTm32QGbZ"
], ],
"x": 694.1271, "x": 691.5955,
"y": 1254.2238666666667, "y": 1235.2367666666667,
"direction": 2 "direction": 2
}, },
"meta": { "meta": {
@ -8055,8 +8025,8 @@
"columnIds": [ "columnIds": [
"yc1mNA3iMmF8xoUX60z6F" "yc1mNA3iMmF8xoUX60z6F"
], ],
"x": 694.1271, "x": 691.5955,
"y": 1123.5572, "y": 1104.5701,
"direction": 2 "direction": 2
}, },
"meta": { "meta": {
@ -8092,34 +8062,6 @@
"createAt": 1750645375148 "createAt": 1750645375148
} }
}, },
"2TcX9drzSjfyNoNBwHe2B": {
"id": "2TcX9drzSjfyNoNBwHe2B",
"identification": false,
"relationshipType": 16,
"startRelationshipType": 2,
"start": {
"tableId": "6ajvOCaGuXU9pzV0Y9jEi",
"columnIds": [
"_AcWUYKzNJd-V0fRHq8Cx"
],
"x": 1627.5371,
"y": 734.4446,
"direction": 1
},
"end": {
"tableId": "QCNA57Pi6A9dJDgybxS5v",
"columnIds": [
"38UvwuKxUk-yugwJmu0o0"
],
"x": 684.0004,
"y": 1019.2028,
"direction": 2
},
"meta": {
"updateAt": 1750667733988,
"createAt": 1750667733988
}
},
"e74Cc4zZztxyoazM_ssbu": { "e74Cc4zZztxyoazM_ssbu": {
"id": "e74Cc4zZztxyoazM_ssbu", "id": "e74Cc4zZztxyoazM_ssbu",
"identification": false, "identification": false,
@ -8139,8 +8081,8 @@
"columnIds": [ "columnIds": [
"s1Az-lXWK0NlVQqFEEK8o" "s1Az-lXWK0NlVQqFEEK8o"
], ],
"x": 694.1271, "x": 691.5955,
"y": 992.8905333333332, "y": 973.9034333333333,
"direction": 2 "direction": 2
}, },
"meta": { "meta": {
@ -8148,34 +8090,6 @@
"createAt": 1750829265309 "createAt": 1750829265309
} }
}, },
"FHzw49BTN_7RwEJXeKdhl": {
"id": "FHzw49BTN_7RwEJXeKdhl",
"identification": false,
"relationshipType": 16,
"startRelationshipType": 2,
"start": {
"tableId": "IsMoJXzvtuoOFFt93qS0w",
"columnIds": [
"sVypeCGZk-JXvsbwc93Rw"
],
"x": 1696.4192,
"y": 1116.281,
"direction": 1
},
"end": {
"tableId": "B8haiEbPc1lRBWTv1g25G",
"columnIds": [
"AU5HgX9gt97EPfq5SoKnd"
],
"x": 1457.1138999999998,
"y": 1115.9058,
"direction": 2
},
"meta": {
"updateAt": 1750898732189,
"createAt": 1750898732189
}
},
"Y-MNlBi4tzmX_zwrY0zTc": { "Y-MNlBi4tzmX_zwrY0zTc": {
"id": "Y-MNlBi4tzmX_zwrY0zTc", "id": "Y-MNlBi4tzmX_zwrY0zTc",
"identification": false, "identification": false,

View File

@ -19,7 +19,7 @@ class DomainHelper extends PartHelper
} }
switch ($field) { switch ($field) {
case 'domain': case 'domain':
$form = form_input($field, "", ["placeholder" => "예)domain.co.kr", ...$extras]); $form = form_input($field, "", ['id' => $field, "placeholder" => "예)domain.co.kr", ...$extras]);
$form .= "<div id=\"domain-errors\" style=\"color:red; margin-top:5px;\"></div>"; $form .= "<div id=\"domain-errors\" style=\"color:red; margin-top:5px;\"></div>";
break; break;
default: default:

View File

@ -2,7 +2,6 @@
return [ return [
'title' => "Domain정보", 'title' => "Domain정보",
'label' => [ 'label' => [
'clientinfo_uid' => "고객명",
'domain' => "도메인", 'domain' => "도메인",
'expired_at' => "종료일", 'expired_at' => "종료일",
'price' => "금액", 'price' => "금액",

View File

@ -13,7 +13,6 @@ class DomainModel extends PartModel
protected $primaryKey = self::PK; protected $primaryKey = self::PK;
protected $returnType = DomainEntity::class; protected $returnType = DomainEntity::class;
protected $allowedFields = [ protected $allowedFields = [
'clientinfo_uid',
"domain", "domain",
"status", "status",
"updated_at" "updated_at"
@ -28,9 +27,6 @@ class DomainModel extends PartModel
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true)); throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
} }
switch ($field) { switch ($field) {
case "clientinfo_uid":
$rule = "required|numeric";
break;
case "domain": case "domain":
$rule = "required|trim|valid_domain"; $rule = "required|trim|valid_domain";
$rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->table}.{$field}]" : ""; $rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->table}.{$field}]" : "";

View File

@ -23,14 +23,13 @@ class DomainService extends PartService
public function getFormFields(): array public function getFormFields(): array
{ {
return [ return [
"clientinfo_uid",
"domain", "domain",
"status", "status",
]; ];
} }
public function getFilterFields(): array public function getFilterFields(): array
{ {
return ["clientinfo_uid", 'status',]; return ['status',];
} }
public function getBatchJobFields(): array public function getBatchJobFields(): array
{ {
@ -39,6 +38,6 @@ class DomainService extends PartService
public function getIndexFields(): array public function getIndexFields(): array
{ {
return ['clientinfo_uid', 'domain', 'status']; return ['domain', 'status'];
} }
} }

View File

@ -0,0 +1,20 @@
<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?>
<?php if ($error = session('error')): echo $viewDatas['helper']->alert($error) ?><?php endif ?>
<div id="container" class="content">
<link href="/css/<?= $viewDatas['layout'] ?>/form.css" media="screen" rel="stylesheet" type="text/css" />
<div class="action_form">
<table class="table table-bordered">
<?php foreach ($viewDatas['entities'] as $entity): ?>
<?php $viewDatas['entity'] = $entity ?>
<?php foreach ($viewDatas['control']['view_fields'] as $field): ?>
<tr>
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?></th>
<td nowrap class="text-start"><?= $viewDatas['helper']->getFieldView($field, $viewDatas['entity']->$field, $viewDatas) ?></td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</table>
</div>
</div>
<?= $this->endSection() ?>

View File

@ -3,9 +3,15 @@
<head> <head>
<title><?= LAYOUTS[$viewDatas['layout']]['title'] ?></title> <title><?= LAYOUTS[$viewDatas['layout']]['title'] ?></title>
<?php foreach (LAYOUTS[$viewDatas['layout']]['metas'] as $meta): ?><?= $meta ?><?php endforeach; ?> <?php foreach (LAYOUTS[$viewDatas['layout']]['metas'] as $meta): ?>
<?php foreach (LAYOUTS[$viewDatas['layout']]['stylesheets'] as $stylesheet): ?><?= $stylesheet ?><?php endforeach; ?> <?= $meta ?>
<?php foreach (LAYOUTS[$viewDatas['layout']]['javascripts'] as $javascript): ?><?= $javascript ?><?php endforeach; ?> <?php endforeach; ?>
<?php foreach (LAYOUTS[$viewDatas['layout']]['stylesheets'] as $stylesheet): ?>
<?= $stylesheet ?>
<?php endforeach; ?>
<?php foreach (LAYOUTS[$viewDatas['layout']]['javascripts'] as $javascript): ?>
<?= $javascript ?>
<?php endforeach; ?>
<link href="/css/<?= $viewDatas['layout'] ?>.css" media="screen" rel="stylesheet" type="text/css" /> <link href="/css/<?= $viewDatas['layout'] ?>.css" media="screen" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>.js"></script> <script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>.js"></script>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->

View File

@ -1,49 +1,2 @@
<link href="/css/<?= $viewDatas['layout'] ?>/form.css" media="screen" rel="stylesheet" type="text/css" /> <link href="/css/<?= $viewDatas['layout'] ?>/form.css" media="screen" rel="stylesheet" type="text/css" />
<script src="/js/<?= $viewDatas['layout'] ?>/form.js" referrerpolicy="origin"></script> <script src="/js/<?= $viewDatas['layout'] ?>/form.js" referrerpolicy="origin"></script>
<script src="/assets/tinymce/tinymce.min.js" referrerpolicy="origin"></script>
<link rel="stylesheet" href="/assets/tagify/dist/tagify.css">
<script src="/assets/tagify/dist/tagify.js"></script>
<?php foreach ($viewDatas['individualStylesheets'] as $css): ?>
<link href="/css/<?= $viewDatas['layout'] ?>/<?= $css ?>" media="screen" rel="stylesheet" type="text/css" />
<?php endforeach ?>
<?php foreach ($viewDatas['individualScripts'] as $js): ?>
<script src="/js/<?= $viewDatas['layout'] ?>/<?= $js ?>" referrerpolicy="origin"></script>
<?php endforeach ?>
<script>
const input = document.querySelector('#domain');
const errorBox = document.getElementById('domain-errors');
const tagify = new Tagify(input, {
enforceWhitelist: false, // 자유 입력 허용
whitelist: [], // 자동완성 후보
duplicates: false, // 중복 제거
delimiters: ", ", // 엔터나 콤마로 구분
pattern: /^[a-zA-Z0-9.-]+\.[a-z]{2,}$/ // 기본 도메인 형식
});
// ✅ 입력된 태그가 추가될 때 AJAX 검증
tagify.on('add', async e => {
const domain = e.detail.data.value;
// 서버로 도메인 유효성 검증 요청
const res = await fetch('/admin/equipment/part/domain/validate', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
domain
})
});
const result = await res.json();
if (!result.valid) {
// 유효하지 않으면 해당 태그 제거
tagify.removeTag(domain);
errorBox.innerText = `"${domain}" 은(는) 이미 등록되었거나 유효하지 않습니다.`;
} else {
errorBox.innerText = '';
}
});
</script>

View File

@ -31,4 +31,35 @@ document.addEventListener('DOMContentLoaded', function() {
dropdownAutoWidth: true dropdownAutoWidth: true
}); });
} }
if (document.querySelector('#domain')) {
const domainSelecor = document.querySelector('#domain')
const errorBox = document.getElementById('domain-errors');
const tagify = new Tagify(domainSelecor, {
enforceWhitelist: false,
whitelist: [],
duplicates: false,
delimiters: ", ",
pattern: /[a-zA-Z0-9\.\/\?\:@\-_=#]+\.([a-zA-Z0-9\&\.\/\?\:@\-_=#])*/ // 도메인주소 패턴
});
// ✅ 패턴이 맞지 않을 때
tagify.on('invalid', e => {
const value = e.detail.data.value;
errorBox.innerText = `"${value}" 은(는) 유효한 도메인 형식이 아니거나 중복됩니다. 예: domain.co.kr`;
});
// ✅ 서버에서 존재 여부 확인
tagify.on('add', async e => {
const domain = e.detail.data.value;
const res = await fetch('/admin/equipment/part/domain/confirm', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({domain})
});
const results = await res.json();
if (exists = results.exists === true || results.exists === 'true') {
tagify.removeTag(domain); // 이미 존재하는 도메인 제거
errorBox.innerText = results.message;
}
});
}
}); });