dbms_init_base

This commit is contained in:
최준흠 2025-05-01 13:31:13 +09:00
parent 12cd2fb3d8
commit 1a879d779c
20 changed files with 35 additions and 55 deletions

View File

@ -19,7 +19,7 @@ class Home extends AdminController
}
protected function getServiceClass(): Service
{
if ($this->service === null) {
if (!$this->service) {
$this->service = new Service($this->request);
}
return $this->service;

View File

@ -22,14 +22,14 @@ class MyLogController extends AdminController
}
protected function getServiceClass(): Service
{
if ($this->service === null) {
if (!$this->service) {
$this->service = new Service();
}
return $this->service;
}
public function getUserService(): UserService
{
if ($this->_userService === null) {
if (!$this->_userService) {
$this->_userService = new UserService($this->request);
}
return $this->_userService;

View File

@ -22,7 +22,7 @@ class UserController extends AdminController
}
protected function getServiceClass(): Service
{
if ($this->service === null) {
if (!$this->service) {
$this->service = new Service($this->request);
}
return $this->service;
@ -40,7 +40,7 @@ class UserController extends AdminController
{
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) {
case 'role':
@ -48,7 +48,7 @@ class UserController extends AdminController
$validation->setRule("{$field}.*", $field, $rule);
break;
default:
$validation = parent::setValidation($action, $field, $rule, $validation);
$validation = parent::setValidation($validation, $action, $field, $rule);
break;
}
return $validation;

View File

@ -43,7 +43,7 @@ abstract class CommonController extends BaseController
}
final public function getService(): mixed
{
if ($this->_service === null) {
if (!$this->_service) {
$serviceClass = $this->getServiceClass();
$this->_service = new $serviceClass($this->request);
// $this->_service->setDebug(true);
@ -111,11 +111,11 @@ abstract class CommonController extends BaseController
// dd($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) {
default:
$validation->setRule($field, $field, $this->getService()->getModel()->getFieldRule($action, $field));
$validation->setRule($field, $field, $rule ?? $this->getService()->getModel()->getFieldRule($action, $field));
break;
}
return $validation;
@ -139,8 +139,8 @@ abstract class CommonController extends BaseController
$validation = service('validation');
// var_dump($this->field_rules);
// exit;
foreach ($this->field_rules as $field => $rule) {
$validation = $this->setValidation($this->action, $field, $rule, $validation);
foreach ($fields as $field) {
$validation = $this->setValidation($validation, $this->action, $field, $this->field_rules[$field] ?? null);
}
if (!$validation->withRequest($this->request)->run()) {
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);
$entity = $this->getService()->getEntity();
if ($entity === null) {
if (!$entity) {
throw new \Exception("해당 정보를 찾을수 없습니다.");
}
return $entity;
@ -329,10 +329,10 @@ abstract class CommonController extends BaseController
$this->init(__FUNCTION__);
$this->getService()->getModel()->where($this->getService()->getModel()::PK, $uid);
$entity = $this->getService()->getEntity();
if ($entity === null) {
if (!$entity) {
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
}
$this->entity = $this->delete_process($uid);
$this->entity = $this->delete_process($entity);
$this->getService()->getModel()->transCommit();
return $this->getResultPageByActon($this->action);
} catch (\Exception $e) {
@ -356,10 +356,10 @@ abstract class CommonController extends BaseController
foreach ($entities as $entity) {
try {
if ($this->getService()->delete($entity)) {
MyLogService::debug("[$entity->getTitle()]" . MESSAGES["DELETED"]);
MyLogService::debug("[{$entity->getTitle()}]" . MESSAGES["DELETED"]);
}
} 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->entity = $this->getService()->getEntity();
if ($this->entity === null) {
if (!$this->entity) {
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
}
list($file_name, $uploaded_filename) = $this->entity->getDownlaodFile();

View File

@ -26,7 +26,7 @@ class UserController extends CommonController
}
protected function getServiceClass(): Service
{
if ($this->service === null) {
if (!$this->service) {
$this->service = new Service($this->request);
}
return $this->service;

View File

@ -16,8 +16,6 @@ abstract class CommonEntity extends Entity
{
parent::__construct($data);
}
abstract public function __toString();
final public function getPK(): string
{
$field = constant("static::PK");
@ -30,7 +28,7 @@ abstract class CommonEntity extends Entity
}
final public function getUpdatedAt(): string
{
return $this->created_at;
return $this->updated_at;
}
final public function getCreatedAt(): string
{

View File

@ -2,17 +2,13 @@
namespace App\Entities;
use App\Entities\CommonEntity as Entity;
use App\Entities\CommonEntity;
use App\Models\MyLogModel as Model;
class MyLogEntity extends Entity
class MyLogEntity extends CommonEntity
{
const PK = Model::PK;
const TITLE = Model::TITLE;
public function __toString(): string
{
return "{$this->getPK()}:{$this->getTitle()}}";
}
//공통부분
//Common Function
}

View File

@ -2,19 +2,13 @@
namespace App\Entities;
use App\Entities\CommonEntity as Entity;
use App\Entities\CommonEntity;
use App\Models\UserModel as Model;
class UserEntity extends CommonEntity
{
const PK = Model::PK;
const TITLE = Model::TITLE;
public function __toString(): string
{
return "{$this->getPK()}:{$this->getID()}:{$this->getTitle()},{$this->getRole()}}";
}
//공통부분
public function getID(): string
{
return $this->attributes['id'];

View File

@ -9,10 +9,6 @@ class UserSNSEntity extends CommonEntity
{
const PK = Model::PK;
const TITLE = Model::TITLE;
public function __toString(): string
{
return "{$this->getPK()}|{$this->getID()}|{$this->getTitle()}";
}
//Common Function
public function getParent(): int|null
{

View File

@ -16,7 +16,7 @@ class API extends GoogleSocket
public function getClient(): Client
{
if ($this->_client === null) {
if (!$this->_client) {
$this->_client = new Client();
$this->_client->setClientId(env('socket.google.client.id'));
$this->_client->setClientSecret(env('socket.google.client.key'));

View File

@ -14,7 +14,7 @@ class CURL extends GoogleSocket
public function getClient(): Client
{
if ($this->_client === null) {
if (!$this->_client) {
$this->_client = new Client();
}
return $this->_client;

View File

@ -39,7 +39,7 @@ abstract class GoogleSocket extends MySocket
}
public function getService(): Service
{
if ($this->_service === null) {
if (!$this->_service) {
$this->_service = new 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('id', $id);
$entity = $this->getEntity();
if ($entity === null) {
if (!$entity) {
//Transaction Start
$this->getService()->getModel()->transStart();
try {

View File

@ -14,7 +14,7 @@ abstract class MySocket
abstract public function getClient(): mixed;
final protected function getCookieJar(): CookieJar
{
if ($this->_cookieJar === null) {
if (!$this->_cookieJar) {
$this->_cookieJar = new CookieJar();
}
return $this->_cookieJar;

View File

@ -16,7 +16,7 @@ class WebSocket extends MySocket
}
public function getClient(): Client
{
if ($this->_client === null) {
if (!$this->_client) {
$this->_client = new Client();
}
return $this->_client;

View File

@ -142,7 +142,7 @@ abstract class CommonModel extends Model
if (!$entity->hasChanged()) {
throw new \Exception(__FUNCTION__ . " 변경된 내용이 없습니다.");
}
// log_message("debug", var_export($entity, true));
log_message("debug", var_export($entity, true));
// 최종 저장 시 오류 발생하면
if (!$this->save($entity)) {
throw new \Exception("저장오류:" . var_export($this->errors(), true));

View File

@ -11,12 +11,10 @@ use CodeIgniter\Session\Session;
abstract class AuthService extends CommonService
{
private ?Session $_session = null;
private ?Model $_model = null;
public function __construct() {}
final public function getSession(): Session
{
if ($this->_session === null) {
if (!$this->_session) {
$this->_session = \Config\Services::session();
}
return $this->_session;
@ -41,7 +39,6 @@ abstract class AuthService extends CommonService
return $this->getAuthInfo('id');
}
final public function getNameByAuthInfo(): string
{
return $this->getAuthInfo('name');
@ -52,7 +49,6 @@ abstract class AuthService extends CommonService
return $this->getAuthInfo('role');
}
final public function isLoggedIn(): bool
{
return $this->getSession()->has(SESSION_NAMES['ISLOGIN']);

View File

@ -36,7 +36,7 @@ class GoogleService extends AuthService
public function getMySocket(string $access_code): mixed
{
if ($this->_mySocket === null) {
if (!$this->_mySocket) {
throw new \Exception("Socket 방식이 지정되지 않았습니다.");
}
$this->_mySocket->setToken($this->_access_code);
@ -51,7 +51,7 @@ class GoogleService extends AuthService
// local db 사용와의 연결 확인
$this->getModel()->where($this->getModel()::PK, $userSNS_entity->getParent());
$entity = $this->getEntity();
if ($entity === null) {
if (!$entity) {
throw new PageNotFoundException("회원[{$userSNS_entity->getTitle()}]님은 아직 로컬사용자 연결이 이루어지지 않았습니다.");
}
return $entity;

View File

@ -33,7 +33,7 @@ abstract class CommonService
}
final public function getModel(): mixed
{
if ($this->_model === null) {
if (!$this->_model) {
$modelClass = $this->getModelClass();
$this->_model = new $modelClass();
// $this->_model->setDebug(true);

View File

@ -13,7 +13,7 @@ class MyLogService
public function __construct() {}
static public function getModel(): Model
{
if (self::$_model === null) {
if (!self::$_model) {
self::$_model = new Model();
}
return self::$_model;

View File

@ -61,6 +61,6 @@ class UserService extends CommonService
}
public function delete(Entity $entity): bool
{
return $this->getModel()->delete($entity->getPK());
return $this->getModel()->delete($entity);
}
}