فهرست منبع

新增接口:添加资讯、修改资讯的接口

FengR 1 روز پیش
والد
کامیت
e8a60070bc
1فایلهای تغییر یافته به همراه27 افزوده شده و 12 حذف شده
  1. 27 12
      app/JsonRpc/NewsService.php

+ 27 - 12
app/JsonRpc/NewsService.php

@@ -85,6 +85,7 @@ use App\Model\ResearchTopic;
 use App\Model\RetopicUser;
 use App\Model\WebCateinfo;
 use App\Model\SinglePage;
+use App\Model\WebsiteColumn;
 #[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class NewsService implements NewsServiceInterface
 {
@@ -649,12 +650,19 @@ class NewsService implements NewsServiceInterface
         if (!isset($data['catid'])) {
           throw new \Exception('缺少必要字段:catid');
         }
+        $column_arr = WebsiteColumn::where('column_name','官网')->pluck('id')->toArray();
         // 查找网站,若是核心站则返回字段is_core=1,否则返回is_core=0,若是不存在此网站则为is_core=2
         $web = WebsiteCategory::where('category_id', $data['catid'])
           ->leftJoin('website', 'website_category.website_id', '=', 'website.id')
           ->select(
             'website_id',
-            Db::raw('CASE WHEN website.id IS NULL THEN 2 WHEN JSON_CONTAINS(website.`website_column_arr_id`, \'3\') THEN 1 ELSE 0 END as is_core')
+            DB::raw('            
+                CASE 
+                    WHEN website.id IS NULL THEN 2 
+                    WHEN website.website_column_id IN ('.implode(',', $column_arr).') THEN 1 
+                    ELSE 0 
+                END as is_core
+            ')
           )
           ->get();
         // $id = 225;   -----测试开启
@@ -1132,14 +1140,21 @@ class NewsService implements NewsServiceInterface
     // 若是审核通过  则更新c_show_time
     if ($data['status'] == 1) {
       // 查找网站,若是核心站则返回字段is_core=1,否则返回is_core=0,若是不存在此网站则为is_core=2
-      $web = Article::where('article.id', $data['id'])
-        ->leftJoin('website_category', 'article.catid', 'website_category.category_id')
-        ->leftJoin('website', 'website_category.website_id', '=', 'website.id')
-        ->select(
-          'website_id',
-          Db::raw('CASE WHEN website.id IS NULL THEN 2 WHEN JSON_CONTAINS(website.`website_column_arr_id`, \'3\') THEN 1 ELSE 0 END as is_core')
-        )
-        ->get();
+    $column_arr = WebsiteColumn::where('column_name','官网')->pluck('id')->toArray();
+    // 查找网站,若是核心站则返回字段is_core=1,否则返回is_core=0,若是不存在此网站则为is_core=2
+    $web = WebsiteCategory::where('category_id', $data['catid'])
+      ->leftJoin('website', 'website_category.website_id', '=', 'website.id')
+      ->select(
+        'website_id',
+        DB::raw('            
+            CASE 
+                WHEN website.id IS NULL THEN 2 
+                WHEN website.website_column_id IN ('.implode(',', $column_arr).') THEN 1 
+                ELSE 0 
+            END as is_core
+        ')
+      )
+      ->get();
       // 非核心站与核心站----显示时间-----间隔
       $time = 20;
       // 若不是采集来的文章,则非核心站之间的间隔时间为5分钟;初始时间与当前时间差二十分钟
@@ -9807,9 +9822,9 @@ class NewsService implements NewsServiceInterface
     ->when(!empty($where), function ($query) use ($where) {
         $query->where($where);
     })
-    ->when(!empty($data['catid']), function ($query) use ($data) {
-        $query->where('catid', $data['catid']);
-    })
+    // ->when(!isset($data['catid']), function ($query) use ($data) {
+    //     $query->where('catid', $data['catid']);
+    // })
     ->where('status', 1)
     ->select(['id', 'title', 'catid','status','website_id','updated_at'])
     ->orderBy('updated_at', 'desc')