cfmgrv4 init...10

This commit is contained in:
최준흠 2025-03-12 15:56:01 +09:00
parent 364567c138
commit 0e2f198687
11 changed files with 179 additions and 91 deletions

View File

@ -54,6 +54,93 @@ abstract class CloudflareController extends AdminController
} }
return $this->_recordModel; return $this->_recordModel;
} }
//생성관련
protected function create_process_result($message): RedirectResponse|string
{
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, $message, $this->myauth->getUIDByAuthInfo());
return parent::create_process_result($message);
// $this->init(__FUNCTION__);
// helper(['form']);
// $this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
// return view(
// strtolower($this->view_path . $this->getService()->getClassPath() . "/create_result"),
// data: ['viewDatas' => $this->getViewDatas()]
// );
}
protected function create_process_failed($message): RedirectResponse|string
{
MyLogService::add("error", $message);
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, MESSAGES["FAILED"], $this->myauth->getUIDByAuthInfo());
return parent::create_process_failed($message);
}
//수정관련
protected function modify_process_result($message): RedirectResponse|string
{
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, $message, $this->myauth->getUIDByAuthInfo());
return parent::modify_process_result($message);
}
protected function modify_process_failed($message): RedirectResponse|string
{
MyLogService::add("error", $message);
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, MESSAGES["FAILED"], $this->myauth->getUIDByAuthInfo());
return parent::modify_process_failed($message);
}
//단일필드작업
protected function toggle_process_result($message): RedirectResponse|string
{
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, $message, $this->myauth->getUIDByAuthInfo());
return parent::toggle_process_result($message);
}
protected function toggle_process_failed($message): RedirectResponse|string
{
MyLogService::add("error", $message);
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, MESSAGES["FAILED"], $this->myauth->getUIDByAuthInfo());
return parent::toggle_process_failed($message);
}
//일괄처리작업
protected function batchjob_process_result($message): RedirectResponse|string
{
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, $message, $this->myauth->getUIDByAuthInfo());
return parent::batchjob_process_result($message);
}
protected function batchjob_process_failed($message): RedirectResponse|string
{
MyLogService::add("error", $message);
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, MESSAGES["FAILED"], $this->myauth->getUIDByAuthInfo());
return parent::batchjob_process_failed($message);
}
//Delete관련
protected function delete_process_result($message): RedirectResponse|string
{
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, $message, $this->myauth->getUIDByAuthInfo());
return parent::delete_process_result($message);
}
protected function delete_process_failed($message): RedirectResponse|string
{
MyLogService::add("error", $message);
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, MESSAGES["FAILED"], $this->myauth->getUIDByAuthInfo());
return parent::delete_process_failed($message);
}
//일괄삭제
protected function batchdelete_process_result($message): RedirectResponse|string
{
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, $message, $this->myauth->getUIDByAuthInfo());
return parent::batchjob_delete_process_result($message);
}
protected function batchdelete_process_failed($message): RedirectResponse|string
{
MyLogService::add("error", $message);
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, MESSAGES["FAILED"], $this->myauth->getUIDByAuthInfo());
return parent::batchjob_delete_process_failed($message);
}
//Sync관련련
protected function sync_process(string $uid): void {} protected function sync_process(string $uid): void {}
protected function sync_process_result($message): RedirectResponse|string protected function sync_process_result($message): RedirectResponse|string
{ {

View File

@ -11,6 +11,7 @@ use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use App\Services\MyLogService;
class ZoneController extends CloudflareController class ZoneController extends CloudflareController
{ {
@ -131,16 +132,7 @@ class ZoneController extends CloudflareController
} }
$this->entitys = $entitys; $this->entitys = $entitys;
} }
protected function create_process_result($message): RedirectResponse|string
{
$this->init(__FUNCTION__);
helper(['form']);
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
return view(
strtolower($this->view_path . $this->getService()->getClassPath() . "/create_result"),
data: ['viewDatas' => $this->getViewDatas()]
);
}
public function create(): RedirectResponse|string public function create(): RedirectResponse|string
{ {
$this->init(__FUNCTION__, [$this->getService()->getModel()::PARENT, 'domains', 'hosts', 'type', 'content', 'proxied']); $this->init(__FUNCTION__, [$this->getService()->getModel()::PARENT, 'domains', 'hosts', 'type', 'content', 'proxied']);

View File

@ -13,7 +13,6 @@ use CodeIgniter\Validation\Validation;
use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Reader\Html; use PhpOffice\PhpSpreadsheet\Reader\Html;
use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf; use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf;
use App\Services\MyLogService;
abstract class CommonController extends BaseController abstract class CommonController extends BaseController
{ {
@ -127,6 +126,10 @@ abstract class CommonController extends BaseController
$url = strtolower(base_url() . $this->uri_path . $this->getService()->getClassName()) . "/view/" . $this->entity->getPK(); $url = strtolower(base_url() . $this->uri_path . $this->getService()->getClassName()) . "/view/" . $this->entity->getPK();
return redirect()->to($url)->with('error', $message); return redirect()->to($url)->with('error', $message);
} }
protected function create_process_failed($message): RedirectResponse|string
{
return redirect()->back()->withInput()->with('error', $message);
}
final protected function create_procedure(): RedirectResponse|string final protected function create_procedure(): RedirectResponse|string
{ {
//Transaction Start //Transaction Start
@ -135,18 +138,11 @@ abstract class CommonController extends BaseController
helper(['form']); helper(['form']);
$this->create_process(); $this->create_process();
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
if ($this->isMyLog) {
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, MESSAGES["SUCCESS"], $this->myauth->getUIDByAuthInfo());
}
return $this->create_process_result(MESSAGES["SUCCESS"]); return $this->create_process_result(MESSAGES["SUCCESS"]);
} catch (\Exception $e) { } catch (\Exception $e) {
//Transaction Rollback //Transaction Rollback
$this->getService()->getModel()->transRollback(); $this->getService()->getModel()->transRollback();
if ($this->isMyLog) { return $this->create_process_result($e->getMessage());
MyLogService::add("error", $e->getMessage());
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, MESSAGES["FAILED"], $this->myauth->getUIDByAuthInfo());
}
return redirect()->back()->withInput()->with('error', $e->getMessage());
} }
} }
// 수정 // 수정
@ -192,10 +188,6 @@ abstract class CommonController extends BaseController
if ($this->entity === null) { if ($this->entity === null) {
throw new \Exception(__FUNCTION__ . " => {$uid} 정보를 찾을수 없습니다."); throw new \Exception(__FUNCTION__ . " => {$uid} 정보를 찾을수 없습니다.");
} }
//수정된값 Log남기기
foreach ($this->fields as $field) {
MyLogService::add("info", "{$field}: {$this->formDatas[$field]}=>{$this->entity->$field}");
}
$this->entity = $this->getService()->modify($this->entity, $this->formDatas); $this->entity = $this->getService()->modify($this->entity, $this->formDatas);
} }
protected function modify_process_result($message): RedirectResponse|string protected function modify_process_result($message): RedirectResponse|string
@ -203,6 +195,10 @@ abstract class CommonController extends BaseController
$url = strtolower(base_url() . $this->uri_path . $this->getService()->getClassName()) . "/view/" . $this->entity->getPK(); $url = strtolower(base_url() . $this->uri_path . $this->getService()->getClassName()) . "/view/" . $this->entity->getPK();
return redirect()->to($url)->with('error', $message); return redirect()->to($url)->with('error', $message);
} }
protected function modify_process_failed($message): RedirectResponse|string
{
return redirect()->back()->withInput()->with('error', $message);
}
final protected function modify_procedure(mixed $uid): RedirectResponse|string final protected function modify_procedure(mixed $uid): RedirectResponse|string
{ {
//Transaction Start //Transaction Start
@ -211,18 +207,11 @@ abstract class CommonController extends BaseController
helper(['form']); helper(['form']);
$this->modify_process($uid); $this->modify_process($uid);
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
if ($this->isMyLog) {
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, MESSAGES["SUCCESS"], $this->myauth->getUIDByAuthInfo());
}
return $this->modify_process_result(MESSAGES["SUCCESS"]); return $this->modify_process_result(MESSAGES["SUCCESS"]);
} catch (\Exception $e) { } catch (\Exception $e) {
//Transaction Rollback //Transaction Rollback
$this->getService()->getModel()->transRollback(); $this->getService()->getModel()->transRollback();
if ($this->isMyLog) { return $this->modify_process_result($e->getMessage());
MyLogService::add("error", $e->getMessage());
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, MESSAGES["FAILED"], $this->myauth->getUIDByAuthInfo());
}
return redirect()->back()->withInput()->with('error', $e->getMessage());
} }
} }
//단일필드작업 //단일필드작업
@ -230,6 +219,10 @@ abstract class CommonController extends BaseController
{ {
return redirect()->to($this->myauth->popPreviousUrl())->with('error', $message); return redirect()->to($this->myauth->popPreviousUrl())->with('error', $message);
} }
protected function toggle_process_failed($message): RedirectResponse|string
{
return redirect()->back()->with('error', $message);
}
final protected function toggle_procedure(mixed $uid, string $field): RedirectResponse final protected function toggle_procedure(mixed $uid, string $field): RedirectResponse
{ {
//Transaction Start //Transaction Start
@ -239,19 +232,11 @@ abstract class CommonController extends BaseController
$this->fields = [$field]; $this->fields = [$field];
$this->modify_process($uid); $this->modify_process($uid);
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
if ($this->isMyLog) {
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, MESSAGES["SUCCESS"], $this->myauth->getUIDByAuthInfo());
}
return $this->toggle_process_result(MESSAGES["SUCCESS"]); return $this->toggle_process_result(MESSAGES["SUCCESS"]);
} catch (\Exception $e) { } catch (\Exception $e) {
//Transaction Rollback //Transaction Rollback
$this->getService()->getModel()->transRollback(); $this->getService()->getModel()->transRollback();
if ($this->isMyLog) { return $this->toggle_process_failed($e->getMessage());
MyLogService::add("error", $e->getMessage());
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, MESSAGES["FAILED"], $this->myauth->getUIDByAuthInfo());
}
return redirect()->back()->with('error', $e->getMessage());
} }
} }
//일괄처리작업 //일괄처리작업
@ -259,6 +244,10 @@ abstract class CommonController extends BaseController
{ {
return redirect()->to($this->myauth->popPreviousUrl())->with('error', $message); return redirect()->to($this->myauth->popPreviousUrl())->with('error', $message);
} }
protected function batchjob_process_failed($message): RedirectResponse|string
{
return redirect()->back()->with('error', $message);
}
final protected function batchjob_procedure(): RedirectResponse final protected function batchjob_procedure(): RedirectResponse
{ {
//Transaction Start //Transaction Start
@ -281,19 +270,11 @@ abstract class CommonController extends BaseController
$this->modify_process($uid); $this->modify_process($uid);
} }
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
if ($this->isMyLog) {
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, MESSAGES["SUCCESS"], $this->myauth->getUIDByAuthInfo());
}
return $this->batchjob_process_result(MESSAGES["SUCCESS"]); return $this->batchjob_process_result(MESSAGES["SUCCESS"]);
} catch (\Exception $e) { } catch (\Exception $e) {
//Transaction Rollback //Transaction Rollback
$this->getService()->getModel()->transRollback(); $this->getService()->getModel()->transRollback();
if ($this->isMyLog) { return $this->batchjob_process_failed($e->getMessage());
MyLogService::add("error", $e->getMessage());
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, MESSAGES["FAILED"], $this->myauth->getUIDByAuthInfo());
}
return redirect()->back()->with('error', $e->getMessage());
} }
} }
//View //View
@ -314,13 +295,17 @@ abstract class CommonController extends BaseController
data: ['viewDatas' => $this->getViewDatas()] data: ['viewDatas' => $this->getViewDatas()]
); );
} }
protected function view_process_failed($message): RedirectResponse|string
{
return redirect()->back()->with('error', $message);
}
final protected function view_procedure(mixed $uid): RedirectResponse|string final protected function view_procedure(mixed $uid): RedirectResponse|string
{ {
try { try {
$this->view_process($uid); $this->view_process($uid);
return $this->view_process_result(); return $this->view_process_result();
} catch (\Exception $e) { } catch (\Exception $e) {
return redirect()->back()->with('error', $e->getMessage()); return $this->view_process_failed($e->getMessage());
} }
} }
//삭제 delete,batchjob_delete 공통사용 //삭제 delete,batchjob_delete 공통사용
@ -331,16 +316,16 @@ abstract class CommonController extends BaseController
if ($this->entity === null) { if ($this->entity === null) {
throw new \Exception("{$uid} 정보를 찾을수 없습니다."); throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
} }
//삭제된값 Log남기기
foreach ($this->fields as $field) {
MyLogService::add("info", "{$field}: {$this->entity->$field}");
}
$this->entity = $this->getService()->delete($this->entity->getPK()); $this->entity = $this->getService()->delete($this->entity->getPK());
} }
protected function delete_process_result($message): RedirectResponse|string protected function delete_process_result($message): RedirectResponse|string
{ {
return redirect()->to($this->myauth->popPreviousUrl())->with('error', $message); return redirect()->to($this->myauth->popPreviousUrl())->with('error', $message);
} }
protected function delete_process_failed($message): RedirectResponse|string
{
return redirect()->back()->with('error', $message);
}
final public function delete(mixed $uid): RedirectResponse final public function delete(mixed $uid): RedirectResponse
{ {
//Transaction Start //Transaction Start
@ -348,21 +333,21 @@ abstract class CommonController extends BaseController
try { try {
$this->delete_process($uid); $this->delete_process($uid);
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
if ($this->isMyLog) {
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, MESSAGES["SUCCESS"], $this->myauth->getUIDByAuthInfo());
}
return $this->delete_process_result(MESSAGES["SUCCESS"]); return $this->delete_process_result(MESSAGES["SUCCESS"]);
} catch (\Exception $e) { } catch (\Exception $e) {
//Transaction Rollback //Transaction Rollback
$this->getService()->getModel()->transRollback(); $this->getService()->getModel()->transRollback();
if ($this->isMyLog) { return $this->delete_process_failed($e->getMessage());
MyLogService::add("error", $e->getMessage());
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, MESSAGES["FAILED"], $this->myauth->getUIDByAuthInfo());
}
return redirect()->back()->with('error', $e->getMessage());
} }
} }
protected function batchjob_delete_process_result($message): RedirectResponse|string
{
return redirect()->to($this->myauth->popPreviousUrl())->with('error', $message);
}
protected function batchjob_delete_process_failed($message): RedirectResponse|string
{
return redirect()->back()->with('error', $message);
}
//일괄삭제 //일괄삭제
final public function batchjob_delete(): RedirectResponse|string final public function batchjob_delete(): RedirectResponse|string
{ {
@ -378,19 +363,11 @@ abstract class CommonController extends BaseController
$this->delete_process($uid); $this->delete_process($uid);
} }
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
if ($this->isMyLog) {
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, MESSAGES["SUCCESS"], $this->myauth->getUIDByAuthInfo());
}
return $this->delete_process_result(MESSAGES["SUCCESS"]); return $this->delete_process_result(MESSAGES["SUCCESS"]);
} catch (\Exception $e) { } catch (\Exception $e) {
//Transaction Rollback //Transaction Rollback
$this->getService()->getModel()->transRollback(); $this->getService()->getModel()->transRollback();
if ($this->isMyLog) { return $this->delete_process_result($e->getMessage());
MyLogService::add("error", $e->getMessage());
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, MESSAGES["FAILED"], $this->myauth->getUIDByAuthInfo());
}
return redirect()->back()->with('error', $e->getMessage());
} }
} }
// 리스트 // 리스트
@ -418,7 +395,7 @@ abstract class CommonController extends BaseController
{ {
$this->list_condition_process(); $this->list_condition_process();
$total_count = $this->getService()->getModel()->countAllResults(); $total_count = $this->getService()->getModel()->countAllResults();
// MyLogService::add("debug", $this->getService()->getModel()->getLastQuery()); // log_message("debug", $this->getService()->getModel()->getLastQuery());
return $total_count; return $total_count;
} }
//PageNation 처리 //PageNation 처리
@ -466,7 +443,7 @@ abstract class CommonController extends BaseController
} }
$this->getService()->getModel()->limit($this->per_page, $this->page * $this->per_page - $this->per_page); $this->getService()->getModel()->limit($this->per_page, $this->page * $this->per_page - $this->per_page);
$entitys = $this->getService()->getModel()->select($this->getService()->getModel()::TABLE . '.*')->findAll(); $entitys = $this->getService()->getModel()->select($this->getService()->getModel()::TABLE . '.*')->findAll();
MyLogService::add("debug", $this->getService()->getModel()->getLastQuery()); log_message("debug", $this->getService()->getModel()->getLastQuery());
return $entitys; return $entitys;
} }
protected function list_process_result(): string protected function list_process_result(): string

View File

@ -6,6 +6,7 @@ use App\Entities\Cloudflare\AccountEntity;
use App\Entities\Cloudflare\AuthEntity; use App\Entities\Cloudflare\AuthEntity;
use App\Models\Cloudflare\AccountModel; use App\Models\Cloudflare\AccountModel;
use stdClass; use stdClass;
use App\Services\MyLogService;
class AccountService extends CloudflareService class AccountService extends CloudflareService
{ {
@ -43,6 +44,10 @@ class AccountService extends CloudflareService
{ {
//부모데이터정의 //부모데이터정의
$this->setParentEntity($parent_entity); $this->setParentEntity($parent_entity);
//생성값 formDatas Log남기기
foreach ($formDatas as $field => $value) {
MyLogService::add("info", "{$field}:{$value}");
}
return $this->getModel()->create($formDatas); return $this->getModel()->create($formDatas);
} }
@ -50,14 +55,22 @@ class AccountService extends CloudflareService
{ {
//부모데이터정의 //부모데이터정의
$this->setParentEntity($parent_entity); $this->setParentEntity($parent_entity);
//변경전 entity 값, 변경값 formDatas Log남기기
foreach ($formDatas as $field => $value) {
MyLogService::add("info", "{$field}:{$entity->$field}=>{$value}");
}
return $this->getModel()->modify($entity, $formDatas); return $this->getModel()->modify($entity, $formDatas);
} }
public function delete(AuthEntity $parent_entity): void public function delete(AuthEntity $parent_entity, AccountEntity $entity): void
{ {
//부모데이터정의 //부모데이터정의
$this->setParentEntity($parent_entity); $this->setParentEntity($parent_entity);
$this->getModel()->delete(); //삭제전 entity 값 Log남기기
foreach ($this->getModel()->getAllowedFields() as $field) {
MyLogService::add("info", "{$field}:{$entity->$field}");
}
$this->getModel()->delete($entity->getPK());
} }
//Result 형태 //Result 형태

View File

@ -4,6 +4,7 @@ namespace App\Services\Cloudflare;
use App\Entities\Cloudflare\AuthEntity; use App\Entities\Cloudflare\AuthEntity;
use App\Models\Cloudflare\AuthModel; use App\Models\Cloudflare\AuthModel;
use App\Services\MyLogService;
class AuthService extends CloudflareService class AuthService extends CloudflareService
{ {
@ -24,16 +25,28 @@ class AuthService extends CloudflareService
public function create(array $formDatas): AuthEntity public function create(array $formDatas): AuthEntity
{ {
//생성값 formDatas Log남기기
foreach ($formDatas as $field => $value) {
MyLogService::add("info", "{$field}:{$value}");
}
return $this->getModel()->create($formDatas); return $this->getModel()->create($formDatas);
} }
public function modify(AuthEntity $entity, array $formDatas): AuthEntity public function modify(AuthEntity $entity, array $formDatas): AuthEntity
{ {
//변경전 entity 값, 변경값 formDatas Log남기기
foreach ($formDatas as $field => $value) {
MyLogService::add("info", "{$field}:{$entity->$field}=>{$value}");
}
return $this->getModel()->modify($entity, $formDatas); return $this->getModel()->modify($entity, $formDatas);
} }
public function delete(): void public function delete(AuthEntity $entity): void
{ {
$this->getModel()->delete(); //삭제전 entity 값 Log남기기
foreach ($this->getModel()->getAllowedFields() as $field) {
MyLogService::add("info", "{$field}:{$entity->$field}");
}
$this->getModel()->delete($entity->getPK());
} }
} }

View File

@ -94,7 +94,6 @@ class FirewallService extends CloudflareService
MyLogService::add("info", "{$body->result->id}:{$entity->expression}=>{$rule}"); MyLogService::add("info", "{$body->result->id}:{$entity->expression}=>{$rule}");
//DB수정 //DB수정
$entity = $this->getModel()->modify($entity, $formDatas); $entity = $this->getModel()->modify($entity, $formDatas);
MyLogService::add("info", __FUNCTION__ . " {$entity->getTitle()} " . MESSAGES["UPDATED"]);
// log_message("debug", $this->getModel()->getLastQuery()); // log_message("debug", $this->getModel()->getLastQuery());
} }
} }

View File

@ -96,7 +96,6 @@ class RecordService extends CloudflareService
} }
//DB생성 //DB생성
$entity = $this->getModel()->create($formDatas); $entity = $this->getModel()->create($formDatas);
MyLogService::add("info", __FUNCTION__ . " {$entity->getTitle()} " . MESSAGES["CREATED"]);
// log_message("debug", $this->getModel()->getLastQuery()); // log_message("debug", $this->getModel()->getLastQuery());
return $entity; return $entity;
} }
@ -141,7 +140,6 @@ class RecordService extends CloudflareService
} }
//DB수정 //DB수정
$entity = $this->getModel()->modify($entity, $formDatas); $entity = $this->getModel()->modify($entity, $formDatas);
MyLogService::add("info", __FUNCTION__ . " {$entity->getTitle()} " . MESSAGES["UPDATED"]);
// log_message("debug", $this->getModel()->getLastQuery()); // log_message("debug", $this->getModel()->getLastQuery());
return $entity; return $entity;
} }
@ -157,7 +155,6 @@ class RecordService extends CloudflareService
foreach ($this->getModel()->getAllowedFields() as $field) { foreach ($this->getModel()->getAllowedFields() as $field) {
MyLogService::add("info", "{$field}:{$entity->$field}"); MyLogService::add("info", "{$field}:{$entity->$field}");
} }
MyLogService::add("info", __FUNCTION__ . " {$entity->getTitle()} " . MESSAGES["DELETED"]);
// log_message("debug", $this->getModel()->getLastQuery()); // log_message("debug", $this->getModel()->getLastQuery());
return $entity; return $entity;
} }

View File

@ -125,7 +125,6 @@ class ZoneService extends CloudflareService
} }
//DB생성 //DB생성
$entity = $this->getModel()->create($formDatas); $entity = $this->getModel()->create($formDatas);
MyLogService::add("info", __FUNCTION__ . " {$entity->getTitle()} " . MESSAGES["CREATED"]);
// log_message("debug", $this->getModel()->getLastQuery()); // log_message("debug", $this->getModel()->getLastQuery());
return $entity; return $entity;
} }
@ -144,7 +143,6 @@ class ZoneService extends CloudflareService
} }
//DB수정 //DB수정
$entity = $this->getModel()->modify($entity, $formDatas); $entity = $this->getModel()->modify($entity, $formDatas);
MyLogService::add("info", __FUNCTION__ . " {$entity->getTitle()} " . MESSAGES["UPDATED"]);
// log_message("debug", $this->getModel()->getLastQuery()); // log_message("debug", $this->getModel()->getLastQuery());
return $entity; return $entity;
} }
@ -160,7 +158,6 @@ class ZoneService extends CloudflareService
foreach ($this->getModel()->getAllowedFields() as $field) { foreach ($this->getModel()->getAllowedFields() as $field) {
MyLogService::add("info", "{$field}:{$entity->$field}"); MyLogService::add("info", "{$field}:{$entity->$field}");
} }
MyLogService::add("info", __FUNCTION__ . " {$entity->getTitle()} " . MESSAGES["DELETED"]);
// log_message("debug", $this->getModel()->getLastQuery()); // log_message("debug", $this->getModel()->getLastQuery());
return $entity; return $entity;
} }

View File

@ -21,14 +21,26 @@ class MapurlService extends CommonService
} }
public function create(array $formDatas): MapurlEntity public function create(array $formDatas): MapurlEntity
{ {
//생성값 formDatas Log남기기
foreach ($formDatas as $field => $value) {
MyLogService::add("info", "{$field}:{$value}");
}
return $this->getModel()->create($formDatas); return $this->getModel()->create($formDatas);
} }
public function modify(MapurlEntity $entity, array $formDatas): MapurlEntity public function modify(MapurlEntity $entity, array $formDatas): MapurlEntity
{ {
//변경전 entity 값, 변경값 formDatas Log남기기
foreach ($formDatas as $field => $value) {
MyLogService::add("info", "{$field}:{$entity->$field}=>{$value}");
}
return $this->getModel()->modify($entity, $formDatas); return $this->getModel()->modify($entity, $formDatas);
} }
public function delete(): void public function delete(MapurlEntity $entity): void
{ {
$this->getModel()->delete(); //삭제전 entity 값 Log남기기
foreach ($this->getModel()->getAllowedFields() as $field) {
MyLogService::add("info", "{$field}:{$entity->$field}");
}
$this->getModel()->delete($entity->getPK());
} }
} }

View File

@ -4,6 +4,7 @@ namespace App\Services;
use App\Models\UserSNSModel; use App\Models\UserSNSModel;
use App\Entities\UserSNSEntity; use App\Entities\UserSNSEntity;
use Google\Service\AndroidEnterprise\Resource\Users;
class UserSNSService extends CommonService class UserSNSService extends CommonService
{ {
@ -27,8 +28,8 @@ class UserSNSService extends CommonService
{ {
return $this->getModel()->modify($entity, $formDatas); return $this->getModel()->modify($entity, $formDatas);
} }
public function delete(): void public function delete(UserSNSEntity $entity): void
{ {
$this->getModel()->delete(); $this->getModel()->delete($entity->getPK());
} }
} }

View File

@ -39,8 +39,8 @@ class UserService extends CommonService
// die(var_export($formDatas, true)); // die(var_export($formDatas, true));
return $this->getModel()->modify($entity, $formDatas); return $this->getModel()->modify($entity, $formDatas);
} }
public function delete(): void public function delete(UserEntity $entity): void
{ {
$this->getModel()->delete(); $this->getModel()->delete($entity);
} }
} }