dbmsv4 init...5

This commit is contained in:
최준흠 2026-02-26 13:07:07 +09:00
parent 9ae564ebcb
commit a79a9635f3
25 changed files with 383 additions and 457 deletions

View File

@ -12,29 +12,31 @@ class BoardEntity extends CommonEntity
protected array $nullableFields = [ protected array $nullableFields = [
'user_uid', 'user_uid',
'worker_uid', 'worker_uid',
]; 'content',
protected $attributes = [
'user_uid' => null,
'worker_uid' => null,
'category' => '',
'title' => '',
'status' => '',
'content' => ''
]; ];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);
$this->nullableFields = [
...$this->nullableFields,
'user_uid',
'worker_uid',
];
} }
public function getUserUid(): int|null public function getUserUid(): ?int
{ {
return $this->user_uid ?? null; return $this->user_uid;
} }
public function getWorkerUid(): int|null public function getWorkerUid(): ?int
{ {
return $this->worker_uid ?? null; return $this->worker_uid;
} }
public function getCaregory(): string public function getCaregory(): string
{ {
return $this->category ?? ""; return $this->category;
}
public function getContent(): ?string
{
return $this->category;
} }
} }

View File

@ -3,90 +3,118 @@
namespace App\Entities; namespace App\Entities;
use CodeIgniter\Entity\Entity; use CodeIgniter\Entity\Entity;
use DateTime;
abstract class CommonEntity extends Entity abstract class CommonEntity extends Entity
{ {
protected $datamap = []; /**
* 날짜 필드
*/
protected $dates = ['created_at', 'updated_at', 'deleted_at']; protected $dates = ['created_at', 'updated_at', 'deleted_at'];
/** /**
* 엔티티에서 "빈문자/공백 입력은 NULL로 저장"해야 하는 필드 목록. * 문자열을 NULL로 변환할 필드
* 기본은 배열이고, Entity에서 필요한 것만 override해서 채우면 . * Entity에서 override 해서 사용
*/ */
protected array $nullableFields = []; protected array $nullableFields = [];
/**
* 생성자
*/
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);
} }
final public function __get(string $key) /*
|--------------------------------------------------------------------------
| Magic Getter
|--------------------------------------------------------------------------
| Entity 내부에서도 $this->field 스타일 사용 가능
|--------------------------------------------------------------------------
*/
public function __get(string $key)
{ {
if (array_key_exists($key, $this->attributes)) {
return $this->attributes[$key];
}
return parent::__get($key); return parent::__get($key);
} }
/** /*
* 중요: Entity에 값이 들어오는 "모든 경로" (new Entity($data), fill(), $entity->field=...) |--------------------------------------------------------------------------
* 에서 공통 규칙을 적용하기 위해 __set을 정의. | Magic Setter
*/ |--------------------------------------------------------------------------
final public function __set(string $key, $value = null) */
public function __set(string $key, $value = null)
{ {
if (array_key_exists($key, $this->attributes)) { // 1⃣ 문자열 trim
if (is_string($value)) {
// 이 엔티티에서 NULL로 보정할 필드만 처리 (화이트리스트) $value = trim($value);
if (!empty($this->nullableFields) && in_array($key, $this->nullableFields, true)) {
if (is_string($value)) {
$value = trim($value);
}
$this->attributes[$key] = ($value === '' || $value === null) ? null : $value;
return;
}
// 기본: 그대로 저장
$this->attributes[$key] = $value;
return;
} }
// 2⃣ nullable 처리
if (in_array($key, $this->nullableFields, true)) {
if ($value === '' || $value === null) {
$value = null;
}
}
// 3⃣ 날짜 자동 변환
// if (in_array($key, $this->dates, true)) {
// if (is_string($value) && $value !== '') {
// $value = new DateTime($value);
// }
// }
// ✅ 반드시 부모 __set 호출
parent::__set($key, $value); parent::__set($key, $value);
} }
final public function getPK(): int|string /*
|--------------------------------------------------------------------------
| 공통 Getter들 (모두 property 스타일 사용)
|--------------------------------------------------------------------------
*/
final public function getPK(): int|string|null
{ {
$field = constant("static::PK"); $field = constant('static::PK');
return $this->attributes[$field] ?? ""; return $this->$field;
} }
final public function getTitle(): string final public function getTitle(): ?string
{ {
$field = constant("static::TITLE"); $field = constant('static::TITLE');
return $this->attributes[$field] ?? ""; return $this->$field;
}
public function getCustomTitle(): string
{
return $this->getTitle();
} }
final public function getStatus(): string final public function getStatus(): string
{ {
return $this->status ?? ""; return $this->status;
}
final public function getUpdatedAt(): string
{
return $this->updated_at ?? "";
} }
final public function getCreatedAt(): string final public function getCreatedAt(): string
{ {
return $this->created_at ?? ""; return $this->created_at;
} }
final public function getDeletedAt(): string final public function getUpdatedAt(): ?string
{ {
return $this->deleted_at ?? ""; return $this->updated_at;
} }
}
final public function getDeletedAt(): ?string
{
return $this->deleted_at;
}
/*
|--------------------------------------------------------------------------
| Override Getter들 (모두 property 스타일 사용)
|--------------------------------------------------------------------------
*/
public function getCustomTitle(): string
{
return (string) $this->getTitle();
}
}

View File

@ -9,36 +9,19 @@ class ClientEntity extends CustomerEntity
const PK = ClientModel::PK; const PK = ClientModel::PK;
const TITLE = ClientModel::TITLE; const TITLE = ClientModel::TITLE;
protected array $nullableFields = [ /**
'id', * 생성자
'passwd', */
];
// ✅ role은 반드시 string 기본값
protected $attributes = [
'id' => null,
'passwd' => null,
'site' => '',
'name' => '',
'phone' => '',
'email' => '',
'role' => '', // ✅ [] 금지
'account_balance' => 0,
'coupon_balance' => 0,
'point_balance' => 0,
'status' => '',
'history' => '',
];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);
} }
public function getUserUid(): int|null /*
{ |--------------------------------------------------------------------------
return $this->user_uid ?? null; | Override Getter들 (모두 property 스타일 사용)
} |--------------------------------------------------------------------------
*/
public function getCustomTitle(mixed $title = null): string public function getCustomTitle(mixed $title = null): string
{ {
@ -47,32 +30,32 @@ class ClientEntity extends CustomerEntity
public function getName(): string public function getName(): string
{ {
return (string) ($this->attributes['name'] ?? ''); return $this->name;
} }
public function getSite(): string public function getSite(): string
{ {
return (string) ($this->attributes['site'] ?? ''); return $this->site;
} }
public function getAccountBalance(): int public function getAccountBalance(): int
{ {
return (int) ($this->attributes['account_balance'] ?? 0); return (int) ($this->account_balance ?? 0);
} }
public function getCouponBalance(): int public function getCouponBalance(): int
{ {
return (int) ($this->attributes['coupon_balance'] ?? 0); return (int) ($this->coupon_balance ?? 0);
} }
public function getPointBalance(): int public function getPointBalance(): int
{ {
return (int) ($this->attributes['point_balance'] ?? 0); return (int) ($this->point_balance ?? 0);
} }
public function getHistory(): string|null public function getHistory(): ?string
{ {
return $this->attributes['history'] ?? null; return $this->history;
} }
/** /**

View File

@ -9,5 +9,14 @@ abstract class CustomerEntity extends CommonEntity
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);
$this->nullableFields = [
...$this->nullableFields,
'user_uid',
];
}
final public function getUserUid(): ?int
{
return $this->user_uid;
} }
} }

View File

@ -12,85 +12,75 @@ class ServiceEntity extends CustomerEntity
'serverinfo_uid', 'serverinfo_uid',
'end_at' 'end_at'
]; ];
protected $attributes = [
'serverinfo_uid' => null,
'code' => '',
'title' => '',
'site' => '',
'location' => '',
'rack' => 0,
'coupon_balance' => 0,
'line' => 0,
'billing_at' => '',
'sale' => 0,
'amount' => 0,
'start_at' => '',
'end_at' => null,
'status' => '',
'history' => ''
];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);
$this->nullableFields = [
...$this->nullableFields,
'serverinfo_uid',
'end_at'
];
$this->dates = [
...$this->dates,
'start_at',
'end_at',
];
} }
public function getUserUid(): int|null public function getClientInfoUid(): ?int
{ {
return $this->user_uid ?? null; return $this->clientinfo_uid;
} }
public function getClientInfoUid(): int|null public function getServerInfoUid(): ?int
{ {
return $this->clientinfo_uid ?? null; return $this->serverinfo_uid;
}
public function getServerInfoUid(): int|null
{
return $this->serverinfo_uid ?? null;
} }
//기본기능용 //기본기능용
public function getCode(): string public function getCode(): string
{ {
return $this->code ?? ''; return $this->code;
} }
public function getSite(): string public function getSite(): string
{ {
return $this->site ?? ''; return $this->site;
} }
public function getLocation(): string public function getLocation(): string
{ {
return $this->location ?? ''; return $this->location;
} }
public function getBillingAt(): string public function getBillingAt(): string
{ {
return $this->billing_at ?? ''; return $this->billing_at;
} }
//청구금액->기본:상면비+회선비+서버금액(price)+서버파트연결(월비용)-할인액 //청구금액->기본:상면비+회선비+서버금액(price)+서버파트연결(월비용)-할인액
//상면비 //상면비
public function getRack(): int public function getRack(): int
{ {
return $this->rack ?? 0; return (int) ($this->rack ?? 0);
} }
//회선비 //회선비
public function getLine(): int public function getLine(): int
{ {
return $this->line ?? 0; return (int) ($this->line ?? 0);
} }
public function getSale(): int public function getSale(): int
{ {
return $this->sale ?? 0; return (int) ($this->sale ?? 0);
} }
public function getAmount(): int public function getAmount(): int
{ {
return $this->amount ?? 0; return (int) ($this->amount ?? 0);
} }
public function getStartAt(): string public function getStartAt(): string
{ {
return $this->start_at ?? ''; return $this->start_at;
} }
public function getEndAt(): string|null public function getEndAt(): ?string
{ {
return $this->end_at ?? null; return $this->end_at;
} }
public function getHistory(): string public function getHistory(): ?string
{ {
return $this->history ?? ''; return $this->history;
} }
} }

View File

@ -8,35 +8,35 @@ class AccountEntity extends WalletEntity
{ {
const PK = AccountModel::PK; const PK = AccountModel::PK;
const TITLE = AccountModel::TITLE; const TITLE = AccountModel::TITLE;
protected array $nullableFields = [ /**
'alias' * 생성자
]; */
protected $attributes = [
'title' => '',
'bank' => '',
'alias' => null,
'issue_at' => '',
'amount' => 0,
'balance' => 0,
'status' => '',
'content' => ''
];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);
$this->nullableFields = [
...$this->nullableFields,
'bank',
'alias',
];
$this->dates = [
...$this->dates,
'issue_at',
];
} }
//기본기능
public function getBank(): string public function getBank(): ?string
{ {
return $this->bank ?? ''; return $this->bank;
} }
public function getAlias(): string
public function getAlias(): ?string
{ {
return $this->alias ?? ''; return $this->alias;
} }
public function getIssueAt(): string public function getIssueAt(): string
{ {
return $this->issue_at ?? ''; return $this->issue_at;
} }
} }

View File

@ -6,16 +6,12 @@ use App\Models\Customer\Wallet\CouponModel;
class CouponEntity extends WalletEntity class CouponEntity extends WalletEntity
{ {
const PK = CouponModel::PK; const PK = CouponModel::PK;
const TITLE = CouponModel::TITLE; const TITLE = CouponModel::TITLE;
protected $attributes = [
'title' => '', /**
'amount' => 0, * 생성자
'balance' => 0, */
'status' => '',
'content' => ''
];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);

View File

@ -8,13 +8,9 @@ class PointEntity extends WalletEntity
{ {
const PK = PointModel::PK; const PK = PointModel::PK;
const TITLE = PointModel::TITLE; const TITLE = PointModel::TITLE;
protected $attributes = [ /**
'title' => '', * 생성자
'amount' => 0, */
'balance' => 0,
'status' => '',
'content' => ''
];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);

View File

@ -4,32 +4,44 @@ namespace App\Entities\Customer\Wallet;
use App\Entities\Customer\CustomerEntity; use App\Entities\Customer\CustomerEntity;
abstract class WalletEntity extends CustomerEntity abstract class WalletEntity extends CustomerEntity
{ {
/**
* 생성자
*/
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);
$this->nullableFields = [
...$this->nullableFields,
'clientinfo_uid',
'content',
];
} }
final public function getUserUid(): int|null
/*
|--------------------------------------------------------------------------
| Getter (절대 attributes 직접 접근하지 않음)
|--------------------------------------------------------------------------
*/
final public function getClientInfoUid(): ?int
{ {
return $this->user_uid ?? null; return $this->clientinfo_uid;
} }
final public function getClientInfoUid(): int|null
{
return $this->clientinfo_uid ?? null;
}
//기본기능
final public function getAmount(): int final public function getAmount(): int
{ {
return $this->amount ?? 0; return (int) ($this->amount ?? 0);
} }
final public function getBalance(): int final public function getBalance(): int
{ {
return $this->balance ?? 0; return (int) ($this->balance ?? 0);
} }
final public function getContent(): string
final public function getContent(): ?string
{ {
return $this->content ?? ''; return $this->content;
} }
} }

View File

@ -8,52 +8,41 @@ class CHASSISEntity extends EquipmentEntity
{ {
const PK = CHASSISModel::PK; const PK = CHASSISModel::PK;
const TITLE = CHASSISModel::TITLE; const TITLE = CHASSISModel::TITLE;
protected array $nullableFields = [
'cpuinfo_uid',
'raminfo_uid',
'diskinfo_uid',
];
protected $attributes = [
'title' => '',
'price' => 0,
'used' => 0,
'stock' => 0,
'status' => '',
'cpuinfo_uid' => null,
'cpu_cnt' => 0,
'raminfo_uid' => null,
'ram_cnt' => 0,
'diskinfo_uid' => null,
'disk_cnt' => 0,
];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);
$this->nullableFields = [
...$this->nullableFields,
'cpuinfo_uid',
'raminfo_uid',
'diskinfo_uid',
];
} }
public function getCPUInfoUid(): int|null public function getCPUInfoUid(): ?int
{ {
return $this->cpuinfo_uid ?? null; return $this->cpuinfo_uid;
} }
public function getRAMInfoUid(): int|null public function getRAMInfoUid(): ?int
{ {
return $this->raminfo_uid ?? null; return $this->raminfo_uid;
} }
public function getDISKInfoUid(): int|null public function getDISKInfoUid(): ?int
{ {
return $this->diskinfo_uid ?? null; return $this->diskinfo_uid;
} }
//기본기능 //기본기능
public function getPrice(): int public function getPrice(): int
{ {
return $this->price ?? 0; return (int) ($this->price ?? 0);
} }
public function getStock(): int public function getStock(): int
{ {
return $this->stock ?? 0; return (int) ($this->stock ?? 0);
} }
public function getUsed(): int public function getUsed(): int
{ {
return $this->used ?? 0; return (int) ($this->used ?? 0);
} }
public function getAvailable(): int public function getAvailable(): int
{ {
@ -61,14 +50,14 @@ class CHASSISEntity extends EquipmentEntity
} }
public function getCPUCnt(): int public function getCPUCnt(): int
{ {
return $this->cpu_cnt ?? 0; return (int) ($this->cpu_cnt ?? 0);
} }
public function getRAMCnt(): int public function getRAMCnt(): int
{ {
return $this->ram_cnt ?? 0; return (int) ($this->ram_cnt ?? 0);
} }
public function getDISKCnt(): int public function getDISKCnt(): int
{ {
return $this->disk_cnt ?? 0; return (int) ($this->disk_cnt ?? 0);
} }
} }

View File

@ -7,47 +7,40 @@ use App\Models\Equipment\LineModel;
class LineEntity extends EquipmentEntity class LineEntity extends EquipmentEntity
{ {
const PK = LineModel::PK; const PK = LineModel::PK;
protected array $nullableFields = [
'start_at',
'end_at',
];
protected $attributes = [
'title' => '',
'type' => '',
'protocol' => '',
'bandwith' => '',
'start_at' => null,
'end_at' => null,
'status' => '',
'content' => '',
];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);
$this->nullableFields = [
...$this->nullableFields,
'start_at',
'end_at',
];
$this->dates = [
...$this->dates,
'start_at',
'end_at',
];
} }
const TITLE = LineModel::TITLE; const TITLE = LineModel::TITLE;
public function getType(): string public function getType(): string
{ {
return $this->type ?? ''; return $this->type;
} }
public function getProtocol(): string public function getProtocol(): string
{ {
return $this->protocol ?? ''; return $this->protocol;
} }
public function getBandwith(): string public function getBandwith(): string
{ {
return $this->bandwith ?? ''; return $this->bandwith;
} }
public function getStartAt(): string|null public function getStartAt(): ?string
{ {
return $this->start_at ?? null; return $this->start_at;
} }
public function getEndAt(): string|null public function getEndAt(): ?string
{ {
return $this->end_at ?? null; return $this->end_at;
}
public function getContent(): string
{
return $this->content ?? '';
} }
} }

View File

@ -9,61 +9,35 @@ class ServerEntity extends EquipmentEntity
const PK = ServerModel::PK; const PK = ServerModel::PK;
const TITLE = ServerModel::TITLE; const TITLE = ServerModel::TITLE;
protected array $nullableFields = [
'clientinfo_uid',
'serviceinfo_uid',
'chassisinfo_uid',
'switchinfo_uid',
'ip',
'viewer',
'os',
'format_at',
];
protected $attributes = [
'clientinfo_uid' => null,
'serviceinfo_uid' => null,
'chassisinfo_uid' => null,
'switchinfo_uid' => null,
'code' => '',
'title' => '',
'type' => '',
'ip' => null,
'viewer' => null,
'os' => null,
'price' => 0,
'manufactur_at' => '',
'format_at' => null,
'status' => '',
];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);
$this->nullableFields = [
...$this->nullableFields,
'clientinfo_uid',
'serviceinfo_uid',
'switchinfo_uid',
'ip',
'viewer',
'os',
'format_at',
];
} }
final public function getClientInfoUid(): int|null final public function getClientInfoUid(): ?int
{ {
$val = $this->clientinfo_uid ?? null; return $this->clientinfo_uid;
return ($val === '' || $val === null) ? null : (int) $val;
} }
final public function getServiceInfoUid(): int|null final public function getServiceInfoUid(): ?int
{ {
$val = $this->serviceinfo_uid ?? null; return $this->serviceinfo_uid;
return ($val === '' || $val === null) ? null : (int) $val;
} }
final public function getChassisInfoUid(): int|null final public function getChassisInfoUid(): int
{ {
$val = $this->chassisinfo_uid ?? null; return $this->chassisinfo_uid;
return ($val === '' || $val === null) ? null : (int) $val;
} }
final public function getSwitchInfoUid(): int|null final public function getSwitchInfoUid(): ?int
{ {
$val = $this->switchinfo_uid ?? null; return $this->switchinfo_uid;
return ($val === '' || $val === null) ? null : (int) $val;
}
public function setSwitchInfoUid($value)
{
$this->attributes['switchinfo_uid'] = ($value === '' || $value === null) ? null : (int) $value;
return $this;
} }
//기본기능용 //기본기능용
@ -73,38 +47,36 @@ class ServerEntity extends EquipmentEntity
} }
final public function getCode(): string final public function getCode(): string
{ {
return $this->code ?? null; return $this->code;
} }
public function getType(): ?string public function getType(): ?string
{ {
return $this->type ?? null; return $this->type;
} }
public function getIP(): ?string public function getIP(): ?string
{ {
$val = $this->ip ?? null; return $this->ip;
return ($val === '' || $val === null) ? null : $val;
} }
public function getViewer(): ?string public function getViewer(): ?string
{ {
return $this->viewer ?? null; return $this->viewer;
} }
public function getOS(): ?string public function getOS(): ?string
{ {
return $this->os ?? null; return $this->os;
} }
public function getPrice(): int public function getPrice(): int
{ {
return $this->price ?? 0; return (int) ($this->price ?? 0);
} }
public function getManufacturAt(): string public function getManufacturAt(): string
{ {
return $this->manufactur_at ?? ''; return $this->manufactur_at;
} }
public function getFormatAt(): ?string public function getFormatAt(): ?string
{ {
$val = $this->format_at ?? null; $this->format_at;
return ($val === '' || $val === null) ? null : $val;
} }
} }

View File

@ -15,57 +15,33 @@ class ServerPartEntity extends EquipmentEntity
'billing_at', 'billing_at',
'extra', 'extra',
]; ];
protected $attributes = [
'clientinfo_uid' => null,
'part_uid' => null,
'serviceinfo_uid' => null,
'title' => '',
'type' => '',
'billing' => '',
'billing_at' => null,
'cnt' => 0,
'amount' => 0,
'extra' => null,
];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);
$this->nullableFields = [
...$this->nullableFields,
'clientinfo_uid',
'part_uid',
'serviceinfo_uid',
'billing_at',
'extra',
];
} }
public function getClientInfoUid(): int|null public function getClientInfoUid(): ?int
{ {
return $this->clientinfo_uid ?? null; return $this->clientinfo_uid;
} }
public function setClientinfoUid($value) public function getServiceInfoUid(): ?int
{ {
$this->attributes['clientinfo_uid'] = ($value === '' || $value === null) ? null : (int) $value; return $this->serviceinfo_uid;
return $this;
} }
public function getServiceInfoUid(): int|null public function getServerInfoUid(): int
{ {
return $this->serviceinfo_uid ?? null; return $this->serverinfo_uid;
} }
public function setServiceinfoUid($value) public function getPartUid(): ?int
{ {
$this->attributes['serviceinfo_uid'] = ($value === '' || $value === null) ? null : (int) $value; return $this->part_uid;
return $this;
}
public function getServerInfoUid(): int|null
{
return $this->serverinfo_uid ?? null;
}
public function setServerinfoUid($value)
{
$this->attributes['serverinfo_uid'] = ($value === '' || $value === null) ? null : (int) $value;
return $this;
}
public function getPartUid(): int|null
{
return $this->part_uid ?? null;
}
public function setPartUid($value)
{
$this->attributes['part_uid'] = ($value === '' || $value === null) ? null : (int) $value;
return $this;
} }
//기본기능용 //기본기능용
public function getCustomTitle(): string public function getCustomTitle(): string
@ -78,26 +54,26 @@ class ServerPartEntity extends EquipmentEntity
} }
public function getType(): string public function getType(): string
{ {
return $this->type ?? ""; return $this->type;
} }
public function getBilling(): string public function getBilling(): string
{ {
return $this->billing ?? ""; return $this->billing;
} }
public function getBillingAt(): string|null public function getBillingAt(): ?string
{ {
return $this->billing_at ?? null; return $this->billing_at;
} }
public function getCnt(): int public function getCnt(): int
{ {
return $this->cnt ?? 0; return (int) ($this->cnt ?? 0);
} }
public function getAmount(): int public function getAmount(): int
{ {
return $this->amount ?? 0; return (int) ($this->amount ?? 0);
} }
public function getExtra(): string|null public function getExtra(): ?string
{ {
return $this->extra ?? null; return $this->extra;
} }
} }

View File

@ -11,20 +11,14 @@ class MylogEntity extends CommonEntity
protected array $nullableFields = [ protected array $nullableFields = [
'user_uid', 'user_uid',
]; ];
protected $attributes = [
'user_uid' => null,
'title' => '',
'status' => '',
'content' => ''
];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);
} }
//공통부분 //공통부분
//Common Function //Common Function
public function getUserUid(): int|null public function getUserUid(): ?int
{ {
return $this->user_uid ?? null; return $this->user_uid;
} }
} }

View File

@ -8,43 +8,44 @@ class CSEntity extends PartType2Entity
{ {
const PK = CSModel::PK; const PK = CSModel::PK;
const TITLE = CSModel::TITLE; const TITLE = CSModel::TITLE;
protected $attributes = [
'type' => '',
'ip' => '',
'accountid' => '',
'domain' => '',
'price' => 0,
'status' => '',
];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);
$this->nullableFields = [
...$this->nullableFields,
'clientinfo_uid',
'serviceinfo_uid',
'serverinfo_uid',
'accountid',
'domain',
];
} }
//기본기능 //기본기능
final public function getClientInfoUid(): int|null final public function getClientInfoUid(): ?int
{ {
return $this->clientinfo_uid; return $this->clientinfo_uid;
} }
final public function getServiceInfoUid(): int|null final public function getServiceInfoUid(): ?int
{ {
return $this->serviceinfo_uid; return $this->serviceinfo_uid;
} }
final public function getServerInfoUid(): int|null final public function getServerInfoUid(): ?int
{ {
return $this->serverinfo_uid; return $this->serverinfo_uid;
} }
public function getIP(): string public function getIP(): string
{ {
return $this->ip ?? ''; return $this->ip;
} }
//기본기능 //기본기능
public function getAccountID(): string public function getAccountID(): ?string
{ {
return $this->accountid ?? ""; return $this->accountid;
} }
public function getDomain(): string public function getDomain(): ?string
{ {
return $this->domain ?? ""; return $this->domain;
} }
//abstract 선언처리용 //abstract 선언처리용
} }

View File

@ -8,14 +8,7 @@ class DISKEntity extends PartType1Entity
{ {
const PK = DISKModel::PK; const PK = DISKModel::PK;
const TITLE = DISKModel::TITLE; const TITLE = DISKModel::TITLE;
protected $attributes = [
'title' => '',
'used' => 0,
'price' => 0,
'stock' => 0,
'format' => 0,
'status' => '',
];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);

View File

@ -8,46 +8,46 @@ class IPEntity extends PartType3Entity
{ {
const PK = IPModel::PK; const PK = IPModel::PK;
const TITLE = IPModel::TITLE; const TITLE = IPModel::TITLE;
protected $attributes = [
'title' => '',
'used' => 0,
'price' => 0,
'stock' => 0,
'ip' => '',
'status' => '',
'content' => '',
];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);
$this->nullableFields = [
...$this->nullableFields,
'old_clientinfo_uid',
'clientinfo_uid',
'serviceinfo_uid',
'serverinfo_uid',
'content',
];
} }
public function getLineInfoUID(): int|null public function getLineInfoUID(): int
{ {
return $this->lineinfo_uid ?? null; return $this->lineinfo_uid;
} }
public function getOldClientInfoUID(): int|null public function getOldClientInfoUID(): ?int
{ {
return $this->old_clientinfo_uid ?? null; return $this->old_clientinfo_uid;
} }
final public function getClientInfoUid(): int|null final public function getClientInfoUid(): ?int
{ {
return $this->clientinfo_uid; return $this->clientinfo_uid;
} }
final public function getServiceInfoUid(): int|null final public function getServiceInfoUid(): ?int
{ {
return $this->serviceinfo_uid; return $this->serviceinfo_uid;
} }
final public function getServerInfoUid(): int|null final public function getServerInfoUid(): ?int
{ {
return $this->serverinfo_uid; return $this->serverinfo_uid;
} }
//기본기능 //기본기능
public function getIP(): string public function getIP(): string
{ {
return $this->ip ?? ""; return $this->ip;
} }
public function getContent(): string public function getContent(): ?string
{ {
return $this->content ?? ""; return $this->content;
} }
} }

View File

@ -19,6 +19,6 @@ abstract class PartEntity extends CommonEntity
} }
final public function getPrice(): int final public function getPrice(): int
{ {
return $this->price ?? 0; return (int) ($this->price ?? 0);
} }
} }

View File

@ -2,17 +2,8 @@
namespace App\Entities\Part; namespace App\Entities\Part;
use App\Models\Part\CPUModel;
class PartType1Entity extends PartEntity class PartType1Entity extends PartEntity
{ {
protected $attributes = [
'title' => '',
'used' => 0,
'price' => 0,
'stock' => 0,
'status' => '',
];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);
@ -20,11 +11,11 @@ class PartType1Entity extends PartEntity
//기본기능 //기본기능
final public function getStock(): int final public function getStock(): int
{ {
return $this->stock ?? 0; return (int) ($this->stock ?? 0);
} }
final public function getUsed(): int final public function getUsed(): int
{ {
return $this->used ?? 0; return (int) ($this->used ?? 0);
} }
final public function getAvailable(): int final public function getAvailable(): int
{ {

View File

@ -8,13 +8,7 @@ class RAMEntity extends PartType1Entity
{ {
const PK = RAMModel::PK; const PK = RAMModel::PK;
const TITLE = RAMModel::TITLE; const TITLE = RAMModel::TITLE;
protected $attributes = [
'title' => '',
'used' => 0,
'price' => 0,
'stock' => 0,
'status' => '',
];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);

View File

@ -8,4 +8,10 @@ class SOFTWAREEntity extends PartType1Entity
{ {
const PK = SOFTWAREModel::PK; const PK = SOFTWAREModel::PK;
const TITLE = SOFTWAREModel::TITLE; const TITLE = SOFTWAREModel::TITLE;
public function __construct(array|null $data = null)
{
parent::__construct($data);
}
//기본기능
} }

View File

@ -8,29 +8,31 @@ class SWITCHEntity extends PartType3Entity
{ {
const PK = SWITCHModel::PK; const PK = SWITCHModel::PK;
const TITLE = SWITCHModel::TITLE; const TITLE = SWITCHModel::TITLE;
protected $attributes = [
'code' => 0,
'price' => 0,
'status' => '',
];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);
$this->nullableFields = [
...$this->nullableFields,
'clientinfo_uid',
'serviceinfo_uid',
'serverinfo_uid',
];
} }
final public function getClientInfoUid(): int|null final public function getClientInfoUid(): ?int
{ {
return $this->clientinfo_uid ?? null; return $this->clientinfo_uid;
} }
final public function getServiceInfoUid(): int|null final public function getServiceInfoUid(): ?int
{ {
return $this->serviceinfo_uid ?? null; return $this->serviceinfo_uid;
} }
final public function getServerInfoUid(): int|null final public function getServerInfoUid(): ?int
{ {
return $this->serverinfo_uid ?? null; return $this->serverinfo_uid;
} }
public function getCode(): string public function getCode(): string
{ {
return $this->code ?? ""; return $this->code;
} }
} }

View File

@ -28,22 +28,30 @@ class PaymentEntity extends CommonEntity
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);
$this->nullableFields = [
...$this->nullableFields,
'clientinfo_uid',
'serviceinfo_uid',
'serverpartinfo_uid',
'pay',
'content',
];
} }
public function getUserUid(): int|null public function getUserUid(): ?int
{ {
return $this->user_uid ?? null; return $this->user_uid;
} }
public function getClientInfoUid(): int|null public function getClientInfoUid(): ?int
{ {
return $this->clientinfo_uid ?? null; return $this->clientinfo_uid;
} }
public function getServiceInfoUid(): int|null public function getServiceInfoUid(): ?int
{ {
return $this->serviceinfo_uid ?? null; return $this->serviceinfo_uid;
} }
public function getServerPartInfoUid(): int|null public function getServerPartInfoUid(): ?int
{ {
return $this->serverpartinfo_uid ?? null; return $this->serverpartinfo_uid;
} }
//기본기능 //기본기능
public function getCustomTitle(): string public function getCustomTitle(): string
@ -52,27 +60,27 @@ class PaymentEntity extends CommonEntity
} }
public function getBilling(): string public function getBilling(): string
{ {
return $this->billing ?? ""; return $this->billing;
} }
public function getAmount(): int public function getAmount(): int
{ {
return $this->amount ?? 0; return (int) ($this->amount ?? 0);
} }
public function getBillingAt(): string public function getBillingAt(): string
{ {
return $this->billing_at ?? ""; return $this->billing_at;
} }
public function getBillingMonth(): int public function getBillingMonth(): int
{ {
return $this->billing_month ?? 0; return (int) ($this->billing_month ?? 0);
} }
public function getPay(): string|null public function getPay(): ?string
{ {
return $this->pay ?? null; return $this->pay;
} }
public function getContent(): string public function getContent(): ?string
{ {
return $this->content ?? ""; return $this->content;
} }
public function getCountDueAt(): string public function getCountDueAt(): string
{ {

View File

@ -10,37 +10,33 @@ class UserEntity extends CommonEntity
const PK = Model::PK; const PK = Model::PK;
const TITLE = Model::TITLE; const TITLE = Model::TITLE;
protected array $nullableFields = [
'mobile',
// uid 같은 숫자 PK가 nullable이면 여기에 추가
];
// ✅ role은 반드시 "문자열" 기본값 (DB 저장형)
protected $attributes = [
'id' => '',
'passwd' => '',
'name' => '',
'email' => '',
'mobile' => null,
'role' => '', // ✅ array 금지
'status' => '',
];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);
$this->nullableFields = [
...$this->nullableFields,
'mobile',
];
} }
public function getID(): string public function getID(): string
{ {
return (string) ($this->attributes['id'] ?? ''); return $this->id;
} }
public function getPassword(): string public function getPassword(): string
{ {
return (string) ($this->attributes['passwd'] ?? ''); return $this->passwd;
} }
public function getEmail(): string
{
return $this->email;
}
public function getMobile(): ?string
{
return $this->mobile;
}
/** /**
* role을 "배열" 반환 (DB에는 CSV/JSON/배열 무엇이든 복구) * role을 "배열" 반환 (DB에는 CSV/JSON/배열 무엇이든 복구)
*/ */

View File

@ -9,11 +9,6 @@ class UserSNSEntity extends CommonEntity
{ {
const PK = Model::PK; const PK = Model::PK;
const TITLE = Model::TITLE; const TITLE = Model::TITLE;
protected $attributes = [
'id' => '',
'site' => '',
'email' => "",
];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);