From a026bdff6f5a7490e93f14799c0f90141ff49efa Mon Sep 17 00:00:00 2001 From: "choi.jh" Date: Wed, 12 Nov 2025 18:43:47 +0900 Subject: [PATCH] trafficmonitor init...1 --- app/Controllers/Admin/AdminController.php | 42 +++++++++++++++++++++ app/Controllers/Admin/TrafficController.php | 2 +- app/DTOs/TrafficDTO.php | 4 ++ app/Forms/TrafficForm.php | 4 ++ app/Language/en/Traffic.php | 6 ++- app/Models/TrafficModel.php | 2 + 6 files changed, 57 insertions(+), 3 deletions(-) diff --git a/app/Controllers/Admin/AdminController.php b/app/Controllers/Admin/AdminController.php index 8968cdd..3fd5bf5 100644 --- a/app/Controllers/Admin/AdminController.php +++ b/app/Controllers/Admin/AdminController.php @@ -127,6 +127,48 @@ abstract class AdminController extends CommonController return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); } } + final public function batchjob(): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $selectedFields = []; + $formDatas = []; + foreach ($this->service->getFormService->getBatchjobFilters() as $field) { + $value = $this->request->getPost($field); + if ($value) { + $selectedFields[] = $field; + $formDatas[$field] = $value; + } + } + if (!count($selectedFields)) { + throw new \Exception("변경할 조건항목을 선택하셔야합니다."); + } + //변경할 UIDS 정의 + $uids = $this->request->getPost('batchjob_uids[]'); + if (!is_array($uids) || !count($uids)) { + throw new \Exception("적용할 리스트을 선택하셔야합니다."); + } + $this->service->getFormService()->setFormFields($selectedFields); + $this->service->getFormService()->setFormRules($action, $selectedFields); + $this->service->getFormService()->setFormFilters($selectedFields); + $this->service->getFormService()->setFormOptions($selectedFields); + $entities = []; + $errors = []; + foreach ($uids as $uid) { + try { + $entities[] = $this->modify_process($uid); + } catch (ValidationException $e) { + $errors[] = "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage(); + } catch (\Exception $e) { + $errors[] = "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage(); + } + } + return $this->action_modal_process("{$this->getTitle()}에서 " . count($entities) . "개, 총:" . count($uids) . " 수정이 완료되었습니다."); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); + } + } protected function delete_process($uid): CommonEntity { return $this->service->delete($uid); diff --git a/app/Controllers/Admin/TrafficController.php b/app/Controllers/Admin/TrafficController.php index c8b7041..3017c9c 100644 --- a/app/Controllers/Admin/TrafficController.php +++ b/app/Controllers/Admin/TrafficController.php @@ -25,7 +25,7 @@ class TrafficController extends AdminController } protected function action_init_process(string $action): void { - $fields = ['client', 'switch', 'ip', 'interface', 'status']; + $fields = ['client', 'server', 'server_ip',, 'switch', 'ip', 'interface', 'status']; $filters = ['status']; switch ($action) { case 'create': diff --git a/app/DTOs/TrafficDTO.php b/app/DTOs/TrafficDTO.php index 855b04c..4fe0354 100644 --- a/app/DTOs/TrafficDTO.php +++ b/app/DTOs/TrafficDTO.php @@ -6,6 +6,8 @@ class TrafficDTO extends CommonDTO { public ?int $uid = null; public ?string $client = null; + public ?string $server = null; + public ?string $server_ip = null; public ?string $switch = null; public ?string $ip = null; public ?string $interface = null; @@ -26,6 +28,8 @@ class TrafficDTO extends CommonDTO return [ 'uid' => $this->uid, 'client' => $this->client, + 'server' => $this->server, + 'server_ip' => $this->server_ip, 'switch' => $this->switch, 'ip' => $this->ip, 'interface' => $this->interface, diff --git a/app/Forms/TrafficForm.php b/app/Forms/TrafficForm.php index 24be07e..c5282bc 100644 --- a/app/Forms/TrafficForm.php +++ b/app/Forms/TrafficForm.php @@ -18,10 +18,14 @@ class TrafficForm extends CommonForm case "status": $rule = "required|trim|string"; break; + case "server": case "switch": $rule = "required|trim|string"; $rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""; break; + case "server_ip": + $rule = "required|trim|valid_ip[both]"; //ipv4 , ipv6 , both(ipv4,ipv6) + break; case "ip": $rule = "required|trim|valid_ip[both]"; //ipv4 , ipv6 , both(ipv4,ipv6) break; diff --git a/app/Language/en/Traffic.php b/app/Language/en/Traffic.php index 5522741..6b5aaf7 100644 --- a/app/Language/en/Traffic.php +++ b/app/Language/en/Traffic.php @@ -3,8 +3,10 @@ return [ 'title' => "트래픽정보", 'label' => [ 'client' => "고객명", - 'switch' => "스위치", - 'ip' => "IP", + 'server' => "서버번호", + 'server_ip' => "서버IP", + 'switch' => "스위치번호", + 'ip' => "스위치IP", 'interface' => "인텍스", 'status' => "상태", 'updated_at' => "수정일", diff --git a/app/Models/TrafficModel.php b/app/Models/TrafficModel.php index 89d264c..75e2f5e 100644 --- a/app/Models/TrafficModel.php +++ b/app/Models/TrafficModel.php @@ -16,6 +16,8 @@ class TrafficModel extends CommonModel protected $allowedFields = [ "uid", "client", + "server", + "server_ip", "switch", "ip", "interface",