From c71efa7eb56b2ea2d77978663b8f4f2f3fde4d28 Mon Sep 17 00:00:00 2001 From: "choi.jh" Date: Mon, 27 Oct 2025 10:29:14 +0900 Subject: [PATCH] dbmsv3 init...1 --- app/Controllers/Admin/BoardController.php | 1 + .../Admin/Customer/AccountController.php | 3 ++- .../Admin/Customer/ClientController.php | 1 + .../Admin/Customer/CouponController.php | 3 ++- .../Admin/Customer/PointController.php | 9 ++++++++- app/Controllers/CommonController.php | 2 ++ app/Models/BoardModel.php | 16 +++++----------- app/Models/CommonModel.php | 8 -------- app/Models/Customer/AccountModel.php | 19 ++++++------------- app/Models/Customer/ClientModel.php | 6 ------ app/Models/Customer/CouponModel.php | 6 ------ app/Models/Customer/PointModel.php | 6 ------ app/Models/Customer/ServiceModel.php | 2 -- app/Models/Equipment/ServerModel.php | 7 ------- app/Models/MyLogModel.php | 17 +++++------------ app/Models/PaymentModel.php | 7 ------- app/Services/Auth/AuthService.php | 12 ++++++------ 17 files changed, 38 insertions(+), 87 deletions(-) diff --git a/app/Controllers/Admin/BoardController.php b/app/Controllers/Admin/BoardController.php index b1a6cd5..f591b7a 100644 --- a/app/Controllers/Admin/BoardController.php +++ b/app/Controllers/Admin/BoardController.php @@ -2,6 +2,7 @@ namespace App\Controllers\Admin; +use App\Entities\BoardEntity; use App\Services\BoardService; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; diff --git a/app/Controllers/Admin/Customer/AccountController.php b/app/Controllers/Admin/Customer/AccountController.php index a6e8698..3c1b1ad 100644 --- a/app/Controllers/Admin/Customer/AccountController.php +++ b/app/Controllers/Admin/Customer/AccountController.php @@ -2,8 +2,9 @@ namespace App\Controllers\Admin\Customer; -use App\Services\Customer\AccountService; +use App\Entities\Customer\AccountEntity; +use App\Services\Customer\AccountService; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; diff --git a/app/Controllers/Admin/Customer/ClientController.php b/app/Controllers/Admin/Customer/ClientController.php index f31fa49..d315af1 100644 --- a/app/Controllers/Admin/Customer/ClientController.php +++ b/app/Controllers/Admin/Customer/ClientController.php @@ -71,6 +71,7 @@ class ClientController extends CustomerController } return $result; } + //고객 상세정보 public function detail(mixed $uid): RedirectResponse|string { try { diff --git a/app/Controllers/Admin/Customer/CouponController.php b/app/Controllers/Admin/Customer/CouponController.php index 2b29377..d5e13b8 100644 --- a/app/Controllers/Admin/Customer/CouponController.php +++ b/app/Controllers/Admin/Customer/CouponController.php @@ -2,8 +2,9 @@ namespace App\Controllers\Admin\Customer; -use App\Services\Customer\CouponService; +use App\Entities\Customer\CouponEntity; +use App\Services\Customer\CouponService; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; diff --git a/app/Controllers/Admin/Customer/PointController.php b/app/Controllers/Admin/Customer/PointController.php index e2c14b2..e2259ec 100644 --- a/app/Controllers/Admin/Customer/PointController.php +++ b/app/Controllers/Admin/Customer/PointController.php @@ -2,8 +2,9 @@ namespace App\Controllers\Admin\Customer; -use App\Services\Customer\PointService; +use App\Entities\Customer\PointEntity; +use App\Services\Customer\PointService; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; @@ -27,4 +28,10 @@ class PointController extends CustomerController return $this->_service; } //Index,FieldForm관련. + //생성 + protected function create_proceess(array $formDatas): PointEntity + { + $formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo(); + return parent::create_process($formDatas); + } } diff --git a/app/Controllers/CommonController.php b/app/Controllers/CommonController.php index 6f4dce0..3247f84 100644 --- a/app/Controllers/CommonController.php +++ b/app/Controllers/CommonController.php @@ -147,6 +147,8 @@ abstract class CommonController extends BaseController } protected function create_process(array $formDatas): mixed { + // 관리자 UID는 현재 인증된 사용자로 설정 + $formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo(); return $this->getService()->create($formDatas); } public function create(): RedirectResponse|string diff --git a/app/Models/BoardModel.php b/app/Models/BoardModel.php index 33c7cb9..2b1e268 100644 --- a/app/Models/BoardModel.php +++ b/app/Models/BoardModel.php @@ -7,11 +7,11 @@ use App\Entities\BoardEntity; class BoardModel extends CommonModel { const TABLE = "boardinfo"; - const PK = "uid"; + const PK = "uid"; const TITLE = "title"; - protected $table = self::TABLE; - protected $primaryKey = self::PK; - protected $returnType = BoardEntity::class; + protected $table = self::TABLE; + protected $primaryKey = self::PK; + protected $returnType = BoardEntity::class; protected $allowedFields = [ "uid", "user_uid", @@ -20,7 +20,7 @@ class BoardModel extends CommonModel "title", "content", "status", - "updated_at" + "updated_at", ]; public function __construct() { @@ -51,10 +51,4 @@ class BoardModel extends CommonModel } return $rule; } - final public function create(array $formDatas): BoardEntity - { - // 관리자 UID는 현재 인증된 사용자로 설정 - $formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo(); - return parent::create($formDatas); - } } diff --git a/app/Models/CommonModel.php b/app/Models/CommonModel.php index 37a01aa..7435253 100644 --- a/app/Models/CommonModel.php +++ b/app/Models/CommonModel.php @@ -6,7 +6,6 @@ use CodeIgniter\Model; abstract class CommonModel extends Model { - private $_myAuth = null; protected $table = ''; protected $primaryKey = ''; protected $useAutoIncrement = true; @@ -65,13 +64,6 @@ abstract class CommonModel extends Model // protected $beforeInsert = ['generateUUID']; // allowedFields에는 PK넣으면 않됨, Column Type: CHAR(36) // - final public function getMyAuth(): mixed - { - if (!$this->_myAuth) { - $this->_myAuth = service('myauth'); - } - return $this->_myAuth; - } final protected function generateUUID(): string { $data = random_bytes(16); diff --git a/app/Models/Customer/AccountModel.php b/app/Models/Customer/AccountModel.php index a6f2064..a5bd394 100644 --- a/app/Models/Customer/AccountModel.php +++ b/app/Models/Customer/AccountModel.php @@ -7,11 +7,11 @@ use App\Entities\Customer\AccountEntity; class AccountModel extends CustomerModel { const TABLE = "accountinfo"; - const PK = "uid"; + const PK = "uid"; const TITLE = "title"; - protected $table = self::TABLE; - protected $primaryKey = self::PK; - protected $returnType = AccountEntity::class; + protected $table = self::TABLE; + protected $primaryKey = self::PK; + protected $returnType = AccountEntity::class; protected $allowedFields = [ "uid", "user_uid", @@ -23,7 +23,7 @@ class AccountModel extends CustomerModel "issue_at", "amount", "status", - "updated_at" + "updated_at", ]; public function __construct() { @@ -38,7 +38,7 @@ class AccountModel extends CustomerModel case "user_uid": case "clientinfo_uid": case "amount": - $rule = "required|numeric"; + $rule = "required|numeric"; break; case "bank": case "title": @@ -58,11 +58,4 @@ class AccountModel extends CustomerModel } return $rule; } - - final public function create(array $formDatas): AccountEntity - { - // 관리자 UID는 현재 인증된 사용자로 설정 - $formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo(); - return parent::create($formDatas); - } } diff --git a/app/Models/Customer/ClientModel.php b/app/Models/Customer/ClientModel.php index ed3387e..54359ec 100644 --- a/app/Models/Customer/ClientModel.php +++ b/app/Models/Customer/ClientModel.php @@ -68,10 +68,4 @@ class ClientModel extends CustomerModel return $rule; } //입력전 코드처리 - final public function create(array $formDatas): ClientEntity - { - // 관리자 UID는 현재 인증된 사용자로 설정 - $formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo(); - return parent::create($formDatas); - } } diff --git a/app/Models/Customer/CouponModel.php b/app/Models/Customer/CouponModel.php index 325853b..34b62ab 100644 --- a/app/Models/Customer/CouponModel.php +++ b/app/Models/Customer/CouponModel.php @@ -50,10 +50,4 @@ class CouponModel extends CustomerModel } return $rule; } - final public function create(array $formDatas): CouponEntity - { - // 관리자 UID는 현재 인증된 사용자로 설정 - $formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo(); - return parent::create($formDatas); - } } diff --git a/app/Models/Customer/PointModel.php b/app/Models/Customer/PointModel.php index e5c115c..688e5d7 100644 --- a/app/Models/Customer/PointModel.php +++ b/app/Models/Customer/PointModel.php @@ -50,10 +50,4 @@ class PointModel extends CustomerModel } return $rule; } - final public function create(array $formDatas): PointEntity - { - // 관리자 UID는 현재 인증된 사용자로 설정 - $formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo(); - return parent::create($formDatas); - } } diff --git a/app/Models/Customer/ServiceModel.php b/app/Models/Customer/ServiceModel.php index 54f1b71..b07f215 100644 --- a/app/Models/Customer/ServiceModel.php +++ b/app/Models/Customer/ServiceModel.php @@ -83,8 +83,6 @@ class ServiceModel extends CustomerModel final public function create(array $formDatas): ServiceEntity { $formDatas['code'] = $formDatas['site'] . "_s" . uniqid(); - // 관리자 UID는 현재 인증된 사용자로 설정 - $formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo(); return parent::create($formDatas); } } diff --git a/app/Models/Equipment/ServerModel.php b/app/Models/Equipment/ServerModel.php index e555be5..d99706a 100644 --- a/app/Models/Equipment/ServerModel.php +++ b/app/Models/Equipment/ServerModel.php @@ -97,11 +97,4 @@ class ServerModel extends EquipmentModel return $value; } //기본기능 - //입력전 코드처리 - final public function create(array $formDatas): ServerEntity - { - // 관리자 UID는 현재 인증된 사용자로 설정 - $formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo(); - return parent::create($formDatas); - } } diff --git a/app/Models/MyLogModel.php b/app/Models/MyLogModel.php index 578d633..1f74f24 100644 --- a/app/Models/MyLogModel.php +++ b/app/Models/MyLogModel.php @@ -7,18 +7,18 @@ use App\Entities\MyLogEntity; class MyLogModel extends CommonModel { const TABLE = "mylog"; - const PK = "uid"; + const PK = "uid"; const TITLE = "title"; - protected $table = self::TABLE; - protected $primaryKey = self::PK; - protected $returnType = MyLogEntity::class; + protected $table = self::TABLE; + protected $primaryKey = self::PK; + protected $returnType = MyLogEntity::class; protected $allowedFields = [ "uid", "user_uid", "title", "content", "status", - "updated_at" + "updated_at", ]; public function __construct() { @@ -48,11 +48,4 @@ class MyLogModel extends CommonModel } return $rule; } - - final public function create(array $formDatas): MylogEntity - { - // 관리자 UID는 현재 인증된 사용자로 설정 - $formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo(); - return parent::create($formDatas); - } } diff --git a/app/Models/PaymentModel.php b/app/Models/PaymentModel.php index 39655f3..212c83c 100644 --- a/app/Models/PaymentModel.php +++ b/app/Models/PaymentModel.php @@ -64,11 +64,4 @@ class PaymentModel extends CommonModel } return $rule; } - - final public function create(array $formDatas): PaymentEntity - { - // 관리자 UID는 현재 인증된 사용자로 설정 - $formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo(); - return parent::create($formDatas); - } } diff --git a/app/Services/Auth/AuthService.php b/app/Services/Auth/AuthService.php index 37b89b5..d6fa510 100644 --- a/app/Services/Auth/AuthService.php +++ b/app/Services/Auth/AuthService.php @@ -28,11 +28,11 @@ abstract class AuthService extends CommonService } return $this->_session; } - private function getAuthInfo(string $key = ""): array|string + private function getAuthInfo(string $key = ""): array|string|null { $authInfo = $this->getSession()->get(SESSION_NAMES['AUTH']); if ($key) { - return $authInfo[$key] ?? ""; + return $authInfo[$key] ?? null; } return $authInfo; } @@ -40,19 +40,19 @@ abstract class AuthService extends CommonService { return ['id', 'passwd']; } - final public function getUIDByAuthInfo(): string + final public function getUIDByAuthInfo(): string|null { return $this->getAuthInfo('uid'); } - final public function getIDByAuthInfo(): string + final public function getIDByAuthInfo(): string|null { return $this->getAuthInfo('id'); } - final public function getNameByAuthInfo(): string + final public function getNameByAuthInfo(): string|null { return $this->getAuthInfo('name'); } - final public function getRoleByAuthInfo(): string + final public function getRoleByAuthInfo(): string|null { return $this->getAuthInfo('role'); }