|
@@ -879,4 +879,81 @@ class NewsService implements NewsServiceInterface
|
|
|
}
|
|
|
return Result::success($category);
|
|
|
}
|
|
|
+
|
|
|
+ * 模块新闻加强plus版
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getWebsiteAllArticle(array $data): array
|
|
|
+ {
|
|
|
+
|
|
|
+ $input['id'] = $data['id'];
|
|
|
+ $input['website_id'] = $data['website_id'];
|
|
|
+
|
|
|
+ $data = json_decode($input['id'], true);
|
|
|
+
|
|
|
+ $result = array_map(function ($item) use ($input) {
|
|
|
+ list($parentCatId, $parentImgNum, $parentTextNum) = explode(',', $item['parent']);
|
|
|
+ $website = [
|
|
|
+ 'website_id' => $input['website_id'],
|
|
|
+ ];
|
|
|
+
|
|
|
+ $category = WebsiteCategory::where('category_id', $parentCatId)->where($website)->first(['alias', 'category_id']);
|
|
|
+
|
|
|
+
|
|
|
+ $imgArticles = Article::where('catid', $parentCatId)
|
|
|
+ ->where('imgurl', '!=', '')
|
|
|
+
|
|
|
+ ->limit($parentImgNum)
|
|
|
+ ->get();
|
|
|
+
|
|
|
+
|
|
|
+ $textArticles = Article::where('catid', $parentCatId)
|
|
|
+
|
|
|
+ ->limit($parentTextNum)
|
|
|
+ ->get();
|
|
|
+
|
|
|
+ $resultItem = [
|
|
|
+ 'alias' => $category ? $category->alias : null,
|
|
|
+ 'category_id' => $parentCatId,
|
|
|
+ 'imgnum' => $imgArticles->toArray(),
|
|
|
+ 'textnum' => $textArticles->toArray()
|
|
|
+ ];
|
|
|
+
|
|
|
+ if (!empty($item['child']) && $item['child'] != "") {
|
|
|
+
|
|
|
+ $childCategory = WebsiteCategory::where('pid', $parentCatId)->where($website)->first();
|
|
|
+ if ($childCategory) {
|
|
|
+ list($childCatId, $childImgNum, $childTextNum) = explode(',', $item['child']);
|
|
|
+
|
|
|
+
|
|
|
+ $childCategoryInfo = WebsiteCategory::where('category_id', $childCatId)->where($website)->first(['alias', 'category_id']);
|
|
|
+
|
|
|
+
|
|
|
+ $childImgArticles = Article::where('catid', $childCatId)
|
|
|
+ ->where('imgurl', '!=', '')
|
|
|
+
|
|
|
+ ->limit($childImgNum)
|
|
|
+ ->get();
|
|
|
+
|
|
|
+
|
|
|
+ $childTextArticles = Article::where('catid', $childCatId)
|
|
|
+
|
|
|
+ ->limit($childTextNum)
|
|
|
+ ->get();
|
|
|
+
|
|
|
+ $resultItem['child'] = [
|
|
|
+ 'alias' => $childCategoryInfo ? $childCategoryInfo->alias : null,
|
|
|
+ 'category_id' => $childCatId,
|
|
|
+ 'imgnum' => $childImgArticles->toArray(),
|
|
|
+ 'textnum' => $childTextArticles->toArray()
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $resultItem;
|
|
|
+ }, $data);
|
|
|
+ return Result::success($result);
|
|
|
+
|
|
|
+ }
|
|
|
}
|