dbmsv4 init...2

This commit is contained in:
최준흠 2025-12-09 14:30:07 +09:00
parent 358323ce8d
commit aabbe2f5e6
4 changed files with 33 additions and 11 deletions

View File

@ -38,7 +38,6 @@ abstract class CommonController extends AbstractCRUDController
protected function batchjob_process(array $uids, array $formDatas): array
{
// Service 로직 호출 (오버라이드 포인트)
return $this->service->batchjob($uids, $formDatas);
}

View File

@ -62,7 +62,7 @@ abstract class CommonService
// 💡 동적으로 가져온 Entity 클래스 이름으로 instanceof 검사
$entityClass = $this->getEntityClass();
if (!$entity instanceof $entityClass) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 {$entityClass}만 가능:\n" . var_export($entity, true));
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 {$entityClass}만 가능:" . get_class($entity));
}
return $this->getEntity_process($entity);
} catch (DatabaseException $e) {
@ -169,9 +169,9 @@ abstract class CommonService
//생성용
protected function create_process(array $formDatas): object
{
$fields = array_keys($formDatas);
$this->getFormService()->setFormFields($fields);
$this->getFormService()->setFormRules('create', $fields);
// $fields = array_keys($formDatas);
// $this->getFormService()->setFormFields($fields);
// $this->getFormService()->setFormRules('create', $fields);
//FormData 검증
if (!$this->getFormService()->validate($formDatas)) {
throw new ValidationException(implode("\n", service('validation')->getErrors()));
@ -238,7 +238,6 @@ abstract class CommonService
// original에 있는 PK 값을 attributes에 명시적으로 복사합니다.
$formDatas[$pkField] = $entity->getPK();
}
// dd($formDatas);
foreach ($formDatas as $key => $value) {
if ($value !== null) {
$entity->$key = $value;
@ -291,8 +290,32 @@ abstract class CommonService
//배치 작업용 수정
protected function batchjob_process($entity, array $formDatas): object
{
// modify_process를 호출하여 로직 재사용 (PK 로드 및 PK 제거/방어 로직 포함)
$entity = $this->modify_process($entity, $formDatas);
$fields = array_keys($formDatas);
$this->getFormService()->setFormFields($fields);
$this->getFormService()->setFormRules('modify', $fields);
// 검증
if (!$this->getFormService()->validate($formDatas)) {
throw new ValidationException(
implode("\n", service('validation')->getErrors())
);
}
//관리자 정보추가용
$formDatas['user_uid'] = $this->getAuthContext()->getUID();
//PK 추가
$pkField = $this->model->getPKField();
if (!isset($formDatas[$pkField]) && !empty($entity->getPK())) {
// original에 있는 PK 값을 attributes에 명시적으로 복사합니다.
$formDatas[$pkField] = $entity->getPK();
}
foreach ($formDatas as $key => $value) {
if ($value !== null) {
$entity->$key = $value;
}
}
$entity = $this->save_process($entity);
//입력/출력데이터 확인용
log_message('debug', var_export($formDatas, true));
log_message('debug', var_export($entity->toArray(), true));
return $entity;
}
final public function batchjob(array $uids, array $formDatas): array

View File

@ -146,8 +146,8 @@ class ClientService extends CustomerService
if ($status === STATUS['WITHDRAWAL']) {
if ($balance < $value) {
throw new RuntimeException(sprintf(
"%s 에서 오류발생: %s 고객의 %s[%s]이/가 사용한 %s 금액/수[%s] 보다 작습니다.",
__METHOD__,
"%s 에서 오류발생: %s 고객의 %s[ %s ]이/가 사용한 %s 금액/수[ %s ]이/가 부족합니다.",
static::class . '->' . __FUNCTION__,
$entity->getTitle(),
$title,
number_format($balance),

View File

@ -213,7 +213,7 @@ class PaymentService extends CommonService
protected function batchjob_process($entity, array $formDatas): object
{
// modify_process를 호출하여 로직 재사용 (PK 로드 및 PK 제거/방어 로직 포함)
$entity = $this->modify_process($entity, $formDatas);
$entity = parent::batchjob_process($entity, $formDatas);
//지불방식에 따른 고객 예치금,쿠폰,포인트 처리
service('customer_clientservice')->updateWalletByPayment($entity);
return $entity;