Skip to content

Commit 1a90f3c

Browse files
committed
推荐接口优化
1 parent 4126454 commit 1a90f3c

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

src/Http/Controllers/Api/BlogController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ public function recommendArticles(Request $request)
287287
$articles = Cache::remember(self::CACHE_KEY_ARTICLE_RECOMMEND, $expiresAt, function () use ($validated, $fields) {
288288
return BlogArticle::query()
289289
->where('status', 1) // 只推荐已发布文章
290+
->where('category_id', '>', 0) // 只推荐有分类的文章
290291
->when($validated['seo_url_key'] ?? false, function ($q) use ($validated) {
291292
$q->where('seo_url_key', '!=', $validated['seo_url_key']); // 排除当前文章
292293
})->when($validated['type'] === 'popular', function ($q) {

0 commit comments

Comments
 (0)