dbms_init...1

This commit is contained in:
최준흠 2025-06-06 15:32:47 +09:00
parent 1c7426a479
commit 930714b6c9
8 changed files with 67 additions and 16 deletions

View File

@ -42,6 +42,9 @@ class AccountController extends CustomerController
{
//account_balance 체크
$entity = $this->getClientService()->getEntity($formDatas['clientinfo_uid']);
if (!$entity) {
throw new \Exception("{$formDatas['clientinfo_uid']}에 대한 고객정보를 찾을수 없습니다.");
}
$amount = intval($formDatas['amount']);
if ($formDatas['status'] === DEFAULTS['STATUS']) { //입금, 쿠폰추가
$entity = $this->getClientService()->deposit($entity, 'account_balance', $amount);

View File

@ -41,6 +41,9 @@ class CouponController extends CustomerController
{
//coupon_balance 체크
$entity = $this->getClientService()->getEntity($formDatas['clientinfo_uid']);
if (!$entity) {
throw new \Exception("{$formDatas['clientinfo_uid']}에 대한 고객정보를 찾을수 없습니다.");
}
$amount = intval($formDatas['amount']);
if ($formDatas['status'] === DEFAULTS['STATUS']) { //입금, 쿠폰추가
$entity = $this->getClientService()->deposit($entity, 'coupon_balance', $amount);

View File

@ -42,6 +42,9 @@ class PointController extends CustomerController
{
//point_balance 체크
$entity = $this->getClientService()->getEntity($formDatas['clientinfo_uid']);
if (!$entity) {
throw new \Exception("{$formDatas['clientinfo_uid']}에 대한 고객정보를 찾을수 없습니다.");
}
$amount = intval($formDatas['amount']);
if ($formDatas['status'] === DEFAULTS['STATUS']) { //입금, 쿠폰추가
$entity = $this->getClientService()->deposit($entity, 'point_balance', $amount);

View File

@ -93,6 +93,9 @@ class ServiceItemController extends CustomerController
//도메인의 경우 domaininfo에 등록 후 ServiceItemEntity의 item_uid에 넣고 create해야함
if ($formDatas['item_type'] === 'DOMAIN') {
$serviceEntity = $this->getServiceService()->getEntity($formDatas['serviceinfo_uid']);
if (!$serviceEntity) {
throw new \Exception("{$formDatas['serviceinfo_uid']}에 대한 서비스정보를 찾을수 없습니다.");
}
$equipmentEntity = $this->getEquipmentService($formDatas['item_type'])->create([
'clientinfo_uid' => $serviceEntity->getClientInfoUID(),
'domain' => $formDatas['item_uid']

View File

@ -4,14 +4,15 @@ namespace App\Controllers\Auth;
use App\Controllers\CommonController;
use App\Entities\UserEntity;
use App\Helpers\AuthHelper;
use App\Libraries\LogCollector;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use App\Entities\UserEntity;
use App\Helpers\AuthHelper;
abstract class AuthController extends CommonController
{
private $_helper = null;
@ -33,6 +34,18 @@ abstract class AuthController extends CommonController
}
return $this->_helper;
}
//로그인 실패시 오류에서는 Logger에 남기지 않아야 함.
protected function getResultFail(string $message = MESSAGES["FAILED"]): RedirectResponse|string
{
if (env('app.debug.' . $this->getAction())) {
$result = $message;
} else {
$result = redirect()->back()->withInput()->with('error', $message);
}
return $result;
}
//로그인화면
public function create_form_process(): void
{

View File

@ -318,6 +318,9 @@ abstract class CommonController extends BaseController
}
//기존 Entity 가져오기
$entity = $this->getService()->getEntity($uid);
if (!$entity) {
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
}
$this->entity = $this->modify_form_process($entity);
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
$this->getService()->getModel()->transCommit();
@ -339,6 +342,9 @@ abstract class CommonController extends BaseController
try {
//기존 Entity 가져오기
$entity = $this->getService()->getEntity($uid);
if (!$entity) {
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
}
//각 Field 초기화
$this->initAction(__FUNCTION__);
//입력값정의
@ -368,6 +374,9 @@ abstract class CommonController extends BaseController
try {
//기존 Entity 가져오기
$entity = $this->getService()->getEntity($uid);
if (!$entity) {
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
}
//각 Field 초기화:Field는 한개만 존재하므로 Field와 Rule을 재정의
$this->setAction(__FUNCTION__);
$this->setFormFields([$field]);
@ -422,11 +431,16 @@ abstract class CommonController extends BaseController
$entities = [];
foreach ($uids as $uid) {
//기존 Entity 가져오기
$entity = $this->getService()->getEntity($uid);
$entities[] = $this->batchjob_process($entity, $formDatas);
$entity = $this->getService()->getEntity($uid);
if (!$entity) {
LogCollector::debug(__METHOD__ . "에서 {$uid}에 대한 정보를 찾을수 없습니다.");
} else {
$entities[] = $this->batchjob_process($entity, $formDatas);
}
}
$this->entities = $entities;
$this->getService()->getModel()->transCommit();
LogCollector::debug(sprintf("%s에서 총 %s개중 %s개 일괄작업을 완료하였습니다.", __METHOD__, count($uids), count($entities)));
return $this->getResultSuccess();
} catch (\Exception $e) {
$this->getService()->getModel()->transRollback();
@ -452,6 +466,9 @@ abstract class CommonController extends BaseController
$this->setAction(__FUNCTION__);
//기존 Entity 가져오기
$entity = $this->getService()->getEntity($uid);
if (!$entity) {
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
}
$this->entity = $this->delete_process($entity);
$this->getService()->getModel()->transCommit();
return $this->getResultSuccess();
@ -485,10 +502,15 @@ abstract class CommonController extends BaseController
foreach ($uids as $uid) {
//기존 Entity 가져오기
$entity = $this->getService()->getEntity($uid);
$entities[] = $this->batchjob_delete_process($entity);
if (!$entity) {
LogCollector::debug(__METHOD__ . "에서 {$uid}에 대한 정보를 찾을수 없습니다.");
} else {
$entities[] = $this->batchjob_delete_process($entity);
}
}
$this->entities = $entities;
$this->getService()->getModel()->transCommit();
LogCollector::debug(sprintf("%s에서 총 %s개중 %s개 일괄삭제를 완료하였습니다.", __METHOD__, count($uids), count($entities)));
return $this->getResultSuccess();
} catch (\Exception $e) {
$this->getService()->getModel()->transRollback();
@ -509,6 +531,9 @@ abstract class CommonController extends BaseController
helper(['form']);
//기존 Entity 가져오기
$entity = $this->getService()->getEntity($uid);
if (!$entity) {
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
}
$this->entity = $this->view_process($entity);
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
return $this->getResultSuccess();
@ -659,7 +684,11 @@ abstract class CommonController extends BaseController
if (!$uid) {
throw new \Exception("{$output_type}은 반드시 uid의 값이 필요합니다.");
}
$this->entity = $this->getService()->getEntity($uid);
$entity = $this->getService()->getEntity($uid);
if (!$entity) {
throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
}
$this->entity = $entity;
list($file_name, $uploaded_filename) = $this->entity->getDownlaodFile();
$full_path = WRITEPATH . DIRECTORY_SEPARATOR . "uploads" . DIRECTORY_SEPARATOR . $uploaded_filename;
break;

View File

@ -40,7 +40,10 @@ class LocalService extends AuthService
public function login(array $formDatas): UserEntity
{
$entity = $this->getEntity(['id' => $formDatas['id'], 'status' => DEFAULTS['STATUS']]);
$entity = $this->getEntity(['id' => $formDatas['id'], 'status' => DEFAULTS['STATUS']], false);
if (!$entity) {
throw new \Exception("{$formDatas['id']}에 대한 로그인 정보를 찾을수 없습니다.");
}
if (!password_verify($formDatas['passwd'], $entity->getPassword())) {
// log_message("error", "암호: {$formDatas['passwd']}, {$entity->passwd}");
throw new \Exception("암호가 맞지 않습니다.");

View File

@ -58,15 +58,9 @@ abstract class CommonService
}
return $this->_model;
}
final public function getEntity(mixed $where, $isThrow = true): mixed
final public function getEntity(mixed $where, ?string $message = null): mixed
{
$entity = is_array($where) ? $this->getModel()->where($where)->first() : $this->getModel()->find($where);
if (!$entity) {
if ($isThrow) {
throw new \Exception(__METHOD__ . "에서 해당 정보를 찾을수 없습니다.");
}
}
return $entity;
return is_array($where) ? $this->getModel()->where($where)->first() : $this->getModel()->find($where);
}
final public function getEntities(mixed $where = null, array $columns = ['*']): array
{