dbmsv2 init...1
This commit is contained in:
parent
8ca711f32b
commit
b50267cdf8
@ -4,8 +4,6 @@ namespace App\Controllers\Admin\Customer;
|
||||
|
||||
use App\Entities\Customer\ClientEntity;
|
||||
use App\Services\Customer\ClientService;
|
||||
use App\Services\Customer\ServiceService;
|
||||
use App\Services\Equipment\ServerService;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
@ -37,17 +35,7 @@ class ClientController extends CustomerController
|
||||
//생성 전처리, 관리자 UID는 현재 인증된 사용자로 설정
|
||||
$formDatas['user_uid'] = $this->getService()->getMyAuth()->getUIDByAuthInfo();
|
||||
//생성처리
|
||||
$entity = parent::create_process($formDatas);
|
||||
// 생성 후처리, Client 코드값 재정의
|
||||
$format = env("Client.Prefix.{$formDatas['site']}.code.format", false);
|
||||
if (!$format) {
|
||||
throw new \Exception(__METHOD__ . "에서 code의 code의 format[Client.Prefix.{$formDatas['site']}.code.format] 정의되지 않았습니다.");
|
||||
}
|
||||
$this->getService()->modify(
|
||||
$entity,
|
||||
['code' => sprintf($format, (int) $entity->getPK() + 1000)]
|
||||
);
|
||||
return $entity;
|
||||
return parent::create_process($formDatas);
|
||||
}
|
||||
//수정관련
|
||||
protected function modify_process(mixed $entity, array $formDatas): ClientEntity
|
||||
|
||||
@ -49,34 +49,4 @@ class ServerController extends EquipmentController
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
//생성
|
||||
protected function create_form_process(): void
|
||||
{
|
||||
//Form 기본값정의
|
||||
$format = env("Server.Prefix.code.format", false);
|
||||
if (!$format) {
|
||||
throw new \Exception(__METHOD__ . "에서 code의 format[Server.Prefix.code.format]이 정의되지 않았습니다.");
|
||||
}
|
||||
$formDatas = $this->getService()->getFormDatas();
|
||||
$formDatas['code'] = $this->getService()->getLastestCode(
|
||||
$format,
|
||||
(int)env("Server.Default.code", 0)
|
||||
);
|
||||
$this->getService()->setFormDatas($formDatas);
|
||||
parent::create_form_process();
|
||||
}
|
||||
//생성
|
||||
protected function create_process(array $formDatas): ServerEntity
|
||||
{
|
||||
//코드 패턴체크
|
||||
$this->getService()->codeCheck($formDatas);
|
||||
return parent::create_process($formDatas);
|
||||
}
|
||||
//수정
|
||||
protected function modify_process(mixed $entity, array $formDatas): ServerEntity
|
||||
{
|
||||
//코드 패턴체크
|
||||
$this->getService()->codeCheck($formDatas);
|
||||
return parent::modify_process($entity, $formDatas);
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,19 +29,4 @@ class SwitchController extends EquipmentController
|
||||
return $this->_service;
|
||||
}
|
||||
//Index,FieldForm관
|
||||
protected function create_process(array $formDatas): SwitchEntity
|
||||
{
|
||||
//코드 패턴체크
|
||||
$pattern = env("Switch.Prefix.code.pattern", false);
|
||||
if (!$pattern) {
|
||||
throw new \Exception(__METHOD__ . "에서 code의 prefix[Switch.Prefix.code.pattern]가 정의되지 않았습니다.");
|
||||
}
|
||||
if (!array_key_exists('code', $formDatas)) {
|
||||
throw new \Exception("Switch코드가 정의되지 않았습니다");
|
||||
}
|
||||
if (!preg_match($pattern, $formDatas['code'])) {
|
||||
throw new \Exception("Switch코드[{$formDatas['code']}의 형식이 맞지않습니다");
|
||||
}
|
||||
return parent::create_process($formDatas);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
"settings": {
|
||||
"width": 3000,
|
||||
"height": 3000,
|
||||
"scrollTop": -1121.7873,
|
||||
"scrollLeft": -1298,
|
||||
"scrollTop": -1642.7873,
|
||||
"scrollLeft": -144.3986,
|
||||
"zoomLevel": 0.79,
|
||||
"show": 511,
|
||||
"database": 4,
|
||||
"databaseName": "",
|
||||
"canvasType": "@dineug/erd-editor/builtin-schema-sql",
|
||||
"canvasType": "ERD",
|
||||
"language": 1,
|
||||
"tableNameCase": 4,
|
||||
"columnNameCase": 2,
|
||||
@ -340,7 +340,6 @@
|
||||
"comment": "PART정보",
|
||||
"columnIds": [
|
||||
"2HB01q46-mugMjuOz85YG",
|
||||
"InO1oDu66d2I2e84cDrpF",
|
||||
"OGYYobEerCY_Fsb8dqU0D",
|
||||
"1q8jG5dQKdD35_XYimkSk",
|
||||
"HYB03rpc8hol5HFnZGtAi",
|
||||
@ -381,7 +380,7 @@
|
||||
"color": ""
|
||||
},
|
||||
"meta": {
|
||||
"updateAt": 1758087644044,
|
||||
"updateAt": 1758615408174,
|
||||
"createAt": 1745819764138
|
||||
}
|
||||
},
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -16,18 +16,25 @@ return [
|
||||
'deleted_at' => "삭제일",
|
||||
"serverpartinfo" => "부품정보",
|
||||
],
|
||||
"TYPE" => [
|
||||
'HP' => "HP",
|
||||
"INTEL" => "INTEL",
|
||||
"AMD" => "AMD",
|
||||
],
|
||||
"TITLE" => [
|
||||
'HP DL360 Gen6' => "HP DL360 Gen6",
|
||||
"HP DL360 Gen6" => "HP DL360 Gen6",
|
||||
"HP DL360 Gen7" => "HP DL360 Gen7",
|
||||
"HP DL360 Gen8" => "HP DL360 Gen8",
|
||||
"HP DL360 Gen9" => "HP DL360 Gen9",
|
||||
"HP DL360 Gen10" => "HP DL360 Gen10",
|
||||
"Hitach HA3000" => "Hitach HA3000",
|
||||
],
|
||||
"TYPE" => [
|
||||
'hp' => "HP",
|
||||
"del" => "DELL",
|
||||
"etc" => "조립",
|
||||
"INTEL I3" => "INTEL I3",
|
||||
"INTEL I5" => "INTEL I5",
|
||||
"INTEL I7" => "INTEL I7",
|
||||
"INTEL I9" => "INTEL I9",
|
||||
"AMD Z2" => "AMD Ryzen Z2",
|
||||
"AMD AI-5" => "AMD AI-5",
|
||||
"AMD Threadripper" => "AMD Threadripper",
|
||||
],
|
||||
"STATUS" => [
|
||||
STATUS['AVAILABLE'] => "사용가능",
|
||||
|
||||
@ -13,19 +13,11 @@ class ClientProcess implements MigrationProcessInterface
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
private function getClientCode(string $site, string $client_code): string
|
||||
{
|
||||
$format = env("Client.Prefix.{$site}.code.format", false);
|
||||
if (!$format) {
|
||||
throw new \Exception(__METHOD__ . "에서 code의 prefix[Client.Prefix.{$site}.code.format]가 정의되지 않았습니다.");
|
||||
}
|
||||
return sprintf($format, (int)substr($client_code, 1));
|
||||
}
|
||||
public function process(array $row, int $cnt): void
|
||||
{
|
||||
$temps = [];
|
||||
$temps['site'] = 'prime';
|
||||
$temps['code'] = $this->getClientCode($temps['site'], $row['Client_Code']);
|
||||
$temps['code'] = $temps['site'] . "_c" . uniqid();
|
||||
$temps['user_uid'] = 1;
|
||||
$temps['role'] = $row['Client_Reseller'] == 30 ? "reseller" : "user";
|
||||
$temps['name'] = $row['Client_Name'];
|
||||
|
||||
@ -14,14 +14,6 @@ class SwitchCodeProcess implements MigrationProcessInterface
|
||||
}
|
||||
public function process(array $row, int $cnt): void
|
||||
{
|
||||
$pattern = env("Switch.Prefix.code.pattern", false);
|
||||
if (!$pattern) {
|
||||
throw new \Exception(__METHOD__ . "에서 code의 prefix[Switch.Prefix.code.pattern]가 정의되지 않았습니다.");
|
||||
}
|
||||
if (!preg_match($pattern, $row['service_sw'])) {
|
||||
echo "{$cnt} {$row['service_sw']}-> SKIP SWITCHCODE\n";
|
||||
return;
|
||||
}
|
||||
$temps = [];
|
||||
$temps['code'] = trim($row['service_sw']);
|
||||
$temps['status'] = SwitchEntity::DEFAULT_STATUS; // Assuming SwitchEntity has a STATUS_DEFAULT constant
|
||||
|
||||
@ -73,6 +73,12 @@ abstract class CommonModel extends Model
|
||||
$data[8] = chr(ord($data[8]) & 0x3f | 0x80); // variant 10
|
||||
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
|
||||
}
|
||||
// final public function getLastestCode(string $format, int $default): string
|
||||
// {
|
||||
// $entity = $this->selectMax($this->primaryKey)->first();
|
||||
// $pk = (int) ($entity->getPK() ?? $default); // 정수로 강제 변환
|
||||
// return sprintf($format, date('ymd'), $pk + 1);
|
||||
// }
|
||||
public function getFormRule(string $action, string $field): string
|
||||
{
|
||||
if (is_array($field)) {
|
||||
|
||||
@ -67,4 +67,10 @@ class ClientModel extends CustomerModel
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
//입력전 코드처리
|
||||
public function create(array $formDatas): ClientEntity
|
||||
{
|
||||
$formDatas['code'] = $formDatas['site'] . "_c" . uniqid();
|
||||
return parent::create($formDatas);
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ class ServiceModel extends CustomerModel
|
||||
//입력전 코드처리
|
||||
public function create(array $formDatas): ServiceEntity
|
||||
{
|
||||
$formDatas['code'] = "s" . time();
|
||||
$formDatas['code'] = $formDatas['site'] . "_s" . uniqid();
|
||||
return parent::create($formDatas);
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,6 +39,7 @@ class ServerModel extends EquipmentModel
|
||||
case "serviceinfo_uid":
|
||||
$rule = "permit_empty|numeric";
|
||||
break;
|
||||
case "code":
|
||||
case "title":
|
||||
$rule = "required|trim|string";
|
||||
break;
|
||||
@ -79,11 +80,10 @@ class ServerModel extends EquipmentModel
|
||||
return $value;
|
||||
}
|
||||
//기본기능
|
||||
//create용 장비코드 마지막번호 가져오기
|
||||
final public function getLastestCode(string $format, int $default): string
|
||||
//입력전 임시코드처리
|
||||
public function create(array $formDatas): ServerEntity
|
||||
{
|
||||
$entity = $this->selectMax($this->primaryKey)->first();
|
||||
$pk = (int) ($entity->getPK() ?? $default); // 정수로 강제 변환
|
||||
return sprintf($format, date('ymd'), $pk + 1);
|
||||
$formDatas['code'] = "m" . uniqid();
|
||||
return parent::create($formDatas);
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,10 +76,8 @@ class ClientService extends CustomerService
|
||||
}
|
||||
return $this->_paymentService;
|
||||
}
|
||||
//기본 기능부분
|
||||
|
||||
//압금(쿠폰:추가)처리
|
||||
public function deposit(ClientEntity $entity, string $field, int $amount): ClientEntity
|
||||
final public function deposit(ClientEntity $entity, string $field, int $amount): ClientEntity
|
||||
{
|
||||
switch ($field) {
|
||||
case 'account_balance':
|
||||
@ -108,7 +106,7 @@ class ClientService extends CustomerService
|
||||
return $this->getClientService()->modify($entity, $formDatas);
|
||||
}
|
||||
//출금(쿠폰:사용)처리
|
||||
public function withdrawal(ClientEntity $entity, string $field, int $amount): ClientEntity
|
||||
final public function withdrawal(ClientEntity $entity, string $field, int $amount): ClientEntity
|
||||
{
|
||||
switch ($field) {
|
||||
case 'account_balance':
|
||||
@ -136,7 +134,8 @@ class ClientService extends CustomerService
|
||||
$formDatas = [$field => $amount];
|
||||
return $this->getClientService()->modify($entity, $formDatas);
|
||||
}
|
||||
|
||||
//기본 기능부분
|
||||
//생성
|
||||
public function create(array $formDatas): ClientEntity
|
||||
{
|
||||
$formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $formDatas['role']);
|
||||
|
||||
@ -137,31 +137,7 @@ class ServiceService extends CustomerService
|
||||
}
|
||||
return $this->_serverPartService;
|
||||
}
|
||||
//기본 기능부분
|
||||
public function getFormOption(string $field, array $options = []): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'serverinfo_uid':
|
||||
$options = $this->getServerService()->getEntities();
|
||||
break;
|
||||
case 'CPU':
|
||||
case 'RAM':
|
||||
case 'DISK':
|
||||
case 'OS':
|
||||
case 'DB':
|
||||
case 'SOFTWARE':
|
||||
case 'SWITCH':
|
||||
case 'IP':
|
||||
case 'CS':
|
||||
$options = $this->getServerService()->getFormOption($field, $options);
|
||||
break;
|
||||
default:
|
||||
$options = parent::getFormOption($field, $options);
|
||||
break;
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
//FieldForm관련용
|
||||
//create용 서비스코드 마지막번호 가져오기
|
||||
//interval을 기준으로 최근 신규 서비스정보 가져오기
|
||||
final public function getEntitiesByNewService(int $interval, string $status = ServiceEntity::DEFAULT_STATUS): array
|
||||
{
|
||||
@ -238,6 +214,31 @@ class ServiceService extends CustomerService
|
||||
return $total_amount;
|
||||
}
|
||||
//기본기능
|
||||
//기본 기능부분
|
||||
//FieldForm관련용
|
||||
public function getFormOption(string $field, array $options = []): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'serverinfo_uid':
|
||||
$options = $this->getServerService()->getEntities();
|
||||
break;
|
||||
case 'CPU':
|
||||
case 'RAM':
|
||||
case 'DISK':
|
||||
case 'OS':
|
||||
case 'DB':
|
||||
case 'SOFTWARE':
|
||||
case 'SWITCH':
|
||||
case 'IP':
|
||||
case 'CS':
|
||||
$options = $this->getServerService()->getFormOption($field, $options);
|
||||
break;
|
||||
default:
|
||||
$options = parent::getFormOption($field, $options);
|
||||
break;
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
//Action 기능
|
||||
private function action_process(ServiceEntity $entity, string $action): ServiceEntity
|
||||
{
|
||||
|
||||
@ -50,13 +50,7 @@ class PartService extends EquipmentService
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(mixed $field = null, mixed $value = null): void
|
||||
{
|
||||
$this->getModel()->orderBy('code ASC');
|
||||
$this->getModel()->orderBy('type ASC,uid ASC');
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
|
||||
public function create(array $formDatas): PartEntity
|
||||
{
|
||||
$entity = parent::create($formDatas);
|
||||
return $this->modify($entity, ['code' => $entity->getType() . $entity->getPK()]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@ class ServerService extends EquipmentService
|
||||
public function getFormFields(): array
|
||||
{
|
||||
return [
|
||||
"code",
|
||||
"type",
|
||||
"title",
|
||||
"price",
|
||||
@ -87,26 +86,6 @@ class ServerService extends EquipmentService
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
//create용 장비코드 마지막번호 가져오기
|
||||
final public function getLastestCode(string $format, int $default): string
|
||||
{
|
||||
return $this->getModel()->getLastestCode($format, $default);
|
||||
}
|
||||
final public function codeCheck(array $formDatas)
|
||||
{
|
||||
//코드 패턴체크
|
||||
$pattern = env("Server.Prefix.code.pattern", false);
|
||||
if (!$pattern) {
|
||||
throw new \Exception(__METHOD__ . "에서 code의 prefix[Server.Prefix.code.pattern]가 정의되지 않았습니다.");
|
||||
}
|
||||
if (!array_key_exists('code', $formDatas)) {
|
||||
throw new \Exception("Server코드가 정의되지 않았습니다");
|
||||
}
|
||||
if (!preg_match($pattern, $formDatas['code'])) {
|
||||
throw new \Exception("Server코드[{$formDatas['code']}의 형식이 맞지않습니다");
|
||||
}
|
||||
}
|
||||
//기본 기능부분
|
||||
//FieldForm관련용
|
||||
public function getFormOption(string $field, $options = []): array
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user