From 8423908a5f80bc5e76cdc781111327dc58ae0da0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Fri, 13 Sep 2024 09:59:30 +0900 Subject: [PATCH] Automation init...3 --- app/Libraries/MyCrawler/YamapLibrary.php | 22 +++++++++++++++------- app/Models/CommonModel.php | 5 +++++ app/Models/Mangboard/BoardModel.php | 1 - 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/Libraries/MyCrawler/YamapLibrary.php b/app/Libraries/MyCrawler/YamapLibrary.php index b87b304..96d67ef 100644 --- a/app/Libraries/MyCrawler/YamapLibrary.php +++ b/app/Libraries/MyCrawler/YamapLibrary.php @@ -92,11 +92,17 @@ class YamapLibrary extends MyCrawlerLibrary } private function modifyBoard(BoardEntity $entity) { - $formDatas = [ - "image_path" => array_shift($this->_media_tags["image_path"]), - "content" => implode("\n", $this->_media_tags["content"]) - ]; - $this->getBoardModel()->modify($entity, $formDatas); + $image_path = array_shift($this->_media_tags["image_path"]); + if ($image_path === null) { + $this->getBoardModel()->delete([$this->getBoardModel()->getFieldPK() => $entity->getPK()]); + log_message("notice", __FUNCTION__ . " 내용이 없어서 삭제처리"); + } else { + $formDatas = [ + "image_path" => $image_path, + "content" => implode("\n", $this->_media_tags["content"]), + ]; + $this->getBoardModel()->modify($entity, $formDatas); + } log_message("notice", __FUNCTION__ . " 작업 완료"); } @@ -163,8 +169,10 @@ class YamapLibrary extends MyCrawlerLibrary __FUNCTION__, $content )); - $this->_media_tags["image_path"][] = sprintf("%s/%s", $this->getMyStorage()->getPath(), $this->getMyStorage()->getOriginName()); - $this->_media_tags["content"][] = $content; + if ($content === "") { + $this->_media_tags["image_path"][] = sprintf("%s/%s", $this->getMyStorage()->getPath(), $this->getMyStorage()->getOriginName()); + $this->_media_tags["content"][] = $content; + } return $myStorageLibrary; } diff --git a/app/Models/CommonModel.php b/app/Models/CommonModel.php index c749bb5..38e62ec 100644 --- a/app/Models/CommonModel.php +++ b/app/Models/CommonModel.php @@ -173,6 +173,11 @@ abstract class CommonModel extends Model case "content": $value = htmlentities($formDatas[$field], ENT_QUOTES); break; + case "updated_at": + case "created_at": + case "deleted_at": + $rules[$field] = "if_exist|valid_date"; + break; default: $value = $formDatas[$field]; break; diff --git a/app/Models/Mangboard/BoardModel.php b/app/Models/Mangboard/BoardModel.php index f520806..f42dd1a 100644 --- a/app/Models/Mangboard/BoardModel.php +++ b/app/Models/Mangboard/BoardModel.php @@ -143,7 +143,6 @@ class BoardModel extends CommonModel //입력후 PID값을 GID값에 넣어주기 위함 return $this->modify($entity, ['gid' => intval($entity->getPK())]); } - //modify용 public function modify(BoardEntity $entity, array $formDatas): BoardEntity {