Automation init...3

This commit is contained in:
최준흠 2024-09-16 14:13:10 +09:00
parent 7a0e6405c5
commit 4433192604
18 changed files with 61 additions and 78 deletions

View File

@ -3,17 +3,20 @@
namespace App\Controllers\Mangboard; namespace App\Controllers\Mangboard;
use App\Controllers\CommonController; use App\Controllers\CommonController;
use App\Libraries\Mangboard\UserLibrary; use App\Libraries\Mangboard\User;
use App\Entities\Mangboard\UserEntity; use App\Entities\Mangboard\UserEntity;
use App\Libraries\MyCrawler\YamapCrawler; use App\Libraries\MyCrawler\YamapCrawler;
use App\Libraries\MyCrawler\YamoonCrawler; use App\Libraries\MyCrawler\YamoonCrawler;
class CrawlerController extends CommonController class CrawlerController extends CommonController
{ {
private function login_process(string $id, string $password): UserEntity private $_user = null;
private function getUser()
{ {
$user_library = new UserLibrary(); if ($this->_user === null) {
return $user_library->login(getenv("mangboard.host.url"), $id, $password); $this->_user = new User();
}
return $this->_user;
} }
public function yamap(string $category, string $id = "", string $debug = "false"): string 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; $id = $id == "" ? getenv("mangboard.login.default.id") : $id;
$password = getenv("mangboard.login.default.password"); $password = getenv("mangboard.login.default.password");
//1. 사이트 로그인 처리 //1. 사이트 로그인 처리
$user_entity = $this->login_process($id, $password); $user_entity = $this->getUser()->login(getenv("mangboard.host.url"), $id, $password);
//2. 필요한 로그인한 사용자정보,Socket,Storage 정의후 Crawler에게 전달. //2. 필요한 로그인한 사용자정보,Socket,Storage 정의후 Crawler에게 전달.
$crawler = new YamapCrawler(getenv('yamap.host.url'), $category, $user_entity); $crawler = new YamapCrawler(getenv('yamap.host.url'), $category, $user_entity);
$crawler->setDebug($debug === "true" ? true : false); $crawler->setDebug($debug === "true" ? true : false);
@ -38,7 +41,7 @@ class CrawlerController extends CommonController
$id = $id == "" ? getenv("mangboard.login.default.id") : $id; $id = $id == "" ? getenv("mangboard.login.default.id") : $id;
$password = getenv("mangboard.login.default.password"); $password = getenv("mangboard.login.default.password");
//1. 사이트 로그인 처리 //1. 사이트 로그인 처리
$user_entity = $this->login_process($id, $password); $user_entity = $this->getUser()->login(getenv("mangboard.host.url"), $id, $password);
//2. 필요한 로그인한 사용자정보,Socket,Storage 정의후 Crawler에게 전달. //2. 필요한 로그인한 사용자정보,Socket,Storage 정의후 Crawler에게 전달.
$crawler = new YamoonCrawler(getenv("yamoon.host.url"), $category, $user_entity); $crawler = new YamoonCrawler(getenv("yamoon.host.url"), $category, $user_entity);
$crawler->setDebug($debug === "true" ? true : false); $crawler->setDebug($debug === "true" ? true : false);

View File

@ -8,7 +8,7 @@ use App\Entities\Mangboard\UserEntity;
use App\Entities\Mangboard\BoardsEntity; use App\Entities\Mangboard\BoardsEntity;
use App\Entities\Mangboard\BoardEntity; use App\Entities\Mangboard\BoardEntity;
class BoardLibrary extends CommonLibrary class Board extends CommonLibrary
{ {
private $_model = null; private $_model = null;
private $_boards_entity = null; private $_boards_entity = null;

View File

@ -7,7 +7,7 @@ use App\Models\Mangboard\BoardsModel;
use App\Entities\Mangboard\UserEntity; use App\Entities\Mangboard\UserEntity;
use App\Entities\Mangboard\BoardsEntity; use App\Entities\Mangboard\BoardsEntity;
class BoardsLibrary extends CommonLibrary class Boards extends CommonLibrary
{ {
private $_model = null; private $_model = null;
private $_entity = null; private $_entity = null;

View File

@ -10,7 +10,7 @@ use App\Entities\Mangboard\FileEntity;
use App\Entities\Mangboard\BoardsEntity; use App\Entities\Mangboard\BoardsEntity;
use App\Entities\Mangboard\BoardEntity; use App\Entities\Mangboard\BoardEntity;
class FileLibrary extends CommonLibrary class File extends CommonLibrary
{ {
private $_model = null; private $_model = null;
private $_boards_entity = null; private $_boards_entity = null;

View File

@ -8,7 +8,7 @@ use App\Libraries\MyStorage\MangboardStorage;
use App\Libraries\CommonLibrary; use App\Libraries\CommonLibrary;
use App\Entities\Mangboard\BoardEntity; use App\Entities\Mangboard\BoardEntity;
class ImageLibrary extends CommonLibrary class Image extends CommonLibrary
{ {
use FileTrait, ImageTrait; use FileTrait, ImageTrait;
public function __construct() public function __construct()

View File

@ -6,7 +6,7 @@ use App\Models\Mangboard\UserModel;
use App\Entities\Mangboard\UserEntity; use App\Entities\Mangboard\UserEntity;
use App\Libraries\CommonLibrary; use App\Libraries\CommonLibrary;
class UserLibrary extends CommonLibrary class User extends CommonLibrary
{ {
private $_user_model = null; private $_user_model = null;
public function __construct() public function __construct()

View File

@ -3,11 +3,10 @@
namespace App\Libraries\MyAuth; namespace App\Libraries\MyAuth;
use App\Libraries\MySocket\Web\GoogleSocket; use App\Libraries\MySocket\Web\GoogleSocket;
use App\Libraries\MyAuthLibrary;
use App\Entities\UserEntity; use App\Entities\UserEntity;
use App\Entities\SNSUserEntity; use App\Entities\SNSUserEntity;
class GoogleAuth extends MyAuthLibrary class GoogleAuth extends MyAuth
{ {
private $_mySocket = null; private $_mySocket = null;
private $_site = "GOOGLE"; private $_site = "GOOGLE";

View File

@ -2,10 +2,9 @@
namespace App\Libraries\MyAuth; namespace App\Libraries\MyAuth;
use App\Libraries\MyAuthLibrary;
use App\Entities\UserEntity; use App\Entities\UserEntity;
class LocalAuth extends MyAuthLibrary class LocalAuth extends MyAuth
{ {
public function __construct() public function __construct()
{ {

View File

@ -1,13 +1,13 @@
<?php <?php
namespace App\Libraries; namespace App\Libraries\MyAuth;
use App\Entities\UserEntity; use App\Entities\UserEntity;
use App\Models\UserModel; use App\Models\UserModel;
use App\Models\SNSUserModel; use App\Models\SNSUserModel;
// 참고:https://github.com/SyntaxPhoenix/iloclient // 참고:https://github.com/SyntaxPhoenix/iloclient
abstract class MyAuthLibrary abstract class MyAuth
{ {
private $_userModel = null; private $_userModel = null;
private $_snsUserModel = null; private $_snsUserModel = null;

View File

@ -1,12 +1,12 @@
<?php <?php
namespace App\Libraries; namespace App\Libraries\MyCrawler;
use App\Libraries\CommonLibrary; use App\Libraries\CommonLibrary;
use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\DomCrawler\Crawler;
use App\Traits\FileTrait; use App\Traits\FileTrait;
abstract class MyCrawlerLibrary extends CommonLibrary abstract class MyCrawler extends CommonLibrary
{ {
use FileTrait; use FileTrait;
private $_mySocket = null; private $_mySocket = null;

View File

@ -2,14 +2,12 @@
namespace App\Libraries\MyCrawler; namespace App\Libraries\MyCrawler;
use App\Libraries\MyCrawlerLibrary;
use App\Libraries\MySocket\WebSocket; use App\Libraries\MySocket\WebSocket;
use App\Libraries\MyStorage\MangboardStorage; use App\Libraries\MyStorage\MangboardStorage;
use App\Entities\Mangboard\UserEntity; use App\Entities\Mangboard\UserEntity;
use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\DomCrawler\Crawler;
class YamapCrawler extends MyCrawlerLibrary class YamapCrawler extends MyCrawler
{ {
private $_category = ""; private $_category = "";
private $_user_entity = null; private $_user_entity = null;
@ -119,9 +117,9 @@ class YamapCrawler extends MyCrawlerLibrary
list($listInfo, $urls) = $this->detailPage($listInfo); list($listInfo, $urls) = $this->detailPage($listInfo);
$this->mediaProcess($urls); $this->mediaProcess($urls);
//File DB 및 Board DB 등록작업 //File DB 및 Board DB 등록작업
$board_entity = $this->getMyStorage()->getBoardLibrary()->createByCrawler($i, $listInfo, $this->_storages); $board_entity = $this->getMyStorage()->getBoard()->createByCrawler($i, $listInfo, $this->_storages);
$this->getMyStorage()->getFileLibrary()->createByCrawler($board_entity, $this->_storages); $this->getMyStorage()->getFile()->createByCrawler($board_entity, $this->_storages);
$this->getMyStorage()->getImageLibrary()->createByCrawler($board_entity, $this->_storages); $this->getMyStorage()->getImage()->createByCrawler($board_entity, $this->_storages);
log_message("notice", "게시물 {$i}번째/{$total}개중 {$listInfo["nickname"]} 작업완료."); log_message("notice", "게시물 {$i}번째/{$total}개중 {$listInfo["nickname"]} 작업완료.");
$i++; $i++;
} catch (\Exception $e) { } catch (\Exception $e) {

View File

@ -2,13 +2,12 @@
namespace App\Libraries\MyCrawler; namespace App\Libraries\MyCrawler;
use App\Entities\Mangboard\UserEntity;
use App\Libraries\MyCrawlerLibrary;
use App\Libraries\MySocket\WebSocket; use App\Libraries\MySocket\WebSocket;
use App\Libraries\MyStorage\MangboardStorage; use App\Libraries\MyStorage\MangboardStorage;
use App\Entities\Mangboard\UserEntity;
use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\DomCrawler\Crawler;
class YamoonCrawler extends MyCrawlerLibrary class YamoonCrawler extends MyCrawler
{ {
private $_category = ""; private $_category = "";
private $_user_entity = null; private $_user_entity = null;
@ -96,9 +95,9 @@ class YamoonCrawler extends MyCrawlerLibrary
list($listInfo, $urls) = $this->detailPage($listInfo); list($listInfo, $urls) = $this->detailPage($listInfo);
$this->mediaProcess($urls); $this->mediaProcess($urls);
//File DB 및 Board DB 등록작업 //File DB 및 Board DB 등록작업
$board_entity = $this->getMyStorage()->getBoardLibrary()->createByCrawler($i, $listInfo, $this->_storages); $board_entity = $this->getMyStorage()->getBoard()->createByCrawler($i, $listInfo, $this->_storages);
$this->getMyStorage()->getFileLibrary()->createByCrawler($board_entity, $this->_storages); $this->getMyStorage()->getFile()->createByCrawler($board_entity, $this->_storages);
$this->getMyStorage()->getImageLibrary()->createByCrawler($board_entity, $this->_storages); $this->getMyStorage()->getImage()->createByCrawler($board_entity, $this->_storages);
log_message("notice", "게시물 {$i}번째/{$total}개중 {$listInfo["nickname"]} 작업완료."); log_message("notice", "게시물 {$i}번째/{$total}개중 {$listInfo["nickname"]} 작업완료.");
$i++; $i++;
} catch (\Exception $e) { } catch (\Exception $e) {

View File

@ -1,10 +1,10 @@
<?php <?php
namespace App\Libraries; namespace App\Libraries\MySocket;
use App\Libraries\CommonLibrary; use App\Libraries\CommonLibrary;
abstract class MySocketLibrary extends CommonLibrary abstract class MySocket extends CommonLibrary
{ {
private $_host = null; private $_host = null;
protected function __construct(string $host) protected function __construct(string $host)

View File

@ -4,9 +4,8 @@ namespace App\Libraries\MySocket;
use GuzzleHttp\Cookie\CookieJar; use GuzzleHttp\Cookie\CookieJar;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use App\Libraries\MySocketLibrary;
class WebSocket extends MySocketLibrary class WebSocket extends MySocket
{ {
private $_client = null; private $_client = null;
private $_cookieJar = null; private $_cookieJar = null;

View File

@ -2,10 +2,9 @@
namespace App\Libraries\MyStorage; namespace App\Libraries\MyStorage;
use App\Libraries\MyStorageLibrary;
use App\Traits\FileTrait; use App\Traits\FileTrait;
class FileStorage extends MyStorageLibrary class FileStorage extends MyStorage
{ {
use FileTrait; use FileTrait;
private $_path = ""; private $_path = "";

View File

@ -3,17 +3,17 @@
namespace App\Libraries\MyStorage; namespace App\Libraries\MyStorage;
use App\Entities\Mangboard\UserEntity; use App\Entities\Mangboard\UserEntity;
use App\Libraries\Mangboard\BoardLibrary; use App\Libraries\Mangboard\Board;
use App\Libraries\Mangboard\BoardsLibrary; use App\Libraries\Mangboard\Boards;
use App\Libraries\Mangboard\FileLibrary; use App\Libraries\Mangboard\File;
use App\Libraries\Mangboard\ImageLibrary; use App\Libraries\Mangboard\Image;
class MangboardStorage extends FileStorage class MangboardStorage extends FileStorage
{ {
private $_boards_library = null; private $_boards = null;
private $_board_library = null; private $_board = null;
private $_file_library = null; private $_file = null;
private $_image_library = null; private $_image = null;
private $_category = ""; private $_category = "";
private $_user_entity = null; private $_user_entity = null;
public function __construct(string $category, UserEntity $user_entity) public function __construct(string $category, UserEntity $user_entity)
@ -83,38 +83,38 @@ class MangboardStorage extends FileStorage
return $content; return $content;
} }
private function getBoardsLibrary(): BoardsLibrary private function getBoards(): Boards
{ {
if ($this->_boards_library === null) { if ($this->_boards === null) {
$this->_boards_library = new BoardsLibrary($this->getCategory(), $this->getUserEntity()); $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) { if ($this->_board === null) {
$this->_board_library = new BoardLibrary( $this->_board = new Board(
$this->getBoardsLibrary()->getEntity(), $this->getBoards()->getEntity(),
$this->getUserEntity() $this->getUserEntity()
); );
} }
return $this->_board_library; return $this->_board;
} }
final public function getFileLibrary(): FileLibrary final public function getFile(): File
{ {
if ($this->_file_library === null) { if ($this->_file === null) {
$this->_file_library = new FileLibrary( $this->_file = new File(
$this->getBoardsLibrary()->getEntity(), $this->getBoards()->getEntity(),
$this->getUserEntity() $this->getUserEntity()
); );
} }
return $this->_file_library; return $this->_file;
} }
final public function getImageLibrary(): ImageLibrary final public function getImage(): Image
{ {
if ($this->_image_library === null) { if ($this->_image === null) {
$this->_image_library = new ImageLibrary(); $this->_image = new Image();
} }
return $this->_image_library; return $this->_image;
} }
} }

View File

@ -1,10 +1,10 @@
<?php <?php
namespace App\Libraries; namespace App\Libraries\MyStorage;
use App\Libraries\CommonLibrary; use App\Libraries\CommonLibrary;
abstract class MyStorageLibrary extends CommonLibrary abstract class MyStorage extends CommonLibrary
{ {
private $_originName = ""; private $_originName = "";
private $_originContent = ""; private $_originContent = "";

View File

@ -1,13 +0,0 @@
<?php
namespace App\Libraries;
use App\Libraries\CommonLibrary;
abstract class MyUtilLibrary extends CommonLibrary
{
protected function __construct()
{
parent::__construct();
}
}