dbms_init_base
This commit is contained in:
parent
12cd2fb3d8
commit
1a879d779c
@ -19,7 +19,7 @@ class Home extends AdminController
|
|||||||
}
|
}
|
||||||
protected function getServiceClass(): Service
|
protected function getServiceClass(): Service
|
||||||
{
|
{
|
||||||
if ($this->service === null) {
|
if (!$this->service) {
|
||||||
$this->service = new Service($this->request);
|
$this->service = new Service($this->request);
|
||||||
}
|
}
|
||||||
return $this->service;
|
return $this->service;
|
||||||
|
|||||||
@ -22,14 +22,14 @@ class MyLogController extends AdminController
|
|||||||
}
|
}
|
||||||
protected function getServiceClass(): Service
|
protected function getServiceClass(): Service
|
||||||
{
|
{
|
||||||
if ($this->service === null) {
|
if (!$this->service) {
|
||||||
$this->service = new Service();
|
$this->service = new Service();
|
||||||
}
|
}
|
||||||
return $this->service;
|
return $this->service;
|
||||||
}
|
}
|
||||||
public function getUserService(): UserService
|
public function getUserService(): UserService
|
||||||
{
|
{
|
||||||
if ($this->_userService === null) {
|
if (!$this->_userService) {
|
||||||
$this->_userService = new UserService($this->request);
|
$this->_userService = new UserService($this->request);
|
||||||
}
|
}
|
||||||
return $this->_userService;
|
return $this->_userService;
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class UserController extends AdminController
|
|||||||
}
|
}
|
||||||
protected function getServiceClass(): Service
|
protected function getServiceClass(): Service
|
||||||
{
|
{
|
||||||
if ($this->service === null) {
|
if (!$this->service) {
|
||||||
$this->service = new Service($this->request);
|
$this->service = new Service($this->request);
|
||||||
}
|
}
|
||||||
return $this->service;
|
return $this->service;
|
||||||
@ -40,7 +40,7 @@ class UserController extends AdminController
|
|||||||
{
|
{
|
||||||
return ['status'];
|
return ['status'];
|
||||||
}
|
}
|
||||||
protected function setValidation(string $action, string $field, string $rule, Validation $validation): Validation
|
protected function setValidation(Validation $validation, string $action, string $field, ?string $rule = null): Validation
|
||||||
{
|
{
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
case 'role':
|
case 'role':
|
||||||
@ -48,7 +48,7 @@ class UserController extends AdminController
|
|||||||
$validation->setRule("{$field}.*", $field, $rule);
|
$validation->setRule("{$field}.*", $field, $rule);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$validation = parent::setValidation($action, $field, $rule, $validation);
|
$validation = parent::setValidation($validation, $action, $field, $rule);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $validation;
|
return $validation;
|
||||||
|
|||||||
@ -43,7 +43,7 @@ abstract class CommonController extends BaseController
|
|||||||
}
|
}
|
||||||
final public function getService(): mixed
|
final public function getService(): mixed
|
||||||
{
|
{
|
||||||
if ($this->_service === null) {
|
if (!$this->_service) {
|
||||||
$serviceClass = $this->getServiceClass();
|
$serviceClass = $this->getServiceClass();
|
||||||
$this->_service = new $serviceClass($this->request);
|
$this->_service = new $serviceClass($this->request);
|
||||||
// $this->_service->setDebug(true);
|
// $this->_service->setDebug(true);
|
||||||
@ -111,11 +111,11 @@ abstract class CommonController extends BaseController
|
|||||||
// dd($options);
|
// dd($options);
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
protected function setValidation(string $action, string $field, string $rule, Validation $validation): Validation
|
protected function setValidation(Validation $validation, string $action, string $field, ?string $rule = null): Validation
|
||||||
{
|
{
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
default:
|
default:
|
||||||
$validation->setRule($field, $field, $this->getService()->getModel()->getFieldRule($action, $field));
|
$validation->setRule($field, $field, $rule ?? $this->getService()->getModel()->getFieldRule($action, $field));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $validation;
|
return $validation;
|
||||||
@ -139,8 +139,8 @@ abstract class CommonController extends BaseController
|
|||||||
$validation = service('validation');
|
$validation = service('validation');
|
||||||
// var_dump($this->field_rules);
|
// var_dump($this->field_rules);
|
||||||
// exit;
|
// exit;
|
||||||
foreach ($this->field_rules as $field => $rule) {
|
foreach ($fields as $field) {
|
||||||
$validation = $this->setValidation($this->action, $field, $rule, $validation);
|
$validation = $this->setValidation($validation, $this->action, $field, $this->field_rules[$field] ?? null);
|
||||||
}
|
}
|
||||||
if (!$validation->withRequest($this->request)->run()) {
|
if (!$validation->withRequest($this->request)->run()) {
|
||||||
throw new \Exception("{$this->getService()->getClassName()} 작업 데이터 검증 오류발생\n" . implode(
|
throw new \Exception("{$this->getService()->getClassName()} 작업 데이터 검증 오류발생\n" . implode(
|
||||||
@ -193,7 +193,7 @@ abstract class CommonController extends BaseController
|
|||||||
{
|
{
|
||||||
$this->getService()->getModel()->where($this->getService()->getModel()::PK, $uid);
|
$this->getService()->getModel()->where($this->getService()->getModel()::PK, $uid);
|
||||||
$entity = $this->getService()->getEntity();
|
$entity = $this->getService()->getEntity();
|
||||||
if ($entity === null) {
|
if (!$entity) {
|
||||||
throw new \Exception("해당 정보를 찾을수 없습니다.");
|
throw new \Exception("해당 정보를 찾을수 없습니다.");
|
||||||
}
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
@ -329,10 +329,10 @@ abstract class CommonController extends BaseController
|
|||||||
$this->init(__FUNCTION__);
|
$this->init(__FUNCTION__);
|
||||||
$this->getService()->getModel()->where($this->getService()->getModel()::PK, $uid);
|
$this->getService()->getModel()->where($this->getService()->getModel()::PK, $uid);
|
||||||
$entity = $this->getService()->getEntity();
|
$entity = $this->getService()->getEntity();
|
||||||
if ($entity === null) {
|
if (!$entity) {
|
||||||
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
|
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
|
||||||
}
|
}
|
||||||
$this->entity = $this->delete_process($uid);
|
$this->entity = $this->delete_process($entity);
|
||||||
$this->getService()->getModel()->transCommit();
|
$this->getService()->getModel()->transCommit();
|
||||||
return $this->getResultPageByActon($this->action);
|
return $this->getResultPageByActon($this->action);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -356,10 +356,10 @@ abstract class CommonController extends BaseController
|
|||||||
foreach ($entities as $entity) {
|
foreach ($entities as $entity) {
|
||||||
try {
|
try {
|
||||||
if ($this->getService()->delete($entity)) {
|
if ($this->getService()->delete($entity)) {
|
||||||
MyLogService::debug("[$entity->getTitle()]" . MESSAGES["DELETED"]);
|
MyLogService::debug("[{$entity->getTitle()}]" . MESSAGES["DELETED"]);
|
||||||
}
|
}
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
MyLogService::debug("[$entity->getTitle()]" . MESSAGES["FAILED"] . ":" . $e->getMessage());
|
MyLogService::debug("[{$entity->getTitle()}]" . MESSAGES["FAILED"] . ":" . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -550,7 +550,7 @@ abstract class CommonController extends BaseController
|
|||||||
}
|
}
|
||||||
$this->getService()->getModel()->where($this->getService()->getModel()::PK, $uid);
|
$this->getService()->getModel()->where($this->getService()->getModel()::PK, $uid);
|
||||||
$this->entity = $this->getService()->getEntity();
|
$this->entity = $this->getService()->getEntity();
|
||||||
if ($this->entity === null) {
|
if (!$this->entity) {
|
||||||
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
|
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
|
||||||
}
|
}
|
||||||
list($file_name, $uploaded_filename) = $this->entity->getDownlaodFile();
|
list($file_name, $uploaded_filename) = $this->entity->getDownlaodFile();
|
||||||
|
|||||||
@ -26,7 +26,7 @@ class UserController extends CommonController
|
|||||||
}
|
}
|
||||||
protected function getServiceClass(): Service
|
protected function getServiceClass(): Service
|
||||||
{
|
{
|
||||||
if ($this->service === null) {
|
if (!$this->service) {
|
||||||
$this->service = new Service($this->request);
|
$this->service = new Service($this->request);
|
||||||
}
|
}
|
||||||
return $this->service;
|
return $this->service;
|
||||||
|
|||||||
@ -16,8 +16,6 @@ abstract class CommonEntity extends Entity
|
|||||||
{
|
{
|
||||||
parent::__construct($data);
|
parent::__construct($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public function __toString();
|
|
||||||
final public function getPK(): string
|
final public function getPK(): string
|
||||||
{
|
{
|
||||||
$field = constant("static::PK");
|
$field = constant("static::PK");
|
||||||
@ -30,7 +28,7 @@ abstract class CommonEntity extends Entity
|
|||||||
}
|
}
|
||||||
final public function getUpdatedAt(): string
|
final public function getUpdatedAt(): string
|
||||||
{
|
{
|
||||||
return $this->created_at;
|
return $this->updated_at;
|
||||||
}
|
}
|
||||||
final public function getCreatedAt(): string
|
final public function getCreatedAt(): string
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,17 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Entities;
|
namespace App\Entities;
|
||||||
|
|
||||||
use App\Entities\CommonEntity as Entity;
|
use App\Entities\CommonEntity;
|
||||||
use App\Models\MyLogModel as Model;
|
use App\Models\MyLogModel as Model;
|
||||||
|
|
||||||
class MyLogEntity extends Entity
|
class MyLogEntity extends CommonEntity
|
||||||
{
|
{
|
||||||
const PK = Model::PK;
|
const PK = Model::PK;
|
||||||
const TITLE = Model::TITLE;
|
const TITLE = Model::TITLE;
|
||||||
public function __toString(): string
|
|
||||||
{
|
|
||||||
return "{$this->getPK()}:{$this->getTitle()}}";
|
|
||||||
}
|
|
||||||
//공통부분
|
//공통부분
|
||||||
//Common Function
|
//Common Function
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,19 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Entities;
|
namespace App\Entities;
|
||||||
|
|
||||||
use App\Entities\CommonEntity as Entity;
|
use App\Entities\CommonEntity;
|
||||||
use App\Models\UserModel as Model;
|
use App\Models\UserModel as Model;
|
||||||
|
|
||||||
class UserEntity extends CommonEntity
|
class UserEntity extends CommonEntity
|
||||||
{
|
{
|
||||||
const PK = Model::PK;
|
const PK = Model::PK;
|
||||||
const TITLE = Model::TITLE;
|
const TITLE = Model::TITLE;
|
||||||
public function __toString(): string
|
|
||||||
{
|
|
||||||
return "{$this->getPK()}:{$this->getID()}:{$this->getTitle()},{$this->getRole()}}";
|
|
||||||
}
|
|
||||||
//공통부분
|
|
||||||
|
|
||||||
public function getID(): string
|
public function getID(): string
|
||||||
{
|
{
|
||||||
return $this->attributes['id'];
|
return $this->attributes['id'];
|
||||||
|
|||||||
@ -9,10 +9,6 @@ class UserSNSEntity extends CommonEntity
|
|||||||
{
|
{
|
||||||
const PK = Model::PK;
|
const PK = Model::PK;
|
||||||
const TITLE = Model::TITLE;
|
const TITLE = Model::TITLE;
|
||||||
public function __toString(): string
|
|
||||||
{
|
|
||||||
return "{$this->getPK()}|{$this->getID()}|{$this->getTitle()}";
|
|
||||||
}
|
|
||||||
//Common Function
|
//Common Function
|
||||||
public function getParent(): int|null
|
public function getParent(): int|null
|
||||||
{
|
{
|
||||||
|
|||||||
@ -16,7 +16,7 @@ class API extends GoogleSocket
|
|||||||
|
|
||||||
public function getClient(): Client
|
public function getClient(): Client
|
||||||
{
|
{
|
||||||
if ($this->_client === null) {
|
if (!$this->_client) {
|
||||||
$this->_client = new Client();
|
$this->_client = new Client();
|
||||||
$this->_client->setClientId(env('socket.google.client.id'));
|
$this->_client->setClientId(env('socket.google.client.id'));
|
||||||
$this->_client->setClientSecret(env('socket.google.client.key'));
|
$this->_client->setClientSecret(env('socket.google.client.key'));
|
||||||
|
|||||||
@ -14,7 +14,7 @@ class CURL extends GoogleSocket
|
|||||||
|
|
||||||
public function getClient(): Client
|
public function getClient(): Client
|
||||||
{
|
{
|
||||||
if ($this->_client === null) {
|
if (!$this->_client) {
|
||||||
$this->_client = new Client();
|
$this->_client = new Client();
|
||||||
}
|
}
|
||||||
return $this->_client;
|
return $this->_client;
|
||||||
|
|||||||
@ -39,7 +39,7 @@ abstract class GoogleSocket extends MySocket
|
|||||||
}
|
}
|
||||||
public function getService(): Service
|
public function getService(): Service
|
||||||
{
|
{
|
||||||
if ($this->_service === null) {
|
if (!$this->_service) {
|
||||||
$this->_service = new Service();
|
$this->_service = new Service();
|
||||||
}
|
}
|
||||||
return $this->_service;
|
return $this->_service;
|
||||||
@ -49,7 +49,7 @@ abstract class GoogleSocket extends MySocket
|
|||||||
$this->getService()->getModel()->where(Model::SITE, $this->getSite());
|
$this->getService()->getModel()->where(Model::SITE, $this->getSite());
|
||||||
$this->getService()->getModel()->where('id', $id);
|
$this->getService()->getModel()->where('id', $id);
|
||||||
$entity = $this->getEntity();
|
$entity = $this->getEntity();
|
||||||
if ($entity === null) {
|
if (!$entity) {
|
||||||
//Transaction Start
|
//Transaction Start
|
||||||
$this->getService()->getModel()->transStart();
|
$this->getService()->getModel()->transStart();
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -14,7 +14,7 @@ abstract class MySocket
|
|||||||
abstract public function getClient(): mixed;
|
abstract public function getClient(): mixed;
|
||||||
final protected function getCookieJar(): CookieJar
|
final protected function getCookieJar(): CookieJar
|
||||||
{
|
{
|
||||||
if ($this->_cookieJar === null) {
|
if (!$this->_cookieJar) {
|
||||||
$this->_cookieJar = new CookieJar();
|
$this->_cookieJar = new CookieJar();
|
||||||
}
|
}
|
||||||
return $this->_cookieJar;
|
return $this->_cookieJar;
|
||||||
|
|||||||
@ -16,7 +16,7 @@ class WebSocket extends MySocket
|
|||||||
}
|
}
|
||||||
public function getClient(): Client
|
public function getClient(): Client
|
||||||
{
|
{
|
||||||
if ($this->_client === null) {
|
if (!$this->_client) {
|
||||||
$this->_client = new Client();
|
$this->_client = new Client();
|
||||||
}
|
}
|
||||||
return $this->_client;
|
return $this->_client;
|
||||||
|
|||||||
@ -142,7 +142,7 @@ abstract class CommonModel extends Model
|
|||||||
if (!$entity->hasChanged()) {
|
if (!$entity->hasChanged()) {
|
||||||
throw new \Exception(__FUNCTION__ . " 변경된 내용이 없습니다.");
|
throw new \Exception(__FUNCTION__ . " 변경된 내용이 없습니다.");
|
||||||
}
|
}
|
||||||
// log_message("debug", var_export($entity, true));
|
log_message("debug", var_export($entity, true));
|
||||||
// 최종 저장 시 오류 발생하면
|
// 최종 저장 시 오류 발생하면
|
||||||
if (!$this->save($entity)) {
|
if (!$this->save($entity)) {
|
||||||
throw new \Exception("저장오류:" . var_export($this->errors(), true));
|
throw new \Exception("저장오류:" . var_export($this->errors(), true));
|
||||||
|
|||||||
@ -11,12 +11,10 @@ use CodeIgniter\Session\Session;
|
|||||||
abstract class AuthService extends CommonService
|
abstract class AuthService extends CommonService
|
||||||
{
|
{
|
||||||
private ?Session $_session = null;
|
private ?Session $_session = null;
|
||||||
private ?Model $_model = null;
|
|
||||||
|
|
||||||
public function __construct() {}
|
public function __construct() {}
|
||||||
final public function getSession(): Session
|
final public function getSession(): Session
|
||||||
{
|
{
|
||||||
if ($this->_session === null) {
|
if (!$this->_session) {
|
||||||
$this->_session = \Config\Services::session();
|
$this->_session = \Config\Services::session();
|
||||||
}
|
}
|
||||||
return $this->_session;
|
return $this->_session;
|
||||||
@ -41,7 +39,6 @@ abstract class AuthService extends CommonService
|
|||||||
return $this->getAuthInfo('id');
|
return $this->getAuthInfo('id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final public function getNameByAuthInfo(): string
|
final public function getNameByAuthInfo(): string
|
||||||
{
|
{
|
||||||
return $this->getAuthInfo('name');
|
return $this->getAuthInfo('name');
|
||||||
@ -52,7 +49,6 @@ abstract class AuthService extends CommonService
|
|||||||
return $this->getAuthInfo('role');
|
return $this->getAuthInfo('role');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final public function isLoggedIn(): bool
|
final public function isLoggedIn(): bool
|
||||||
{
|
{
|
||||||
return $this->getSession()->has(SESSION_NAMES['ISLOGIN']);
|
return $this->getSession()->has(SESSION_NAMES['ISLOGIN']);
|
||||||
|
|||||||
@ -36,7 +36,7 @@ class GoogleService extends AuthService
|
|||||||
|
|
||||||
public function getMySocket(string $access_code): mixed
|
public function getMySocket(string $access_code): mixed
|
||||||
{
|
{
|
||||||
if ($this->_mySocket === null) {
|
if (!$this->_mySocket) {
|
||||||
throw new \Exception("Socket 방식이 지정되지 않았습니다.");
|
throw new \Exception("Socket 방식이 지정되지 않았습니다.");
|
||||||
}
|
}
|
||||||
$this->_mySocket->setToken($this->_access_code);
|
$this->_mySocket->setToken($this->_access_code);
|
||||||
@ -51,7 +51,7 @@ class GoogleService extends AuthService
|
|||||||
// local db 사용와의 연결 확인
|
// local db 사용와의 연결 확인
|
||||||
$this->getModel()->where($this->getModel()::PK, $userSNS_entity->getParent());
|
$this->getModel()->where($this->getModel()::PK, $userSNS_entity->getParent());
|
||||||
$entity = $this->getEntity();
|
$entity = $this->getEntity();
|
||||||
if ($entity === null) {
|
if (!$entity) {
|
||||||
throw new PageNotFoundException("회원[{$userSNS_entity->getTitle()}]님은 아직 로컬사용자 연결이 이루어지지 않았습니다.");
|
throw new PageNotFoundException("회원[{$userSNS_entity->getTitle()}]님은 아직 로컬사용자 연결이 이루어지지 않았습니다.");
|
||||||
}
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
|
|||||||
@ -33,7 +33,7 @@ abstract class CommonService
|
|||||||
}
|
}
|
||||||
final public function getModel(): mixed
|
final public function getModel(): mixed
|
||||||
{
|
{
|
||||||
if ($this->_model === null) {
|
if (!$this->_model) {
|
||||||
$modelClass = $this->getModelClass();
|
$modelClass = $this->getModelClass();
|
||||||
$this->_model = new $modelClass();
|
$this->_model = new $modelClass();
|
||||||
// $this->_model->setDebug(true);
|
// $this->_model->setDebug(true);
|
||||||
|
|||||||
@ -13,7 +13,7 @@ class MyLogService
|
|||||||
public function __construct() {}
|
public function __construct() {}
|
||||||
static public function getModel(): Model
|
static public function getModel(): Model
|
||||||
{
|
{
|
||||||
if (self::$_model === null) {
|
if (!self::$_model) {
|
||||||
self::$_model = new Model();
|
self::$_model = new Model();
|
||||||
}
|
}
|
||||||
return self::$_model;
|
return self::$_model;
|
||||||
|
|||||||
@ -61,6 +61,6 @@ class UserService extends CommonService
|
|||||||
}
|
}
|
||||||
public function delete(Entity $entity): bool
|
public function delete(Entity $entity): bool
|
||||||
{
|
{
|
||||||
return $this->getModel()->delete($entity->getPK());
|
return $this->getModel()->delete($entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user