dbms_init...1
This commit is contained in:
parent
e72fda1d2e
commit
2f99e33763
@ -160,33 +160,7 @@ 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,
|
||||
'foreignKeys' => true,
|
||||
'busyTimeout' => 1000,
|
||||
'dateFormat' => [
|
||||
'date' => 'Y-m-d',
|
||||
'datetime' => 'Y-m-d H:i:s',
|
||||
'time' => 'H:i:s',
|
||||
],
|
||||
];
|
||||
|
||||
public array $primeidc = [];
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@ -197,5 +171,27 @@ class Database extends Config
|
||||
if (ENVIRONMENT === 'testing') {
|
||||
$this->defaultGroup = 'tests';
|
||||
}
|
||||
|
||||
$this->primeidc = [
|
||||
'DSN' => '',
|
||||
'hostname' => env('database.primeidc.hostname', 'localhost'),
|
||||
'username' => env('database.primeidc.username', 'root'),
|
||||
'password' => env('database.primeidc.password', ''),
|
||||
'database' => env('database.primeidc.database', 'primeidc'),
|
||||
'DBDriver' => 'MySQLi',
|
||||
'DBPrefix' => '',
|
||||
'pConnect' => false,
|
||||
'DBDebug' => (ENVIRONMENT !== 'production'),
|
||||
'cacheOn' => false,
|
||||
'cacheDir' => '',
|
||||
'charset' => 'utf8mb4',
|
||||
'DBCollat' => 'utf8mb4_general_ci',
|
||||
'swapPre' => '',
|
||||
'encrypt' => false,
|
||||
'compress' => false,
|
||||
'strictOn' => false,
|
||||
'failover' => [],
|
||||
'port' => 3306,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,6 +13,9 @@ $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('billing', 'Payment::billing');
|
||||
$routes->group('primeidc', ['namespace' => 'App\Controllers\CLI\DBMigration'], function ($routes) {
|
||||
$routes->cli('client', 'PrimeIDC::client');
|
||||
});
|
||||
});
|
||||
$routes->group('', ['namespace' => 'App\Controllers'], function ($routes) {
|
||||
$routes->get('/', 'Home::index');
|
||||
|
||||
71
app/Controllers/CLI/DBMigration/DBMigration.php
Normal file
71
app/Controllers/CLI/DBMigration/DBMigration.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\CLI\DBMigration;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use CodeIgniter\Database\BaseConnection;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
abstract class DBMigration extends BaseController
|
||||
{
|
||||
private $_targetDB = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
abstract protected function getSourceDB(): BaseConnection;
|
||||
abstract protected function getClient(): array;
|
||||
final protected function getTargetDB(): BaseConnection
|
||||
{
|
||||
if ($this->_targetDB === null) {
|
||||
$this->_targetDB = \Config\Database::connect('default');
|
||||
}
|
||||
return $this->_targetDB;
|
||||
}
|
||||
|
||||
|
||||
private function convertClient(array $row): array
|
||||
{
|
||||
$temps = [];
|
||||
$temps['code'] = $row['Client_Code'];
|
||||
$temps['role'] = $row['Client_Reseller'] == 30 ? "reseller" : "user";
|
||||
$temps['name'] = $row['Client_Name'];
|
||||
$temps['phone'] = empty($row['Client_Phone1']) ? "" : $row['Client_Phone1'];
|
||||
if (empty($temps['phone'])) {
|
||||
$temps['phone'] = empty($row['Client_Phone2']) ? "" : $row['Client_Phone2'];
|
||||
}
|
||||
$temps['email'] = empty($row['Client_EMail1']) ? "" : $row['Client_EMail1'];
|
||||
if (empty($temps['email'])) {
|
||||
$temps['email'] = empty($row['Client_EMail2']) ? "" : $row['Client_EMail2'];
|
||||
}
|
||||
$temps['account_balance'] = intval($row['Client_Money']);
|
||||
$temps['coupon_balance'] = 0;
|
||||
$temps['point_balance'] = 0;
|
||||
$temps['status'] = 'default';
|
||||
return $temps;
|
||||
}
|
||||
private function setClient(mixed $rows): void
|
||||
{
|
||||
foreach ($rows as $row) {
|
||||
$datas = $this->convertClient($row);
|
||||
$this->getTargetDB()->table('clientinfo')->insert($datas);
|
||||
}
|
||||
}
|
||||
|
||||
final public function client(): void
|
||||
{
|
||||
//Transaction Start
|
||||
$this->getTargetDB()->transStart();
|
||||
try {
|
||||
$this->setClient($this->getClient());
|
||||
echo " 작업을 완료하였습니다.";
|
||||
$this->getTargetDB()->transCommit();
|
||||
} catch (\Exception $e) {
|
||||
//Transaction Rollback
|
||||
$this->getTargetDB()->transRollback();
|
||||
echo " 작업을 실패하였습니다.\n--------------\n" . $e->getMessage() . "\n--------------\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
30
app/Controllers/CLI/DBMigration/PrimeIDC.php
Normal file
30
app/Controllers/CLI/DBMigration/PrimeIDC.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\CLI\DBMigration;
|
||||
|
||||
use CodeIgniter\Database\BaseConnection;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class PrimeIDC extends DBMigration
|
||||
{
|
||||
private $_sourceDB = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
final protected function getSourceDB(): BaseConnection
|
||||
{
|
||||
if ($this->_sourceDB === null) {
|
||||
$this->_sourceDB = \Config\Database::connect('primeidc');
|
||||
}
|
||||
return $this->_sourceDB;
|
||||
}
|
||||
protected function getClient(): array
|
||||
{
|
||||
$rows = $this->getSourceDB()->query('SELECT * FROM clientdb')->getResultArray();
|
||||
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
@ -12,14 +12,12 @@ use Psr\Log\LoggerInterface;
|
||||
|
||||
class Payment extends BaseController
|
||||
{
|
||||
private $_db = null;
|
||||
private ?ServiceService $_serviceService = null;
|
||||
private ?ServiceItemService $_servicItemeService = null;
|
||||
private ?ServicePaymentService $_servicePaymentService = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
// $this->_db = \Config\Database::connect();
|
||||
}
|
||||
public function getServiceService(): ServiceService
|
||||
{
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -4,13 +4,13 @@
|
||||
"settings": {
|
||||
"width": 3000,
|
||||
"height": 3000,
|
||||
"scrollTop": -1339.1952,
|
||||
"scrollLeft": -710.6025,
|
||||
"zoomLevel": 0.79,
|
||||
"scrollTop": -655.903,
|
||||
"scrollLeft": -1430.7592,
|
||||
"zoomLevel": 0.76,
|
||||
"show": 511,
|
||||
"database": 4,
|
||||
"databaseName": "",
|
||||
"canvasType": "ERD",
|
||||
"canvasType": "@dineug/erd-editor/builtin-schema-sql",
|
||||
"language": 1,
|
||||
"tableNameCase": 4,
|
||||
"columnNameCase": 2,
|
||||
@ -127,6 +127,7 @@
|
||||
"comment": "고객정보",
|
||||
"columnIds": [
|
||||
"_AcWUYKzNJd-V0fRHq8Cx",
|
||||
"n7IyDCZLDqfEo49XRYtYR",
|
||||
"z-q_Ah0sghd0nR7VcCTLX",
|
||||
"n61V7aSxLmcIeQqsYgAEE",
|
||||
"5hP5ZiQGWDGf4HJrOiFb6",
|
||||
@ -141,7 +142,9 @@
|
||||
],
|
||||
"seqColumnIds": [
|
||||
"_AcWUYKzNJd-V0fRHq8Cx",
|
||||
"n7IyDCZLDqfEo49XRYtYR",
|
||||
"z-q_Ah0sghd0nR7VcCTLX",
|
||||
"FFviMCKUUVRlcZdx-Uqiq",
|
||||
"n61V7aSxLmcIeQqsYgAEE",
|
||||
"5hP5ZiQGWDGf4HJrOiFb6",
|
||||
"XPpipgVUsGKsXCW5YNg1X",
|
||||
@ -168,7 +171,7 @@
|
||||
"color": ""
|
||||
},
|
||||
"meta": {
|
||||
"updateAt": 1750828861490,
|
||||
"updateAt": 1751880477982,
|
||||
"createAt": 1745819764137
|
||||
}
|
||||
},
|
||||
@ -7667,6 +7670,46 @@
|
||||
"updateAt": 1750916270440,
|
||||
"createAt": 1750916263299
|
||||
}
|
||||
},
|
||||
"FFviMCKUUVRlcZdx-Uqiq": {
|
||||
"id": "FFviMCKUUVRlcZdx-Uqiq",
|
||||
"tableId": "6ajvOCaGuXU9pzV0Y9jEi",
|
||||
"name": "",
|
||||
"comment": "",
|
||||
"dataType": "",
|
||||
"default": "",
|
||||
"options": 0,
|
||||
"ui": {
|
||||
"keys": 0,
|
||||
"widthName": 60,
|
||||
"widthComment": 60,
|
||||
"widthDataType": 60,
|
||||
"widthDefault": 60
|
||||
},
|
||||
"meta": {
|
||||
"updateAt": 1751880464936,
|
||||
"createAt": 1751880464936
|
||||
}
|
||||
},
|
||||
"n7IyDCZLDqfEo49XRYtYR": {
|
||||
"id": "n7IyDCZLDqfEo49XRYtYR",
|
||||
"tableId": "6ajvOCaGuXU9pzV0Y9jEi",
|
||||
"name": "code",
|
||||
"comment": "client코드",
|
||||
"dataType": "VARCHAR(20)",
|
||||
"default": "",
|
||||
"options": 4,
|
||||
"ui": {
|
||||
"keys": 0,
|
||||
"widthName": 60,
|
||||
"widthComment": 60,
|
||||
"widthDataType": 75,
|
||||
"widthDefault": 60
|
||||
},
|
||||
"meta": {
|
||||
"updateAt": 1751881957770,
|
||||
"createAt": 1751880475984
|
||||
}
|
||||
}
|
||||
},
|
||||
"relationshipEntities": {
|
||||
@ -7681,7 +7724,7 @@
|
||||
"_AcWUYKzNJd-V0fRHq8Cx"
|
||||
],
|
||||
"x": 2158.5371,
|
||||
"y": 662.7779333333333,
|
||||
"y": 666.7779333333333,
|
||||
"direction": 2
|
||||
},
|
||||
"end": {
|
||||
@ -7737,7 +7780,7 @@
|
||||
"_AcWUYKzNJd-V0fRHq8Cx"
|
||||
],
|
||||
"x": 2158.5371,
|
||||
"y": 892.1112666666666,
|
||||
"y": 912.1112666666666,
|
||||
"direction": 2
|
||||
},
|
||||
"end": {
|
||||
@ -7765,7 +7808,7 @@
|
||||
"_AcWUYKzNJd-V0fRHq8Cx"
|
||||
],
|
||||
"x": 2158.5371,
|
||||
"y": 777.4445999999999,
|
||||
"y": 789.4445999999999,
|
||||
"direction": 2
|
||||
},
|
||||
"end": {
|
||||
@ -7821,7 +7864,7 @@
|
||||
"_AcWUYKzNJd-V0fRHq8Cx"
|
||||
],
|
||||
"x": 1893.0371,
|
||||
"y": 949.4446,
|
||||
"y": 973.4446,
|
||||
"direction": 8
|
||||
},
|
||||
"end": {
|
||||
@ -7849,7 +7892,7 @@
|
||||
"_AcWUYKzNJd-V0fRHq8Cx"
|
||||
],
|
||||
"x": 1627.5371,
|
||||
"y": 734.4446,
|
||||
"y": 835.4446,
|
||||
"direction": 1
|
||||
},
|
||||
"end": {
|
||||
@ -7857,9 +7900,9 @@
|
||||
"columnIds": [
|
||||
"NzxkmndrTbH7xb6fbnGV7"
|
||||
],
|
||||
"x": 1197.1139,
|
||||
"y": 999.9058,
|
||||
"direction": 4
|
||||
"x": 1457.1138999999998,
|
||||
"y": 1057.9058,
|
||||
"direction": 2
|
||||
},
|
||||
"meta": {
|
||||
"updateAt": 1748506571484,
|
||||
@ -7894,34 +7937,6 @@
|
||||
"createAt": 1748507336370
|
||||
}
|
||||
},
|
||||
"I80TuGxKm3tXIO_EO2PSm": {
|
||||
"id": "I80TuGxKm3tXIO_EO2PSm",
|
||||
"identification": false,
|
||||
"relationshipType": 16,
|
||||
"startRelationshipType": 2,
|
||||
"start": {
|
||||
"tableId": "6ajvOCaGuXU9pzV0Y9jEi",
|
||||
"columnIds": [
|
||||
"_AcWUYKzNJd-V0fRHq8Cx"
|
||||
],
|
||||
"x": 2158.5371,
|
||||
"y": 906.4446,
|
||||
"direction": 2
|
||||
},
|
||||
"end": {
|
||||
"tableId": "GRBrbb1hqwKSRMfod3I7U",
|
||||
"columnIds": [
|
||||
"U3pGwK2LVZA4wQ1xa6EcF"
|
||||
],
|
||||
"x": 2396.448,
|
||||
"y": 1131.4062,
|
||||
"direction": 1
|
||||
},
|
||||
"meta": {
|
||||
"updateAt": 1749008230148,
|
||||
"createAt": 1749008230148
|
||||
}
|
||||
},
|
||||
"o8yw46vm30cC7wl9cRMdo": {
|
||||
"id": "o8yw46vm30cC7wl9cRMdo",
|
||||
"identification": false,
|
||||
@ -7933,7 +7948,7 @@
|
||||
"_AcWUYKzNJd-V0fRHq8Cx"
|
||||
],
|
||||
"x": 1627.5371,
|
||||
"y": 820.4446,
|
||||
"y": 927.4446,
|
||||
"direction": 1
|
||||
},
|
||||
"end": {
|
||||
@ -7941,9 +7956,9 @@
|
||||
"columnIds": [
|
||||
"f1hR1JRFHBHwiJSSX34gw"
|
||||
],
|
||||
"x": 1370.4472333333333,
|
||||
"y": 999.9058,
|
||||
"direction": 4
|
||||
"x": 1457.1138999999998,
|
||||
"y": 1173.9058,
|
||||
"direction": 2
|
||||
},
|
||||
"meta": {
|
||||
"updateAt": 1749517809733,
|
||||
@ -8017,7 +8032,7 @@
|
||||
"_AcWUYKzNJd-V0fRHq8Cx"
|
||||
],
|
||||
"x": 1627.5371,
|
||||
"y": 906.4446,
|
||||
"y": 743.4446,
|
||||
"direction": 1
|
||||
},
|
||||
"end": {
|
||||
@ -8053,7 +8068,7 @@
|
||||
"columnIds": [
|
||||
"Vf3bNvvEPfu1zCs4rcHTU"
|
||||
],
|
||||
"x": 1023.7805666666667,
|
||||
"x": 1197.1138999999998,
|
||||
"y": 999.9058,
|
||||
"direction": 4
|
||||
},
|
||||
@ -8110,7 +8125,7 @@
|
||||
"PLQrLZGFiiPQDZSYpU-Rc"
|
||||
],
|
||||
"x": 1457.1138999999998,
|
||||
"y": 1115.9058,
|
||||
"y": 1289.9058,
|
||||
"direction": 2
|
||||
},
|
||||
"meta": {
|
||||
@ -8138,7 +8153,7 @@
|
||||
"9DIj0WNLrGT8VCHZuRkCz"
|
||||
],
|
||||
"x": 1457.1138999999998,
|
||||
"y": 1347.9058,
|
||||
"y": 1405.9058,
|
||||
"direction": 2
|
||||
},
|
||||
"meta": {
|
||||
@ -8157,7 +8172,7 @@
|
||||
"_AcWUYKzNJd-V0fRHq8Cx"
|
||||
],
|
||||
"x": 1627.5371,
|
||||
"y": 648.4446,
|
||||
"y": 651.4446,
|
||||
"direction": 1
|
||||
},
|
||||
"end": {
|
||||
|
||||
@ -11,7 +11,7 @@ class ClientEntity extends CustomerEntity
|
||||
//타 객체정의 부분
|
||||
public function getSerialCode(): string
|
||||
{
|
||||
return "C" . $this->getPK();
|
||||
return $this->attributes['code'];
|
||||
}
|
||||
public function getName(): string
|
||||
{
|
||||
|
||||
@ -233,7 +233,8 @@ class CommonHelper
|
||||
$forms = [];
|
||||
foreach ($viewDatas['control']['filter_optons'][$field] as $key => $filterEntity) {
|
||||
$values = is_array($value) ? $value : explode(DEFAULTS["DELIMITER_ROLE"], $value);
|
||||
$forms[] = form_checkbox("{$field}[]", $key, in_array($key, $values), [...$extras]) . $filterEntity->getTitle();
|
||||
//form_check에는 "class" => "form-control" 쓰면 않되거나 form-check를 써야함
|
||||
$forms[] = form_checkbox("{$field}[]", $key, in_array($key, $values)) . $filterEntity->getTitle();
|
||||
}
|
||||
$form = implode(" ", $forms);
|
||||
} else {
|
||||
|
||||
@ -58,4 +58,11 @@ class ClientModel extends CustomerModel
|
||||
$this->orLike(self::TABLE . '.email', $word, 'both');
|
||||
parent::setList_WordFilter($word);
|
||||
}
|
||||
public function create(array $formDatas, mixed $entity): mixed
|
||||
{
|
||||
$entity = parent::create($formDatas, $entity);
|
||||
$code = 'C' . str_pad($entity->getPK(), 4, '0', STR_PAD_LEFT);
|
||||
$this->update($entity->getPK(), ['code' => $code]);
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user