dbmsv2 init...1
This commit is contained in:
parent
dec5d81824
commit
c3740990ef
@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Controllers\Admin\Customer;
|
namespace App\Controllers\Admin\Customer;
|
||||||
|
|
||||||
|
use App\Entities\Customer\ClientEntity;
|
||||||
use App\Helpers\Customer\ClientHelper;
|
use App\Helpers\Customer\ClientHelper;
|
||||||
use App\Services\Customer\ClientService;
|
use App\Services\Customer\ClientService;
|
||||||
use CodeIgniter\HTTP\RequestInterface;
|
|
||||||
|
|
||||||
|
use CodeIgniter\HTTP\RequestInterface;
|
||||||
use CodeIgniter\HTTP\ResponseInterface;
|
use CodeIgniter\HTTP\ResponseInterface;
|
||||||
use CodeIgniter\Validation\Validation;
|
use CodeIgniter\Validation\Validation;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
@ -37,27 +38,28 @@ class ClientController extends CustomerController
|
|||||||
}
|
}
|
||||||
//Index,FieldForm관련
|
//Index,FieldForm관련
|
||||||
//생성관련
|
//생성관련
|
||||||
protected function create_process(array $formDatas): void
|
protected function create_process(array $formDatas): ClientEntity
|
||||||
{
|
{
|
||||||
// 관리자 UID는 현재 인증된 사용자로 설정
|
// 관리자 UID는 현재 인증된 사용자로 설정
|
||||||
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
|
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
|
||||||
parent::create_process($formDatas);
|
$entity = parent::create_process($formDatas);
|
||||||
// 생성 후, Client 코드값 재정의
|
// 생성 후, Client 코드값 재정의
|
||||||
$format = env("Client.Prefix.{$formDatas['site']}.code.format", false);
|
$format = env("Client.Prefix.{$formDatas['site']}.code.format", false);
|
||||||
if (!$format) {
|
if (!$format) {
|
||||||
throw new \Exception(__METHOD__ . "에서 code의 prefix가 정의되지 않았습니다.");
|
throw new \Exception(__METHOD__ . "에서 code의 prefix가 정의되지 않았습니다.");
|
||||||
}
|
}
|
||||||
$this->getService()->modify(
|
$this->getService()->modify(
|
||||||
$this->entity,
|
$entity,
|
||||||
['code' => sprintf($format, (int) $this->entity->getPK() + 1000)]
|
['code' => sprintf($format, (int) $entity->getPK() + 1000)]
|
||||||
);
|
);
|
||||||
|
return $entity;
|
||||||
}
|
}
|
||||||
//수정관련
|
//수정관련
|
||||||
protected function modify_process(mixed $entity, array $formDatas): void
|
protected function modify_process(mixed $entity, array $formDatas): ClientEntity
|
||||||
{
|
{
|
||||||
// 관리자 UID는 현재 인증된 사용자로 설정
|
// 관리자 UID는 현재 인증된 사용자로 설정
|
||||||
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
|
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
|
||||||
parent::modify_process($entity, $formDatas);
|
return parent::modify_process($entity, $formDatas);
|
||||||
}
|
}
|
||||||
protected function doValidation_process(Validation $validation, string $field, string $rule): Validation
|
protected function doValidation_process(Validation $validation, string $field, string $rule): Validation
|
||||||
{
|
{
|
||||||
|
|||||||
@ -138,7 +138,8 @@ class PaymentController extends CustomerController
|
|||||||
try {
|
try {
|
||||||
//각 Field 초기화
|
//각 Field 초기화
|
||||||
$this->setAction(__FUNCTION__);
|
$this->setAction(__FUNCTION__);
|
||||||
$this->initAction();
|
//각 Field 초기화
|
||||||
|
$this->initAction($this->getService()->getFormFields());
|
||||||
$this->invoice_process();
|
$this->invoice_process();
|
||||||
return $this->getResultSuccess();
|
return $this->getResultSuccess();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|||||||
@ -2,14 +2,15 @@
|
|||||||
|
|
||||||
namespace App\Controllers\Admin\Equipment;
|
namespace App\Controllers\Admin\Equipment;
|
||||||
|
|
||||||
|
use App\Entities\Equipment\LineEntity;
|
||||||
|
use App\Helpers\Equipment\LineHelper;
|
||||||
|
use App\Services\Equipment\IPService;
|
||||||
|
|
||||||
|
use App\Services\Equipment\LineService;
|
||||||
use CodeIgniter\HTTP\RequestInterface;
|
use CodeIgniter\HTTP\RequestInterface;
|
||||||
use CodeIgniter\HTTP\ResponseInterface;
|
use CodeIgniter\HTTP\ResponseInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
use App\Helpers\Equipment\LineHelper;
|
|
||||||
use App\Services\Equipment\LineService;
|
|
||||||
use App\Services\Equipment\IPService;
|
|
||||||
|
|
||||||
class LineController extends EquipmentController
|
class LineController extends EquipmentController
|
||||||
{
|
{
|
||||||
private ?IpService $_ipService = null;
|
private ?IpService $_ipService = null;
|
||||||
@ -46,17 +47,18 @@ class LineController extends EquipmentController
|
|||||||
//Index,FieldForm관련
|
//Index,FieldForm관련
|
||||||
|
|
||||||
//생성
|
//생성
|
||||||
protected function create_process(array $formDatas): void
|
protected function create_process(array $formDatas): LineEntity
|
||||||
{
|
{
|
||||||
//Line 등록
|
//Line 등록
|
||||||
if (!$this->getHelper()->isValidCIDR($formDatas['bandwith'])) {
|
if (!$this->getHelper()->isValidCIDR($formDatas['bandwith'])) {
|
||||||
throw new \Exception("{$formDatas['bandwith']}는 CIDR 형식에 부합되지 않습니다.");
|
throw new \Exception("{$formDatas['bandwith']}는 CIDR 형식에 부합되지 않습니다.");
|
||||||
}
|
}
|
||||||
//부모처리
|
//부모처리
|
||||||
parent::create_process($formDatas);
|
$entity = parent::create_process($formDatas);
|
||||||
//Prefixed IP to array 자동 등록
|
//Prefixed IP to array 자동 등록
|
||||||
foreach ($this->getHelper()->cidrToIpRange($formDatas['bandwith']) as $ip) {
|
foreach ($this->getHelper()->cidrToIpRange($formDatas['bandwith']) as $ip) {
|
||||||
$this->getIPService()->createByLineInfo($this->entity, $ip);
|
$this->getIPService()->createByLineInfo($entity, $ip);
|
||||||
}
|
}
|
||||||
|
return $entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,7 +70,8 @@ class Home extends AdminController
|
|||||||
{
|
{
|
||||||
//각 Field 초기화
|
//각 Field 초기화
|
||||||
$this->setAction(__FUNCTION__);
|
$this->setAction(__FUNCTION__);
|
||||||
$this->initAction();
|
//각 Field 초기화
|
||||||
|
$this->initAction($this->getService()->getIndexFields());
|
||||||
//Total 서버 현황
|
//Total 서버 현황
|
||||||
$this->totalCounts = $this->getService()->getTotalCountsByType();
|
$this->totalCounts = $this->getService()->getTotalCountsByType();
|
||||||
//interval을 기준으로 최근 신규 서비스정보 가져오기
|
//interval을 기준으로 최근 신규 서비스정보 가져오기
|
||||||
|
|||||||
@ -95,10 +95,13 @@ abstract class CommonController extends BaseController
|
|||||||
}
|
}
|
||||||
return $this->_control['action'];
|
return $this->_control['action'];
|
||||||
}
|
}
|
||||||
final protected function initAction(array $actionFields = []): void
|
final protected function initAction(array $actionFields): void
|
||||||
{
|
{
|
||||||
//action Fields정의용
|
//Fields 정의
|
||||||
$this->initAction_process(actionFields: $actionFields);
|
$this->setControlDatas('actionFields', array_key_exists('fields', $actionFields) ? $actionFields['fields'] : []);
|
||||||
|
//Filters 정의
|
||||||
|
$this->setControlDatas('actionFilters', array_key_exists('filters', $actionFields) ? $actionFields['filters'] : []);
|
||||||
|
//Field Rule정의
|
||||||
$temps = [];
|
$temps = [];
|
||||||
foreach ($this->getControlDatas('actionFields') as $field) {
|
foreach ($this->getControlDatas('actionFields') as $field) {
|
||||||
$temps[$field] = $this->getFormFieldRule_process($this->getAction(), $field);
|
$temps[$field] = $this->getFormFieldRule_process($this->getAction(), $field);
|
||||||
@ -113,10 +116,12 @@ abstract class CommonController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->setControlDatas('filter_optons', $temps);
|
$this->setControlDatas('filter_optons', $temps);
|
||||||
|
//일괄작업용 Fields정의
|
||||||
$this->setControlDatas(
|
$this->setControlDatas(
|
||||||
'batchjob_fields',
|
'batchjob_fields',
|
||||||
array_key_exists('batchjob_fields', $actionFields) ? $actionFields['batchjob_fields'] : $this->getService()->getBatchjobFields()
|
array_key_exists('batchjob_fields', $actionFields) ? $actionFields['batchjob_fields'] : $this->getService()->getBatchjobFields()
|
||||||
);
|
);
|
||||||
|
//일괄작업용 버튼정의
|
||||||
$this->setControlDatas(
|
$this->setControlDatas(
|
||||||
'batchjob_buttions',
|
'batchjob_buttions',
|
||||||
array_key_exists('batchjob_buttions', $actionFields) ? $actionFields['batchjob_buttions'] : $this->getService()->getBatchjobButtons()
|
array_key_exists('batchjob_buttions', $actionFields) ? $actionFields['batchjob_buttions'] : $this->getService()->getBatchjobButtons()
|
||||||
@ -166,7 +171,7 @@ abstract class CommonController extends BaseController
|
|||||||
//각 Field 초기화
|
//각 Field 초기화
|
||||||
$this->setAction(__FUNCTION__);
|
$this->setAction(__FUNCTION__);
|
||||||
//각 Field 초기화
|
//각 Field 초기화
|
||||||
$this->initAction();
|
$this->initAction($this->getService()->getFormFields());
|
||||||
$this->create_form_process();
|
$this->create_form_process();
|
||||||
//actionFilters에 해당하는 값이 있을 경우 정의
|
//actionFilters에 해당하는 값이 있을 경우 정의
|
||||||
helper(['form']);
|
helper(['form']);
|
||||||
@ -183,7 +188,7 @@ abstract class CommonController extends BaseController
|
|||||||
//각 Field 초기화
|
//각 Field 초기화
|
||||||
$this->setAction(__FUNCTION__);
|
$this->setAction(__FUNCTION__);
|
||||||
//각 Field 초기화
|
//각 Field 초기화
|
||||||
$this->initAction();
|
$this->initAction($this->getService()->getFormFields());
|
||||||
//전달값받기
|
//전달값받기
|
||||||
$formDatas = $this->getFormDatas($this->getControlDatas('actionFields'), $this->request->getPost());
|
$formDatas = $this->getFormDatas($this->getControlDatas('actionFields'), $this->request->getPost());
|
||||||
$formDatas = $this->create_validate_process($formDatas);
|
$formDatas = $this->create_validate_process($formDatas);
|
||||||
@ -201,13 +206,13 @@ abstract class CommonController extends BaseController
|
|||||||
try {
|
try {
|
||||||
//각 Field 초기화
|
//각 Field 초기화
|
||||||
$this->setAction(__FUNCTION__);
|
$this->setAction(__FUNCTION__);
|
||||||
|
//각 Field 초기화
|
||||||
|
$this->initAction($this->getService()->getFormFields());
|
||||||
//기존 Entity 가져오기
|
//기존 Entity 가져오기
|
||||||
$entity = $this->getService()->getEntity($uid);
|
$entity = $this->getService()->getEntity($uid);
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
|
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
|
||||||
}
|
}
|
||||||
//각 Field 초기화
|
|
||||||
$this->initAction();
|
|
||||||
$this->entity = $this->modify_form_process($entity);
|
$this->entity = $this->modify_form_process($entity);
|
||||||
helper(['form']);
|
helper(['form']);
|
||||||
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||||
@ -221,15 +226,15 @@ abstract class CommonController extends BaseController
|
|||||||
//Transaction Start
|
//Transaction Start
|
||||||
$this->_db->transStart();
|
$this->_db->transStart();
|
||||||
try {
|
try {
|
||||||
//Action 정의
|
//각 Field 초기화
|
||||||
$this->setAction(__FUNCTION__);
|
$this->setAction(__FUNCTION__);
|
||||||
|
//각 Field 초기화
|
||||||
|
$this->initAction($this->getService()->getFormFields());
|
||||||
//기존 Entity 가져오기
|
//기존 Entity 가져오기
|
||||||
$entity = $this->getService()->getEntity($uid);
|
$entity = $this->getService()->getEntity($uid);
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
|
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
|
||||||
}
|
}
|
||||||
//각 Field 초기화
|
|
||||||
$this->initAction();
|
|
||||||
//전달값받기
|
//전달값받기
|
||||||
$formDatas = $this->getFormDatas($this->getControlDatas('actionFields'), $this->request->getPost());
|
$formDatas = $this->getFormDatas($this->getControlDatas('actionFields'), $this->request->getPost());
|
||||||
$formDatas = $this->modify_validate_process($formDatas);
|
$formDatas = $this->modify_validate_process($formDatas);
|
||||||
@ -247,14 +252,15 @@ abstract class CommonController extends BaseController
|
|||||||
//Transaction Start
|
//Transaction Start
|
||||||
$this->_db->transStart();
|
$this->_db->transStart();
|
||||||
try {
|
try {
|
||||||
|
//각 Field 초기화
|
||||||
$this->setAction(__FUNCTION__);
|
$this->setAction(__FUNCTION__);
|
||||||
|
//각 Field 초기화:조건항목 Field는 한개만 존재하므로 Field와 Rule을 정의
|
||||||
|
$this->initAction(['fields' => [$field], 'filters' => [$field]]);
|
||||||
//기존 Entity 가져오기
|
//기존 Entity 가져오기
|
||||||
$entity = $this->getService()->getEntity($uid);
|
$entity = $this->getService()->getEntity($uid);
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
|
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
|
||||||
}
|
}
|
||||||
//각 Field 초기화:조건항목 Field는 한개만 존재하므로 Field와 Rule을 정의
|
|
||||||
$this->initAction(['fields' => [$field], 'filters' => [$field]]);
|
|
||||||
//전달값받기
|
//전달값받기
|
||||||
$formDatas = $this->getFormDatas($this->getControlDatas('actionFields'), $this->request->getVar());
|
$formDatas = $this->getFormDatas($this->getControlDatas('actionFields'), $this->request->getVar());
|
||||||
$formDatas = $this->toggle_validate_process($formDatas);
|
$formDatas = $this->toggle_validate_process($formDatas);
|
||||||
@ -274,10 +280,8 @@ abstract class CommonController extends BaseController
|
|||||||
$selectedFields = [];
|
$selectedFields = [];
|
||||||
//getBatchJobFields를 이용해서 선택된 Field 와 값정의
|
//getBatchJobFields를 이용해서 선택된 Field 와 값정의
|
||||||
$formDatas = [];
|
$formDatas = [];
|
||||||
foreach ($this->getControlDatas('batchjob_fields') as $field) {
|
foreach ($this->getService()->getBatchjobFields() as $field) {
|
||||||
$value = $this->request->getPost($field);
|
$value = $this->request->getPost($field);
|
||||||
echo "TEST:" . $value;
|
|
||||||
exit;
|
|
||||||
if ($value) {
|
if ($value) {
|
||||||
$selectedFields[] = $field;
|
$selectedFields[] = $field;
|
||||||
$formDatas[$field] = $value;
|
$formDatas[$field] = $value;
|
||||||
@ -298,11 +302,11 @@ abstract class CommonController extends BaseController
|
|||||||
//Transaction Start
|
//Transaction Start
|
||||||
$this->_db->transStart();
|
$this->_db->transStart();
|
||||||
try {
|
try {
|
||||||
//Action 정의
|
//각 Field 초기화
|
||||||
$this->setAction(__FUNCTION__);
|
$this->setAction(__FUNCTION__);
|
||||||
list($selectedFields, $formDatas, $uids) = $this->batchjob_pre_process();
|
list($selectedFields, $formDatas, $uids) = $this->batchjob_pre_process();
|
||||||
//각 Field 초기화: 일괄작업은 선택된 조건항목 Field만 존재하므로 Field와 Rule을 정의
|
//각 Field 초기화:조건항목 Field와 Rule을 정의
|
||||||
$this->initAction(['fields' => [$selectedFields], 'filters' => [$selectedFields]]);
|
$this->initAction(['fields' => $selectedFields, 'filters' => $selectedFields]);
|
||||||
//전달값받기
|
//전달값받기
|
||||||
$formDatas = $this->getFormDatas($this->getControlDatas('actionFields'), $this->request->getPost());
|
$formDatas = $this->getFormDatas($this->getControlDatas('actionFields'), $this->request->getPost());
|
||||||
$formDatas = $this->batchjob_validate_process($formDatas);
|
$formDatas = $this->batchjob_validate_process($formDatas);
|
||||||
@ -379,14 +383,15 @@ abstract class CommonController extends BaseController
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
//Action 정의
|
//Action 정의
|
||||||
|
//각 Field 초기화
|
||||||
$this->setAction(__FUNCTION__);
|
$this->setAction(__FUNCTION__);
|
||||||
|
//각 Field 초기화
|
||||||
|
$this->initAction($this->getService()->getViewFields());
|
||||||
//기존 Entity 가져오기
|
//기존 Entity 가져오기
|
||||||
$entity = $this->getService()->getEntity($uid);
|
$entity = $this->getService()->getEntity($uid);
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
|
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
|
||||||
}
|
}
|
||||||
//각 Field 초기화
|
|
||||||
$this->initAction();
|
|
||||||
$this->entity = $this->view_process($entity);
|
$this->entity = $this->view_process($entity);
|
||||||
helper(['form']);
|
helper(['form']);
|
||||||
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||||
@ -417,10 +422,10 @@ abstract class CommonController extends BaseController
|
|||||||
final public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse|string
|
final public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse|string
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
//Action 정의
|
//각 Field 초기화
|
||||||
$this->setAction(__FUNCTION__);
|
$this->setAction(__FUNCTION__);
|
||||||
//각 Field 초기화
|
//각 Field 초기화
|
||||||
$this->initAction();
|
$this->initAction($this->getService()->getIndexFields());
|
||||||
//URL처리
|
//URL처리
|
||||||
// $this->uri = $this->request->getUri();
|
// $this->uri = $this->request->getUri();
|
||||||
switch ($output_type) {
|
switch ($output_type) {
|
||||||
@ -456,27 +461,6 @@ abstract class CommonController extends BaseController
|
|||||||
//공통 기본 기능
|
//공통 기본 기능
|
||||||
|
|
||||||
//추가 개별 처리 기능
|
//추가 개별 처리 기능
|
||||||
//action Fields정의용
|
|
||||||
protected function initAction_process(array $actionFields = []): void
|
|
||||||
{
|
|
||||||
switch ($this->getAction()) {
|
|
||||||
case 'view':
|
|
||||||
$temps = is_array($actionFields) && array_key_exists('fields', $actionFields) ? $actionFields : $this->getService()->getViewFields();
|
|
||||||
$this->setControlDatas('actionFields', is_array($temps) && array_key_exists('fields', $temps) ? $temps['fields'] : []);
|
|
||||||
$this->setControlDatas('actionFilters', is_array($temps) && array_key_exists('filters', $temps) ? $temps['filters'] : []);
|
|
||||||
break;
|
|
||||||
case 'index':
|
|
||||||
$temps = is_array($actionFields) && array_key_exists('fields', $actionFields) ? $actionFields : $this->getService()->getIndexFields();
|
|
||||||
$this->setControlDatas('actionFields', is_array($temps) && array_key_exists('fields', $temps) ? $temps['fields'] : []);
|
|
||||||
$this->setControlDatas('actionFilters', is_array($temps) && array_key_exists('filters', $temps) ? $temps['filters'] : []);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$temps = is_array($actionFields) && array_key_exists('fields', $actionFields) ? $actionFields : $this->getService()->getFormFields();
|
|
||||||
$this->setControlDatas('actionFields', is_array($temps) && array_key_exists('fields', $temps) ? $temps['fields'] : []);
|
|
||||||
$this->setControlDatas('actionFilters', is_array($temps) && array_key_exists('filters', $temps) ? $temps['filters'] : []);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//FieldForm관련용
|
//FieldForm관련용
|
||||||
protected function getFormFieldOption_process(string $field, array $options = []): array
|
protected function getFormFieldOption_process(string $field, array $options = []): array
|
||||||
{
|
{
|
||||||
@ -690,10 +674,10 @@ abstract class CommonController extends BaseController
|
|||||||
public function index(): RedirectResponse|string
|
public function index(): RedirectResponse|string
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
//Action 정의
|
//각 Field 초기화
|
||||||
$this->setAction(__FUNCTION__);
|
$this->setAction(__FUNCTION__);
|
||||||
//각 Field 초기화
|
//각 Field 초기화
|
||||||
$this->initAction();
|
$this->initAction($this->getService()->getIndexFields());
|
||||||
helper(['form']);
|
helper(['form']);
|
||||||
//Return Url정의
|
//Return Url정의
|
||||||
$this->getMyAuth()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : ""));
|
$this->getMyAuth()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : ""));
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user