소스 검색

获取头条类新闻模块-合集

15313670163 2 주 전
부모
커밋
266fb82413
1개의 변경된 파일31개의 추가작업 그리고 3개의 파일을 삭제
  1. 31 3
      app/JsonRpc/NewsService.php

+ 31 - 3
app/JsonRpc/NewsService.php

@@ -1132,6 +1132,7 @@ class NewsService implements NewsServiceInterface
                 $textArticles = []; 
                 // return Result::error("暂无此栏目",0); 
             }else{ 
+                $parent_alias = $category->aLIas_pinyin ? $category->aLIas_pinyin.'/' : null;
                 // return Result::success($website);
                 // 查询图片新闻 
                 // 合并查询条件
@@ -1162,7 +1163,7 @@ class NewsService implements NewsServiceInterface
                         'website_category.alias',
                         'website_category.aLIas_pinyin'
                     )
-                    ->selectRaw("CONCAT(?, aLIas_pinyin, '/') as aLIas_pinyin", [$pinyin])
+                    ->selectRaw("CONCAT(?, aLIas_pinyin) as aLIas_pinyin", [$parent_alias])
                     ->orderBy('article.updated_at', 'desc')
                     ->limit($parentTextNum)
                     ->get()
@@ -1184,7 +1185,7 @@ class NewsService implements NewsServiceInterface
                         'website_category.alias',
                         'website_category.aLIas_pinyin'
                     )
-                    ->selectRaw("CONCAT(?, aLIas_pinyin, '/') as aLIas_pinyin", [$pinyin])
+                    ->selectRaw("CONCAT(?, aLIas_pinyin ) as aLIas_pinyin", [$parent_alias])
                     ->orderBy('article.updated_at', 'desc')
                     ->where('imgurl', '!=', '')
                     ->limit($parentImgNum)
@@ -1209,7 +1210,34 @@ class NewsService implements NewsServiceInterface
         return Result::success($result); 
 
     }
-    
+     /**
+     *获取头条类新闻模块-合集
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteAllArticlett(array $data): array
+    {
+        $input['id'] = $data['id'];
+        $input['website_id'] = $data['website_id'];
+        $data = json_decode($input['id'], true);
+        // 使用 array_map 处理每个元素
+        $result = array_map(function ($item) use ($input) { 
+            list($parentCatId, $parentImgNum, $parentTextNum) = explode(',', $item['parent']);  
+            $website = [
+                'website_id' => $input['website_id'] 
+            ];
+            $category = WebsiteCategory::where('website_id', $input['website_id'])->pluck('category_id');
+            $category = array_values(array_unique($category->toArray()));
+            $placeid = isset($data['placeid']) && !empty($data['placeid']) ? $data['placeid'] - 1 : 0;
+            $where = [
+                'status' => 1,
+            ];
+
+            return $category;
+        }, $data); // 添加第二个参数 $data,确保 array_map 函数有两个参数
+           
+        return Result::success($result);
+    }
 
 
 }