From a07d041db7ce2f3600b472eb1b9599f5e1e38487 Mon Sep 17 00:00:00 2001 From: hellcat Date: Thu, 6 Aug 2026 21:38:53 +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 ac16401e..5302d925 100755 --- a/app/Http/Controllers/Api/v1/ArticlesController.php +++ b/app/Http/Controllers/Api/v1/ArticlesController.php @@ -134,19 +134,41 @@ public function receiveShadowrocketids(Request $oRequest) $oCategories = Categories::where("sSlug", "shadowrocketids")->first(); + $oArticle = Articles::where('sSlug', $sSlug)->first(); + + $aAttributes = [ + 'sThumb' => $sThumbPath, + 'iCategoryId' => $oCategories->id, + 'sTitle' => '「'.date("n月j日").'」'.$sTitle, + 'sTitleSub' => $sTitleSub, + 'sContent' => $sArticle, + 'iStatus' => 1, + 'iUserId' => 1, + ]; + + // 只有新创建时才写入初始点赞数 + if (!$oArticle) { + $aAttributes['i7like'] = $i7like; + } + $oArticle = Articles::updateOrCreate( - ['sSlug' => $sSlug], - [ - 'sThumb' => $sThumbPath, - 'iCategoryId' => $oCategories->id, - 'sTitle' => $sTitle, - 'sTitleSub' => $sTitleSub, - 'sContent' => $sArticle, - 'i7like' => $i7like, - 'iStatus' => 1, - 'iUserId' => 1, - ], - ); + ['sSlug' => $sSlug], + $aAttributes + ); + +// $oArticle = Articles::updateOrCreate( +// ['sSlug' => $sSlug], +// [ +// 'sThumb' => $sThumbPath, +// 'iCategoryId' => $oCategories->id, +// 'sTitle' => $sTitle, +// 'sTitleSub' => $sTitleSub, +// 'sContent' => $sArticle, +// 'i7like' => $i7like, +// 'iStatus' => 1, +// 'iUserId' => 1, +// ], +// ); (new TagService())->syncArticleTagsByName($oArticle, $aArticleTags);