From 58019f8d957c111a055d3cd5c68c8622ff75eafb Mon Sep 17 00:00:00 2001 From: hellcat Date: Wed, 5 Aug 2026 19:39:22 +0800 Subject: [PATCH] no message --- .../Controllers/Api/v1/ArticlesController.php | 46 ++++++++++++++----- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/Api/v1/ArticlesController.php b/app/Http/Controllers/Api/v1/ArticlesController.php index f37e7a67..ac16401e 100755 --- a/app/Http/Controllers/Api/v1/ArticlesController.php +++ b/app/Http/Controllers/Api/v1/ArticlesController.php @@ -197,19 +197,41 @@ public function receiveFreenode(Request $oRequest) $oCategories = Categories::where("sSlug", "freenode")->first(); + $oArticle = Articles::where('sSlug', $sSlug)->first(); + + $aAttributes = [ + 'sThumb' => $sThumbPath, + 'iCategoryId' => $oCategories->id, + 'sTitle' => $sArticleTitle, + 'sTitleSub' => $sArticleTitleSub, + 'sContent' => $sArticleContent, + 'iStatus' => 1, + 'iUserId' => 1, + ]; + + // 只有新创建时才写入初始点赞数 + if (!$oArticle) { + $aAttributes['i7like'] = $i7like; + } + $oArticle = Articles::updateOrCreate( - ['sSlug' => $sSlug], - [ - 'sThumb' => $sThumbPath, - 'iCategoryId' => $oCategories->id, - 'sTitle' => $sArticleTitle, - 'sTitleSub' => $sArticleTitleSub, - 'sContent' => $sArticleContent, - 'i7like' => $i7like, - 'iStatus' => 1, - 'iUserId' => 1, - ], - ); + ['sSlug' => $sSlug], + $aAttributes + ); + +// $oArticle = Articles::updateOrCreate( +// ['sSlug' => $sSlug], +// [ +// 'sThumb' => $sThumbPath, +// 'iCategoryId' => $oCategories->id, +// 'sTitle' => $sArticleTitle, +// 'sTitleSub' => $sArticleTitleSub, +// 'sContent' => $sArticleContent, +// 'i7like' => $i7like, +// 'iStatus' => 1, +// 'iUserId' => 1, +// ], +// ); // 我希望,如果数据已经有了,i7like就不再更新 (new TagService())->syncArticleTagsByName($oArticle, $aArticleTags);