From 4433192604a3a4ec2f15ab65f7edcdeeef00c636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Mon, 16 Sep 2024 14:13:10 +0900 Subject: [PATCH] Automation init...3 --- .../Mangboard/CrawlerController.php | 15 +++--- .../Mangboard/{BoardLibrary.php => Board.php} | 2 +- .../{BoardsLibrary.php => Boards.php} | 2 +- .../Mangboard/{FileLibrary.php => File.php} | 2 +- .../Mangboard/{ImageLibrary.php => Image.php} | 2 +- .../Mangboard/{UserLibrary.php => User.php} | 2 +- app/Libraries/MyAuth/GoogleAuth.php | 3 +- app/Libraries/MyAuth/LocalAuth.php | 3 +- .../{MyAuthLibrary.php => MyAuth/MyAuth.php} | 4 +- .../MyCrawler.php} | 4 +- app/Libraries/MyCrawler/YamapCrawler.php | 10 ++-- app/Libraries/MyCrawler/YamoonCrawler.php | 11 ++-- .../MySocket.php} | 4 +- app/Libraries/MySocket/WebSocket.php | 3 +- app/Libraries/MyStorage/FileStorage.php | 3 +- app/Libraries/MyStorage/MangboardStorage.php | 52 +++++++++---------- .../MyStorage.php} | 4 +- app/Libraries/MyUtilLibrary.php | 13 ----- 18 files changed, 61 insertions(+), 78 deletions(-) rename app/Libraries/Mangboard/{BoardLibrary.php => Board.php} (98%) rename app/Libraries/Mangboard/{BoardsLibrary.php => Boards.php} (96%) rename app/Libraries/Mangboard/{FileLibrary.php => File.php} (98%) rename app/Libraries/Mangboard/{ImageLibrary.php => Image.php} (98%) rename app/Libraries/Mangboard/{UserLibrary.php => User.php} (97%) rename app/Libraries/{MyAuthLibrary.php => MyAuth/MyAuth.php} (95%) rename app/Libraries/{MyCrawlerLibrary.php => MyCrawler/MyCrawler.php} (98%) rename app/Libraries/{MySocketLibrary.php => MySocket/MySocket.php} (80%) rename app/Libraries/{MyStorageLibrary.php => MyStorage/MyStorage.php} (93%) delete mode 100644 app/Libraries/MyUtilLibrary.php diff --git a/app/Controllers/Mangboard/CrawlerController.php b/app/Controllers/Mangboard/CrawlerController.php index b5f8bae..136cb5e 100644 --- a/app/Controllers/Mangboard/CrawlerController.php +++ b/app/Controllers/Mangboard/CrawlerController.php @@ -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); diff --git a/app/Libraries/Mangboard/BoardLibrary.php b/app/Libraries/Mangboard/Board.php similarity index 98% rename from app/Libraries/Mangboard/BoardLibrary.php rename to app/Libraries/Mangboard/Board.php index 02619e7..c85f6fc 100644 --- a/app/Libraries/Mangboard/BoardLibrary.php +++ b/app/Libraries/Mangboard/Board.php @@ -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; diff --git a/app/Libraries/Mangboard/BoardsLibrary.php b/app/Libraries/Mangboard/Boards.php similarity index 96% rename from app/Libraries/Mangboard/BoardsLibrary.php rename to app/Libraries/Mangboard/Boards.php index f3675d7..73161b4 100644 --- a/app/Libraries/Mangboard/BoardsLibrary.php +++ b/app/Libraries/Mangboard/Boards.php @@ -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; diff --git a/app/Libraries/Mangboard/FileLibrary.php b/app/Libraries/Mangboard/File.php similarity index 98% rename from app/Libraries/Mangboard/FileLibrary.php rename to app/Libraries/Mangboard/File.php index 9d5ce53..484f603 100644 --- a/app/Libraries/Mangboard/FileLibrary.php +++ b/app/Libraries/Mangboard/File.php @@ -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; diff --git a/app/Libraries/Mangboard/ImageLibrary.php b/app/Libraries/Mangboard/Image.php similarity index 98% rename from app/Libraries/Mangboard/ImageLibrary.php rename to app/Libraries/Mangboard/Image.php index 85e2fed..d8dd40f 100644 --- a/app/Libraries/Mangboard/ImageLibrary.php +++ b/app/Libraries/Mangboard/Image.php @@ -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() diff --git a/app/Libraries/Mangboard/UserLibrary.php b/app/Libraries/Mangboard/User.php similarity index 97% rename from app/Libraries/Mangboard/UserLibrary.php rename to app/Libraries/Mangboard/User.php index 60442bf..e31d2f8 100644 --- a/app/Libraries/Mangboard/UserLibrary.php +++ b/app/Libraries/Mangboard/User.php @@ -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() diff --git a/app/Libraries/MyAuth/GoogleAuth.php b/app/Libraries/MyAuth/GoogleAuth.php index 4db5e04..aa8a585 100644 --- a/app/Libraries/MyAuth/GoogleAuth.php +++ b/app/Libraries/MyAuth/GoogleAuth.php @@ -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"; diff --git a/app/Libraries/MyAuth/LocalAuth.php b/app/Libraries/MyAuth/LocalAuth.php index 361b407..19e6b86 100644 --- a/app/Libraries/MyAuth/LocalAuth.php +++ b/app/Libraries/MyAuth/LocalAuth.php @@ -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() { diff --git a/app/Libraries/MyAuthLibrary.php b/app/Libraries/MyAuth/MyAuth.php similarity index 95% rename from app/Libraries/MyAuthLibrary.php rename to app/Libraries/MyAuth/MyAuth.php index e5646c5..7e5b302 100644 --- a/app/Libraries/MyAuthLibrary.php +++ b/app/Libraries/MyAuth/MyAuth.php @@ -1,13 +1,13 @@ 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) { diff --git a/app/Libraries/MyCrawler/YamoonCrawler.php b/app/Libraries/MyCrawler/YamoonCrawler.php index fe7890e..4c0eb98 100644 --- a/app/Libraries/MyCrawler/YamoonCrawler.php +++ b/app/Libraries/MyCrawler/YamoonCrawler.php @@ -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) { diff --git a/app/Libraries/MySocketLibrary.php b/app/Libraries/MySocket/MySocket.php similarity index 80% rename from app/Libraries/MySocketLibrary.php rename to app/Libraries/MySocket/MySocket.php index 3236af0..18135a5 100644 --- a/app/Libraries/MySocketLibrary.php +++ b/app/Libraries/MySocket/MySocket.php @@ -1,10 +1,10 @@ _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; } } diff --git a/app/Libraries/MyStorageLibrary.php b/app/Libraries/MyStorage/MyStorage.php similarity index 93% rename from app/Libraries/MyStorageLibrary.php rename to app/Libraries/MyStorage/MyStorage.php index 06f46e9..5e25bfb 100644 --- a/app/Libraries/MyStorageLibrary.php +++ b/app/Libraries/MyStorage/MyStorage.php @@ -1,10 +1,10 @@