dbms_init...1
This commit is contained in:
parent
460fa7e347
commit
6ced3137cb
@ -15,9 +15,9 @@ $routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes)
|
|||||||
$routes->group('', ['namespace' => 'App\Controllers'], function ($routes) {
|
$routes->group('', ['namespace' => 'App\Controllers'], function ($routes) {
|
||||||
$routes->get('/', 'Home::index');
|
$routes->get('/', 'Home::index');
|
||||||
$routes->group('auth', ['namespace' => 'App\Controllers\Auth'], function ($routes) {
|
$routes->group('auth', ['namespace' => 'App\Controllers\Auth'], function ($routes) {
|
||||||
$routes->get('login', 'LocalController::login_form');
|
$routes->get('login', 'LocalController::create_form');
|
||||||
$routes->post('login', 'LocalController::login');
|
$routes->post('login', 'LocalController::create');
|
||||||
$routes->get('google_login', 'GoogleController::login');
|
$routes->get('google_login', 'GoogleController::create');
|
||||||
$routes->get('logout', 'LocalController::logout');
|
$routes->get('logout', 'LocalController::logout');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -50,11 +50,9 @@ class AccountController extends CustomerController
|
|||||||
}
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
protected function create_process(string $action, array $fields, array $formDatas = []): AccountEntity
|
protected function create_process(array $formDatas): AccountEntity
|
||||||
{
|
{
|
||||||
//데이터 검증
|
$entity = parent::create_process($formDatas);
|
||||||
$formDatas = $this->doValidate($action, $fields, $formDatas);
|
|
||||||
$entity = $this->getService()->create($formDatas);
|
|
||||||
//고객예치금처리
|
//고객예치금처리
|
||||||
$this->setAccountBalance($formDatas);
|
$this->setAccountBalance($formDatas);
|
||||||
return $entity;
|
return $entity;
|
||||||
|
|||||||
@ -2,17 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Controllers\Admin\Customer;
|
namespace App\Controllers\Admin\Customer;
|
||||||
|
|
||||||
use App\Entities\Customer\AccountEntity;
|
|
||||||
use App\Entities\Customer\ClientEntity;
|
|
||||||
use App\Entities\Customer\CouponEntity;
|
|
||||||
use App\Helpers\Customer\ClientHelper;
|
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
use App\Helpers\Customer\ClientHelper;
|
||||||
|
use App\Services\Customer\ClientService;
|
||||||
|
|
||||||
class ClientController extends CustomerController
|
class ClientController extends CustomerController
|
||||||
{
|
{
|
||||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||||
@ -39,7 +36,7 @@ class ClientController extends CustomerController
|
|||||||
return $this->_helper;
|
return $this->_helper;
|
||||||
}
|
}
|
||||||
//Index,FieldForm관련
|
//Index,FieldForm관련
|
||||||
protected function setValidation(Validation $validation, string $action, string $field, string $rule): Validation
|
protected function setValidation(Validation $validation, string $field, string $rule): Validation
|
||||||
{
|
{
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
case 'role':
|
case 'role':
|
||||||
@ -47,7 +44,7 @@ class ClientController extends CustomerController
|
|||||||
$validation->setRule("{$field}.*", $field, $rule);
|
$validation->setRule("{$field}.*", $field, $rule);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$validation = parent::setValidation($validation, $action, $field, $rule);
|
$validation = parent::setValidation($validation, $field, $rule);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $validation;
|
return $validation;
|
||||||
|
|||||||
@ -49,11 +49,9 @@ class CouponController extends CustomerController
|
|||||||
}
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
protected function create_process(string $action, array $fields, array $formDatas = []): CouponEntity
|
protected function create_process(array $formDatas): CouponEntity
|
||||||
{
|
{
|
||||||
//데이터 검증
|
$entity = parent::create_process($formDatas);
|
||||||
$formDatas = $this->doValidate($action, $fields, $formDatas);
|
|
||||||
$entity = $this->getService()->create($formDatas);
|
|
||||||
//고객쿠폰처리
|
//고객쿠폰처리
|
||||||
$this->setCouponBalance($formDatas);
|
$this->setCouponBalance($formDatas);
|
||||||
return $entity;
|
return $entity;
|
||||||
|
|||||||
@ -50,11 +50,9 @@ class PointController extends CustomerController
|
|||||||
}
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
protected function create_process(string $action, array $fields, array $formDatas = []): PointEntity
|
protected function create_process(array $formDatas): PointEntity
|
||||||
{
|
{
|
||||||
//데이터 검증
|
$entity = parent::create_process($formDatas);
|
||||||
$formDatas = $this->doValidate($action, $fields, $formDatas);
|
|
||||||
$entity = $this->getService()->create($formDatas);
|
|
||||||
//고객포인트처리
|
//고객포인트처리
|
||||||
$this->setPointBalance($formDatas);
|
$this->setPointBalance($formDatas);
|
||||||
return $entity;
|
return $entity;
|
||||||
|
|||||||
@ -45,22 +45,21 @@ class ServiceController extends CustomerController
|
|||||||
}
|
}
|
||||||
return $this->_serviceItemService;
|
return $this->_serviceItemService;
|
||||||
}
|
}
|
||||||
protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string
|
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"]): RedirectResponse|string
|
||||||
{
|
{
|
||||||
$this->action = $action;
|
switch ($this->getAction()) {
|
||||||
switch ($action) {
|
|
||||||
case 'index':
|
case 'index':
|
||||||
$this->getHelper()->setViewDatas($this->getViewDatas());
|
$this->getHelper()->setViewDatas($this->getViewDatas());
|
||||||
$result = view($this->view_path . 'service' . DIRECTORY_SEPARATOR . $action, ['viewDatas' => $this->getViewDatas()]);
|
$result = view($this->view_path . 'service' . DIRECTORY_SEPARATOR . $this->getAction(), ['viewDatas' => $this->getViewDatas()]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$result = parent::getResultPageByActon($action, $message);
|
$result = parent::getResultSuccess($message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
//Index,FieldForm관련
|
//Index,FieldForm관련
|
||||||
protected function index_process(string $action, array $fields): array
|
protected function index_process(): array
|
||||||
{
|
{
|
||||||
//추가 Field작업 처리
|
//추가 Field작업 처리
|
||||||
$this->item_types = lang($this->getServiceItemService()->getClassName() . '.' . strtoupper('ITEM_TYPE'));
|
$this->item_types = lang($this->getServiceItemService()->getClassName() . '.' . strtoupper('ITEM_TYPE'));
|
||||||
@ -68,7 +67,7 @@ class ServiceController extends CustomerController
|
|||||||
$this->field_options = $this->getFormFieldOption($field, $this->field_options);
|
$this->field_options = $this->getFormFieldOption($field, $this->field_options);
|
||||||
}
|
}
|
||||||
$entities = [];
|
$entities = [];
|
||||||
foreach (parent::index_process($action, $fields) as $entity) {
|
foreach (parent::index_process() as $entity) {
|
||||||
foreach ($this->item_types as $field => $label) {
|
foreach ($this->item_types as $field => $label) {
|
||||||
$itemEntities = $this->getServiceItemService()->getEntities(['item_type' => $field]);
|
$itemEntities = $this->getServiceItemService()->getEntities(['item_type' => $field]);
|
||||||
$entity->setItemEntities($field, $itemEntities);
|
$entity->setItemEntities($field, $itemEntities);
|
||||||
|
|||||||
@ -74,34 +74,32 @@ class ServiceItemController extends CustomerController
|
|||||||
}
|
}
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string
|
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"]): RedirectResponse|string
|
||||||
{
|
{
|
||||||
$this->action = $action;
|
switch ($this->getAction()) {
|
||||||
switch ($action) {
|
|
||||||
case 'index':
|
case 'index':
|
||||||
$this->getHelper()->setViewDatas($this->getViewDatas());
|
$this->getHelper()->setViewDatas($this->getViewDatas());
|
||||||
$result = view($this->view_path . 'popup' . DIRECTORY_SEPARATOR . $action, ['viewDatas' => $this->getViewDatas()]);
|
$result = view($this->view_path . 'popup' . DIRECTORY_SEPARATOR . $this->getAction(), ['viewDatas' => $this->getViewDatas()]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$result = parent::getResultPageByActon($action, $message);
|
$result = parent::getResultSuccess($message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
//Index,FieldForm관련
|
//Index,FieldForm관련
|
||||||
protected function create_process(string $action, array $fields, array $formDatas = []): mixed
|
protected function create_process(array $formDatas): mixed
|
||||||
{
|
{
|
||||||
$this->field_rules = $this->getFieldRules($action, $fields);
|
//도메인의 경우 domaininfo에 등록 후 ServiceItemEntity의 item_uid에 넣고 create해야함
|
||||||
//데이터 검증
|
if ($formDatas['item_type'] === 'DOMAIN') {
|
||||||
$validatedFormDatas = $this->doValidate($action, $fields, $formDatas);
|
$serviceEntity = $this->getServiceService()->getEntity($formDatas['serviceinfo_uid']);
|
||||||
//도메인의 경우 domaininfo에 등록 후 ItemEntity의 item_uid에 넣어줘야함
|
$equipmentEntity = $this->getEquipmentService($formDatas['item_type'])->create([
|
||||||
if ($validatedFormDatas['item_type'] === 'DOMAIN') {
|
'clientinfo_uid' => $serviceEntity->getClientInfoUID(),
|
||||||
$serviceEntity = $this->getServiceService()->getEntity($validatedFormDatas['serviceinfo_uid']);
|
'domain' => $formDatas['item_uid']
|
||||||
$tempDatas = ['clientinfo_uid' => $serviceEntity->getClientInfoUID(), 'domain' => $validatedFormDatas['item_uid']];
|
]);
|
||||||
$equipmentEntity = $this->getEquipmentService($validatedFormDatas['item_type'])->create($tempDatas);
|
|
||||||
//도메인용 항목의 item_uid로 전달함
|
//도메인용 항목의 item_uid로 전달함
|
||||||
$validatedFormDatas['item_uid'] = $equipmentEntity->getPK();
|
$formDatas['item_uid'] = $equipmentEntity->getPK();
|
||||||
}
|
}
|
||||||
return $this->getService()->create($validatedFormDatas);
|
return parent::create_process($formDatas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,17 +48,15 @@ class LineController extends PartController
|
|||||||
//Index,FieldForm관련
|
//Index,FieldForm관련
|
||||||
|
|
||||||
//생성
|
//생성
|
||||||
protected function create_process(string $action, array $fields, array $formDatas = []): LineEntity
|
protected function create_process(array $formDatas): LineEntity
|
||||||
{
|
{
|
||||||
//Line 등록
|
//Line 등록
|
||||||
if (!$this->getHelper()->isValidCIDR($this->formDatas['bandwith'])) {
|
if (!$this->getHelper()->isValidCIDR($formDatas['bandwith'])) {
|
||||||
throw new \Exception("{$this->formDatas['bandwith']}는 CIDR 형식에 부합되지 않습니다.");
|
throw new \Exception("{$formDatas['bandwith']}는 CIDR 형식에 부합되지 않습니다.");
|
||||||
}
|
}
|
||||||
//데이터 검증
|
$entity = parent::create_process($formDatas);
|
||||||
$validatedFormDatas = $this->doValidate($action, $fields, $formDatas);
|
//Prefixed IP to array 등록
|
||||||
return $this->getService()->create($validatedFormDatas);
|
foreach ($this->getHelper()->cidrToIpRange($formDatas['bandwith']) as $ip) {
|
||||||
//IP 등록
|
|
||||||
foreach ($this->getHelper()->cidrToIpRange($this->formDatas['bandwith']) as $ip) {
|
|
||||||
$this->getIpService()->createByLineInfo($entity, $ip);
|
$this->getIpService()->createByLineInfo($entity, $ip);
|
||||||
}
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
|
|||||||
@ -32,20 +32,6 @@ class Home extends AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Index,FieldForm관련
|
//Index,FieldForm관련
|
||||||
public function getFields(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
public function getFilterFields(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
public function getBatchJobFields(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
//Index,FieldForm관련
|
|
||||||
|
|
||||||
public function index(): string
|
public function index(): string
|
||||||
{
|
{
|
||||||
helper(['form']);
|
helper(['form']);
|
||||||
|
|||||||
@ -40,7 +40,7 @@ class UserController extends AdminController
|
|||||||
return $this->_helper;
|
return $this->_helper;
|
||||||
}
|
}
|
||||||
//Index,FieldForm관련
|
//Index,FieldForm관련
|
||||||
protected function setValidation(Validation $validation, string $action, string $field, string $rule): Validation
|
protected function setValidation(Validation $validation, string $field, string $rule): Validation
|
||||||
{
|
{
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
case 'role':
|
case 'role':
|
||||||
@ -48,7 +48,7 @@ class UserController extends AdminController
|
|||||||
$validation->setRule("{$field}.*", $field, $rule);
|
$validation->setRule("{$field}.*", $field, $rule);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$validation = parent::setValidation($validation, $action, $field, $rule);
|
$validation = parent::setValidation($validation, $field, $rule);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $validation;
|
return $validation;
|
||||||
|
|||||||
@ -26,7 +26,7 @@ abstract class AuthController extends CommonController
|
|||||||
$this->individualScripts = [];
|
$this->individualScripts = [];
|
||||||
}
|
}
|
||||||
abstract protected function getSNSButton(): string;
|
abstract protected function getSNSButton(): string;
|
||||||
abstract protected function login_process(string $action): UserEntity;
|
abstract protected function create_process(array $formDatas): UserEntity;
|
||||||
|
|
||||||
final public function getHelper(): mixed
|
final public function getHelper(): mixed
|
||||||
{
|
{
|
||||||
@ -35,50 +35,15 @@ abstract class AuthController extends CommonController
|
|||||||
}
|
}
|
||||||
return $this->_helper;
|
return $this->_helper;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function getFields(): array
|
|
||||||
{
|
|
||||||
return ['id', 'passwd'];
|
|
||||||
}
|
|
||||||
//로그인화면
|
//로그인화면
|
||||||
final public function login_form(): RedirectResponse|string
|
public function create_form_process(): void
|
||||||
{
|
{
|
||||||
$action = __FUNCTION__;
|
$this->sns_buttoh = $this->getSNSButton();
|
||||||
try {
|
|
||||||
helper(['form']);
|
|
||||||
$this->sns_buttoh = $this->getSNSButton();
|
|
||||||
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
|
||||||
return $this->getResultPageByActon($action);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
if (env('app.debug.' . $action)) {
|
|
||||||
echo $e->getMessage();
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
return redirect()->back()->withInput()->with('error', $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//로그인
|
|
||||||
final public function login(): RedirectResponse|string
|
|
||||||
{
|
|
||||||
$action = __FUNCTION__;
|
|
||||||
try {
|
|
||||||
$this->entity = $this->login_process($action);
|
|
||||||
return $this->getResultPageByActon($action, MESSAGES['LOGIN']);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
if (env('app.debug.' . $action)) {
|
|
||||||
echo $e->getMessage();
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
return redirect()->back()->withInput()->with('error', $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//로그아웃
|
//로그아웃
|
||||||
final public function logout(): RedirectResponse
|
final public function logout(): RedirectResponse
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// $this->init(__FUNCTION__);
|
|
||||||
$this->getService()->logout();
|
$this->getService()->logout();
|
||||||
// 홈페이지로 리다이렉트
|
// 홈페이지로 리다이렉트
|
||||||
return redirect()->route('/')->with('error', MESSAGES['LOGOUT']);
|
return redirect()->route('/')->with('error', MESSAGES['LOGOUT']);
|
||||||
|
|||||||
@ -41,12 +41,11 @@ class GoogleController extends AuthController
|
|||||||
}
|
}
|
||||||
|
|
||||||
//로그인처리
|
//로그인처리
|
||||||
protected function login_process(string $action): UserEntity
|
protected function create_process(array $formDatas): UserEntity
|
||||||
{
|
{
|
||||||
$access_code = $this->request->getVar('code');
|
if (!array_key_exists('access_code', $formDatas) || !$formDatas['access_code']) {
|
||||||
if (!$access_code) {
|
|
||||||
throw new \Exception("구글 로그인 실패");
|
throw new \Exception("구글 로그인 실패");
|
||||||
}
|
}
|
||||||
return $this->getService()->login($this->getService()->checkUser($access_code));
|
return ($this->getService()->login($formDatas));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,11 +29,8 @@ class LocalController extends AuthController
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
//로그인처리
|
//로그인처리
|
||||||
protected function login_process(string $action, array $formDatas = []): UserEntity
|
protected function create_process(array $formDatas): UserEntity
|
||||||
{
|
{
|
||||||
foreach ($this->fields as $field) {
|
return ($this->getService()->login($formDatas));
|
||||||
$formDatas[] = $this->request->getVar($field);
|
|
||||||
}
|
|
||||||
return $this->getService()->login($this->getService()->checkUser($formDatas));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,7 @@ abstract class CommonController extends BaseController
|
|||||||
private $_myAuth = null;
|
private $_myAuth = null;
|
||||||
private ?MyLogService $_myLogService = null;
|
private ?MyLogService $_myLogService = null;
|
||||||
private $_viewDatas = [];
|
private $_viewDatas = [];
|
||||||
|
private $_control = [];
|
||||||
abstract public function getService(): mixed;
|
abstract public function getService(): mixed;
|
||||||
abstract function getHelper(): mixed;
|
abstract function getHelper(): mixed;
|
||||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||||
@ -34,13 +35,6 @@ abstract class CommonController extends BaseController
|
|||||||
$this->myAuthName = $this->getMyAuth()->getNameByAuthInfo();
|
$this->myAuthName = $this->getMyAuth()->getNameByAuthInfo();
|
||||||
$this->myAuthUID = $this->getMyAuth()->getUIDByAuthInfo();
|
$this->myAuthUID = $this->getMyAuth()->getUIDByAuthInfo();
|
||||||
}
|
}
|
||||||
//각 Field 초기화
|
|
||||||
$this->form_fields = $this->getFormFields();
|
|
||||||
$this->filter_fields = $this->getFilterFields();
|
|
||||||
$this->field_options = $this->getFormFieldOptions($this->getFormFields());
|
|
||||||
$this->index_fields = $this->getIndexFields();
|
|
||||||
$this->view_fields = $this->getViewFields();
|
|
||||||
$this->batchjob_fields = $this->getBatchJobFields();
|
|
||||||
}
|
}
|
||||||
final public function __get($name)
|
final public function __get($name)
|
||||||
{
|
{
|
||||||
@ -72,75 +66,114 @@ abstract class CommonController extends BaseController
|
|||||||
return $this->_myLogService;
|
return $this->_myLogService;
|
||||||
}
|
}
|
||||||
//Index,FieldForm관련
|
//Index,FieldForm관련
|
||||||
public function getFormFields(?array $form_fields = null): array
|
final protected function setAction(string $action): void
|
||||||
{
|
{
|
||||||
if (is_array($form_fields)) {
|
$this->_control['action'] = $action;
|
||||||
$this->form_fields = $form_fields;
|
|
||||||
}
|
|
||||||
if (!is_array($this->form_fields)) {
|
|
||||||
$this->form_fields = $this->getService()->getFormFields();;
|
|
||||||
}
|
|
||||||
return $this->form_fields;
|
|
||||||
}
|
}
|
||||||
public function getFilterFields(?array $filter_fields = null): array
|
final protected function getAction(): string
|
||||||
{
|
{
|
||||||
if (is_array($filter_fields)) {
|
if (!array_key_exists('action', $this->_control)) {
|
||||||
$this->filter_fields = $filter_fields;
|
throw new \Exception("action이 정의되지 않았습니다.");
|
||||||
}
|
}
|
||||||
if (!is_array($this->filter_fields)) {
|
return $this->_control['action'];
|
||||||
$this->filter_fields = $this->getService()->getFilterFields();;
|
|
||||||
}
|
|
||||||
return $this->filter_fields;
|
|
||||||
}
|
}
|
||||||
public function getIndexFields(?array $index_fields = null): array
|
final protected function setFormFields(array $fields): void
|
||||||
{
|
{
|
||||||
if (is_array($index_fields)) {
|
$this->_control['form_fields'] = $fields;
|
||||||
$this->index_fields = $index_fields;
|
|
||||||
}
|
|
||||||
if (!is_array($this->index_fields)) {
|
|
||||||
$this->index_fields = $this->getService()->getIndexFields();;
|
|
||||||
}
|
|
||||||
return $this->index_fields;
|
|
||||||
}
|
}
|
||||||
public function getViewFields(?array $view_fields = null): array
|
final protected function getFormFields(): array
|
||||||
{
|
{
|
||||||
if (is_array($view_fields)) {
|
return $this->_control['form_fields'] ?? [];
|
||||||
$this->view_fields = $view_fields;
|
|
||||||
}
|
|
||||||
if (!is_array($this->view_fields)) {
|
|
||||||
$this->view_fields = $this->getService()->getViewFields();;
|
|
||||||
}
|
|
||||||
return $this->view_fields;
|
|
||||||
}
|
}
|
||||||
public function getBatchJobFields(?array $batchjob_fields = null): array
|
final protected function setIndexFields(array $fields): void
|
||||||
{
|
{
|
||||||
if (is_array($batchjob_fields)) {
|
$this->_control['index_fields'] = $fields;
|
||||||
$this->batchjob_fields = $batchjob_fields;
|
|
||||||
}
|
|
||||||
if (!is_array($this->batchjob_fields)) {
|
|
||||||
$this->batchjob_fields = $this->getService()->getBatchJobFields();;
|
|
||||||
}
|
|
||||||
return $this->batchjob_fields;
|
|
||||||
}
|
}
|
||||||
protected function getFieldRule(string $action, string $field): string
|
final protected function getIndexFields(): array
|
||||||
|
{
|
||||||
|
return $this->_control['index_fields'] ?? [];
|
||||||
|
}
|
||||||
|
final protected function setViewFields(array $fields): void
|
||||||
|
{
|
||||||
|
$this->_control['view_fields'] = $fields;
|
||||||
|
}
|
||||||
|
final protected function getViewFields(): array
|
||||||
|
{
|
||||||
|
return $this->_control['view_fields'] ?? [];
|
||||||
|
}
|
||||||
|
final protected function setFilterFields(array $fields): void
|
||||||
|
{
|
||||||
|
$this->_control['filter_fields'] = $fields;
|
||||||
|
}
|
||||||
|
final protected function getFilterFields(): array
|
||||||
|
{
|
||||||
|
return $this->_control['filter_fields'] ?? [];
|
||||||
|
}
|
||||||
|
final protected function setBatchjobFields(array $fields): void
|
||||||
|
{
|
||||||
|
$this->_control['batchjob_fields'] = $fields;
|
||||||
|
}
|
||||||
|
final protected function getBatchjobFields(): array
|
||||||
|
{
|
||||||
|
return $this->_control['batchjob_fields'] ?? [];
|
||||||
|
}
|
||||||
|
final protected function setFieldRule(string $field, string $rule): void
|
||||||
|
{
|
||||||
|
if (!array_key_exists('field_rules', $this->_control)) {
|
||||||
|
$this->_control['field_rules'] = [];
|
||||||
|
}
|
||||||
|
$this->_control['field_rules'][$field] = $rule;
|
||||||
|
}
|
||||||
|
final protected function getFieldRule(string $field): string
|
||||||
|
{
|
||||||
|
return $this->_control['field_rules'][$field] ?? [];
|
||||||
|
}
|
||||||
|
final protected function getFieldRules(): array
|
||||||
|
{
|
||||||
|
return $this->_control['field_rules'] ?? [];
|
||||||
|
}
|
||||||
|
final protected function setFilterFieldOption(string $field, array $options): void
|
||||||
|
{
|
||||||
|
if (!array_key_exists('filter_optons', $this->_control)) {
|
||||||
|
$this->_control['filter_optons'] = [];
|
||||||
|
}
|
||||||
|
$this->_control['filter_optons'][$field] = $options;
|
||||||
|
}
|
||||||
|
final protected function getFilterFieldOption(string $field): string
|
||||||
|
{
|
||||||
|
return $this->_control['filter_optons'][$field] ?? [];
|
||||||
|
}
|
||||||
|
final protected function getFilterFieldOptions(): array
|
||||||
|
{
|
||||||
|
return $this->_control['filter_optons'] ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function initAction(string $action): void
|
||||||
|
{ //각 Field 초기화
|
||||||
|
$this->setAction($action);
|
||||||
|
$this->setFormFields($this->getService()->getFormFields());
|
||||||
|
$this->setIndexFields($this->getService()->getIndexFields());
|
||||||
|
$this->setViewFields($this->getService()->setViewFields());
|
||||||
|
$this->setFilterFields($this->getService()->getFilterFields());
|
||||||
|
foreach ($this->getFormFields() as $field) {
|
||||||
|
$this->setFieldRule($field, $this->getFormFieldRule($this->getAction(), $field));
|
||||||
|
}
|
||||||
|
foreach ($this->getFilterFields() as $field) {
|
||||||
|
$this->setFilterFieldOption($field, $this->getFormFieldOption($field, $this->getFilterFieldOptions()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
{
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||||
}
|
}
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
default:
|
default:
|
||||||
$rule = $this->getService()->getFieldRule($action, $field);
|
$rule = $this->getService()->getFormFieldRule($action, $field);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $rule;
|
return $rule;
|
||||||
}
|
}
|
||||||
final protected function getFieldRules(string $action, array $fields, $rules = []): array
|
|
||||||
{
|
|
||||||
foreach ($fields as $field) {
|
|
||||||
$rules[$field] = $this->getFieldRule($action, $field);
|
|
||||||
}
|
|
||||||
return $rules;
|
|
||||||
}
|
|
||||||
protected function getFormFieldOption(string $field, array $options): array
|
protected function getFormFieldOption(string $field, array $options): array
|
||||||
{
|
{
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
@ -153,20 +186,7 @@ abstract class CommonController extends BaseController
|
|||||||
}
|
}
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
final protected function getFormFieldOptions(array $fields, array $options = []): array
|
protected function setValidation(Validation $validation, string $field, string $rule): Validation
|
||||||
{
|
|
||||||
foreach ($fields as $field) {
|
|
||||||
if (is_array($field)) {
|
|
||||||
throw new \Exception(__FUNCTION__ . "에서 field array 입니다.\n" . var_export($field, true));
|
|
||||||
}
|
|
||||||
if (!array_key_exists($field, $options)) {
|
|
||||||
$options[$field] = [];
|
|
||||||
}
|
|
||||||
$options = $this->getFormFieldOption($field, $options);
|
|
||||||
}
|
|
||||||
return $options;
|
|
||||||
}
|
|
||||||
protected function setValidation(Validation $validation, string $action, string $field, string $rule): Validation
|
|
||||||
{
|
{
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
default:
|
default:
|
||||||
@ -177,14 +197,14 @@ abstract class CommonController extends BaseController
|
|||||||
}
|
}
|
||||||
//Field관련
|
//Field관련
|
||||||
//데이터 검증
|
//데이터 검증
|
||||||
final protected function doValidate(string $action, array $fields, array $formDatas, ?Validation $validation = null): array
|
final protected function doValidate(array $rules, array $formDatas, ?Validation $validation = null): array
|
||||||
{
|
{
|
||||||
//변경할 값 확인 : Upload된 파일 검증시 $this->request->getPOST()보다 먼처 체크필요
|
//변경할 값 확인 : Upload된 파일 검증시 $this->request->getPOST()보다 먼처 체크필요
|
||||||
if (!$validation) {
|
if (!$validation) {
|
||||||
$validation = service('validation');
|
$validation = service('validation');
|
||||||
}
|
}
|
||||||
foreach ($fields as $field) {
|
foreach ($rules as $field => $rule) {
|
||||||
$validation = $this->setValidation($validation, $action, $field, $this->getFieldRule($action, $field));
|
$validation = $this->setValidation($validation, $field, $rule);
|
||||||
}
|
}
|
||||||
if (!$validation->run($formDatas)) {
|
if (!$validation->run($formDatas)) {
|
||||||
throw new \Exception("{$this->getService()->getClassName()} 작업 데이터 검증 오류발생\n" . implode(
|
throw new \Exception("{$this->getService()->getClassName()} 작업 데이터 검증 오류발생\n" . implode(
|
||||||
@ -192,14 +212,26 @@ abstract class CommonController extends BaseController
|
|||||||
$validation->getErrors()
|
$validation->getErrors()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
return $validation->getValidated();
|
return $formDatas;
|
||||||
|
// return $validation->getValidated();
|
||||||
}
|
}
|
||||||
protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string
|
protected function getResultFail(string $message = MESSAGES["FAILED"]): RedirectResponse|string
|
||||||
{
|
{
|
||||||
$this->action = $action;
|
if (env('app.debug.' . $this->getAction())) {
|
||||||
switch ($action) {
|
$result = $message;
|
||||||
|
} else {
|
||||||
|
LogCollector::debug($message);
|
||||||
|
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), $message);
|
||||||
|
$result = redirect()->back()->withInput()->with('error', $message);
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"]): RedirectResponse|string
|
||||||
|
{
|
||||||
|
switch ($this->getAction()) {
|
||||||
case 'create':
|
case 'create':
|
||||||
case 'modify':
|
case 'modify':
|
||||||
|
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), $message);
|
||||||
$result = $this->view($this->entity->getPK());
|
$result = $this->view($this->entity->getPK());
|
||||||
break;
|
break;
|
||||||
case 'create_form':
|
case 'create_form':
|
||||||
@ -208,7 +240,7 @@ abstract class CommonController extends BaseController
|
|||||||
case 'index':
|
case 'index':
|
||||||
case 'view':
|
case 'view':
|
||||||
// $this->getHelper()->setViewDatas($this->getViewDatas());
|
// $this->getHelper()->setViewDatas($this->getViewDatas());
|
||||||
$result = view($this->view_path . $action, ['viewDatas' => $this->getViewDatas()]);
|
$result = view($this->view_path . $this->getAction(), ['viewDatas' => $this->getViewDatas()]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$result = redirect()->to($this->getMyAuth()->popPreviousUrl())->with('error', $message);
|
$result = redirect()->to($this->getMyAuth()->popPreviousUrl())->with('error', $message);
|
||||||
@ -219,14 +251,12 @@ abstract class CommonController extends BaseController
|
|||||||
//Index,FieldForm관련
|
//Index,FieldForm관련
|
||||||
|
|
||||||
// 생성
|
// 생성
|
||||||
final protected function create_form_process($action): void
|
protected function create_form_process(): void {}
|
||||||
{
|
|
||||||
$this->field_rules = $this->getFieldRules($action, $this->getFormFields());
|
|
||||||
}
|
|
||||||
final public function create_form(): RedirectResponse|string
|
final public function create_form(): RedirectResponse|string
|
||||||
{
|
{
|
||||||
$action = 'create';
|
|
||||||
try {
|
try {
|
||||||
|
//각 Field 초기화
|
||||||
|
$this->initAction(__FUNCTION__);
|
||||||
helper(['form']);
|
helper(['form']);
|
||||||
//filter_fields에 해당하는 값이 있을 경우 정의
|
//filter_fields에 해당하는 값이 있을 경우 정의
|
||||||
foreach ($this->getFilterFields() as $field) {
|
foreach ($this->getFilterFields() as $field) {
|
||||||
@ -235,61 +265,48 @@ abstract class CommonController extends BaseController
|
|||||||
$this->$field = $value;
|
$this->$field = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->create_form_process($action);
|
$this->create_form_process();
|
||||||
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||||
return $this->getResultPageByActon($action);
|
return $this->getResultSuccess();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if (env('app.debug.' . $action)) {
|
return $this->getResultFail($e->getMessage());
|
||||||
echo $e->getMessage();
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
return redirect()->back()->withInput()->with('error', $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected function create_process(string $action, array $fields, array $formDatas = []): mixed
|
protected function create_process(array $formDatas): mixed
|
||||||
{
|
{
|
||||||
$this->field_rules = $this->getFieldRules($action, $fields);
|
|
||||||
//데이터 검증
|
//데이터 검증
|
||||||
$validatedFormDatas = $this->doValidate($action, $fields, $formDatas);
|
$formDatas = $this->doValidate($this->getFieldRules(), $formDatas);
|
||||||
return $this->getService()->create($validatedFormDatas);
|
return $this->getService()->create($formDatas);
|
||||||
}
|
}
|
||||||
final public function create(): RedirectResponse|string
|
final public function create(): RedirectResponse|string
|
||||||
{
|
{
|
||||||
$action = __FUNCTION__;
|
|
||||||
$this->getService()->getModel()->transStart();
|
$this->getService()->getModel()->transStart();
|
||||||
try {
|
try {
|
||||||
|
//각 Field 초기화
|
||||||
|
$this->initAction(__FUNCTION__);
|
||||||
//입력값정의
|
//입력값정의
|
||||||
$formDatas = [];
|
$formDatas = [];
|
||||||
foreach ($this->getFormFields() as $field) {
|
foreach ($this->getFormFields() as $field) {
|
||||||
$formDatas[] = $this->request->getVar($field);
|
$formDatas[] = $this->request->getVar($field);
|
||||||
}
|
}
|
||||||
$this->entity = $this->create_process($action, $this->getFormFields(), $formDatas);
|
$this->entity = $this->create_process($formDatas);
|
||||||
$this->getService()->getModel()->transCommit();
|
$this->getService()->getModel()->transCommit();
|
||||||
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["SUCCESS"]);
|
return $this->getResultSuccess();
|
||||||
return $this->getResultPageByActon($action);
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->getService()->getModel()->transRollback();
|
$this->getService()->getModel()->transRollback();
|
||||||
LogCollector::debug($e->getMessage());
|
return $this->getResultFail($e->getMessage());
|
||||||
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["FAILED"]);
|
|
||||||
if (env('app.debug.' . $action)) {
|
|
||||||
echo $e->getMessage();
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
return redirect()->back()->withInput()->with('error', $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//수정관련
|
//수정관련
|
||||||
final protected function modify_form_process(string $action, mixed $entity): mixed
|
protected function modify_form_process(mixed $entity): mixed
|
||||||
{
|
{
|
||||||
$this->field_rules = $this->getFieldRules($action, $this->getFormFields());
|
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
final public function modify_form(mixed $uid): RedirectResponse|string
|
final public function modify_form(mixed $uid): RedirectResponse|string
|
||||||
{
|
{
|
||||||
$action = 'modify';
|
|
||||||
try {
|
try {
|
||||||
|
//각 Field 초기화
|
||||||
|
$this->initAction(__FUNCTION__);
|
||||||
helper(['form']);
|
helper(['form']);
|
||||||
//filter_fields에 해당하는 값이 있을 경우 정의
|
//filter_fields에 해당하는 값이 있을 경우 정의
|
||||||
foreach ($this->getFilterFields() as $field) {
|
foreach ($this->getFilterFields() as $field) {
|
||||||
@ -300,108 +317,86 @@ abstract class CommonController extends BaseController
|
|||||||
}
|
}
|
||||||
//기존 Entity 가져오기
|
//기존 Entity 가져오기
|
||||||
$entity = $this->getService()->getEntity($uid);
|
$entity = $this->getService()->getEntity($uid);
|
||||||
$this->entity = $this->modify_form_process($action, $entity);
|
$this->entity = $this->modify_form_process($entity);
|
||||||
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||||
return $this->getResultPageByActon($action);
|
$this->getService()->getModel()->transCommit();
|
||||||
|
return $this->getResultSuccess();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if (env('app.debug.' . $action)) {
|
return $this->getResultFail($e->getMessage());
|
||||||
echo $e->getMessage();
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
return redirect()->back()->withInput()->with('error', $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected function modify_process(string $action, mixed $entity, array $fields, array $formDatas = []): mixed
|
protected function modify_process(mixed $entity, array $formDatas): mixed
|
||||||
{
|
{
|
||||||
$this->field_rules = $this->getFieldRules($action, $fields);
|
|
||||||
//데이터 검증
|
//데이터 검증
|
||||||
$validatedFormDatas = $this->doValidate($action, $fields, $formDatas);
|
$formDatas = $this->doValidate($this->getFieldRules(), $formDatas);
|
||||||
return $this->getService()->modify($entity, $validatedFormDatas);
|
return $this->getService()->modify($entity, $formDatas);
|
||||||
}
|
}
|
||||||
final public function modify(int $uid): RedirectResponse|string
|
final public function modify(int $uid): RedirectResponse|string
|
||||||
{
|
{
|
||||||
$action = __FUNCTION__;
|
|
||||||
//Transaction Start
|
//Transaction Start
|
||||||
$this->getService()->getModel()->transStart();
|
$this->getService()->getModel()->transStart();
|
||||||
try {
|
try {
|
||||||
|
//기존 Entity 가져오기
|
||||||
|
$entity = $this->getService()->getEntity($uid);
|
||||||
|
//각 Field 초기화
|
||||||
|
$this->initAction(__FUNCTION__);
|
||||||
//입력값정의
|
//입력값정의
|
||||||
$formDatas = [];
|
$formDatas = [];
|
||||||
foreach ($this->getFormFields() as $field) {
|
foreach ($this->getFormFields() as $field) {
|
||||||
$formDatas[] = $this->request->getVar($field);
|
$formDatas[] = $this->request->getVar($field);
|
||||||
}
|
}
|
||||||
//기존 Entity 가져오기
|
$this->entity = $this->modify_process($entity, $formDatas);
|
||||||
$entity = $this->getService()->getEntity($uid);
|
|
||||||
$this->entity = $this->modify_process($action, $entity, $this->getFormFields(), $formDatas);
|
|
||||||
$this->getService()->getModel()->transCommit();
|
$this->getService()->getModel()->transCommit();
|
||||||
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["SUCCESS"]);
|
return $this->getResultSuccess();
|
||||||
return $this->getResultPageByActon($action);
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->getService()->getModel()->transRollback();
|
$this->getService()->getModel()->transRollback();
|
||||||
LogCollector::debug($e->getMessage());
|
return $this->getResultFail($e->getMessage());
|
||||||
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["FAILED"]);
|
|
||||||
if (env('app.debug.' . $action)) {
|
|
||||||
echo $e->getMessage();
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
return redirect()->back()->withInput()->with('error', $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//단일필드작업
|
//단일필드작업
|
||||||
protected function toggle_process(string $action, mixed $entity, array $fields, array $formDatas = []): mixed
|
protected function toggle_process(mixed $entity, array $formDatas): mixed
|
||||||
{
|
{
|
||||||
$this->field_rules = $this->getFieldRules($action, $fields);
|
|
||||||
//데이터 검증
|
//데이터 검증
|
||||||
$validatedFormDatas = $this->doValidate($action, $fields, $formDatas);
|
$formDatas = $this->doValidate($this->getFieldRules(), $formDatas);
|
||||||
return $this->getService()->modify($entity, $validatedFormDatas);
|
return $this->getService()->modify($entity, $formDatas);
|
||||||
}
|
}
|
||||||
final public function toggle(mixed $uid, string $field): RedirectResponse
|
final public function toggle(mixed $uid, string $field): RedirectResponse
|
||||||
{
|
{
|
||||||
$action = __FUNCTION__;
|
|
||||||
//Transaction Start
|
//Transaction Start
|
||||||
$this->getService()->getModel()->transStart();
|
$this->getService()->getModel()->transStart();
|
||||||
try {
|
try {
|
||||||
//데이터가 있는경우 Field만 처리하기위해
|
|
||||||
$fields = [$field];
|
|
||||||
//입력값정의
|
|
||||||
$formDatas = [$this->request->getVar($field)];
|
|
||||||
//기존 Entity 가져오기
|
//기존 Entity 가져오기
|
||||||
$entity = $this->getService()->getEntity($uid);
|
$entity = $this->getService()->getEntity($uid);
|
||||||
$this->entity = $this->toggle_process($action, $entity, $fields, $formDatas);
|
//각 Field 초기화:Field는 한개만 존재하므로 Field와 Rule을 재정의
|
||||||
|
$this->setAction(__FUNCTION__);
|
||||||
|
$this->setFormFields([$field]);
|
||||||
|
$this->setFieldRule($field, $this->getFormFieldRule($this->getAction(), $field));
|
||||||
|
//입력값정의
|
||||||
|
$formDatas = [$this->request->getVar($field)];
|
||||||
|
$this->entity = $this->toggle_process($entity, $formDatas);
|
||||||
$this->getService()->getModel()->transCommit();
|
$this->getService()->getModel()->transCommit();
|
||||||
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["SUCCESS"]);
|
return $this->getResultSuccess();
|
||||||
return $this->getResultPageByActon($action);
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->getService()->getModel()->transRollback();
|
$this->getService()->getModel()->transRollback();
|
||||||
LogCollector::debug($e->getMessage());
|
return $this->getResultFail($e->getMessage());
|
||||||
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["FAILED"]);
|
|
||||||
if (env('app.debug.' . $action)) {
|
|
||||||
echo $e->getMessage();
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
return redirect()->back()->withInput()->with('error', $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//일괄처리작업
|
//일괄처리작업
|
||||||
protected function batchjob_process(string $action, mixed $entity, array $fields, array $formDatas = []): array
|
protected function batchjob_process(mixed $entity, array $formDatas): mixed
|
||||||
{
|
{
|
||||||
$this->field_rules = $this->getFieldRules($action, $fields);
|
|
||||||
//데이터 검증
|
//데이터 검증
|
||||||
$validatedFormDatas = $this->doValidate($action, $fields, $formDatas);
|
$formDatas = $this->doValidate($this->getFieldRules(), $formDatas);
|
||||||
return $this->getService()->modify($entity, $validatedFormDatas);
|
return $this->getService()->modify($entity, $formDatas);
|
||||||
}
|
}
|
||||||
final public function batchjob(): RedirectResponse
|
final public function batchjob(): RedirectResponse
|
||||||
{
|
{
|
||||||
$action = __FUNCTION__;
|
|
||||||
//Transaction Start
|
//Transaction Start
|
||||||
$this->getService()->getModel()->transStart();
|
$this->getService()->getModel()->transStart();
|
||||||
try {
|
try {
|
||||||
//데이터가 있는경우 Field만 처리하기위해
|
//변경할 FormField 정의
|
||||||
$fields = [];
|
$fields = [];
|
||||||
$formDatas = [];
|
$formDatas = [];
|
||||||
foreach ($this->getBatchJobFields() as $field) {
|
foreach ($this->getBatchjobFields() as $field) {
|
||||||
$value = $this->request->getVar($field);
|
$value = $this->request->getVar($field);
|
||||||
if ($value) {
|
if ($value) {
|
||||||
$fields[] = $field;
|
$fields[] = $field;
|
||||||
@ -411,31 +406,29 @@ abstract class CommonController extends BaseController
|
|||||||
if (!count($fields)) {
|
if (!count($fields)) {
|
||||||
throw new \Exception("변경할 정보를 선택하셔야합니다.");
|
throw new \Exception("변경할 정보를 선택하셔야합니다.");
|
||||||
}
|
}
|
||||||
//변경할 UIDS
|
//변경할 UIDS 정의
|
||||||
$uids = $this->request->getVar('batchjob_uids[]');
|
$uids = $this->request->getVar('batchjob_uids[]');
|
||||||
if (!is_array($uids) || !count($uids)) {
|
if (!is_array($uids) || !count($uids)) {
|
||||||
throw new \Exception("적용할 리스트를 선택하셔야합니다.");
|
throw new \Exception("적용할 리스트를 선택하셔야합니다.");
|
||||||
}
|
}
|
||||||
|
//각 Field 초기화:Bachjob의 데이터가 있는경우 Field만 처리하기위해 Field와 Rule을 재정의
|
||||||
|
$this->setAction(__FUNCTION__);
|
||||||
|
$this->setFormFields($fields);
|
||||||
|
foreach ($this->getFormFields() as $field) {
|
||||||
|
$this->setFieldRule($field, $this->getFormFieldRule($this->getAction(), $field));
|
||||||
|
}
|
||||||
$entities = [];
|
$entities = [];
|
||||||
foreach ($uids as $uid) {
|
foreach ($uids as $uid) {
|
||||||
//기존 Entity 가져오기
|
//기존 Entity 가져오기
|
||||||
$entity = $this->getService()->getEntity($uid);
|
$entity = $this->getService()->getEntity($uid);
|
||||||
$entities[] = $this->batchjob_process($action, $entity, $fields, $formDatas);
|
$entities[] = $this->batchjob_process($entity, $formDatas);
|
||||||
}
|
}
|
||||||
$this->entities = $entities;
|
$this->entities = $entities;
|
||||||
$this->getService()->getModel()->transCommit();
|
$this->getService()->getModel()->transCommit();
|
||||||
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["SUCCESS"]);
|
return $this->getResultSuccess();
|
||||||
return $this->getResultPageByActon($action);
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->getService()->getModel()->transRollback();
|
$this->getService()->getModel()->transRollback();
|
||||||
LogCollector::debug($e->getMessage());
|
return $this->getResultFail($e->getMessage());
|
||||||
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["FAILED"]);
|
|
||||||
if (env('app.debug.' . $action)) {
|
|
||||||
echo $e->getMessage();
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
return redirect()->back()->withInput()->with('error', $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,26 +443,19 @@ abstract class CommonController extends BaseController
|
|||||||
}
|
}
|
||||||
final public function delete(mixed $uid): RedirectResponse|string
|
final public function delete(mixed $uid): RedirectResponse|string
|
||||||
{
|
{
|
||||||
$action = __FUNCTION__;
|
|
||||||
//Transaction Start
|
//Transaction Start
|
||||||
$this->getService()->getModel()->transStart();
|
$this->getService()->getModel()->transStart();
|
||||||
try {
|
try {
|
||||||
|
//각 Field 초기화:삭제는 다른 초기화 필요없음
|
||||||
|
$this->setAction(__FUNCTION__);
|
||||||
//기존 Entity 가져오기
|
//기존 Entity 가져오기
|
||||||
$entity = $this->getService()->getEntity($uid);
|
$entity = $this->getService()->getEntity($uid);
|
||||||
$this->entity = $this->delete_process($entity);
|
$this->entity = $this->delete_process($entity);
|
||||||
$this->getService()->getModel()->transCommit();
|
$this->getService()->getModel()->transCommit();
|
||||||
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["SUCCESS"]);
|
return $this->getResultSuccess();
|
||||||
return $this->getResultPageByActon($action);
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->getService()->getModel()->transRollback();
|
$this->getService()->getModel()->transRollback();
|
||||||
LogCollector::debug($e->getMessage());
|
return $this->getResultFail($e->getMessage());
|
||||||
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["FAILED"]);
|
|
||||||
if (env('app.debug.' . $action)) {
|
|
||||||
echo $e->getMessage();
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
return redirect()->back()->withInput()->with('error', $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//일괄삭제
|
//일괄삭제
|
||||||
@ -483,7 +469,6 @@ abstract class CommonController extends BaseController
|
|||||||
}
|
}
|
||||||
final public function batchjob_delete(): RedirectResponse|string
|
final public function batchjob_delete(): RedirectResponse|string
|
||||||
{
|
{
|
||||||
$action = __FUNCTION__;
|
|
||||||
//Transaction Start
|
//Transaction Start
|
||||||
$this->getService()->getModel()->transStart();
|
$this->getService()->getModel()->transStart();
|
||||||
try {
|
try {
|
||||||
@ -492,6 +477,8 @@ abstract class CommonController extends BaseController
|
|||||||
if (!is_array($uids) || !count($uids)) {
|
if (!is_array($uids) || !count($uids)) {
|
||||||
throw new \Exception("적용할 리스트를 선택하셔야합니다.");
|
throw new \Exception("적용할 리스트를 선택하셔야합니다.");
|
||||||
}
|
}
|
||||||
|
//각 Field 초기화:삭제는 다른 초기화 필요없음
|
||||||
|
$this->setAction(__FUNCTION__);
|
||||||
$entities = [];
|
$entities = [];
|
||||||
foreach ($uids as $uid) {
|
foreach ($uids as $uid) {
|
||||||
//기존 Entity 가져오기
|
//기존 Entity 가져오기
|
||||||
@ -500,44 +487,31 @@ abstract class CommonController extends BaseController
|
|||||||
}
|
}
|
||||||
$this->entities = $entities;
|
$this->entities = $entities;
|
||||||
$this->getService()->getModel()->transCommit();
|
$this->getService()->getModel()->transCommit();
|
||||||
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["SUCCESS"]);
|
return $this->getResultSuccess();
|
||||||
return $this->getResultPageByActon($action);
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->getService()->getModel()->transRollback();
|
$this->getService()->getModel()->transRollback();
|
||||||
LogCollector::debug($e->getMessage());
|
return $this->getResultFail($e->getMessage());
|
||||||
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["FAILED"]);
|
|
||||||
if (env('app.debug.' . $action)) {
|
|
||||||
echo $e->getMessage();
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
return redirect()->back()->withInput()->with('error', $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//View
|
//View
|
||||||
protected function view_process(string $action, mixed $entity, array $fields): mixed
|
protected function view_process(mixed $entity): mixed
|
||||||
{
|
{
|
||||||
$this->field_rules = $this->getFieldRules($action, $fields);
|
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
final public function view(string $uid): RedirectResponse|string
|
final public function view(string $uid): RedirectResponse|string
|
||||||
{
|
{
|
||||||
$action = __FUNCTION__;
|
|
||||||
try {
|
try {
|
||||||
|
//각 Field 초기화
|
||||||
|
$this->initAction(__FUNCTION__);
|
||||||
helper(['form']);
|
helper(['form']);
|
||||||
//기존 Entity 가져오기
|
//기존 Entity 가져오기
|
||||||
$entity = $this->getService()->getEntity($uid);
|
$entity = $this->getService()->getEntity($uid);
|
||||||
$this->entity = $this->view_process($action, $entity, $this->getViewFields());
|
$this->entity = $this->view_process($entity);
|
||||||
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||||
return $this->getResultPageByActon($action);
|
return $this->getResultSuccess();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if (env('app.debug.index')) {
|
return $this->getResultFail($e->getMessage());
|
||||||
echo $e->getMessage();
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
return redirect()->back()->withInput()->with('error', $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -611,9 +585,8 @@ abstract class CommonController extends BaseController
|
|||||||
$this->total_page = $pager->getPageCount($pager_group);
|
$this->total_page = $pager->getPageCount($pager_group);
|
||||||
return $pager->links($pager_group, $template);
|
return $pager->links($pager_group, $template);
|
||||||
}
|
}
|
||||||
protected function index_process(string $action, array $fields): array
|
protected function index_process(): array
|
||||||
{
|
{
|
||||||
$this->field_rules = $this->getFieldRules($action, $fields);
|
|
||||||
//조건절 처리
|
//조건절 처리
|
||||||
$this->setConditionForList();
|
$this->setConditionForList();
|
||||||
//TotalCount
|
//TotalCount
|
||||||
@ -629,20 +602,16 @@ abstract class CommonController extends BaseController
|
|||||||
}
|
}
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$action = __FUNCTION__;
|
|
||||||
try {
|
try {
|
||||||
|
//각 Field 초기화
|
||||||
|
$this->initAction(__FUNCTION__);
|
||||||
// 현재 URL을 스택에 저장
|
// 현재 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() : ""));
|
||||||
helper(['form']);
|
helper(['form']);
|
||||||
$this->entities = $this->index_process($action, $this->getIndexFields());
|
$this->entities = $this->index_process();
|
||||||
return $this->getResultPageByActon($action);
|
return $this->getResultSuccess();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if (env('app.debug.' . $action)) {
|
return $this->getResultFail($e->getMessage());
|
||||||
echo $e->getMessage();
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
return redirect()->back()->withInput()->with('error', $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,15 +636,16 @@ abstract class CommonController extends BaseController
|
|||||||
// Download
|
// Download
|
||||||
final public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse
|
final public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse
|
||||||
{
|
{
|
||||||
$action = __FUNCTION__;
|
|
||||||
try {
|
try {
|
||||||
|
//각 Field 초기화
|
||||||
|
$this->initAction(__FUNCTION__);
|
||||||
//URL처리
|
//URL처리
|
||||||
// $this->uri = $this->request->getUri();
|
// $this->uri = $this->request->getUri();
|
||||||
switch ($output_type) {
|
switch ($output_type) {
|
||||||
case 'excel':
|
case 'excel':
|
||||||
case 'pdf':
|
case 'pdf':
|
||||||
// string buffer에서 읽어오는 경우
|
// string buffer에서 읽어오는 경우
|
||||||
$this->entities = $this->index_process($action, $this->getIndexFields());
|
$this->entities = $this->index_process();
|
||||||
$html = view('templates' . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR . __FUNCTION__, ['viewDatas' => $this->getViewDatas()]);
|
$html = view('templates' . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR . __FUNCTION__, ['viewDatas' => $this->getViewDatas()]);
|
||||||
//data loading
|
//data loading
|
||||||
$reader = new Html();
|
$reader = new Html();
|
||||||
@ -694,12 +664,7 @@ abstract class CommonController extends BaseController
|
|||||||
}
|
}
|
||||||
return $this->response->download($full_path, null)->setFileName($file_name);
|
return $this->response->download($full_path, null)->setFileName($file_name);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if (env('app.debug.' . $action)) {
|
return $this->getResultFail($e->getMessage());
|
||||||
echo $e->getMessage();
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
return redirect()->back()->withInput()->with('error', $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,14 +80,14 @@ abstract class CommonModel extends Model
|
|||||||
$data[8] = chr(ord($data[8]) & 0x3f | 0x80); // variant 10
|
$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));
|
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
|
||||||
}
|
}
|
||||||
final protected function getFieldRules(string $action, array $fields, $rules = []): array
|
final protected function getFormFieldRules(string $action, array $fields, $rules = []): array
|
||||||
{
|
{
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
$rules[$field] = $this->getFieldRule($action, $field);
|
$rules[$field] = $this->getFormFieldRule($action, $field);
|
||||||
}
|
}
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
public function getFieldRule(string $action, string $field): string
|
public function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
{
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||||
|
|||||||
@ -24,7 +24,7 @@ class AccountModel extends CustomerModel
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
public function getFieldRule(string $action, string $field): string
|
public function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
{
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||||
@ -40,7 +40,7 @@ class AccountModel extends CustomerModel
|
|||||||
$rule = "required|trim|string";
|
$rule = "required|trim|string";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$rule = parent::getFieldRule($action, $field);
|
$rule = parent::getFormFieldRule($action, $field);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $rule;
|
return $rule;
|
||||||
|
|||||||
@ -27,7 +27,7 @@ class ClientModel extends CustomerModel
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
public function getFieldRule(string $action, string $field): string
|
public function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
{
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||||
@ -47,7 +47,7 @@ class ClientModel extends CustomerModel
|
|||||||
$rule = "if_exist|numeric";
|
$rule = "if_exist|numeric";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$rule = parent::getFieldRule($action, $field);
|
$rule = parent::getFormFieldRule($action, $field);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $rule;
|
return $rule;
|
||||||
|
|||||||
@ -23,7 +23,7 @@ class CouponModel extends CustomerModel
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
public function getFieldRule(string $action, string $field): string
|
public function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
{
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||||
@ -38,7 +38,7 @@ class CouponModel extends CustomerModel
|
|||||||
$rule = "required|trim|string";
|
$rule = "required|trim|string";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$rule = parent::getFieldRule($action, $field);
|
$rule = parent::getFormFieldRule($action, $field);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $rule;
|
return $rule;
|
||||||
|
|||||||
@ -23,7 +23,7 @@ class PointModel extends CustomerModel
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
public function getFieldRule(string $action, string $field): string
|
public function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
{
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||||
@ -38,7 +38,7 @@ class PointModel extends CustomerModel
|
|||||||
$rule = "required|trim|string";
|
$rule = "required|trim|string";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$rule = parent::getFieldRule($action, $field);
|
$rule = parent::getFormFieldRule($action, $field);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $rule;
|
return $rule;
|
||||||
|
|||||||
@ -29,7 +29,7 @@ class ServiceItemModel extends CustomerModel
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
public function getFieldRule(string $action, string $field): string
|
public function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
{
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||||
@ -53,7 +53,7 @@ class ServiceItemModel extends CustomerModel
|
|||||||
$rule = "if_exist|valid_date";
|
$rule = "if_exist|valid_date";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$rule = parent::getFieldRule($action, $field);
|
$rule = parent::getFormFieldRule($action, $field);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $rule;
|
return $rule;
|
||||||
|
|||||||
@ -28,7 +28,7 @@ class ServiceModel extends CustomerModel
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
public function getFieldRule(string $action, string $field): string
|
public function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
{
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||||
@ -53,7 +53,7 @@ class ServiceModel extends CustomerModel
|
|||||||
$rule = "if_exist|trim|string";
|
$rule = "if_exist|trim|string";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$rule = parent::getFieldRule($action, $field);
|
$rule = parent::getFormFieldRule($action, $field);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $rule;
|
return $rule;
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class DomainModel extends EquipmentModel
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
public function getFieldRule(string $action, string $field): string
|
public function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
{
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||||
@ -38,7 +38,7 @@ class DomainModel extends EquipmentModel
|
|||||||
$rule = "required|trim|valid_domain";
|
$rule = "required|trim|valid_domain";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$rule = parent::getFieldRule($action, $field);
|
$rule = parent::getFormFieldRule($action, $field);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $rule;
|
return $rule;
|
||||||
|
|||||||
@ -21,7 +21,7 @@ class CpuModel extends PartModel
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
final public function getFieldRule(string $action, string $field): string
|
final public function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
{
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||||
@ -34,7 +34,7 @@ class CpuModel extends PartModel
|
|||||||
$rule = "required|numeric";
|
$rule = "required|numeric";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$rule = parent::getFieldRule($action, $field);
|
$rule = parent::getFormFieldRule($action, $field);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $rule;
|
return $rule;
|
||||||
|
|||||||
@ -25,7 +25,7 @@ class DefenceModel extends PartModel
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
public function getFieldRule(string $action, string $field): string
|
public function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
{
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||||
@ -42,7 +42,7 @@ class DefenceModel extends PartModel
|
|||||||
$rule = "required|numeric";
|
$rule = "required|numeric";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$rule = parent::getFieldRule($action, $field);
|
$rule = parent::getFormFieldRule($action, $field);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $rule;
|
return $rule;
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class IpModel extends PartModel
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
public function getFieldRule(string $action, string $field): string
|
public function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
{
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||||
@ -38,7 +38,7 @@ class IpModel extends PartModel
|
|||||||
$rule = "required|trim|valid_ip[both]"; //ipv4 , ipv6 , both(ipv4,ipv6)
|
$rule = "required|trim|valid_ip[both]"; //ipv4 , ipv6 , both(ipv4,ipv6)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$rule = parent::getFieldRule($action, $field);
|
$rule = parent::getFormFieldRule($action, $field);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $rule;
|
return $rule;
|
||||||
|
|||||||
@ -25,7 +25,7 @@ class LineModel extends PartModel
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
public function getFieldRule(string $action, string $field): string
|
public function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
{
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||||
@ -43,7 +43,7 @@ class LineModel extends PartModel
|
|||||||
$rule = "required|trim|string";
|
$rule = "required|trim|string";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$rule = parent::getFieldRule($action, $field);
|
$rule = parent::getFormFieldRule($action, $field);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $rule;
|
return $rule;
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class RamModel extends PartModel
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
final public function getFieldRule(string $action, string $field): string
|
final public function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
{
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||||
@ -35,7 +35,7 @@ class RamModel extends PartModel
|
|||||||
$rule = "required|numeric";
|
$rule = "required|numeric";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$rule = parent::getFieldRule($action, $field);
|
$rule = parent::getFormFieldRule($action, $field);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $rule;
|
return $rule;
|
||||||
|
|||||||
@ -23,7 +23,7 @@ class SoftwareModel extends PartModel
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
public function getFieldRule(string $action, string $field): string
|
public function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
{
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||||
@ -37,7 +37,7 @@ class SoftwareModel extends PartModel
|
|||||||
$rule = "required|numeric";
|
$rule = "required|numeric";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$rule = parent::getFieldRule($action, $field);
|
$rule = parent::getFormFieldRule($action, $field);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $rule;
|
return $rule;
|
||||||
|
|||||||
@ -21,7 +21,7 @@ class StorageModel extends PartModel
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
final public function getFieldRule(string $action, string $field): string
|
final public function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
{
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||||
@ -34,7 +34,7 @@ class StorageModel extends PartModel
|
|||||||
$rule = "required|numeric";
|
$rule = "required|numeric";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$rule = parent::getFieldRule($action, $field);
|
$rule = parent::getFormFieldRule($action, $field);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $rule;
|
return $rule;
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class ServerModel extends EquipmentModel
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
public function getFieldRule(string $action, string $field): string
|
public function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
{
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||||
@ -35,7 +35,7 @@ class ServerModel extends EquipmentModel
|
|||||||
$rule = "required|numeric";
|
$rule = "required|numeric";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$rule = parent::getFieldRule($action, $field);
|
$rule = parent::getFormFieldRule($action, $field);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $rule;
|
return $rule;
|
||||||
|
|||||||
@ -25,7 +25,7 @@ class MyLogModel extends CommonModel
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
public function getFieldRule(string $action, string $field): string
|
public function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
{
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||||
@ -35,7 +35,7 @@ class MyLogModel extends CommonModel
|
|||||||
$rule = "if_exist|numeric";
|
$rule = "if_exist|numeric";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$rule = parent::getFieldRule($action, $field);
|
$rule = parent::getFormFieldRule($action, $field);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $rule;
|
return $rule;
|
||||||
|
|||||||
@ -26,7 +26,7 @@ class UserModel extends CommonModel
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
public function getFieldRule(string $action, string $field): string
|
public function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
{
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||||
@ -50,7 +50,7 @@ class UserModel extends CommonModel
|
|||||||
$rule = "required|trim|string";
|
$rule = "required|trim|string";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$rule = parent::getFieldRule($action, $field);
|
$rule = parent::getFormFieldRule($action, $field);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $rule;
|
return $rule;
|
||||||
|
|||||||
@ -28,15 +28,7 @@ class UserSNSModel extends CommonModel
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
public function getFilterFields(): array
|
public function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
|
||||||
return ['status'];
|
|
||||||
}
|
|
||||||
public function getBatchJobFields(): array
|
|
||||||
{
|
|
||||||
return ['status'];
|
|
||||||
}
|
|
||||||
public function getFieldRule(string $action, string $field): string
|
|
||||||
{
|
{
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
case "id":
|
case "id":
|
||||||
@ -55,7 +47,7 @@ class UserSNSModel extends CommonModel
|
|||||||
$rule = "required|trim|string";
|
$rule = "required|trim|string";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$rule = parent::getFieldRule($action, $field);
|
$rule = parent::getFormFieldRule($action, $field);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $rule;
|
return $rule;
|
||||||
|
|||||||
@ -17,8 +17,8 @@ abstract class AuthService extends CommonService
|
|||||||
parent::__construct($request);
|
parent::__construct($request);
|
||||||
$this->addClassName('Auth');
|
$this->addClassName('Auth');
|
||||||
}
|
}
|
||||||
|
abstract public function login(array $formDatas): UserEntity;
|
||||||
//Index,FieldForm관련
|
//Index,FieldForm관련
|
||||||
|
|
||||||
final public function getSession(): Session
|
final public function getSession(): Session
|
||||||
{
|
{
|
||||||
if (!$this->_session) {
|
if (!$this->_session) {
|
||||||
@ -26,7 +26,6 @@ abstract class AuthService extends CommonService
|
|||||||
}
|
}
|
||||||
return $this->_session;
|
return $this->_session;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getAuthInfo(string $key = ""): array|string
|
private function getAuthInfo(string $key = ""): array|string
|
||||||
{
|
{
|
||||||
$authInfo = $this->getSession()->get(SESSION_NAMES['AUTH']);
|
$authInfo = $this->getSession()->get(SESSION_NAMES['AUTH']);
|
||||||
@ -35,45 +34,30 @@ abstract class AuthService extends CommonService
|
|||||||
}
|
}
|
||||||
return $authInfo;
|
return $authInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormFields(): array
|
public function getFormFields(): array
|
||||||
{
|
{
|
||||||
return ['id', 'passwd'];
|
return ['id', 'passwd'];
|
||||||
}
|
}
|
||||||
public function getFilterFields(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
public function getBatchJobFields(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
final public function getUIDByAuthInfo(): string
|
final public function getUIDByAuthInfo(): string
|
||||||
{
|
{
|
||||||
return $this->getAuthInfo('uid');
|
return $this->getAuthInfo('uid');
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function getIDByAuthInfo(): string
|
final public function getIDByAuthInfo(): string
|
||||||
{
|
{
|
||||||
return $this->getAuthInfo('id');
|
return $this->getAuthInfo('id');
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function getNameByAuthInfo(): string
|
final public function getNameByAuthInfo(): string
|
||||||
{
|
{
|
||||||
return $this->getAuthInfo('name');
|
return $this->getAuthInfo('name');
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function getRoleByAuthInfo(): string
|
final public function getRoleByAuthInfo(): string
|
||||||
{
|
{
|
||||||
return $this->getAuthInfo('role');
|
return $this->getAuthInfo('role');
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function isLoggedIn(): bool
|
final public function isLoggedIn(): bool
|
||||||
{
|
{
|
||||||
return $this->getSession()->has(SESSION_NAMES['ISLOGIN']);
|
return $this->getSession()->has(SESSION_NAMES['ISLOGIN']);
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function isAccessRole(array $roles): bool
|
final public function isAccessRole(array $roles): bool
|
||||||
{
|
{
|
||||||
$role = $this->getRoleByAuthInfo();
|
$role = $this->getRoleByAuthInfo();
|
||||||
@ -83,12 +67,10 @@ abstract class AuthService extends CommonService
|
|||||||
// 교집합이 없으면 false
|
// 교집합이 없으면 false
|
||||||
return !empty(array_intersect(explode(DEFAULTS['DELIMITER_ROLE'], $role), $roles));
|
return !empty(array_intersect(explode(DEFAULTS['DELIMITER_ROLE'], $role), $roles));
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function pushCurrentUrl(string $url): void
|
final public function pushCurrentUrl(string $url): void
|
||||||
{
|
{
|
||||||
$this->getSession()->set($this->url_stack_name, $url);
|
$this->getSession()->set($this->url_stack_name, $url);
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function popPreviousUrl(): string
|
final public function popPreviousUrl(): string
|
||||||
{
|
{
|
||||||
$url = $this->getSession()->get($this->url_stack_name) ?? "";
|
$url = $this->getSession()->get($this->url_stack_name) ?? "";
|
||||||
@ -98,14 +80,12 @@ abstract class AuthService extends CommonService
|
|||||||
}
|
}
|
||||||
return '/'; // 기본 URL
|
return '/'; // 기본 URL
|
||||||
}
|
}
|
||||||
|
final protected function login_process(UserEntity $entity): UserEntity
|
||||||
public function login(UserEntity $entity): UserEntity
|
|
||||||
{
|
{
|
||||||
$this->getSession()->set(SESSION_NAMES['ISLOGIN'], true);
|
$this->getSession()->set(SESSION_NAMES['ISLOGIN'], true);
|
||||||
$this->getSession()->set(SESSION_NAMES['AUTH'], ['uid' => $entity->getPK(), 'id' => $entity->getID(), 'name' => $entity->getTitle(), 'role' => $entity->role]);
|
$this->getSession()->set(SESSION_NAMES['AUTH'], ['uid' => $entity->getPK(), 'id' => $entity->getID(), 'name' => $entity->getTitle(), 'role' => $entity->role]);
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function logout(): void
|
final public function logout(): void
|
||||||
{
|
{
|
||||||
// 세션 데이터 삭제
|
// 세션 데이터 삭제
|
||||||
|
|||||||
@ -33,11 +33,26 @@ class GoogleService extends AuthService
|
|||||||
return new UserEntity();
|
return new UserEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkUser(string $access_code): UserEntity
|
public function getFormFields(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
"access_code",
|
||||||
|
];
|
||||||
|
}
|
||||||
|
public function getFilterFields(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
public function getBatchJobFields(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function login(array $formDatas): UserEntity
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// Google 서비스 설정
|
// Google 서비스 설정
|
||||||
$this->this->getMySocket()->setToken($access_code);
|
$this->getMySocket()->setToken($formDatas['access_code']);
|
||||||
$sns_entity = $this->_mySocket->signup();
|
$sns_entity = $this->_mySocket->signup();
|
||||||
// local db 사용와의 연결 확인
|
// local db 사용와의 연결 확인
|
||||||
$entity = $this->getEntity($sns_entity->getParent());
|
$entity = $this->getEntity($sns_entity->getParent());
|
||||||
|
|||||||
@ -22,14 +22,29 @@ class LocalService extends AuthService
|
|||||||
return new UserEntity();
|
return new UserEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkUser(array $formDatas): UserEntity
|
public function getFormFields(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
"id",
|
||||||
|
"passwd",
|
||||||
|
];
|
||||||
|
}
|
||||||
|
public function getFilterFields(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
public function getBatchJobFields(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function login(array $formDatas): UserEntity
|
||||||
{
|
{
|
||||||
$entity = $this->getEntity(['id' => $formDatas['id'], 'status' => DEFAULTS['STATUS']]);
|
$entity = $this->getEntity(['id' => $formDatas['id'], 'status' => DEFAULTS['STATUS']]);
|
||||||
if (!password_verify($formDatas['passwd'], $entity->getPassword())) {
|
if (!password_verify($formDatas['passwd'], $entity->getPassword())) {
|
||||||
// log_message("error", "암호: {$formDatas['passwd']}, {$entity->passwd}");
|
// log_message("error", "암호: {$formDatas['passwd']}, {$entity->passwd}");
|
||||||
throw new \Exception("암호가 맞지 않습니다.");
|
throw new \Exception("암호가 맞지 않습니다.");
|
||||||
}
|
}
|
||||||
|
return $this->login_process($entity);
|
||||||
return $entity;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,14 +84,14 @@ abstract class CommonService
|
|||||||
return $entitys;
|
return $entitys;
|
||||||
} //
|
} //
|
||||||
//FieldForm관련용
|
//FieldForm관련용
|
||||||
public function getFieldRule(string $action, string $field): string
|
public function getFormFieldRule(string $action, string $field): string
|
||||||
{
|
{
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||||
}
|
}
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
default:
|
default:
|
||||||
$rule = $this->getModel()->getFieldRule($action, $field);
|
$rule = $this->getModel()->getFormFieldRule($action, $field);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $rule;
|
return $rule;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user