diff --git a/app/Services/TG/Hook/Mod/Article.php b/app/Services/TG/Hook/Mod/Article.php index e8eadb3..8c38249 100644 --- a/app/Services/TG/Hook/Mod/Article.php +++ b/app/Services/TG/Hook/Mod/Article.php @@ -15,14 +15,12 @@ class Article extends Base { $aArticleList = ModelArticle::orderBy($sOrderBy)->get()->toArray(); -// $aTmp = []; $str = ""; foreach ($aArticleList as &$row) { // 使用引用来修改原数组 unset($row['updated_at']); // 移除 updated_at 字段 unset($row['created_at']); // 移除 created_at 字段 // $aTmp[] = $this->toJson($row); // $this->oTGHttp->sendToTG(json_encode($row, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); - $str .= "\n"; $str .= $this->toJson($row); $str .= "\n"; @@ -124,7 +122,13 @@ class Article extends Base { } - public function Json($aParam) + public function JsonAdd($aParam) { + + return $this->JsonSet($aParam, "add"); + + } + + public function JsonSet($aParam, $sType = "set") { $iId = $aParam["aOption"][1] ?? false; $sJson = $aParam["aArg"] ?? false; @@ -137,10 +141,17 @@ class Article extends Base { return "需要json"; } - $oArticle = ModelArticle::find($iId); - - if (!$oArticle) { - return "没到到这个"; + if ($sType == "add") { + + $oArticle = new ModelArticle(); + + } else { + + $oArticle = ModelArticle::find($iId); + if (!$oArticle) { + return "没到到这个"; + } + } $sJson = implode(" ", $sJson); @@ -155,9 +166,6 @@ class Article extends Base { $aParam["aArg"][1] = $oArticle->id; return $this->Find($aParam); - -// return $this->toJson($oArticle); - } // /ArticleSet__id__user_name xxx