dbms_init...1
This commit is contained in:
parent
b07ea18f34
commit
6f0792d53e
@ -100,17 +100,6 @@ class ServiceController extends CustomerController
|
||||
parent::delete_process($entity);
|
||||
}
|
||||
//List 관련
|
||||
protected function setWordConditionForList(): void
|
||||
{
|
||||
$this->word = $this->request->getVar('word');
|
||||
if ($this->word !== null && $this->word !== '') {
|
||||
if ($this->getHelper()->isIPAddress($this->word, 'ipv4')) {
|
||||
$this->getService()->setSearchIp($this->word);
|
||||
} else {
|
||||
$this->getService()->getModel()->setList_WordFilter($this->word);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected function index_process(): void
|
||||
{
|
||||
//서비스별 미납 Count
|
||||
|
||||
@ -35,10 +35,4 @@ class StorageController extends PartController
|
||||
return $this->_helper;
|
||||
}
|
||||
//Index,FieldForm관련
|
||||
protected function setOrderByForList(): void
|
||||
{
|
||||
//OrderBy 처리
|
||||
$this->getService()->getModel()->orderBy('model', 'ASC', false);
|
||||
parent::setOrderByForList();
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ use App\Services\UserService;
|
||||
|
||||
class UserController extends AdminController
|
||||
{
|
||||
private $_db;
|
||||
private $_service = null;
|
||||
private $_helper = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
@ -23,7 +24,7 @@ class UserController extends AdminController
|
||||
$this->class_path .= $this->getService()->getClassName();
|
||||
$this->uri_path .= strtolower($this->getService()->getClassName('/')) . '/';
|
||||
// $this->view_path .= strtolower($this->getService()->getClassName()) . DIRECTORY_SEPARATOR;
|
||||
|
||||
$this->_db = \Config\Database::connect();
|
||||
}
|
||||
final public function getService(): UserService
|
||||
{
|
||||
@ -119,7 +120,7 @@ class UserController extends AdminController
|
||||
final public function profile_modify(int $uid): RedirectResponse|string
|
||||
{
|
||||
//Transaction Start
|
||||
$this->getService()->getModel()->transStart();
|
||||
$this->_db->transStart();
|
||||
try {
|
||||
//각 Field 초기화
|
||||
$fields = [
|
||||
@ -141,10 +142,10 @@ class UserController extends AdminController
|
||||
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
|
||||
}
|
||||
$this->entity = $this->profile_modify_process($entity, $formDatas);
|
||||
$this->getService()->getModel()->transCommit();
|
||||
$this->_db->transCommit();
|
||||
return $this->getResultSuccess();
|
||||
} catch (\Exception $e) {
|
||||
$this->getService()->getModel()->transRollback();
|
||||
$this->_db->transRollback();
|
||||
return $this->getResultFail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,12 +13,14 @@ use Psr\Log\LoggerInterface;
|
||||
|
||||
class Payment extends BaseController
|
||||
{
|
||||
private $_db;
|
||||
private ?ServiceService $_serviceService = null;
|
||||
private ?ServiceItemService $_servicItemeService = null;
|
||||
private ?ServicePaymentService $_servicePaymentService = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_db = \Config\Database::connect();
|
||||
}
|
||||
public function getServiceService(): ServiceService
|
||||
{
|
||||
@ -44,7 +46,7 @@ class Payment extends BaseController
|
||||
public function billing(): void
|
||||
{
|
||||
//Transaction Start
|
||||
$this->getServiceService()->getModel()->transStart();
|
||||
$this->_db->transStart();
|
||||
try {
|
||||
//서비스중 결제일이 오늘이고, 상태가 사용중이 경우만 서비스 모두 연장처리
|
||||
$this->getServiceService()->extendBillingAt(date('Y-m-d'), DEFAULTS['STATUS']);
|
||||
@ -62,10 +64,10 @@ class Payment extends BaseController
|
||||
}
|
||||
// echo $this->getServiceService()->getModel()->getLastQuery() . "\n";
|
||||
log_message("notice", "Billing 작업을 완료하였습니다.");
|
||||
$this->getServiceService()->getModel()->transCommit();
|
||||
$this->_db->transCommit();
|
||||
} catch (\Exception $e) {
|
||||
//Transaction Rollback
|
||||
$this->getServiceService()->getModel()->transRollback();
|
||||
$this->_db->transRollback();
|
||||
log_message(
|
||||
"error",
|
||||
"Billing 작업을 실패하였습니다.\n--------------\n" .
|
||||
|
||||
@ -21,6 +21,7 @@ use Psr\Log\LoggerInterface;
|
||||
|
||||
abstract class CommonController extends BaseController
|
||||
{
|
||||
private $_db;
|
||||
private $_myAuth = null;
|
||||
private ?MyLogService $_myLogService = null;
|
||||
private $_viewDatas = [];
|
||||
@ -37,6 +38,7 @@ abstract class CommonController extends BaseController
|
||||
$this->myAuthName = $this->getMyAuth()->getNameByAuthInfo();
|
||||
$this->myAuthUID = $this->getMyAuth()->getUIDByAuthInfo();
|
||||
}
|
||||
$this->_db = \Config\Database::connect();
|
||||
}
|
||||
final public function __get($name)
|
||||
{
|
||||
@ -316,7 +318,7 @@ abstract class CommonController extends BaseController
|
||||
}
|
||||
final public function create(): RedirectResponse|string
|
||||
{
|
||||
$this->getService()->getModel()->transStart();
|
||||
$this->_db->transStart();
|
||||
try {
|
||||
//각 Field 초기화
|
||||
$this->initAction(__FUNCTION__);
|
||||
@ -327,10 +329,10 @@ abstract class CommonController extends BaseController
|
||||
}
|
||||
// dd($formDatas);
|
||||
$this->create_process($formDatas);
|
||||
$this->getService()->getModel()->transCommit();
|
||||
$this->_db->transCommit();
|
||||
return $this->getResultSuccess();
|
||||
} catch (\Exception $e) {
|
||||
$this->getService()->getModel()->transRollback();
|
||||
$this->_db->transRollback();
|
||||
return $this->getResultFail($e->getMessage());
|
||||
}
|
||||
}
|
||||
@ -369,7 +371,7 @@ abstract class CommonController extends BaseController
|
||||
final public function modify(int $uid): RedirectResponse|string
|
||||
{
|
||||
//Transaction Start
|
||||
$this->getService()->getModel()->transStart();
|
||||
$this->_db->transStart();
|
||||
try {
|
||||
//각 Field 초기화
|
||||
$this->initAction(__FUNCTION__);
|
||||
@ -384,10 +386,10 @@ abstract class CommonController extends BaseController
|
||||
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
|
||||
}
|
||||
$this->modify_process($entity, $formDatas);
|
||||
$this->getService()->getModel()->transCommit();
|
||||
$this->_db->transCommit();
|
||||
return $this->getResultSuccess();
|
||||
} catch (\Exception $e) {
|
||||
$this->getService()->getModel()->transRollback();
|
||||
$this->_db->transRollback();
|
||||
return $this->getResultFail($e->getMessage());
|
||||
}
|
||||
}
|
||||
@ -401,7 +403,7 @@ abstract class CommonController extends BaseController
|
||||
final public function toggle(mixed $uid, string $field): RedirectResponse|string
|
||||
{
|
||||
//Transaction Start
|
||||
$this->getService()->getModel()->transStart();
|
||||
$this->_db->transStart();
|
||||
try {
|
||||
//각 Field 초기화:조건항목 Field는 한개만 존재하므로 Field와 Rule을 정의
|
||||
$this->setAction(__FUNCTION__);
|
||||
@ -415,10 +417,10 @@ abstract class CommonController extends BaseController
|
||||
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
|
||||
}
|
||||
$this->toggle_process($entity, $formDatas);
|
||||
$this->getService()->getModel()->transCommit();
|
||||
$this->_db->transCommit();
|
||||
return $this->getResultSuccess();
|
||||
} catch (\Exception $e) {
|
||||
$this->getService()->getModel()->transRollback();
|
||||
$this->_db->transRollback();
|
||||
return $this->getResultFail($e->getMessage());
|
||||
}
|
||||
}
|
||||
@ -442,7 +444,7 @@ abstract class CommonController extends BaseController
|
||||
final public function batchjob(): RedirectResponse|string
|
||||
{
|
||||
//Transaction Start
|
||||
$this->getService()->getModel()->transStart();
|
||||
$this->_db->transStart();
|
||||
try {
|
||||
$selectedFields = [];
|
||||
//getBatchJobFields를 이용해서 선택된 Field 와 값정의
|
||||
@ -469,11 +471,11 @@ abstract class CommonController extends BaseController
|
||||
$this->setFieldRule($field, $this->getFormFieldRule($this->getAction(), $field));
|
||||
}
|
||||
$this->batchjob_process($uids, $formDatas);
|
||||
$this->getService()->getModel()->transCommit();
|
||||
$this->_db->transCommit();
|
||||
LogCollector::debug(sprintf("%s에서 총 %s개중 %s개 일괄작업을 완료하였습니다.", __METHOD__, count($uids), count($this->entities)));
|
||||
return $this->getResultSuccess();
|
||||
} catch (\Exception $e) {
|
||||
$this->getService()->getModel()->transRollback();
|
||||
$this->_db->transRollback();
|
||||
return $this->getResultFail($e->getMessage());
|
||||
}
|
||||
}
|
||||
@ -486,7 +488,7 @@ abstract class CommonController extends BaseController
|
||||
final public function delete(mixed $uid): RedirectResponse|string
|
||||
{
|
||||
//Transaction Start
|
||||
$this->getService()->getModel()->transStart();
|
||||
$this->_db->transStart();
|
||||
try {
|
||||
//각 Field 초기화:삭제는 다른 초기화 필요없음
|
||||
$this->setAction(__FUNCTION__);
|
||||
@ -496,10 +498,10 @@ abstract class CommonController extends BaseController
|
||||
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
|
||||
}
|
||||
$this->delete_process($entity);
|
||||
$this->getService()->getModel()->transCommit();
|
||||
$this->_db->transCommit();
|
||||
return $this->getResultSuccess();
|
||||
} catch (\Exception $e) {
|
||||
$this->getService()->getModel()->transRollback();
|
||||
$this->_db->transRollback();
|
||||
return $this->getResultFail($e->getMessage());
|
||||
}
|
||||
}
|
||||
@ -521,7 +523,7 @@ abstract class CommonController extends BaseController
|
||||
final public function batchjob_delete(): RedirectResponse|string
|
||||
{
|
||||
//Transaction Start
|
||||
$this->getService()->getModel()->transStart();
|
||||
$this->_db->transStart();
|
||||
try {
|
||||
//변경할 UIDS
|
||||
$uids = $this->request->getPost('batchjob_uids[]');
|
||||
@ -531,11 +533,11 @@ abstract class CommonController extends BaseController
|
||||
//각 Field 초기화:삭제는 다른 초기화 필요없음
|
||||
$this->setAction(__FUNCTION__);
|
||||
$this->batchjob_delete_process($uids);
|
||||
$this->getService()->getModel()->transCommit();
|
||||
$this->_db->transCommit();
|
||||
LogCollector::debug(sprintf("%s에서 총 %s개중 %s개 일괄삭제를 완료하였습니다.", __METHOD__, count($uids), count($this->entities)));
|
||||
return $this->getResultSuccess();
|
||||
} catch (\Exception $e) {
|
||||
$this->getService()->getModel()->transRollback();
|
||||
$this->_db->transRollback();
|
||||
return $this->getResultFail($e->getMessage());
|
||||
}
|
||||
}
|
||||
@ -579,19 +581,19 @@ abstract class CommonController extends BaseController
|
||||
foreach ($this->getFilterFields() as $field) {
|
||||
$filter_value = $this->getFilterValues($field);
|
||||
if ($filter_value !== null && $filter_value !== '') {
|
||||
$this->getService()->getModel()->setList_FormFilter($field, $filter_value);
|
||||
$this->getService()->setList_FormFilter($field, $filter_value);
|
||||
}
|
||||
}
|
||||
//검색어조건절 처리
|
||||
$this->word = $this->request->getVar('word');
|
||||
if ($this->word !== null && $this->word !== '') {
|
||||
$this->getService()->getModel()->setList_WordFilter($this->word);
|
||||
$this->getService()->setList_WordFilter($this->word);
|
||||
}
|
||||
//날자검색
|
||||
$this->start = $this->request->getVar('start');
|
||||
$this->end = $this->request->getVar('end');
|
||||
if ($this->start !== null && $this->start !== '' && $this->end !== null && $this->end !== '') {
|
||||
$this->getService()->getModel()->setList_DateFilter($this->start, $this->end);
|
||||
$this->getService()->setList_DateFilter($this->start, $this->end);
|
||||
}
|
||||
}
|
||||
//PageNation 처리
|
||||
@ -613,7 +615,6 @@ abstract class CommonController extends BaseController
|
||||
// 2.app/Config/Pager.php/$templates에 'bootstrap_full => 'Pagers\bootstrap_full',
|
||||
// 'bootstrap_simple' => 'Pagers\bootstrap_simple', 추가
|
||||
$pager = service("pager");
|
||||
// $this->getService()->getModel()->paginate($this->per_page, $pager_group, $this->page, $segment);
|
||||
$pager->makeLinks($this->page, $this->per_page, $this->total_count, $template, $segment, $pager_group);
|
||||
$this->page = $pager->getCurrentPage($pager_group);
|
||||
$this->total_page = $pager->getPageCount($pager_group);
|
||||
@ -626,10 +627,10 @@ abstract class CommonController extends BaseController
|
||||
$this->order_field = $this->request->getVar('order_field');
|
||||
$this->order_value = $this->request->getVar('order_value');
|
||||
if ($this->order_field !== null && $this->order_field !== '') {
|
||||
$this->getService()->getModel()->setOrderBy($this->order_field, $this->order_value);
|
||||
$this->getService()->setOrderBy($this->order_field, $this->order_value);
|
||||
}
|
||||
$this->getService()->getModel()->limit($this->per_page);
|
||||
$this->getService()->getModel()->offset(($this->page - 1) * $this->per_page);
|
||||
$this->getService()->setLimit($this->per_page);
|
||||
$this->getService()->setOffset(($this->page - 1) * $this->per_page);
|
||||
$this->entities = $this->getService()->getEntities();
|
||||
}
|
||||
public function index(): RedirectResponse|string
|
||||
@ -648,7 +649,7 @@ abstract class CommonController extends BaseController
|
||||
//조건절 처리
|
||||
$this->setConditionForList();
|
||||
//TotalCount (SoftDelete적용이 되려면 countAllResults를 사용해야함)
|
||||
$this->total_count = $this->getService()->getModel()->selectCount('*', 'cnt')->countAllResults();
|
||||
$this->total_count = $this->getService()->getTotalCount();
|
||||
//Pagination 처리
|
||||
$this->pagination = $this->getPaginationForList();
|
||||
//줄수 처리용
|
||||
|
||||
@ -49,8 +49,6 @@ abstract class GoogleSocket extends MySocket
|
||||
//이미 등록된 사용자인지 확인 후 없으면 등록 처리리
|
||||
$entity = $this->getService()->getEntity([Model::SITE => $this->getSite(), 'id' => $id], false);
|
||||
if (!$entity) {
|
||||
//Transaction Start
|
||||
$this->getService()->getModel()->transStart();
|
||||
try {
|
||||
//없다면 새로 등록
|
||||
$formDatas = [
|
||||
@ -62,10 +60,8 @@ abstract class GoogleSocket extends MySocket
|
||||
'status' => 'unuse',
|
||||
];
|
||||
$entity = $this->getService()->create($formDatas);
|
||||
$this->getService()->getModel()->transCommit();
|
||||
} catch (\Exception $e) {
|
||||
//Transaction Rollback
|
||||
$this->getService()->getModel()->transRollback();
|
||||
log_message("error", $e->getMessage());
|
||||
throw new \Exception(__FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage());
|
||||
}
|
||||
|
||||
@ -213,29 +213,11 @@ abstract class CommonModel extends Model
|
||||
|
||||
//List 검색용
|
||||
//FormFilter 조건절 처리
|
||||
public function setList_FormFilter(string $field, mixed $filter_value): void
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
//일반검색
|
||||
$this->where("{$this->getTable()}.{$field}", $filter_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
final public function setList_FormFilter(string $field, mixed $filter_value): void {}
|
||||
//검색어조건절처리
|
||||
public function setList_WordFilter(string $word): void
|
||||
{
|
||||
$this->orLike($this->getTable() . "." . $this->getTitleField(), $word, 'both');
|
||||
}
|
||||
final public function setList_WordFilter(string $word): void {}
|
||||
//날자검색
|
||||
public function setList_DateFilter(string $start, string $end): void
|
||||
{
|
||||
$this->where(sprintf("%s.created_at >= '%s 00:00:00'", $this->getTable(), $start));
|
||||
$this->where(sprintf("%s.created_at <= '%s 23:59:59'", $this->getTable(), $end));
|
||||
}
|
||||
final public function setList_DateFilter(string $start, string $end): void {}
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->orderBy(sprintf("%s.%s %s", $this->getTable(), $field, $value ?: "DESC"));
|
||||
}
|
||||
final public function setOrderBy(string $field, $value): void {}
|
||||
}
|
||||
|
||||
@ -45,10 +45,4 @@ class AccountModel extends CustomerModel
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
//List 검색용
|
||||
public function setList_WordFilter(string $word): void
|
||||
{
|
||||
$this->orLike(self::TABLE . '.alias', $word, 'both');
|
||||
parent::setList_WordFilter($word);
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,26 +58,4 @@ class ClientModel extends CustomerModel
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
//Create용
|
||||
//FormFilter 조건절 처리
|
||||
public function setList_FormFilter(string $field, mixed $filter_value): void
|
||||
{
|
||||
switch ($field) {
|
||||
case 'role':
|
||||
$where = "FIND_IN_SET(" . $this->escape($filter_value) . ", {$this->getTable()}.{$field}) > 0";
|
||||
//FIND_IN_SET()은 MySQL 함수이므로 CodeIgniter가 이를 일반 컬럼명으로 착각하고 escape하게 되면 오류가 발생합니다. 따라서 ->where($sql, null, false)로 명시하여 escape를 꺼줘야 정상 작동
|
||||
$this->where($where, null, false);
|
||||
break;
|
||||
default:
|
||||
parent::setList_FormFilter($field, $filter_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//검색어조건절처리
|
||||
//List 검색용
|
||||
public function setList_WordFilter(string $word): void
|
||||
{
|
||||
$this->orLike(self::TABLE . '.email', $word, 'both');
|
||||
parent::setList_WordFilter($word);
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,11 +62,4 @@ class ServicePaymentModel extends CustomerModel
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->orderBy('billing_at', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,11 +40,4 @@ class CodeModel extends EquipmentModel
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->getModel()->orderBy('code', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,11 +40,4 @@ class CpuModel extends PartModel
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->orderBy('model', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,11 +51,4 @@ class DefenceModel extends PartModel
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->orderBy('INET_ATON(ip)', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,11 +40,4 @@ class DomainModel extends PartModel
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->orderBy('domain', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,11 +44,4 @@ class IpModel extends PartModel
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->orderBy('INET_ATON(ip)', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,11 +41,4 @@ class RamModel extends PartModel
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->getModel()->orderBy('model', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,11 +45,4 @@ class SoftwareModel extends PartModel
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->getModel()->orderBy('model', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,11 +41,4 @@ class ServerModel extends EquipmentModel
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->getModel()->orderBy('model', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,11 +41,4 @@ class SwitchModel extends EquipmentModel
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->getModel()->orderBy('code', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,10 +40,4 @@ class MyLogModel extends CommonModel
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
//List 검색용
|
||||
public function setList_WordFilter(string $word): void
|
||||
{
|
||||
$this->orLike(self::TABLE . "." . self::TITLE, $word, 'both');
|
||||
$this->orLike(self::TABLE . '.content', $word, 'both');
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,26 +70,4 @@ class UserModel extends CommonModel
|
||||
}
|
||||
return $convertedData;
|
||||
}
|
||||
//List 검색용
|
||||
//FormFilter 조건절 처리
|
||||
public function setList_FormFilter(string $field, mixed $filter_value): void
|
||||
{
|
||||
switch ($field) {
|
||||
case 'role':
|
||||
$where = "FIND_IN_SET(" . $this->escape($filter_value) . ", {$this->getTable()}.{$field}) > 0";
|
||||
//FIND_IN_SET()은 MySQL 함수이므로 CodeIgniter가 이를 일반 컬럼명으로 착각하고 escape하게 되면 오류가 발생합니다. 따라서 ->where($sql, null, false)로 명시하여 escape를 꺼줘야 정상 작동
|
||||
$this->where($where, null, false);
|
||||
break;
|
||||
default:
|
||||
parent::setList_FormFilter($field, $filter_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//검색어조건절처리
|
||||
public function setList_WordFilter(string $word): void
|
||||
{
|
||||
$this->orLike(self::TABLE . '.id', $word, 'both');
|
||||
$this->orLike(self::TABLE . "." . self::TITLE, $word, 'both');
|
||||
$this->orLike(self::TABLE . '.email', $word, 'both');
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ abstract class CommonService
|
||||
{
|
||||
return implode($delimeter, $this->_classNames);
|
||||
}
|
||||
final public function getModel(): mixed
|
||||
final protected function getModel(): mixed
|
||||
{
|
||||
if (!$this->_model) {
|
||||
$this->_model = $this->getModelClass();
|
||||
@ -52,11 +52,21 @@ abstract class CommonService
|
||||
}
|
||||
final public function getEntity(mixed $where, ?string $message = null): mixed
|
||||
{
|
||||
$entity = is_array($where) ? $this->getModel()->where($where)->first() : $this->getModel()->find($where);
|
||||
if (!$entity) {
|
||||
throw new \Exception($message ?? __METHOD__ . "에서 해당 정보가 존재하지 않습니다");
|
||||
try {
|
||||
$entity = is_array($where) ? $this->getModel()->where($where)->first() : $this->getModel()->find($where);
|
||||
if (!$entity) {
|
||||
throw new \Exception($message ?? __METHOD__ . "에서 해당 정보가 존재하지 않습니다");
|
||||
}
|
||||
return $entity;
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf(
|
||||
"\n------%s SQL오류-----\n%s\n------------------------------\n",
|
||||
__FUNCTION__,
|
||||
$this->getModel()->getLastQuery()
|
||||
);
|
||||
LogCollector::error($message);
|
||||
throw new \Exception($message);
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
protected function findAllDatas(array $columns = ['*']): mixed
|
||||
{
|
||||
@ -64,18 +74,43 @@ abstract class CommonService
|
||||
}
|
||||
final public function getEntities(mixed $where = null, array $columns = ['*']): array
|
||||
{
|
||||
if ($where) {
|
||||
$this->getModel()->where($where);
|
||||
try {
|
||||
if ($where) {
|
||||
$this->getModel()->where($where);
|
||||
}
|
||||
$entities = [];
|
||||
foreach ($this->findAllDatas($columns) as $entity) {
|
||||
$entities[$entity->getPK()] = $entity;
|
||||
}
|
||||
return $entities;
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf(
|
||||
"\n------%s SQL오류-----\n%s\n------------------------------\n",
|
||||
__FUNCTION__,
|
||||
$this->getModel()->getLastQuery()
|
||||
);
|
||||
LogCollector::error($message);
|
||||
throw new \Exception($message);
|
||||
}
|
||||
$entities = [];
|
||||
foreach ($this->findAllDatas($columns) as $entity) {
|
||||
$entities[$entity->getPK()] = $entity;
|
||||
} //
|
||||
final public function isIPAddress(string $ip, $type = false): bool
|
||||
{
|
||||
switch ($type) {
|
||||
case 'ipv4':
|
||||
$result = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
|
||||
break;
|
||||
case 'ipv6':
|
||||
$result = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
|
||||
break;
|
||||
case 'all':
|
||||
$result = filter_var($ip, FILTER_VALIDATE_IP);
|
||||
break;
|
||||
default:
|
||||
$result = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE);
|
||||
break;
|
||||
}
|
||||
if (env('app.debug.index')) {
|
||||
echo $this->getModel()->getLastQuery() . "<BR>";
|
||||
}
|
||||
return $entities;
|
||||
} //
|
||||
return $result;
|
||||
}
|
||||
//기본 기능부분
|
||||
|
||||
//FieldForm관련용
|
||||
@ -134,4 +169,46 @@ abstract class CommonService
|
||||
LogCollector::info("[{$entity->getTitle()}]" . MESSAGES["DELETED"] . ":");
|
||||
return $entity;
|
||||
}
|
||||
|
||||
//List 검색용
|
||||
final public function getTotalCount(): int
|
||||
{
|
||||
return $this->getModel()->countAllResults(false);
|
||||
}
|
||||
//Limit처리
|
||||
final public function setLimit(int $per_page): void
|
||||
{
|
||||
$this->getModel()->limit($per_page);
|
||||
}
|
||||
//Offset처리
|
||||
final public function setOffset(int $offset): void
|
||||
{
|
||||
$this->getModel()->offset($offset);
|
||||
}
|
||||
//FormFilter 조건절 처리
|
||||
public function setList_FormFilter(string $field, mixed $filter_value): void
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
//일반검색
|
||||
$this->getModel()->where("{$this->getModel()->getTable()}.{$field}", $filter_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//검색어조건절처리
|
||||
public function setList_WordFilter(string $word): void
|
||||
{
|
||||
$this->getModel()->orLike($this->getModel()->getTable() . "." . $this->getModel()->getTitleField(), $word, 'both');
|
||||
}
|
||||
//날자검색
|
||||
public function setList_DateFilter(string $start, string $end): void
|
||||
{
|
||||
$this->getModel()->where(sprintf("%s.created_at >= '%s 00:00:00'", $this->getModel()->getTable(), $start));
|
||||
$this->getModel()->where(sprintf("%s.created_at <= '%s 23:59:59'", $this->getModel()->getTable(), $end));
|
||||
}
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->getModel()->orderBy(sprintf("%s.%s %s", $this->getModel()->getTable(), $field, $value ?: "DESC"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,4 +62,10 @@ class AccountService extends CustomerService
|
||||
$this->setBalance($formDatas);
|
||||
return parent::create($formDatas);
|
||||
}
|
||||
//List 검색용
|
||||
public function setList_WordFilter(string $word): void
|
||||
{
|
||||
$this->getModel()->orLike($this->getModel()->getTable() . '.alias', $word, 'both');
|
||||
parent::setList_WordFilter($word);
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,4 +110,26 @@ class ClientService extends CustomerService
|
||||
}
|
||||
return parent::modify($entity, $formDatas);
|
||||
}
|
||||
|
||||
//List 검색용
|
||||
//FormFilter 조건절 처리
|
||||
public function setList_FormFilter(string $field, mixed $filter_value): void
|
||||
{
|
||||
switch ($field) {
|
||||
case 'role':
|
||||
$where = "FIND_IN_SET(" . $this->getModel()->escape($filter_value) . ", {$this->getModel()->getTable()}.{$field}) > 0";
|
||||
//FIND_IN_SET()은 MySQL 함수이므로 CodeIgniter가 이를 일반 컬럼명으로 착각하고 escape하게 되면 오류가 발생합니다. 따라서 ->where($sql, null, false)로 명시하여 escape를 꺼줘야 정상 작동
|
||||
$this->getModel()->where($where, null, false);
|
||||
break;
|
||||
default:
|
||||
parent::setList_FormFilter($field, $filter_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//검색어조건절처리
|
||||
public function setList_WordFilter(string $word): void
|
||||
{
|
||||
$this->getModel()->orLike($this->getModel()->getTable() . '.email', $word, 'both');
|
||||
parent::setList_WordFilter($word);
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,4 +105,11 @@ class ServicePaymentService extends CustomerService
|
||||
$this->modify($entity, ['ownerinfo_uid' => $ownerinfo_uid]);
|
||||
}
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->getModel()->orderBy('billing_at', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,4 +225,14 @@ class ServiceService extends CustomerService
|
||||
}
|
||||
return parent::delete($entity);
|
||||
}
|
||||
//List 검색용
|
||||
//검색어조건절처리
|
||||
public function setList_WordFilter(string $word): void
|
||||
{
|
||||
if ($this->isIPAddress($word, 'ipv4')) {
|
||||
$this->setSearchIp($word);
|
||||
} else {
|
||||
parent::setList_WordFilter($word);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,4 +50,11 @@ class CodeService extends EquipmentService
|
||||
}
|
||||
return $this->getModel()->modify($entity, ['status' => $status]);
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->getModel()->orderBy('code', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,4 +39,11 @@ class CpuService extends PartService
|
||||
{
|
||||
return ['model', 'status'];
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->getModel()->orderBy('model', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,4 +43,11 @@ class DefenceService extends PartService
|
||||
{
|
||||
return ['type', 'ip', 'accountid', 'domain', 'status'];
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->getModel()->orderBy('INET_ATON(ip)', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,4 +40,11 @@ class DomainService extends PartService
|
||||
{
|
||||
return ['domain', 'status'];
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->getModel()->orderBy('domain', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,4 +84,11 @@ class IpService extends PartService
|
||||
}
|
||||
return $this->getModel()->modify($entity, ['status' => $status]);
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->getModel()->orderBy('INET_ATON(ip)', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,4 +39,11 @@ class RamService extends PartService
|
||||
{
|
||||
return ['model', 'status'];
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->getModel()->orderBy('model', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,4 +41,11 @@ class SoftwareService extends PartService
|
||||
{
|
||||
return ['type', 'model', 'status'];
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->getModel()->orderBy('model', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,4 +39,11 @@ class StorageService extends PartService
|
||||
{
|
||||
return ['model', 'status'];
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->getModel()->orderBy('model', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,4 +41,11 @@ class ServerService extends EquipmentService
|
||||
{
|
||||
return ['model', 'status'];
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->getModel()->orderBy('model', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,4 +50,11 @@ class SwitchService extends EquipmentService
|
||||
}
|
||||
return $this->getModel()->modify($entity, ['status' => $status]);
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(string $field, $value): void
|
||||
{
|
||||
$this->getModel()->orderBy('code', 'ASC', false);
|
||||
parent::setOrderBy($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,4 +81,10 @@ class MyLogService extends CommonService
|
||||
LogCollector::clear();
|
||||
return $this->create($formDatas);
|
||||
}
|
||||
//List 검색용
|
||||
public function setList_WordFilter(string $word): void
|
||||
{
|
||||
$this->getModel()->orLike($this->getModel()::TABLE . "." . $this->getModel()::TITLE, $word, 'both');
|
||||
$this->getModel()->orLike($this->getModel()::TABLE . '.content', $word, 'both');
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,4 +61,26 @@ class UserService extends CommonService
|
||||
// die(var_export($formDatas, true));
|
||||
return parent::modify($entity, $formDatas);
|
||||
}
|
||||
//List 검색용
|
||||
//FormFilter 조건절 처리
|
||||
public function setList_FormFilter(string $field, mixed $filter_value): void
|
||||
{
|
||||
switch ($field) {
|
||||
case 'role':
|
||||
$where = "FIND_IN_SET(" . $this->getModel()->escape($filter_value) . ", {$this->getModel()->getTable()}.{$field}) > 0";
|
||||
//FIND_IN_SET()은 MySQL 함수이므로 CodeIgniter가 이를 일반 컬럼명으로 착각하고 escape하게 되면 오류가 발생합니다. 따라서 ->where($sql, null, false)로 명시하여 escape를 꺼줘야 정상 작동
|
||||
$this->getModel()->where($where, null, false);
|
||||
break;
|
||||
default:
|
||||
parent::setList_FormFilter($field, $filter_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//검색어조건절처리
|
||||
public function setList_WordFilter(string $word): void
|
||||
{
|
||||
$this->getModel()->orLike($this->getModel()->getTable() . '.id', $word, 'both');
|
||||
$this->getModel()->orLike($this->getModel()->getTable() . "." . $this->getModel()::TITLE, $word, 'both');
|
||||
$this->getModel()->orLike($this->getModel()->getTable() . '.email', $word, 'both');
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user