dbmsv4 init...4
This commit is contained in:
parent
2e66009a7f
commit
cb9384bbbf
@ -25,29 +25,29 @@ class Database extends Config
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
public array $default = [
|
||||
'DSN' => '',
|
||||
'hostname' => 'localhost',
|
||||
'username' => '',
|
||||
'password' => '',
|
||||
'database' => '',
|
||||
'DBDriver' => 'MySQLi',
|
||||
'DBPrefix' => '',
|
||||
'pConnect' => false,
|
||||
'DBDebug' => true,
|
||||
'charset' => 'utf8mb4',
|
||||
'DBCollat' => 'utf8mb4_general_ci',
|
||||
'swapPre' => '',
|
||||
'encrypt' => false,
|
||||
'compress' => false,
|
||||
'strictOn' => false,
|
||||
'failover' => [],
|
||||
'port' => 3306,
|
||||
'numberNative' => false,
|
||||
'foundRows' => false,
|
||||
'dateFormat' => [
|
||||
'date' => 'Y-m-d',
|
||||
'DSN' => '',
|
||||
'hostname' => 'localhost',
|
||||
'username' => '',
|
||||
'password' => '',
|
||||
'database' => '',
|
||||
'DBDriver' => 'MySQLi',
|
||||
'DBPrefix' => '',
|
||||
'pConnect' => false,
|
||||
'DBDebug' => true,
|
||||
'charset' => 'utf8mb4',
|
||||
'DBCollat' => 'utf8mb4_general_ci',
|
||||
'swapPre' => '',
|
||||
'encrypt' => false,
|
||||
'compress' => false,
|
||||
'strictOn' => false,
|
||||
'failover' => [],
|
||||
'port' => 3306,
|
||||
'numberNative' => true,
|
||||
'foundRows' => false,
|
||||
'dateFormat' => [
|
||||
'date' => 'Y-m-d',
|
||||
'datetime' => 'Y-m-d H:i:s',
|
||||
'time' => 'H:i:s',
|
||||
'time' => 'H:i:s',
|
||||
],
|
||||
];
|
||||
|
||||
@ -163,29 +163,29 @@ class Database extends Config
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
public array $tests = [
|
||||
'DSN' => '',
|
||||
'hostname' => '127.0.0.1',
|
||||
'username' => '',
|
||||
'password' => '',
|
||||
'database' => ':memory:',
|
||||
'DBDriver' => 'SQLite3',
|
||||
'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS
|
||||
'pConnect' => false,
|
||||
'DBDebug' => true,
|
||||
'charset' => 'utf8',
|
||||
'DBCollat' => '',
|
||||
'swapPre' => '',
|
||||
'encrypt' => false,
|
||||
'compress' => false,
|
||||
'strictOn' => false,
|
||||
'failover' => [],
|
||||
'port' => 3306,
|
||||
'DSN' => '',
|
||||
'hostname' => '127.0.0.1',
|
||||
'username' => '',
|
||||
'password' => '',
|
||||
'database' => ':memory:',
|
||||
'DBDriver' => 'SQLite3',
|
||||
'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS
|
||||
'pConnect' => false,
|
||||
'DBDebug' => true,
|
||||
'charset' => 'utf8',
|
||||
'DBCollat' => '',
|
||||
'swapPre' => '',
|
||||
'encrypt' => false,
|
||||
'compress' => false,
|
||||
'strictOn' => false,
|
||||
'failover' => [],
|
||||
'port' => 3306,
|
||||
'foreignKeys' => true,
|
||||
'busyTimeout' => 1000,
|
||||
'dateFormat' => [
|
||||
'date' => 'Y-m-d',
|
||||
'dateFormat' => [
|
||||
'date' => 'Y-m-d',
|
||||
'datetime' => 'Y-m-d H:i:s',
|
||||
'time' => 'H:i:s',
|
||||
'time' => 'H:i:s',
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
@ -21,14 +21,14 @@ class BoardEntity extends CommonEntity
|
||||
}
|
||||
final public function getUserUid(): int|null
|
||||
{
|
||||
return $this->attributes['user_uid'] ?? null;
|
||||
return $this->user_uid ?? null;
|
||||
}
|
||||
final public function getWorkerUid(): int|null
|
||||
{
|
||||
return $this->attributes['worker_uid'] ?? null;
|
||||
return $this->worker_uid ?? null;
|
||||
}
|
||||
final public function getCaregory(): string
|
||||
{
|
||||
return $this->attributes['category'] ?? "";
|
||||
return $this->category ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,13 +7,20 @@ use CodeIgniter\Entity\Entity;
|
||||
abstract class CommonEntity extends Entity
|
||||
{
|
||||
protected $datamap = [];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
//사용법 : $client->created_at->format('Y-m-d')
|
||||
//비교방법 : if ($client->created_at < new \DateTime('2024-01-01')) {
|
||||
public function __construct(array|null $data = null)
|
||||
{
|
||||
parent::__construct($data);
|
||||
}
|
||||
public function __get(string $key)
|
||||
{
|
||||
if (array_key_exists($key, $this->attributes)) {
|
||||
return $this->attributes[$key];
|
||||
}
|
||||
return parent::__get($key);
|
||||
}
|
||||
final public function getPK(): int|string
|
||||
{
|
||||
$field = constant("static::PK");
|
||||
@ -30,18 +37,18 @@ abstract class CommonEntity extends Entity
|
||||
}
|
||||
final public function getStatus(): string
|
||||
{
|
||||
return $this->attributes['status'] ?? "";
|
||||
return $this->status ?? "";
|
||||
}
|
||||
final public function getUpdatedAt(): string
|
||||
{
|
||||
return $this->attributes['updated_at'] ?? "";
|
||||
return $this->updated_at ?? "";
|
||||
}
|
||||
final public function getCreatedAt(): string
|
||||
{
|
||||
return $this->attributes['created_at'] ?? "";
|
||||
return $this->created_at ?? "";
|
||||
}
|
||||
final public function getDeletedAt(): string
|
||||
{
|
||||
return $this->attributes['deleted_at'] ?? "";
|
||||
return $this->deleted_at ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ class ClientEntity extends CustomerEntity
|
||||
|
||||
public function getUserUid(): int|null
|
||||
{
|
||||
return $this->attributes['user_uid'] ?? null;
|
||||
return $this->user_uid ?? null;
|
||||
}
|
||||
//기본기능
|
||||
public function getCustomTitle(mixed $title = null): string
|
||||
@ -36,27 +36,27 @@ class ClientEntity extends CustomerEntity
|
||||
}
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->attributes['name'];
|
||||
return $this->name;
|
||||
}
|
||||
public function getSite(): string
|
||||
{
|
||||
return $this->attributes['site'];
|
||||
return $this->site;
|
||||
}
|
||||
public function getAccountBalance(): int
|
||||
{
|
||||
return $this->attributes['account_balance'] ?? 0;
|
||||
return $this->account_balance ?? 0;
|
||||
}
|
||||
public function getCouponBalance(): int
|
||||
{
|
||||
return $this->attributes['coupon_balance'] ?? 0;
|
||||
return $this->coupon_balance ?? 0;
|
||||
}
|
||||
public function getPointBalance(): int
|
||||
{
|
||||
return $this->attributes['point_balance'] ?? 0;
|
||||
return $this->point_balance ?? 0;
|
||||
}
|
||||
public function getHistory(): string|null
|
||||
{
|
||||
return $this->attributes['history'];
|
||||
return $this->history;
|
||||
}
|
||||
/*
|
||||
* 사용자의 역할을 배열 형태로 반환합니다.
|
||||
@ -65,7 +65,7 @@ class ClientEntity extends CustomerEntity
|
||||
*/
|
||||
public function getRole(): array
|
||||
{
|
||||
$role = $this->attributes['role'] ?? null;
|
||||
$role = $this->role ?? null;
|
||||
// 1. 이미 배열인 경우 (방어적 코딩)
|
||||
if (is_array($role)) {
|
||||
return array_filter($role);
|
||||
@ -113,6 +113,6 @@ class ClientEntity extends CustomerEntity
|
||||
$cleanedRoles = array_map(fn($item) => trim((string) ($item ?? ''), " \t\n\r\0\x0B\""), $roleArray);
|
||||
$roleArray = array_filter($cleanedRoles);
|
||||
// 최종적으로 DB에 삽입될 단일 CSV 문자열로 변환하여 저장합니다.
|
||||
$this->attributes['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $roleArray);
|
||||
$this->role = implode(DEFAULTS["DELIMITER_ROLE"], $roleArray);
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,8 +14,8 @@ class ServiceEntity extends CustomerEntity
|
||||
'site' => '',
|
||||
'location' => '',
|
||||
'rack' => 0,
|
||||
'coupon_balance' => 0,
|
||||
'line' => 0,
|
||||
'coupon_balance' => 0,
|
||||
'line' => 0,
|
||||
'billing_at' => '',
|
||||
'sale' => 0,
|
||||
'amount' => 0,
|
||||
@ -30,58 +30,58 @@ class ServiceEntity extends CustomerEntity
|
||||
}
|
||||
final public function getUserUid(): int|null
|
||||
{
|
||||
return $this->attributes['user_uid'] ?? null;
|
||||
return $this->user_uid ?? null;
|
||||
}
|
||||
final public function getClientInfoUid(): int|null
|
||||
final public function getClientInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['clientinfo_uid'] ?? null;
|
||||
return $this->clientinfo_uid ?? null;
|
||||
}
|
||||
final public function getServerInfoUid(): int|null
|
||||
final public function getServerInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['serverinfo_uid'] ?? null;
|
||||
return $this->serverinfo_uid ?? null;
|
||||
}
|
||||
//기본기능용
|
||||
final public function getCode(): string
|
||||
{
|
||||
return $this->attributes['code'] ?? '';
|
||||
return $this->code ?? '';
|
||||
}
|
||||
final public function getSite(): string
|
||||
{
|
||||
return $this->attributes['site'] ?? '';
|
||||
return $this->site ?? '';
|
||||
}
|
||||
final public function getLocation(): string
|
||||
{
|
||||
return $this->attributes['location'] ?? '';
|
||||
return $this->location ?? '';
|
||||
}
|
||||
final public function getBillingAt(): string
|
||||
{
|
||||
return $this->attributes['billing_at'] ?? '';
|
||||
return $this->billing_at ?? '';
|
||||
}
|
||||
//청구금액->기본:상면비+회선비+서버금액(price)+서버파트연결(월비용)-할인액
|
||||
//상면비
|
||||
final public function getRack(): int
|
||||
{
|
||||
return $this->attributes['rack'] ?? 0;
|
||||
return $this->rack ?? 0;
|
||||
}
|
||||
//회선비
|
||||
final public function getLine(): int
|
||||
{
|
||||
return $this->attributes['line'] ?? 0;
|
||||
return $this->line ?? 0;
|
||||
}
|
||||
final public function getSale(): int
|
||||
{
|
||||
return $this->attributes['sale'] ?? 0;
|
||||
return $this->sale ?? 0;
|
||||
}
|
||||
final public function getAmount(): int
|
||||
{
|
||||
return $this->attributes['amount'] ?? 0;
|
||||
return $this->amount ?? 0;
|
||||
}
|
||||
final public function getStartAt(): string
|
||||
{
|
||||
return $this->attributes['start_at'] ?? '';
|
||||
return $this->start_at ?? '';
|
||||
}
|
||||
public function getHistory(): string
|
||||
{
|
||||
return $this->attributes['history'] ?? '';
|
||||
return $this->history ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,16 +6,22 @@ use App\Models\Customer\Wallet\AccountModel;
|
||||
|
||||
class AccountEntity extends WalletEntity
|
||||
{
|
||||
const PK = AccountModel::PK;
|
||||
const PK = AccountModel::PK;
|
||||
const TITLE = AccountModel::TITLE;
|
||||
protected $casts = [
|
||||
'clientinfo_uid' => 'integer',
|
||||
'user_uid' => '?integer',
|
||||
];
|
||||
protected $attributes = [
|
||||
'clientinfo_uid' => null,
|
||||
'user_uid' => null,
|
||||
'title' => '',
|
||||
'bank' => '',
|
||||
'alias' => '',
|
||||
'issue_at' => '',
|
||||
'amount' => 0,
|
||||
'balance' => 0,
|
||||
'status' => '',
|
||||
'status' => '',
|
||||
'content' => ''
|
||||
];
|
||||
public function __construct(array|null $data = null)
|
||||
@ -25,14 +31,14 @@ class AccountEntity extends WalletEntity
|
||||
//기본기능
|
||||
public function getBank(): string
|
||||
{
|
||||
return $this->attributes['bank'] ?? '';
|
||||
return $this->bank ?? '';
|
||||
}
|
||||
public function getAlias(): string
|
||||
{
|
||||
return $this->attributes['alias'] ?? '';
|
||||
return $this->alias ?? '';
|
||||
}
|
||||
public function getIssueAt(): string
|
||||
{
|
||||
return $this->attributes['issue_at'] ?? '';
|
||||
return $this->issue_at ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,13 +7,13 @@ use App\Models\Customer\Wallet\CouponModel;
|
||||
class CouponEntity extends WalletEntity
|
||||
{
|
||||
|
||||
const PK = CouponModel::PK;
|
||||
const PK = CouponModel::PK;
|
||||
const TITLE = CouponModel::TITLE;
|
||||
protected $attributes = [
|
||||
'title' => '',
|
||||
'amount' => 0,
|
||||
'balance' => 0,
|
||||
'status' => '',
|
||||
'status' => '',
|
||||
'content' => ''
|
||||
];
|
||||
public function __construct(array|null $data = null)
|
||||
|
||||
@ -12,7 +12,7 @@ class PointEntity extends WalletEntity
|
||||
'title' => '',
|
||||
'amount' => 0,
|
||||
'balance' => 0,
|
||||
'status' => '',
|
||||
'status' => '',
|
||||
'content' => ''
|
||||
];
|
||||
public function __construct(array|null $data = null)
|
||||
|
||||
@ -13,23 +13,23 @@ abstract class WalletEntity extends CustomerEntity
|
||||
}
|
||||
final public function getUserUid(): int|null
|
||||
{
|
||||
return $this->attributes['user_uid'] ?? null;
|
||||
return $this->user_uid ?? null;
|
||||
}
|
||||
final public function getClientInfoUid(): int|null
|
||||
final public function getClientInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['clientinfo_uid'] ?? null;
|
||||
return $this->clientinfo_uid ?? null;
|
||||
}
|
||||
//기본기능
|
||||
final public function getAmount(): int
|
||||
{
|
||||
return $this->attributes['amount'] ?? 0;
|
||||
return $this->amount ?? 0;
|
||||
}
|
||||
final public function getBalance(): int
|
||||
{
|
||||
return $this->attributes['balance'] ?? 0;
|
||||
return $this->balance ?? 0;
|
||||
}
|
||||
final public function getContent(): string
|
||||
{
|
||||
return $this->attributes['content'] ?? '';
|
||||
return $this->content ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ use App\Models\Equipment\CHASSISModel;
|
||||
|
||||
class CHASSISEntity extends EquipmentEntity
|
||||
{
|
||||
const PK = CHASSISModel::PK;
|
||||
const PK = CHASSISModel::PK;
|
||||
const TITLE = CHASSISModel::TITLE;
|
||||
protected $attributes = [
|
||||
'title' => '',
|
||||
@ -22,45 +22,45 @@ class CHASSISEntity extends EquipmentEntity
|
||||
{
|
||||
parent::__construct($data);
|
||||
}
|
||||
public function getCPUInfoUid(): int|null
|
||||
public function getCPUInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['cpuinfo_uid'] ?? null;
|
||||
return $this->cpuinfo_uid ?? null;
|
||||
}
|
||||
public function getRAMInfoUid(): int|null
|
||||
public function getRAMInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['raminfo_uid'] ?? null;
|
||||
return $this->raminfo_uid ?? null;
|
||||
}
|
||||
public function getDISKInfoUid(): int|null
|
||||
public function getDISKInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['diskinfo_uid'] ?? null;
|
||||
return $this->diskinfo_uid ?? null;
|
||||
}
|
||||
//기본기능
|
||||
public function getPrice(): int
|
||||
{
|
||||
return $this->attributes['price'] ?? 0;
|
||||
return $this->price ?? 0;
|
||||
}
|
||||
public function getStock(): int
|
||||
{
|
||||
return $this->attributes['stock'] ?? 0;
|
||||
return $this->stock ?? 0;
|
||||
}
|
||||
public function getUsed(): int
|
||||
{
|
||||
return $this->attributes['used'] ?? 0;
|
||||
return $this->used ?? 0;
|
||||
}
|
||||
public function getAvailable(): int
|
||||
{
|
||||
return $this->getStock() - $this->getUsed();
|
||||
}
|
||||
public function getCPUCnt(): int
|
||||
public function getCPUCnt(): int
|
||||
{
|
||||
return $this->attributes['cpu_cnt'] ?? 0;
|
||||
return $this->cpu_cnt ?? 0;
|
||||
}
|
||||
public function getRAMCnt(): int
|
||||
public function getRAMCnt(): int
|
||||
{
|
||||
return $this->attributes['ram_cnt'] ?? 0;
|
||||
return $this->ram_cnt ?? 0;
|
||||
}
|
||||
public function getDISKCnt(): int
|
||||
public function getDISKCnt(): int
|
||||
{
|
||||
return $this->attributes['disk_cnt'] ?? 0;
|
||||
return $this->disk_cnt ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,26 +24,26 @@ class LineEntity extends EquipmentEntity
|
||||
const TITLE = LineModel::TITLE;
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->attributes['type'] ?? '';
|
||||
return $this->type ?? '';
|
||||
}
|
||||
public function getProtocol(): string
|
||||
{
|
||||
return $this->attributes['protocol'] ?? '';
|
||||
return $this->protocol ?? '';
|
||||
}
|
||||
public function getBandwith(): string
|
||||
{
|
||||
return $this->attributes['bandwith'] ?? '';
|
||||
return $this->bandwith ?? '';
|
||||
}
|
||||
public function getStartAt(): string
|
||||
{
|
||||
return $this->attributes['start_at'] ?? '';
|
||||
return $this->start_at ?? '';
|
||||
}
|
||||
public function getEndAt(): string
|
||||
{
|
||||
return $this->attributes['end_at'] ?? '';
|
||||
return $this->end_at ?? '';
|
||||
}
|
||||
public function getContent(): string
|
||||
{
|
||||
return $this->attributes['content'] ?? '';
|
||||
return $this->content ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,7 +8,13 @@ class ServerEntity extends EquipmentEntity
|
||||
{
|
||||
const PK = ServerModel::PK;
|
||||
const TITLE = ServerModel::TITLE;
|
||||
|
||||
protected $attributes = [
|
||||
'user_uid' => null,
|
||||
'clientinfo_uid' => null,
|
||||
'serviceinfo_uid' => null,
|
||||
'chassisinfo_uid' => null,
|
||||
'switchinfo_uid' => null,
|
||||
'code' => '',
|
||||
'title' => '',
|
||||
'type' => '',
|
||||
@ -26,19 +32,23 @@ class ServerEntity extends EquipmentEntity
|
||||
}
|
||||
final public function getClientInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['clientinfo_uid'] ?? null;
|
||||
$val = $this->clientinfo_uid ?? null;
|
||||
return ($val === '' || $val === null) ? null : (int) $val;
|
||||
}
|
||||
final public function getServiceInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['serviceinfo_uid'] ?? null;
|
||||
$val = $this->serviceinfo_uid ?? null;
|
||||
return ($val === '' || $val === null) ? null : (int) $val;
|
||||
}
|
||||
final public function getChassisInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['chassisinfo_uid'] ?? null;
|
||||
$val = $this->chassisinfo_uid ?? null;
|
||||
return ($val === '' || $val === null) ? null : (int) $val;
|
||||
}
|
||||
final public function getSwitchInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['switchinfo_uid'] ?? null;
|
||||
$val = $this->switchinfo_uid ?? null;
|
||||
return ($val === '' || $val === null) ? null : (int) $val;
|
||||
}
|
||||
//기본기능용
|
||||
public function getCustomTitle(mixed $title = null): string
|
||||
@ -47,34 +57,34 @@ class ServerEntity extends EquipmentEntity
|
||||
}
|
||||
final public function getCode(): string
|
||||
{
|
||||
return $this->attributes['code'] ?? '';
|
||||
return $this->code ?? null;
|
||||
}
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->attributes['type'] ?? '';
|
||||
return $this->type ?? null;
|
||||
}
|
||||
public function getIP(): string
|
||||
{
|
||||
return $this->attributes['ip'] ?? '';
|
||||
return $this->ip ?? '';
|
||||
}
|
||||
public function getViewer(): string
|
||||
{
|
||||
return $this->attributes['viewer'] ?? '';
|
||||
return $this->viewer ?? '';
|
||||
}
|
||||
public function getOS(): string
|
||||
{
|
||||
return $this->attributes['os'] ?? '';
|
||||
return $this->os ?? '';
|
||||
}
|
||||
public function getPrice(): int
|
||||
{
|
||||
return $this->attributes['price'] ?? 0;
|
||||
return $this->price ?? 0;
|
||||
}
|
||||
public function getManufacturAt(): string
|
||||
{
|
||||
return $this->attributes['manufactur_at'] ?? '';
|
||||
return $this->manufactur_at ?? '';
|
||||
}
|
||||
public function getFormatAt(): string
|
||||
{
|
||||
return $this->attributes['format_at'] ?? '';
|
||||
return $this->format_at ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,9 +6,21 @@ use App\Models\Equipment\ServerPartModel;
|
||||
|
||||
class ServerPartEntity extends EquipmentEntity
|
||||
{
|
||||
const PK = ServerPartModel::PK;
|
||||
const PK = ServerPartModel::PK;
|
||||
const TITLE = ServerPartModel::TITLE;
|
||||
|
||||
protected $casts = [
|
||||
'clientinfo_uid' => '?integer',
|
||||
'part_uid' => '?integer',
|
||||
'serverinfo_uid' => 'integer',
|
||||
'serviceinfo_uid' => '?integer',
|
||||
];
|
||||
|
||||
protected $attributes = [
|
||||
'clientinfo_uid' => null,
|
||||
'part_uid' => null,
|
||||
'serverinfo_uid' => null,
|
||||
'serviceinfo_uid' => null,
|
||||
'title' => '',
|
||||
'type' => '',
|
||||
'billing' => '',
|
||||
@ -21,21 +33,21 @@ class ServerPartEntity extends EquipmentEntity
|
||||
{
|
||||
parent::__construct($data);
|
||||
}
|
||||
public function getClientInfoUid(): int|null
|
||||
public function getClientInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['clientinfo_uid'] ?? null;
|
||||
return $this->clientinfo_uid ?? null;
|
||||
}
|
||||
public function getServiceInfoUid(): int|null
|
||||
public function getServiceInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['serviceinfo_uid'] ?? null;
|
||||
return $this->serviceinfo_uid ?? null;
|
||||
}
|
||||
public function getServerInfoUid(): int|null
|
||||
public function getServerInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['serverinfo_uid'] ?? null;
|
||||
return $this->serverinfo_uid ?? null;
|
||||
}
|
||||
public function getPartUid(): int|null
|
||||
public function getPartUid(): int|null
|
||||
{
|
||||
return $this->attributes['part_uid'] ?? null;
|
||||
return $this->part_uid ?? null;
|
||||
}
|
||||
//기본기능용
|
||||
public function getCustomTitle(): string
|
||||
@ -48,26 +60,26 @@ class ServerPartEntity extends EquipmentEntity
|
||||
}
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->attributes['type'] ?? "";
|
||||
return $this->type ?? "";
|
||||
}
|
||||
public function getBilling(): string
|
||||
{
|
||||
return $this->attributes['billing'] ?? "";
|
||||
return $this->billing ?? "";
|
||||
}
|
||||
public function getBillingAt(): string
|
||||
{
|
||||
return $this->attributes['billing_at'] ?? "";
|
||||
return $this->billing_at ?? "";
|
||||
}
|
||||
public function getCnt(): int
|
||||
{
|
||||
return $this->attributes['cnt'] ?? 0;
|
||||
return $this->cnt ?? 0;
|
||||
}
|
||||
public function getAmount(): int
|
||||
{
|
||||
return $this->attributes['amount'] ?? 0;
|
||||
return $this->amount ?? 0;
|
||||
}
|
||||
public function getExtra(): string
|
||||
{
|
||||
return $this->attributes['extra'] ?? '';
|
||||
return $this->extra ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ use App\Models\Part\CPUModel;
|
||||
|
||||
class CPUEntity extends PartType1Entity
|
||||
{
|
||||
const PK = CPUModel::PK;
|
||||
const PK = CPUModel::PK;
|
||||
const TITLE = CPUModel::TITLE;
|
||||
public function __construct(array|null $data = null)
|
||||
{
|
||||
|
||||
@ -21,30 +21,30 @@ class CSEntity extends PartType2Entity
|
||||
parent::__construct($data);
|
||||
}
|
||||
//기본기능
|
||||
final public function getClientInfoUid(): int|null
|
||||
final public function getClientInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['clientinfo_uid'];
|
||||
return $this->clientinfo_uid;
|
||||
}
|
||||
final public function getServiceInfoUid(): int|null
|
||||
final public function getServiceInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['serviceinfo_uid'];
|
||||
return $this->serviceinfo_uid;
|
||||
}
|
||||
final public function getServerInfoUid(): int|null
|
||||
final public function getServerInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['serverinfo_uid'];
|
||||
return $this->serverinfo_uid;
|
||||
}
|
||||
public function getIP(): string
|
||||
{
|
||||
return $this->attributes['ip'] ?? '';
|
||||
return $this->ip ?? '';
|
||||
}
|
||||
//기본기능
|
||||
public function getAccountID(): string
|
||||
{
|
||||
return $this->attributes['accountid'] ?? "";
|
||||
return $this->accountid ?? "";
|
||||
}
|
||||
public function getDomain(): string
|
||||
{
|
||||
return $this->attributes['domain'] ?? "";
|
||||
return $this->domain ?? "";
|
||||
}
|
||||
//abstract 선언처리용
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ use App\Models\Part\DISKModel;
|
||||
|
||||
class DISKEntity extends PartType1Entity
|
||||
{
|
||||
const PK = DISKModel::PK;
|
||||
const PK = DISKModel::PK;
|
||||
const TITLE = DISKModel::TITLE;
|
||||
protected $attributes = [
|
||||
'title' => '',
|
||||
@ -24,6 +24,6 @@ class DISKEntity extends PartType1Entity
|
||||
|
||||
public function getFormat(): int
|
||||
{
|
||||
return $this->attributes['format'] ?? 0;
|
||||
return $this->format ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,33 +21,33 @@ class IPEntity extends PartType3Entity
|
||||
{
|
||||
parent::__construct($data);
|
||||
}
|
||||
public function getLineInfoUID(): int|null
|
||||
public function getLineInfoUID(): int|null
|
||||
{
|
||||
return $this->attributes['lineinfo_uid'] ?? null;
|
||||
return $this->lineinfo_uid ?? null;
|
||||
}
|
||||
public function getOldClientInfoUID(): int|null
|
||||
public function getOldClientInfoUID(): int|null
|
||||
{
|
||||
return $this->attributes['old_clientinfo_uid'] ?? null;
|
||||
return $this->old_clientinfo_uid ?? null;
|
||||
}
|
||||
final public function getClientInfoUid(): int|null
|
||||
final public function getClientInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['clientinfo_uid'];
|
||||
return $this->clientinfo_uid;
|
||||
}
|
||||
final public function getServiceInfoUid(): int|null
|
||||
final public function getServiceInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['serviceinfo_uid'];
|
||||
return $this->serviceinfo_uid;
|
||||
}
|
||||
final public function getServerInfoUid(): int|null
|
||||
final public function getServerInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['serverinfo_uid'];
|
||||
return $this->serverinfo_uid;
|
||||
}
|
||||
//기본기능
|
||||
public function getIP(): string
|
||||
{
|
||||
return $this->attributes['ip'] ?? "";
|
||||
return $this->ip ?? "";
|
||||
}
|
||||
public function getContent(): string
|
||||
{
|
||||
return $this->attributes['content'] ?? "";
|
||||
return $this->content ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,10 +15,10 @@ abstract class PartEntity extends CommonEntity
|
||||
//기본기능용
|
||||
public function getCustomTitle(mixed $title = null): string
|
||||
{
|
||||
return sprintf("%s %s원", $title ? $title : $this->getTitle(), number_format($this->getPrice()));
|
||||
return sprintf("%s %s원", $title ? $title : $this->getTitle(), number_format($this->getPrice()));
|
||||
}
|
||||
final public function getPrice(): int
|
||||
{
|
||||
return $this->attributes['price'] ?? 0;
|
||||
return $this->price ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,11 +20,11 @@ class PartType1Entity extends PartEntity
|
||||
//기본기능
|
||||
final public function getStock(): int
|
||||
{
|
||||
return $this->attributes['stock'] ?? 0;
|
||||
return $this->stock ?? 0;
|
||||
}
|
||||
final public function getUsed(): int
|
||||
{
|
||||
return $this->attributes['used'] ?? 0;
|
||||
return $this->used ?? 0;
|
||||
}
|
||||
final public function getAvailable(): int
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@ use App\Models\Part\RAMModel;
|
||||
|
||||
class RAMEntity extends PartType1Entity
|
||||
{
|
||||
const PK = RAMModel::PK;
|
||||
const PK = RAMModel::PK;
|
||||
const TITLE = RAMModel::TITLE;
|
||||
protected $attributes = [
|
||||
'title' => '',
|
||||
|
||||
@ -6,6 +6,6 @@ use App\Models\Part\SOFTWAREModel;
|
||||
|
||||
class SOFTWAREEntity extends PartType1Entity
|
||||
{
|
||||
const PK = SOFTWAREModel::PK;
|
||||
const PK = SOFTWAREModel::PK;
|
||||
const TITLE = SOFTWAREModel::TITLE;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ use App\Models\Part\SWITCHModel;
|
||||
|
||||
class SWITCHEntity extends PartType3Entity
|
||||
{
|
||||
const PK = SWITCHModel::PK;
|
||||
const PK = SWITCHModel::PK;
|
||||
const TITLE = SWITCHModel::TITLE;
|
||||
protected $attributes = [
|
||||
'code' => 0,
|
||||
@ -15,23 +15,22 @@ class SWITCHEntity extends PartType3Entity
|
||||
];
|
||||
public function __construct(array|null $data = null)
|
||||
{
|
||||
$this->attributes['code'] = '';
|
||||
parent::__construct($data);
|
||||
}
|
||||
final public function getClientInfoUid(): int|null
|
||||
final public function getClientInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['clientinfo_uid'];
|
||||
return $this->clientinfo_uid ?? null;
|
||||
}
|
||||
final public function getServiceInfoUid(): int|null
|
||||
final public function getServiceInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['serviceinfo_uid'];
|
||||
return $this->serviceinfo_uid ?? null;
|
||||
}
|
||||
final public function getServerInfoUid(): int|null
|
||||
final public function getServerInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['serverinfo_uid'];
|
||||
return $this->serverinfo_uid ?? null;
|
||||
}
|
||||
public function getCode(): string
|
||||
{
|
||||
return $this->attributes['code'] ?? "";
|
||||
return $this->code ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,15 +25,15 @@ class PaymentEntity extends CommonEntity
|
||||
}
|
||||
final public function getUserUid(): int|null
|
||||
{
|
||||
return $this->attributes['user_uid'] ?? null;
|
||||
return $this->user_uid ?? null;
|
||||
}
|
||||
final public function getClientInfoUid(): int|null
|
||||
final public function getClientInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['clientinfo_uid'] ?? null;
|
||||
return $this->clientinfo_uid ?? null;
|
||||
}
|
||||
final public function getServiceInfoUid(): int|null
|
||||
final public function getServiceInfoUid(): int|null
|
||||
{
|
||||
return $this->attributes['serviceinfo_uid'] ?? null;
|
||||
return $this->serviceinfo_uid ?? null;
|
||||
}
|
||||
//기본기능
|
||||
public function getCustomTitle(): string
|
||||
@ -42,27 +42,27 @@ class PaymentEntity extends CommonEntity
|
||||
}
|
||||
public function getBilling(): string
|
||||
{
|
||||
return $this->attributes['billing'] ?? "";
|
||||
return $this->billing ?? "";
|
||||
}
|
||||
public function getAmount(): int
|
||||
{
|
||||
return $this->attributes['amount'] ?? 0;
|
||||
return $this->amount ?? 0;
|
||||
}
|
||||
public function getBillingAt(): string
|
||||
{
|
||||
return $this->attributes['billing_at'] ?? "";
|
||||
return $this->billing_at ?? "";
|
||||
}
|
||||
public function getBillingMonth(): int
|
||||
{
|
||||
return $this->attributes['billing_month'] ?? 0;
|
||||
return $this->billing_month ?? 0;
|
||||
}
|
||||
public function getPay(): string
|
||||
{
|
||||
return $this->attributes['pay'] ?? "";
|
||||
return $this->pay ?? "";
|
||||
}
|
||||
public function getContent(): string
|
||||
{
|
||||
return $this->attributes['content'] ?? "";
|
||||
return $this->content ?? "";
|
||||
}
|
||||
public function getCountDueAt(): string
|
||||
{
|
||||
@ -72,10 +72,10 @@ class PaymentEntity extends CommonEntity
|
||||
$due = new DateTime($this->getBillingAt());
|
||||
if ($due < $now) {
|
||||
$interval = $due->diff($now);
|
||||
$result = "{$interval->days}일지남";
|
||||
$result = "{$interval->days}일지남";
|
||||
} else if ($due > $now) {
|
||||
$interval = $now->diff($due);
|
||||
$day = $interval->days + 1;
|
||||
$day = $interval->days + 1;
|
||||
$result = "{$day}일전";
|
||||
} else {
|
||||
$result = "당일";
|
||||
|
||||
@ -30,11 +30,11 @@ class UserEntity extends CommonEntity
|
||||
}
|
||||
public function getID(): string
|
||||
{
|
||||
return (string) $this->attributes['id'];
|
||||
return (string) $this->id;
|
||||
}
|
||||
public function getPassword(): string
|
||||
{
|
||||
return $this->attributes['passwd'];
|
||||
return $this->passwd;
|
||||
}
|
||||
/**
|
||||
* 사용자의 역할을 배열 형태로 반환합니다.
|
||||
@ -43,7 +43,7 @@ class UserEntity extends CommonEntity
|
||||
*/
|
||||
public function getRole(): array
|
||||
{
|
||||
$role = $this->attributes['role'] ?? null;
|
||||
$role = $this->role ?? null;
|
||||
// 1. 이미 배열인 경우 (방어적 코딩)
|
||||
if (is_array($role)) {
|
||||
return array_filter($role);
|
||||
@ -70,7 +70,7 @@ class UserEntity extends CommonEntity
|
||||
{
|
||||
// 입력된 비밀번호가 null이 아니고 비어있지 않을 때만 해시 처리
|
||||
if (!empty($password)) {
|
||||
$this->attributes['passwd'] = password_hash($password, PASSWORD_BCRYPT);
|
||||
$this->passwd = password_hash($password, PASSWORD_BCRYPT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,6 +99,6 @@ class UserEntity extends CommonEntity
|
||||
$cleanedRoles = array_map(fn($item) => trim((string) ($item ?? ''), " \t\n\r\0\x0B\""), $roleArray);
|
||||
$roleArray = array_filter($cleanedRoles);
|
||||
// 최종적으로 DB에 삽입될 단일 CSV 문자열로 변환하여 저장합니다.
|
||||
$this->attributes['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $roleArray);
|
||||
$this->role = implode(DEFAULTS["DELIMITER_ROLE"], $roleArray);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,18 +21,18 @@ class UserSNSEntity extends CommonEntity
|
||||
//Common Function
|
||||
public function getID(): string
|
||||
{
|
||||
return $this->attributes['id'];
|
||||
return $this->id;
|
||||
}
|
||||
public function getSite(): string
|
||||
{
|
||||
return $this->attributes['site'];
|
||||
return $this->site;
|
||||
}
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->attributes['email'];
|
||||
return $this->email;
|
||||
}
|
||||
public function getParent(): int|string
|
||||
{
|
||||
return $this->attributes['user_uid'];
|
||||
return $this->user_uid;
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,11 +126,14 @@ abstract class CommonService
|
||||
* 단일 엔티티를 조회합니다.
|
||||
*/
|
||||
abstract protected function getEntity_process(CommonEntity $entity): CommonEntity;
|
||||
final public function getEntity(string|int|array $where, ?string $message = null): ?CommonEntity
|
||||
final public function getEntity($where = null, ?string $message = null): ?CommonEntity
|
||||
{
|
||||
try {
|
||||
$entity = is_array($where) ? $this->model->where($where)->first() : $this->model->find($where);
|
||||
if (!$entity) {
|
||||
$entity = null;
|
||||
if ($where !== null) {
|
||||
$entity = is_array($where) ? $this->model->where($where)->first() : $this->model->find($where);
|
||||
}
|
||||
if ($entity === null) {
|
||||
return null;
|
||||
}
|
||||
// 💡 동적으로 가져온 Entity 클래스 이름으로 instanceof 검사
|
||||
@ -234,8 +237,8 @@ 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));
|
||||
$result = $this->model->save($entity);
|
||||
log_message('debug', __FUNCTION__ . ":" . $this->model->getLastQuery());
|
||||
// 최종적으로 DB에 반영된 PK를 반환받습니다. (UPDATE이면 기존 PK, INSERT이면 새 PK)
|
||||
$entity->{$this->getPKField()} = $this->handle_save_result($result, $initialPK);
|
||||
|
||||
@ -46,7 +46,28 @@ class ServerPartService extends EquipmentService
|
||||
{
|
||||
return $entity;
|
||||
}
|
||||
private function getFormDatasForServerPart(array $formDatas): array
|
||||
private function getBillingAtByServiceEntity(ServiceEntity $serviceEntity, string $billing): string
|
||||
{
|
||||
//청구방식에 따른 결제일 설정
|
||||
$billing_at = null;
|
||||
if ($billing === PAYMENT['BILLING']['MONTH']) {
|
||||
$billing_at = $serviceEntity->getBillingAt();
|
||||
} else if ($billing === PAYMENT['BILLING']['ONETIME']) {
|
||||
$billing_at = date("Y-m-d");
|
||||
} else {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$billing}에 해당하는 청구방식을 찾을수 없습니다.");
|
||||
}
|
||||
return $billing_at;
|
||||
}
|
||||
private function setPartTitleByPartEntity(array $formDatas): string
|
||||
{
|
||||
$partEntity = $this->getPartService($formDatas['type'])->getEntity($formDatas['part_uid']);
|
||||
if (!$partEntity instanceof PartEntity) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$formDatas['part_uid']}에 해당하는 파트정보을 찾을수 없습니다.");
|
||||
}
|
||||
return $partEntity->getTitle();
|
||||
}
|
||||
private function getFormDatasForServerPart(array $formDatas, ServerEntity $serverEntity): array
|
||||
{
|
||||
if (empty($formDatas['serverinfo_uid'])) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 서버번호가 지정되지 않았습니다.");
|
||||
@ -61,44 +82,33 @@ class ServerPartService extends EquipmentService
|
||||
if (empty($formDatas['part_uid'])) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 파트번호가 지정되지 않았습니다.");
|
||||
}
|
||||
//서버정보 가져오기
|
||||
$serverEntity = service('equipment_serverservice')->getEntity($formDatas['serverinfo_uid']);
|
||||
if (!$serverEntity instanceof ServerEntity) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$formDatas['serverinfo_uid']}에 해당하는 서버정보을 찾을수 없습니다.");
|
||||
}
|
||||
//해당 파트정보의 Title을 파트정보의 Title로 설정
|
||||
$formDatas['title'] = $this->setPartTitleByPartEntity($formDatas);
|
||||
//청구일 설정
|
||||
//서비스정보 가져오기
|
||||
$serviceEntity = null;
|
||||
if ($serverEntity->getServiceInfoUid()) {
|
||||
$serviceEntity = service('customer_serviceservice')->getEntity($serverEntity->getServiceInfoUid());
|
||||
}
|
||||
//각 파트정보 가져오기
|
||||
$partEntity = $this->getPartService($formDatas['type'])->getEntity($formDatas['part_uid']);
|
||||
if (!$serviceEntity instanceof ServiceEntity) {
|
||||
$formDatas['billing_at'] = null;
|
||||
if ($serviceEntity instanceof ServiceEntity) {
|
||||
$formDatas['billing_at'] = $this->getBillingAtByServiceEntity($serviceEntity, $formDatas['billing']);
|
||||
}
|
||||
//해당 파트정보에 고객번호,서비스번호 설정
|
||||
$formDatas['clientinfo_uid'] = $serverEntity->getClientInfoUid();
|
||||
$formDatas['serviceinfo_uid'] = $serverEntity->getServiceInfoUid();
|
||||
//해당 파트정보의 Title을 서버파트정보의 Titlte 설정
|
||||
$formDatas['title'] = $partEntity->getTitle();
|
||||
//청구방식에 따른 결제일 설정
|
||||
$formDatas['billing_at'] = null;
|
||||
if ($formDatas['billing'] === PAYMENT['BILLING']['MONTH']) {
|
||||
if (!$serviceEntity instanceof ServiceEntity) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 매월결제 상품은 서비스정보가 지정된 후 설정하실 수 있습니다.");
|
||||
}
|
||||
$formDatas['billing_at'] = $serviceEntity->getBillingAt();
|
||||
} elseif ($formDatas['billing'] === PAYMENT['BILLING']['ONETIME']) {
|
||||
if (!$serviceEntity instanceof ServiceEntity) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 매월결제 상품은 서비스정보가 지정된 후 설정하실 수 있습니다.");
|
||||
}
|
||||
$formDatas['billing_at'] = date("Y-m-d");
|
||||
}
|
||||
return array($serverEntity, $serviceEntity, $partEntity, $formDatas);
|
||||
return $formDatas;
|
||||
}
|
||||
protected function create_process(array $formDatas): CommonEntity
|
||||
{
|
||||
//서버정보 가져오기
|
||||
$serverEntity = service('equipment_serverservice')->getEntity($formDatas['serverinfo_uid']);
|
||||
if (!$serverEntity instanceof ServerEntity) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$formDatas['serverinfo_uid']}에 해당하는 서버정보을 찾을수 없습니다.");
|
||||
}
|
||||
//생성을 위한 추가 FormDatas설정
|
||||
$formDatas = $this->getFormDatasForServerPart($formDatas, $serverEntity);
|
||||
//서버파트 생성
|
||||
list($serverEntity, $serviceEntity, $partEntity, $formDatas) = $this->getFormDatasForServerPart($formDatas);
|
||||
$entity = parent::create_process($formDatas);
|
||||
if (!$entity instanceof ServerPartEntity) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능");
|
||||
@ -106,7 +116,11 @@ class ServerPartService extends EquipmentService
|
||||
//해당 파트정보를 서버파트정보에 추가
|
||||
$this->getPartService($entity->getType())->attachToServerPart($entity);
|
||||
//서비스가 정의 되어 있으면
|
||||
if ($serviceEntity instanceof ServiceEntity) {
|
||||
if ($entity->getServiceInfoUid()) {
|
||||
$serviceEntity = service('customer_serviceservice')->getEntity($entity->getServiceInfoUid());
|
||||
if (!$serviceEntity instanceof ServiceEntity) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$entity->getServiceInfoUid()}에 해당하는 서비스정보을 찾을수 없습니다.");
|
||||
}
|
||||
//Billing형식이 Month이면 서비스 금액설정 호출
|
||||
if ($entity->getBilling() == PAYMENT['BILLING']['MONTH']) {
|
||||
service('customer_serviceservice')->updateAmount($serviceEntity);
|
||||
@ -120,7 +134,13 @@ class ServerPartService extends EquipmentService
|
||||
}
|
||||
protected function modify_process($entity, array $formDatas): CommonEntity
|
||||
{
|
||||
list($serverEntity, $serviceEntity, $partEntity, $formDatas) = $this->getFormDatasForServerPart($formDatas);
|
||||
//서버정보 가져오기
|
||||
$serverEntity = service('equipment_serverservice')->getEntity($formDatas['serverinfo_uid']);
|
||||
if (!$serverEntity instanceof ServerEntity) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$formDatas['serverinfo_uid']}에 해당하는 서버정보을 찾을수 없습니다.");
|
||||
}
|
||||
//수정을 위한 추가 FormDatas설정
|
||||
$formDatas = $this->getFormDatasForServerPart($formDatas, $serverEntity);
|
||||
//서버파트 수정
|
||||
$oldEntity = clone $entity;
|
||||
$entity = parent::modify_process($entity, $formDatas);
|
||||
@ -130,7 +150,11 @@ class ServerPartService extends EquipmentService
|
||||
//해당 파트정보가 변경
|
||||
$this->getPartService($entity->getType())->modifyServerPart($oldEntity, $entity);
|
||||
//서비스가 정의 되어 있으면
|
||||
if ($serviceEntity instanceof ServiceEntity) {
|
||||
if ($entity->getServiceInfoUid()) {
|
||||
$serviceEntity = service('customer_serviceservice')->getEntity($entity->getServiceInfoUid());
|
||||
if (!$serviceEntity instanceof ServiceEntity) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$entity->getServiceInfoUid()}에 해당하는 서비스정보을 찾을수 없습니다.");
|
||||
}
|
||||
//Billing형식이 Month이면 서비스 금액설정 호출
|
||||
if ($entity->getBilling() == PAYMENT['BILLING']['MONTH']) {
|
||||
service('customer_serviceservice')->updateAmount($serviceEntity);
|
||||
|
||||
@ -127,8 +127,13 @@ class ServerService extends EquipmentService
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 ServerEntity만 가능");
|
||||
}
|
||||
//서버추가시 서버파트 자동추가용
|
||||
service('part_ipservice')->attachToServer($entity);
|
||||
service('part_switchservice')->attachToServer($entity);
|
||||
// dd($entity);
|
||||
if ($entity->getIP()) {
|
||||
service('part_ipservice')->attachToServer($entity);
|
||||
}
|
||||
if ($entity->getSwitchInfoUid()) {
|
||||
service('part_switchservice')->attachToServer($entity);
|
||||
}
|
||||
service('equipment_chassisservice')->attachToServer($entity);
|
||||
service('equipment_serverpartservice')->attachToServer($entity);
|
||||
return $entity;
|
||||
@ -218,8 +223,12 @@ class ServerService extends EquipmentService
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$uid}에 해당하는 서버정보을 찾을수 없습니다.");
|
||||
}
|
||||
//서버파트정보 해제
|
||||
service('part_ipservice')->detachFromServer($entity);
|
||||
service('part_switchservice')->detachFromServer($entity);
|
||||
if ($entity->getIP()) {
|
||||
service('part_ipservice')->detachFromServer($entity);
|
||||
}
|
||||
if ($entity->getSwitchInfoUid()) {
|
||||
service('part_switchservice')->detachFromServer($entity);
|
||||
}
|
||||
service('equipment_serverpartservice')->detachFromServer($entity);
|
||||
//서버정보 초기화
|
||||
$formDatas['serviceinfo_uid'] = null;
|
||||
|
||||
@ -56,7 +56,7 @@ class SWITCHService extends PartType3Service
|
||||
//IP정보에서 해당하는 IP가 있으면 가져와서 사용중인지 체크 후 수정
|
||||
$entity = $this->getEntity($serverEntity->getSwitchInfoUid());
|
||||
if (!$entity instanceof SWITCHEntity) {
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 {$serverEntity->getSwitchInfoUid()}에 해당하는 IP정보를 찾을수없습니다.");
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 {$serverEntity->getSwitchInfoUid()}에 해당하는 스위치정보를 찾을수없습니다.");
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user