cfmgrv4 init...4
This commit is contained in:
parent
36322a95de
commit
cb5810855e
@ -2,40 +2,37 @@
|
||||
|
||||
namespace App\Controllers\Admin\Cloudflare;
|
||||
|
||||
use App\Helpers\Cloudflare\AccountHelper;
|
||||
use App\Models\Cloudflare\AccountModel;
|
||||
use App\Services\Cloudflare\AccountService;
|
||||
use CodeIgniter\HTTP\DownloadResponse;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Helpers\Cloudflare\AccountHelper;
|
||||
use App\Models\Cloudflare\AccountModel;
|
||||
use App\Services\Cloudflare\Account;
|
||||
|
||||
class AccountController extends CloudflareController
|
||||
{
|
||||
private $_auth_entity = null;
|
||||
private $_myLibrays = [];
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->class_name = "Account";
|
||||
$this->class_path .= $this->class_name;
|
||||
$this->title = lang("{$this->class_path}.title");
|
||||
$this->title = lang("{$this->getService()->class_path}.title");
|
||||
$this->helper = new AccountHelper();
|
||||
}
|
||||
final protected function getModel(): AccountModel
|
||||
protected function getModel(): AccountModel
|
||||
{
|
||||
if ($this->model === null) {
|
||||
$this->model = new AccountModel();
|
||||
if ($this->_model === null) {
|
||||
$this->_model = new AccountModel();
|
||||
}
|
||||
return $this->model;
|
||||
return $this->_model;
|
||||
}
|
||||
final protected function getMyLibrary(): Account
|
||||
protected function getService(): AccountService
|
||||
{
|
||||
if (!isset($this->_myLibrays[$this->_auth_entity->getPK()])) {
|
||||
$this->_myLibrays[$this->_auth_entity->getPK()] = new Account($this->_auth_entity);
|
||||
if ($this->service === null) {
|
||||
$this->service = new AccountService();
|
||||
}
|
||||
return $this->_myLibrays[$this->_auth_entity->getPK()];
|
||||
return $this->service;
|
||||
}
|
||||
protected function getFormFieldOption(string $field, array $options = []): array
|
||||
{
|
||||
@ -82,11 +79,12 @@ class AccountController extends CloudflareController
|
||||
//reload Account By Auth
|
||||
protected function reload_process(mixed $uid): void
|
||||
{
|
||||
$this->_auth_entity = $this->getAuthModel()->getEntityByPK($uid);
|
||||
if ($this->_auth_entity === null) {
|
||||
//부모데이터정의
|
||||
$this->auth_entity = $this->getAuthModel()->getEntityByPK($uid);
|
||||
if ($this->auth_entity === null) {
|
||||
throw new \Exception("Auth: {$uid} 정보를 찾을수 없습니다.");
|
||||
}
|
||||
$this->getMyLibrary()->reload();
|
||||
$this->getService()->reload($this->auth_entity);
|
||||
}
|
||||
public function reload(int $uid): RedirectResponse
|
||||
{
|
||||
|
||||
@ -2,30 +2,36 @@
|
||||
|
||||
namespace App\Controllers\Admin\Cloudflare;
|
||||
|
||||
use App\Helpers\Cloudflare\AuthHelper;
|
||||
use App\Models\Cloudflare\AuthModel;
|
||||
use App\Services\Cloudflare\AuthService;
|
||||
use CodeIgniter\HTTP\DownloadResponse;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Helpers\Cloudflare\AuthHelper;
|
||||
use App\Models\Cloudflare\AuthModel;
|
||||
|
||||
class AuthController extends CloudflareController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->class_name .= "Auth";
|
||||
$this->class_path .= $this->class_name;
|
||||
$this->title = lang("{$this->class_path}.title");
|
||||
$this->title = lang("{$this->getService()->class_path}.title");
|
||||
$this->helper = new AuthHelper();
|
||||
}
|
||||
final protected function getModel(): AuthModel
|
||||
protected function getModel(): AuthModel
|
||||
{
|
||||
if ($this->model === null) {
|
||||
$this->model = new AuthModel();
|
||||
if ($this->_model === null) {
|
||||
$this->_model = new AuthModel();
|
||||
}
|
||||
return $this->model;
|
||||
return $this->_model;
|
||||
}
|
||||
protected function getService(): AuthService
|
||||
{
|
||||
if ($this->service === null) {
|
||||
$this->service = new AuthService();
|
||||
}
|
||||
return $this->service;
|
||||
}
|
||||
private function init(string $action, array $fields = []): void
|
||||
{
|
||||
|
||||
@ -21,8 +21,8 @@ abstract class CloudflareController extends AdminController
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->class_path = "Cloudflare/";
|
||||
$this->uri_path .= strtolower($this->class_path);
|
||||
$this->uri_path .= "cloudflare/";
|
||||
// dd($this->uri_path);
|
||||
}
|
||||
final protected function getAuthModel(): AuthModel
|
||||
{
|
||||
@ -59,7 +59,7 @@ abstract class CloudflareController extends AdminController
|
||||
$this->getModel()->transStart();
|
||||
try {
|
||||
$this->sync_process($uid);
|
||||
$this->message = "{$this->class_name}: 동기화작업을 완료하였습니다.";
|
||||
$this->message = "{$this->getService()->class_name}: 동기화작업을 완료하였습니다.";
|
||||
$this->getModel()->transCommit();
|
||||
log_message("notice", __FUNCTION__ . $this->message);
|
||||
// 이전 URL로 리다이렉트
|
||||
@ -79,7 +79,7 @@ abstract class CloudflareController extends AdminController
|
||||
$this->getModel()->transStart();
|
||||
try {
|
||||
$this->reload_process($uid);
|
||||
$this->message = "{$this->class_name}: Reload 작업이 완료되었습니다.";
|
||||
$this->message = "{$this->getService()->class_name}: Reload 작업이 완료되었습니다.";
|
||||
$this->getModel()->transCommit();
|
||||
log_message("notice", __FUNCTION__ . $this->message);
|
||||
// 이전 URL로 리다이렉트
|
||||
|
||||
@ -2,26 +2,23 @@
|
||||
|
||||
namespace App\Controllers\Admin\Cloudflare;
|
||||
|
||||
use App\Helpers\Cloudflare\FirewallHelper;
|
||||
use CodeIgniter\HTTP\DownloadResponse;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Models\Cloudflare\FirewallModel;
|
||||
use App\Services\Cloudflare\FirewallService;
|
||||
use App\Helpers\Cloudflare\FirewallHelper;
|
||||
use App\Models\Cloudflare\ZoneModel;
|
||||
use App\Services\Cloudflare\Firewall;
|
||||
|
||||
class FirewallController extends CloudflareController
|
||||
{
|
||||
private $_zone_entity = null;
|
||||
private $_myLibrays = [];
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->class_name .= "Firewall";
|
||||
$this->class_path .= $this->class_name;
|
||||
$this->title = lang("{$this->class_path}.title");
|
||||
$this->title = lang("{$this->getService()->class_path}.title");
|
||||
$this->helper = new FirewallHelper();
|
||||
}
|
||||
final protected function getModel(): FirewallModel
|
||||
@ -31,12 +28,12 @@ class FirewallController extends CloudflareController
|
||||
}
|
||||
return $this->model;
|
||||
}
|
||||
final protected function getMyLibrary(): Firewall
|
||||
protected function getService(): FirewallService
|
||||
{
|
||||
if (!isset($this->_myLibrays[$this->_zone_entity->getPK()])) {
|
||||
$this->_myLibrays[$this->_zone_entity->getPK()] = new Firewall($this->_zone_entity);
|
||||
if ($this->service === null) {
|
||||
$this->service = new FirewallService();
|
||||
}
|
||||
return $this->_myLibrays[$this->_zone_entity->getPK()];
|
||||
return $this->service;
|
||||
}
|
||||
protected function getFormFieldOption(string $field, array $options = []): array
|
||||
{
|
||||
@ -77,7 +74,7 @@ class FirewallController extends CloudflareController
|
||||
//부모데이터정의
|
||||
$this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->entity->getParent());
|
||||
//Socket처리
|
||||
$this->entity = $this->getMyLibrary()->modify($this->entity, $this->formDatas);
|
||||
$this->entity = $this->getService()->modify($this->_zone_entity, $this->entity, $this->formDatas);
|
||||
}
|
||||
//View
|
||||
//create_process_result에서 결과값을 entitys에 저장하고 호출하기때문에 아래와 같이 처리함
|
||||
@ -131,11 +128,12 @@ class FirewallController extends CloudflareController
|
||||
//reload Firewall By Zone
|
||||
protected function reload_process(mixed $uid): void
|
||||
{
|
||||
//부모데이터정의
|
||||
$this->_zone_entity = $this->getZoneModel()->getEntityByPK($uid);
|
||||
if ($this->_zone_entity === null) {
|
||||
throw new \Exception("Zone: {$uid} 정보를 찾을수 없습니다.");
|
||||
}
|
||||
$this->getMyLibrary()->reload();
|
||||
$this->getService()->reload($this->_zone_entity);
|
||||
}
|
||||
public function reload(string $uid): RedirectResponse
|
||||
{
|
||||
|
||||
@ -9,19 +9,16 @@ use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Helpers\Cloudflare\RecordHelper;
|
||||
use App\Models\Cloudflare\RecordModel;
|
||||
use App\Services\Cloudflare\RecordService;
|
||||
use App\Models\Cloudflare\ZoneModel;
|
||||
use App\Services\Cloudflare\Record;
|
||||
|
||||
class RecordController extends CloudflareController
|
||||
{
|
||||
private $_zone_entity = null;
|
||||
private $_myLibrays = [];
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->class_name .= "Record";
|
||||
$this->class_path .= $this->class_name;
|
||||
$this->title = lang("{$this->class_path}.title");
|
||||
$this->title = lang("{$this->getService()->class_path}.title");
|
||||
$this->helper = new RecordHelper();
|
||||
}
|
||||
final protected function getModel(): RecordModel
|
||||
@ -31,12 +28,12 @@ class RecordController extends CloudflareController
|
||||
}
|
||||
return $this->model;
|
||||
}
|
||||
final protected function getMyLibrary(): Record
|
||||
protected function getService(): RecordService
|
||||
{
|
||||
if (!isset($this->_myLibrays[$this->_zone_entity->getPK()])) {
|
||||
$this->_myLibrays[$this->_zone_entity->getPK()] = new Record($this->_zone_entity);
|
||||
if ($this->service === null) {
|
||||
$this->service = new RecordService();
|
||||
}
|
||||
return $this->_myLibrays[$this->_zone_entity->getPK()];
|
||||
return $this->service;
|
||||
}
|
||||
protected function getFormFieldOption(string $field, array $options = []): array
|
||||
{
|
||||
@ -122,7 +119,8 @@ class RecordController extends CloudflareController
|
||||
//Socket처리
|
||||
$entitys = [];
|
||||
foreach ($this->formDatas['hosts'] as $host) {
|
||||
$entity = $this->getMyLibrary()->create(
|
||||
$entity = $this->getService()->create(
|
||||
$this->_zone_entity,
|
||||
$host,
|
||||
$this->formDatas['type'],
|
||||
$this->formDatas['content'],
|
||||
@ -170,7 +168,7 @@ class RecordController extends CloudflareController
|
||||
//부모데이터정의
|
||||
$this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->entity->getParent());
|
||||
//Socket처리
|
||||
$this->entity = $this->getMyLibrary()->modify($this->entity, $this->formDatas);
|
||||
$this->entity = $this->getService()->modify($this->_zone_entity, $this->entity, $this->formDatas);
|
||||
}
|
||||
}
|
||||
//일괄처리작업
|
||||
@ -198,7 +196,7 @@ class RecordController extends CloudflareController
|
||||
//부모데이터정의
|
||||
$this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->entity->getParent());
|
||||
//Cloudflare 삭제
|
||||
$this->entity = $this->getMyLibrary()->delete($this->entity);
|
||||
$this->entity = $this->getService()->delete($this->_zone_entity, $this->entity);
|
||||
}
|
||||
//리스트
|
||||
protected function list_entitys_process(): array
|
||||
@ -252,7 +250,7 @@ class RecordController extends CloudflareController
|
||||
//부모데이터정의
|
||||
$this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->entity->getParent());
|
||||
//Socket처리
|
||||
$this->entity = $this->getMyLibrary()->sync($this->entity);
|
||||
$this->entity = $this->getService()->sync($this->_zone_entity, $this->entity);
|
||||
}
|
||||
public function sync(string $uid): RedirectResponse
|
||||
{
|
||||
@ -261,11 +259,12 @@ class RecordController extends CloudflareController
|
||||
//reload Record By Zone
|
||||
protected function reload_process(mixed $uid): void
|
||||
{
|
||||
//부모데이터정의
|
||||
$this->_zone_entity = $this->getZoneModel()->getEntityByPK($uid);
|
||||
if ($this->_zone_entity === null) {
|
||||
throw new \Exception("Zone: {$uid} 정보를 찾을수 없습니다.");
|
||||
}
|
||||
$this->getMyLibrary()->reload();
|
||||
$this->getService()->reload($this->_zone_entity);
|
||||
}
|
||||
public function reload(string $uid): RedirectResponse
|
||||
{
|
||||
|
||||
@ -2,42 +2,39 @@
|
||||
|
||||
namespace App\Controllers\Admin\Cloudflare;
|
||||
|
||||
use App\Helpers\Cloudflare\ZoneHelper;
|
||||
use App\Models\Cloudflare\AccountModel;
|
||||
use App\Models\Cloudflare\ZoneModel;
|
||||
use App\Services\Cloudflare\RecordService;
|
||||
use App\Services\Cloudflare\ZoneService;
|
||||
use CodeIgniter\HTTP\DownloadResponse;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Helpers\Cloudflare\ZoneHelper;
|
||||
use App\Models\Cloudflare\AccountModel;
|
||||
use App\Models\Cloudflare\ZoneModel;
|
||||
use App\Services\Cloudflare\Record;
|
||||
use App\Services\Cloudflare\Zone;
|
||||
|
||||
class ZoneController extends CloudflareController
|
||||
{
|
||||
private $_account_entity = null;
|
||||
private $_myLibrays = [];
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->class_name .= "Zone";
|
||||
$this->class_path .= $this->class_name;
|
||||
$this->title = lang("{$this->class_path}.title");
|
||||
$this->title = lang("{$this->getService()->class_path}.title");;
|
||||
$this->helper = new ZoneHelper();
|
||||
}
|
||||
final protected function getModel(): ZoneModel
|
||||
protected function getModel(): ZoneModel
|
||||
{
|
||||
if ($this->model === null) {
|
||||
$this->model = new ZoneModel();
|
||||
if ($this->_model === null) {
|
||||
$this->_model = new ZoneModel();
|
||||
}
|
||||
return $this->model;
|
||||
return $this->_model;
|
||||
}
|
||||
final protected function getMyLibrary(): Zone
|
||||
protected function getService(): ZoneService
|
||||
{
|
||||
if (!isset($this->_myLibrays[$this->_account_entity->getPK()])) {
|
||||
$this->_myLibrays[$this->_account_entity->getPK()] = new Zone($this->_account_entity);
|
||||
if ($this->service === null) {
|
||||
$this->service = new ZoneService();
|
||||
}
|
||||
return $this->_myLibrays[$this->_account_entity->getPK()];
|
||||
return $this->service;
|
||||
}
|
||||
protected function getFormFieldOption(string $field, array $options = []): array
|
||||
{
|
||||
@ -148,7 +145,7 @@ class ZoneController extends CloudflareController
|
||||
$cnt = 1;
|
||||
$zone_entitys = [];
|
||||
foreach ($this->formDatas['domains'] as $domain) {
|
||||
$entity = $this->getMyLibrary()->create($domain);
|
||||
$entity = $this->getService()->create($this->_account_entity, $domain);
|
||||
log_message("debug", "Zone:{$entity->getTitle()} 작업을 완료하였습니다.");
|
||||
$zone_entitys[] = $entity;
|
||||
$cnt++;
|
||||
@ -156,10 +153,11 @@ class ZoneController extends CloudflareController
|
||||
//Record생성
|
||||
$entitys = [];
|
||||
foreach ($zone_entitys as $zone_entity) {
|
||||
$record = new Record($zone_entity);
|
||||
$record = new RecordService();
|
||||
$record_entitys = [];
|
||||
foreach ($this->formDatas['hosts'] as $host) {
|
||||
$entity = $record->create(
|
||||
$zone_entity,
|
||||
$host,
|
||||
$this->formDatas['type'],
|
||||
$this->formDatas['content'],
|
||||
@ -205,7 +203,7 @@ class ZoneController extends CloudflareController
|
||||
//부모데이터정의
|
||||
$this->_account_entity = $this->getAccountModel()->getEntityByPK($this->entity->getParent());
|
||||
//Socket처리
|
||||
$this->entity = $this->getMyLibrary()->modify($this->entity, $this->formDatas);
|
||||
$this->entity = $this->getService()->modify($this->_account_entity, $this->entity, $this->formDatas);
|
||||
}
|
||||
//일괄처리작업
|
||||
public function batcjob(): RedirectResponse
|
||||
@ -233,13 +231,13 @@ class ZoneController extends CloudflareController
|
||||
//Record부터 삭제필요
|
||||
$this->getRecordModel()->where($this->getRecordModel()::PARENT, $this->entity->getPK());
|
||||
foreach ($this->getRecordModel()->getEntitys() as $record_entity) {
|
||||
$record = new Record($this->entity);
|
||||
$record->delete($record_entity);
|
||||
$record = new RecordService();
|
||||
$record->delete($this->entity, $record_entity);
|
||||
}
|
||||
//Zone 삭제
|
||||
//부모데이터정의
|
||||
$this->_account_entity = $this->getAccountModel()->getEntityByPK($this->entity->getParent());
|
||||
$this->entity = $this->getMyLibrary()->delete($this->entity);
|
||||
$this->entity = $this->getService()->delete($this->_account_entity, $this->entity);
|
||||
}
|
||||
// 리스트
|
||||
protected function list_entitys_process(): array
|
||||
@ -293,7 +291,7 @@ class ZoneController extends CloudflareController
|
||||
//부모데이터정의
|
||||
$this->_account_entity = $this->getAccountModel()->getEntityByPK($this->entity->getParent());
|
||||
//Socket처리
|
||||
$this->entity = $this->getMyLibrary()->sync($this->entity);
|
||||
$this->entity = $this->getService()->sync($this->_account_entity, $this->entity);
|
||||
}
|
||||
public function sync(string $uid): RedirectResponse
|
||||
{
|
||||
@ -302,11 +300,12 @@ class ZoneController extends CloudflareController
|
||||
//reload Zone By Account
|
||||
protected function reload_process(mixed $uid): void
|
||||
{
|
||||
//부모데이터정의
|
||||
$this->_account_entity = $this->getAccountModel()->getEntityByPK($uid);
|
||||
if ($this->_account_entity === null) {
|
||||
throw new \Exception("Account: {$uid} 정보를 찾을수 없습니다.");
|
||||
}
|
||||
$this->getMyLibrary()->reload();
|
||||
$this->getService()->reload($this->_account_entity);
|
||||
}
|
||||
public function reload(string $uid): RedirectResponse
|
||||
{
|
||||
|
||||
@ -2,24 +2,23 @@
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Controllers\CommonController;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use App\Helpers\CommonHelper;
|
||||
use App\Controllers\Admin\AdminController;
|
||||
|
||||
class Home extends AdminController
|
||||
class Home extends CommonController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->title = "Main";
|
||||
$this->layout = "admin";
|
||||
$this->uri_path = "admin/";
|
||||
$this->view_path = "admin/";
|
||||
$this->title = "관리자페이지 메인";
|
||||
$this->helper = new CommonHelper();
|
||||
}
|
||||
protected function getModel(): mixed
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public function index(): string
|
||||
{
|
||||
helper(['form']);
|
||||
|
||||
@ -4,7 +4,7 @@ namespace App\Controllers\Admin;
|
||||
|
||||
use App\Helpers\MapurlHelper;
|
||||
use App\Models\MapurlModel;
|
||||
|
||||
use App\Services\MapurlService;
|
||||
use CodeIgniter\HTTP\DownloadResponse;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
@ -16,17 +16,23 @@ class MapurlController extends AdminController
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->class_name .= "Mapurl";
|
||||
$this->class_path .= $this->class_name;
|
||||
$this->title = lang("{$this->class_path}.title");
|
||||
$this->title = lang("{$this->getService()->class_path}.title");
|
||||
$this->helper = new MapurlHelper();
|
||||
}
|
||||
protected function getModel(): MapurlModel
|
||||
{
|
||||
if ($this->model === null) {
|
||||
$this->model = new MapurlModel();
|
||||
if ($this->_model === null) {
|
||||
$this->_model = new MapurlModel();
|
||||
}
|
||||
return $this->model;
|
||||
return $this->_model;
|
||||
}
|
||||
|
||||
protected function getService(): MapurlService
|
||||
{
|
||||
if ($this->service === null) {
|
||||
$this->service = new MapurlService();
|
||||
}
|
||||
return $this->service;
|
||||
}
|
||||
private function init(string $action, array $fields = []): void
|
||||
{
|
||||
|
||||
@ -4,7 +4,7 @@ namespace App\Controllers\Admin;
|
||||
|
||||
use App\Helpers\UserHelper;
|
||||
use App\Models\UserModel;
|
||||
|
||||
use App\Services\UserService;
|
||||
use CodeIgniter\HTTP\DownloadResponse;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
@ -12,22 +12,28 @@ use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\Validation\Validation;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
|
||||
class UserController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->class_name = "User";
|
||||
$this->class_path .= $this->class_name;
|
||||
$this->title = lang("{$this->class_path}.title");
|
||||
$this->title = lang("{$this->getService()->class_path}.title");
|
||||
$this->helper = new UserHelper();
|
||||
}
|
||||
protected function getModel(): UserModel
|
||||
{
|
||||
if ($this->model === null) {
|
||||
$this->model = new UserModel();
|
||||
if ($this->_model === null) {
|
||||
$this->_model = new UserModel();
|
||||
}
|
||||
return $this->model;
|
||||
return $this->_model;
|
||||
}
|
||||
protected function getService(): UserService
|
||||
{
|
||||
if ($this->service === null) {
|
||||
$this->service = new UserService();
|
||||
}
|
||||
return $this->service;
|
||||
}
|
||||
protected function setValidationRule($field, Validation $validation, string $action): Validation
|
||||
{
|
||||
@ -74,6 +80,7 @@ class UserController extends AdminController
|
||||
{
|
||||
$this->action = $action;
|
||||
$this->fields = count($fields) ? $fields : ['id', $this->getModel()::TITLE, 'email', 'mobile', 'role', 'updated_at', 'created_at'];
|
||||
$this->field_rules = $this->getModel()->getFieldRules($action, $this->fields);
|
||||
$this->filter_fields = ['role', 'status'];
|
||||
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
|
||||
$this->batchjob_fields = ['status'];
|
||||
|
||||
@ -2,33 +2,37 @@
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Helpers\UserSNSHelper;
|
||||
use App\Models\UserModel;
|
||||
|
||||
use App\Models\UserSNSModel;
|
||||
use CodeIgniter\HTTP\DownloadResponse;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\Validation\Validation;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Helpers\UserSNSHelper;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\UserSNSModel;
|
||||
use App\Services\UserSNSService;
|
||||
|
||||
class UserSNSController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->class_name = "UserSNS";
|
||||
$this->class_path .= $this->class_name;
|
||||
$this->title = lang("{$this->class_path}.title");
|
||||
$this->title = lang("{$this->getService()->class_path}.title");
|
||||
$this->helper = new UserSNSHelper();
|
||||
}
|
||||
protected function getModel(): UserSNSModel
|
||||
{
|
||||
if ($this->model === null) {
|
||||
$this->model = new UserSNSModel();
|
||||
if ($this->_model === null) {
|
||||
$this->_model = new UserSNSModel();
|
||||
}
|
||||
return $this->model;
|
||||
return $this->_model;
|
||||
}
|
||||
protected function getService(): UserSNSService
|
||||
{
|
||||
if ($this->service === null) {
|
||||
$this->service = new UserSNSService();
|
||||
}
|
||||
return $this->service;
|
||||
}
|
||||
protected function getFormFieldOption(string $field, array $options = []): array
|
||||
{
|
||||
|
||||
@ -7,9 +7,9 @@ use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
use App\Models\UserModel;
|
||||
use App\Helpers\UserHelper;
|
||||
use App\Services\UserService;
|
||||
use App\Helpers\Cloudflare\AuthHelper;
|
||||
use App\Libraries\MyAuth\GoogleAuth;
|
||||
use App\Libraries\MyAuth\LocalAuth;
|
||||
|
||||
@ -18,17 +18,22 @@ class AuthController extends MVController
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->class_name .= "User";
|
||||
$this->class_path .= $this->class_name;
|
||||
$this->title = lang("{$this->class_path}.title");
|
||||
$this->helper = new UserHelper();
|
||||
$this->title = lang("{$this->getService()->class_path}.title");;
|
||||
$this->helper = new AuthHelper();
|
||||
}
|
||||
protected function getModel(): UserModel
|
||||
{
|
||||
if ($this->model === null) {
|
||||
$this->model = new UserModel();
|
||||
if ($this->_model === null) {
|
||||
$this->_model = new UserModel();
|
||||
}
|
||||
return $this->model;
|
||||
return $this->_model;
|
||||
}
|
||||
protected function getService(): UserService
|
||||
{
|
||||
if ($this->service === null) {
|
||||
$this->service = new UserService();
|
||||
}
|
||||
return $this->service;
|
||||
}
|
||||
private function init(string $action, array $fields = []): void
|
||||
{
|
||||
|
||||
@ -6,10 +6,10 @@ use App\Controllers\BaseController;
|
||||
use App\Entities\Cloudflare\AccountEntity;
|
||||
use App\Entities\Cloudflare\AuthEntity;
|
||||
use App\Entities\Cloudflare\ZoneEntity;
|
||||
use App\Services\Cloudflare\Account;
|
||||
use App\Services\Cloudflare\Zone;
|
||||
use App\Services\Cloudflare\Record;
|
||||
use App\Services\Cloudflare\Firewall;
|
||||
use App\Services\Cloudflare\AccountService;
|
||||
use App\Services\Cloudflare\ZoneService;
|
||||
use App\Services\Cloudflare\RecordService;
|
||||
use App\Services\Cloudflare\FirewallService;
|
||||
use App\Models\Cloudflare\AuthModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
@ -37,23 +37,23 @@ class Cloudflare extends BaseController
|
||||
}
|
||||
private function account_process(AuthEntity $auth_entity): array
|
||||
{
|
||||
$account = new Account($auth_entity);
|
||||
return $account->reload();
|
||||
$account = new AccountService();
|
||||
return $account->reload($auth_entity);
|
||||
}
|
||||
private function zone_process(AccountEntity $account_entity): array
|
||||
{
|
||||
$zone = new Zone($account_entity);
|
||||
return $zone->reload();
|
||||
$zone = new ZoneService();
|
||||
return $zone->reload($account_entity);
|
||||
}
|
||||
private function record_process(ZoneEntity $zone_entity): array
|
||||
{
|
||||
$record = new Record($zone_entity);
|
||||
return $record->reload();
|
||||
$record = new RecordService();
|
||||
return $record->reload($zone_entity);
|
||||
}
|
||||
private function firewall_process(ZoneEntity $zone_entity): array
|
||||
{
|
||||
$firewall = new Firewall($zone_entity);
|
||||
return $firewall->reload();
|
||||
$firewall = new FirewallService();
|
||||
return $firewall->reload($zone_entity);
|
||||
}
|
||||
public function reload(mixed $uid = false): void
|
||||
{
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
namespace App\Controllers\Cloudflare;
|
||||
|
||||
use App\Controllers\MVController;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@ -21,8 +20,6 @@ abstract class CloudflareController extends MVController
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->class_path = "Cloudflare/";
|
||||
$this->uri_path .= strtolower($this->class_path);
|
||||
}
|
||||
final protected function getAuthModel(): AuthModel
|
||||
{
|
||||
@ -60,18 +57,18 @@ abstract class CloudflareController extends MVController
|
||||
final protected function trigger_procedure(): ResponseInterface
|
||||
{
|
||||
//Transaction Start
|
||||
$this->getModel()->transStart();
|
||||
$this->getService()->getModel()->transStart();
|
||||
try {
|
||||
// 여기에 필요한 로직을 구현하세요
|
||||
log_message("debug", var_export($this->request->getVar(), true));
|
||||
$this->trigger_process();
|
||||
$this->message = "{$this->class_name}: Trigger 작업이 완료되었습니다.";
|
||||
$this->getModel()->transCommit();
|
||||
$this->getService()->getModel()->transCommit();
|
||||
log_message("notice", __FUNCTION__ . $this->message);
|
||||
return $this->response->setJSON(['status' => 200, $this->message], 200);
|
||||
} catch (\Exception $e) {
|
||||
//Transaction Rollback
|
||||
$this->getModel()->transRollback();
|
||||
$this->getService()->getModel()->transRollback();
|
||||
log_message("error", $e->getMessage());
|
||||
return $this->response->setJSON(['status' => 500, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
|
||||
@ -6,18 +6,14 @@ use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Models\Cloudflare\FirewallModel;
|
||||
use App\Services\Cloudflare\Firewall;
|
||||
use App\Services\Cloudflare\FirewallService;
|
||||
|
||||
class FirewallController extends CloudflareController
|
||||
{
|
||||
private $_zone_entity = null;
|
||||
private $_myLibrays = [];
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->class_name .= "Firewall";
|
||||
$this->class_path .= $this->class_name;
|
||||
$this->title = lang("{$this->class_path}.title");
|
||||
}
|
||||
final protected function getModel(): FirewallModel
|
||||
{
|
||||
@ -26,12 +22,12 @@ class FirewallController extends CloudflareController
|
||||
}
|
||||
return $this->model;
|
||||
}
|
||||
final protected function getMyLibrary(): Firewall
|
||||
protected function getService(): FirewallService
|
||||
{
|
||||
if (!isset($this->_myLibrays[$this->_zone_entity->getPK()])) {
|
||||
$this->_myLibrays[$this->_zone_entity->getPK()] = new Firewall($this->_zone_entity);
|
||||
if ($this->service === null) {
|
||||
$this->service = new FirewallService();
|
||||
}
|
||||
return $this->_myLibrays[$this->_zone_entity->getPK()];
|
||||
return $this->service;
|
||||
}
|
||||
//Trigger작업
|
||||
protected function trigger_process(): void
|
||||
|
||||
@ -6,18 +6,14 @@ use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Models\Cloudflare\RecordModel;
|
||||
use App\Services\Cloudflare\Record;
|
||||
use App\Services\Cloudflare\RecordService;
|
||||
|
||||
class RecordController extends CloudflareController
|
||||
{
|
||||
private $_zone_entity = null;
|
||||
private $_myLibrays = [];
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->class_name .= "Record";
|
||||
$this->class_path .= $this->class_name;
|
||||
$this->title = lang("{$this->class_path}.title");
|
||||
}
|
||||
final protected function getModel(): RecordModel
|
||||
{
|
||||
@ -26,12 +22,12 @@ class RecordController extends CloudflareController
|
||||
}
|
||||
return $this->model;
|
||||
}
|
||||
final protected function getMyLibrary(): Record
|
||||
protected function getService(): RecordService
|
||||
{
|
||||
if (!isset($this->_myLibrays[$this->_zone_entity->getPK()])) {
|
||||
$this->_myLibrays[$this->_zone_entity->getPK()] = new Record($this->_zone_entity);
|
||||
if ($this->service === null) {
|
||||
$this->service = new RecordService();
|
||||
}
|
||||
return $this->_myLibrays[$this->_zone_entity->getPK()];
|
||||
return $this->service;
|
||||
}
|
||||
//Trigger작업
|
||||
protected function trigger_process(): void
|
||||
|
||||
@ -6,18 +6,14 @@ use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Models\Cloudflare\ZoneModel;
|
||||
use App\Services\Cloudflare\Zone;
|
||||
use App\Services\Cloudflare\ZoneService;
|
||||
|
||||
class ZoneController extends CloudflareController
|
||||
{
|
||||
private $_account_entity = null;
|
||||
private $_myLibrays = [];
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->class_name .= "Zone";
|
||||
$this->class_path .= $this->class_name;
|
||||
$this->title = lang("{$this->class_path}.title");
|
||||
}
|
||||
final protected function getModel(): ZoneModel
|
||||
{
|
||||
@ -26,12 +22,12 @@ class ZoneController extends CloudflareController
|
||||
}
|
||||
return $this->model;
|
||||
}
|
||||
final protected function getMyLibrary(): Zone
|
||||
protected function getService(): ZoneService
|
||||
{
|
||||
if (!isset($this->_myLibrays[$this->_account_entity->getPK()])) {
|
||||
$this->_myLibrays[$this->_account_entity->getPK()] = new Zone($this->_account_entity);
|
||||
if ($this->service === null) {
|
||||
$this->service = new ZoneService();
|
||||
}
|
||||
return $this->_myLibrays[$this->_account_entity->getPK()];
|
||||
return $this->service;
|
||||
}
|
||||
//Trigger작업
|
||||
protected function trigger_process(): void
|
||||
|
||||
@ -9,7 +9,7 @@ use Psr\Log\LoggerInterface;
|
||||
|
||||
abstract class CommonController extends BaseController
|
||||
{
|
||||
private $_viewDatas = [];
|
||||
private $_controlDatas = [];
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
@ -17,17 +17,17 @@ abstract class CommonController extends BaseController
|
||||
}
|
||||
final public function __get($name)
|
||||
{
|
||||
if (!array_key_exists($name, $this->_viewDatas)) {
|
||||
if (!array_key_exists($name, $this->_controlDatas)) {
|
||||
return null;
|
||||
}
|
||||
return $this->_viewDatas[$name];
|
||||
return $this->_controlDatas[$name];
|
||||
}
|
||||
final public function __set($name, $value): void
|
||||
{
|
||||
$this->_viewDatas[$name] = $value;
|
||||
$this->_controlDatas[$name] = $value;
|
||||
}
|
||||
final public function getViewDatas(): array
|
||||
{
|
||||
return $this->_viewDatas;
|
||||
return $this->_controlDatas;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Front;
|
||||
|
||||
use App\Controllers\MVController;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
abstract class FrontController extends MVController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->layout = "front";
|
||||
$this->uri_path = "front/";
|
||||
$this->view_path = "front/";
|
||||
}
|
||||
}
|
||||
@ -17,9 +17,10 @@ abstract class MVController extends CommonController
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->class_path = "";
|
||||
$this->class_path = $this->getService()->class_path;
|
||||
}
|
||||
abstract protected function getModel(): mixed;
|
||||
abstract protected function getService(): mixed;
|
||||
//Field별 Form Rule용
|
||||
protected function setValidationRule($field, Validation $validation, string $action): Validation
|
||||
{
|
||||
@ -42,8 +43,9 @@ abstract class MVController extends CommonController
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
// dd(lang($this->class_path . '.' . strtoupper($field)));
|
||||
$options[$field] = lang($this->class_path . '.' . strtoupper($field));
|
||||
// echo "TEST:" . $this->getService()->class_path . "," . $this->getService()->class_name;
|
||||
// dd(lang($this->getService()->class_path . '.' . strtoupper($field)));
|
||||
$options[$field] = lang($this->getService()->class_path . '.' . strtoupper($field));
|
||||
break;
|
||||
}
|
||||
return $options;
|
||||
@ -56,7 +58,6 @@ abstract class MVController extends CommonController
|
||||
}
|
||||
$options = $this->getFormFieldOption($field, $options);
|
||||
}
|
||||
// dd($options);
|
||||
return $options;
|
||||
}
|
||||
//전송된 데이터
|
||||
@ -77,9 +78,7 @@ abstract class MVController extends CommonController
|
||||
return $formDatas;
|
||||
}
|
||||
// 생성
|
||||
protected function create_form_process(): void
|
||||
{
|
||||
}
|
||||
protected function create_form_process(): void {}
|
||||
final protected function create_form_procedure(): RedirectResponse|string
|
||||
{
|
||||
try {
|
||||
@ -100,7 +99,7 @@ abstract class MVController extends CommonController
|
||||
//변경할 값 확인 : Upload된 파일 검증시 $this->request->getPOST()보다 먼처 체크필요
|
||||
$validation = $this->getValidation($fields, service('validation'), $action);
|
||||
if (!$validation->withRequest($this->request)->run()) {
|
||||
throw new \Exception("{$this->class_name} 작업 데이터 검증 오류발생\n" . implode(
|
||||
throw new \Exception("{$this->getService()->class_name} 작업 데이터 검증 오류발생\n" . implode(
|
||||
"\n",
|
||||
$validation->getErrors()
|
||||
));
|
||||
@ -110,11 +109,11 @@ abstract class MVController extends CommonController
|
||||
{
|
||||
$this->create_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
$this->entity = $this->getModel()->create($this->formDatas);
|
||||
$this->entity = $this->getService()->create($this->formDatas);
|
||||
}
|
||||
protected function create_process_result(): RedirectResponse|string
|
||||
{
|
||||
$url = strtolower(base_url() . $this->uri_path . $this->class_name) . "/view/" . $this->entity->getPK();
|
||||
$url = strtolower(base_url() . $this->uri_path . $this->getService()->class_name) . "/view/" . $this->entity->getPK();
|
||||
return redirect()->to($url)->with('error', $this->message);
|
||||
}
|
||||
final protected function create_procedure(): RedirectResponse|string
|
||||
@ -125,7 +124,7 @@ abstract class MVController extends CommonController
|
||||
helper(['form']);
|
||||
$this->create_process();
|
||||
$this->getModel()->transCommit();
|
||||
$this->message = "{$this->class_name} : 생성작업이 완료되었습니다.";
|
||||
$this->message = "{$this->getService()->class_name} : 생성작업이 완료되었습니다.";
|
||||
log_message("notice", $this->message);
|
||||
return $this->create_process_result();
|
||||
} catch (\Exception $e) {
|
||||
@ -163,7 +162,7 @@ abstract class MVController extends CommonController
|
||||
//변경할 값 확인 : Upload된 파일 검증시 $this->request->getVar()보다 먼처 체크필요
|
||||
$validation = $this->getValidation($fields, service('validation'), $action);
|
||||
if (!$validation->withRequest($this->request)->run()) {
|
||||
throw new \Exception("{$this->class_name} 작업 데이터 검증 오류발생\n" . implode(
|
||||
throw new \Exception("{$this->getService()->class_name} 작업 데이터 검증 오류발생\n" . implode(
|
||||
"\n",
|
||||
$validation->getErrors()
|
||||
));
|
||||
@ -178,11 +177,11 @@ abstract class MVController extends CommonController
|
||||
if ($this->entity === null) {
|
||||
throw new \Exception(__FUNCTION__ . " => {$uid} 정보를 찾을수 없습니다.");
|
||||
}
|
||||
$this->entity = $this->getModel()->modify($this->entity, $this->formDatas);
|
||||
$this->entity = $this->getService()->modify($this->entity, $this->formDatas);
|
||||
}
|
||||
protected function modify_process_result(): RedirectResponse|string
|
||||
{
|
||||
$url = strtolower(base_url() . $this->uri_path . $this->class_name) . "/view/" . $this->entity->getPK();
|
||||
$url = strtolower(base_url() . $this->uri_path . $this->getService()->class_name) . "/view/" . $this->entity->getPK();
|
||||
return redirect()->to($url)->with('error', $this->message);
|
||||
}
|
||||
final protected function modify_procedure(mixed $uid): RedirectResponse|string
|
||||
@ -193,7 +192,7 @@ abstract class MVController extends CommonController
|
||||
helper(['form']);
|
||||
$this->modify_process($uid);
|
||||
$this->getModel()->transCommit();
|
||||
$this->message = "{$this->class_name} : 수정작업이 완료되었습니다.";
|
||||
$this->message = "{$this->getService()->class_name} : 수정작업이 완료되었습니다.";
|
||||
log_message("notice", $this->message);
|
||||
return $this->modify_process_result();
|
||||
} catch (\Exception $e) {
|
||||
@ -226,7 +225,7 @@ abstract class MVController extends CommonController
|
||||
$this->modify_process($uid);
|
||||
}
|
||||
$this->getModel()->transCommit();
|
||||
$this->message = "{$this->class_name} : 일괄처리작업이 완료되었습니다.";
|
||||
$this->message = "{$this->getService()->class_name} : 일괄처리작업이 완료되었습니다.";
|
||||
log_message("notice", $this->message);
|
||||
// 이전 URL로 리다이렉트
|
||||
return redirect()->to($this->myauth->popPreviousUrl())->with('error', $this->message);
|
||||
@ -247,7 +246,7 @@ abstract class MVController extends CommonController
|
||||
$this->fields = [$field];
|
||||
$this->modify_process($uid);
|
||||
$this->getModel()->transCommit();
|
||||
$this->message = "{$this->class_name} : 단일필드작업이 완료되었습니다.";
|
||||
$this->message = "{$this->getService()->class_name} : 단일필드작업이 완료되었습니다.";
|
||||
log_message("notice", $this->message);
|
||||
// 이전 URL로 리다이렉트
|
||||
return redirect()->to($this->myauth->popPreviousUrl())->with('error', $this->message);
|
||||
@ -294,7 +293,7 @@ abstract class MVController extends CommonController
|
||||
if ($this->entity === null) {
|
||||
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
|
||||
}
|
||||
$this->entity = $this->getModel()->delete($this->entity->getPK());
|
||||
$this->entity = $this->getService()->delete($this->entity->getPK());
|
||||
}
|
||||
final public function delete(mixed $uid): RedirectResponse
|
||||
{
|
||||
@ -303,7 +302,7 @@ abstract class MVController extends CommonController
|
||||
try {
|
||||
$this->delete_process($uid);
|
||||
$this->getModel()->transCommit();
|
||||
$this->message = "{$this->class_name} : 삭제작업이 완료되었습니다.";
|
||||
$this->message = "{$this->getService()->class_name} : 삭제작업이 완료되었습니다.";
|
||||
log_message("notice", $this->message);
|
||||
// 이전 URL로 리다이렉트
|
||||
return redirect()->to($this->myauth->popPreviousUrl())->with('error', $this->message);
|
||||
@ -329,7 +328,7 @@ abstract class MVController extends CommonController
|
||||
$this->delete_process($uid);
|
||||
}
|
||||
$this->getModel()->transCommit();
|
||||
$this->message = "{$this->class_name} : 일괄삭제처리작업이 완료되었습니다.";
|
||||
$this->message = "{$this->getService()->class_name} : 일괄삭제처리작업이 완료되었습니다.";
|
||||
log_message("notice", $this->message);
|
||||
// 이전 URL로 리다이렉트
|
||||
return redirect()->to($this->myauth->popPreviousUrl())->with('error', $this->message);
|
||||
@ -441,12 +440,12 @@ abstract class MVController extends CommonController
|
||||
$full_path = WRITEPATH . DIRECTORY_SEPARATOR . "excel";
|
||||
switch ($document_type) {
|
||||
case 'excel':
|
||||
$file_name = sprintf("%s_%s.xlsx", $this->class_name, date('Y-m-d_Hm'));
|
||||
$file_name = sprintf("%s_%s.xlsx", $this->getService()->class_name, date('Y-m-d_Hm'));
|
||||
$writer = IOFactory::createWriter($loaded_data, 'Xlsx');
|
||||
$writer->save($full_path . DIRECTORY_SEPARATOR . $file_name);
|
||||
break;
|
||||
case 'pdf':
|
||||
$file_name = sprintf("%s_%s.pdf", $this->class_name, date('Y-m-d_Hm'));
|
||||
$file_name = sprintf("%s_%s.pdf", $this->getService()->class_name, date('Y-m-d_Hm'));
|
||||
$writer = new Mpdf($loaded_data);
|
||||
$writer->save($full_path . DIRECTORY_SEPARATOR . $file_name);
|
||||
break;
|
||||
|
||||
@ -15,7 +15,7 @@ class AccountHelper extends MVCHelper
|
||||
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
if (in_array($viewDatas['action'], ['create', 'modify'])) {
|
||||
$extras = (strpos($viewDatas['model']->getFieldRule($viewDatas['action'], $field), 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
|
||||
$extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
|
||||
}
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
@ -68,22 +68,33 @@ class AccountHelper extends MVCHelper
|
||||
$this->old_parent = $viewDatas['entity']->getParent();
|
||||
break;
|
||||
case AccountModel::TITLE:
|
||||
$value = anchor(
|
||||
$reload = anchor(
|
||||
base_url() . $viewDatas['uri_path'] . 'zone/reload/' . $viewDatas['entity']->getPK(),
|
||||
ICONS["RELOAD"],
|
||||
[
|
||||
"class" => "btn btn-sm btn-primary btn-circle",
|
||||
"target" => "_self",
|
||||
]
|
||||
) . " " .
|
||||
anchor(
|
||||
base_url() . $viewDatas['uri_path'] . "zone?account_uid=" . $viewDatas['entity']->getPK(),
|
||||
ICONS["FLAG"],
|
||||
[
|
||||
"class" => "btn btn-sm btn-primary btn-circle",
|
||||
"target" => "_self",
|
||||
]
|
||||
) . " " . parent::getFieldView($field, $viewDatas, $extras);
|
||||
);
|
||||
$flag = anchor(
|
||||
base_url() . $viewDatas['uri_path'] . "zone?account_uid=" . $viewDatas['entity']->getPK(),
|
||||
ICONS["FLAG"],
|
||||
[
|
||||
"class" => "btn btn-sm btn-primary btn-circle",
|
||||
"target" => "_self",
|
||||
]
|
||||
);
|
||||
$value = $reload . " " . $flag . " " . form_label(
|
||||
$value,
|
||||
'view',
|
||||
[
|
||||
"data-src" => current_url() . '/view/' . $viewDatas['entity']->getPK(),
|
||||
"data-bs-toggle" => "modal",
|
||||
"data-bs-target" => "#index_action_form",
|
||||
"style" => "color: blue; cursor: pointer; font-weight:bold;",
|
||||
...$extras,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'type':
|
||||
case 'status':
|
||||
|
||||
@ -14,7 +14,7 @@ class AuthHelper extends MVCHelper
|
||||
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
if (in_array($viewDatas['action'], ['create', 'modify'])) {
|
||||
$extras = (strpos($viewDatas['model']->getFieldRule($viewDatas['action'], $field), 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
|
||||
$extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
|
||||
}
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
@ -32,22 +32,33 @@ class AuthHelper extends MVCHelper
|
||||
$value = $viewDatas['entity']->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case AuthModel::TITLE:
|
||||
$value = anchor(
|
||||
$reload = anchor(
|
||||
base_url() . $viewDatas['uri_path'] . 'account/reload/' . $viewDatas['entity']->getPK(),
|
||||
ICONS["RELOAD"],
|
||||
[
|
||||
"class" => "btn btn-sm btn-primary btn-circle",
|
||||
"target" => "_self"
|
||||
]
|
||||
) . " " .
|
||||
anchor(
|
||||
base_url() . $viewDatas['uri_path'] . "account?auth_uid=" . $viewDatas['entity']->getPK(),
|
||||
ICONS["FLAG"],
|
||||
[
|
||||
"class" => "btn btn-sm btn-primary btn-circle",
|
||||
"target" => "_self"
|
||||
]
|
||||
) . " " . parent::getFieldView($field, $viewDatas, $extras);
|
||||
);
|
||||
$flag = anchor(
|
||||
base_url() . $viewDatas['uri_path'] . "account?auth_uid=" . $viewDatas['entity']->getPK(),
|
||||
ICONS["FLAG"],
|
||||
[
|
||||
"class" => "btn btn-sm btn-primary btn-circle ms1",
|
||||
"target" => "_self"
|
||||
]
|
||||
);
|
||||
$value = $reload . " " . $flag . " " . form_label(
|
||||
$value,
|
||||
'view',
|
||||
[
|
||||
"data-src" => current_url() . '/view/' . $viewDatas['entity']->getPK(),
|
||||
"data-bs-toggle" => "modal",
|
||||
"data-bs-target" => "#index_action_form",
|
||||
"style" => "color: blue; cursor: pointer; font-weight:bold;",
|
||||
...$extras,
|
||||
]
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$value = parent::getFieldView($field, $viewDatas, $extras);
|
||||
|
||||
@ -15,7 +15,7 @@ class FirewallHelper extends MVCHelper
|
||||
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
if (in_array($viewDatas['action'], ['create', 'modify'])) {
|
||||
$extras = (strpos($viewDatas['model']->getFieldRule($viewDatas['action'], $field), 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
|
||||
$extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
|
||||
}
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
@ -76,7 +76,17 @@ class FirewallHelper extends MVCHelper
|
||||
$this->old_parent = $viewDatas['entity']->getParent();
|
||||
break;
|
||||
case FirewallModel::TITLE:
|
||||
$value = parent::getFieldView($field, $viewDatas, ['class' => "label_hosts", ...$extras]);
|
||||
$value = form_label(
|
||||
$value,
|
||||
'view',
|
||||
[
|
||||
"data-src" => current_url() . '/view/' . $viewDatas['entity']->getPK(),
|
||||
"data-bs-toggle" => "modal",
|
||||
"data-bs-target" => "#index_action_form",
|
||||
"style" => "color: blue; cursor: pointer; font-weight:bold;",
|
||||
...$extras,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'expression':
|
||||
// 값이 40자 이상인 경우 자르고 '...' 추가
|
||||
|
||||
@ -28,7 +28,7 @@ class RecordHelper extends MVCHelper
|
||||
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
if (in_array($viewDatas['action'], ['create', 'modify'])) {
|
||||
$extras = (strpos($viewDatas['model']->getFieldRule($viewDatas['action'], $field), 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
|
||||
$extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
|
||||
}
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
@ -95,13 +95,23 @@ class RecordHelper extends MVCHelper
|
||||
$this->old_parent = $viewDatas['entity']->getParent();
|
||||
break;
|
||||
case RecordModel::TITLE:
|
||||
$value = parent::getFieldView($field, $viewDatas, ['class' => "label_hosts", ...$extras]);
|
||||
$fixed = anchor(
|
||||
sprintf("%s/toggle/%s/fixed?fixed=%s", current_url(), $viewDatas['entity']->getPK(), $viewDatas['entity']->fixed == 'on' ? "off" : "on"),
|
||||
$viewDatas['entity']->fixed == 'on' ? "<span class=\"text-danger\">" . ICONS['LOCK'] . "</span>" : ICONS['UNLOCK'],
|
||||
["class" => "ext-danger", "style" => "float:right;", ...$extras]
|
||||
);
|
||||
$value = $fixed . " " . $value;
|
||||
$value = $fixed . " " . form_label(
|
||||
$value,
|
||||
'view',
|
||||
[
|
||||
"data-src" => current_url() . '/view/' . $viewDatas['entity']->getPK(),
|
||||
"data-bs-toggle" => "modal",
|
||||
"data-bs-target" => "#index_action_form",
|
||||
'class' => "label_hosts",
|
||||
"style" => "color: blue; cursor: pointer; font-weight:bold;",
|
||||
...$extras,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'content':
|
||||
// 값이 40자 이상인 경우 자르고 '...' 추가
|
||||
|
||||
@ -15,7 +15,7 @@ class ZoneHelper extends MVCHelper
|
||||
function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
if (in_array($viewDatas['action'], ['create', 'modify'])) {
|
||||
$extras = (strpos($viewDatas['model']->getFieldRule($viewDatas['action'], $field), 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
|
||||
$extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
|
||||
}
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
@ -91,31 +91,34 @@ class ZoneHelper extends MVCHelper
|
||||
$this->old_parent = $viewDatas['entity']->getParent();
|
||||
break;
|
||||
case ZoneModel::TITLE:
|
||||
$record = anchor(
|
||||
$record_reload = anchor(
|
||||
base_url() . $viewDatas['uri_path'] . 'record/reload/' . $viewDatas['entity']->getPK(),
|
||||
ICONS["RELOAD"],
|
||||
[
|
||||
"class" => "btn btn-sm btn-primary btn-circle",
|
||||
"class" => "btn btn-sm btn-primary btn-circle",
|
||||
"target" => "_self",
|
||||
]
|
||||
);
|
||||
$record_flag = anchor(
|
||||
base_url() . $viewDatas['uri_path'] . "record?zone_uid=" . $viewDatas['entity']->getPK(),
|
||||
ICONS["FLAG"],
|
||||
[
|
||||
"class" => "btn btn-sm btn-outline-primary btn-circle",
|
||||
"target" => "_self"
|
||||
]
|
||||
) . " " .
|
||||
anchor(
|
||||
base_url() . $viewDatas['uri_path'] . "record?zone_uid=" . $viewDatas['entity']->getPK(),
|
||||
ICONS["FLAG"],
|
||||
);
|
||||
$firewall_reload = "";
|
||||
$firewall_flag = "";
|
||||
if (in_array($viewDatas['myauth']->getAuthInfo('id'), explode(",", env("cloudflare.firewall.acl")))) {
|
||||
$firewall_reload = anchor(
|
||||
base_url() . $viewDatas['uri_path'] . 'firewall/reload/' . $viewDatas['entity']->getPK(),
|
||||
ICONS["RELOAD"],
|
||||
[
|
||||
"class" => "btn btn-sm btn-outline-primary btn-circle",
|
||||
"class" => "btn btn-sm btn-warning btn-circle",
|
||||
"target" => "_self"
|
||||
]
|
||||
);
|
||||
$firewall = anchor(
|
||||
base_url() . $viewDatas['uri_path'] . 'firewall/reload/' . $viewDatas['entity']->getPK(),
|
||||
ICONS["RELOAD"],
|
||||
[
|
||||
"class" => "btn btn-sm btn-warning btn-circle",
|
||||
"target" => "_self"
|
||||
]
|
||||
) . " " .
|
||||
anchor(
|
||||
$firewall_flag = anchor(
|
||||
base_url() . $viewDatas['uri_path'] . "firewall?zone_uid=" . $viewDatas['entity']->getPK(),
|
||||
ICONS["FLAG"],
|
||||
[
|
||||
@ -123,11 +126,24 @@ class ZoneHelper extends MVCHelper
|
||||
"target" => "_self"
|
||||
]
|
||||
);
|
||||
}
|
||||
$value = form_label(
|
||||
$value,
|
||||
'view',
|
||||
[
|
||||
"data-src" => current_url() . '/view/' . $viewDatas['entity']->getPK(),
|
||||
"data-bs-toggle" => "modal",
|
||||
"data-bs-target" => "#index_action_form",
|
||||
'class' => "label_zones",
|
||||
"style" => "color: blue; cursor: pointer; font-weight:bold;",
|
||||
...$extras,
|
||||
]
|
||||
);
|
||||
$value = sprintf(
|
||||
"<table><tr><td style=\"padding-bottom:5px;\">%s</td><td rowspan=\"2\">%s</td></tr><tr><td>%s</td></tr></table>",
|
||||
$record,
|
||||
parent::getFieldView($field, $viewDatas, ['class' => "label_zones", ...$extras]),
|
||||
(in_array($viewDatas['myauth']->getAuthInfo('id'), explode(",", env("cloudflare.firewall.acl")))) ? $firewall : ""
|
||||
$record_reload . " " . $record_flag,
|
||||
$value,
|
||||
$firewall_reload . " " . $firewall_flag
|
||||
);
|
||||
break;
|
||||
case 'name_servers':
|
||||
|
||||
@ -12,9 +12,7 @@ abstract class MVCHelper extends CommonHelper
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
if (strpos($viewDatas['model']->getFieldRule($viewDatas['action'], $field), 'required') !== false) {
|
||||
$extras = ["class" => "text-danger ", ...$extras];
|
||||
}
|
||||
$extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "text-danger", "required" => "", ...$extras] : $extras;
|
||||
$label = form_label(lang("{$viewDatas['class_path']}.label.{$field}"), $field, $extras);
|
||||
break;
|
||||
}
|
||||
@ -24,7 +22,7 @@ abstract class MVCHelper extends CommonHelper
|
||||
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
if (in_array($viewDatas['action'], ['create', 'modify'])) {
|
||||
$extras = (strpos($viewDatas['model']->getFieldRule($viewDatas['action'], $field), 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
|
||||
$extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
|
||||
}
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
@ -48,19 +46,6 @@ abstract class MVCHelper extends CommonHelper
|
||||
{
|
||||
$value = $viewDatas['entity']->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case $viewDatas['model']::TITLE:
|
||||
$value = form_label(
|
||||
$value,
|
||||
'view',
|
||||
[
|
||||
"data-src" => current_url() . '/view/' . $viewDatas['entity']->getPK(),
|
||||
"data-bs-toggle" => "modal",
|
||||
"data-bs-target" => "#index_action_form",
|
||||
"style" => "color: blue; cursor: pointer; font-weight:bold;",
|
||||
...$extras,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'category_uid':
|
||||
foreach (array_values($viewDatas['field_options'][$field]) as $category_2depths) {
|
||||
foreach ($category_2depths as $key => $depth) {
|
||||
|
||||
@ -13,7 +13,7 @@ class MapurlHelper extends MVCHelper
|
||||
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
if (in_array($viewDatas['action'], ['create', 'modify'])) {
|
||||
$extras = (strpos($viewDatas['model']->getFieldRule($viewDatas['action'], $field), 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
|
||||
$extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
|
||||
}
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
@ -29,6 +29,29 @@ class MapurlHelper extends MVCHelper
|
||||
}
|
||||
return $form;
|
||||
} //
|
||||
public function getFieldView(string $field, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
$value = $viewDatas['entity']->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case MapurlModel::TITLE:
|
||||
$value = form_label(
|
||||
$value,
|
||||
'view',
|
||||
[
|
||||
"data-src" => current_url() . '/view/' . $viewDatas['entity']->getPK(),
|
||||
"data-bs-toggle" => "modal",
|
||||
"data-bs-target" => "#index_action_form",
|
||||
"style" => "color: blue; cursor: pointer; font-weight:bold;",
|
||||
...$extras,
|
||||
]
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$value = parent::getFieldView($field, $viewDatas, $extras);
|
||||
break;
|
||||
}
|
||||
return $value;
|
||||
} //
|
||||
public function getRemapPage(array $viewDatas): string
|
||||
{
|
||||
$urls = [];
|
||||
|
||||
@ -13,7 +13,7 @@ class UserHelper extends MVCHelper
|
||||
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
if (in_array($viewDatas['action'], ['create', 'modify'])) {
|
||||
$extras = (strpos($viewDatas['model']->getFieldRule($viewDatas['action'], $field), 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
|
||||
$extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
|
||||
}
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
@ -64,6 +64,19 @@ class UserHelper extends MVCHelper
|
||||
{
|
||||
$value = $viewDatas['entity']->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case UserModel::TITLE:
|
||||
$value = form_label(
|
||||
$value,
|
||||
'view',
|
||||
[
|
||||
"data-src" => current_url() . '/view/' . $viewDatas['entity']->getPK(),
|
||||
"data-bs-toggle" => "modal",
|
||||
"data-bs-target" => "#index_action_form",
|
||||
"style" => "color: blue; cursor: pointer; font-weight:bold;",
|
||||
...$extras,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'role':
|
||||
$roles = [];
|
||||
foreach (explode(DEFAULTS["DELIMITER_ROLE"], $value) as $key) {
|
||||
|
||||
@ -13,7 +13,7 @@ class UserSNSHelper extends MVCHelper
|
||||
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
if (in_array($viewDatas['action'], ['create', 'modify'])) {
|
||||
$extras = (strpos($viewDatas['model']->getFieldRule($viewDatas['action'], $field), 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
|
||||
$extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
|
||||
}
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
@ -42,6 +42,29 @@ class UserSNSHelper extends MVCHelper
|
||||
}
|
||||
return $form;
|
||||
} //
|
||||
public function getFieldView(string $field, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
$value = $viewDatas['entity']->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case UserSNSModel::TITLE:
|
||||
$value = form_label(
|
||||
$value,
|
||||
'view',
|
||||
[
|
||||
"data-src" => current_url() . '/view/' . $viewDatas['entity']->getPK(),
|
||||
"data-bs-toggle" => "modal",
|
||||
"data-bs-target" => "#index_action_form",
|
||||
"style" => "color: blue; cursor: pointer; font-weight:bold;",
|
||||
...$extras,
|
||||
]
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$value = parent::getFieldView($field, $viewDatas, $extras);
|
||||
break;
|
||||
}
|
||||
return $value;
|
||||
} //
|
||||
public function getListButton(string $action, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
switch ($action) {
|
||||
|
||||
@ -162,11 +162,12 @@ abstract class CommonModel extends Model
|
||||
throw new \Exception(__FUNCTION__ . " 변경된 내용이 없습니다.");
|
||||
}
|
||||
// log_message("debug", var_export($entity, true));
|
||||
//최종 저장시 오류발생하면
|
||||
// 최종 저장시 오류발생하면
|
||||
if (!$this->save($entity)) {
|
||||
throw new \Exception("저장오류:" . var_export($this->errors(), true));
|
||||
}
|
||||
// log_message("debug", $this->getTable() . " => " . __FUNCTION__ . " DB에 {$entity->getTitle()} 저장이 완료되었습니다.");
|
||||
log_message("debug", $this->getTable() . " => " . __FUNCTION__ . " DB에 {$entity->getTitle()} 저장이 완료되었습니다.");
|
||||
// log_message("debug", $this->getLastQuery());
|
||||
return $entity;
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf(
|
||||
|
||||
@ -2,26 +2,32 @@
|
||||
|
||||
namespace App\Services\Cloudflare;
|
||||
|
||||
use App\Models\Cloudflare\AccountModel;
|
||||
use App\Entities\Cloudflare\AuthEntity;
|
||||
use App\Entities\Cloudflare\AccountEntity;
|
||||
use App\Entities\Cloudflare\AuthEntity;
|
||||
use App\Models\Cloudflare\AccountModel;
|
||||
|
||||
class Account extends Cloudflare
|
||||
class AccountService extends CloudflareService
|
||||
{
|
||||
private ?AuthEntity $_parent_entity = null;
|
||||
private ?AccountModel $_model = null;
|
||||
public function __construct(AuthEntity $parent_entity)
|
||||
public function __construct()
|
||||
{
|
||||
$this->_parent_entity = $parent_entity;
|
||||
parent::__construct($parent_entity);
|
||||
$this->class_name = "Account";
|
||||
parent::__construct();
|
||||
$this->class_path .= $this->class_name;
|
||||
}
|
||||
protected function getParentEntity(): AuthEntity
|
||||
private function getParentEntity(): AuthEntity
|
||||
{
|
||||
if ($this->_parent_entity === null) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 부모정보가 없습니다.");
|
||||
}
|
||||
return $this->_parent_entity;
|
||||
}
|
||||
private function setParentEntity(AuthEntity $parent_entity): void
|
||||
{
|
||||
$this->_parent_entity = $parent_entity;
|
||||
$this->setAuthEntity($this->getParentEntity());
|
||||
}
|
||||
protected function getModel(): AccountModel
|
||||
{
|
||||
if ($this->_model === null) {
|
||||
@ -29,6 +35,24 @@ class Account extends Cloudflare
|
||||
}
|
||||
return $this->_model;
|
||||
}
|
||||
public function create(AuthEntity $parent_entity, array $formDatas): AccountEntity
|
||||
{
|
||||
//부모데이터정의
|
||||
$this->setParentEntity($parent_entity);
|
||||
return $this->getModel()->create($formDatas);
|
||||
}
|
||||
public function modify(AuthEntity $parent_entity, AccountEntity $entity, array $formDatas): AccountEntity
|
||||
{
|
||||
//부모데이터정의
|
||||
$this->setParentEntity($parent_entity);
|
||||
return $this->getModel()->modify($entity, $formDatas);
|
||||
}
|
||||
public function delete(AuthEntity $parent_entity): void
|
||||
{
|
||||
//부모데이터정의
|
||||
$this->setParentEntity($parent_entity);
|
||||
$this->getModel()->delete();
|
||||
}
|
||||
//Result 형태
|
||||
// [
|
||||
// {"id":"078e88a7735965b661715af13031ecb0",
|
||||
@ -56,9 +80,11 @@ class Account extends Cloudflare
|
||||
return $formDatas;
|
||||
}
|
||||
|
||||
public function reload(): array
|
||||
public function reload(AuthEntity $parent_entity): array
|
||||
{
|
||||
log_message("notice", "\n----------Auth {$this->getAuthEntity()->getTitle()}의 Account 처리 시작-----------");
|
||||
//부모데이터정의
|
||||
$this->setParentEntity($parent_entity);
|
||||
log_message("notice", "\n----------Auth {$this->getParentEntity()->getTitle()}의 Account 처리 시작-----------");
|
||||
$entitys = [];
|
||||
try {
|
||||
$results = $this->reload_procedure("accounts");
|
||||
@ -76,7 +102,7 @@ class Account extends Cloudflare
|
||||
$cnt++;
|
||||
}
|
||||
//부모키를 기준으로 CF에 존재하지 않는 데이터 삭제용
|
||||
$this->getModel()->where(AccountModel::PARENT, $this->getAuthEntity()->getPK());
|
||||
$this->getModel()->where(AccountModel::PARENT, $this->getParentEntity()->getPK());
|
||||
$this->getModel()->whereNotIn(AccountModel::PK, array_keys($entitys));
|
||||
$this->getModel()->delete();
|
||||
// log_message("debug", $this->getModel()->getLastQuery());
|
||||
@ -85,7 +111,7 @@ class Account extends Cloudflare
|
||||
log_message("error", $e->getMessage());
|
||||
throw new \Exception($e->getMessage());
|
||||
}
|
||||
log_message("notice", message: "\n-----------Auth {$this->getAuthEntity()->getTitle()}의 Account 처리[" . count($entitys) . "개] 완료-----------");
|
||||
log_message("notice", message: "\n-----------Auth {$this->getParentEntity()->getTitle()}의 Account 처리[" . count($entitys) . "개] 완료-----------");
|
||||
return $entitys;
|
||||
}
|
||||
}
|
||||
36
app/Services/Cloudflare/AuthService.php
Normal file
36
app/Services/Cloudflare/AuthService.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cloudflare;
|
||||
|
||||
use App\Entities\Cloudflare\AuthEntity;
|
||||
use App\Models\Cloudflare\AuthModel;
|
||||
|
||||
class AuthService extends CloudflareService
|
||||
{
|
||||
private ?AuthModel $_model = null;
|
||||
public function __construct()
|
||||
{
|
||||
$this->class_name = "Auth";
|
||||
parent::__construct();
|
||||
$this->class_path .= $this->class_name;
|
||||
}
|
||||
protected function getModel(): AuthModel
|
||||
{
|
||||
if ($this->_model === null) {
|
||||
$this->_model = new AuthModel();
|
||||
}
|
||||
return $this->_model;
|
||||
}
|
||||
public function create(array $formDatas): AuthEntity
|
||||
{
|
||||
return $this->getModel()->create($formDatas);
|
||||
}
|
||||
public function modify(AuthEntity $entity, array $formDatas): AuthEntity
|
||||
{
|
||||
return $this->getModel()->modify($entity, $formDatas);
|
||||
}
|
||||
public function delete(): void
|
||||
{
|
||||
$this->getModel()->delete();
|
||||
}
|
||||
}
|
||||
@ -2,28 +2,28 @@
|
||||
|
||||
namespace App\Services\Cloudflare;
|
||||
|
||||
use App\Models\Cloudflare\AuthModel;
|
||||
use App\Libraries\MySocket\CloudflareSocket;
|
||||
use App\Entities\Cloudflare\AuthEntity;
|
||||
use App\Libraries\MySocket\CloudflareSocket;
|
||||
use App\Models\Cloudflare\AuthModel;
|
||||
use App\Services\CommonService;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
abstract class Cloudflare
|
||||
abstract class CloudflareService extends CommonService
|
||||
{
|
||||
private $_mySocket = null;
|
||||
private $_mySockets = [];
|
||||
private $_auth_entity = null;
|
||||
private $_authModel = null;
|
||||
protected function __construct(AuthEntity $auth_entity)
|
||||
protected function __construct()
|
||||
{
|
||||
$this->_auth_entity = $auth_entity;
|
||||
parent::__construct();
|
||||
$this->class_path = "Cloudflare/";
|
||||
}
|
||||
abstract protected function getArrayByResult(\stdClass $result, array $formDatas = []): array;
|
||||
abstract protected function getParentEntity(): mixed;
|
||||
final public function getMySocket(): CloudflareSocket
|
||||
{
|
||||
if ($this->_mySocket === null) {
|
||||
$this->_mySocket = new CloudflareSocket($this->getAuthEntity());
|
||||
if (!isset($this->_mySockets[$this->getAuthEntity()->getPK()])) {
|
||||
$this->_mySockets[$this->getAuthEntity()->getPK()] = new CloudflareSocket($this->getAuthEntity());
|
||||
}
|
||||
return $this->_mySocket;
|
||||
return $this->_mySockets[$this->getAuthEntity()->getPK()];
|
||||
}
|
||||
final protected function getAuthEntity(): AuthEntity
|
||||
{
|
||||
@ -32,6 +32,10 @@ abstract class Cloudflare
|
||||
}
|
||||
return $this->_auth_entity;
|
||||
}
|
||||
final protected function setAuthEntity(AuthEntity $auth_entity): void
|
||||
{
|
||||
$this->_auth_entity = $auth_entity;
|
||||
}
|
||||
final protected function getAuthModel(): AuthModel
|
||||
{
|
||||
if ($this->_authModel === null) {
|
||||
@ -7,14 +7,27 @@ use App\Entities\Cloudflare\ZoneEntity;
|
||||
use App\Models\Cloudflare\AccountModel;
|
||||
use App\Models\Cloudflare\FirewallModel;
|
||||
|
||||
class Firewall extends Cloudflare
|
||||
class FirewallService extends CloudflareService
|
||||
{
|
||||
private ?ZoneEntity $_parent_entity = null;
|
||||
private ?FirewallModel $_model = null;
|
||||
private ?AccountModel $_accountModel = null;
|
||||
public function __construct(ZoneEntity $zone_entity)
|
||||
public function __construct()
|
||||
{
|
||||
$this->_parent_entity = $zone_entity;
|
||||
$this->class_name = "Firewall";
|
||||
parent::__construct();
|
||||
$this->class_path .= $this->class_name;
|
||||
}
|
||||
private function getParentEntity(): ZoneEntity
|
||||
{
|
||||
if ($this->_parent_entity === null) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 부모정보가 없습니다.");
|
||||
}
|
||||
return $this->_parent_entity;
|
||||
}
|
||||
private function setParentEntity(mixed $parent_entity): void
|
||||
{
|
||||
$this->_parent_entity = $parent_entity;
|
||||
$account_entity = $this->getAccountModel()->getEntityByPK($this->getParentEntity()->getParent());
|
||||
if ($account_entity === null) {
|
||||
throw new \Exception("해당 계정정보를 찾을수 없습니다.");
|
||||
@ -23,14 +36,7 @@ class Firewall extends Cloudflare
|
||||
if ($auth_entity === null) {
|
||||
throw new \Exception("해당 계정정보를 찾을수 없습니다.");
|
||||
}
|
||||
parent::__construct($auth_entity);
|
||||
}
|
||||
protected function getParentEntity(): ZoneEntity
|
||||
{
|
||||
if ($this->_parent_entity === null) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 부모정보가 없습니다.");
|
||||
}
|
||||
return $this->_parent_entity;
|
||||
$this->setAuthEntity($auth_entity);
|
||||
}
|
||||
protected function getModel(): FirewallModel
|
||||
{
|
||||
@ -60,8 +66,10 @@ class Firewall extends Cloudflare
|
||||
// log_message("debug", print_r($formDatas, true));
|
||||
return $formDatas;
|
||||
}
|
||||
public function modify(FirewallEntity $entity, array $formDatas): FirewallEntity
|
||||
public function modify(ZoneEntity $parent_entity, FirewallEntity $entity, array $formDatas): FirewallEntity
|
||||
{
|
||||
//부모데이터정의
|
||||
$this->setParentEntity($parent_entity);
|
||||
$datas = [
|
||||
'id' => $entity->getPK(), // 수정할 rule의 ID
|
||||
"action" => $entity->mode,
|
||||
@ -83,8 +91,10 @@ class Firewall extends Cloudflare
|
||||
return $entity;
|
||||
}
|
||||
//Reload
|
||||
public function reload(): array
|
||||
public function reload(ZoneEntity $parent_entity): array
|
||||
{
|
||||
//부모데이터정의
|
||||
$this->setParentEntity($parent_entity);
|
||||
// log_message("notice", "\n-----------Zone {$this->getParentEntity()->getTitle()}의 Firewall 처리 시작-----------");
|
||||
$entitys = [];
|
||||
try {
|
||||
@ -7,14 +7,27 @@ use App\Entities\Cloudflare\ZoneEntity;
|
||||
use App\Models\Cloudflare\AccountModel;
|
||||
use App\Models\Cloudflare\RecordModel;
|
||||
|
||||
class Record extends Cloudflare
|
||||
class RecordService extends CloudflareService
|
||||
{
|
||||
private ?ZoneEntity $_parent_entity = null;
|
||||
private ?RecordModel $_model = null;
|
||||
private ?AccountModel $_accountModel = null;
|
||||
public function __construct(ZoneEntity $zone_entity)
|
||||
public function __construct()
|
||||
{
|
||||
$this->_parent_entity = $zone_entity;
|
||||
$this->class_name = "Record";
|
||||
parent::__construct();
|
||||
$this->class_path .= $this->class_name;
|
||||
}
|
||||
private function getParentEntity(): ZoneEntity
|
||||
{
|
||||
if ($this->_parent_entity === null) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 부모정보가 없습니다.");
|
||||
}
|
||||
return $this->_parent_entity;
|
||||
}
|
||||
private function setParentEntity(mixed $parent_entity): void
|
||||
{
|
||||
$this->_parent_entity = $parent_entity;
|
||||
$account_entity = $this->getAccountModel()->getEntityByPK($this->getParentEntity()->getParent());
|
||||
if ($account_entity === null) {
|
||||
throw new \Exception("해당 계정정보를 찾을수 없습니다.");
|
||||
@ -23,14 +36,7 @@ class Record extends Cloudflare
|
||||
if ($auth_entity === null) {
|
||||
throw new \Exception("해당 계정정보를 찾을수 없습니다.");
|
||||
}
|
||||
parent::__construct($auth_entity);
|
||||
}
|
||||
protected function getParentEntity(): ZoneEntity
|
||||
{
|
||||
if ($this->_parent_entity === null) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 부모정보가 없습니다.");
|
||||
}
|
||||
return $this->_parent_entity;
|
||||
$this->setAuthEntity($auth_entity);
|
||||
}
|
||||
protected function getModel(): RecordModel
|
||||
{
|
||||
@ -63,8 +69,10 @@ class Record extends Cloudflare
|
||||
// log_message("debug", print_r($formDatas, true));
|
||||
return $formDatas;
|
||||
}
|
||||
public function create(string $host, string $type, string $content, string $proxied): RecordEntity
|
||||
public function create(ZoneEntity $parent_entity, string $host, string $type, string $content, string $proxied): RecordEntity
|
||||
{
|
||||
//부모데이터정의
|
||||
$this->setParentEntity($parent_entity);
|
||||
//Socket용
|
||||
//호스트생성을 위해 Cloudflare에 전송
|
||||
$datas = [
|
||||
@ -78,8 +86,10 @@ class Record extends Cloudflare
|
||||
//DB생성
|
||||
return $this->getModel()->create($this->getArrayByResult($body->result));
|
||||
}
|
||||
public function modify(RecordEntity $entity, array $formDatas): RecordEntity
|
||||
public function modify(ZoneEntity $parent_entity, RecordEntity $entity, array $formDatas): RecordEntity
|
||||
{
|
||||
//부모데이터정의
|
||||
$this->setParentEntity($parent_entity);
|
||||
//TTL값은 CDN(proxied)가 사용함일때는 무조건 1, 않함일때는 120이 적용
|
||||
$datas = [
|
||||
'type' => isset($formDatas['type']) ? $formDatas['type'] : $entity->type,
|
||||
@ -104,16 +114,20 @@ class Record extends Cloudflare
|
||||
// DB 수정
|
||||
return $this->getModel()->modify($entity, $this->getArrayByResult($body->result));
|
||||
}
|
||||
public function delete(RecordEntity $entity): RecordEntity
|
||||
public function delete(ZoneEntity $parent_entity, RecordEntity $entity): RecordEntity
|
||||
{
|
||||
//부모데이터정의
|
||||
$this->setParentEntity($parent_entity);
|
||||
$this->getMySocket()->delete("zones/{$this->getParentEntity()->getPK()}/dns_records/{$entity->getPK()}");
|
||||
//DB삭제
|
||||
$this->getModel()->delete($entity->getPK());
|
||||
log_message("debug", $this->getModel()->getLastQuery());
|
||||
return $entity;
|
||||
}
|
||||
public function sync(RecordEntity $entity): RecordEntity
|
||||
public function sync(ZoneEntity $parent_entity, RecordEntity $entity): RecordEntity
|
||||
{
|
||||
//부모데이터정의
|
||||
$this->setParentEntity($parent_entity);
|
||||
// 기존 Sync형태
|
||||
$response = $this->getMySocket()->get("zones/{$this->getParentEntity()->getPK()}/dns_records/{$entity->getPK()}");
|
||||
$body = json_decode($response->getBody());
|
||||
@ -138,8 +152,10 @@ class Record extends Cloudflare
|
||||
return $entity;
|
||||
}
|
||||
//Reload
|
||||
public function reload(): array
|
||||
public function reload(ZoneEntity $parent_entity): array
|
||||
{
|
||||
//부모데이터정의
|
||||
$this->setParentEntity($parent_entity);
|
||||
// log_message("notice", "\n-----------Zone {$this->getParentEntity()->getTitle()}의 Record 처리 시작-----------");
|
||||
$entitys = [];
|
||||
try {
|
||||
@ -6,7 +6,7 @@ use App\Entities\Cloudflare\AccountEntity;
|
||||
use App\Entities\Cloudflare\ZoneEntity;
|
||||
use App\Models\Cloudflare\ZoneModel;
|
||||
|
||||
class Zone extends Cloudflare
|
||||
class ZoneService extends CloudflareService
|
||||
{
|
||||
private ?AccountEntity $_parent_entity = null;
|
||||
private ?ZoneModel $_model = null;
|
||||
@ -17,22 +17,28 @@ class Zone extends Cloudflare
|
||||
'ssl' => 'flexible',
|
||||
'always_use_https' => 'off'
|
||||
];
|
||||
public function __construct(AccountEntity $account_entity)
|
||||
public function __construct()
|
||||
{
|
||||
$this->_parent_entity = $account_entity;
|
||||
$auth_entity = $this->getAuthModel()->getEntityByPK(uid: $this->getParentEntity()->getParent());
|
||||
if ($auth_entity === null) {
|
||||
throw new \Exception("해당 계정정보를 찾을수 없습니다.");
|
||||
}
|
||||
parent::__construct($auth_entity);
|
||||
$this->class_name = "Zone";
|
||||
parent::__construct();
|
||||
$this->class_path .= $this->class_name;
|
||||
}
|
||||
protected function getParentEntity(): AccountEntity
|
||||
private function getParentEntity(): AccountEntity
|
||||
{
|
||||
if ($this->_parent_entity === null) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 부모정보가 없습니다.");
|
||||
}
|
||||
return $this->_parent_entity;
|
||||
}
|
||||
private function setParentEntity(mixed $parent_entity): void
|
||||
{
|
||||
$this->_parent_entity = $parent_entity;
|
||||
$auth_entity = $this->getAuthModel()->getEntityByPK(uid: $this->getParentEntity()->getParent());
|
||||
if ($auth_entity === null) {
|
||||
throw new \Exception("해당 계정정보를 찾을수 없습니다.");
|
||||
}
|
||||
$this->setAuthEntity($auth_entity);
|
||||
}
|
||||
protected function getModel(): ZoneModel
|
||||
{
|
||||
if ($this->_model === null) {
|
||||
@ -94,8 +100,10 @@ class Zone extends Cloudflare
|
||||
//최종 결과값은 body->result->id='필드명',body->result->value='on/off'이런식으로 받음
|
||||
return $body->result->value;
|
||||
}
|
||||
public function create(string $domain, bool $jump_start = false): ZoneEntity
|
||||
public function create(AccountEntity $parent_entity, string $domain, bool $jump_start = false): ZoneEntity
|
||||
{
|
||||
//부모데이터정의
|
||||
$this->setParentEntity($parent_entity);
|
||||
//Socket용
|
||||
//도메인생성을 위해 Cloudflare에 전송
|
||||
$datas = [
|
||||
@ -113,8 +121,10 @@ class Zone extends Cloudflare
|
||||
}
|
||||
return $this->getModel()->create($formDatas);
|
||||
}
|
||||
public function modify(ZoneEntity $entity, array $formDatas): ZoneEntity
|
||||
public function modify(AccountEntity $parent_entity, ZoneEntity $entity, array $formDatas): ZoneEntity
|
||||
{
|
||||
//부모데이터정의
|
||||
$this->setParentEntity($parent_entity);
|
||||
// throw new \Exception("zone:modify" . var_export($formDatas, true));
|
||||
foreach ($formDatas as $field => $value) {
|
||||
//modify,toggle,batchjob 사용 셋팅 ipv6 , //development_mode , //security_level
|
||||
@ -123,16 +133,19 @@ class Zone extends Cloudflare
|
||||
//DB수정
|
||||
return $this->getModel()->modify($entity, $formDatas);
|
||||
}
|
||||
public function delete(ZoneEntity $entity): ZoneEntity
|
||||
public function delete(AccountEntity $parent_entity, ZoneEntity $entity): ZoneEntity
|
||||
{
|
||||
//부모데이터정의
|
||||
$this->setParentEntity($parent_entity);
|
||||
$this->getMySocket()->delete("zones/{$entity->getPK()}");
|
||||
//DB삭제
|
||||
$this->getModel()->delete($entity->getPK());
|
||||
log_message("debug", $this->getModel()->getLastQuery());
|
||||
return $entity;
|
||||
}
|
||||
public function sync(ZoneEntity $entity): ZoneEntity
|
||||
public function sync(AccountEntity $parent_entity, ZoneEntity $entity): ZoneEntity
|
||||
{
|
||||
$this->setParentEntity($parent_entity);
|
||||
$response = $this->getMySocket()->get("zones/{$entity->getPK()}");
|
||||
$body = json_decode($response->getBody());
|
||||
$formDatas = $this->getArrayByResult($body->result);
|
||||
@ -144,8 +157,10 @@ class Zone extends Cloudflare
|
||||
return $entity;
|
||||
}
|
||||
//Reload
|
||||
public function reload(): array
|
||||
public function reload(AccountEntity $parent_entity): array
|
||||
{
|
||||
//부모데이터정의
|
||||
$this->setParentEntity($parent_entity);
|
||||
log_message("notice", "\n-----------Account {$this->getParentEntity()->getTitle()}의 Zone처리 시작-----------");
|
||||
$entitys = [];
|
||||
try {
|
||||
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
abstract class Common
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
}
|
||||
25
app/Services/CommonService.php
Normal file
25
app/Services/CommonService.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
abstract class CommonService
|
||||
{
|
||||
private $_serviceDatas = [];
|
||||
public function __construct() {}
|
||||
abstract protected function getModel(): mixed;
|
||||
final public function __get($name)
|
||||
{
|
||||
if (!array_key_exists($name, $this->_serviceDatas)) {
|
||||
return null;
|
||||
}
|
||||
return $this->_serviceDatas[$name];
|
||||
}
|
||||
final public function __set($name, $value): void
|
||||
{
|
||||
$this->_serviceDatas[$name] = $value;
|
||||
}
|
||||
final public function getServiceDatas(): array
|
||||
{
|
||||
return $this->_serviceDatas;
|
||||
}
|
||||
}
|
||||
37
app/Services/MapurlService.php
Normal file
37
app/Services/MapurlService.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\MapurlModel;
|
||||
use App\Entities\MapurlEntity;
|
||||
|
||||
class MapurlService extends CommonService
|
||||
{
|
||||
private $_view_path = "";
|
||||
private ?MapurlModel $_model = null;
|
||||
public function __construct()
|
||||
{
|
||||
$this->class_name = "Mapurl";
|
||||
parent::__construct();
|
||||
$this->class_path .= $this->class_name;
|
||||
}
|
||||
protected function getModel(): MapurlModel
|
||||
{
|
||||
if ($this->_model === null) {
|
||||
$this->_model = new MapurlModel();
|
||||
}
|
||||
return $this->_model;
|
||||
}
|
||||
public function create(array $formDatas): MapurlEntity
|
||||
{
|
||||
return $this->getModel()->create($formDatas);
|
||||
}
|
||||
public function modify(MapurlEntity $entity, array $formDatas): MapurlEntity
|
||||
{
|
||||
return $this->getModel()->modify($entity, $formDatas);
|
||||
}
|
||||
public function delete(): void
|
||||
{
|
||||
$this->getModel()->delete();
|
||||
}
|
||||
}
|
||||
36
app/Services/UserSNSService.php
Normal file
36
app/Services/UserSNSService.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\UserSNSModel;
|
||||
use App\Entities\UserSNSEntity;
|
||||
|
||||
class UserSNSService extends CommonService
|
||||
{
|
||||
private ?UserSNSModel $_model = null;
|
||||
public function __construct()
|
||||
{
|
||||
$this->class_name = "UserSNS";
|
||||
parent::__construct();
|
||||
$this->class_path .= $this->class_name;
|
||||
}
|
||||
protected function getModel(): UserSNSModel
|
||||
{
|
||||
if ($this->_model === null) {
|
||||
$this->_model = new UserSNSModel();
|
||||
}
|
||||
return $this->_model;
|
||||
}
|
||||
public function create(array $formDatas): UserSNSEntity
|
||||
{
|
||||
return $this->getModel()->create($formDatas);
|
||||
}
|
||||
public function modify(UserSNSEntity $entity, array $formDatas): UserSNSEntity
|
||||
{
|
||||
return $this->getModel()->modify($entity, $formDatas);
|
||||
}
|
||||
public function delete(): void
|
||||
{
|
||||
$this->getModel()->delete();
|
||||
}
|
||||
}
|
||||
@ -5,29 +5,22 @@ namespace App\Services;
|
||||
use App\Models\UserModel;
|
||||
use App\Entities\UserEntity;
|
||||
|
||||
class User extends Common
|
||||
class UserService extends CommonService
|
||||
{
|
||||
private ?UserModel $_model = null;
|
||||
public function __construct()
|
||||
{
|
||||
$this->class_name = "User";
|
||||
parent::__construct();
|
||||
$this->class_path .= $this->class_name;
|
||||
}
|
||||
public function getModel(): UserModel
|
||||
protected function getModel(): UserModel
|
||||
{
|
||||
if ($this->_model === null) {
|
||||
$this->_model = new UserModel();
|
||||
}
|
||||
return $this->_model;
|
||||
}
|
||||
|
||||
public function find(array $wheres): ?UserEntity
|
||||
{
|
||||
return $this->getModel()->where($wheres)->first();
|
||||
}
|
||||
public function findAll(array $wheres = []): array
|
||||
{
|
||||
return $this->getModel()->where($wheres)->findAll();
|
||||
}
|
||||
public function create(array $formDatas): UserEntity
|
||||
{
|
||||
return $this->getModel()->create($formDatas);
|
||||
@ -36,8 +29,8 @@ class User extends Common
|
||||
{
|
||||
return $this->getModel()->modify($entity, $formDatas);
|
||||
}
|
||||
public function delete(array $wheres): void
|
||||
public function delete(): void
|
||||
{
|
||||
$this->getModel()->where($wheres)->delete();
|
||||
$this->getModel()->delete();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user