dbms_init...1

This commit is contained in:
choi.jh 2025-07-11 10:52:38 +09:00
parent 89f85762e7
commit 9901168c62
14 changed files with 88 additions and 77 deletions

View File

@ -37,6 +37,20 @@ class ClientController extends CustomerController
return $this->_helper; return $this->_helper;
} }
//Index,FieldForm관련 //Index,FieldForm관련
//생성관련
protected function create_process(array $formDatas): void
{
// 관리자 UID는 현재 인증된 사용자로 설정
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
parent::create_process($formDatas);
}
//수정관련
protected function modify_process(mixed $entity, array $formDatas): void
{
// 관리자 UID는 현재 인증된 사용자로 설정
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
parent::modify_process($entity, $formDatas);
}
protected function setValidation(Validation $validation, string $field, string $rule): Validation protected function setValidation(Validation $validation, string $field, string $rule): Validation
{ {
switch ($field) { switch ($field) {

View File

@ -67,6 +67,20 @@ class ServiceController extends CustomerController
return $result; return $result;
} }
//Index,FieldForm관련 //Index,FieldForm관련
//생성관련
protected function create_process(array $formDatas): void
{
// 관리자 UID는 현재 인증된 사용자로 설정
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
parent::create_process($formDatas);
}
//수정관련
protected function modify_process(mixed $entity, array $formDatas): void
{
// 관리자 UID는 현재 인증된 사용자로 설정
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
parent::modify_process($entity, $formDatas);
}
//View 관련 //View 관련
protected function view_process(mixed $entity): void protected function view_process(mixed $entity): void
{ {

View File

@ -2,9 +2,11 @@
namespace App\Controllers\Admin\Customer; namespace App\Controllers\Admin\Customer;
use App\Entities\Customer\ServicePaymentEntity;
use App\Helpers\Customer\ServiceItemHelper; use App\Helpers\Customer\ServiceItemHelper;
use App\Services\Customer\ServiceItemService;
use App\Services\Customer\ServiceItemService;
use App\Services\Customer\ServicePaymentService;
use App\Services\Customer\ServiceService; use App\Services\Customer\ServiceService;
use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
@ -14,6 +16,7 @@ use Psr\Log\LoggerInterface;
class ServiceItemController extends CustomerController class ServiceItemController extends CustomerController
{ {
private ?ServiceService $_serviceService = null; private ?ServiceService $_serviceService = null;
private ?ServicePaymentService $_servicePaymentService = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{ {
parent::initController($request, $response, $logger); parent::initController($request, $response, $logger);
@ -50,6 +53,13 @@ class ServiceItemController extends CustomerController
} }
return $this->_serviceService; return $this->_serviceService;
} }
public function getServicePaymentService(): ServicePaymentService
{
if (!$this->_servicePaymentService) {
$this->_servicePaymentService = new ServicePaymentService();
}
return $this->_servicePaymentService;
}
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
{ {
switch ($this->getAction()) { switch ($this->getAction()) {
@ -86,7 +96,16 @@ class ServiceItemController extends CustomerController
if (!$serviceEntity) { if (!$serviceEntity) {
throw new \Exception("{$formDatas['serviceinfo_uid']}에 대한 서비스정보를 찾을수 없습니다."); throw new \Exception("{$formDatas['serviceinfo_uid']}에 대한 서비스정보를 찾을수 없습니다.");
} }
//부모처리
parent::create_process($formDatas); parent::create_process($formDatas);
//결제 처리
$paymentFormDatas = [];
//금액(amount)가 0원일경우는 바로 결제완료 처리함.
if ($this->entity->getAmount() === 0) {
// 관리자 UID는 현재 인증된 사용자로 설정
$paymentFormDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
$paymentFormDatas['status'] = ServicePaymentEntity::STATUS_PAID;
}
// dd($paymentFormDatas);
$this->getServicePaymentService()->createByServiceItemService($paymentFormDatas, $this->entity);
} }
} }

View File

@ -78,6 +78,20 @@ class ServicePaymentController extends CustomerController
return $result; return $result;
} }
//Index,FieldForm관련 //Index,FieldForm관련
//생성관련
protected function create_process(array $formDatas): void
{
// 관리자 UID는 현재 인증된 사용자로 설정
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
parent::create_process($formDatas);
}
//수정관련
protected function modify_process(mixed $entity, array $formDatas): void
{
// 관리자 UID는 현재 인증된 사용자로 설정
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
parent::modify_process($entity, $formDatas);
}
//View 관련 //View 관련
protected function view_process(mixed $entity): void protected function view_process(mixed $entity): void
{ {

View File

@ -44,7 +44,7 @@ class UserController extends AdminController
{ {
switch ($this->getAction()) { switch ($this->getAction()) {
case 'profile_modify': case 'profile_modify':
$this->getMyLogService()->save($this->getService()->getClassName(), __FUNCTION__, $message); $this->getMyLogService()->save($this->getService()->getClassName(), __FUNCTION__, $message, $this->getMyAuth()->getUIDByAuthInfo());
$result = $this->view($this->entity->getPK()); $result = $this->view($this->entity->getPK());
break; break;
case 'profile_modify_form': case 'profile_modify_form':

View File

@ -3,9 +3,10 @@
namespace App\Controllers\CLI; namespace App\Controllers\CLI;
use App\Controllers\BaseController; use App\Controllers\BaseController;
use App\Services\Customer\ServiceService; use App\Entities\Customer\ServicePaymentEntity;
use App\Services\Customer\ServiceItemService; use App\Services\Customer\ServiceItemService;
use App\Services\Customer\ServicePaymentService; use App\Services\Customer\ServicePaymentService;
use App\Services\Customer\ServiceService;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
@ -54,8 +55,8 @@ class Payment extends BaseController
//결제정보 ServicePaymentService에 월별 결제만 신규등록 //결제정보 ServicePaymentService에 월별 결제만 신규등록
if ($itemEntity->getBillingCycle() == "month") { if ($itemEntity->getBillingCycle() == "month") {
//결제정보 ServicePaymentService에 등록 //결제정보 ServicePaymentService에 등록
$this->getServicePaymentService()->setServiceItemEntity($itemEntity); $paymentFormDatas = ['status' => ServicePaymentEntity::STATUS_UNPAID];
$this->getServicePaymentService()->create([]); $this->getServicePaymentService()->createByServiceItemService($paymentFormDatas, $itemEntity);
} }
} }
} }

View File

@ -240,7 +240,7 @@ abstract class CommonController extends BaseController
protected function getResultFail(string $message = MESSAGES["FAILED"]): RedirectResponse protected function getResultFail(string $message = MESSAGES["FAILED"]): RedirectResponse
{ {
LogCollector::debug($message); LogCollector::debug($message);
$this->getMyLogService()->save($this->getService()->getClassName(), __FUNCTION__, $message); $this->getMyLogService()->save($this->getService()->getClassName(), __FUNCTION__, $message, $this->getMyAuth()->getUIDByAuthInfo());
if ($this->request->getMethod() === 'POST') { if ($this->request->getMethod() === 'POST') {
return redirect()->back()->withInput()->with('error', $message); return redirect()->back()->withInput()->with('error', $message);
} }
@ -252,7 +252,7 @@ abstract class CommonController extends BaseController
switch ($this->getAction()) { switch ($this->getAction()) {
case 'create': case 'create':
case 'modify': case 'modify':
$this->getMyLogService()->save($this->getService()->getClassName(), __FUNCTION__, $message); $this->getMyLogService()->save($this->getService()->getClassName(), __FUNCTION__, $message, $this->getMyAuth()->getUIDByAuthInfo());
$result = $this->view($this->entity->getPK()); $result = $this->view($this->entity->getPK());
break; break;
case 'create_form': case 'create_form':
@ -297,6 +297,7 @@ abstract class CommonController extends BaseController
return $this->getResultFail($e->getMessage()); return $this->getResultFail($e->getMessage());
} }
} }
//생성관련
protected function create_process(array $formDatas): void protected function create_process(array $formDatas): void
{ {
//데이터 검증 //데이터 검증

View File

@ -9,6 +9,8 @@ class ServicePaymentEntity extends CustomerEntity
{ {
const PK = ServicePaymentModel::PK; const PK = ServicePaymentModel::PK;
const TITLE = ServicePaymentModel::TITLE; const TITLE = ServicePaymentModel::TITLE;
const STATUS_UNPAID = "default";
const STATUS_PAID = "paid";
//관리자정보객체 //관리자정보객체
final public function getServiceUid(): int final public function getServiceUid(): int
{ {

View File

@ -148,9 +148,10 @@ abstract class CommonModel extends Model
// 최종 저장 시 오류 발생하면 // 최종 저장 시 오류 발생하면
if (!$this->save($formDatas)) { if (!$this->save($formDatas)) {
$message = sprintf( $message = sprintf(
"\n------%s 오류-----\n%s\n------------------------------\n", "\n------%s 오류-----\n%s\n%s\n------------------------------\n",
__METHOD__, __METHOD__,
var_export($this->errors(), true) var_export($this->errors(), true),
$this->getLastQuery()
); );
LogCollector::debug($message); LogCollector::debug($message);
throw new \Exception($message); throw new \Exception($message);

View File

@ -10,20 +10,12 @@ abstract class CommonService
private $_serviceDatas = []; private $_serviceDatas = [];
private $_model = null; private $_model = null;
private $_classNames = []; private $_classNames = [];
private $_myAuth = null;
protected function __construct() {} protected function __construct() {}
abstract public function getModelClass(): mixed; abstract public function getModelClass(): mixed;
abstract public function getEntityClass(): mixed; abstract public function getEntityClass(): mixed;
abstract public function getFormFields(): array; abstract public function getFormFields(): array;
abstract public function getFilterFields(): array; abstract public function getFilterFields(): array;
abstract public function getBatchJobFields(): array; abstract public function getBatchJobFields(): array;
final protected function getMyAuth(): mixed
{
if (!$this->_myAuth) {
$this->_myAuth = service('myauth');
}
return $this->_myAuth;
}
public function getIndexFields(): array public function getIndexFields(): array
{ {
return $this->getFormFields(); return $this->getFormFields();

View File

@ -99,8 +99,6 @@ class ClientService extends CustomerService
public function create(array $formDatas): ClientEntity public function create(array $formDatas): ClientEntity
{ {
//수정자 정보 자동추가용
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
$formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $formDatas['role']); $formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $formDatas['role']);
return parent::create($formDatas); return parent::create($formDatas);
} }
@ -110,8 +108,6 @@ class ClientService extends CustomerService
if (isset($formDatas['role'])) { if (isset($formDatas['role'])) {
$formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $formDatas['role']); $formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $formDatas['role']);
} }
//수정자 정보 자동추가용
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
return parent::modify($entity, $formDatas); return parent::modify($entity, $formDatas);
} }
} }

View File

@ -6,12 +6,10 @@ use App\Entities\Customer\ServiceItemEntity;
use App\Entities\Equipment\Part\IpEntity; use App\Entities\Equipment\Part\IpEntity;
use App\Models\Customer\ServiceItemModel; use App\Models\Customer\ServiceItemModel;
use App\Services\Customer\CustomerService; use App\Services\Customer\CustomerService;
use App\Services\Customer\ServicePaymentService;
use App\Services\Equipment\Part\IpService; use App\Services\Equipment\Part\IpService;
class ServiceItemService extends CustomerService class ServiceItemService extends CustomerService
{ {
private ?ServicePaymentService $_servicePaymentService = null;
private ?IpService $_ipService = null; private ?IpService $_ipService = null;
public function __construct() public function __construct()
{ {
@ -33,13 +31,6 @@ class ServiceItemService extends CustomerService
} }
return $this->_ipService; return $this->_ipService;
} }
public function getServicePaymentService(): ServicePaymentService
{
if (!$this->_servicePaymentService) {
$this->_servicePaymentService = new ServicePaymentService();
}
return $this->_servicePaymentService;
}
public function getFormFields(): array public function getFormFields(): array
{ {
return [ return [
@ -67,16 +58,6 @@ class ServiceItemService extends CustomerService
} }
//Entity의 관련객체정의용 //Entity의 관련객체정의용
//FieldForm관련용 //FieldForm관련용
public function create(array $formDatas): ServiceItemEntity
{
$entity = parent::create($formDatas);
//결제정보 ServicePaymentService에 등록
$this->getServicePaymentService()->setServiceItemEntity($entity);
//관리자 정보 자동추가용
$paymentFormDatas = ['user_uid' => $this->getMyAuth()->getUIDByAuthInfo()];
$this->getServicePaymentService()->create($paymentFormDatas);
return $entity;
}
public function modify(mixed $entity, array $formDatas): ServiceItemEntity public function modify(mixed $entity, array $formDatas): ServiceItemEntity
{ {
//IP가 기존과 다를경우 //toggle,batchjob의 경우 $formDatas에 code가 없을수도 있음 //IP가 기존과 다를경우 //toggle,batchjob의 경우 $formDatas에 code가 없을수도 있음

View File

@ -6,14 +6,9 @@ use App\Entities\Customer\ServiceEntity;
use App\Entities\Customer\ServiceItemEntity; use App\Entities\Customer\ServiceItemEntity;
use App\Entities\Customer\ServicePaymentEntity; use App\Entities\Customer\ServicePaymentEntity;
use App\Models\Customer\ServicePaymentModel; use App\Models\Customer\ServicePaymentModel;
use App\Services\Customer\ServiceService;
use App\Services\UserService;
class ServicePaymentService extends CustomerService class ServicePaymentService extends CustomerService
{ {
private ?ServiceItemEntity $_serviceItemEntity = null;
private ?UserService $_userService = null;
private ?ServiceService $_serviceService = null;
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
@ -53,18 +48,6 @@ class ServicePaymentService extends CustomerService
{ {
return ['serviceinfo_uid', "ownerinfo_uid", 'item_type', 'item_uid', 'billing_cycle', 'amount', 'billing_at', 'issue_at', 'countdown', 'status', 'user_uid']; return ['serviceinfo_uid', "ownerinfo_uid", 'item_type', 'item_uid', 'billing_cycle', 'amount', 'billing_at', 'issue_at', 'countdown', 'status', 'user_uid'];
} }
public function setServiceItemEntity(ServiceItemEntity $entity): void
{
$this->_serviceItemEntity = $entity;
}
public function getServiceItemEntity(): ServiceItemEntity
{
if ($this->_serviceItemEntity === null) {
throw new \Exception("ServiceItem이 지정되지 않았습니다.");
}
return $this->_serviceItemEntity;
}
//Entity의 관련객체정의용
//기본 기능부분 //기본 기능부분
//FieldForm관련용 //FieldForm관련용
public function getFormFieldOption(string $field, array $options = []): array public function getFormFieldOption(string $field, array $options = []): array
@ -93,30 +76,23 @@ class ServicePaymentService extends CustomerService
return $unpaids; return $unpaids;
} }
//결체처리정보 등록 : ServiceItemService에서 사용 //결체처리정보 등록 : ServiceItemService에서 사용
public function create(array $formDatas): ServicePaymentEntity public function createByServiceItemService(array $formDatas, ServiceItemEntity $serviceItemEntity): ServicePaymentEntity
{ {
$serviceItemEntity = $this->getServiceItemEntity();
$serviceEntity = $this->getServiceService()->getEntity($serviceItemEntity->getServiceUid()); $serviceEntity = $this->getServiceService()->getEntity($serviceItemEntity->getServiceUid());
if (!$serviceEntity) { if (!$serviceEntity) {
throw new \Exception("{$serviceItemEntity->getServiceUid()}에 대한 서비스정보를 찾을수 없습니다."); throw new \Exception("{$serviceItemEntity->getServiceUid()}에 대한 서비스정보를 찾을수 없습니다.");
} }
$formDatas = [ $formDatas['serviceinfo_uid'] = $serviceItemEntity->getServiceUid();
'serviceinfo_uid' => $serviceItemEntity->getServiceUid(), $formDatas['ownerinfo_uid'] = $serviceEntity->getOwnerUid();
'ownerinfo_uid' => $serviceEntity->getOwnerUid(), $formDatas['item_type'] = $serviceItemEntity->getItemType();
'item_type' => $serviceItemEntity->getItemType(), $formDatas['item_uid'] = $serviceItemEntity->getItemUid();
'item_uid' => $serviceItemEntity->getItemUid(), $formDatas['billing_cycle'] = $serviceItemEntity->getBillingCycle();
'billing_cycle' => $serviceItemEntity->getBillingCycle(), $formDatas['amount'] = $serviceItemEntity->getAmount();
'amount' => $serviceItemEntity->getAmount(), $formDatas['billing_at'] = $serviceEntity->getBillingAt();
'billing_at' => $serviceEntity->getBillingAt(), $formDatas['issue_at'] = date('Y-m-d');
'issue_at' => date('Y-m-d'),
];
//금액(amount)가 0원일경우는 바로 결제완료 및 결제자 등록 처리함.
if ($serviceItemEntity->getAmount() === 0) {
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
$formDatas['status'] = 'paid';
}
return $this->create($formDatas); return $this->create($formDatas);
} }
//Service정보 와 관리자가 기존 정보과 같고, 결제가 아직 완료되지 않은 결제정보의 관리자 변경 //Service정보 와 관리자가 기존 정보과 같고, 결제가 아직 완료되지 않은 결제정보의 관리자 변경
public function modifyOwnerByService(ServiceEntity $serviceEntity, int $ownerinfo_uid) public function modifyOwnerByService(ServiceEntity $serviceEntity, int $ownerinfo_uid)
{ {

View File

@ -69,10 +69,10 @@ class MyLogService extends CommonService
} }
return $options; return $options;
} }
public function save(string $class, string $method, string $title): MyLogEntity public function save(string $class, string $method, string $title, int $user_uid): MyLogEntity
{ {
$formDatas = [ $formDatas = [
'user_uid' => $this->getMyAuth()->getUIDByAuthInfo(), 'user_uid' => $user_uid,
'class_name' => $class, 'class_name' => $class,
'method_name' => $method, 'method_name' => $method,
'title' => $title, 'title' => $title,