dbmsv4 init...3

This commit is contained in:
최준흠 2025-12-22 14:55:38 +09:00
parent 0618101647
commit b0b4acc531
5 changed files with 24 additions and 81 deletions

View File

@ -14,7 +14,26 @@ $routes->addPlaceholder('uuid', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}
//2. Config/Filters.php -> $aliases = ['authFilter' => AuthFilter::class]
$routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes) {
$routes->cli('invoice', 'Invoice::execute');
$routes->cli('migration', 'DBMigration::execute');
$routes->group('migration', ['namespace' => 'App\Controllers\CLI\DBMigration'], function ($routes) {
$routes->group('primeidc', ['namespace' => 'App\Controllers\CLI\DBMigration'], function ($routes) {
$routes->cli('client', 'PrimeidcSource::client');
$routes->cli('line', 'PrimeidcSource::line');
$routes->cli('servercode', 'PrimeidcSource::servercode');
$routes->cli('switchcode', 'PrimeidcSource::switchcode');
});
$routes->group('itsolution', ['namespace' => 'App\Controllers\CLI\DBMigration'], function ($routes) {
$routes->cli('client', 'ItsolutionSource::client');
$routes->cli('line', 'ItsolutionSource::line');
$routes->cli('servercode', 'ItsolutionSource::servercode');
$routes->cli('switchcode', 'ItsolutionSource::switchcode');
});
$routes->group('gdidc', ['namespace' => 'App\Controllers\CLI\DBMigration'], function ($routes) {
$routes->cli('client', 'GdidcSource::client');
$routes->cli('line', 'GdidcSource::line');
$routes->cli('servercode', 'GdidcSource::servercode');
$routes->cli('switchcode', 'GdidcSource::switchcode');
});
});
});
$routes->group('', ['namespace' => 'App\Controllers'], function ($routes) {
$routes->get('/', 'Home::index');

View File

@ -68,18 +68,7 @@ abstract class BaseSource extends DBMigration
*/
private function executeQuery(string $sql, array $params = []): array
{
return $this->getSourceDB()
->query($sql, $params)
->getResultArray();
}
private function executeFile(string $filename, string $deilmeter = ','): array
{
$datas = [];
$lines = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) {
$datas[] = explode($deilmeter, $line);
}
return $datas;
return $this->getSourceDB()->query($sql, $params)->getResultArray();
}
protected function getClient(): array
@ -101,10 +90,8 @@ abstract class BaseSource extends DBMigration
{
return $this->executeQuery(self::SQL_GET_SWITCH_CODE, ['%일회성%']);
}
protected function getPartCode(): array
{
return $this->executeFile('/home/donfig/dbmsv2/app/Database/dbmsv2_part.txt');
}
//호출되는 함수
final public function client(): void
{
$this->execute(
@ -140,12 +127,4 @@ abstract class BaseSource extends DBMigration
__FUNCTION__
);
}
final public function partcode(): void
{
$this->execute(
new PartCodeProcess($this->getTargetDB()),
$this->getPartCode(),
__FUNCTION__
);
}
}

View File

@ -23,8 +23,6 @@ abstract class DBMigration extends BaseController
abstract protected function getLine(): array;
abstract protected function getServerCode(): array;
abstract protected function getSWITCHCode(): array;
abstract protected function getPartCode(): array;
final protected function getTargetDB(): BaseConnection
{
if ($this->_targetDB === null) {

View File

@ -2,7 +2,6 @@
namespace App\Libraries\DBMigration\Process;
use App\Entities\UserEntity;
use CodeIgniter\Database\BaseConnection;
class ClientProcess implements MigrationProcessInterface
@ -31,7 +30,7 @@ class ClientProcess implements MigrationProcessInterface
$temps['account_balance'] = intval($row['Client_Money']);
$temps['coupon_balance'] = 0;
$temps['point_balance'] = 0;
$temps['status'] = UserEntity::DEFAULT_STATUS; // Default status
$temps['status'] = STATUS['AVAILABLE']; // Default status
$temps['updated_at'] = empty($row['Client_Renew_date']) ? NULL : $row['Client_Renew_date'];
if (!empty($row['Client_Receive_date'])) {
$temps['created_at'] = $row['Client_Receive_date'];

View File

@ -1,52 +0,0 @@
<?php
namespace App\Libraries\DBMigration\Process;
use CodeIgniter\Database\BaseConnection;
class PartCodeProcess implements MigrationProcessInterface
{
private $db;
public function __construct(BaseConnection $db)
{
$this->db = $db;
}
public function process(array $row, int $cnt): void
{
try {
if (count($row) < 2) {
throw new \Exception("{$cnt} {$row[0]}:{$row[1]} -> SKIP PARTCODE\n");
}
$temps = [];
$temps['title'] = trim($row[1]);
$temps['price'] = trim($row[2]);
$temps['stock'] = 100;
$temps['status'] = "available";
switch (trim($row[0])) {
case 'CPU':
$table = 'cpuinfo';
break;
case 'RAM':
$table = 'raminfo';
break;
case 'DISK':
$table = 'diskinfo';
break;
case 'OS':
$table = 'osinfo';
break;
case 'SOFTWARE':
$table = 'softwareinfo';
break;
}
$result = $this->db->table($table)->insert($temps);
if (!$result) {
throw new \Exception($this->db->error()['message']);
}
echo "{$cnt} -> {$temps['title']} 완료.\n";
} catch (\Exception $e) {
echo $e->getMessage();
}
}
}