cfmgrv4 init...10
This commit is contained in:
parent
bf0f17c253
commit
e0e105baaa
@ -77,6 +77,6 @@ class MapurlModel extends CommonModel
|
||||
public function setList_WordFilter(string $word): void
|
||||
{
|
||||
$this->orLike(self::TABLE . "." . self::TITLE, $word, 'both');
|
||||
$this->orLike(self::TABLE . '.new_url', $word, 'both');
|
||||
$this->orLike(self::TABLE . '.newurl', $word, 'both');
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,10 +6,11 @@ use App\Entities\Cloudflare\AccountEntity;
|
||||
use App\Entities\Cloudflare\AuthEntity;
|
||||
use App\Models\Cloudflare\AccountModel;
|
||||
use stdClass;
|
||||
use App\Services\MyLogService;
|
||||
use App\Traits\MylogTrait;
|
||||
|
||||
class AccountService extends CloudflareService
|
||||
{
|
||||
use MylogTrait;
|
||||
private ?AuthEntity $_parent_entity = null;
|
||||
private ?AccountModel $_model = null;
|
||||
|
||||
@ -45,9 +46,7 @@ class AccountService extends CloudflareService
|
||||
//부모데이터정의
|
||||
$this->setParentEntity($parent_entity);
|
||||
//생성값 formDatas Log남기기
|
||||
foreach ($formDatas as $field => $value) {
|
||||
MyLogService::add("info", "{$field}:{$value}");
|
||||
}
|
||||
$this->add_MylogTrait(__FUNCTION__, $formDatas);
|
||||
return $this->getModel()->create($formDatas);
|
||||
}
|
||||
|
||||
@ -56,9 +55,7 @@ class AccountService extends CloudflareService
|
||||
//부모데이터정의
|
||||
$this->setParentEntity($parent_entity);
|
||||
//변경전 entity 값, 변경값 formDatas Log남기기
|
||||
foreach ($this->getModel()->getFields() as $field) {
|
||||
MyLogService::add("info", "{$field}:{$entity->$field}=>{$formDatas[$field]}");
|
||||
}
|
||||
$this->add_MylogTrait(__FUNCTION__, $formDatas, $entity);
|
||||
return $this->getModel()->modify($entity, $formDatas);
|
||||
}
|
||||
|
||||
@ -67,9 +64,7 @@ class AccountService extends CloudflareService
|
||||
//부모데이터정의
|
||||
$this->setParentEntity($parent_entity);
|
||||
//삭제전 entity 값 Log남기기
|
||||
foreach ($this->getModel()->getFields() as $field) {
|
||||
MyLogService::add("info", "{$field}:{$entity->$field}");
|
||||
}
|
||||
$this->add_MylogTrait(__FUNCTION__, [], $entity);
|
||||
$this->getModel()->delete($entity->getPK());
|
||||
}
|
||||
|
||||
|
||||
@ -6,10 +6,11 @@ use App\Entities\Cloudflare\RecordEntity;
|
||||
use App\Entities\Cloudflare\ZoneEntity;
|
||||
use App\Models\Cloudflare\AccountModel;
|
||||
use App\Models\Cloudflare\RecordModel;
|
||||
use App\Services\MyLogService;
|
||||
use App\Traits\MylogTrait;
|
||||
|
||||
class RecordService extends CloudflareService
|
||||
{
|
||||
use MylogTrait;
|
||||
private ?ZoneEntity $_parent_entity = null;
|
||||
private ?RecordModel $_model = null;
|
||||
private ?AccountModel $_accountModel = null;
|
||||
@ -91,9 +92,7 @@ class RecordService extends CloudflareService
|
||||
$body = json_decode($response->getBody());
|
||||
$formDatas = $this->getArrayByResult($body->result);
|
||||
//생성값 formDatas Log남기기
|
||||
foreach ($formDatas as $field => $value) {
|
||||
MyLogService::add("info", "{$field}:{$value}");
|
||||
}
|
||||
$this->add_MylogTrait(__FUNCTION__, $formDatas);
|
||||
//DB생성
|
||||
$entity = $this->getModel()->create($formDatas);
|
||||
// log_message("debug", $this->getModel()->getLastQuery());
|
||||
@ -135,9 +134,7 @@ class RecordService extends CloudflareService
|
||||
$body = json_decode($response->getBody());
|
||||
$formDatas = $this->getArrayByResult($body->result);
|
||||
//변경전 entity 값, 변경값 formDatas Log남기기
|
||||
foreach ($this->getModel()->getFields() as $field) {
|
||||
MyLogService::add("info", "{$field}:{$entity->$field}=>{$formDatas[$field]}");
|
||||
}
|
||||
$this->add_MylogTrait(__FUNCTION__, $formDatas, $entity);
|
||||
//DB수정
|
||||
$entity = $this->getModel()->modify($entity, $formDatas);
|
||||
// log_message("debug", $this->getModel()->getLastQuery());
|
||||
@ -152,9 +149,7 @@ class RecordService extends CloudflareService
|
||||
//DB삭제
|
||||
$this->getModel()->delete($entity->getPK());
|
||||
//삭제전 entity 값 Log남기기
|
||||
foreach ($this->getModel()->getFields() as $field) {
|
||||
MyLogService::add("info", "{$field}:{$entity->$field}");
|
||||
}
|
||||
$this->add_MylogTrait(__FUNCTION__, [], $entity);
|
||||
// log_message("debug", $this->getModel()->getLastQuery());
|
||||
return $entity;
|
||||
}
|
||||
|
||||
@ -6,9 +6,11 @@ use App\Entities\Cloudflare\AccountEntity;
|
||||
use App\Entities\Cloudflare\ZoneEntity;
|
||||
use App\Models\Cloudflare\ZoneModel;
|
||||
use App\Services\MyLogService;
|
||||
use App\Traits\MylogTrait;
|
||||
|
||||
class ZoneService extends CloudflareService
|
||||
{
|
||||
use MylogTrait;
|
||||
private ?AccountEntity $_parent_entity = null;
|
||||
private ?ZoneModel $_model = null;
|
||||
private array $_setting_fields = [
|
||||
@ -120,9 +122,7 @@ class ZoneService extends CloudflareService
|
||||
$formDatas[$field] = $this->setCFSetting($formDatas[ZoneModel::PK], $field, $default);
|
||||
}
|
||||
//생성값 formDatas Log남기기
|
||||
foreach ($formDatas as $field => $value) {
|
||||
MyLogService::add("info", "{$field}:{$value}");
|
||||
}
|
||||
$this->add_MylogTrait(__FUNCTION__, $formDatas);
|
||||
//DB생성
|
||||
$entity = $this->getModel()->create($formDatas);
|
||||
// log_message("debug", $this->getModel()->getLastQuery());
|
||||
@ -138,9 +138,7 @@ class ZoneService extends CloudflareService
|
||||
$formDatas[$field] = $this->setCFSetting($entity->getPK(), $field, $value);
|
||||
}
|
||||
//변경전 entity 값, 변경값 formDatas Log남기기
|
||||
foreach ($this->getModel()->getFields() as $field) {
|
||||
MyLogService::add("info", "{$field}:{$entity->$field}=>{$formDatas[$field]}");
|
||||
}
|
||||
$this->add_MylogTrait(__FUNCTION__, $formDatas, $entity);
|
||||
//DB수정
|
||||
$entity = $this->getModel()->modify($entity, $formDatas);
|
||||
// log_message("debug", $this->getModel()->getLastQuery());
|
||||
@ -155,9 +153,7 @@ class ZoneService extends CloudflareService
|
||||
//DB삭제
|
||||
$this->getModel()->delete($entity->getPK());
|
||||
//삭제전 entity 값 Log남기기
|
||||
foreach ($this->getModel()->getFields() as $field) {
|
||||
MyLogService::add("info", "{$field}:{$entity->$field}");
|
||||
}
|
||||
$this->add_MylogTrait(__FUNCTION__, [], $entity);
|
||||
// log_message("debug", $this->getModel()->getLastQuery());
|
||||
return $entity;
|
||||
}
|
||||
|
||||
@ -4,9 +4,11 @@ namespace App\Services;
|
||||
|
||||
use App\Models\MapurlModel;
|
||||
use App\Entities\MapurlEntity;
|
||||
use App\Traits\MylogTrait;
|
||||
|
||||
class MapurlService extends CommonService
|
||||
{
|
||||
use MylogTrait;
|
||||
private ?MapurlModel $_model = null;
|
||||
public function __construct()
|
||||
{
|
||||
@ -22,25 +24,19 @@ class MapurlService extends CommonService
|
||||
public function create(array $formDatas): MapurlEntity
|
||||
{
|
||||
//생성값 formDatas Log남기기
|
||||
foreach ($formDatas as $field => $value) {
|
||||
MyLogService::add("info", "{$field}:{$value}");
|
||||
}
|
||||
$this->add_MylogTrait(__FUNCTION__, $formDatas);
|
||||
return $this->getModel()->create($formDatas);
|
||||
}
|
||||
public function modify(MapurlEntity $entity, array $formDatas): MapurlEntity
|
||||
{
|
||||
//변경전 entity 값, 변경값 formDatas Log남기기
|
||||
foreach ($this->getModel()->getFields() as $field) {
|
||||
MyLogService::add("info", "{$field}:{$entity->$field}=>{$formDatas[$field]}");
|
||||
}
|
||||
$this->add_MylogTrait(__FUNCTION__, $formDatas, $entity);
|
||||
return $this->getModel()->modify($entity, $formDatas);
|
||||
}
|
||||
public function delete(MapurlEntity $entity): void
|
||||
{
|
||||
//삭제전 entity 값 Log남기기
|
||||
foreach ($this->getModel()->getFields() as $field) {
|
||||
MyLogService::add("info", "{$field}:{$entity->$field}");
|
||||
}
|
||||
$this->add_MylogTrait(__FUNCTION__, [], $entity);
|
||||
$this->getModel()->delete($entity->getPK());
|
||||
}
|
||||
}
|
||||
|
||||
31
app/Traits/MylogTrait.php
Normal file
31
app/Traits/MylogTrait.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use App\Entities\CommonEntity;
|
||||
use App\Services\MyLogService;
|
||||
|
||||
|
||||
trait MylogTrait
|
||||
{
|
||||
final public function add_MylogTrait(string $action, array $formDatas, ?CommonEntity $entity = null): void
|
||||
{
|
||||
switch ($action) {
|
||||
case 'create':
|
||||
foreach ($formDatas as $field => $value) {
|
||||
MyLogService::add("info", "{$field}:{$value}");
|
||||
}
|
||||
break;
|
||||
case 'modify':
|
||||
foreach ($formDatas as $field => $value) {
|
||||
MyLogService::add("info", "{$field}:{$entity->$field}=>{$formDatas[$field]}");
|
||||
}
|
||||
break;
|
||||
case 'delete':
|
||||
foreach ($this->getModel()->getFields() as $field) {
|
||||
MyLogService::add("info", "{$field}:{$entity->$field}");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user