From bbbdb92ccf7a90e842744500075ef80ad11a7b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Tue, 6 May 2025 19:08:29 +0900 Subject: [PATCH] dbms_init...1 --- app/Config/Constants.php | 11 --- app/Config/Routes.php | 54 ++++++++++++ .../Admin/Customer/AccountController.php | 77 ----------------- .../Admin/Customer/ClientController.php | 62 ------------- .../Admin/Customer/CouponController.php | 38 ++++++++ .../Admin/Customer/CustomerController.php | 27 +++++- .../Admin/Customer/PointController.php | 38 ++++++++ app/Controllers/Admin/MyLogController.php | 20 ++--- app/Controllers/Admin/UserController.php | 47 ++-------- app/Controllers/Auth/AuthController.php | 15 ---- app/Controllers/CommonController.php | 20 ++++- app/Database/erp2.vuerd.json | 12 +-- app/Entities/CommonEntity.php | 8 ++ app/Entities/Customer/AccountEntity.php | 17 +--- app/Entities/Customer/ClientEntity.php | 15 ++-- app/Entities/Customer/CouponEntity.php | 16 ++++ app/Entities/Customer/CustomerEntity.php | 5 ++ app/Entities/Customer/PointEntity.php | 16 ++++ app/Helpers/AuthHelper.php | 6 +- app/Helpers/CommonHelper.php | 84 ++++++++++++++++-- app/Helpers/Customer/AccountHelper.php | 86 +------------------ app/Helpers/Customer/ClientHelper.php | 47 ++++------ app/Helpers/Customer/CouponHelper.php | 16 ++++ app/Helpers/Customer/CustomerHelper.php | 28 ++++++ app/Helpers/Customer/PointHelper.php | 16 ++++ app/Helpers/MyLogHelper.php | 26 +----- app/Helpers/UserHelper.php | 66 +------------- app/Language/en/Customer/Account.php | 17 ++++ app/Language/en/Customer/Client.php | 3 + app/Language/en/Customer/Coupon.php | 16 ++++ app/Language/en/Customer/Point.php | 16 ++++ app/Language/en/User.php | 2 - .../MySocket/GoogleSocket/GoogleSocket.php | 2 +- app/Models/CommonModel.php | 8 +- app/Models/Customer/AccountModel.php | 19 ++-- app/Models/Customer/ClientModel.php | 15 +++- app/Models/Customer/CouponModel.php | 62 +++++++++++++ app/Models/Customer/PointModel.php | 62 +++++++++++++ app/Models/MyLogModel.php | 8 ++ app/Models/UserModel.php | 8 ++ app/Models/UserSNSModel.php | 8 ++ app/Services/Auth/AuthService.php | 14 ++- app/Services/Auth/GoogleService.php | 24 ++++-- app/Services/Auth/LocalService.php | 9 ++ app/Services/CommonService.php | 12 +++ app/Services/Customer/AccountService.php | 29 +------ app/Services/Customer/ClientService.php | 15 +--- app/Services/Customer/CouponService.php | 28 ++++++ app/Services/Customer/CustomerService.php | 29 +++++++ app/Services/Customer/PointService.php | 28 ++++++ app/Services/UserSNSService.php | 29 ++----- app/Services/UserService.php | 10 +-- app/Views/admin/create_form.php | 2 +- app/Views/admin/index.php | 1 + app/Views/admin/modify_form.php | 2 +- app/Views/layouts/admin/left_menu.php | 2 +- .../left_menu/{client.php => customer.php} | 13 ++- app/Views/templates/admin/index_footer.php | 1 - 58 files changed, 803 insertions(+), 564 deletions(-) create mode 100644 app/Controllers/Admin/Customer/CouponController.php create mode 100644 app/Controllers/Admin/Customer/PointController.php create mode 100644 app/Entities/Customer/CouponEntity.php create mode 100644 app/Entities/Customer/PointEntity.php create mode 100644 app/Helpers/Customer/CouponHelper.php create mode 100644 app/Helpers/Customer/PointHelper.php create mode 100644 app/Language/en/Customer/Account.php create mode 100644 app/Language/en/Customer/Coupon.php create mode 100644 app/Language/en/Customer/Point.php create mode 100644 app/Models/Customer/CouponModel.php create mode 100644 app/Models/Customer/PointModel.php create mode 100644 app/Services/Customer/CouponService.php create mode 100644 app/Services/Customer/PointService.php rename app/Views/layouts/admin/left_menu/{client.php => customer.php} (54%) diff --git a/app/Config/Constants.php b/app/Config/Constants.php index b7ca92c..7735ff8 100644 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -96,7 +96,6 @@ define('EVENT_PRIORITY_HIGH', 10); //Default값 정의 define('DEFAULTS', [ 'ROLE' => "guest", - 'STATUS' => "use", 'EMPTY' => "", 'DELIMITER_FILE' => "||", 'DELIMITER_ROLE' => ",", @@ -133,16 +132,6 @@ define('URLS', [ 'SIGNUP' => '/auth/signup', 'LOGOUT' => '/auth/logout', ]); -//회원ROLE -define('ROLES', [ - 'guest', - 'user', - 'vip', - 'manager', - 'cloudflare', - 'director', - 'master', -]); //SESSION 관련 define('SESSION_NAMES', [ 'RETURN_URL' => "return_url", diff --git a/app/Config/Routes.php b/app/Config/Routes.php index f1c911a..4925d09 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -40,4 +40,58 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au $routes->get('/', 'MyLogController::index'); $routes->get('view/(:num)', 'MyLogController::view/$1'); }); + $routes->group('customer', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) { + $routes->group('client', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) { + $routes->get('/', 'ClientController::index', []); + $routes->get('create', 'ClientController::create_form'); + $routes->post('create', 'ClientController::create'); + $routes->get('modify/(:num)', 'ClientController::modify_form/$1'); + $routes->post('modify/(:num)', 'ClientController::modify/$1'); + $routes->get('view/(:num)', 'ClientController::view/$1'); + $routes->get('delete/(:num)', 'ClientController::delete/$1'); + $routes->get('toggle/(:num)/(:any)', 'ClientController::toggle/$1/$2'); + $routes->post('batchjob', 'ClientController::batchjob'); + $routes->post('batchjob_delete', 'ClientController::batchjob_delete'); + $routes->get('download/(:alpha)', 'ClientController::download/$1'); + }); + $routes->group('account', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) { + $routes->get('/', 'AccountController::index', []); + $routes->get('create', 'AccountController::create_form'); + $routes->post('create', 'AccountController::create'); + $routes->get('modify/(:num)', 'AccountController::modify_form/$1'); + $routes->post('modify/(:num)', 'AccountController::modify/$1'); + $routes->get('view/(:num)', 'AccountController::view/$1'); + $routes->get('delete/(:num)', 'AccountController::delete/$1'); + $routes->get('toggle/(:num)/(:any)', 'AccountController::toggle/$1/$2'); + $routes->post('batchjob', 'AccountController::batchjob'); + $routes->post('batchjob_delete', 'AccountController::batchjob_delete'); + $routes->get('download/(:alpha)', 'AccountController::download/$1'); + }); + $routes->group('coupon', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) { + $routes->get('/', 'CouponController::index', []); + $routes->get('create', 'CouponController::create_form'); + $routes->post('create', 'CouponController::create'); + $routes->get('modify/(:num)', 'CouponController::modify_form/$1'); + $routes->post('modify/(:num)', 'CouponController::modify/$1'); + $routes->get('view/(:num)', 'CouponController::view/$1'); + $routes->get('delete/(:num)', 'CouponController::delete/$1'); + $routes->get('toggle/(:num)/(:any)', 'CouponController::toggle/$1/$2'); + $routes->post('batchjob', 'CouponController::batchjob'); + $routes->post('batchjob_delete', 'CouponController::batchjob_delete'); + $routes->get('download/(:alpha)', 'CouponController::download/$1'); + }); + $routes->group('point', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) { + $routes->get('/', 'PointController::index', []); + $routes->get('create', 'PointController::create_form'); + $routes->post('create', 'PointController::create'); + $routes->get('modify/(:num)', 'PointController::modify_form/$1'); + $routes->post('modify/(:num)', 'PointController::modify/$1'); + $routes->get('view/(:num)', 'PointController::view/$1'); + $routes->get('delete/(:num)', 'PointController::delete/$1'); + $routes->get('toggle/(:num)/(:any)', 'PointController::toggle/$1/$2'); + $routes->post('batchjob', 'PointController::batchjob'); + $routes->post('batchjob_delete', 'PointController::batchjob_delete'); + $routes->get('download/(:alpha)', 'PointController::download/$1'); + }); + }); }); diff --git a/app/Controllers/Admin/Customer/AccountController.php b/app/Controllers/Admin/Customer/AccountController.php index 63a5495..aac9ec8 100644 --- a/app/Controllers/Admin/Customer/AccountController.php +++ b/app/Controllers/Admin/Customer/AccountController.php @@ -5,7 +5,6 @@ namespace App\Controllers\Admin\Customer; use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; -use CodeIgniter\Validation\Validation; use Psr\Log\LoggerInterface; use App\Helpers\Customer\AccountHelper; @@ -35,81 +34,5 @@ class AccountController extends CustomerController } return $this->_helper; } - //Index,FieldForm관련 - public function getFields(): array - { - return ['id', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role', 'status']; - } - public function getFilterFields(): array - { - return ['role', 'status']; - } - public function getBatchJobFields(): array - { - return ['status']; - } - protected function setValidation(Validation $validation, string $action, string $field, ?string $rule = null): Validation - { - switch ($field) { - case 'role': - //아래 Rule Array는 필드명.* checkbox를 사용 - $validation->setRule("{$field}.*", $field, $rule); - break; - default: - $validation = parent::setValidation($validation, $action, $field, $rule); - break; - } - return $validation; - } //Index,FieldForm관련. - - protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string - { - switch ($action) { - case 'create': - case 'modify': - $url = base_url() . $this->uri_path . "view/" . $this->entity->getPK(); - $result = redirect()->to($url)->with('error', $message); - break; - default: - $result = parent::getResultPageByActon($action, $message); - break; - } - return $result; - } - - //생성 - protected function create_form_process(): void - { - $fields = [ - 'fields' => ['id', 'passwd', 'confirmpassword', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role'], - ]; - $this->init('create_form', $fields); - parent::create_form_process(); - } - protected function create_process(): mixed - { - $fields = [ - 'fields' => ['id', 'passwd', 'confirmpassword', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role'], - ]; - $this->init('create', $fields); - return parent::create_process(); - } - //수정 - protected function modify_form_process(mixed $uid): mixed - { - $fields = [ - 'fields' => ['id', 'passwd', 'confirmpassword', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role'], - ]; - $this->init('modify_form', $fields); - return parent::modify_form_process($uid); - } - protected function modify_process($uid): mixed - { - $fields = [ - 'fields' => ['id', 'passwd', 'confirmpassword', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role', 'status'], - ]; - $this->init('modify', $fields); - return parent::modify_process($uid); - } } diff --git a/app/Controllers/Admin/Customer/ClientController.php b/app/Controllers/Admin/Customer/ClientController.php index 83c45e5..9aa4dce 100644 --- a/app/Controllers/Admin/Customer/ClientController.php +++ b/app/Controllers/Admin/Customer/ClientController.php @@ -37,18 +37,6 @@ class ClientController extends CustomerController return $this->_helper; } //Index,FieldForm관련 - public function getFields(): array - { - return ['id', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role', 'status']; - } - public function getFilterFields(): array - { - return ['role', 'status']; - } - public function getBatchJobFields(): array - { - return ['status']; - } protected function setValidation(Validation $validation, string $action, string $field, ?string $rule = null): Validation { switch ($field) { @@ -63,54 +51,4 @@ class ClientController extends CustomerController return $validation; } //Index,FieldForm관련. - - protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string - { - switch ($action) { - case 'create': - case 'modify': - $url = base_url() . $this->uri_path . "view/" . $this->entity->getPK(); - $result = redirect()->to($url)->with('error', $message); - break; - default: - $result = parent::getResultPageByActon($action, $message); - break; - } - return $result; - } - - //생성 - protected function create_form_process(): void - { - $fields = [ - 'fields' => ['id', 'passwd', 'confirmpassword', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role'], - ]; - $this->init('create_form', $fields); - parent::create_form_process(); - } - protected function create_process(): mixed - { - $fields = [ - 'fields' => ['id', 'passwd', 'confirmpassword', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role'], - ]; - $this->init('create', $fields); - return parent::create_process(); - } - //수정 - protected function modify_form_process(mixed $uid): mixed - { - $fields = [ - 'fields' => ['id', 'passwd', 'confirmpassword', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role'], - ]; - $this->init('modify_form', $fields); - return parent::modify_form_process($uid); - } - protected function modify_process($uid): mixed - { - $fields = [ - 'fields' => ['id', 'passwd', 'confirmpassword', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role', 'status'], - ]; - $this->init('modify', $fields); - return parent::modify_process($uid); - } } diff --git a/app/Controllers/Admin/Customer/CouponController.php b/app/Controllers/Admin/Customer/CouponController.php new file mode 100644 index 0000000..821785e --- /dev/null +++ b/app/Controllers/Admin/Customer/CouponController.php @@ -0,0 +1,38 @@ +uri_path .= strtolower($this->getService()->getClassName()) . '/'; + $this->class_path = $this->getService()->getClassPath(); + $this->title = lang("{$this->getService()->getClassPath()}.title"); + $this->helper = $this->getHelper(); + } + public function getService(): CouponService + { + if (!$this->_service) { + $this->_service = new CouponService($this->request); + } + return $this->_service; + } + public function getHelper(): mixed + { + if (!$this->_helper) { + $this->_helper = new CouponHelper($this->request); + } + return $this->_helper; + } + //Index,FieldForm관련. +} diff --git a/app/Controllers/Admin/Customer/CustomerController.php b/app/Controllers/Admin/Customer/CustomerController.php index 6dc8f23..bc11d9e 100644 --- a/app/Controllers/Admin/Customer/CustomerController.php +++ b/app/Controllers/Admin/Customer/CustomerController.php @@ -6,14 +6,39 @@ use App\Controllers\Admin\AdminController; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; +use App\Services\Customer\ClientService; abstract class CustomerController extends AdminController { + private $_clientrService = null; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); $this->uri_path .= 'customer/'; $this->uri_path .= "customer/"; - $this->view_path .= "customer" . DIRECTORY_SEPARATOR; + // $this->view_path .= "customer" . DIRECTORY_SEPARATOR; } + final public function getClientService(): ClientService + { + if (!$this->_clientrService) { + $this->_clientrService = new ClientService($this->request); + } + return $this->_clientrService; + } + //Index,FieldForm관련 + protected function getFormFieldOption(string $field, array $options = []): array + { + switch ($field) { + case 'clientinfo_uid': + $options[$field] = $this->getClientService()->getFormFieldOption($field); + // echo $this->getUserModel()->getLastQuery(); + // dd($options); + break; + default: + $options = parent::getFormFieldOption($field, $options); + break; + } + return $options; + } + //Index,FieldForm관련 } diff --git a/app/Controllers/Admin/Customer/PointController.php b/app/Controllers/Admin/Customer/PointController.php new file mode 100644 index 0000000..4c00fea --- /dev/null +++ b/app/Controllers/Admin/Customer/PointController.php @@ -0,0 +1,38 @@ +uri_path .= strtolower($this->getService()->getClassName()) . '/'; + $this->class_path = $this->getService()->getClassPath(); + $this->title = lang("{$this->getService()->getClassPath()}.title"); + $this->helper = $this->getHelper(); + } + public function getService(): PointService + { + if (!$this->_service) { + $this->_service = new PointService($this->request); + } + return $this->_service; + } + public function getHelper(): mixed + { + if (!$this->_helper) { + $this->_helper = new PointHelper($this->request); + } + return $this->_helper; + } + //Index,FieldForm관련. +} diff --git a/app/Controllers/Admin/MyLogController.php b/app/Controllers/Admin/MyLogController.php index cd94fa2..b3f21b2 100644 --- a/app/Controllers/Admin/MyLogController.php +++ b/app/Controllers/Admin/MyLogController.php @@ -45,18 +45,6 @@ class MyLogController extends AdminController return $this->_userService; } //Index,FieldForm관련 - public function getFields(): array - { - return ['class_name', 'method_name', $this->getService()->getModel()::TITLE, 'user_uid', 'status']; - } - public function getFilterFields(): array - { - return ['user_uid', 'status']; - } - public function getBatchJobFields(): array - { - return []; - } protected function getFormFieldOption(string $field, array $options = []): array { switch ($field) { @@ -83,4 +71,12 @@ class MyLogController extends AdminController $this->init('view', $fields); return parent::view_process($uid); } + protected function index_process(): array + { + $fields = [ + 'fields' => ['user_uid', 'class_name', 'method_name', $this->getService()->getModel()::TITLE, 'status', 'created_at'], + ]; + $this->init('index', $fields); + return parent::index_process(); + } } diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php index cf52e65..166bcdb 100644 --- a/app/Controllers/Admin/UserController.php +++ b/app/Controllers/Admin/UserController.php @@ -39,18 +39,6 @@ class UserController extends AdminController return $this->_helper; } //Index,FieldForm관련 - public function getFields(): array - { - return ['id', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role', 'status']; - } - public function getFilterFields(): array - { - return ['role', 'status']; - } - public function getBatchJobFields(): array - { - return ['status']; - } protected function setValidation(Validation $validation, string $action, string $field, ?string $rule = null): Validation { switch ($field) { @@ -81,38 +69,21 @@ class UserController extends AdminController return $result; } - //생성 - protected function create_form_process(): void + //View관련 + protected function view_process($uid): mixed { $fields = [ - 'fields' => ['id', 'passwd', 'confirmpassword', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role'], + 'fields' => ['id', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role', 'status'], ]; - $this->init('create_form', $fields); - parent::create_form_process(); + $this->init('view', $fields); + return parent::view_process($uid); } - protected function create_process(): mixed + protected function index_process(): array { $fields = [ - 'fields' => ['id', 'passwd', 'confirmpassword', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role'], + 'fields' => ['id', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role', 'status'], ]; - $this->init('create', $fields); - return parent::create_process(); - } - //수정 - protected function modify_form_process(mixed $uid): mixed - { - $fields = [ - 'fields' => ['id', 'passwd', 'confirmpassword', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role'], - ]; - $this->init('modify_form', $fields); - return parent::modify_form_process($uid); - } - protected function modify_process($uid): mixed - { - $fields = [ - 'fields' => ['id', 'passwd', 'confirmpassword', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role', 'status'], - ]; - $this->init('modify', $fields); - return parent::modify_process($uid); + $this->init('index', $fields); + return parent::index_process(); } } diff --git a/app/Controllers/Auth/AuthController.php b/app/Controllers/Auth/AuthController.php index 1b8642d..0c4c81c 100644 --- a/app/Controllers/Auth/AuthController.php +++ b/app/Controllers/Auth/AuthController.php @@ -34,21 +34,6 @@ abstract class AuthController extends CommonController return $this->_helper; } - //Index,FieldForm관련 - public function getFields(): array - { - return ['id', 'passwd']; - } - public function getFilterFields(): array - { - return ['role', 'status']; - } - public function getBatchJobFields(): array - { - return ['status']; - } - //Index,FieldForm관련 - protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string { switch ($action) { diff --git a/app/Controllers/CommonController.php b/app/Controllers/CommonController.php index fcc8ac8..93edf19 100644 --- a/app/Controllers/CommonController.php +++ b/app/Controllers/CommonController.php @@ -25,9 +25,6 @@ abstract class CommonController extends BaseController private $_viewDatas = []; abstract public function getService(): mixed; abstract function getHelper(): mixed; - abstract public function getFields(): array; - abstract public function getFilterFields(): array; - abstract public function getBatchJobFields(): array; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); @@ -77,6 +74,18 @@ abstract class CommonController extends BaseController $this->field_options = array_key_exists('field_options', $fields) && is_array($fields['field_optionss']) && count($fields['field_options']) ? $fields['field_options'] : $this->getFormFieldOptions($this->filter_fields); $this->batchjob_fields = array_key_exists('batchjob_fields', $fields) && is_array($fields['batchjob_fields']) && count($fields['batchjob_fields']) ? $fields['filter_fields'] : $this->getBatchJobFields(); } + public function getFields(): array + { + return $this->getService()->getFields(); + } + public function getFilterFields(): array + { + return $this->getService()->getFilterFields(); + } + public function getBatchJobFields(): array + { + return $this->getService()->getBatchJobFields(); + } protected function getFieldRule(string $action, string $field): string { if (is_array($field)) { @@ -148,6 +157,11 @@ abstract class CommonController extends BaseController protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string { switch ($action) { + case 'create': + case 'modify': + $this->getHelper()->setViewDatas($this->getViewDatas()); + $result = view($this->view_path . 'view', ['viewDatas' => $this->getViewDatas()]);; + break; case 'create_form': case 'modify_form': case 'index': diff --git a/app/Database/erp2.vuerd.json b/app/Database/erp2.vuerd.json index c5e7b15..dc7191f 100644 --- a/app/Database/erp2.vuerd.json +++ b/app/Database/erp2.vuerd.json @@ -4,13 +4,13 @@ "settings": { "width": 4000, "height": 4000, - "scrollTop": -200, - "scrollLeft": -790.4997, + "scrollTop": -100, + "scrollLeft": -867.7529, "zoomLevel": 0.82, "show": 431, "database": 4, "databaseName": "", - "canvasType": "ERD", + "canvasType": "@dineug/erd-editor/builtin-schema-sql", "language": 1, "tableNameCase": 4, "columnNameCase": 2, @@ -4224,7 +4224,7 @@ "3jtklRjnxzZANo69T6vWW": { "id": "3jtklRjnxzZANo69T6vWW", "tableId": "jO40Ej5EXImXnadoJo9bn", - "name": "quantity", + "name": "amount", "comment": "", "dataType": "INT", "default": "", @@ -4237,7 +4237,7 @@ "widthDefault": 60 }, "meta": { - "updateAt": 1745914595560, + "updateAt": 1746511104589, "createAt": 1745914576666 } }, @@ -5954,7 +5954,7 @@ 1745914576665, -1, { - "name": 1745914587515, + "name": 1746511104588, "dataType": 1745914593550, "options(notNull)": 1745914595560 } diff --git a/app/Entities/CommonEntity.php b/app/Entities/CommonEntity.php index 6d0c634..ae45b2e 100644 --- a/app/Entities/CommonEntity.php +++ b/app/Entities/CommonEntity.php @@ -36,4 +36,12 @@ abstract class CommonEntity extends Entity return $this->attributes['created_at']; } //공통부분 + final public function isMatched(string $field, string $value): bool + { + return $this->attributes[$field] == $value; + } + public function getStatus(): string|null + { + return $this->attributes['status'] ?? null; + } } diff --git a/app/Entities/Customer/AccountEntity.php b/app/Entities/Customer/AccountEntity.php index aa478a9..1b3630e 100644 --- a/app/Entities/Customer/AccountEntity.php +++ b/app/Entities/Customer/AccountEntity.php @@ -2,24 +2,15 @@ namespace App\Entities\Customer; -use App\Entities\CommonEntity; use App\Models\Customer\AccountModel; -class AccountEntity extends CommonEntity +class AccountEntity extends CustomerEntity { - const PK = AccountModel::PK; + const PK = AccountModel::PK; const TITLE = AccountModel::TITLE; - public function getClient() + public function getAmount() { - return $this->attributes['clientinfo_uid']; - } - public function getCoupon() - { - return $this->attributes['coupon_balance']; - } - public function getPoint() - { - return $this->attributes['point_balance']; + return $this->attributes['amount']; } } diff --git a/app/Entities/Customer/ClientEntity.php b/app/Entities/Customer/ClientEntity.php index 49f2bff..9194cde 100644 --- a/app/Entities/Customer/ClientEntity.php +++ b/app/Entities/Customer/ClientEntity.php @@ -2,28 +2,31 @@ namespace App\Entities\Customer; -use App\Entities\CommonEntity; use App\Models\Customer\ClientModel; -class ClientEntity extends CommonEntity +class ClientEntity extends CustomerEntity { const PK = ClientModel::PK; const TITLE = ClientModel::TITLE; + + public function getClient() + { + return $this->attributes[self::PK]; + } public function getRole(): string { return $this->attributes['role']; } - - public function getAccount() + public function getAccount(): int { return $this->attributes['account_balance']; } - public function getCoupon() + public function getCoupon(): int { return $this->attributes['coupon_balance']; } - public function getPoint() + public function getPoint(): int { return $this->attributes['point_balance']; } diff --git a/app/Entities/Customer/CouponEntity.php b/app/Entities/Customer/CouponEntity.php new file mode 100644 index 0000000..15f9d3b --- /dev/null +++ b/app/Entities/Customer/CouponEntity.php @@ -0,0 +1,16 @@ +attributes['amount']; + } +} diff --git a/app/Entities/Customer/CustomerEntity.php b/app/Entities/Customer/CustomerEntity.php index bea2a44..4ddb392 100644 --- a/app/Entities/Customer/CustomerEntity.php +++ b/app/Entities/Customer/CustomerEntity.php @@ -10,4 +10,9 @@ abstract class CustomerEntity extends CommonEntity { parent::__construct($data); } + + public function getClient() + { + return $this->attributes['clientinfo_uid']; + } } diff --git a/app/Entities/Customer/PointEntity.php b/app/Entities/Customer/PointEntity.php new file mode 100644 index 0000000..f63d43e --- /dev/null +++ b/app/Entities/Customer/PointEntity.php @@ -0,0 +1,16 @@ +attributes['amount']; + } +} diff --git a/app/Helpers/AuthHelper.php b/app/Helpers/AuthHelper.php index 1c6ffe7..dca1b01 100644 --- a/app/Helpers/AuthHelper.php +++ b/app/Helpers/AuthHelper.php @@ -3,7 +3,7 @@ namespace App\Helpers; use CodeIgniter\HTTP\IncomingRequest; -use App\Models\UserModel as Model; +use App\Models\UserModel; class AuthHelper extends CommonHelper { @@ -11,6 +11,7 @@ class AuthHelper extends CommonHelper public function __construct(?IncomingRequest $request = null) { parent::__construct($request); + $this->setTitleField(UserModel::TITLE); } public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string { @@ -20,9 +21,6 @@ class AuthHelper extends CommonHelper $value = $value ?: DEFAULTS['EMPTY']; switch ($field) { case 'id': - case Model::TITLE: - $form = form_input($field, $value, $extras); - break; case 'passwd': $form = form_password($field, "", ["autocomplete" => $field, ...$extras]); break; diff --git a/app/Helpers/CommonHelper.php b/app/Helpers/CommonHelper.php index e5b2a76..9e60161 100644 --- a/app/Helpers/CommonHelper.php +++ b/app/Helpers/CommonHelper.php @@ -6,12 +6,24 @@ use CodeIgniter\HTTP\IncomingRequest; class CommonHelper { - protected ?IncomingRequest $request = null; private $_viewDatas = []; + private $_titleField = ""; + protected ?IncomingRequest $request = null; public function __construct(?IncomingRequest $request = null) { $this->request = $request; } + final public function setTitleField(string $field): void + { + $this->_titleField = $field; + } + final public function getTitleField(): string + { + if (!$this->_titleField) { + throw new \Exception("titleField가 지정되지 않았습니다."); + } + return $this->_titleField; + } final public function setViewDatas(array $viewDatas): void { $this->_viewDatas = $viewDatas; @@ -174,10 +186,43 @@ class CommonHelper } $value = $value ?: DEFAULTS['EMPTY']; switch ($field) { + case 'email': + $form = form_input($field, $value, ["placeholder" => "예)test@example.com", ...$extras]); + break; + case 'mobile': + case 'phone': + $form = form_input($field, $value, ["placeholder" => "예)010-0010-0010", ...$extras]); + break; + case 'role': + if (!is_array($viewDatas['field_options'][$field])) { + echo var_dump($viewDatas['field_options']); + exit; + } + if (in_array($viewDatas['action'], ['create_form', 'modify_form'])) { + $forms = []; + foreach ($viewDatas['field_options'][$field] as $key => $label) { + $values = is_array($value) ? $value : explode(DEFAULTS["DELIMITER_ROLE"], $value); + $forms[] = form_checkbox("{$field}[]", $key, in_array($key, $values)) . $label; + } + $form = implode(" ", $forms); + } else { + $formOptions = array_merge( + ["" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택'], + $viewDatas['field_options'][$field] + ); + $form = form_dropdown($field, $formOptions, $value, $extras); + } + break; case 'status': - $form = form_dropdown($field, [ - "" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택', - ] + $viewDatas['field_options'][$field], $value, $extras); + if (!is_array($viewDatas['field_options'][$field])) { + echo var_dump($viewDatas['field_options']); + exit; + } + $formOptions = array_merge( + ["" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택'], + $viewDatas['field_options'][$field] + ); + $form = form_dropdown($field, $formOptions, $value, $extras); break; case 'updated_at': case 'created_at': @@ -195,6 +240,19 @@ class CommonHelper { $value = $viewDatas['entity']->$field ?: DEFAULTS['EMPTY']; switch ($field) { + case $this->getTitleField(): + $value = form_label( + $value, + 'view', + [ + "data-src" => current_url() . '/view/' . $viewDatas['entity']->getPK(), + "data-bs-toggle" => "modal", + "data-bs-target" => "#index_action_form", + "style" => "color: blue; cursor: pointer; font-weight:bold;", + ...$extras, + ] + ); + break; case 'category_uid': foreach (array_values($viewDatas['field_options'][$field]) as $category_2depths) { foreach ($category_2depths as $key => $depth) { @@ -204,6 +262,20 @@ class CommonHelper } } break; + case 'user_uid': + $user_uids = []; + foreach (explode(DEFAULTS["DELIMITER_ROLE"], $value) as $key) { + $user_uids[] = $viewDatas['field_options'][$field][$key]; + } + $value = implode(" , ", array: $user_uids); + break; + case 'role': + $roles = []; + foreach (explode(DEFAULTS["DELIMITER_ROLE"], $value) as $key) { + $roles[] = $viewDatas['field_options'][$field][$key]; + } + $value = implode(" , ", $roles); + break; case 'updated_at': case 'created_at': $value = $value ? date("Y-m-d", strtotime($value)) : ""; @@ -224,9 +296,9 @@ class CommonHelper return $value; } - public function getListRowColor($entity): string + public function getListRowColor(mixed $entity, string $field = 'status', string $value = 'use'): string { - return $entity->status != DEFAULTS['STATUS'] ? 'class="table-danger"' : ""; + return $entity->isMatched($field, $value) ? "" : 'class="table-danger"'; } public function getListLabel(string $field, array $viewDatas, array $extras = []): string diff --git a/app/Helpers/Customer/AccountHelper.php b/app/Helpers/Customer/AccountHelper.php index d90a91a..aa5d47f 100644 --- a/app/Helpers/Customer/AccountHelper.php +++ b/app/Helpers/Customer/AccountHelper.php @@ -2,95 +2,15 @@ namespace App\Helpers\Customer; -use App\Helpers\CommonHelper; -use App\Models\UserModel as Model; +use App\Models\Customer\AccountModel; use CodeIgniter\HTTP\IncomingRequest; -class AccountHelper extends CommonHelper +class AccountHelper extends CustomerHelper { protected ?IncomingRequest $request = null; public function __construct(?IncomingRequest $request = null) { parent::__construct($request); + $this->setTitleField(AccountModel::TITLE); } - public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string - { - if (in_array($viewDatas['action'], ['create', 'modify'])) { - $extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras]; - } - $value = $value ?: DEFAULTS['EMPTY']; - switch ($field) { - case 'id': - case Model::TITLE: - $form = form_input($field, $value, $extras); - break; - case 'passwd': - case 'confirmpassword': - $form = form_password($field, "", ["autocomplete" => $field, ...$extras]); - break; - case 'email': - $form = form_input($field, $value, ["placeholder" => "예)test@example.com", ...$extras]); - break; - case 'mobile': - $form = form_input($field, $value, ["placeholder" => "예)010-0010-0010", ...$extras]); - break; - case 'role': - if (in_array($viewDatas['action'], ['create_form', 'modify_form'])) { - $forms = []; - foreach ($viewDatas['field_options'][$field] as $key => $label) { - $values = is_array($value) ? $value : explode(DEFAULTS["DELIMITER_ROLE"], $value); - $forms[] = form_checkbox( - "{$field}[]", - $key, - in_array($key, $values) - ) . $label; - } - $form = implode(" ", $forms); - } else { - $form = form_dropdown( - $field, - [ - "" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택', - ] + $viewDatas['field_options'][$field], - $value, - $extras - ); - } - break; - default: - $form = parent::getFieldForm($field, $value, $viewDatas, $extras); - break; - } - return $form; - } // - public function getFieldView(string $field, array $viewDatas, array $extras = []): string - { - $value = $viewDatas['entity']->$field ?: DEFAULTS['EMPTY']; - switch ($field) { - case Model::TITLE: - $value = form_label( - $value, - 'view', - [ - "data-src" => current_url() . '/view/' . $viewDatas['entity']->getPK(), - "data-bs-toggle" => "modal", - "data-bs-target" => "#index_action_form", - "style" => "color: blue; cursor: pointer; font-weight:bold;", - ...$extras, - ] - ); - break; - case 'role': - $roles = []; - foreach (explode(DEFAULTS["DELIMITER_ROLE"], $value) as $key) { - $roles[] = $viewDatas['field_options'][$field][$key]; - } - $value = implode(" , ", $roles); - break; - default: - $value = parent::getFieldView($field, $viewDatas, $extras); - break; - } - return $value; - } // } diff --git a/app/Helpers/Customer/ClientHelper.php b/app/Helpers/Customer/ClientHelper.php index 4b3ad62..eb8946c 100644 --- a/app/Helpers/Customer/ClientHelper.php +++ b/app/Helpers/Customer/ClientHelper.php @@ -2,16 +2,16 @@ namespace App\Helpers\Customer; -use App\Helpers\CommonHelper; use App\Models\Customer\ClientModel; use CodeIgniter\HTTP\IncomingRequest; -class ClientHelper extends CommonHelper +class ClientHelper extends CustomerHelper { protected ?IncomingRequest $request = null; public function __construct(?IncomingRequest $request = null) { parent::__construct($request); + $this->setTitleField(ClientModel::TITLE); } public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string { @@ -20,10 +20,6 @@ class ClientHelper extends CommonHelper } $value = $value ?: DEFAULTS['EMPTY']; switch ($field) { - case 'id': - case ClientModel::TITLE: - $form = form_input($field, $value, $extras); - break; case 'email': $form = form_input($field, $value, ["placeholder" => "예)test@example.com", ...$extras]); break; @@ -31,26 +27,23 @@ class ClientHelper extends CommonHelper $form = form_input($field, $value, ["placeholder" => "예)010-0010-0010", ...$extras]); break; case 'role': + if (!is_array($viewDatas['field_options'][$field])) { + echo var_dump($viewDatas['field_options']); + exit; + } if (in_array($viewDatas['action'], ['create_form', 'modify_form'])) { $forms = []; foreach ($viewDatas['field_options'][$field] as $key => $label) { $values = is_array($value) ? $value : explode(DEFAULTS["DELIMITER_ROLE"], $value); - $forms[] = form_checkbox( - "{$field}[]", - $key, - in_array($key, $values) - ) . $label; + $forms[] = form_checkbox("{$field}[]", $key, in_array($key, $values)) . $label; } $form = implode(" ", $forms); } else { - $form = form_dropdown( - $field, - [ - "" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택', - ] + $viewDatas['field_options'][$field], - $value, - $extras + $formOptions = array_merge( + ["" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택'], + $viewDatas['field_options'][$field] ); + $form = form_dropdown($field, $formOptions, $value, $extras); } break; default: @@ -63,19 +56,6 @@ class ClientHelper extends CommonHelper { $value = $viewDatas['entity']->$field ?: DEFAULTS['EMPTY']; switch ($field) { - case ClientModel::TITLE: - $value = form_label( - $value, - 'view', - [ - "data-src" => current_url() . '/view/' . $viewDatas['entity']->getPK(), - "data-bs-toggle" => "modal", - "data-bs-target" => "#index_action_form", - "style" => "color: blue; cursor: pointer; font-weight:bold;", - ...$extras, - ] - ); - break; case 'role': $roles = []; foreach (explode(DEFAULTS["DELIMITER_ROLE"], $value) as $key) { @@ -83,6 +63,11 @@ class ClientHelper extends CommonHelper } $value = implode(" , ", $roles); break; + case 'account_balance': + case 'coupon_balance': + case 'point_balance': + $value = number_format($value); + break; default: $value = parent::getFieldView($field, $viewDatas, $extras); break; diff --git a/app/Helpers/Customer/CouponHelper.php b/app/Helpers/Customer/CouponHelper.php new file mode 100644 index 0000000..ec87cd0 --- /dev/null +++ b/app/Helpers/Customer/CouponHelper.php @@ -0,0 +1,16 @@ +setTitleField(CouponModel::TITLE); + } +} diff --git a/app/Helpers/Customer/CustomerHelper.php b/app/Helpers/Customer/CustomerHelper.php index 91a6a4e..ea8aa04 100644 --- a/app/Helpers/Customer/CustomerHelper.php +++ b/app/Helpers/Customer/CustomerHelper.php @@ -11,4 +11,32 @@ class CustomerHelper extends CommonHelper { parent::__construct($request); } + public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string + { + if (in_array($viewDatas['action'], ['create', 'modify'])) { + $extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras]; + } + $value = $value ?: DEFAULTS['EMPTY']; + switch ($field) { + case "clientinfo_uid": + if (!is_array($viewDatas['field_options'][$field])) { + echo var_dump($viewDatas['field_options']); + exit; + } + $formOptions = array_merge( + ["" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택'], + $viewDatas['field_options'][$field] + ); + $form = form_dropdown($field, $formOptions, $value, $extras); + break; + default: + $form = parent::getFieldForm($field, $value, $viewDatas, $extras); + break; + } + return $form; + } // + public function getListRowColor(mixed $entity, string $field = 'status', string $value = 'in'): string + { + return $entity->isMatched($field, $value) ? "" : 'class="table-danger"'; + } } diff --git a/app/Helpers/Customer/PointHelper.php b/app/Helpers/Customer/PointHelper.php new file mode 100644 index 0000000..e297f66 --- /dev/null +++ b/app/Helpers/Customer/PointHelper.php @@ -0,0 +1,16 @@ +setTitleField(field: PointModel::TITLE); + } +} diff --git a/app/Helpers/MyLogHelper.php b/app/Helpers/MyLogHelper.php index e394918..a615c34 100644 --- a/app/Helpers/MyLogHelper.php +++ b/app/Helpers/MyLogHelper.php @@ -3,7 +3,7 @@ namespace App\Helpers; use CodeIgniter\HTTP\IncomingRequest; -use App\Models\MyLogModel as Model; +use App\Models\MyLogModel; class MyLogHelper extends CommonHelper { @@ -11,38 +11,16 @@ class MyLogHelper extends CommonHelper public function __construct(?IncomingRequest $request = null) { parent::__construct($request); + $this->setTitleField(MyLogModel::TITLE); } public function getFieldView(string $field, array $viewDatas, array $extras = []): string { $value = $viewDatas['entity']->$field ?: DEFAULTS['EMPTY']; switch ($field) { - case Model::TITLE: - $value = form_label( - $value, - 'view', - [ - "data-src" => current_url() . '/view/' . $viewDatas['entity']->getPK(), - "data-bs-toggle" => "modal", - "data-bs-target" => "#index_action_form", - "style" => "color: blue; cursor: pointer; font-weight:bold;", - ...$extras, - ] - ); - break; - case 'user_uid': - $user_uids = []; - foreach (explode(DEFAULTS["DELIMITER_ROLE"], $value) as $key) { - $user_uids[] = $viewDatas['field_options'][$field][$key]; - } - $value = implode(" , ", array: $user_uids); - break; case 'content': $value = nl2br($value); break; - case 'status': - $value = $viewDatas['field_options'][$field][$value]; - break; default: $value = parent::getFieldView($field, $viewDatas, $extras); break; diff --git a/app/Helpers/UserHelper.php b/app/Helpers/UserHelper.php index 6017cb3..d2e4318 100644 --- a/app/Helpers/UserHelper.php +++ b/app/Helpers/UserHelper.php @@ -3,7 +3,7 @@ namespace App\Helpers; use CodeIgniter\HTTP\IncomingRequest; -use App\Models\UserModel as Model; +use App\Models\UserModel; class UserHelper extends CommonHelper { @@ -11,6 +11,7 @@ class UserHelper extends CommonHelper public function __construct(?IncomingRequest $request = null) { parent::__construct($request); + $this->setTitleField(UserModel::TITLE); } public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string { @@ -19,77 +20,14 @@ class UserHelper extends CommonHelper } $value = $value ?: DEFAULTS['EMPTY']; switch ($field) { - case 'id': - case Model::TITLE: - $form = form_input($field, $value, $extras); - break; case 'passwd': case 'confirmpassword': $form = form_password($field, "", ["autocomplete" => $field, ...$extras]); break; - case 'email': - $form = form_input($field, $value, ["placeholder" => "예)test@example.com", ...$extras]); - break; - case 'mobile': - $form = form_input($field, $value, ["placeholder" => "예)010-0010-0010", ...$extras]); - break; - case 'role': - if (in_array($viewDatas['action'], ['create_form', 'modify_form'])) { - $forms = []; - foreach ($viewDatas['field_options'][$field] as $key => $label) { - $values = is_array($value) ? $value : explode(DEFAULTS["DELIMITER_ROLE"], $value); - $forms[] = form_checkbox( - "{$field}[]", - $key, - in_array($key, $values) - ) . $label; - } - $form = implode(" ", $forms); - } else { - $form = form_dropdown( - $field, - [ - "" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택', - ] + $viewDatas['field_options'][$field], - $value, - $extras - ); - } - break; default: $form = parent::getFieldForm($field, $value, $viewDatas, $extras); break; } return $form; } // - public function getFieldView(string $field, array $viewDatas, array $extras = []): string - { - $value = $viewDatas['entity']->$field ?: DEFAULTS['EMPTY']; - switch ($field) { - case Model::TITLE: - $value = form_label( - $value, - 'view', - [ - "data-src" => current_url() . '/view/' . $viewDatas['entity']->getPK(), - "data-bs-toggle" => "modal", - "data-bs-target" => "#index_action_form", - "style" => "color: blue; cursor: pointer; font-weight:bold;", - ...$extras, - ] - ); - break; - case 'role': - $roles = []; - foreach (explode(DEFAULTS["DELIMITER_ROLE"], $value) as $key) { - $roles[] = $viewDatas['field_options'][$field][$key]; - } - $value = implode(" , ", $roles); - break; - default: - $value = parent::getFieldView($field, $viewDatas, $extras); - break; - } - return $value; - } // } diff --git a/app/Language/en/Customer/Account.php b/app/Language/en/Customer/Account.php new file mode 100644 index 0000000..2c131cc --- /dev/null +++ b/app/Language/en/Customer/Account.php @@ -0,0 +1,17 @@ + "고객예치금", + 'label' => [ + 'clientinfo_uid' => "고객명", + 'title' => "제목", + 'alias' => "입/출금자명", + 'amount' => "금액", + 'status' => "입/출금", + 'updated_at' => "수정일", + 'created_at' => "작성일", + ], + "STATUS" => [ + "in" => "입금", + "out" => "출금", + ], +]; diff --git a/app/Language/en/Customer/Client.php b/app/Language/en/Customer/Client.php index 24fc24b..8ce5c1f 100644 --- a/app/Language/en/Customer/Client.php +++ b/app/Language/en/Customer/Client.php @@ -6,6 +6,9 @@ return [ 'phone' => "연락처", 'role' => "권한", 'name' => "이름", + 'account_balance' => "예치금", + 'coupon_balance' => "쿠폰", + 'point_balance' => "포인트", 'status' => "상태", 'updated_at' => "수정일", 'created_at' => "작성일", diff --git a/app/Language/en/Customer/Coupon.php b/app/Language/en/Customer/Coupon.php new file mode 100644 index 0000000..1c020c6 --- /dev/null +++ b/app/Language/en/Customer/Coupon.php @@ -0,0 +1,16 @@ + "고객쿠폰", + 'label' => [ + 'clientinfo_uid' => "고객명", + 'title' => "제목", + 'amount' => "갯수", + 'status' => "추가/사용", + 'updated_at' => "수정일", + 'created_at' => "작성일", + ], + "STATUS" => [ + "in" => "추가", + "out" => "사용", + ], +]; diff --git a/app/Language/en/Customer/Point.php b/app/Language/en/Customer/Point.php new file mode 100644 index 0000000..94e4039 --- /dev/null +++ b/app/Language/en/Customer/Point.php @@ -0,0 +1,16 @@ + "고객포인트", + 'label' => [ + 'clientinfo_uid' => "고객명", + 'title' => "제목", + 'amount' => "금액", + 'status' => "입/출금", + 'updated_at' => "수정일", + 'created_at' => "작성일", + ], + "STATUS" => [ + "in" => "입금", + "out" => "출금", + ], +]; diff --git a/app/Language/en/User.php b/app/Language/en/User.php index fec0c75..19d78ce 100644 --- a/app/Language/en/User.php +++ b/app/Language/en/User.php @@ -15,8 +15,6 @@ return [ 'created_at' => "작성일", ], "ROLE" => [ - "user" => "일반회원", - "vip" => "VIP회원", "manager" => "관리자", "cloudflare" => "Cloudflare관리자", "firewall" => "firewall관리자", diff --git a/app/Libraries/MySocket/GoogleSocket/GoogleSocket.php b/app/Libraries/MySocket/GoogleSocket/GoogleSocket.php index 77d4c48..4aca207 100644 --- a/app/Libraries/MySocket/GoogleSocket/GoogleSocket.php +++ b/app/Libraries/MySocket/GoogleSocket/GoogleSocket.php @@ -71,7 +71,7 @@ abstract class GoogleSocket extends MySocket } } //상태가 use(승인완료)가 아니라면 - if ($entity->status !== DEFAULTS['STATUS']) { + if ($entity->getStatus() !== DEFAULTS['STATUS']) { throw new PageNotFoundException("{$entity->getSite()}의{$entity->getEmail()}:{$entity->getTitle()}님은 {$entity->status}입니다 "); } return $entity; diff --git a/app/Models/CommonModel.php b/app/Models/CommonModel.php index 9f6b495..ed10103 100644 --- a/app/Models/CommonModel.php +++ b/app/Models/CommonModel.php @@ -50,8 +50,9 @@ abstract class CommonModel extends Model { parent::__construct(); } + abstract public function getFilterFields(): array; + abstract public function getBatchJobFields(): array; abstract public function setList_WordFilter(string $word): void; - final public function getTable(): string { return constant("static::TABLE"); @@ -64,6 +65,11 @@ abstract class CommonModel extends Model { return constant("static::TITLE"); } + final public function getFields(): array + { + return $this->allowedFields; + } + //Primary Key로 uuid를 사용시 해당 모델에 아래 변수 반드시 추가 필요 // protected $useAutoIncrement = false; // protected $beforeInsert = ['generateUUID']; diff --git a/app/Models/Customer/AccountModel.php b/app/Models/Customer/AccountModel.php index ec258b4..fd56065 100644 --- a/app/Models/Customer/AccountModel.php +++ b/app/Models/Customer/AccountModel.php @@ -3,11 +3,10 @@ namespace App\Models\Customer; use App\Entities\Customer\AccountEntity; -use App\Models\CommonModel; class AccountModel extends CustomerModel { - const TABLE = "acountinfo"; + const TABLE = "accountinfo"; const PK = "uid"; const TITLE = "title"; protected $table = self::TABLE; @@ -15,15 +14,23 @@ class AccountModel extends CustomerModel protected $returnType = AccountEntity::class; protected $allowedFields = [ "clientinfo_uid", - "title", - "alias", - "amount", "status", + "alias", + "title", + "amount", ]; public function __construct() { parent::__construct(); } + public function getFilterFields(): array + { + return ["clientinfo_uid", 'status']; + } + public function getBatchJobFields(): array + { + return ['status']; + } public function getFieldRule(string $action, string $field): string { if (is_array($field)) { @@ -39,7 +46,7 @@ class AccountModel extends CustomerModel $rule = "required|trim|string"; break; case "status": - $rule = "if_exist|in_list[in,out]"; + $rule = "required|in_list[in,out]"; break; default: $rule = parent::getFieldRule($action, $field); diff --git a/app/Models/Customer/ClientModel.php b/app/Models/Customer/ClientModel.php index e384c19..49f939a 100644 --- a/app/Models/Customer/ClientModel.php +++ b/app/Models/Customer/ClientModel.php @@ -13,10 +13,10 @@ class ClientModel extends CustomerModel protected $primaryKey = self::PK; protected $returnType = ClientEntity::class; protected $allowedFields = [ - "role", "name", "email", "phone", + "role", "account_balance", "coupon_balance", "point_balance", @@ -26,6 +26,14 @@ class ClientModel extends CustomerModel { parent::__construct(); } + public function getFilterFields(): array + { + return ['role', 'status']; + } + public function getBatchJobFields(): array + { + return ['status']; + } public function getFieldRule(string $action, string $field): string { if (is_array($field)) { @@ -45,7 +53,10 @@ class ClientModel extends CustomerModel case "account_balance": case "coupon_balance": case "point_balance": - $rule = "if_exist|trim|number"; + $rule = "if_exist|trim|numeric"; + break; + case "status": + $rule = "if_exist|in_list[use,pause]"; break; default: $rule = parent::getFieldRule($action, $field); diff --git a/app/Models/Customer/CouponModel.php b/app/Models/Customer/CouponModel.php new file mode 100644 index 0000000..acae44b --- /dev/null +++ b/app/Models/Customer/CouponModel.php @@ -0,0 +1,62 @@ + field가 array 입니다.\n" . var_export($field, true)); + } + switch ($field) { + case "clientinfo_uid": + case "amount": + $rule = "required|number"; + break; + case "title": + $rule = "required|trim|string"; + break; + case "status": + $rule = "required|in_list[in,out]"; + break; + default: + $rule = parent::getFieldRule($action, $field); + break; + } + return $rule; + } + + //List 검색용 + public function setList_WordFilter(string $word): void + { + $this->orLike(self::TABLE . "." . self::TITLE, $word, 'both'); + $this->orLike(self::TABLE . '.alias', $word, 'both'); + } +} diff --git a/app/Models/Customer/PointModel.php b/app/Models/Customer/PointModel.php new file mode 100644 index 0000000..075dff5 --- /dev/null +++ b/app/Models/Customer/PointModel.php @@ -0,0 +1,62 @@ + field가 array 입니다.\n" . var_export($field, true)); + } + switch ($field) { + case "clientinfo_uid": + case "amount": + $rule = "required|number"; + break; + case "title": + $rule = "required|trim|string"; + break; + case "status": + $rule = "required|in_list[in,out]"; + break; + default: + $rule = parent::getFieldRule($action, $field); + break; + } + return $rule; + } + + //List 검색용 + public function setList_WordFilter(string $word): void + { + $this->orLike(self::TABLE . "." . self::TITLE, $word, 'both'); + $this->orLike(self::TABLE . '.alias', $word, 'both'); + } +} diff --git a/app/Models/MyLogModel.php b/app/Models/MyLogModel.php index d46edd8..7293662 100644 --- a/app/Models/MyLogModel.php +++ b/app/Models/MyLogModel.php @@ -25,6 +25,14 @@ class MyLogModel extends CommonModel { parent::__construct(); } + public function getFilterFields(): array + { + return ['user_uid', 'status']; + } + public function getBatchJobFields(): array + { + return ['status']; + } public function getFieldRule(string $action, string $field): string { if (is_array($field)) { diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php index e8f1d7c..5b9dc7f 100644 --- a/app/Models/UserModel.php +++ b/app/Models/UserModel.php @@ -26,6 +26,14 @@ class UserModel extends CommonModel { parent::__construct(); } + public function getFilterFields(): array + { + return ['role', 'status']; + } + public function getBatchJobFields(): array + { + return ['status']; + } public function getFieldRule(string $action, string $field): string { if (is_array($field)) { diff --git a/app/Models/UserSNSModel.php b/app/Models/UserSNSModel.php index 0729e63..c041c34 100644 --- a/app/Models/UserSNSModel.php +++ b/app/Models/UserSNSModel.php @@ -28,6 +28,14 @@ class UserSNSModel extends CommonModel { parent::__construct(); } + public function getFilterFields(): array + { + return ['status']; + } + public function getBatchJobFields(): array + { + return ['status']; + } public function getFieldRule(string $action, string $field): string { switch ($field) { diff --git a/app/Services/Auth/AuthService.php b/app/Services/Auth/AuthService.php index 43ce088..a240a63 100644 --- a/app/Services/Auth/AuthService.php +++ b/app/Services/Auth/AuthService.php @@ -3,7 +3,6 @@ namespace App\Services\Auth; use App\Entities\UserEntity; -use App\Models\UserModel; use App\Services\CommonService; use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\Session\Session; @@ -21,14 +20,12 @@ abstract class AuthService extends CommonService { return "Auth" . DIRECTORY_SEPARATOR; } - final public function getModelClass(): UserModel + //Index,FieldForm관련 + final public function getFields(): array { - return new UserModel(); - } - final public function getEntityClass(): UserEntity - { - return new UserEntity(); + return ['id', 'passwd']; } + //Index,FieldForm관련 final public function getSession(): Session { @@ -78,9 +75,8 @@ abstract class AuthService extends CommonService if ($role === "") { return false; } - $myRoles = explode(DEFAULTS['DELIMITER_ROLE'], $role); // 교집합이 없으면 false - return !empty(array_intersect($myRoles, $roles)); + return !empty(array_intersect(explode(DEFAULTS['DELIMITER_ROLE'], $role), $roles)); } final public function pushCurrentUrl(string $url): void diff --git a/app/Services/Auth/GoogleService.php b/app/Services/Auth/GoogleService.php index c2342c9..5da1edc 100644 --- a/app/Services/Auth/GoogleService.php +++ b/app/Services/Auth/GoogleService.php @@ -3,7 +3,8 @@ namespace App\Services\Auth; use App\Entities\UserEntity; -// use App\Libraries\MySocket\GoogleSocket\CURL; +use App\Models\UserModel; +use App\Libraries\MySocket\GoogleSocket\CURL; use CodeIgniter\Exceptions\PageNotFoundException; use CodeIgniter\HTTP\IncomingRequest; @@ -15,18 +16,31 @@ class GoogleService extends AuthService $this->_mySocket = $mySocket; parent::__construct($request); } + public function getMySocket(): mixed + { + if (!$this->_mySocket) { + throw new \Exception("Socket이 지정되지 않았습니다."); + } + return $this->_mySOcket; + } public function getClassName(): string { return parent::getClassName() . DIRECTORY_SEPARATOR . "Google"; } + final public function getModelClass(): UserModel + { + return new UserModel(); + } + final public function getEntityClass(): UserEntity + { + return new UserEntity(); + } + public function checkUser(string $access_code): UserEntity { try { // Google 서비스 설정 - if (!$this->_mySocket) { - throw new \Exception("Socket 방식이 지정되지 않았습니다."); - } - $this->_mySocket->setToken($access_code); + $this->this->getMySocket()->setToken($access_code); $sns_entity = $this->_mySocket->signup(); // local db 사용와의 연결 확인 $entity = $this->getEntity($sns_entity->getParent()); diff --git a/app/Services/Auth/LocalService.php b/app/Services/Auth/LocalService.php index f69feb9..6afc975 100644 --- a/app/Services/Auth/LocalService.php +++ b/app/Services/Auth/LocalService.php @@ -3,6 +3,7 @@ namespace App\Services\Auth; use App\Entities\UserEntity; +use App\Models\UserModel; use CodeIgniter\HTTP\IncomingRequest; class LocalService extends AuthService @@ -15,6 +16,14 @@ class LocalService extends AuthService { return parent::getClassName() . DIRECTORY_SEPARATOR . "Local"; } + final public function getModelClass(): UserModel + { + return new UserModel(); + } + final public function getEntityClass(): UserEntity + { + return new UserEntity(); + } public function checkUser(array $formDatas): UserEntity { $entity = $this->getEntity(['id' => $formDatas['id']]); diff --git a/app/Services/CommonService.php b/app/Services/CommonService.php index 0e5846d..378e3f5 100644 --- a/app/Services/CommonService.php +++ b/app/Services/CommonService.php @@ -44,6 +44,18 @@ abstract class CommonService } return $this->_model; } + public function getFields(): array + { + return $this->getModel()->getFields(); + } + public function getFilterFields(): array + { + return $this->getModel()->getFilterFields(); + } + public function getBatchJobFields(): array + { + return $this->getModel()->getBatchJobFields(); + } final public function getEntity(mixed $where, $isThrow = true): mixed { $entity = is_array($where) ? $this->getModel()->where($where)->first() : $this->getModel()->find($where); diff --git a/app/Services/Customer/AccountService.php b/app/Services/Customer/AccountService.php index 88413ae..ab40c65 100644 --- a/app/Services/Customer/AccountService.php +++ b/app/Services/Customer/AccountService.php @@ -13,9 +13,9 @@ class AccountService extends CustomerService { parent::__construct($request); } - final public function getClassName(): string + public function getClassName(): string { - return "Account"; + return parent::getClassName() . DIRECTORY_SEPARATOR . "Account"; } public function getModelClass(): AccountModel { @@ -25,29 +25,4 @@ class AccountService extends CustomerService { return new AccountEntity(); } - public function getFormFieldOption(string $field, array $options = []): array - { - switch ($field) { - default: - $this->getModel()->orderBy($this->getModel()::TITLE, 'ASC'); - $options = parent::getFormFieldOption($field, $options); - break; - } - return $options; - } - public function create(array $formDatas, mixed $entity = null): AccountEntity - { - $formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $formDatas['role']); - return parent::create($formDatas, $entity ?? new AccountEntity()); - } - public function modify(mixed $entity, array $formDatas): AccountEntity - { - // die(var_export($formDatas, true)); - //Role을 지정이 있을경우에만 , toggle이나 batcjhjob에서는 없을수도 있으므로 - if (isset($formDatas['role'])) { - $formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $formDatas['role']); - } - // die(var_export($formDatas, true)); - return parent::modify($entity, $formDatas); - } } diff --git a/app/Services/Customer/ClientService.php b/app/Services/Customer/ClientService.php index 8bd0d3b..faae700 100644 --- a/app/Services/Customer/ClientService.php +++ b/app/Services/Customer/ClientService.php @@ -8,14 +8,15 @@ use CodeIgniter\HTTP\IncomingRequest; class ClientService extends CustomerService { + protected ?IncomingRequest $request = null; public function __construct(?IncomingRequest $request = null) { parent::__construct($request); } - final public function getClassName(): string + public function getClassName(): string { - return "Client"; + return parent::getClassName() . DIRECTORY_SEPARATOR . "Client"; } public function getModelClass(): ClientModel { @@ -25,16 +26,6 @@ class ClientService extends CustomerService { return new ClientEntity(); } - public function getFormFieldOption(string $field, array $options = []): array - { - switch ($field) { - default: - $this->getModel()->orderBy($this->getModel()::TITLE, 'ASC'); - $options = parent::getFormFieldOption($field, $options); - break; - } - return $options; - } public function create(array $formDatas, mixed $entity = null): ClientEntity { $formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $formDatas['role']); diff --git a/app/Services/Customer/CouponService.php b/app/Services/Customer/CouponService.php new file mode 100644 index 0000000..1b7e96a --- /dev/null +++ b/app/Services/Customer/CouponService.php @@ -0,0 +1,28 @@ +_accountService) { + $this->_accountService = new AccountService($this->getRequest()); + } + return $this->_accountService; + } + final public function getCouponService(): CouponService + { + if (!$this->_couponService) { + $this->_couponService = new CouponService($this->getRequest()); + } + return $this->_couponService; + } + final public function getPointService(): PointService + { + if (!$this->_pointService) { + $this->_pointService = new PointService($this->getRequest()); + } + return $this->_pointService; + } } diff --git a/app/Services/Customer/PointService.php b/app/Services/Customer/PointService.php new file mode 100644 index 0000000..6c3f3d8 --- /dev/null +++ b/app/Services/Customer/PointService.php @@ -0,0 +1,28 @@ +getClassName(); + return new UserSNSModel(); } - public function getModelClass(): string + public function getEntityClass(): UserSNSEntity { - return Model::class; - } - public function getEntityClass(): string - { - return Entity::class; - } - - public function getFields(): array - { - return [$this->getModel()::PARENT, 'site', 'id', $this->getModel()::TITLE, 'email']; - } - public function getFilterFields(): array - { - return [$this->getModel()::PARENT, 'status']; - } - public function getBatchJobFields(): array - { - return []; + return new UserSNSEntity(); } } diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 92aaf65..e1b4406 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -25,15 +25,9 @@ class UserService extends CommonService { return new UserEntity(); } - public function getFormFieldOption(string $field, array $options = []): array + public function getFields(): array { - switch ($field) { - default: - $this->getModel()->orderBy($this->getModel()::TITLE, 'ASC'); - $options = parent::getFormFieldOption($field, $options); - break; - } - return $options; + return ['id', 'passwd', 'confirmpassword', $this->getModel()::TITLE, 'email', 'mobile', 'role']; } public function create(array $formDatas, mixed $entity = null): UserEntity { diff --git a/app/Views/admin/create_form.php b/app/Views/admin/create_form.php index 9ee5b65..5af7c31 100644 --- a/app/Views/admin/create_form.php +++ b/app/Views/admin/create_form.php @@ -18,7 +18,7 @@
"btn btn-outline btn-primary")); ?>
- has('error')): ?>
+ has('error')): ?>
endSection() ?> \ No newline at end of file diff --git a/app/Views/admin/index.php b/app/Views/admin/index.php index 7a3aac0..9cbd8b6 100644 --- a/app/Views/admin/index.php +++ b/app/Views/admin/index.php @@ -55,6 +55,7 @@ +alert($error) ?>
include(LAYOUTS[$viewDatas['layout']]['path'] . '/bottom'); ?> diff --git a/app/Views/admin/modify_form.php b/app/Views/admin/modify_form.php index 3db7b0a..50b79e6 100644 --- a/app/Views/admin/modify_form.php +++ b/app/Views/admin/modify_form.php @@ -18,7 +18,7 @@
"btn btn-outline btn-primary"]) ?>
- has('error')): ?>
+ has('error')): ?>
endSection() ?> \ No newline at end of file diff --git a/app/Views/layouts/admin/left_menu.php b/app/Views/layouts/admin/left_menu.php index dece60d..ac2684f 100644 --- a/app/Views/layouts/admin/left_menu.php +++ b/app/Views/layouts/admin/left_menu.php @@ -7,7 +7,7 @@ Main include(LAYOUTS[$viewDatas['layout']]['path'] . '/left_menu/base'); ?> - include(LAYOUTS[$viewDatas['layout']]['path'] . '/left_menu/client'); ?> + include(LAYOUTS[$viewDatas['layout']]['path'] . '/left_menu/customer'); ?> include(LAYOUTS[$viewDatas['layout']]['path'] . '/left_menu/device'); ?> diff --git a/app/Views/layouts/admin/left_menu/client.php b/app/Views/layouts/admin/left_menu/customer.php similarity index 54% rename from app/Views/layouts/admin/left_menu/client.php rename to app/Views/layouts/admin/left_menu/customer.php index 54ad6ae..f636c2b 100644 --- a/app/Views/layouts/admin/left_menu/client.php +++ b/app/Views/layouts/admin/left_menu/customer.php @@ -6,21 +6,18 @@
-
\ No newline at end of file diff --git a/app/Views/templates/admin/index_footer.php b/app/Views/templates/admin/index_footer.php index ba38439..e69de29 100644 --- a/app/Views/templates/admin/index_footer.php +++ b/app/Views/templates/admin/index_footer.php @@ -1 +0,0 @@ -alert($error) ?> \ No newline at end of file