cfmgrv4 init...10
This commit is contained in:
parent
97c4dc825b
commit
c8787e4e82
@ -4,6 +4,8 @@ namespace App\Controllers\Admin\Cloudflare;
|
|||||||
|
|
||||||
use App\Helpers\Cloudflare\AuthHelper;
|
use App\Helpers\Cloudflare\AuthHelper;
|
||||||
use App\Services\Cloudflare\AuthService;
|
use App\Services\Cloudflare\AuthService;
|
||||||
|
use App\Services\MyLogService;
|
||||||
|
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;
|
||||||
@ -25,6 +27,7 @@ class AuthController extends CloudflareController
|
|||||||
}
|
}
|
||||||
return $this->service;
|
return $this->service;
|
||||||
}
|
}
|
||||||
|
//생성
|
||||||
protected function create_init(string $action, $fields = []): void
|
protected function create_init(string $action, $fields = []): void
|
||||||
{
|
{
|
||||||
$fields = [
|
$fields = [
|
||||||
|
|||||||
@ -54,8 +54,83 @@ abstract class CloudflareController extends AdminController
|
|||||||
}
|
}
|
||||||
return $this->_recordModel;
|
return $this->_recordModel;
|
||||||
}
|
}
|
||||||
|
//생성
|
||||||
|
protected function create_process_result($message): RedirectResponse|string
|
||||||
|
{
|
||||||
|
MyLogService::save($this->getService(), $this->myauth, $message, DEFAULTS['STATUS']);
|
||||||
|
return parent::create_process_result($message);
|
||||||
|
}
|
||||||
|
protected function create_process_failed($message): RedirectResponse|string
|
||||||
|
{
|
||||||
|
MyLogService::save($this->getService(), $this->myauth, $message);
|
||||||
|
return parent::create_process_failed($message);
|
||||||
|
}
|
||||||
|
//수정
|
||||||
|
protected function modify_process_result($message): RedirectResponse|string
|
||||||
|
{
|
||||||
|
MyLogService::save($this->getService(), $this->myauth, $message, DEFAULTS['STATUS']);
|
||||||
|
return parent::modify_process_result($message);
|
||||||
|
}
|
||||||
|
protected function modify_process_failed($message): RedirectResponse|string
|
||||||
|
{
|
||||||
|
MyLogService::save($this->getService(), $this->myauth, $message);
|
||||||
|
return parent::modify_process_failed($message);
|
||||||
|
}
|
||||||
|
//단일필드작업
|
||||||
|
protected function toggle_process_result($message): RedirectResponse|string
|
||||||
|
{
|
||||||
|
MyLogService::save($this->getService(), $this->myauth, $message, DEFAULTS['STATUS']);
|
||||||
|
return parent::toggle_process_result($message);
|
||||||
|
}
|
||||||
|
protected function toggle_process_failed($message): RedirectResponse|string
|
||||||
|
{
|
||||||
|
MyLogService::save($this->getService(), $this->myauth, $message);
|
||||||
|
return parent::toggle_process_failed($message);
|
||||||
|
}
|
||||||
|
//일괄처리작업
|
||||||
|
protected function batchjob_process_result($message): RedirectResponse|string
|
||||||
|
{
|
||||||
|
MyLogService::save($this->getService(), $this->myauth, $message, DEFAULTS['STATUS']);
|
||||||
|
return parent::batchjob_process_result($message);
|
||||||
|
}
|
||||||
|
protected function batchjob_process_failed($message): RedirectResponse|string
|
||||||
|
{
|
||||||
|
MyLogService::save($this->getService(), $this->myauth, $message);
|
||||||
|
return parent::batchjob_process_failed($message);
|
||||||
|
}
|
||||||
|
//삭제 delete,batchjob_delete 공통사용
|
||||||
|
protected function delete_process_result($message): RedirectResponse|string
|
||||||
|
{
|
||||||
|
MyLogService::save($this->getService(), $this->myauth, $message, DEFAULTS['STATUS']);
|
||||||
|
return parent::delete_process_result($message);
|
||||||
|
}
|
||||||
|
protected function delete_process_failed($message): RedirectResponse|string
|
||||||
|
{
|
||||||
|
MyLogService::save($this->getService(), $this->myauth, $message);
|
||||||
|
return parent::delete_process_failed($message);
|
||||||
|
}
|
||||||
|
//일괄삭제
|
||||||
|
protected function batchjob_delete_process_result($message): RedirectResponse|string
|
||||||
|
{
|
||||||
|
MyLogService::save($this->getService(), $this->myauth, $message, DEFAULTS['STATUS']);
|
||||||
|
return parent::batchjob_delete_process_result($message);
|
||||||
|
}
|
||||||
|
protected function batchjob_delete_process_failed($message): RedirectResponse|string
|
||||||
|
{
|
||||||
|
MyLogService::save($this->getService(), $this->myauth, $message);
|
||||||
|
return parent::batchjob_delete_process_failed($message);
|
||||||
|
}
|
||||||
//Sync관련
|
//Sync관련
|
||||||
|
protected function sync_process_result($message): RedirectResponse|string
|
||||||
|
{
|
||||||
|
MyLogService::save($this->getService(), $this->myauth, $message, DEFAULTS['STATUS']);
|
||||||
|
return redirect()->to($this->myauth->popPreviousUrl())->with('error', $message);
|
||||||
|
}
|
||||||
|
protected function sync_process_failed($message): RedirectResponse|string
|
||||||
|
{
|
||||||
|
MyLogService::save($this->getService(), $this->myauth, $message);
|
||||||
|
return redirect()->to($this->myauth->popPreviousUrl())->with('error', $message);
|
||||||
|
}
|
||||||
protected function sync_process(string $uid): void {}
|
protected function sync_process(string $uid): void {}
|
||||||
final protected function sync_procedure(string $uid): RedirectResponse
|
final protected function sync_procedure(string $uid): RedirectResponse
|
||||||
{
|
{
|
||||||
@ -64,11 +139,11 @@ abstract class CloudflareController extends AdminController
|
|||||||
try {
|
try {
|
||||||
$this->sync_process($uid);
|
$this->sync_process($uid);
|
||||||
$this->getService()->getModel()->transCommit();
|
$this->getService()->getModel()->transCommit();
|
||||||
return redirect()->to($this->myauth->popPreviousUrl())->with('error', MESSAGES["SUCCESS"]);
|
return $this->sync_process_result(MESSAGES["SUCCESS"]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
//Transaction Rollback
|
//Transaction Rollback
|
||||||
$this->getService()->getModel()->transRollback();
|
$this->getService()->getModel()->transRollback();
|
||||||
return redirect()->to($this->myauth->popPreviousUrl())->with('error', $e->getMessage());
|
return $this->sync_process_failed($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final public function sync(string $uid): RedirectResponse
|
final public function sync(string $uid): RedirectResponse
|
||||||
@ -84,19 +159,12 @@ abstract class CloudflareController extends AdminController
|
|||||||
$this->getService()->getModel()->transStart();
|
$this->getService()->getModel()->transStart();
|
||||||
try {
|
try {
|
||||||
$this->reload_process($uid);
|
$this->reload_process($uid);
|
||||||
if ($this->isMyLog) {
|
|
||||||
MyLogService::save($this->getService()->getClassName(), __FUNCTION__, MESSAGES["SUCCESS"], $this->myauth->getUIDByAuthInfo());
|
|
||||||
}
|
|
||||||
$this->getService()->getModel()->transCommit();
|
$this->getService()->getModel()->transCommit();
|
||||||
return redirect()->to($this->myauth->popPreviousUrl())->with('error', MESSAGES["SUCCESS"]);
|
return redirect()->to($this->myauth->popPreviousUrl())->with('error', MESSAGES["SUCCESS"]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
//Transaction Rollback
|
//Transaction Rollback
|
||||||
$this->getService()->getModel()->transRollback();
|
$this->getService()->getModel()->transRollback();
|
||||||
if ($this->isMyLog) {
|
return redirect()->to($this->myauth->popPreviousUrl())->with('error', $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());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final public function reload(string $uid): RedirectResponse
|
final public function reload(string $uid): RedirectResponse
|
||||||
|
|||||||
@ -7,6 +7,8 @@ use App\Helpers\Cloudflare\ZoneHelper;
|
|||||||
use App\Models\Cloudflare\AccountModel;
|
use App\Models\Cloudflare\AccountModel;
|
||||||
use App\Services\Cloudflare\RecordService;
|
use App\Services\Cloudflare\RecordService;
|
||||||
use App\Services\Cloudflare\ZoneService;
|
use App\Services\Cloudflare\ZoneService;
|
||||||
|
use App\Services\MyLogService;
|
||||||
|
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;
|
||||||
|
|||||||
@ -337,6 +337,14 @@ abstract class CommonController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
//삭제 delete,batchjob_delete 공통사용
|
//삭제 delete,batchjob_delete 공통사용
|
||||||
|
protected function delete_process_result($message): RedirectResponse|string
|
||||||
|
{
|
||||||
|
return redirect()->to($this->myauth->popPreviousUrl())->with('error', $message);
|
||||||
|
}
|
||||||
|
protected function delete_process_failed($message): RedirectResponse|string
|
||||||
|
{
|
||||||
|
return redirect()->back()->with('error', $message);
|
||||||
|
}
|
||||||
protected function delete_process(mixed $uid): void
|
protected function delete_process(mixed $uid): void
|
||||||
{
|
{
|
||||||
//자신정보정의
|
//자신정보정의
|
||||||
@ -346,14 +354,6 @@ abstract class CommonController extends BaseController
|
|||||||
}
|
}
|
||||||
$this->entity = $this->getService()->delete($this->entity);
|
$this->entity = $this->getService()->delete($this->entity);
|
||||||
}
|
}
|
||||||
protected function delete_process_result($message): RedirectResponse|string
|
|
||||||
{
|
|
||||||
return redirect()->to($this->myauth->popPreviousUrl())->with('error', $message);
|
|
||||||
}
|
|
||||||
protected function delete_process_failed($message): RedirectResponse|string
|
|
||||||
{
|
|
||||||
return redirect()->back()->with('error', $message);
|
|
||||||
}
|
|
||||||
final protected function delete_procedure(mixed $uid): RedirectResponse|string
|
final protected function delete_procedure(mixed $uid): RedirectResponse|string
|
||||||
{
|
{
|
||||||
//Transaction Start
|
//Transaction Start
|
||||||
@ -409,6 +409,10 @@ abstract class CommonController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
//View
|
//View
|
||||||
|
protected function view_init(string $action, $fields = []): void
|
||||||
|
{
|
||||||
|
$this->init($action, $fields);
|
||||||
|
}
|
||||||
protected function view_process(mixed $uid): void
|
protected function view_process(mixed $uid): void
|
||||||
{
|
{
|
||||||
//자신정보정의
|
//자신정보정의
|
||||||
@ -439,10 +443,6 @@ abstract class CommonController extends BaseController
|
|||||||
return $this->view_process_failed($e->getMessage());
|
return $this->view_process_failed($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected function view_init(string $action, $fields = []): void
|
|
||||||
{
|
|
||||||
$this->init($action, $fields);
|
|
||||||
}
|
|
||||||
final public function view(string $uid): RedirectResponse|string
|
final public function view(string $uid): RedirectResponse|string
|
||||||
{
|
{
|
||||||
$this->view_init(__FUNCTION__);
|
$this->view_init(__FUNCTION__);
|
||||||
@ -450,6 +450,10 @@ abstract class CommonController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 리스트
|
// 리스트
|
||||||
|
protected function index_init(string $action, $fields = []): void
|
||||||
|
{
|
||||||
|
$this->init($action, $fields);
|
||||||
|
}
|
||||||
protected function index_condition_process(): void
|
protected function index_condition_process(): void
|
||||||
{
|
{
|
||||||
//조건절 처리
|
//조건절 처리
|
||||||
@ -558,10 +562,6 @@ abstract class CommonController extends BaseController
|
|||||||
return $this->helper->alert($e->getMessage());
|
return $this->helper->alert($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected function index_init(string $action, $fields = []): void
|
|
||||||
{
|
|
||||||
$this->init($action, $fields);
|
|
||||||
}
|
|
||||||
public function index(): string
|
public function index(): string
|
||||||
{
|
{
|
||||||
$this->index_init(__FUNCTION__);
|
$this->index_init(__FUNCTION__);
|
||||||
|
|||||||
@ -12,4 +12,8 @@ return [
|
|||||||
'updated_at' => "수정일",
|
'updated_at' => "수정일",
|
||||||
'created_at' => "작성일",
|
'created_at' => "작성일",
|
||||||
],
|
],
|
||||||
|
"STATUS" => [
|
||||||
|
"use" => "완료처리",
|
||||||
|
"unuse" => "실패처리",
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\Models\MyLogModel;
|
|
||||||
use App\Entities\MyLogEntity;
|
use App\Entities\MyLogEntity;
|
||||||
|
use App\Models\MyLogModel;
|
||||||
|
use App\Services\Auth\AuthService;
|
||||||
|
|
||||||
class MyLogService
|
class MyLogService
|
||||||
{
|
{
|
||||||
@ -23,14 +24,15 @@ class MyLogService
|
|||||||
log_message($level, $message);
|
log_message($level, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function save($class_name, $method_name, $title, $user_uid): MyLogEntity
|
static public function save($service, AuthService $myauth, string $title, string $status = "unuse"): MyLogEntity
|
||||||
{
|
{
|
||||||
$formDatas = [
|
$formDatas = [
|
||||||
'user_uid' => $user_uid,
|
'user_uid' => $myauth->getUIDByAuthInfo(),
|
||||||
'class_name' => $class_name,
|
'class_name' => $service->getClassName(),
|
||||||
'method_name' => $method_name,
|
'method_name' => $service->getClassPath(),
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'content' => implode("\n", self::$_logBuffers),
|
'content' => implode("\n", self::$_logBuffers),
|
||||||
|
'status' => $status,
|
||||||
];
|
];
|
||||||
self::$_logBuffers = [];
|
self::$_logBuffers = [];
|
||||||
// dd($formDatas);
|
// dd($formDatas);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user