Automation init...3
This commit is contained in:
parent
53b25f2733
commit
2dc97d782e
@ -1,67 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
namespace App\Controllers\Cloudflare;
|
||||
|
||||
use App\Controllers\CommonController;
|
||||
use App\Libraries\MySocket\Cloudflare\AccountSocket;
|
||||
use App\Models\Cloudflare\AccountModel;
|
||||
|
||||
use App\Traits\AuthTrait;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
|
||||
class AccountController extends CommonController
|
||||
use App\Libraries\MySocket\Cloudflare\AccountSocket;
|
||||
use App\Libraries\MyStorage\AccountStorage;
|
||||
|
||||
class AccountController extends MyCloudflare
|
||||
{
|
||||
use AuthTrait;
|
||||
private $_email = "";
|
||||
private $_api_key = "";
|
||||
private $_mySocket = null;
|
||||
private $_model = null;
|
||||
private $_myStorage = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->session = $this->loginCheck_AuthTrait();
|
||||
}
|
||||
final public function getMySocket(string $email, $api_key): AccountSocket
|
||||
final protected function getMySocket(): AccountSocket
|
||||
{
|
||||
if ($this->_mySocket === null) {
|
||||
$this->_mySocket = new AccountSocket($email, $api_key);
|
||||
$this->_mySocket = new AccountSocket($this->_email, $this->_api_key);
|
||||
}
|
||||
return $this->_mySocket;
|
||||
}
|
||||
final public function getModel(): AccountModel
|
||||
final protected function getMyStorage(): AccountStorage
|
||||
{
|
||||
if ($this->_model === null) {
|
||||
$this->_model = new AccountModel();
|
||||
if ($this->_myStorage === null) {
|
||||
$this->_myStorage = new AccountStorage();
|
||||
}
|
||||
return $this->_model;
|
||||
return $this->_myStorage;
|
||||
}
|
||||
public function create(string $email, $api_key, array $formDatas = [])
|
||||
|
||||
public function create(): void
|
||||
{
|
||||
$this->_email = $this->request->getVar('email');
|
||||
$this->_api_key = $this->request->getVar('key');
|
||||
//전송
|
||||
$result = $this->getMySocket($email, $api_key)->create($email);
|
||||
//답변형태
|
||||
// [
|
||||
// {"id":"078e88a7735965b661715af13031ecb0",
|
||||
// "name":"Cloudwin002@idcjp.jp's Account",
|
||||
// "type":"standard",
|
||||
// "settings":{
|
||||
// "enforce_twofactor":false,
|
||||
// "api_access_enabled":null,
|
||||
// "access_approval_expiry":null,
|
||||
// "use_account_custom_ns_by_default":false
|
||||
// },
|
||||
// "legacy_flags":{"enterprise_zone_quota":{"maximum":0,"current":0,"available":0}},
|
||||
// "created_on":"2017-06-26T05:44:49.470184Z"}
|
||||
// ]
|
||||
$formDatas[$this->getModel()->getTitleField()] = $email;
|
||||
$formDatas['key'] = $api_key;
|
||||
$formDatas[$this->getModel()->PK()] = $result->id;
|
||||
$formDatas[$this->getModel()->getTitleField()] = $result->name;
|
||||
$formDatas['type'] = $result->type;
|
||||
$formDatas['status'] = 'use';
|
||||
$formDatas['updated_at'] = $result->created_on;
|
||||
$formDatas['created_at'] = $result->created_on;
|
||||
$entity = $this->getModel()->create($formDatas);
|
||||
log_message("notice", __FUNCTION__ . "=> {$entity->getTitle()} 생성을 완료하였습니다.");
|
||||
$result = $this->getMySocket()->create($this->_email);
|
||||
$formDatas = [];
|
||||
$formDatas['key'] = $this->_api_key;
|
||||
$entity = $this->getMyStorage()->create_process($result, $formDatas);
|
||||
log_message("notice", __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
52
app/Controllers/Cloudflare/Admin/AccountController.php
Normal file
52
app/Controllers/Cloudflare/Admin/AccountController.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Cloudflare\Admin;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
|
||||
use App\Libraries\MyStorage\AccountStorage;
|
||||
use App\Libraries\MySocket\Cloudflare\AccountSocket;
|
||||
use App\Controllers\Cloudflare\MyCloudflare;
|
||||
use App\Traits\AuthTrait;
|
||||
|
||||
class AccountController extends MyCloudflare
|
||||
{
|
||||
use AuthTrait;
|
||||
private $_email = "";
|
||||
private $_api_key = "";
|
||||
private $_mySocket = null;
|
||||
private $_myStorage = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->session = $this->loginCheck_AuthTrait();
|
||||
}
|
||||
final protected function getMySocket(): AccountSocket
|
||||
{
|
||||
if ($this->_mySocket === null) {
|
||||
$this->_mySocket = new AccountSocket($this->_email, $this->_api_key);
|
||||
}
|
||||
return $this->_mySocket;
|
||||
}
|
||||
final protected function getMyStorage(): AccountStorage
|
||||
{
|
||||
if ($this->_myStorage === null) {
|
||||
$this->_myStorage = new AccountStorage();
|
||||
}
|
||||
return $this->_myStorage;
|
||||
}
|
||||
|
||||
public function create(): void
|
||||
{
|
||||
$this->_email = $this->request->getVar('email');
|
||||
$this->_api_key = $this->request->getVar('key');
|
||||
//전송
|
||||
$result = $this->getMySocket()->create($this->_email);
|
||||
$formDatas = [];
|
||||
$formDatas['key'] = $this->_api_key;
|
||||
$entity = $this->getMyStorage()->create_process($result, $formDatas);
|
||||
log_message("notice", __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
||||
}
|
||||
}
|
||||
22
app/Controllers/Cloudflare/MyCloudflare.php
Normal file
22
app/Controllers/Cloudflare/MyCloudflare.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Cloudflare;
|
||||
|
||||
use App\Controllers\CommonController;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
|
||||
abstract class MyCloudflare extends CommonController
|
||||
{
|
||||
private $_email = "";
|
||||
private $_api_key = "";
|
||||
private $_mySocket = null;
|
||||
private $_myStorage = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
abstract protected function getMySocket();
|
||||
abstract protected function getMyStorage();
|
||||
}
|
||||
@ -2,13 +2,13 @@
|
||||
|
||||
namespace App\Controllers\Mangboard\Crawler;
|
||||
|
||||
use App\Controllers\Mangboard\CrawlerController;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use App\Controllers\Mangboard\MyCrawler;
|
||||
|
||||
class InvenCrawler extends CrawlerController
|
||||
class InvenCrawler extends MyCrawler
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
|
||||
@ -16,7 +16,7 @@ use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
abstract class CrawlerController extends CommonController
|
||||
abstract class MyCrawler extends CommonController
|
||||
{
|
||||
use FileTrait;
|
||||
private $_mySocket = null;
|
||||
@ -224,16 +224,48 @@ abstract class CrawlerController extends CommonController
|
||||
}
|
||||
return $storages;
|
||||
}
|
||||
private function backend_process(int $cnt, array $listInfo, array $storages)
|
||||
private function backend_process(int $cnt, array $listInfo, array $storages): void
|
||||
{
|
||||
//File DB 및 Board DB 등록작업등
|
||||
$board_entity = $this->getBoardModel()->createByCrawler(
|
||||
$this->getBoardsEntity(),
|
||||
$this->getUserEntity(),
|
||||
//Board DB 등록작업등
|
||||
$formDatas = ['image_path' => "", 'content' => ""];
|
||||
//미디어관련정보 entity에 넣기
|
||||
$formDatas['title'] = $listInfo["title"];
|
||||
$formDatas['user_pid'] = $this->getUserEntity()->getPK();
|
||||
$formDatas['user_id'] = $this->getUserEntity()->getID();
|
||||
$formDatas['user_name'] = $listInfo["nickname"] != "" ? $listInfo["nickname"] : $this->getUserEntity()->getTitle();
|
||||
$formDatas['level'] = $this->getBoardsEntity()->getListLevel();
|
||||
$formDatas['hit'] = intval($listInfo['hit']);
|
||||
$formDatas['reg_date'] = date("Y-m-d H:i:s", strtotime($listInfo['date']));
|
||||
$formDatas['data_type'] = "html";
|
||||
$formDatas['editor_type'] = "S";
|
||||
foreach ($storages as $storage) {
|
||||
if ($formDatas['image_path'] == "") {
|
||||
$formDatas['image_path'] = $storage->getBasePath() . DIRECTORY_SEPARATOR . $storage->getPath() . DIRECTORY_SEPARATOR . $storage->getOriginName();
|
||||
}
|
||||
$formDatas['content'] .= $storage->getHTMLTag();
|
||||
}
|
||||
//망보드 게시판에 등록
|
||||
if ($formDatas['content'] == "") {
|
||||
throw new \Exception(sprintf(
|
||||
"%s=>%s번째 %s 내용이 없어 => %s 등록 안함 : storage->%s",
|
||||
__FUNCTION__,
|
||||
$cnt,
|
||||
$listInfo,
|
||||
$storages
|
||||
);
|
||||
$listInfo["title"],
|
||||
$this->getBoardModel()->getTable(),
|
||||
count($storages)
|
||||
));
|
||||
}
|
||||
$board_entity = $this->getBoardModel()->create($formDatas);
|
||||
log_message("notice", sprintf(
|
||||
"%s=>%s번째 %s => %s 등록 완료 : storage->%s",
|
||||
__FUNCTION__,
|
||||
$cnt,
|
||||
$listInfo["title"],
|
||||
$this->getBoardModel()->getTable(),
|
||||
count($storages)
|
||||
));
|
||||
|
||||
//File DB 등록작업, 작은이미지 생성
|
||||
foreach ($storages as $storage) {
|
||||
try {
|
||||
$storage->backend_process($this->getBoardsEntity(), $board_entity, $this->getBoardModel()->getTable());
|
||||
@ -2,14 +2,14 @@
|
||||
|
||||
namespace App\Controllers\Mangboard\Crawler;
|
||||
|
||||
use App\Controllers\Mangboard\CrawlerController;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use App\Controllers\Mangboard\MyCrawler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
use DateTime;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
class SirCrawler extends CrawlerController
|
||||
class SirCrawler extends MyCrawler
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
|
||||
@ -2,13 +2,13 @@
|
||||
|
||||
namespace App\Controllers\Mangboard\Crawler;
|
||||
|
||||
use App\Controllers\Mangboard\CrawlerController;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use App\Controllers\Mangboard\MyCrawler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
class YamapCrawler extends CrawlerController
|
||||
class YamapCrawler extends MyCrawler
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
|
||||
@ -2,13 +2,13 @@
|
||||
|
||||
namespace App\Controllers\Mangboard\Crawler;
|
||||
|
||||
use App\Controllers\Mangboard\CrawlerController;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use App\Controllers\Mangboard\MyCrawler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
class YamoonCrawler extends CrawlerController
|
||||
class YamoonCrawler extends MyCrawler
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
|
||||
@ -2,10 +2,7 @@
|
||||
|
||||
namespace App\Libraries\MySocket\Cloudflare;
|
||||
|
||||
use App\Entities\Cloudflare\AccountEntity;
|
||||
use App\Libraries\CommonLibrary;
|
||||
use App\Libraries\MySocket\CloudflareSocket;
|
||||
use Cloudflare\API\Auth\APIKey;
|
||||
|
||||
class AccountSocket extends CloudflareSocket
|
||||
{
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
namespace App\Libraries\MySocket;
|
||||
|
||||
use App\Libraries\CommonLibrary;
|
||||
use App\Entities\Cloudflare\AccountEntity;
|
||||
use Cloudflare\API\Adapter\Guzzle;
|
||||
use Cloudflare\API\Auth\APIKey;
|
||||
|
||||
|
||||
51
app/Libraries/MyStorage/Cloudflare/AccountStorage.php
Normal file
51
app/Libraries/MyStorage/Cloudflare/AccountStorage.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries\MyStorage;
|
||||
|
||||
use App\Libraries\CommonLibrary;
|
||||
use App\Entities\Cloudflare\AccountEntity;
|
||||
use App\Models\Cloudflare\AccountModel;
|
||||
use App\Traits\ImageTrait;
|
||||
|
||||
class AccountStorage extends CommonLibrary
|
||||
{
|
||||
private $_accountModel = null;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
final protected function getAccountModel(): AccountModel
|
||||
{
|
||||
if ($this->_accountModel === null) {
|
||||
$this->_accountModel = new AccountModel();
|
||||
}
|
||||
return $this->_accountModel;
|
||||
}
|
||||
|
||||
final public function create_process($result, array $formDatas): AccountEntity
|
||||
{
|
||||
//Result 형태
|
||||
// [
|
||||
// {"id":"078e88a7735965b661715af13031ecb0",
|
||||
// "name":"Cloudwin002@idcjp.jp's Account",
|
||||
// "type":"standard",
|
||||
// "settings":{
|
||||
// "enforce_twofactor":false,
|
||||
// "api_access_enabled":null,
|
||||
// "access_approval_expiry":null,
|
||||
// "use_account_custom_ns_by_default":false
|
||||
// },
|
||||
// "legacy_flags":{"enterprise_zone_quota":{"maximum":0,"current":0,"available":0}},
|
||||
// "created_on":"2017-06-26T05:44:49.470184Z"}
|
||||
// ]
|
||||
$formDatas[$this->getAccountModel()->PK()] = $result->id;
|
||||
$formDatas[$this->getAccountModel()->getTitleField()] = $result->name;
|
||||
$formDatas['type'] = $result->type;
|
||||
$formDatas['status'] = 'use';
|
||||
$formDatas['updated_at'] = $result->created_on;
|
||||
$formDatas['created_at'] = $result->created_on;
|
||||
$entity = $this->getAccountModel()->create($formDatas);
|
||||
log_message("notice", __FUNCTION__ . "=> {$entity->getTitle()} 생성을 완료하였습니다.");
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
@ -74,15 +74,33 @@ class MangboardStorage extends FileStorage
|
||||
return $content;
|
||||
}
|
||||
|
||||
final public function backend_process(BoardsEntity $boards_entity, BoardEntity $board_entity, string $board_table)
|
||||
final public function backend_process(BoardsEntity $boards_entity, BoardEntity $board_entity, string $board_table): void
|
||||
{
|
||||
$this->getFileModel()->createByCrawler(
|
||||
$boards_entity,
|
||||
$this->_user_entity,
|
||||
$board_entity,
|
||||
$board_table,
|
||||
$this
|
||||
);
|
||||
//File DB에 넣기
|
||||
$formDatas['board_pid'] = $board_entity->getPk();
|
||||
$formDatas['user_pid'] = $this->_user_entity->getPK();
|
||||
$formDatas['user_name'] = $this->_user_entity->getTitle();
|
||||
$formDatas['board_name'] = $boards_entity->getTitle();
|
||||
$formDatas['table_name'] = $board_table;
|
||||
$formDatas['file_path'] = $this->getBasePath() . DIRECTORY_SEPARATOR . $this->getPath() . DIRECTORY_SEPARATOR . $this->getOriginName();
|
||||
$formDatas['file_name'] = $this->getOriginName();
|
||||
$formDatas['file_type'] = $this->getMimeType();
|
||||
$formDatas['file_caption'] = $this->getOriginName();
|
||||
$formDatas['file_alt'] = $this->getOriginName();
|
||||
$formDatas['file_description'] = "Filedata";
|
||||
$formDatas['file_size'] = $this->getFileSize();
|
||||
$formDatas['file_sequence'] = $this->getOriginSequence();
|
||||
$formDatas['reg_date'] = date("Y-m-d H:i:s");
|
||||
$entity = $this->getFileModel()->create($formDatas);
|
||||
log_message("notice", sprintf(
|
||||
"%s -> %s 게시물의 %s번째:%s 파일 등록 완료",
|
||||
__FUNCTION__,
|
||||
$board_entity->getTitle(),
|
||||
$this->getOriginSequence(),
|
||||
$entity->getTitle()
|
||||
));
|
||||
|
||||
//작은이미지 만들기
|
||||
$this->create_small_ImageTrait($board_entity, $this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ class AccountModel extends Model
|
||||
{
|
||||
protected $table = 'cloudflareaccount';
|
||||
protected $primaryKey = 'uid';
|
||||
protected $useAutoIncrement = false;
|
||||
protected $returnType = AccountEntity::class; //object,array,entity명::class
|
||||
protected $allowedFields = ['uid', 'email', 'key', 'oldkey', 'type', 'status', 'updated_at', 'created_at'];
|
||||
protected $useTimestamps = true;
|
||||
|
||||
@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cloudflare\API;
|
||||
|
||||
use App\Entities\Cloudflare\API\ZoneEntity;
|
||||
use App\Entities\Cloudflare\API\FirewallEntity;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class FirewallModel extends Model
|
||||
{
|
||||
const PARENT_FIELD = "zone_uid";
|
||||
protected $DBGroup = "default";
|
||||
protected $table = "cloudflarefirewall";
|
||||
protected $primaryKey = "uid";
|
||||
protected $useAutoIncrement = false;
|
||||
protected $insertID = 0;
|
||||
protected $returnType = "array"; //object,array,entity명::class
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = ["uid", "zone_uid", "description", "filter_id", "filter_expression", "filter_paused", "paused", "action", "updated_at", "crated_at"];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = "datetime";
|
||||
protected $createdField = "created_at";
|
||||
protected $updatedField = "updated_at";
|
||||
protected $deletedField = "deleted_at";
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [
|
||||
"uid" => "if_exist|min_length[10]|max_length[200]",
|
||||
"zone_uid" => "if_exist|min_length[10]|max_length[200]",
|
||||
"description" => "if_exist|string",
|
||||
"filter_id" => "if_exist|min_length[10]|max_length[200]",
|
||||
"filter_expression" => "if_exist|string",
|
||||
"filter_paused" => "if_exist|in_list[on,off]",
|
||||
"paused" => "if_exist|in_list[on,off]",
|
||||
"action" => "if_exist|string",
|
||||
"updated_at" => "if_exist|valid_date",
|
||||
"created_at" => "if_exist|valid_date",
|
||||
];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = true;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
public function getTableName()
|
||||
{
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
public function getEntity(string $uid): FirewallEntity
|
||||
{
|
||||
$entity = $this->asObject(FirewallEntity::class)->where("uid", $uid)->first();
|
||||
if (is_null($entity)) {
|
||||
throw new \Exception(__METHOD__ . "에서 {$uid} 해당 정보가 없습니다.");
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
public function getEntitys(array $wheres)
|
||||
{
|
||||
return $this->asObject(FirewallEntity::class)->where($wheres)->findAll();
|
||||
}
|
||||
public function getEntitysByZone(ZoneEntity $zone)
|
||||
{
|
||||
return $this->getEntitys([self::PARENT_FIELD, $zone->getPrimaryKey()]);
|
||||
}
|
||||
|
||||
//Index 검색용
|
||||
public function setIndexWordFilter(string $word)
|
||||
{
|
||||
$this->like("description", $word, "both"); //befor , after , both
|
||||
}
|
||||
public function setIndexDateFilter($start, $end)
|
||||
{
|
||||
$this->where("created_at >=", $start);
|
||||
$this->where("created_at <=", $end);
|
||||
}
|
||||
public function setIndexOrderBy($field, $order = "ASC")
|
||||
{
|
||||
$this->orderBy("zone_uid ASC, description ASC, {$field} {$order}");
|
||||
}
|
||||
}
|
||||
@ -149,50 +149,4 @@ class BoardModel extends CommonModel
|
||||
{
|
||||
return $this->modify_process($entity, $formDatas);
|
||||
}
|
||||
public function createByCrawler(
|
||||
BoardsEntity $boards_entity,
|
||||
UserEntity $user_entity,
|
||||
int $cnt,
|
||||
array $listInfo,
|
||||
array $storages = [],
|
||||
array $formDatas = ['image_path' => "", 'content' => ""]
|
||||
): BoardEntity {
|
||||
//미디어관련정보 entity에 넣기
|
||||
$formDatas['title'] = $listInfo["title"];
|
||||
$formDatas['user_pid'] = $user_entity->getPK();
|
||||
$formDatas['user_id'] = $user_entity->getID();
|
||||
$formDatas['user_name'] = $listInfo["nickname"] != "" ? $listInfo["nickname"] : $user_entity->getTitle();
|
||||
$formDatas['level'] = $boards_entity->getListLevel();
|
||||
$formDatas['hit'] = intval($listInfo['hit']);
|
||||
$formDatas['reg_date'] = date("Y-m-d H:i:s", strtotime($listInfo['date']));
|
||||
$formDatas['data_type'] = "html";
|
||||
$formDatas['editor_type'] = "S";
|
||||
foreach ($storages as $storage) {
|
||||
if ($formDatas['image_path'] == "") {
|
||||
$formDatas['image_path'] = $storage->getBasePath() . DIRECTORY_SEPARATOR . $storage->getPath() . DIRECTORY_SEPARATOR . $storage->getOriginName();
|
||||
}
|
||||
$formDatas['content'] .= $storage->getHTMLTag();
|
||||
}
|
||||
//망보드 게시판에 등록
|
||||
if ($formDatas['content'] == "") {
|
||||
throw new \Exception(sprintf(
|
||||
"%s=>%s번째 %s 내용이 없어 => %s 등록 안함 : storage->%s",
|
||||
__FUNCTION__,
|
||||
$cnt,
|
||||
$listInfo["title"],
|
||||
$this->getTable(),
|
||||
count($storages)
|
||||
));
|
||||
}
|
||||
$entity = $this->create($formDatas);
|
||||
log_message("notice", sprintf(
|
||||
"%s=>%s번째 %s => %s 등록 완료 : storage->%s",
|
||||
__FUNCTION__,
|
||||
$cnt,
|
||||
$listInfo["title"],
|
||||
$this->getTable(),
|
||||
count($storages)
|
||||
));
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,37 +125,4 @@ class FileModel extends CommonModel
|
||||
{
|
||||
return $this->modify_process($entity, $formDatas);
|
||||
}
|
||||
public function createByCrawler(
|
||||
BoardsEntity $boards_entity,
|
||||
UserEntity $user_entity,
|
||||
BoardEntity $board_entity,
|
||||
string $board_table,
|
||||
MangboardStorage $storage,
|
||||
array $formDatas = []
|
||||
): FileEntity {
|
||||
//Board PID 넣기
|
||||
$formDatas['board_pid'] = $board_entity->getPk();
|
||||
$formDatas['user_pid'] = $user_entity->getPK();
|
||||
$formDatas['user_name'] = $user_entity->getTitle();
|
||||
$formDatas['board_name'] = $boards_entity->getTitle();
|
||||
$formDatas['table_name'] = $board_table;
|
||||
$formDatas['file_path'] = $storage->getBasePath() . DIRECTORY_SEPARATOR . $storage->getPath() . DIRECTORY_SEPARATOR . $storage->getOriginName();
|
||||
$formDatas['file_name'] = $storage->getOriginName();
|
||||
$formDatas['file_type'] = $storage->getMimeType();
|
||||
$formDatas['file_caption'] = $storage->getOriginName();
|
||||
$formDatas['file_alt'] = $storage->getOriginName();
|
||||
$formDatas['file_description'] = "Filedata";
|
||||
$formDatas['file_size'] = $storage->getFileSize();
|
||||
$formDatas['file_sequence'] = $storage->getOriginSequence();
|
||||
$formDatas['reg_date'] = date("Y-m-d H:i:s");
|
||||
$entity = $this->create($formDatas);
|
||||
log_message("notice", sprintf(
|
||||
"%s -> %s 게시물의 %s번째:%s 파일 등록 완료",
|
||||
__FUNCTION__,
|
||||
$board_entity->getTitle(),
|
||||
$storage->getOriginSequence(),
|
||||
$entity->getTitle()
|
||||
));
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user