|
@@ -1181,6 +1181,7 @@ class NewsService implements NewsServiceInterface
|
|
|
$textArticles = [];
|
|
|
// return Result::error("暂无此栏目",0);
|
|
|
}else{
|
|
|
+ $child_category = WebsiteCategory::where('pid', $parentCatId)->where($website)->pluck('category_id')->toArray();
|
|
|
$parent_alias = $category->aLIas_pinyin ? $category->aLIas_pinyin.'/' : null;
|
|
|
// return Result::success($website);
|
|
|
// 查询图片新闻
|
|
@@ -1190,14 +1191,35 @@ class NewsService implements NewsServiceInterface
|
|
|
$subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($website['website_id']) . "') = 0");
|
|
|
})->orWhereNull("ignore_ids");
|
|
|
})
|
|
|
- ->whereRaw("JSON_CONTAINS(category_arr_id, '" . intval($parentCatId) . "')")
|
|
|
- ->leftJoin('website_category', 'website_category.category_id', 'article.catid')
|
|
|
->where('website_category.website_id', $website['website_id'])
|
|
|
- ->where('article.status', 1);
|
|
|
+ ->where('article.status', 1)
|
|
|
+ ->leftJoin('website_category', 'website_category.category_id', 'article.catid');
|
|
|
|
|
|
// 查询文字新闻
|
|
|
$textArticles = clone $baseQuery;
|
|
|
- $textArticles = $textArticles
|
|
|
+ $textArticles = $textArticles->whereIn('catid',$child_category)
|
|
|
+ ->select(
|
|
|
+ 'article.id',
|
|
|
+ 'article.title',
|
|
|
+ // 'article.imgurl',
|
|
|
+ 'article.author',
|
|
|
+ 'article.updated_at',
|
|
|
+ 'article.introduce',
|
|
|
+ 'article.islink',
|
|
|
+ 'article.linkurl',
|
|
|
+ 'article.copyfrom',
|
|
|
+ 'website_category.category_id',
|
|
|
+ 'website_category.alias',
|
|
|
+ 'website_category.aLIas_pinyin'
|
|
|
+ )
|
|
|
+ ->selectRaw("CONCAT(?, aLIas_pinyin) as aLIas_pinyin", [$parent_alias])
|
|
|
+ ->orderBy('article.updated_at', 'desc')
|
|
|
+ ->limit($parentTextNum)
|
|
|
+ ->get()
|
|
|
+ ->all();
|
|
|
+ if(empty($textArticles)){
|
|
|
+ $textArticles = clone $baseQuery;
|
|
|
+ $textArticles = $textArticles->where('catid',$parentCatId)
|
|
|
->select(
|
|
|
'article.id',
|
|
|
'article.title',
|
|
@@ -1217,33 +1239,54 @@ class NewsService implements NewsServiceInterface
|
|
|
->limit($parentTextNum)
|
|
|
->get()
|
|
|
->all();
|
|
|
+ }
|
|
|
// 查询图片新闻
|
|
|
$imgArticles = clone $baseQuery;
|
|
|
- $imgArticles = $imgArticles
|
|
|
+ $imgArticles = $imgArticles->where('imgurl', '!=', '')->whereIn('catid',$child_category)
|
|
|
+ ->select(
|
|
|
+ 'article.id',
|
|
|
+ 'article.title',
|
|
|
+ 'article.imgurl',
|
|
|
+ 'article.author',
|
|
|
+ 'article.updated_at',
|
|
|
+ 'article.introduce',
|
|
|
+ 'article.islink',
|
|
|
+ 'article.linkurl',
|
|
|
+ 'article.copyfrom',
|
|
|
+ 'website_category.category_id',
|
|
|
+ 'website_category.alias',
|
|
|
+ 'website_category.aLIas_pinyin'
|
|
|
+ )
|
|
|
+ ->selectRaw("CONCAT(?, aLIas_pinyin) as aLIas_pinyin", [$parent_alias])
|
|
|
+ ->orderBy('article.updated_at', 'desc')
|
|
|
+ ->limit($parentImgNum)
|
|
|
+ ->get()
|
|
|
+ ->all();
|
|
|
+ if(empty($imgArticles)){
|
|
|
+ $imgArticles = clone $baseQuery;
|
|
|
+ $imgArticles = $imgArticles->where('imgurl', '!=', '')->where('catid',$parentCatId)
|
|
|
->select(
|
|
|
- 'article.id',
|
|
|
- 'article.title',
|
|
|
- 'article.imgurl',
|
|
|
- 'article.author',
|
|
|
- 'article.updated_at',
|
|
|
- 'article.introduce',
|
|
|
- 'article.islink',
|
|
|
- 'article.linkurl',
|
|
|
- 'article.copyfrom',
|
|
|
- 'website_category.category_id',
|
|
|
- 'website_category.alias',
|
|
|
- 'website_category.aLIas_pinyin'
|
|
|
- )
|
|
|
- ->selectRaw("CONCAT(?, aLIas_pinyin ) as aLIas_pinyin", [$parent_alias])
|
|
|
- ->orderBy('article.updated_at', 'desc')
|
|
|
- ->where('imgurl', '!=', '')
|
|
|
- ->limit($parentImgNum)
|
|
|
- ->get()
|
|
|
- ->all();
|
|
|
-
|
|
|
+ 'article.id',
|
|
|
+ 'article.title',
|
|
|
+ 'article.imgurl',
|
|
|
+ 'article.author',
|
|
|
+ 'article.updated_at',
|
|
|
+ 'article.introduce',
|
|
|
+ 'article.islink',
|
|
|
+ 'article.linkurl',
|
|
|
+ 'article.copyfrom',
|
|
|
+ 'website_category.category_id',
|
|
|
+ 'website_category.alias',
|
|
|
+ 'website_category.aLIas_pinyin'
|
|
|
+ )
|
|
|
+ ->selectRaw("CONCAT(?, aLIas_pinyin) as aLIas_pinyin", [$parent_alias])
|
|
|
+ ->orderBy('article.updated_at', 'desc')
|
|
|
+ ->limit($parentImgNum)
|
|
|
+ ->get()
|
|
|
+ ->all();
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
-
|
|
|
$resultItem = [
|
|
|
'alias' => $category ? $category->alias : null,
|
|
|
'category_id' => $parentCatId,
|