ソースを参照

Merge branch '20251009_b_article_timeignore_fr'

FengR 3 ヶ月 前
コミット
5cfdf6187d
1 ファイル変更7 行追加2 行削除
  1. 7 2
      app/JsonRpc/WebsiteService.php

+ 7 - 2
app/JsonRpc/WebsiteService.php

@@ -3056,9 +3056,14 @@ class WebsiteService implements WebsiteServiceInterface
             ->leftJoin('website_category', 'article.catid', '=', 'website_category.category_id')
             // WebsiteCategory::query()->where($where)
             ->leftJoin('website', 'website.id', '=', 'website_category.website_id')
-            ->leftJoin('article_ignore', 'article.id', '=', 'article_ignore.article_id') // 左连接 article_ignore 表
+            ->leftJoinSub(function ($query) use ($data) {
+                $query->from('article_ignore')
+                ->where('article_ignore.article_id', $data['article_id']);
+                }, 'article_ignore', function ($join) {
+                $join->on('website_category.website_id', '=', 'article_ignore.website_id');
+                })
             ->select('website_category.*', 'website.website_name', DB::raw('IFNULL(article_ignore.c_show_time, "") as c_show_time')) // 选择需要的字段,不存在记录时 c_show_time 为空字符串
-            ->distinct()
+            ->distinct('website.website_name') // 使用DISTINCT关键字按website_name过滤重复数据
             ->get();
             // ->array_map(function ($item) {
             //     $item['c_show_time'] = json_decode($item['category_arr_id'], true);