dbmsv4 init...5
This commit is contained in:
parent
7f1fbccb78
commit
74aed0aa84
@ -41,15 +41,7 @@ abstract class AbstractCRUDController extends AbstractWebController
|
||||
}
|
||||
protected function create_process(array $formDatas): CommonEntity
|
||||
{
|
||||
// POST 데이터를 DTO 객체로 변환
|
||||
$dto = $this->service->createDTO($formDatas);
|
||||
// dd($dto->toArray());
|
||||
//DTO 타입 체크 로직을 일반화
|
||||
$dtoClass = $this->service->getDTOClass();
|
||||
if (!$dto instanceof $dtoClass) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: " . get_class($dto) . "는 사용할 수 없습니다. ({$dtoClass} 필요)");
|
||||
}
|
||||
return $this->service->create($dto->toArray());
|
||||
return $this->service->create($formDatas);
|
||||
}
|
||||
|
||||
protected function create_result_process($entity, ?string $redirect_url = null): string|RedirectResponse
|
||||
@ -108,15 +100,7 @@ abstract class AbstractCRUDController extends AbstractWebController
|
||||
|
||||
protected function modify_process($uid, array $formDatas): CommonEntity
|
||||
{
|
||||
// POST 데이터를 DTO 객체로 변환
|
||||
$formDatas[$this->service->getPKField()] = $uid;
|
||||
$dto = $this->service->createDTO($formDatas);
|
||||
//DTO 타입 체크 로직을 일반화
|
||||
$dtoClass = $this->service->getDTOClass();
|
||||
if (!$dto instanceof $dtoClass) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: " . get_class($dto) . "는 사용할 수 없습니다. ({$dtoClass} 필요)");
|
||||
}
|
||||
return $this->service->modify($uid, $dto->toArray());
|
||||
return $this->service->modify($uid, $formDatas);
|
||||
}
|
||||
|
||||
protected function modify_result_process($entity, ?string $redirect_url = null): string|RedirectResponse
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Controllers\Auth;
|
||||
|
||||
use App\DTOs\Auth\GoogleDTO;
|
||||
use App\Entities\UserEntity;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
@ -25,8 +24,7 @@ class GoogleController extends AuthController
|
||||
//로그인처리
|
||||
protected function login_process(): UserEntity
|
||||
{
|
||||
//요청 데이터를 DTO 객체로 변환
|
||||
return $this->service->login(new GoogleDTO($this->request->getPost()));
|
||||
return $this->service->login($this->request->getPost());
|
||||
}
|
||||
protected function logout_process(): void
|
||||
{
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Controllers\Auth;
|
||||
|
||||
use App\DTOs\Auth\LocalDTO;
|
||||
use App\Entities\UserEntity;
|
||||
use App\Services\Auth\LocalService;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
@ -25,7 +24,7 @@ class LocalController extends AuthController
|
||||
//로그인처리
|
||||
protected function login_process(): UserEntity
|
||||
{
|
||||
return $this->service->login(new LocalDTO($this->request->getPost()));
|
||||
return $this->service->login($this->request->getPost());
|
||||
}
|
||||
protected function logout_process(): void
|
||||
{
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Auth;
|
||||
|
||||
use App\DTOs\CommonDTO;
|
||||
|
||||
abstract class AuthDTO extends CommonDTO
|
||||
{
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Auth;
|
||||
|
||||
class GoogleDTO extends AuthDTO
|
||||
{
|
||||
|
||||
public $access_code = null;
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Auth;
|
||||
|
||||
class LocalDTO extends AuthDTO
|
||||
{
|
||||
public ?string $id = null;
|
||||
public ?string $passwd = null;
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs;
|
||||
|
||||
class BoardDTO extends CommonDTO
|
||||
{
|
||||
public ?int $uid = null;
|
||||
public ?int $user_uid = null;
|
||||
public ?int $worker_uid = null;
|
||||
public string $category = '';
|
||||
public string $title = '';
|
||||
public string $status = '';
|
||||
public string $content = '';
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs;
|
||||
|
||||
use ReflectionClass;
|
||||
use ReflectionNamedType;
|
||||
|
||||
abstract class CommonDTO
|
||||
{
|
||||
protected function __construct(array $datas = [])
|
||||
{
|
||||
if (empty($datas))
|
||||
return;
|
||||
|
||||
$reflection = new ReflectionClass($this);
|
||||
|
||||
foreach ($datas as $key => $value) {
|
||||
if (!$reflection->hasProperty($key))
|
||||
continue;
|
||||
|
||||
$property = $reflection->getProperty($key);
|
||||
$type = $property->getType();
|
||||
$assignValue = $value;
|
||||
|
||||
// *_uid 규칙 처리
|
||||
if ($value === '' && preg_match('/_uid$/', $key)) {
|
||||
if ($type instanceof ReflectionNamedType && $type->allowsNull()) {
|
||||
$this->{$key} = null;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 1) 기존: 빈 문자열('') 처리
|
||||
if ($value === '') {
|
||||
if ($type instanceof ReflectionNamedType && $type->allowsNull()) {
|
||||
$assignValue = null;
|
||||
} else {
|
||||
$typeName = ($type instanceof ReflectionNamedType) ? $type->getName() : '';
|
||||
$assignValue = ($typeName === 'int' || $typeName === 'float') ? 0 : '';
|
||||
}
|
||||
}
|
||||
// 2) 기존: 타입별 캐스팅
|
||||
elseif ($type instanceof ReflectionNamedType) {
|
||||
$typeName = $type->getName();
|
||||
|
||||
if ($typeName === 'array' && is_string($value)) {
|
||||
$assignValue = explode(DEFAULTS["DELIMITER_COMMA"], $value);
|
||||
} elseif ($typeName === 'int' && is_numeric($value)) {
|
||||
$assignValue = (int) $value;
|
||||
} elseif ($typeName === 'float' && is_numeric($value)) {
|
||||
$assignValue = (float) $value;
|
||||
}
|
||||
}
|
||||
|
||||
$this->{$key} = $assignValue;
|
||||
}
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
$reflection = new ReflectionClass($this);
|
||||
$properties = $reflection->getProperties();
|
||||
$result = [];
|
||||
|
||||
foreach ($properties as $property) {
|
||||
$name = $property->getName();
|
||||
$result[$name] = $this->{$name};
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Customer;
|
||||
|
||||
use App\DTOs\CommonDTO;
|
||||
|
||||
class ClientDTO extends CommonDTO
|
||||
{
|
||||
public ?int $uid = null;
|
||||
public ?int $user_uid = null;
|
||||
public ?string $id = null;
|
||||
public ?string $passwd = null;
|
||||
public string $site = '';
|
||||
public string $name = '';
|
||||
public string $phone = '';
|
||||
public string $email = '';
|
||||
public array $role = [];
|
||||
public int $account_balance = 0;
|
||||
public int $coupon_balance = 0;
|
||||
public int $point_balance = 0;
|
||||
public string $status = '';
|
||||
public string $history = '';
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
// 1. role 변환 로직 (기존 유지)
|
||||
if (isset($datas['role']) && is_string($datas['role'])) {
|
||||
$datas['role'] = explode(DEFAULTS["DELIMITER_COMMA"], $datas['role']);
|
||||
}
|
||||
|
||||
if (!isset($datas['role'])) {
|
||||
$datas['role'] = [];
|
||||
}
|
||||
|
||||
// 2. [추가] 잔액 관련 데이터가 null이거나 비어있다면 0으로 보정
|
||||
// CommonDTO의 parent::__construct가 호출되기 전에 데이터를 정제합니다.
|
||||
$balanceFields = ['account_balance', 'coupon_balance', 'point_balance'];
|
||||
foreach ($balanceFields as $field) {
|
||||
if (!isset($datas[$field]) || $datas[$field] === '' || $datas[$field] === null) {
|
||||
$datas[$field] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
parent::__construct($datas);
|
||||
}
|
||||
|
||||
public function getRoleToString(): string
|
||||
{
|
||||
return implode(DEFAULTS["DELIMITER_COMMA"], $this->role);
|
||||
}
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Customer;
|
||||
|
||||
use App\DTOs\CommonDTO;
|
||||
|
||||
class ServiceDTO extends CommonDTO
|
||||
{
|
||||
public ?int $uid = null;
|
||||
public ?int $user_uid = null;
|
||||
public ?int $clientinfo_uid = null;
|
||||
public ?int $serverinfo_uid = null;
|
||||
public string $code = '';
|
||||
public string $title = '';
|
||||
public string $site = '';
|
||||
public string $location = '';
|
||||
public int $rack = 0;
|
||||
public int $line = 0;
|
||||
public string $billing_at = '';
|
||||
public int $sale = 0;
|
||||
public int $amount = 0;
|
||||
public string $start_at = '';
|
||||
public string $end_at = '';
|
||||
public string $status = '';
|
||||
public string $history = '';
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Customer\Wallet;
|
||||
|
||||
class AccountDTO extends WalletDTO
|
||||
{
|
||||
public ?int $user_uid = null;
|
||||
public ?int $clientinfo_uid = null;
|
||||
public string $bank = '';
|
||||
public string $alias = '';
|
||||
public string $issue_at = '';
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Customer\Wallet;
|
||||
|
||||
class CouponDTO extends WalletDTO
|
||||
{
|
||||
public ?int $user_uid = null;
|
||||
public ?int $clientinfo_uid = null;
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Customer\Wallet;
|
||||
|
||||
class PointDTO extends WalletDTO
|
||||
{
|
||||
public ?int $user_uid = null;
|
||||
public ?int $clientinfo_uid = null;
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Customer\Wallet;
|
||||
|
||||
use App\DTOs\CommonDTO;
|
||||
|
||||
class WalletDTO extends CommonDTO
|
||||
{
|
||||
public ?int $uid = null;
|
||||
public ?int $user_uid = null;
|
||||
public ?int $clientinfo_uid = null;
|
||||
public string $title = '';
|
||||
public ?int $amount = 0;
|
||||
public ?int $balance = 0;
|
||||
public string $status = '';
|
||||
public string $content = '';
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Equipment;
|
||||
|
||||
use App\DTOs\CommonDTO;
|
||||
|
||||
class CHASSISDTO extends CommonDTO
|
||||
{
|
||||
public ?int $uid = null;
|
||||
public string $title = '';
|
||||
public int $price = 0;
|
||||
public int $used = 0;
|
||||
public int $stock = 0;
|
||||
public string $status = '';
|
||||
public ?int $cpuinfo_uid = null;
|
||||
public int $cpu_cnt = 0;
|
||||
public ?int $raminfo_uid = null;
|
||||
public int $ram_cnt = 0;
|
||||
public ?int $diskinfo_uid = null;
|
||||
public int $disk_cnt = 0;
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Equipment;
|
||||
|
||||
use App\DTOs\CommonDTO;
|
||||
|
||||
class LineDTO extends CommonDTO
|
||||
{
|
||||
public ?int $uid = null;
|
||||
public string $title = '';
|
||||
public string $type = '';
|
||||
public string $protocol = '';
|
||||
public string $bandwith = '';
|
||||
public string $start_at = '';
|
||||
public string $end_at = '';
|
||||
public string $status = '';
|
||||
public string $content = '';
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Equipment;
|
||||
|
||||
use App\DTOs\CommonDTO;
|
||||
|
||||
class ServerDTO extends CommonDTO
|
||||
{
|
||||
public ?int $uid = null;
|
||||
public ?int $user_uid = null;
|
||||
public ?int $clientinfo_uid = null;
|
||||
public ?int $serviceinfo_uid = null;
|
||||
public ?int $chassisinfo_uid = null;
|
||||
public ?int $switchinfo_uid = null;
|
||||
public string $code = '';
|
||||
public string $title = '';
|
||||
public string $type = '';
|
||||
public string $ip = '';
|
||||
public string $viewer = '';
|
||||
public string $os = '';
|
||||
public int $price = 0;
|
||||
public string $manufactur_at = '';
|
||||
public string $format_at = '';
|
||||
public string $status = '';
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Equipment;
|
||||
|
||||
use App\DTOs\CommonDTO;
|
||||
|
||||
class ServerPartDTO extends CommonDTO
|
||||
{
|
||||
public ?int $uid = null;
|
||||
public ?int $clientinfo_uid = null;
|
||||
public ?int $part_uid = null;
|
||||
public ?int $serviceinfo_uid = null;
|
||||
public ?int $serverinfo_uid = null;
|
||||
public string $title = '';
|
||||
public string $type = '';
|
||||
public string $billing = '';
|
||||
public string $billing_at = '';
|
||||
public int $cnt = 0;
|
||||
public int $amount = 0;
|
||||
public string $extra = '';
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs;
|
||||
|
||||
class MylogDTO extends CommonDTO
|
||||
{
|
||||
public ?int $uid = null;
|
||||
public ?int $user_uid = null;
|
||||
public string $title = '';
|
||||
public string $content = '';
|
||||
public string $status = '';
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Part;
|
||||
|
||||
class CPUDTO extends PartDTO
|
||||
{
|
||||
public int $used = 0;
|
||||
public int $stock = 0;
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Part;
|
||||
|
||||
class CSDTO extends PartDTO
|
||||
{
|
||||
public ?int $clientinfo_uid = null;
|
||||
public ?int $serviceinfo_uid = null;
|
||||
public ?int $serverinfo_uid = null;
|
||||
public string $type = '';
|
||||
public string $ip = '';
|
||||
public string $accountid = '';
|
||||
public string $domain = '';
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Part;
|
||||
|
||||
|
||||
class DISKDTO extends PartDTO
|
||||
{
|
||||
public int $used = 0;
|
||||
public int $stock = 0;
|
||||
public int $format = 0;
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Part;
|
||||
|
||||
class IPDTO extends PartDTO
|
||||
{
|
||||
public ?int $lineinfo_uid = null;
|
||||
public ?int $old_clientinfo_uid = null;
|
||||
public ?int $clientinfo_uid = null;
|
||||
public ?int $serviceinfo_uid = null;
|
||||
public ?int $serverinfo_uid = null;
|
||||
public string $ip = '';
|
||||
public string $content = '';
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Part;
|
||||
|
||||
use App\DTOs\CommonDTO;
|
||||
|
||||
class PartDTO extends CommonDTO
|
||||
{
|
||||
public ?int $uid = null;
|
||||
public string $title = '';
|
||||
public int $price = 0;
|
||||
public string $status = '';
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Part;
|
||||
|
||||
|
||||
class RAMDTO extends PartDTO
|
||||
{
|
||||
public int $used = 0;
|
||||
public int $stock = 0;
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Part;
|
||||
|
||||
class SOFTWAREDTO extends PartDTO
|
||||
{
|
||||
public int $used = 0;
|
||||
public int $stock = 0;
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Part;
|
||||
|
||||
class SWITCHDTO extends PartDTO
|
||||
{
|
||||
public ?int $clientinfo_uid = null;
|
||||
public ?int $serviceinfo_uid = null;
|
||||
public ?int $serverinfo_uid = null;
|
||||
public string $code = '';
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs;
|
||||
|
||||
class PaymentDTO extends CommonDTO
|
||||
{
|
||||
public ?int $uid = null;
|
||||
public ?int $user_uid = null;
|
||||
public ?int $clientinfo_uid = null;
|
||||
public ?int $serviceinfo_uid = null;
|
||||
public ?int $serverpartinfo_uid = null;
|
||||
public string $title = '';
|
||||
public int $amount = 0;
|
||||
public string $billing = '';
|
||||
public string $billing_at = '';
|
||||
public int $billing_month = 0;
|
||||
public string $pay = '';
|
||||
public string $status = STATUS['UNPAID'];
|
||||
public string $content = '';
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct($datas);
|
||||
}
|
||||
}
|
||||
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs;
|
||||
|
||||
class UserDTO extends CommonDTO
|
||||
{
|
||||
public ?int $uid = null;
|
||||
public string $id = '';
|
||||
public string $passwd = '';
|
||||
public string $confirmpassword = '';
|
||||
public string $name = '';
|
||||
public string $email = '';
|
||||
public string $mobile = '';
|
||||
public array $role = [];
|
||||
public string $status = '';
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
// 1. [전처리] 입력값이 문자열(CSV)로 들어왔다면 배열로 변환
|
||||
if (isset($datas['role']) && is_string($datas['role'])) {
|
||||
$datas['role'] = explode(DEFAULTS["DELIMITER_COMMA"], $datas['role']);
|
||||
}
|
||||
|
||||
// 2. 만약 데이터가 없다면 빈 배열로 초기화
|
||||
if (!isset($datas['role'])) {
|
||||
$datas['role'] = [];
|
||||
}
|
||||
|
||||
// 3. 부모 생성자 호출
|
||||
parent::__construct($datas);
|
||||
}
|
||||
|
||||
/**
|
||||
* DB 저장용(Entity 전달용) CSV 문자열이 필요할 때 사용합니다.
|
||||
*/
|
||||
public function getRoleToString(): string
|
||||
{
|
||||
return implode(DEFAULTS["DELIMITER_COMMA"], $this->role);
|
||||
}
|
||||
}
|
||||
16
app/Exceptions/FormValidationException.php
Normal file
16
app/Exceptions/FormValidationException.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class FormValidationException extends RuntimeException
|
||||
{
|
||||
public array $errors;
|
||||
|
||||
public function __construct(array $errors, string $message = 'Validation failed', int $code = 0, ?\Throwable $previous = null)
|
||||
{
|
||||
$this->errors = $errors;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
@ -12,6 +12,7 @@ class GoogleForm extends CommonForm
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$fields = ['access_code'];
|
||||
$filters = [];
|
||||
switch ($action) {
|
||||
@ -20,18 +21,18 @@ class GoogleForm extends CommonForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters);
|
||||
$this->setFormOptions($filters);
|
||||
$this->setBatchjobFilters($filters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "access_code":
|
||||
$formRules[$field] = "required|trim|string";
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
|
||||
@ -12,6 +12,7 @@ class LocalForm extends CommonForm
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$fields = ['id', 'passwd'];
|
||||
$filters = [];
|
||||
switch ($action) {
|
||||
@ -20,22 +21,22 @@ class LocalForm extends CommonForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters);
|
||||
$this->setFormOptions($filters);
|
||||
$this->setBatchjobFilters($filters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "id":
|
||||
$formRules[$field] = sprintf("required|trim|min_length[4]|max_length[20]%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
$formRules[$field] = sprintf("required|trim|min_length[4]|max_length[20]%s", in_array($this->formAction, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
break;
|
||||
case "passwd":
|
||||
$formRules[$field] = in_array($action, ["create", "create_form"]) ? "required|trim|string" : "permit_empty|trim|string";
|
||||
$formRules[$field] = in_array($this->formAction, ["create", "create_form"]) ? "required|trim|string" : "permit_empty|trim|string";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
|
||||
@ -12,6 +12,7 @@ class BoardForm extends CommonForm
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$fields = [
|
||||
'category',
|
||||
'worker_uid',
|
||||
@ -59,13 +60,13 @@ class BoardForm extends CommonForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "category":
|
||||
@ -82,24 +83,24 @@ class BoardForm extends CommonForm
|
||||
$formRules[$field] = "permit_empty|string";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
}
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
switch ($field) {
|
||||
case 'worker_uid':
|
||||
foreach ($this->getFormOption_process(service('userservice'), $action, $field, $formDatas) as $tempEntity) {
|
||||
foreach ($this->getFormOption_process(service('userservice'), $field, $formDatas) as $tempEntity) {
|
||||
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
|
||||
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
default:
|
||||
$options = parent::getFormOption($action, $field, $formDatas, $options);
|
||||
$options = parent::getFormOption($field, $formDatas, $options);
|
||||
break;
|
||||
}
|
||||
return $options;
|
||||
|
||||
@ -17,7 +17,6 @@ use RuntimeException;
|
||||
abstract class CommonForm
|
||||
{
|
||||
private $_validation = null;
|
||||
|
||||
private array $_attributes = [];
|
||||
private array $_formFields = [];
|
||||
private array $_formRules = [];
|
||||
@ -28,6 +27,8 @@ abstract class CommonForm
|
||||
private array $_actionButtons = ['view' => ICONS['SEARCH'], 'delete' => ICONS['DELETE']];
|
||||
private array $_batchjobButtons = ['batchjob' => '일괄처리', 'batchjob_delete' => '일괄삭제'];
|
||||
|
||||
protected $formAction = null;
|
||||
|
||||
protected function __construct()
|
||||
{
|
||||
$this->_validation = service('validation');
|
||||
@ -35,6 +36,8 @@ abstract class CommonForm
|
||||
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
log_message('debug', static::class . '->' . __FUNCTION__ . "에서 Called...");
|
||||
$this->formAction = $action;
|
||||
$actionButtons = ['view' => ICONS['SEARCH'], 'delete' => ICONS['DELETE']];
|
||||
$batchjobButtons = [];
|
||||
$this->setActionButtons($actionButtons);
|
||||
@ -70,10 +73,10 @@ abstract class CommonForm
|
||||
return array_intersect_key($this->_formFields, array_flip($fields));
|
||||
}
|
||||
|
||||
public function setFormRules(string $action, array $fields, $formRules = []): void
|
||||
public function setFormRules(array $fields, $formRules = []): void
|
||||
{
|
||||
foreach ($fields as $field) {
|
||||
$formRules = $this->getFormRule($action, $field, $formRules);
|
||||
$formRules = $this->getFormRule($field, $formRules);
|
||||
}
|
||||
$this->_formRules = $formRules;
|
||||
}
|
||||
@ -86,10 +89,10 @@ abstract class CommonForm
|
||||
return array_intersect_key($this->_formRules, array_flip($fields));
|
||||
}
|
||||
|
||||
final public function setFormOptions(string $action, array $fields, array $formDatas = [], $formOptions = []): void
|
||||
final public function setFormOptions(array $fields, array $formDatas = [], $formOptions = []): void
|
||||
{
|
||||
foreach ($fields as $field) {
|
||||
$formOptions[$field] = $formOptions[$field] ?? $this->getFormOption($action, $field, $formDatas);
|
||||
$formOptions[$field] = $formOptions[$field] ?? $this->getFormOption($field, $formDatas);
|
||||
}
|
||||
$this->_formOptions = $formOptions;
|
||||
}
|
||||
@ -298,71 +301,89 @@ abstract class CommonForm
|
||||
*/
|
||||
final public function validate(array &$formDatas): void
|
||||
{
|
||||
log_message('debug', '>>> CommonForm::validate CALLED: ' . static::class);
|
||||
if ($this->_validation === null) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: Validation 서비스가 초기화되지 않았습니다.");
|
||||
}
|
||||
|
||||
log_message('debug', '>>> CommonForm::validate CALLED: ' . static::class . ', formAction:' . $this->formAction);
|
||||
try {
|
||||
// 0) 데이터 구조 정리 (null 변환 X)
|
||||
$formDatas = $this->sanitizeFormDatas($formDatas);
|
||||
|
||||
// 1) 필드 라벨/규칙
|
||||
$formFields = $this->getFormFields();
|
||||
$formRules = $this->getFormRules();
|
||||
|
||||
if (empty($formRules)) {
|
||||
// 1) 전체 라벨/룰
|
||||
$allFormFields = $this->getFormFields(); // ['field' => '라벨', ...]
|
||||
$allFormRules = $this->getFormRules(); // ['field' => 'rules', ...]
|
||||
if (empty($allFormRules)) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 지정된 Form RULE이 없습니다.");
|
||||
}
|
||||
|
||||
// 2) wildcard(role.*) 부모 배열 보정
|
||||
// 2) 액션별 "검증 대상 필드" 결정
|
||||
if ($this->formAction === 'modify') {
|
||||
// (1) formDatas에 실제로 넘어온 필드만
|
||||
$targetFields = array_keys($formDatas);
|
||||
|
||||
// (2) 내부 제어용 키 제거(프로젝트에 맞게 추가/삭제)
|
||||
$exclude = ['_method', 'csrf_test_name', 'submit', 'token', 'action'];
|
||||
$targetFields = array_values(array_diff($targetFields, $exclude));
|
||||
|
||||
// (3) wildcard(role.*) 같은 규칙이 있으면 부모 기반으로 같이 포함
|
||||
// - formDatas에 role이 있으면 role.* 규칙도 함께 검사되도록 추가
|
||||
foreach ($allFormRules as $ruleField => $_ruleStr) {
|
||||
$ruleField = (string) $ruleField;
|
||||
if (!str_contains($ruleField, '.*')) {
|
||||
continue;
|
||||
}
|
||||
$parent = str_replace('.*', '', $ruleField);
|
||||
if (in_array($parent, $targetFields, true)) {
|
||||
$targetFields[] = $ruleField; // e.g. 'role.*'
|
||||
}
|
||||
}
|
||||
|
||||
// (4) 실제로 룰이 정의된 필드만 남김
|
||||
$targetFields = array_values(array_intersect($targetFields, array_keys($allFormRules)));
|
||||
|
||||
// 최종: modify에서는 "타겟만" 룰/라벨 세팅
|
||||
$formRules = $this->getFormRules($targetFields);
|
||||
$formFields = $this->getFormFields($targetFields);
|
||||
} else {
|
||||
// create (및 기타 액션): 전체 룰 검사
|
||||
$formRules = $allFormRules;
|
||||
$formFields = $allFormFields;
|
||||
}
|
||||
|
||||
if (empty($formRules)) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 검증할 대상 RULE이 없습니다.");
|
||||
}
|
||||
|
||||
// 3) wildcard(role.*) 부모 배열 보정
|
||||
$this->ensureParentArrayForWildcardRules($formDatas, $formRules);
|
||||
|
||||
// 3) numeric(FK 포함) 필드: '' -> null, 숫자 문자열 -> int
|
||||
// (규칙 기반 자동 수집)
|
||||
// 4) numeric(FK 포함) 필드: '' -> null, 숫자 문자열 -> int
|
||||
$numericFields = $this->collectNumericFieldsFromRules($formRules);
|
||||
$formDatas = $this->normalizeNumericEmptyToNull($formDatas, $numericFields);
|
||||
|
||||
// 4) dynamicRules 누적 구성 (버그 수정: 루프마다 초기화 금지)
|
||||
// 5) dynamicRules 구성
|
||||
$dynamicRules = [];
|
||||
foreach ($formRules as $field => $rule) {
|
||||
try {
|
||||
// 필드명/규칙 추출(확장 포인트)
|
||||
[$fieldName, $ruleStr] = $this->getValidationRule((string) $field, (string) $rule);
|
||||
[$fieldName, $ruleStr] = $this->getValidationRule((string) $field, (string) $rule);
|
||||
|
||||
// label 결정
|
||||
if (isset($formFields[$fieldName])) {
|
||||
$label = $formFields[$fieldName];
|
||||
} elseif (str_contains($fieldName, '.*')) {
|
||||
$parentField = str_replace('.*', '', $fieldName);
|
||||
$label = ($formFields[$parentField] ?? $fieldName) . " 항목";
|
||||
} else {
|
||||
$label = $fieldName;
|
||||
}
|
||||
|
||||
$dynamicRules[$fieldName] = [
|
||||
'label' => $label,
|
||||
'rules' => $ruleStr,
|
||||
];
|
||||
|
||||
// ❌ 존재 보장으로 '' 삽입하지 않음
|
||||
// - required는 CI4가 "키 없음"도 실패 처리 가능(일반적으로)
|
||||
// - permit_empty는 키 없어도 통과 (강제로 '' 만들면 FK/숫자 문제 발생)
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
throw new RuntimeException("유효성 검사 규칙 준비 중 오류 발생 (필드: {$field}): " . $e->getMessage());
|
||||
// label 결정
|
||||
if (isset($formFields[$fieldName])) {
|
||||
$label = $formFields[$fieldName];
|
||||
} elseif (str_contains($fieldName, '.*')) {
|
||||
$parentField = str_replace('.*', '', $fieldName);
|
||||
$label = ($allFormFields[$parentField] ?? $formFields[$parentField] ?? $fieldName) . " 항목";
|
||||
} else {
|
||||
$label = $fieldName;
|
||||
}
|
||||
|
||||
$dynamicRules[$fieldName] = [
|
||||
'label' => $label,
|
||||
'rules' => $ruleStr,
|
||||
];
|
||||
}
|
||||
|
||||
$this->_validation->setRules($dynamicRules);
|
||||
|
||||
try {
|
||||
if (!$this->_validation->run($formDatas)) {
|
||||
$errors = $this->_validation->getErrors();
|
||||
throw new RuntimeException(implode("\n", $errors));
|
||||
}
|
||||
} catch (\TypeError $e) {
|
||||
throw new RuntimeException("검증 도중 타입 오류 발생: " . $e->getMessage());
|
||||
if (!$this->_validation->run($formDatas)) {
|
||||
$errors = $this->_validation->getErrors();
|
||||
throw new RuntimeException(implode("\n", $errors));
|
||||
}
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
@ -398,14 +419,14 @@ abstract class CommonForm
|
||||
* - permit_empty|numeric 인 FK들이 여기서 정의되면,
|
||||
* validate()에서 자동으로 ''->null 정규화 대상에 포함됩니다.
|
||||
*/
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case $this->getAttribute('pk_field'):
|
||||
if (!$this->getAttribute('useAutoIncrement')) {
|
||||
$formRules[$field] = sprintf(
|
||||
"required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]%s",
|
||||
in_array($action, ["create"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
||||
in_array($this->formAction, ["create"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
||||
);
|
||||
} else {
|
||||
$formRules[$field] = "required|numeric";
|
||||
@ -414,13 +435,13 @@ abstract class CommonForm
|
||||
case $this->getAttribute('title_field'):
|
||||
$formRules[$field] = sprintf(
|
||||
"required|trim|string%s",
|
||||
in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
||||
in_array($this->formAction, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
||||
);
|
||||
break;
|
||||
case "code":
|
||||
$formRules[$field] = sprintf(
|
||||
"required|regex_match[/^[a-zA-Z0-9가-힣\-\_]+$/]|min_length[4]%s",
|
||||
in_array($action, ["create"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
||||
in_array($this->formAction, ["create"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
|
||||
);
|
||||
break;
|
||||
case "user_uid":
|
||||
@ -449,13 +470,13 @@ abstract class CommonForm
|
||||
* Options
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
protected function getFormOption_process($service, string $action, string $field, array $formDatas = []): array
|
||||
protected function getFormOption_process($service, string $field, array $formDatas = []): array
|
||||
{
|
||||
$entities = [];
|
||||
|
||||
switch ($field) {
|
||||
default:
|
||||
if (in_array($action, ['create_form', 'modify_form', 'alternative_create_form'])) {
|
||||
if (in_array($this->formAction, ['create_form', 'modify_form', 'alternative_create_form'])) {
|
||||
if (array_key_exists($field, $formDatas)) {
|
||||
$where = sprintf("status = '%s' OR %s='%s'", STATUS['AVAILABLE'], $this->getAttribute('pk_field'), $formDatas[$field]);
|
||||
} else {
|
||||
@ -471,20 +492,20 @@ abstract class CommonForm
|
||||
return $entities;
|
||||
}
|
||||
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
|
||||
switch ($field) {
|
||||
case 'user_uid':
|
||||
foreach ($this->getFormOption_process(service('userservice'), $action, $field, $formDatas) as $entity) {
|
||||
foreach ($this->getFormOption_process(service('userservice'), $field, $formDatas) as $entity) {
|
||||
$tempOptions[$entity->getPK()] = $entity->getTitle();
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
|
||||
case 'clientinfo_uid':
|
||||
foreach ($this->getFormOption_process(service('customer_clientservice'), $action, $field, $formDatas) as $entity) {
|
||||
foreach ($this->getFormOption_process(service('customer_clientservice'), $field, $formDatas) as $entity) {
|
||||
$tempOptions[$entity->getPK()] = $entity->getCustomTitle();
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
|
||||
@ -10,6 +10,7 @@ class ClientForm extends CustomerForm
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$fields = [
|
||||
'site',
|
||||
'name',
|
||||
@ -47,17 +48,17 @@ class ClientForm extends CustomerForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "name":
|
||||
$formRules[$field] = sprintf("required|trim|string%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
$formRules[$field] = sprintf("required|trim|string%s", in_array($this->formAction, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
break;
|
||||
case "site":
|
||||
$formRules[$field] = "required|trim|string";
|
||||
@ -79,7 +80,7 @@ class ClientForm extends CustomerForm
|
||||
$formRules[$field] = "permit_empty|numeric";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
|
||||
@ -10,6 +10,7 @@ class ServiceForm extends CustomerForm
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$fields = [
|
||||
"site",
|
||||
"location",
|
||||
@ -65,13 +66,13 @@ class ServiceForm extends CustomerForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "clientinfo_uid":
|
||||
@ -100,25 +101,25 @@ class ServiceForm extends CustomerForm
|
||||
$formRules[$field] = "permit_empty|trim|string";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
}
|
||||
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
switch ($field) {
|
||||
case 'serverinfo_uid':
|
||||
foreach ($this->getFormOption_process(service('equipment_serverservice'), $action, $field, $formDatas) as $tempEntity) {
|
||||
foreach ($this->getFormOption_process(service('equipment_serverservice'), $field, $formDatas) as $tempEntity) {
|
||||
$tempOptions[$tempEntity->getPK()] = $tempEntity->getCustomTitle();
|
||||
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
default:
|
||||
$options = parent::getFormOption($action, $field, $formDatas, $options);
|
||||
$options = parent::getFormOption($field, $formDatas, $options);
|
||||
break;
|
||||
}
|
||||
return $options;
|
||||
|
||||
@ -49,16 +49,16 @@ class AccountForm extends WalletForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
$this->setActionButtons($actionButtons);
|
||||
$this->setBatchjobButtons($batchjobButtons);
|
||||
}
|
||||
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "bank":
|
||||
@ -69,7 +69,7 @@ class AccountForm extends WalletForm
|
||||
$formRules[$field] = "required|valid_date";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
|
||||
@ -42,9 +42,9 @@ class CouponForm extends WalletForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
$this->setActionButtons($actionButtons);
|
||||
|
||||
@ -42,9 +42,9 @@ class PointForm extends WalletForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
$this->setActionButtons($actionButtons);
|
||||
|
||||
@ -10,7 +10,7 @@ abstract class WalletForm extends CustomerForm
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "user_uid":
|
||||
@ -26,7 +26,7 @@ abstract class WalletForm extends CustomerForm
|
||||
$formRules[$field] = "permit_empty|trim|string";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
|
||||
@ -10,6 +10,7 @@ class CHASSISForm extends EquipmentForm
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$fields = [
|
||||
"title",
|
||||
"price",
|
||||
@ -43,15 +44,15 @@ class CHASSISForm extends EquipmentForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
$this->setActionButtons($actionButtons);
|
||||
$this->setBatchjobButtons($batchjobButtons);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "used":
|
||||
@ -68,38 +69,38 @@ class CHASSISForm extends EquipmentForm
|
||||
$formRules[$field] = "permit_empty|numeric";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
}
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
switch ($field) {
|
||||
case "cpuinfo_uid":
|
||||
foreach ($this->getFormOption_process(service('part_cpuservice'), $action, $field, $formDatas) as $tempEntity) {
|
||||
foreach ($this->getFormOption_process(service('part_cpuservice'), $field, $formDatas) as $tempEntity) {
|
||||
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
|
||||
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
case "raminfo_uid":
|
||||
foreach ($this->getFormOption_process(service('part_ramservice'), $action, $field, $formDatas) as $tempEntity) {
|
||||
foreach ($this->getFormOption_process(service('part_ramservice'), $field, $formDatas) as $tempEntity) {
|
||||
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
|
||||
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
case "diskinfo_uid":
|
||||
foreach ($this->getFormOption_process(service('part_diskservice'), $action, $field, $formDatas) as $tempEntity) {
|
||||
foreach ($this->getFormOption_process(service('part_diskservice'), $field, $formDatas) as $tempEntity) {
|
||||
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
|
||||
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
default:
|
||||
$options = parent::getFormOption($action, $field, $formDatas, $options);
|
||||
$options = parent::getFormOption($field, $formDatas, $options);
|
||||
break;
|
||||
}
|
||||
return $options;
|
||||
|
||||
@ -10,6 +10,7 @@ class LineForm extends EquipmentForm
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$fields = [
|
||||
"type",
|
||||
"protocol",
|
||||
@ -37,15 +38,15 @@ class LineForm extends EquipmentForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
$this->setActionButtons($actionButtons);
|
||||
$this->setBatchjobButtons($batchjobButtons);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "bandwith":
|
||||
@ -58,7 +59,7 @@ class LineForm extends EquipmentForm
|
||||
$formRules[$field] = "permit_empty|valid_date";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
|
||||
@ -10,6 +10,7 @@ class ServerForm extends EquipmentForm
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$fields = [
|
||||
"serviceinfo_uid",
|
||||
"code",
|
||||
@ -61,17 +62,17 @@ class ServerForm extends EquipmentForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "switchinfo_uid":
|
||||
$formRules[$field] = sprintf("permit_empty|numeric%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
$formRules[$field] = sprintf("permit_empty|numeric%s", in_array($this->formAction, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
break;
|
||||
case "code":
|
||||
case "title":
|
||||
@ -85,7 +86,7 @@ class ServerForm extends EquipmentForm
|
||||
$formRules[$field] = "required|trim|string";
|
||||
break;
|
||||
case "ip": //ipv4 , ipv6 , both(ipv4,ipv6)
|
||||
$formRules[$field] = sprintf("permit_empty|trim|valid_ip[both]%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
$formRules[$field] = sprintf("permit_empty|trim|valid_ip[both]%s", in_array($this->formAction, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
break;
|
||||
case "os":
|
||||
$formRules[$field] = "permit_empty|trim|string";
|
||||
@ -97,41 +98,41 @@ class ServerForm extends EquipmentForm
|
||||
$formRules[$field] = "permit_empty|valid_date";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
}
|
||||
|
||||
protected function getFormOption_process($service, string $action, string $field, array $formDatas = []): array
|
||||
protected function getFormOption_process($service, string $field, array $formDatas = []): array
|
||||
{
|
||||
$entities = [];
|
||||
switch ($field) {
|
||||
case 'ip':
|
||||
if (in_array($action, ['create_form', 'modify_form'])) {
|
||||
if (in_array($this->formAction, ['create_form', 'modify_form'])) {
|
||||
if (array_key_exists($field, $formDatas)) {
|
||||
$where = sprintf("status = '%s' OR %s='%s'", STATUS['AVAILABLE'], $field, $formDatas[$field]);
|
||||
$entities = $service->getEntities([$where => null]);
|
||||
} else {
|
||||
$entities = parent::getFormOption_process($service, $action, $field, $formDatas);
|
||||
$entities = parent::getFormOption_process($service, $field, $formDatas);
|
||||
}
|
||||
} else {
|
||||
$entities = parent::getFormOption_process($service, $action, $field, $formDatas);
|
||||
$entities = parent::getFormOption_process($service, $field, $formDatas);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$entities = parent::getFormOption_process($service, $action, $field, $formDatas);
|
||||
$entities = parent::getFormOption_process($service, $field, $formDatas);
|
||||
break;
|
||||
}
|
||||
return $entities;
|
||||
}
|
||||
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
switch ($field) {
|
||||
case 'serviceinfo_uid':
|
||||
foreach ($this->getFormOption_process(service('customer_serviceservice'), $action, $field, $formDatas) as $tempEntity) {
|
||||
foreach ($this->getFormOption_process(service('customer_serviceservice'), $field, $formDatas) as $tempEntity) {
|
||||
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
|
||||
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
|
||||
}
|
||||
@ -144,7 +145,7 @@ class ServerForm extends EquipmentForm
|
||||
'text' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"
|
||||
]
|
||||
];
|
||||
foreach ($this->getFormOption_process(service('equipment_chassisservice'), $action, $field, $formDatas) as $tempEntity) {
|
||||
foreach ($this->getFormOption_process(service('equipment_chassisservice'), $field, $formDatas) as $tempEntity) {
|
||||
$tempOptions[$tempEntity->getPK()] = [
|
||||
'value' => $tempEntity->getPK(),
|
||||
'text' => $tempEntity->getTitle(),
|
||||
@ -156,7 +157,7 @@ class ServerForm extends EquipmentForm
|
||||
// dd($options);
|
||||
break;
|
||||
case 'switchinfo_uid':
|
||||
foreach ($this->getFormOption_process(service('part_switchservice'), $action, $field, $formDatas) as $tempEntity) {
|
||||
foreach ($this->getFormOption_process(service('part_switchservice'), $field, $formDatas) as $tempEntity) {
|
||||
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
|
||||
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
|
||||
}
|
||||
@ -164,7 +165,7 @@ class ServerForm extends EquipmentForm
|
||||
// dd($options);
|
||||
break;
|
||||
case 'ip': //key=value이 같음주의
|
||||
foreach ($this->getFormOption_process(service('part_ipservice'), $action, 'ip', $formDatas) as $tempEntity) {
|
||||
foreach ($this->getFormOption_process(service('part_ipservice'), 'ip', $formDatas) as $tempEntity) {
|
||||
$tempOptions[$tempEntity->getTitle()] = $tempEntity->getTitle();
|
||||
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
|
||||
}
|
||||
@ -177,7 +178,7 @@ class ServerForm extends EquipmentForm
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
default:
|
||||
$options = parent::getFormOption($action, $field, $formDatas, $options);
|
||||
$options = parent::getFormOption($field, $formDatas, $options);
|
||||
break;
|
||||
}
|
||||
return $options;
|
||||
|
||||
@ -12,6 +12,7 @@ class ServerPartForm extends EquipmentForm
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$fields = [
|
||||
"serverinfo_uid",
|
||||
"type",
|
||||
@ -20,7 +21,6 @@ class ServerPartForm extends EquipmentForm
|
||||
"cnt",
|
||||
"extra",
|
||||
"amount",
|
||||
"status"
|
||||
];
|
||||
$filters = [
|
||||
"serverinfo_uid",
|
||||
@ -44,13 +44,13 @@ class ServerPartForm extends EquipmentForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "serverinfo_uid":
|
||||
@ -72,7 +72,7 @@ class ServerPartForm extends EquipmentForm
|
||||
$formRules[$field] = "permit_empty|trim|string";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
@ -81,7 +81,7 @@ class ServerPartForm extends EquipmentForm
|
||||
{
|
||||
return service('part_' . strtolower($type) . 'service');
|
||||
}
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
switch ($field) {
|
||||
@ -95,7 +95,7 @@ class ServerPartForm extends EquipmentForm
|
||||
'text' => lang("{$this->getAttribute('class_path')}.TYPE.{$type}") . " 선택",
|
||||
]
|
||||
];
|
||||
foreach ($this->getFormOption_process($partService, $action, $field, $formDatas) as $tempEntity) {
|
||||
foreach ($this->getFormOption_process($partService, $field, $formDatas) as $tempEntity) {
|
||||
$tempOptions[$type][$tempEntity->getPK()] = [
|
||||
'value' => $tempEntity->getPK(),
|
||||
'text' => $tempEntity->getTitle(),
|
||||
@ -107,21 +107,21 @@ class ServerPartForm extends EquipmentForm
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
case 'serverinfo_uid':
|
||||
foreach ($this->getFormOption_process(service('equipment_serverservice'), $action, $field, $formDatas) as $tempEntity) {
|
||||
foreach ($this->getFormOption_process(service('equipment_serverservice'), $field, $formDatas) as $tempEntity) {
|
||||
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
|
||||
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
case 'serviceinfo_uid':
|
||||
foreach ($this->getFormOption_process(service('customer_clientservice'), $action, $field, $formDatas) as $tempEntity) {
|
||||
foreach ($this->getFormOption_process(service('customer_clientservice'), $field, $formDatas) as $tempEntity) {
|
||||
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
|
||||
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
default:
|
||||
$options = parent::getFormOption($action, $field, $formDatas, $options);
|
||||
$options = parent::getFormOption($field, $formDatas, $options);
|
||||
break;
|
||||
}
|
||||
return $options;
|
||||
|
||||
@ -12,6 +12,7 @@ class MylogForm extends CommonForm
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$fields = ['title', 'content', 'status'];
|
||||
$filters = ['user_uid', 'status'];
|
||||
$indexFilter = $filters;
|
||||
@ -26,13 +27,13 @@ class MylogForm extends CommonForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "user_uid":
|
||||
@ -45,7 +46,7 @@ class MylogForm extends CommonForm
|
||||
$formRules[$field] = "permit_empty|trim|string";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
|
||||
@ -10,6 +10,7 @@ class CPUForm extends PartForm
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$fields = [
|
||||
"title",
|
||||
"price",
|
||||
@ -32,20 +33,20 @@ class CPUForm extends PartForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "used":
|
||||
$formRules[$field] = "required|numeric";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
|
||||
@ -10,6 +10,7 @@ class CSForm extends PartForm
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$fields = [
|
||||
"type",
|
||||
"ip",
|
||||
@ -58,27 +59,27 @@ class CSForm extends PartForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "type":
|
||||
$formRules[$field] = "required|trim|string";
|
||||
break;
|
||||
case "ip": //ipv4 , ipv6 , both(ipv4,ipv6)
|
||||
$formRules[$field] = sprintf("required|trim|valid_ip[both]%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
$formRules[$field] = sprintf("required|trim|valid_ip[both]%s", in_array($this->formAction, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
break;
|
||||
case "accountid":
|
||||
case "domain":
|
||||
$formRules[$field] = "permit_empty|trim|string";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
|
||||
@ -10,6 +10,7 @@ class DISKForm extends PartForm
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$fields = [
|
||||
"title",
|
||||
"price",
|
||||
@ -33,13 +34,13 @@ class DISKForm extends PartForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "used":
|
||||
@ -49,7 +50,7 @@ class DISKForm extends PartForm
|
||||
$formRules[$field] = "required|numeric";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
|
||||
@ -10,6 +10,7 @@ class IPForm extends PartForm
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$fields = [
|
||||
"lineinfo_uid",
|
||||
"ip",
|
||||
@ -69,15 +70,15 @@ class IPForm extends PartForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
$this->setActionButtons($actionButtons);
|
||||
$this->setBatchjobButtons($batchjobButtons);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "lineinfo_uid":
|
||||
@ -90,27 +91,27 @@ class IPForm extends PartForm
|
||||
$formRules[$field] = "permit_empty|numeric";
|
||||
break;
|
||||
case "ip": //ipv4 , ipv6 , both(ipv4,ipv6)
|
||||
$formRules[$field] = sprintf("required|trim|valid_ip[both]%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
$formRules[$field] = sprintf("required|trim|valid_ip[both]%s", in_array($this->formAction, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
}
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
switch ($field) {
|
||||
case 'lineinfo_uid':
|
||||
foreach ($this->getFormOption_process(service('equipment_lineservice'), $action, $field, $formDatas) as $tempEntity) {
|
||||
foreach ($this->getFormOption_process(service('equipment_lineservice'), $field, $formDatas) as $tempEntity) {
|
||||
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
|
||||
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
case 'old_clientinfo_uid':
|
||||
foreach ($this->getFormOption_process(service('customer_clientservice'), $action, $field, $formDatas) as $tempEntity) {
|
||||
foreach ($this->getFormOption_process(service('customer_clientservice'), $field, $formDatas) as $tempEntity) {
|
||||
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
|
||||
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
|
||||
}
|
||||
@ -118,7 +119,7 @@ class IPForm extends PartForm
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
default:
|
||||
$options = parent::getFormOption($action, $field, $formDatas, $options);
|
||||
$options = parent::getFormOption($field, $formDatas, $options);
|
||||
break;
|
||||
}
|
||||
return $options;
|
||||
|
||||
@ -10,11 +10,11 @@ abstract class PartForm extends CommonForm
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "title":
|
||||
$formRules[$field] = sprintf("required|trim|string%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
$formRules[$field] = sprintf("required|trim|string%s", in_array($this->formAction, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
break;
|
||||
case "clientinfo_uid":
|
||||
case "serviceinfo_uid":
|
||||
@ -27,31 +27,31 @@ abstract class PartForm extends CommonForm
|
||||
$formRules[$field] = "required|numeric";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
}
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
switch ($field) {
|
||||
case 'serviceinfo_uid':
|
||||
foreach ($this->getFormOption_process(service('customer_serviceservice'), $action, $field, $formDatas) as $tempEntity) {
|
||||
foreach ($this->getFormOption_process(service('customer_serviceservice'), $field, $formDatas) as $tempEntity) {
|
||||
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
|
||||
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
case 'serverinfo_uid':
|
||||
foreach ($this->getFormOption_process(service('equipment_serverservice'), $action, $field, $formDatas) as $tempEntity) {
|
||||
foreach ($this->getFormOption_process(service('equipment_serverservice'), $field, $formDatas) as $tempEntity) {
|
||||
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
|
||||
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
default:
|
||||
$options = parent::getFormOption($action, $field, $formDatas, $options);
|
||||
$options = parent::getFormOption($field, $formDatas, $options);
|
||||
break;
|
||||
}
|
||||
return $options;
|
||||
|
||||
@ -10,6 +10,7 @@ class RAMForm extends PartForm
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$fields = [
|
||||
"title",
|
||||
"price",
|
||||
@ -32,20 +33,20 @@ class RAMForm extends PartForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "used":
|
||||
$formRules[$field] = "required|numeric";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
|
||||
@ -10,6 +10,7 @@ class SOFTWAREForm extends PartForm
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$fields = [
|
||||
"title",
|
||||
"price",
|
||||
@ -32,17 +33,17 @@ class SOFTWAREForm extends PartForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
|
||||
@ -10,6 +10,7 @@ class SWITCHForm extends PartForm
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$fields = [
|
||||
"code",
|
||||
"price",
|
||||
@ -49,19 +50,19 @@ class SWITCHForm extends PartForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
$this->setActionButtons($actionButtons);
|
||||
$this->setBatchjobButtons($batchjobButtons);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
|
||||
@ -12,6 +12,7 @@ class PaymentForm extends CommonForm
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$fields = [
|
||||
"serviceinfo_uid",
|
||||
"title",
|
||||
@ -63,15 +64,15 @@ class PaymentForm extends CommonForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
$this->setActionButtons($actionButtons);
|
||||
$this->setBatchjobButtons($batchjobButtons);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "user_uid":
|
||||
@ -96,25 +97,25 @@ class PaymentForm extends CommonForm
|
||||
$formRules[$field] = "permit_empty|trim|string";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
}
|
||||
|
||||
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
|
||||
{
|
||||
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
|
||||
switch ($field) {
|
||||
case 'serviceinfo_uid':
|
||||
foreach ($this->getFormOption_process(service('customer_serviceservice'), $action, $field, $formDatas) as $tempEntity) {
|
||||
foreach ($this->getFormOption_process(service('customer_serviceservice'), $field, $formDatas) as $tempEntity) {
|
||||
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
|
||||
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
|
||||
}
|
||||
$options['options'] = $tempOptions;
|
||||
break;
|
||||
default:
|
||||
$options = parent::getFormOption($action, $field, $formDatas, $options);
|
||||
$options = parent::getFormOption($field, $formDatas, $options);
|
||||
break;
|
||||
}
|
||||
return $options;
|
||||
|
||||
@ -12,6 +12,7 @@ class UserForm extends CommonForm
|
||||
}
|
||||
public function action_init_process(string $action, array &$formDatas = []): void
|
||||
{
|
||||
parent::action_init_process($action, $formDatas);
|
||||
$fields = [
|
||||
'id',
|
||||
'passwd',
|
||||
@ -35,33 +36,33 @@ class UserForm extends CommonForm
|
||||
break;
|
||||
}
|
||||
$this->setFormFields($fields);
|
||||
$this->setFormRules($action, $fields);
|
||||
$this->setFormRules($fields);
|
||||
$this->setFormFilters($filters);
|
||||
$this->setFormOptions($action, $filters, $formDatas);
|
||||
$this->setFormOptions($filters, $formDatas);
|
||||
$this->setIndexFilters($indexFilter);
|
||||
$this->setBatchjobFilters($batchjobFilters);
|
||||
}
|
||||
public function getFormRule(string $action, string $field, array $formRules): array
|
||||
public function getFormRule(string $field, array $formRules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "id":
|
||||
$formRules[$field] = sprintf("required|trim|min_length[4]|max_length[20]%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
$formRules[$field] = sprintf("required|trim|min_length[4]|max_length[20]%s", in_array($this->formAction, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
break;
|
||||
case "passwd":
|
||||
$formRules[$field] = sprintf("%s|%s", in_array($action, ["create", "create_form"]) ? "required" : "permit_empty", "trim|string");
|
||||
$formRules[$field] = sprintf("%s|%s", in_array($this->formAction, ["create", "create_form"]) ? "required" : "permit_empty", "trim|string");
|
||||
break;
|
||||
case "confirmpassword":
|
||||
$formRules[$field] = sprintf("%s|%s", in_array($action, ["create", "create_form"]) ? "required" : "permit_empty", "trim|string|matches[passwd]");
|
||||
$formRules[$field] = sprintf("%s|%s", in_array($this->formAction, ["create", "create_form"]) ? "required" : "permit_empty", "trim|string|matches[passwd]");
|
||||
break;
|
||||
case "email":
|
||||
$formRules[$field] = sprintf("required|trim|valid_email%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
$formRules[$field] = sprintf("required|trim|valid_email%s", in_array($this->formAction, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
|
||||
break;
|
||||
case "role":
|
||||
$formRules[$field] = 'required|is_array|at_least_one';
|
||||
$formRules['role.*'] = 'permit_empty|trim|in_list[manager,cloudflare,firewall,security,director,master]';
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
|
||||
@ -18,18 +18,35 @@ class UserHelper extends CommonHelper
|
||||
$form = form_password($field, "", $extras);
|
||||
break;
|
||||
case 'role':
|
||||
// ✅ value가 string이면 CSV -> array로 변환
|
||||
if (is_string($value)) {
|
||||
$value = array_values(array_filter(array_map('trim', explode(',', $value))));
|
||||
} elseif ($value === null) {
|
||||
$value = [];
|
||||
}
|
||||
|
||||
// ✅ 현재 role 목록(소문자/trim 정규화)
|
||||
$currentRoles = is_array($value)
|
||||
? array_map('strtolower', array_map('trim', $value))
|
||||
: [];
|
||||
|
||||
$form = '';
|
||||
//Form페이지에서는 맨앞에것 제외하기 위함
|
||||
array_shift($viewDatas['formOptions'][$field]['options']);
|
||||
foreach ($viewDatas['formOptions'][$field]['options'] as $key => $label) {
|
||||
$checked = in_array(strtolower(trim($key)), $currentRoles);
|
||||
$form .= '<label class="me-3">';
|
||||
$form .= form_checkbox('role[]', $key, $checked, ['id' => "role_{$key}", ...$extras]);
|
||||
$form .= " {$label}";
|
||||
$form .= '</label>';
|
||||
|
||||
// Form페이지에서는 맨앞에것 제외하기 위함
|
||||
if (isset($viewDatas['formOptions'][$field]['options']) && is_array($viewDatas['formOptions'][$field]['options'])) {
|
||||
$options = $viewDatas['formOptions'][$field]['options'];
|
||||
|
||||
// ✅ 원본을 건드리지 말고 복사본에서 shift (중요)
|
||||
array_shift($options);
|
||||
|
||||
foreach ($options as $key => $label) {
|
||||
$checked = in_array(strtolower(trim((string) $key)), $currentRoles, true);
|
||||
|
||||
$form .= '<label class="me-3">';
|
||||
$form .= form_checkbox('role[]', (string) $key, $checked, ['id' => "role_{$key}", ...$extras]);
|
||||
$form .= " {$label}";
|
||||
$form .= '</label>';
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Services\Auth;
|
||||
|
||||
use App\DTOs\Auth\GoogleDTO;
|
||||
use App\DTOs\Auth\LocalDTO;
|
||||
use App\Entities\UserEntity;
|
||||
use App\Helpers\AuthHelper;
|
||||
use App\Models\CommonModel;
|
||||
@ -24,9 +22,9 @@ abstract class AuthService extends CommonService
|
||||
}
|
||||
//로그인
|
||||
abstract protected function login_process(array $formDatas): UserEntity;
|
||||
final public function login(LocalDTO|GoogleDTO $dto): UserEntity
|
||||
final public function login(array $formDatas): UserEntity
|
||||
{
|
||||
$entity = $this->login_process($dto->toArray());
|
||||
$entity = $this->login_process($formDatas);
|
||||
//인증 세션처리
|
||||
$this->getAuthContext()->setAuthSession($entity);
|
||||
return $entity;
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Services\Auth;
|
||||
|
||||
use App\DTOs\Auth\GoogleDTO;
|
||||
use App\Entities\UserEntity;
|
||||
use App\Forms\Auth\GoogleForm;
|
||||
use App\Libraries\MySocket\GoogleSocket\CURL;
|
||||
@ -18,14 +17,6 @@ class GoogleService extends AuthService
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('Google');
|
||||
}
|
||||
public function createDTO(array $formDatas): GoogleDTO
|
||||
{
|
||||
return new GoogleDTO($formDatas);
|
||||
}
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return GoogleDTO::class;
|
||||
}
|
||||
protected function getEntity_process(mixed $entity): UserEntity
|
||||
{
|
||||
return $entity;
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Services\Auth;
|
||||
|
||||
use App\DTOs\Auth\LocalDTO;
|
||||
use App\Entities\UserEntity;
|
||||
use App\Forms\Auth\LocalForm;
|
||||
use App\Models\UserModel;
|
||||
@ -17,14 +16,7 @@ class LocalService extends AuthService
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('Local');
|
||||
}
|
||||
public function createDTO(array $formDatas): LocalDTO
|
||||
{
|
||||
return new LocalDTO($formDatas);
|
||||
}
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return LocalDTO::class;
|
||||
}
|
||||
|
||||
protected function getEntity_process(mixed $entity): UserEntity
|
||||
{
|
||||
return $entity;
|
||||
|
||||
@ -6,7 +6,6 @@ use App\Models\BoardModel;
|
||||
use App\Helpers\BoardHelper;
|
||||
use App\Forms\BoardForm;
|
||||
use App\Entities\BoardEntity;
|
||||
use App\DTOs\BoardDTO;
|
||||
|
||||
class BoardService extends CommonService
|
||||
{
|
||||
@ -18,14 +17,6 @@ class BoardService extends CommonService
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('Board');
|
||||
}
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return BoardDTO::class;
|
||||
}
|
||||
public function createDTO(array $formDatas): BoardDTO
|
||||
{
|
||||
return new BoardDTO($formDatas);
|
||||
}
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return BoardEntity::class;
|
||||
|
||||
@ -2,13 +2,13 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Forms\CommonForm;
|
||||
use App\DTOs\CommonDTO;
|
||||
use App\Entities\CommonEntity;
|
||||
use App\Models\CommonModel;
|
||||
use App\Libraries\AuthContext;
|
||||
use CodeIgniter\Database\Exceptions\DatabaseException;
|
||||
use RuntimeException;
|
||||
use App\Forms\CommonForm;
|
||||
use App\Models\CommonModel;
|
||||
use App\Entities\CommonEntity;
|
||||
use App\Libraries\AuthContext;
|
||||
use App\Exceptions\FormValidationException;
|
||||
use CodeIgniter\Database\Exceptions\DatabaseException;
|
||||
|
||||
abstract class CommonService
|
||||
{
|
||||
@ -26,8 +26,6 @@ abstract class CommonService
|
||||
{
|
||||
}
|
||||
|
||||
abstract public function getDTOClass(): string;
|
||||
abstract public function createDTO(array $formDatas): CommonDTO;
|
||||
abstract public function getEntityClass(): string;
|
||||
|
||||
/**
|
||||
@ -236,8 +234,6 @@ abstract class CommonService
|
||||
// INSERT 시 Entity의 PK는 0 또는 NULL이어야 함 (DB가 ID를 생성하도록)
|
||||
$initialPK = $entity->getPK();
|
||||
$result = $this->model->save($entity);
|
||||
log_message('debug', __FUNCTION__ . ":" . var_export($entity, true));
|
||||
log_message('debug', __FUNCTION__ . ":" . $this->model->getLastQuery());
|
||||
// 최종적으로 DB에 반영된 PK를 반환받습니다. (UPDATE이면 기존 PK, INSERT이면 새 PK)
|
||||
$entity->{$this->getPKField()} = $this->handle_save_result($result, $initialPK);
|
||||
// handle_save_result에서 확인된 최종 PK를 사용하여 DB에서 최신 엔티티를 가져옴
|
||||
@ -250,7 +246,7 @@ abstract class CommonService
|
||||
}
|
||||
|
||||
//Action 작업시 field에따른 Hook처리(각 Service에서 override);
|
||||
protected function action_process_fieldhook(string $field, $value, array $formDatas): array
|
||||
protected function validation_fieldhook(string $field, $value, array $formDatas): array
|
||||
{
|
||||
return $formDatas;
|
||||
}
|
||||
@ -259,25 +255,25 @@ abstract class CommonService
|
||||
protected function create_process(array $formDatas): CommonEntity
|
||||
{
|
||||
try {
|
||||
log_message('debug', "*** ENTER" . __METHOD__ . " ***");
|
||||
$actionForm = $this->getActionForm();
|
||||
log_message('debug', 'FORMCLASS=' . $this->formClass . ' / FORMINST=' . (is_object($actionForm) ? get_class($actionForm) : 'NULL'));
|
||||
log_message('debug', 'IS_COMMONFORM=' . (is_object($actionForm) && $actionForm instanceof CommonForm ? 'YES' : 'NO'));
|
||||
if ($actionForm instanceof CommonForm) {
|
||||
$actionForm->action_init_process('create', $formDatas);
|
||||
// log_message('debug', 'BEFORE hook CREATE FORMDATA:' . print_r($formDatas ?? null, true));
|
||||
foreach ($formDatas as $field => $value) {
|
||||
$formDatas = $this->action_process_fieldhook($field, $value, $formDatas);
|
||||
$formDatas = $this->validation_fieldhook($field, $value, $formDatas);
|
||||
}
|
||||
log_message('debug', '>>> BEFORE validate: ' . get_class($actionForm));
|
||||
// log_message('debug', 'AFTER hook CREATE FORMDATA:' . print_r($formDatas ?? null, true));
|
||||
$actionForm->validate($formDatas); // ✅ 여기서 검증
|
||||
log_message('debug', '>>> AFTER validate');
|
||||
}
|
||||
|
||||
$entityClass = $this->getEntityClass();
|
||||
$entity = new $entityClass($formDatas);
|
||||
if (!$entity instanceof $entityClass) {
|
||||
throw new RuntimeException("Return Type은 {$entityClass}만 가능");
|
||||
}
|
||||
return $this->save_process($entity);
|
||||
} catch (FormValidationException $e) {
|
||||
throw $e; // ✅ 감싸지 말고 그대로
|
||||
} catch (\Throwable $e) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:" . $e->getMessage());
|
||||
}
|
||||
@ -292,34 +288,41 @@ abstract class CommonService
|
||||
}
|
||||
|
||||
//수정용
|
||||
protected function modify_process_fieldhook(array $formDatas): array
|
||||
{
|
||||
return $formDatas;
|
||||
}
|
||||
protected function modify_process($entity, array $formDatas): CommonEntity
|
||||
{
|
||||
try {
|
||||
log_message('debug', "*** ENTER" . __METHOD__ . " ***");
|
||||
$actionForm = $this->getActionForm();
|
||||
log_message('debug', 'FORMCLASS=' . $this->formClass . ' / FORMINST=' . (is_object($actionForm) ? get_class($actionForm) : 'NULL'));
|
||||
log_message('debug', 'IS_COMMONFORM=' . (is_object($actionForm) && $actionForm instanceof CommonForm ? 'YES' : 'NO'));
|
||||
if ($actionForm instanceof CommonForm) {
|
||||
$actionForm->action_init_process('modify', $formDatas);
|
||||
foreach ($formDatas as $field => $value) {
|
||||
$formDatas = $this->action_process_fieldhook($field, $value, $formDatas);
|
||||
}
|
||||
log_message('debug', '>>> BEFORE validate: ' . get_class($actionForm));
|
||||
$actionForm->validate($formDatas); // ✅ 여기서 검증
|
||||
log_message('debug', '>>> AFTER validate');
|
||||
if (!$actionForm instanceof CommonForm) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: actionForm이 정의되지 않았습니다.");
|
||||
}
|
||||
$actionForm->action_init_process('modify', $formDatas);
|
||||
log_message('debug', 'BEFORE hook MODIFY FORMDATA:' . print_r($formDatas ?? null, true));
|
||||
foreach ($formDatas as $field => $value) {
|
||||
$formDatas = $this->validation_fieldhook($field, $value, $formDatas);
|
||||
}
|
||||
log_message('debug', 'AFTER hook MODIFY FORMDATA:' . print_r($formDatas ?? null, true));
|
||||
$actionForm->validate($formDatas); // ✅ 여기서 검증
|
||||
// 검증 통과 후 엔티티 반영
|
||||
$formDatas = $this->modify_process_fieldhook($formDatas);
|
||||
log_message('debug', 'BEFORE MODIFY fill Entity:' . print_r($formDatas ?? null, true));
|
||||
$entity->fill($formDatas);
|
||||
log_message('debug', 'AFTER MODIFY fill Entity:' . print_r($entity ?? null, true));
|
||||
if (!$entity->hasChanged()) {
|
||||
return $entity;
|
||||
}
|
||||
return $this->save_process($entity);
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
throw $e; // ✅ 감싸지 말고 그대로
|
||||
} catch (\Throwable $e) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:" . $e->getMessage() . "\n" . var_export($entity, true));
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final public function modify(string|int $uid, array $formDatas): CommonEntity
|
||||
{
|
||||
return $this->dbTransaction(function () use ($uid, $formDatas) {
|
||||
|
||||
@ -4,8 +4,6 @@ namespace App\Services\Customer;
|
||||
|
||||
use RuntimeException;
|
||||
use App\Entities\CommonEntity;
|
||||
use App\Entities\PaymentEntity;
|
||||
use App\DTOs\Customer\ClientDTO;
|
||||
use App\Forms\Customer\ClientForm;
|
||||
use App\Models\Customer\ClientModel;
|
||||
use App\Helpers\Customer\ClientHelper;
|
||||
@ -21,14 +19,6 @@ class ClientService extends CustomerService
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('Client');
|
||||
}
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return ClientDTO::class;
|
||||
}
|
||||
public function createDTO(array $formDatas): ClientDTO
|
||||
{
|
||||
return new ClientDTO($formDatas);
|
||||
}
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return ClientEntity::class;
|
||||
@ -48,7 +38,7 @@ class ClientService extends CustomerService
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
|
||||
protected function action_process_fieldhook(string $field, $value, array $formDatas): array
|
||||
protected function validation_fieldhook(string $field, $value, array $formDatas): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'role':
|
||||
@ -64,12 +54,34 @@ class ClientService extends CustomerService
|
||||
$formDatas[$field] = $value;
|
||||
break;
|
||||
default:
|
||||
$formDatas = parent::action_process_fieldhook($field, $value, $formDatas);
|
||||
$formDatas = parent::validation_fieldhook($field, $value, $formDatas);
|
||||
break;
|
||||
}
|
||||
return $formDatas;
|
||||
}
|
||||
protected function modify_process_fieldhook(array $formDatas): array
|
||||
{
|
||||
// 1) DB 컬럼 아닌 값 제거
|
||||
unset($formDatas['confirmpassword']);
|
||||
|
||||
// 2) role은 무조건 문자열로
|
||||
if (array_key_exists('role', $formDatas)) {
|
||||
$arr = is_array($formDatas['role'])
|
||||
? $formDatas['role']
|
||||
: explode(',', (string) $formDatas['role']);
|
||||
|
||||
$arr = array_values(array_filter(array_map('trim', $arr)));
|
||||
sort($arr);
|
||||
$formDatas['role'] = implode(',', $arr);
|
||||
}
|
||||
|
||||
// 3) passwd는 빈 값이면 업데이트 제외 (원하면)
|
||||
if (array_key_exists('passwd', $formDatas) && $formDatas['passwd'] === '') {
|
||||
unset($formDatas['passwd']);
|
||||
}
|
||||
|
||||
return $formDatas;
|
||||
}
|
||||
public function history(string|int $uid, string $history): CommonEntity
|
||||
{
|
||||
return $this->dbTransaction(function () use ($uid, $history) {
|
||||
|
||||
@ -6,7 +6,6 @@ use DateTimeZone;
|
||||
use RuntimeException;
|
||||
use DateTimeImmutable;
|
||||
use App\Entities\CommonEntity;
|
||||
use App\DTOs\Customer\ServiceDTO;
|
||||
use App\Forms\Customer\ServiceForm;
|
||||
use App\Models\Customer\ServiceModel;
|
||||
use App\Helpers\Customer\ServiceHelper;
|
||||
@ -23,16 +22,6 @@ class ServiceService extends CustomerService
|
||||
$this->addClassPaths('Service');
|
||||
}
|
||||
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return ServiceDTO::class;
|
||||
}
|
||||
|
||||
public function createDTO(array $formDatas): ServiceDTO
|
||||
{
|
||||
return new ServiceDTO($formDatas);
|
||||
}
|
||||
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return ServiceEntity::class;
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Services\Customer\Wallet;
|
||||
|
||||
use App\DTOs\Customer\Wallet\AccountDTO;
|
||||
use App\Entities\CommonEntity;
|
||||
use App\Entities\Customer\ClientEntity;
|
||||
use App\Entities\Customer\Wallet\AccountEntity;
|
||||
@ -22,14 +21,6 @@ class AccountService extends WalletService
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('Account');
|
||||
}
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return AccountDTO::class;
|
||||
}
|
||||
public function createDTO(array $formDatas): AccountDTO
|
||||
{
|
||||
return new AccountDTO($formDatas);
|
||||
}
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return AccountEntity::class;
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Services\Customer\Wallet;
|
||||
|
||||
use App\DTOs\Customer\Wallet\CouponDTO;
|
||||
use App\Entities\CommonEntity;
|
||||
use App\Entities\Customer\ClientEntity;
|
||||
use App\Entities\Customer\Wallet\CouponEntity;
|
||||
@ -22,14 +21,6 @@ class CouponService extends WalletService
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('Coupon');
|
||||
}
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return CouponDTO::class;
|
||||
}
|
||||
public function createDTO(array $formDatas): CouponDTO
|
||||
{
|
||||
return new CouponDTO($formDatas);
|
||||
}
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return CouponEntity::class;
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Services\Customer\Wallet;
|
||||
|
||||
use App\DTOs\Customer\Wallet\PointDTO;
|
||||
use App\Entities\CommonEntity;
|
||||
use App\Entities\Customer\ClientEntity;
|
||||
use App\Entities\Customer\Wallet\PointEntity;
|
||||
@ -22,14 +21,6 @@ class PointService extends WalletService
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('Point');
|
||||
}
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return PointDTO::class;
|
||||
}
|
||||
public function createDTO(array $formDatas): PointDTO
|
||||
{
|
||||
return new PointDTO($formDatas);
|
||||
}
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return PointEntity::class;
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Services\Equipment;
|
||||
|
||||
use App\DTOs\Equipment\CHASSISDTO;
|
||||
use App\Entities\CommonEntity;
|
||||
use App\Entities\Equipment\CHASSISEntity;
|
||||
use App\Entities\Equipment\ServerEntity;
|
||||
@ -21,14 +20,6 @@ class CHASSISService extends EquipmentService
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('CHASSIS');
|
||||
}
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return CHASSISDTO::class;
|
||||
}
|
||||
public function createDTO(array $formDatas): CHASSISDTO
|
||||
{
|
||||
return new CHASSISDTO($formDatas);
|
||||
}
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return CHASSISEntity::class;
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Services\Equipment;
|
||||
|
||||
use App\DTOs\Equipment\LineDTO;
|
||||
use App\Entities\Equipment\LineEntity;
|
||||
use App\Forms\Equipment\LineForm;
|
||||
use App\Helpers\Equipment\LineHelper;
|
||||
@ -21,14 +20,6 @@ class LineService extends EquipmentService
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('Line');
|
||||
}
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return LineDTO::class;
|
||||
}
|
||||
public function createDTO(array $formDatas): LineDTO
|
||||
{
|
||||
return new LineDTO($formDatas);
|
||||
}
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return LineEntity::class;
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Services\Equipment;
|
||||
|
||||
use App\DTOs\Equipment\ServerPartDTO;
|
||||
use App\Entities\CommonEntity;
|
||||
use App\Entities\Customer\ServiceEntity;
|
||||
use App\Entities\Equipment\ServerEntity;
|
||||
@ -25,16 +24,6 @@ class ServerPartService extends EquipmentService
|
||||
$this->addClassPaths('ServerPart');
|
||||
}
|
||||
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return ServerPartDTO::class;
|
||||
}
|
||||
|
||||
public function createDTO(array $formDatas): ServerPartDTO
|
||||
{
|
||||
return new ServerPartDTO($formDatas);
|
||||
}
|
||||
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return ServerPartEntity::class;
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Services\Equipment;
|
||||
|
||||
use App\DTOs\Equipment\ServerDTO;
|
||||
use App\Entities\Customer\ServiceEntity;
|
||||
use App\Entities\Equipment\ServerEntity;
|
||||
use App\Forms\Equipment\ServerForm;
|
||||
@ -21,16 +20,6 @@ class ServerService extends EquipmentService
|
||||
$this->addClassPaths('Server');
|
||||
}
|
||||
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return ServerDTO::class;
|
||||
}
|
||||
|
||||
public function createDTO(array $formDatas): ServerDTO
|
||||
{
|
||||
return new ServerDTO($formDatas);
|
||||
}
|
||||
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return ServerEntity::class;
|
||||
|
||||
@ -8,7 +8,6 @@ use App\Libraries\OperationContext;
|
||||
use App\Helpers\MylogHelper;
|
||||
use App\Forms\MylogForm;
|
||||
use App\Entities\MylogEntity;
|
||||
use App\DTOs\MylogDTO;
|
||||
|
||||
class MylogService extends CommonService implements PipelineStepInterface
|
||||
{
|
||||
@ -20,14 +19,6 @@ class MylogService extends CommonService implements PipelineStepInterface
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('Mylog');
|
||||
}
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return MylogDTO::class;
|
||||
}
|
||||
public function createDTO(array $formDatas): MylogDTO
|
||||
{
|
||||
return new MylogDTO($formDatas);
|
||||
}
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return MylogEntity::class;
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Services\Part;
|
||||
|
||||
use App\DTOs\Part\CPUDTO;
|
||||
use App\Entities\Equipment\ServerPartEntity;
|
||||
use App\Entities\Part\CPUEntity;
|
||||
use App\Forms\Part\CPUForm;
|
||||
@ -20,14 +19,6 @@ class CPUService extends PartType1Service
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('CPU');
|
||||
}
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return CPUDTO::class;
|
||||
}
|
||||
public function createDTO(array $formDatas): CPUDTO
|
||||
{
|
||||
return new CPUDTO($formDatas);
|
||||
}
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return CPUEntity::class;
|
||||
|
||||
@ -8,7 +8,6 @@ use App\Helpers\Part\CSHelper;
|
||||
use App\Forms\Part\CSForm;
|
||||
use App\Entities\Part\CSEntity;
|
||||
use App\Entities\Equipment\ServerPartEntity;
|
||||
use App\DTOs\Part\CSDTO;
|
||||
|
||||
class CSService extends PartType2Service
|
||||
{
|
||||
@ -20,14 +19,6 @@ class CSService extends PartType2Service
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('CS');
|
||||
}
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return CSDTO::class;
|
||||
}
|
||||
public function createDTO(array $formDatas): CSDTO
|
||||
{
|
||||
return new CSDTO($formDatas);
|
||||
}
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return CSEntity::class;
|
||||
|
||||
@ -8,8 +8,6 @@ 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
|
||||
{
|
||||
@ -21,14 +19,6 @@ class DISKService extends PartType1Service
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('DISK');
|
||||
}
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return DISKDTO::class;
|
||||
}
|
||||
public function createDTO(array $formDatas): DISKDTO
|
||||
{
|
||||
return new DISKDTO($formDatas);
|
||||
}
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return DISKEntity::class;
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Services\Part;
|
||||
|
||||
use App\DTOs\Part\IPDTO;
|
||||
use App\Entities\Equipment\LineEntity;
|
||||
use App\Entities\Equipment\ServerEntity;
|
||||
use App\Entities\Equipment\ServerPartEntity;
|
||||
@ -22,14 +21,6 @@ class IPService extends PartType3Service
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('IP');
|
||||
}
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return IPDTO::class;
|
||||
}
|
||||
public function createDTO(array $formDatas): IPDTO
|
||||
{
|
||||
return new IPDTO($formDatas);
|
||||
}
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return IPEntity::class;
|
||||
|
||||
@ -8,7 +8,6 @@ use App\Helpers\Part\RAMHelper;
|
||||
use App\Forms\Part\RAMForm;
|
||||
use App\Entities\Part\RAMEntity;
|
||||
use App\Entities\Equipment\ServerPartEntity;
|
||||
use App\DTOs\Part\RAMDTO;
|
||||
|
||||
class RAMService extends PartType1Service
|
||||
{
|
||||
@ -20,14 +19,6 @@ class RAMService extends PartType1Service
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('RAM');
|
||||
}
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return RAMDTO::class;
|
||||
}
|
||||
public function createDTO(array $formDatas): RAMDTO
|
||||
{
|
||||
return new RAMDTO($formDatas);
|
||||
}
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return RAMEntity::class;
|
||||
|
||||
@ -8,8 +8,6 @@ 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
|
||||
{
|
||||
@ -21,14 +19,6 @@ class SOFTWAREService extends PartType1Service
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('SOFTWARE');
|
||||
}
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return SOFTWAREDTO::class;
|
||||
}
|
||||
public function createDTO(array $formDatas): SOFTWAREDTO
|
||||
{
|
||||
return new SOFTWAREDTO($formDatas);
|
||||
}
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return SOFTWAREEntity::class;
|
||||
|
||||
@ -9,8 +9,6 @@ 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
|
||||
{
|
||||
@ -22,14 +20,6 @@ class SWITCHService extends PartType3Service
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('SWITCH');
|
||||
}
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return SWITCHDTO::class;
|
||||
}
|
||||
public function createDTO(array $formDatas): SWITCHDTO
|
||||
{
|
||||
return new SWITCHDTO($formDatas);
|
||||
}
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return SWITCHEntity::class;
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\DTOs\PaymentDTO;
|
||||
use App\Entities\Customer\ClientEntity;
|
||||
use App\Entities\Customer\ServiceEntity;
|
||||
use App\Entities\Equipment\ServerEntity;
|
||||
@ -26,21 +25,11 @@ class PaymentService extends CommonService
|
||||
$this->addClassPaths('Payment');
|
||||
}
|
||||
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return PaymentDTO::class;
|
||||
}
|
||||
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return PaymentEntity::class;
|
||||
}
|
||||
|
||||
public function createDTO(array $formDatas): PaymentDTO
|
||||
{
|
||||
return new PaymentDTO($formDatas);
|
||||
}
|
||||
|
||||
//총 미납건수, 금액
|
||||
final public function getUnPaids(string $group, array $where = []): array
|
||||
{
|
||||
|
||||
@ -2,13 +2,10 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
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
|
||||
{
|
||||
@ -20,14 +17,6 @@ class UserService extends CommonService
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('User');
|
||||
}
|
||||
public function getDTOClass(): string
|
||||
{
|
||||
return UserDTO::class;
|
||||
}
|
||||
public function createDTO(array $formDatas): UserDTO
|
||||
{
|
||||
return new UserDTO($formDatas);
|
||||
}
|
||||
public function getEntityClass(): string
|
||||
{
|
||||
return UserEntity::class;
|
||||
@ -37,6 +26,51 @@ class UserService extends CommonService
|
||||
{
|
||||
return $entity;
|
||||
}
|
||||
protected function validation_fieldhook(string $field, $value, array $formDatas): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'role':
|
||||
if (is_string($value)) {
|
||||
$value = ($value === '') ? [] : explode(DEFAULTS["DELIMITER_COMMA"], $value);
|
||||
} elseif (!is_array($value)) {
|
||||
$value = [];
|
||||
}
|
||||
$value = array_values(array_filter(array_map(
|
||||
fn($v) => trim((string) ($v ?? ''), " \t\n\r\0\x0B\""),
|
||||
$value
|
||||
)));
|
||||
$formDatas[$field] = $value;
|
||||
break;
|
||||
default:
|
||||
$formDatas = parent::validation_fieldhook($field, $value, $formDatas);
|
||||
break;
|
||||
}
|
||||
return $formDatas;
|
||||
}
|
||||
|
||||
protected function modify_process_fieldhook(array $formDatas): array
|
||||
{
|
||||
// 1) DB 컬럼 아닌 값 제거
|
||||
unset($formDatas['confirmpassword']);
|
||||
|
||||
// 2) role은 무조건 문자열로
|
||||
if (array_key_exists('role', $formDatas)) {
|
||||
$arr = is_array($formDatas['role'])
|
||||
? $formDatas['role']
|
||||
: explode(',', (string) $formDatas['role']);
|
||||
|
||||
$arr = array_values(array_filter(array_map('trim', $arr)));
|
||||
sort($arr);
|
||||
$formDatas['role'] = implode(',', $arr);
|
||||
}
|
||||
|
||||
// 3) passwd는 빈 값이면 업데이트 제외 (원하면)
|
||||
if (array_key_exists('passwd', $formDatas) && $formDatas['passwd'] === '') {
|
||||
unset($formDatas['passwd']);
|
||||
}
|
||||
|
||||
return $formDatas;
|
||||
}
|
||||
//List 검색용
|
||||
//FormFilter 조건절 처리
|
||||
public function setFilter(string $field, mixed $filter_value): void
|
||||
|
||||
Loading…
Reference in New Issue
Block a user