Automation init...3
This commit is contained in:
parent
7a0e6405c5
commit
4433192604
@ -3,17 +3,20 @@
|
||||
namespace App\Controllers\Mangboard;
|
||||
|
||||
use App\Controllers\CommonController;
|
||||
use App\Libraries\Mangboard\UserLibrary;
|
||||
use App\Libraries\Mangboard\User;
|
||||
use App\Entities\Mangboard\UserEntity;
|
||||
use App\Libraries\MyCrawler\YamapCrawler;
|
||||
use App\Libraries\MyCrawler\YamoonCrawler;
|
||||
|
||||
class CrawlerController extends CommonController
|
||||
{
|
||||
private function login_process(string $id, string $password): UserEntity
|
||||
private $_user = null;
|
||||
private function getUser()
|
||||
{
|
||||
$user_library = new UserLibrary();
|
||||
return $user_library->login(getenv("mangboard.host.url"), $id, $password);
|
||||
if ($this->_user === null) {
|
||||
$this->_user = new User();
|
||||
}
|
||||
return $this->_user;
|
||||
}
|
||||
public function yamap(string $category, string $id = "", string $debug = "false"): string
|
||||
{
|
||||
@ -21,7 +24,7 @@ class CrawlerController extends CommonController
|
||||
$id = $id == "" ? getenv("mangboard.login.default.id") : $id;
|
||||
$password = getenv("mangboard.login.default.password");
|
||||
//1. 사이트 로그인 처리
|
||||
$user_entity = $this->login_process($id, $password);
|
||||
$user_entity = $this->getUser()->login(getenv("mangboard.host.url"), $id, $password);
|
||||
//2. 필요한 로그인한 사용자정보,Socket,Storage 정의후 Crawler에게 전달.
|
||||
$crawler = new YamapCrawler(getenv('yamap.host.url'), $category, $user_entity);
|
||||
$crawler->setDebug($debug === "true" ? true : false);
|
||||
@ -38,7 +41,7 @@ class CrawlerController extends CommonController
|
||||
$id = $id == "" ? getenv("mangboard.login.default.id") : $id;
|
||||
$password = getenv("mangboard.login.default.password");
|
||||
//1. 사이트 로그인 처리
|
||||
$user_entity = $this->login_process($id, $password);
|
||||
$user_entity = $this->getUser()->login(getenv("mangboard.host.url"), $id, $password);
|
||||
//2. 필요한 로그인한 사용자정보,Socket,Storage 정의후 Crawler에게 전달.
|
||||
$crawler = new YamoonCrawler(getenv("yamoon.host.url"), $category, $user_entity);
|
||||
$crawler->setDebug($debug === "true" ? true : false);
|
||||
|
||||
@ -8,7 +8,7 @@ use App\Entities\Mangboard\UserEntity;
|
||||
use App\Entities\Mangboard\BoardsEntity;
|
||||
use App\Entities\Mangboard\BoardEntity;
|
||||
|
||||
class BoardLibrary extends CommonLibrary
|
||||
class Board extends CommonLibrary
|
||||
{
|
||||
private $_model = null;
|
||||
private $_boards_entity = null;
|
||||
@ -7,7 +7,7 @@ use App\Models\Mangboard\BoardsModel;
|
||||
use App\Entities\Mangboard\UserEntity;
|
||||
use App\Entities\Mangboard\BoardsEntity;
|
||||
|
||||
class BoardsLibrary extends CommonLibrary
|
||||
class Boards extends CommonLibrary
|
||||
{
|
||||
private $_model = null;
|
||||
private $_entity = null;
|
||||
@ -10,7 +10,7 @@ use App\Entities\Mangboard\FileEntity;
|
||||
use App\Entities\Mangboard\BoardsEntity;
|
||||
use App\Entities\Mangboard\BoardEntity;
|
||||
|
||||
class FileLibrary extends CommonLibrary
|
||||
class File extends CommonLibrary
|
||||
{
|
||||
private $_model = null;
|
||||
private $_boards_entity = null;
|
||||
@ -8,7 +8,7 @@ use App\Libraries\MyStorage\MangboardStorage;
|
||||
use App\Libraries\CommonLibrary;
|
||||
use App\Entities\Mangboard\BoardEntity;
|
||||
|
||||
class ImageLibrary extends CommonLibrary
|
||||
class Image extends CommonLibrary
|
||||
{
|
||||
use FileTrait, ImageTrait;
|
||||
public function __construct()
|
||||
@ -6,7 +6,7 @@ use App\Models\Mangboard\UserModel;
|
||||
use App\Entities\Mangboard\UserEntity;
|
||||
use App\Libraries\CommonLibrary;
|
||||
|
||||
class UserLibrary extends CommonLibrary
|
||||
class User extends CommonLibrary
|
||||
{
|
||||
private $_user_model = null;
|
||||
public function __construct()
|
||||
@ -3,11 +3,10 @@
|
||||
namespace App\Libraries\MyAuth;
|
||||
|
||||
use App\Libraries\MySocket\Web\GoogleSocket;
|
||||
use App\Libraries\MyAuthLibrary;
|
||||
use App\Entities\UserEntity;
|
||||
use App\Entities\SNSUserEntity;
|
||||
|
||||
class GoogleAuth extends MyAuthLibrary
|
||||
class GoogleAuth extends MyAuth
|
||||
{
|
||||
private $_mySocket = null;
|
||||
private $_site = "GOOGLE";
|
||||
|
||||
@ -2,10 +2,9 @@
|
||||
|
||||
namespace App\Libraries\MyAuth;
|
||||
|
||||
use App\Libraries\MyAuthLibrary;
|
||||
use App\Entities\UserEntity;
|
||||
|
||||
class LocalAuth extends MyAuthLibrary
|
||||
class LocalAuth extends MyAuth
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries;
|
||||
namespace App\Libraries\MyAuth;
|
||||
|
||||
use App\Entities\UserEntity;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\SNSUserModel;
|
||||
|
||||
// 참고:https://github.com/SyntaxPhoenix/iloclient
|
||||
abstract class MyAuthLibrary
|
||||
abstract class MyAuth
|
||||
{
|
||||
private $_userModel = null;
|
||||
private $_snsUserModel = null;
|
||||
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries;
|
||||
namespace App\Libraries\MyCrawler;
|
||||
|
||||
use App\Libraries\CommonLibrary;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
use App\Traits\FileTrait;
|
||||
|
||||
abstract class MyCrawlerLibrary extends CommonLibrary
|
||||
abstract class MyCrawler extends CommonLibrary
|
||||
{
|
||||
use FileTrait;
|
||||
private $_mySocket = null;
|
||||
@ -2,14 +2,12 @@
|
||||
|
||||
namespace App\Libraries\MyCrawler;
|
||||
|
||||
|
||||
use App\Libraries\MyCrawlerLibrary;
|
||||
use App\Libraries\MySocket\WebSocket;
|
||||
use App\Libraries\MyStorage\MangboardStorage;
|
||||
use App\Entities\Mangboard\UserEntity;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
class YamapCrawler extends MyCrawlerLibrary
|
||||
class YamapCrawler extends MyCrawler
|
||||
{
|
||||
private $_category = "";
|
||||
private $_user_entity = null;
|
||||
@ -119,9 +117,9 @@ class YamapCrawler extends MyCrawlerLibrary
|
||||
list($listInfo, $urls) = $this->detailPage($listInfo);
|
||||
$this->mediaProcess($urls);
|
||||
//File DB 및 Board DB 등록작업
|
||||
$board_entity = $this->getMyStorage()->getBoardLibrary()->createByCrawler($i, $listInfo, $this->_storages);
|
||||
$this->getMyStorage()->getFileLibrary()->createByCrawler($board_entity, $this->_storages);
|
||||
$this->getMyStorage()->getImageLibrary()->createByCrawler($board_entity, $this->_storages);
|
||||
$board_entity = $this->getMyStorage()->getBoard()->createByCrawler($i, $listInfo, $this->_storages);
|
||||
$this->getMyStorage()->getFile()->createByCrawler($board_entity, $this->_storages);
|
||||
$this->getMyStorage()->getImage()->createByCrawler($board_entity, $this->_storages);
|
||||
log_message("notice", "게시물 {$i}번째/{$total}개중 {$listInfo["nickname"]} 작업완료.");
|
||||
$i++;
|
||||
} catch (\Exception $e) {
|
||||
|
||||
@ -2,13 +2,12 @@
|
||||
|
||||
namespace App\Libraries\MyCrawler;
|
||||
|
||||
use App\Entities\Mangboard\UserEntity;
|
||||
use App\Libraries\MyCrawlerLibrary;
|
||||
use App\Libraries\MySocket\WebSocket;
|
||||
use App\Libraries\MyStorage\MangboardStorage;
|
||||
use App\Entities\Mangboard\UserEntity;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
class YamoonCrawler extends MyCrawlerLibrary
|
||||
class YamoonCrawler extends MyCrawler
|
||||
{
|
||||
private $_category = "";
|
||||
private $_user_entity = null;
|
||||
@ -96,9 +95,9 @@ class YamoonCrawler extends MyCrawlerLibrary
|
||||
list($listInfo, $urls) = $this->detailPage($listInfo);
|
||||
$this->mediaProcess($urls);
|
||||
//File DB 및 Board DB 등록작업
|
||||
$board_entity = $this->getMyStorage()->getBoardLibrary()->createByCrawler($i, $listInfo, $this->_storages);
|
||||
$this->getMyStorage()->getFileLibrary()->createByCrawler($board_entity, $this->_storages);
|
||||
$this->getMyStorage()->getImageLibrary()->createByCrawler($board_entity, $this->_storages);
|
||||
$board_entity = $this->getMyStorage()->getBoard()->createByCrawler($i, $listInfo, $this->_storages);
|
||||
$this->getMyStorage()->getFile()->createByCrawler($board_entity, $this->_storages);
|
||||
$this->getMyStorage()->getImage()->createByCrawler($board_entity, $this->_storages);
|
||||
log_message("notice", "게시물 {$i}번째/{$total}개중 {$listInfo["nickname"]} 작업완료.");
|
||||
$i++;
|
||||
} catch (\Exception $e) {
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries;
|
||||
namespace App\Libraries\MySocket;
|
||||
|
||||
use App\Libraries\CommonLibrary;
|
||||
|
||||
abstract class MySocketLibrary extends CommonLibrary
|
||||
abstract class MySocket extends CommonLibrary
|
||||
{
|
||||
private $_host = null;
|
||||
protected function __construct(string $host)
|
||||
@ -4,9 +4,8 @@ namespace App\Libraries\MySocket;
|
||||
|
||||
use GuzzleHttp\Cookie\CookieJar;
|
||||
use GuzzleHttp\Client;
|
||||
use App\Libraries\MySocketLibrary;
|
||||
|
||||
class WebSocket extends MySocketLibrary
|
||||
class WebSocket extends MySocket
|
||||
{
|
||||
private $_client = null;
|
||||
private $_cookieJar = null;
|
||||
|
||||
@ -2,10 +2,9 @@
|
||||
|
||||
namespace App\Libraries\MyStorage;
|
||||
|
||||
use App\Libraries\MyStorageLibrary;
|
||||
use App\Traits\FileTrait;
|
||||
|
||||
class FileStorage extends MyStorageLibrary
|
||||
class FileStorage extends MyStorage
|
||||
{
|
||||
use FileTrait;
|
||||
private $_path = "";
|
||||
|
||||
@ -3,17 +3,17 @@
|
||||
namespace App\Libraries\MyStorage;
|
||||
|
||||
use App\Entities\Mangboard\UserEntity;
|
||||
use App\Libraries\Mangboard\BoardLibrary;
|
||||
use App\Libraries\Mangboard\BoardsLibrary;
|
||||
use App\Libraries\Mangboard\FileLibrary;
|
||||
use App\Libraries\Mangboard\ImageLibrary;
|
||||
use App\Libraries\Mangboard\Board;
|
||||
use App\Libraries\Mangboard\Boards;
|
||||
use App\Libraries\Mangboard\File;
|
||||
use App\Libraries\Mangboard\Image;
|
||||
|
||||
class MangboardStorage extends FileStorage
|
||||
{
|
||||
private $_boards_library = null;
|
||||
private $_board_library = null;
|
||||
private $_file_library = null;
|
||||
private $_image_library = null;
|
||||
private $_boards = null;
|
||||
private $_board = null;
|
||||
private $_file = null;
|
||||
private $_image = null;
|
||||
private $_category = "";
|
||||
private $_user_entity = null;
|
||||
public function __construct(string $category, UserEntity $user_entity)
|
||||
@ -83,38 +83,38 @@ class MangboardStorage extends FileStorage
|
||||
return $content;
|
||||
}
|
||||
|
||||
private function getBoardsLibrary(): BoardsLibrary
|
||||
private function getBoards(): Boards
|
||||
{
|
||||
if ($this->_boards_library === null) {
|
||||
$this->_boards_library = new BoardsLibrary($this->getCategory(), $this->getUserEntity());
|
||||
if ($this->_boards === null) {
|
||||
$this->_boards = new Boards($this->getCategory(), $this->getUserEntity());
|
||||
}
|
||||
return $this->_boards_library;
|
||||
return $this->_boards;
|
||||
}
|
||||
final public function getBoardLibrary(): BoardLibrary
|
||||
final public function getBoard(): Board
|
||||
{
|
||||
if ($this->_board_library === null) {
|
||||
$this->_board_library = new BoardLibrary(
|
||||
$this->getBoardsLibrary()->getEntity(),
|
||||
if ($this->_board === null) {
|
||||
$this->_board = new Board(
|
||||
$this->getBoards()->getEntity(),
|
||||
$this->getUserEntity()
|
||||
);
|
||||
}
|
||||
return $this->_board_library;
|
||||
return $this->_board;
|
||||
}
|
||||
final public function getFileLibrary(): FileLibrary
|
||||
final public function getFile(): File
|
||||
{
|
||||
if ($this->_file_library === null) {
|
||||
$this->_file_library = new FileLibrary(
|
||||
$this->getBoardsLibrary()->getEntity(),
|
||||
if ($this->_file === null) {
|
||||
$this->_file = new File(
|
||||
$this->getBoards()->getEntity(),
|
||||
$this->getUserEntity()
|
||||
);
|
||||
}
|
||||
return $this->_file_library;
|
||||
return $this->_file;
|
||||
}
|
||||
final public function getImageLibrary(): ImageLibrary
|
||||
final public function getImage(): Image
|
||||
{
|
||||
if ($this->_image_library === null) {
|
||||
$this->_image_library = new ImageLibrary();
|
||||
if ($this->_image === null) {
|
||||
$this->_image = new Image();
|
||||
}
|
||||
return $this->_image_library;
|
||||
return $this->_image;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries;
|
||||
namespace App\Libraries\MyStorage;
|
||||
|
||||
use App\Libraries\CommonLibrary;
|
||||
|
||||
abstract class MyStorageLibrary extends CommonLibrary
|
||||
abstract class MyStorage extends CommonLibrary
|
||||
{
|
||||
private $_originName = "";
|
||||
private $_originContent = "";
|
||||
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries;
|
||||
|
||||
use App\Libraries\CommonLibrary;
|
||||
|
||||
abstract class MyUtilLibrary extends CommonLibrary
|
||||
{
|
||||
protected function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user