dbms_init...1

This commit is contained in:
최준흠 2025-05-08 18:54:55 +09:00
parent f0d0c2b885
commit e26d2c1d12
42 changed files with 215 additions and 257 deletions

View File

@ -95,7 +95,6 @@ define('EVENT_PRIORITY_HIGH', 10);
//Default값 정의 //Default값 정의
define('DEFAULTS', [ define('DEFAULTS', [
'ROLE' => "guest",
'EMPTY' => "", 'EMPTY' => "",
'DELIMITER_FILE' => "||", 'DELIMITER_FILE' => "||",
'DELIMITER_ROLE' => ",", 'DELIMITER_ROLE' => ",",

View File

@ -2,16 +2,17 @@
namespace App\Controllers\Admin\Customer; namespace App\Controllers\Admin\Customer;
use CodeIgniter\HTTP\RedirectResponse; use App\Entities\Customer\AccountEntity;
use CodeIgniter\HTTP\RequestInterface; 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\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)
@ -36,6 +37,10 @@ class ClientController extends CustomerController
} }
return $this->_helper; return $this->_helper;
} }
public function getFields(): array
{
return ['name', 'email', 'phone', 'role'];
}
//Index,FieldForm관련 //Index,FieldForm관련
protected function setValidation(Validation $validation, string $action, string $field, ?string $rule = null): Validation protected function setValidation(Validation $validation, string $action, string $field, ?string $rule = null): Validation
{ {
@ -50,5 +55,57 @@ class ClientController extends CustomerController
} }
return $validation; return $validation;
} }
protected function create_process(): ClientEntity
{
//데이터 검증
$this->formDatas = $this->doValidate($this->action, $this->fields);
$entity = $this->getService()->create($this->formDatas);
//Account정보
$temps = [];
$temps['clientinfo_uid'] = $entity->getPK();
$temps['title'] = "첫가입";
$temps['alias'] = $entity->getTitle();
$temps['amount'] = $this->formDatas['account_balance'] ?? 0;
$temps['status'] = lang("{$this->getAccountService()->getClassPath()}.DEFAULTS.status");
$this->getAccountService()->create($temps, new AccountEntity());
//Coupon정보
$temps = [];
$temps['clientinfo_uid'] = $entity->getPK();
$temps['title'] = "첫가입";
$temps['amount'] = $this->formDatas['coupon_balance'] ?? 0;
$temps['status'] = lang("{$this->getCouponService()->getClassPath()}.DEFAULTS.status");
$this->getCouponService()->create($temps, new CouponEntity());
//Point정보
$temps = [];
$temps['clientinfo_uid'] = $entity->getPK();
$temps['title'] = "첫가입";
$temps['amount'] = $this->formDatas['point_balance'] ?? 0;
$temps['status'] = lang("{$this->getPointService()->getClassPath()}.DEFAULTS.status");
$this->getPointService()->create($temps, new CouponEntity());
return $entity;
}
//Index,FieldForm관련. //Index,FieldForm관련.
//View관련
protected function view_process($uid): mixed
{
$fields = [
'fields' => [$this->getService()->getModel()::TITLE, 'email', 'phone', 'role', 'account_balance', 'coupon_balance', 'point_balance', 'status'],
];
$this->init('view', $fields);
return parent::view_process($uid);
}
protected function index_process(): array
{
$fields = [
'fields' => [$this->getService()->getModel()::TITLE, 'email', 'phone', 'role', 'account_balance', 'coupon_balance', 'point_balance', 'status'],
];
$this->init('index', $fields);
return parent::index_process();
}
} }

View File

@ -2,7 +2,6 @@
namespace App\Controllers\Admin\Customer; namespace App\Controllers\Admin\Customer;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
@ -35,4 +34,6 @@ class CouponController extends CustomerController
return $this->_helper; return $this->_helper;
} }
//Index,FieldForm관련. //Index,FieldForm관련.
} }

View File

@ -6,7 +6,11 @@ use App\Controllers\Admin\AdminController;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use App\Services\Customer\AccountService;
use App\Services\Customer\ClientService; use App\Services\Customer\ClientService;
use App\Services\Customer\CouponService;
use App\Services\Customer\PointService;
abstract class CustomerController extends AdminController abstract class CustomerController extends AdminController
{ {
@ -24,6 +28,27 @@ abstract class CustomerController extends AdminController
} }
return $this->_clientService; return $this->_clientService;
} }
final public function getAccountService(): AccountService
{
if (!$this->_accountService) {
$this->_accountService = new AccountService($this->request);
}
return $this->_accountService;
}
final public function getCouponService(): CouponService
{
if (!$this->_couponService) {
$this->_couponService = new CouponService($this->request);
}
return $this->_couponService;
}
final public function getPointService(): PointService
{
if (!$this->_pointService) {
$this->_pointService = new PointService($this->request);
}
return $this->_pointService;
}
//Index,FieldForm관련 //Index,FieldForm관련
protected function getFormFieldOption(string $field, array $options = []): array protected function getFormFieldOption(string $field, array $options = []): array
{ {
@ -39,5 +64,4 @@ abstract class CustomerController extends AdminController
} }
return $options; return $options;
} }
//Index,FieldForm관련
} }

View File

@ -54,6 +54,11 @@ class UserController extends AdminController
} }
//Index,FieldForm관련. //Index,FieldForm관련.
public function getFields(): array
{
return ['id', 'passwd', 'confirmpassword', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role'];
}
protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string
{ {
switch ($action) { switch ($action) {

View File

@ -141,8 +141,6 @@ abstract class CommonController extends BaseController
if (!$validation) { if (!$validation) {
$validation = service('validation'); $validation = service('validation');
} }
// var_dump($this->field_rules);
// exit;
foreach ($fields as $field) { foreach ($fields as $field) {
$validation = $this->setValidation($validation, $action, $field, $this->field_rules[$field] ?? null); $validation = $this->setValidation($validation, $action, $field, $this->field_rules[$field] ?? null);
} }
@ -205,11 +203,11 @@ abstract class CommonController extends BaseController
helper(['form']); helper(['form']);
$this->entity = $this->create_process(); $this->entity = $this->create_process();
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["SUCCESS"]); $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["SUCCESS"]);
return $this->getResultPageByActon($this->action); return $this->getResultPageByActon($this->action);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->getService()->getModel()->transRollback(); $this->getService()->getModel()->transRollback();
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["FAILED"]); $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["FAILED"]);
return redirect()->back()->withInput()->with('error', $e->getMessage()); return redirect()->back()->withInput()->with('error', $e->getMessage());
} }
} }
@ -247,11 +245,11 @@ abstract class CommonController extends BaseController
helper(['form']); helper(['form']);
$this->entity = $this->modify_process($uid); $this->entity = $this->modify_process($uid);
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["SUCCESS"]); $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["SUCCESS"]);
return $this->getResultPageByActon($this->action); return $this->getResultPageByActon($this->action);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->getService()->getModel()->transRollback(); $this->getService()->getModel()->transRollback();
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["FAILED"]); $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["FAILED"]);
return redirect()->back()->withInput()->with('error', $e->getMessage()); return redirect()->back()->withInput()->with('error', $e->getMessage());
} }
} }
@ -273,11 +271,11 @@ abstract class CommonController extends BaseController
$this->fields = [$field]; $this->fields = [$field];
$this->entity = $this->toggle_process($uid); $this->entity = $this->toggle_process($uid);
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["SUCCESS"]); $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["SUCCESS"]);
return $this->getResultPageByActon($this->action); return $this->getResultPageByActon($this->action);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->getService()->getModel()->transRollback(); $this->getService()->getModel()->transRollback();
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["FAILED"]); $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["FAILED"]);
return redirect()->back()->withInput()->with('error', $e->getMessage()); return redirect()->back()->withInput()->with('error', $e->getMessage());
} }
} }
@ -321,11 +319,11 @@ abstract class CommonController extends BaseController
} }
$this->entities = $this->batchjob_process($entities); $this->entities = $this->batchjob_process($entities);
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["SUCCESS"]); $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["SUCCESS"]);
return $this->getResultPageByActon($this->action); return $this->getResultPageByActon($this->action);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->getService()->getModel()->transRollback(); $this->getService()->getModel()->transRollback();
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["FAILED"]); $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["FAILED"]);
return redirect()->back()->withInput()->with('error', $e->getMessage()); return redirect()->back()->withInput()->with('error', $e->getMessage());
} }
} }
@ -348,11 +346,11 @@ abstract class CommonController extends BaseController
$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->_myAuth, MESSAGES["SUCCESS"]); $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["SUCCESS"]);
return $this->getResultPageByActon($this->action); return $this->getResultPageByActon($this->action);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->getService()->getModel()->transRollback(); $this->getService()->getModel()->transRollback();
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["FAILED"]); $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["FAILED"]);
return redirect()->back()->withInput()->with('error', $e->getMessage()); return redirect()->back()->withInput()->with('error', $e->getMessage());
} }
} }
@ -392,11 +390,11 @@ abstract class CommonController extends BaseController
throw new \Exception($message); throw new \Exception($message);
} }
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["SUCCESS"]); $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["SUCCESS"]);
return $this->getResultPageByActon($this->action); return $this->getResultPageByActon($this->action);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->getService()->getModel()->transRollback(); $this->getService()->getModel()->transRollback();
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->_myAuth, MESSAGES["FAILED"]); $this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), MESSAGES["FAILED"]);
return redirect()->back()->withInput()->with('error', $e->getMessage()); return redirect()->back()->withInput()->with('error', $e->getMessage());
} }
} }
@ -426,27 +424,36 @@ abstract class CommonController extends BaseController
//리스트 //리스트
//List 조건절 처리 //List 조건절 처리
protected function setConditionForList(array $filter_fields): void final protected function setConditionForList(array $filter_fields): void
{ {
//조건절 처리 //조건절 처리
foreach ($filter_fields as $field) { foreach ($filter_fields as $field) {
$this->$field = $this->request->getVar($field) ?? DEFAULTS['EMPTY']; $this->$field = $this->request->getVar($field);
if ($this->$field !== DEFAULTS['EMPTY']) { echo "<BR>";
$this->getService()->getModel()->setList_FieldFilter($field, $this->$field); echo "1{$field}:{$this->$field}";
echo "<BR>";
if (!is_null($this->$field)) {
echo "2{$field}:{$this->$field}";
$this->getService()->getModel()->where($this->getService()->getModel()->getTable() . '.' . $field, $this->$field);
} }
} }
//검색어 처리 //검색어 처리
$this->word = $this->request->getVar('word') ?? DEFAULTS['EMPTY']; $this->word = $this->request->getVar('word');
if ($this->word !== DEFAULTS['EMPTY']) { if (!is_null($this->word)) {
$this->getService()->getModel()->setList_WordFilter($this->word); $this->getService()->getModel()->setList_WordFilter($this->word);
} }
//검색일 처리 //검색일 처리
$this->start = $this->request->getVar('start') ?? DEFAULTS['EMPTY']; $this->start = $this->request->getVar('start');
$this->end = $this->request->getVar('end') ?? DEFAULTS['EMPTY']; $this->end = $this->request->getVar('end');
$this->getService()->getModel()->setList_DateFilter($this->start, $this->end); if ($this->start) {
$this->getService()->getModel()->where($this->getService()->getModel()->getTable() . ".created_at >= '{$this->start} 00:00:00'");
}
if ($this->end) {
$this->getService()->getModel()->where($this->getService()->getModel()->getTable() . ".created_at <= '{$this->start} 23:59:59'");
}
} }
//PageNation 처리 //PageNation 처리
protected function getPageOptionsByPaginationForList(): array final protected function getPageOptionsByPaginationForList(): array
{ {
$page_options = ["" => "줄수선택"]; $page_options = ["" => "줄수선택"];
for ($i = $this->per_page; $i <= $this->total_count; $i += $this->per_page) { for ($i = $this->per_page; $i <= $this->total_count; $i += $this->per_page) {
@ -455,7 +462,7 @@ abstract class CommonController extends BaseController
$page_options[$this->total_count] = $this->total_count; $page_options[$this->total_count] = $this->total_count;
return $page_options; return $page_options;
} }
protected function getPaginationForList($pager_group = 'default', int $segment = 0, $template = 'bootstrap_full') final protected function getPaginationForList($pager_group = 'default', int $segment = 0, $template = 'bootstrap_full')
{ {
//Page, Per_page필요부분 //Page, Per_page필요부분
$this->page = (int) $this->request->getVar('page') ?: 1; $this->page = (int) $this->request->getVar('page') ?: 1;
@ -498,7 +505,7 @@ abstract class CommonController extends BaseController
$this->init(__FUNCTION__); $this->init(__FUNCTION__);
$this->entities = $this->index_process(); $this->entities = $this->index_process();
// 현재 URL을 스택에 저장 // 현재 URL을 스택에 저장
$this->_myAuth->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']);
return $this->getResultPageByActon($this->action); return $this->getResultPageByActon($this->action);
} catch (\Exception $e) { } catch (\Exception $e) {

View File

@ -18,7 +18,7 @@ class AuthHelper extends CommonHelper
if (in_array($viewDatas['action'], ['create', 'modify'])) { if (in_array($viewDatas['action'], ['create', 'modify'])) {
$extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras]; $extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
} }
$value = $value ?: DEFAULTS['EMPTY']; $value = $value ?? DEFAULTS['EMPTY'];
switch ($field) { switch ($field) {
case 'id': case 'id':
case 'passwd': case 'passwd':

View File

@ -184,7 +184,7 @@ class CommonHelper
if (in_array($viewDatas['action'], ['create', 'modify'])) { if (in_array($viewDatas['action'], ['create', 'modify'])) {
$extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras]; $extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
} }
$value = $value ?: DEFAULTS['EMPTY']; $value = $value ?? DEFAULTS['EMPTY'];
switch ($field) { switch ($field) {
case 'email': case 'email':
$form = form_input($field, $value, ["placeholder" => "예)test@example.com", ...$extras]); $form = form_input($field, $value, ["placeholder" => "예)test@example.com", ...$extras]);
@ -206,31 +206,32 @@ class CommonHelper
} }
$form = implode(" ", $forms); $form = implode(" ", $forms);
} else { } else {
$formOptions = array_merge( $formOptions = ["" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택'];
["" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택'], foreach ($viewDatas['field_options'][$field] as $key => $label) {
$viewDatas['field_options'][$field] $formOptions[$key] = $label;
); }
$form = form_dropdown($field, $formOptions, $value, $extras); $form = form_dropdown($field, $formOptions, $value, $extras);
} }
break; break;
case 'status':
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 'updated_at':
case 'created_at': case 'created_at':
$extra_class = isset($extras['class']) ? $extras['class'] . ' calender' : 'calender'; $extra_class = isset($extras['class']) ? $extras['class'] . ' calender' : 'calender';
$form = form_input($field, $value, ['class' => $extra_class, ...array_diff_key($extras, ['class' => ''])]); $form = form_input($field, $value, ['class' => $extra_class, ...array_diff_key($extras, ['class' => ''])]);
break; break;
default: default:
$form = form_input($field, $value, ["autocomplete" => $field, ...$extras]); if (in_array($field, $viewDatas['filter_fields'])) {
if (!is_array($viewDatas['field_options'][$field])) {
echo var_dump($viewDatas['field_options']);
exit;
}
$formOptions = ["" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택'];
foreach ($viewDatas['field_options'][$field] as $key => $label) {
$formOptions[$key] = $label;
}
$form = form_dropdown($field, $formOptions, $value, $extras);
} else {
$form = form_input($field, $value, ["autocomplete" => $field, ...$extras]);
}
break; break;
} }
return $form; return $form;
@ -238,7 +239,7 @@ class CommonHelper
public function getFieldView(string $field, array $viewDatas, array $extras = []): string public function getFieldView(string $field, array $viewDatas, array $extras = []): string
{ {
$value = $viewDatas['entity']->$field ?: DEFAULTS['EMPTY']; $value = $viewDatas['entity']->$field ?? DEFAULTS['EMPTY'];
switch ($field) { switch ($field) {
case $this->getTitleField(): case $this->getTitleField():
$value = form_label( $value = form_label(
@ -295,12 +296,10 @@ class CommonHelper
} }
return $value; return $value;
} }
public function getListRowColor(mixed $entity, string $field = 'status', string $value = 'use'): string public function getListRowColor(mixed $entity, string $field = 'status', string $value = 'use'): string
{ {
return $entity->isMatched($field, $value) ? "" : 'class="table-danger"'; return $entity->isMatched($field, $value) ? "" : 'class="table-danger"';
} }
public function getListLabel(string $field, array $viewDatas, array $extras = []): string public function getListLabel(string $field, array $viewDatas, array $extras = []): string
{ {
switch ($field) { switch ($field) {

View File

@ -13,4 +13,8 @@ class AccountHelper extends CustomerHelper
parent::__construct($request); parent::__construct($request);
$this->setTitleField(AccountModel::TITLE); $this->setTitleField(AccountModel::TITLE);
} }
public function getListRowColor(mixed $entity, string $field = 'status', string $value = 'in'): string
{
return $entity->isMatched($field, $value) ? "" : 'class="table-danger"';
}
} }

View File

@ -13,60 +13,14 @@ class ClientHelper extends CustomerHelper
parent::__construct($request); parent::__construct($request);
$this->setTitleField(ClientModel::TITLE); $this->setTitleField(ClientModel::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 'email':
$form = form_input($field, $value, ["placeholder" => "예)test@example.com", ...$extras]);
break;
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;
default:
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
break;
}
return $form;
} //
public function getFieldView(string $field, array $viewDatas, array $extras = []): string public function getFieldView(string $field, array $viewDatas, array $extras = []): string
{ {
$value = $viewDatas['entity']->$field ?: DEFAULTS['EMPTY']; $value = $viewDatas['entity']->$field ?? DEFAULTS['EMPTY'];
switch ($field) { switch ($field) {
case 'role':
$roles = [];
foreach (explode(DEFAULTS["DELIMITER_ROLE"], $value) as $key) {
$roles[] = $viewDatas['field_options'][$field][$key];
}
$value = implode(" , ", $roles);
break;
case 'account_balance': case 'account_balance':
case 'coupon_balance': case 'coupon_balance':
case 'point_balance': case 'point_balance':
$value = number_format($value); $value = number_format(intval($value));
break; break;
default: default:
$value = parent::getFieldView($field, $viewDatas, $extras); $value = parent::getFieldView($field, $viewDatas, $extras);

View File

@ -13,4 +13,8 @@ class CouponHelper extends CustomerHelper
parent::__construct($request); parent::__construct($request);
$this->setTitleField(CouponModel::TITLE); $this->setTitleField(CouponModel::TITLE);
} }
public function getListRowColor(mixed $entity, string $field = 'status', string $value = 'in'): string
{
return $entity->isMatched($field, $value) ? "" : 'class="table-danger"';
}
} }

View File

@ -11,32 +11,4 @@ class CustomerHelper extends CommonHelper
{ {
parent::__construct($request); 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"';
}
} }

View File

@ -13,4 +13,8 @@ class PointHelper extends CustomerHelper
parent::__construct($request); parent::__construct($request);
$this->setTitleField(field: PointModel::TITLE); $this->setTitleField(field: PointModel::TITLE);
} }
public function getListRowColor(mixed $entity, string $field = 'status', string $value = 'in'): string
{
return $entity->isMatched($field, $value) ? "" : 'class="table-danger"';
}
} }

View File

@ -16,7 +16,7 @@ class DeviceHelper extends CommonHelper
if (in_array($viewDatas['action'], ['create', 'modify'])) { if (in_array($viewDatas['action'], ['create', 'modify'])) {
$extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras]; $extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
} }
$value = $value ?: DEFAULTS['EMPTY']; $value = $value ?? DEFAULTS['EMPTY'];
switch ($field) { switch ($field) {
case "serverinfo_uid": case "serverinfo_uid":
if (!is_array($viewDatas['field_options'][$field])) { if (!is_array($viewDatas['field_options'][$field])) {

View File

@ -16,7 +16,7 @@ class MyLogHelper extends CommonHelper
public function getFieldView(string $field, array $viewDatas, array $extras = []): string public function getFieldView(string $field, array $viewDatas, array $extras = []): string
{ {
$value = $viewDatas['entity']->$field ?: DEFAULTS['EMPTY']; $value = $viewDatas['entity']->$field ?? DEFAULTS['EMPTY'];
switch ($field) { switch ($field) {
case 'content': case 'content':
$value = nl2br($value); $value = nl2br($value);

View File

@ -18,7 +18,7 @@ class UserHelper extends CommonHelper
if (in_array($viewDatas['action'], ['create', 'modify'])) { if (in_array($viewDatas['action'], ['create', 'modify'])) {
$extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras]; $extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
} }
$value = $value ?: DEFAULTS['EMPTY']; $value = $value ?? DEFAULTS['EMPTY'];
switch ($field) { switch ($field) {
case 'passwd': case 'passwd':
case 'confirmpassword': case 'confirmpassword':

View File

@ -10,6 +10,9 @@ return [
'updated_at' => "수정일", 'updated_at' => "수정일",
'created_at' => "작성일", 'created_at' => "작성일",
], ],
'DEFAULTS' => [
'status' => "in"
],
"STATUS" => [ "STATUS" => [
"in" => "입금", "in" => "입금",
"out" => "출금", "out" => "출금",

View File

@ -13,6 +13,10 @@ return [
'updated_at' => "수정일", 'updated_at' => "수정일",
'created_at' => "작성일", 'created_at' => "작성일",
], ],
'DEFAULTS' => [
'role' => "user",
'status' => "use"
],
"ROLE" => [ "ROLE" => [
"user" => "일반회원", "user" => "일반회원",
"vip" => "VIP회원", "vip" => "VIP회원",

View File

@ -9,6 +9,9 @@ return [
'updated_at' => "수정일", 'updated_at' => "수정일",
'created_at' => "작성일", 'created_at' => "작성일",
], ],
'DEFAULTS' => [
'status' => "in"
],
"STATUS" => [ "STATUS" => [
"in" => "추가", "in" => "추가",
"out" => "사용", "out" => "사용",

View File

@ -9,6 +9,9 @@ return [
'updated_at' => "수정일", 'updated_at' => "수정일",
'created_at' => "작성일", 'created_at' => "작성일",
], ],
'DEFAULTS' => [
'status' => "in"
],
"STATUS" => [ "STATUS" => [
"in" => "입금", "in" => "입금",
"out" => "출금", "out" => "출금",

View File

@ -12,6 +12,9 @@ return [
'updated_at' => "수정일", 'updated_at' => "수정일",
'created_at' => "작성일", 'created_at' => "작성일",
], ],
'DEFAULTS' => [
'status' => "use"
],
"STATUS" => [ "STATUS" => [
"use" => "완료", "use" => "완료",
"fail" => "실패", "fail" => "실패",

View File

@ -14,6 +14,10 @@ return [
'updated_at' => "수정일", 'updated_at' => "수정일",
'created_at' => "작성일", 'created_at' => "작성일",
], ],
'DEFAULTS' => [
'role' => "manager",
'status' => "use"
],
"ROLE" => [ "ROLE" => [
"manager" => "관리자", "manager" => "관리자",
"cloudflare" => "Cloudflare관리자", "cloudflare" => "Cloudflare관리자",

View File

@ -71,7 +71,7 @@ abstract class GoogleSocket extends MySocket
} }
} }
//상태가 use(승인완료)가 아니라면 //상태가 use(승인완료)가 아니라면
if ($entity->getStatus() !== DEFAULTS['STATUS']) { if ($entity->getStatus() !== 'use') {
throw new PageNotFoundException("{$entity->getSite()}{$entity->getEmail()}:{$entity->getTitle()}님은 {$entity->status}입니다 "); throw new PageNotFoundException("{$entity->getSite()}{$entity->getEmail()}:{$entity->getTitle()}님은 {$entity->status}입니다 ");
} }
return $entity; return $entity;

View File

@ -52,7 +52,6 @@ abstract class CommonModel extends Model
} }
abstract public function getFilterFields(): array; abstract public function getFilterFields(): array;
abstract public function getBatchJobFields(): array; abstract public function getBatchJobFields(): array;
abstract public function setList_WordFilter(string $word): void;
final public function getTable(): string final public function getTable(): string
{ {
return constant("static::TABLE"); return constant("static::TABLE");
@ -211,18 +210,9 @@ abstract class CommonModel extends Model
return $this->save_process($entity); return $this->save_process($entity);
} }
//List관련 //List 검색용
final public function setList_FieldFilter(string $field, int|string $value): void public function setList_WordFilter(string $word): void
{ {
$this->where($this->getTable() . '.' . $field, $value); $this->orLike($this->getTable() . "." . $this->getTitleField(), $word, 'both');
}
final public function setList_DateFilter(string $start, string $end, $field = "created_at"): void
{
if ($start !== DEFAULTS['EMPTY']) {
$this->where($this->getTable() . ".{$field} >= '{$start} 00:00:00'");
}
if ($end !== DEFAULTS['EMPTY']) {
$this->where($this->getTable() . ".{$field} <= '{$end} 23:59:59'");
}
} }
} }

View File

@ -39,7 +39,7 @@ class AccountModel extends CustomerModel
switch ($field) { switch ($field) {
case "clientinfo_uid": case "clientinfo_uid":
case "amount": case "amount":
$rule = "required|number"; $rule = "required|numeric";
break; break;
case "title": case "title":
case "alias": case "alias":
@ -54,11 +54,10 @@ class AccountModel extends CustomerModel
} }
return $rule; return $rule;
} }
//List 검색용 //List 검색용
public function setList_WordFilter(string $word): void public function setList_WordFilter(string $word): void
{ {
$this->orLike(self::TABLE . "." . self::TITLE, $word, 'both');
$this->orLike(self::TABLE . '.alias', $word, 'both'); $this->orLike(self::TABLE . '.alias', $word, 'both');
parent::setList_WordFilter($word);
} }
} }

View File

@ -67,7 +67,7 @@ class ClientModel extends CustomerModel
//List 검색용 //List 검색용
public function setList_WordFilter(string $word): void public function setList_WordFilter(string $word): void
{ {
$this->orLike(self::TABLE . "." . self::TITLE, $word, 'both');
$this->orLike(self::TABLE . '.email', $word, 'both'); $this->orLike(self::TABLE . '.email', $word, 'both');
parent::setList_WordFilter($word);
} }
} }

View File

@ -38,7 +38,7 @@ class CouponModel extends CustomerModel
switch ($field) { switch ($field) {
case "clientinfo_uid": case "clientinfo_uid":
case "amount": case "amount":
$rule = "required|number"; $rule = "required|numeric";
break; break;
case "title": case "title":
$rule = "required|trim|string"; $rule = "required|trim|string";
@ -52,11 +52,4 @@ class CouponModel extends CustomerModel
} }
return $rule; 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');
}
} }

View File

@ -38,7 +38,7 @@ class PointModel extends CustomerModel
switch ($field) { switch ($field) {
case "clientinfo_uid": case "clientinfo_uid":
case "amount": case "amount":
$rule = "required|number"; $rule = "required|numeric";
break; break;
case "title": case "title":
$rule = "required|trim|string"; $rule = "required|trim|string";
@ -52,11 +52,4 @@ class PointModel extends CustomerModel
} }
return $rule; 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');
}
} }

View File

@ -38,7 +38,7 @@ class IpModel extends DeviceModel
switch ($field) { switch ($field) {
case "clientinfo_uid": case "clientinfo_uid":
case "amount": case "amount":
$rule = "required|number"; $rule = "required|numeric";
break; break;
case "title": case "title":
$rule = "required|trim|string"; $rule = "required|trim|string";
@ -52,11 +52,4 @@ class IpModel extends DeviceModel
} }
return $rule; 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');
}
} }

View File

@ -38,7 +38,7 @@ class LineModel extends DeviceModel
switch ($field) { switch ($field) {
case "clientinfo_uid": case "clientinfo_uid":
case "amount": case "amount":
$rule = "required|number"; $rule = "required|numeric";
break; break;
case "title": case "title":
$rule = "required|trim|string"; $rule = "required|trim|string";
@ -52,11 +52,4 @@ class LineModel extends DeviceModel
} }
return $rule; 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');
}
} }

View File

@ -38,7 +38,7 @@ class NetworkModel extends DeviceModel
switch ($field) { switch ($field) {
case "clientinfo_uid": case "clientinfo_uid":
case "amount": case "amount":
$rule = "required|number"; $rule = "required|numeric";
break; break;
case "title": case "title":
$rule = "required|trim|string"; $rule = "required|trim|string";
@ -52,11 +52,4 @@ class NetworkModel extends DeviceModel
} }
return $rule; 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');
}
} }

View File

@ -38,7 +38,7 @@ class PartModel extends DeviceModel
switch ($field) { switch ($field) {
case "clientinfo_uid": case "clientinfo_uid":
case "amount": case "amount":
$rule = "required|number"; $rule = "required|numeric";
break; break;
case "title": case "title":
$rule = "required|trim|string"; $rule = "required|trim|string";
@ -52,11 +52,4 @@ class PartModel extends DeviceModel
} }
return $rule; 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');
}
} }

View File

@ -38,7 +38,7 @@ class RackModel extends DeviceModel
switch ($field) { switch ($field) {
case "clientinfo_uid": case "clientinfo_uid":
case "amount": case "amount":
$rule = "required|number"; $rule = "required|numeric";
break; break;
case "title": case "title":
$rule = "required|trim|string"; $rule = "required|trim|string";
@ -52,11 +52,4 @@ class RackModel extends DeviceModel
} }
return $rule; 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');
}
} }

View File

@ -38,7 +38,7 @@ class ServerModel extends DeviceModel
switch ($field) { switch ($field) {
case "clientinfo_uid": case "clientinfo_uid":
case "amount": case "amount":
$rule = "required|number"; $rule = "required|numeric";
break; break;
case "title": case "title":
$rule = "required|trim|string"; $rule = "required|trim|string";
@ -52,11 +52,4 @@ class ServerModel extends DeviceModel
} }
return $rule; 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');
}
} }

View File

@ -38,7 +38,7 @@ class SoftwareModel extends DeviceModel
switch ($field) { switch ($field) {
case "clientinfo_uid": case "clientinfo_uid":
case "amount": case "amount":
$rule = "required|number"; $rule = "required|numeric";
break; break;
case "title": case "title":
$rule = "required|trim|string"; $rule = "required|trim|string";
@ -52,11 +52,4 @@ class SoftwareModel extends DeviceModel
} }
return $rule; 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');
}
} }

View File

@ -72,6 +72,9 @@ abstract class CommonService
foreach ($this->getModel()->select(implode(',', $columns))->findAll() as $entity) { foreach ($this->getModel()->select(implode(',', $columns))->findAll() as $entity) {
$entitys[$entity->getPK()] = $entity; $entitys[$entity->getPK()] = $entity;
} }
if (env('app.debug.index')) {
echo $this->getModel()->getLastQuery();
}
return $entitys; return $entitys;
} // } //
//FieldForm관련용 //FieldForm관련용

View File

@ -2,9 +2,10 @@
namespace App\Services\Customer; namespace App\Services\Customer;
use CodeIgniter\HTTP\IncomingRequest;
use App\Entities\Customer\ClientEntity; use App\Entities\Customer\ClientEntity;
use App\Models\Customer\ClientModel; use App\Models\Customer\ClientModel;
use CodeIgniter\HTTP\IncomingRequest;
class ClientService extends CustomerService class ClientService extends CustomerService
{ {
@ -26,7 +27,7 @@ class ClientService extends CustomerService
{ {
return new ClientEntity(); return new ClientEntity();
} }
public function create(array $formDatas, mixed $entity = null): ClientEntity public function create(array $formDatas, mixed $entity = new ClientEntity()): ClientEntity
{ {
$formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $formDatas['role']); $formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $formDatas['role']);
return parent::create($formDatas, $entity ?? new ClientEntity()); return parent::create($formDatas, $entity ?? new ClientEntity());

View File

@ -5,15 +5,11 @@ namespace App\Services\Customer;
use App\Services\CommonService; use App\Services\CommonService;
use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\IncomingRequest;
use App\Services\Customer\AccountService; use App\Services\Customer\ClientService;
use App\Services\Customer\CouponService;
use App\Services\Customer\PointService;
abstract class CustomerService extends CommonService abstract class CustomerService extends CommonService
{ {
private ?AccountService $_accountService = null; private ?ClientService $_clientService = null;
private ?CouponService $_couponService = null;
private ?PointService $_pointService = null;
public function __construct(?IncomingRequest $request = null) public function __construct(?IncomingRequest $request = null)
{ {
parent::__construct($request); parent::__construct($request);
@ -23,25 +19,11 @@ abstract class CustomerService extends CommonService
return "Customer"; return "Customer";
} }
final public function getAccountService(): AccountService final public function getClientService(): ClientService
{ {
if (!$this->_accountService) { if (!$this->_clientService) {
$this->_accountService = new AccountService($this->getRequest()); $this->_clientService = new ClientService($this->request);
} }
return $this->_accountService; return $this->_clientService;
}
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;
} }
} }

View File

@ -25,10 +25,6 @@ class UserService extends CommonService
{ {
return new UserEntity(); return new UserEntity();
} }
public function getFields(): array
{
return ['id', 'passwd', 'confirmpassword', $this->getModel()::TITLE, 'email', 'mobile', 'role'];
}
public function create(array $formDatas, mixed $entity = null): UserEntity public function create(array $formDatas, mixed $entity = null): UserEntity
{ {
$formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $formDatas['role']); $formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $formDatas['role']);

View File

@ -18,7 +18,7 @@
<div class="text-center"><?= form_submit('', '입력', array("class" => "btn btn-outline btn-primary")); ?></div> <div class="text-center"><?= form_submit('', '입력', array("class" => "btn btn-outline btn-primary")); ?></div>
<?= form_close(); ?> <?= form_close(); ?>
</div> </div>
<?php if (session()->has('error')): ?><div class="alert alert-info"><?= nl2br(session('error')) ?></div><?php endif; ?> <?php if (session()->has('error')): ?><div class="alert alert-info text-start"><?= nl2br(session('error')) ?></div><?php endif; ?>
</div> </div>
<script src="/assets/tinymce/tinymce.js" referrerpolicy="origin"></script> <script src="/assets/tinymce/tinymce.js" referrerpolicy="origin"></script>
<?= $this->endSection() ?> <?= $this->endSection() ?>

View File

@ -18,7 +18,7 @@
<div class="text-center"><?= form_submit("", '수정', ["class" => "btn btn-outline btn-primary"]) ?></div> <div class="text-center"><?= form_submit("", '수정', ["class" => "btn btn-outline btn-primary"]) ?></div>
<?= form_close(); ?> <?= form_close(); ?>
</div> </div>
<?php if (session()->has('error')): ?><div class="alert alert-info"><?= nl2br(session('error')) ?></div><?php endif; ?> <?php if (session()->has('error')): ?><div class="alert alert-info text-start"><?= nl2br(session('error')) ?></div><?php endif; ?>
</div> </div>
<script src="/assets/tinymce/tinymce.js" referrerpolicy="origin"></script> <script src="/assets/tinymce/tinymce.js" referrerpolicy="origin"></script>
<?= $this->endSection() ?> <?= $this->endSection() ?>

View File

@ -18,7 +18,7 @@
<button type="submit" class="btn-login">로그인</button> <button type="submit" class="btn-login">로그인</button>
<div class="login-options"><?= $viewDatas['sns_buttoh'] ?></div> <div class="login-options"><?= $viewDatas['sns_buttoh'] ?></div>
<?= form_close(); ?> <?= form_close(); ?>
<?php if (session()->has('error')): ?><div class="alert alert-info"><?= session('error') ?></div><?php endif; ?> <?php if (session()->has('error')): ?><div class="alert alert-info text-start"><?= session('error') ?></div><?php endif; ?>
</div> </div>
</div> </div>
</div> </div>