Browse Source

Merge branch 'web_sannong_fr'

15313670163 3 weeks ago
parent
commit
33e84f0602
1 changed files with 48 additions and 0 deletions
  1. 48 0
      app/JsonRpc/NewsService.php

+ 48 - 0
app/JsonRpc/NewsService.php

@@ -1103,6 +1103,54 @@ class NewsService implements NewsServiceInterface
         return Result::success($data);
     }
 
+    
+    /**
+     * 模块新闻加强版 
+     * @param array $data
+     * @return array
+    */
+    public function getWebsiteCatidArticle(array $data): array
+    {
+        $where = [
+            // 'category.status' => 1,
+            'website_category.category_id' => $data['catid'],
+            'website_category.website_id' => $data['website_id'],
+            // 'article.status' => 1,
+        ];
+        // $category = WebsiteCategory::where($where);
+        if (!empty($data['img_num'])) {
+            $category['img'] = WebsiteCategory::where($where)
+                ->leftJoin('article', 'article.catid', 'website_category.category_id')
+                ->where('article.status', 1)
+                ->whereNotNull('article.imgurl')
+                ->select('article.*','website_category.category_id','website_category.alias')
+                ->orderBy('article.updated_at', 'desc')
+                ->limit($data['img_num'])
+                ->get();
+        }
+
+        if (!empty($data['text_num'])) {
+            $category['text'] = WebsiteCategory::where($where)
+                ->leftJoin('article', 'article.catid', 'website_category.category_id')
+                ->where('article.status', 1)
+                ->where(function ($query) {
+                    $query->whereNull('article.imgurl')
+                          ->orWhere('article.imgurl', '');
+                })
+                ->select('article.*','website_category.category_id','website_category.alias')
+                ->orderBy('article.updated_at', 'desc')
+                ->limit($data['text_num'])
+                ->get();
+        }
+
+        // $category = $category->get();
+      
+        if(empty($category)){
+            return Result::error("查询失败", 0);
+        }
+        return Result::success($category);
+    }
+
     /**
      * 验证导航名称是否重复
      * @return void