|
@@ -821,6 +821,7 @@ class NewsService implements NewsServiceInterface
|
|
|
*/
|
|
|
public function getWebsiteArticleList(array $data): array
|
|
|
{
|
|
|
+ // return Result::success($data);
|
|
|
$where[] = ['status', '=', 1];
|
|
|
if (isset($data['keyword']) && !empty($data['keyword'])) {
|
|
|
array_push($where, ['article.title', 'like', '%' . $data['keyword'] . '%']);
|
|
@@ -847,14 +848,38 @@ class NewsService implements NewsServiceInterface
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
- ->where(function ($query) use ($data) {
|
|
|
- $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
|
|
|
- ->orWhereNull("ignore_ids");
|
|
|
- })
|
|
|
- ->orderBy("updated_at", "desc")
|
|
|
- ->limit($data['pageSize'])
|
|
|
- ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
- ->get();
|
|
|
+ ->where(function ($query) use ($data) {
|
|
|
+ $query->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($data['website_id'])."') = 0")
|
|
|
+ ->orWhereNull("ignore_ids");
|
|
|
+ })
|
|
|
+ ->select(
|
|
|
+ 'article.id',
|
|
|
+ 'article.title',
|
|
|
+ 'article.imgurl',
|
|
|
+ 'article.author',
|
|
|
+ 'article.updated_at',
|
|
|
+ 'article.introduce',
|
|
|
+ 'article.islink',
|
|
|
+ 'article.linkurl',
|
|
|
+ 'article.copyfrom',
|
|
|
+ 'article.catid')
|
|
|
+ ->orderBy("updated_at", "desc")
|
|
|
+ ->limit($data['pageSize'])
|
|
|
+ ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
+ ->get()
|
|
|
+ // ;
|
|
|
+ ->map(function ($article ) use ($data) {
|
|
|
+ $catid = $article->catid ?? 0;
|
|
|
+ $pinyin = '';
|
|
|
+ $category = WebsiteCategory::where('category_id', $catid)->where('website_category.website_id', $data['website_id'])->first();
|
|
|
+ $pinyin = $category->aLIas_pinyin ? $category->aLIas_pinyin : null;
|
|
|
+ if ($category->pid != 0 && !empty($category->aLIas_pinyin)) {
|
|
|
+ $childCategory = WebsiteCategory::where('category_id', $category->pid)->where('website_category.website_id', $data['website_id'])->first();
|
|
|
+ $pinyin = $childCategory->aLIas_pinyin ? $childCategory->aLIas_pinyin.'/'. $category->aLIas_pinyin : null;
|
|
|
+ }
|
|
|
+ $article->pinyin = $pinyin;
|
|
|
+ return $article;
|
|
|
+ });
|
|
|
|
|
|
$count = Article::where(function ($query) use ($where) {
|
|
|
foreach ($where as $condition) {
|
|
@@ -1525,6 +1550,7 @@ class NewsService implements NewsServiceInterface
|
|
|
$textArticles = [];
|
|
|
// return Result::error("暂无此栏目",0);
|
|
|
}else{
|
|
|
+ $parent_alias = $category->aLIas_pinyin ? $category->aLIas_pinyin.'/' : null;
|
|
|
// return Result::success($website);
|
|
|
// 查询图片新闻
|
|
|
// 合并查询条件
|
|
@@ -1555,7 +1581,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()
|
|
@@ -1577,7 +1603,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)
|
|
@@ -1597,8 +1623,37 @@ class NewsService implements NewsServiceInterface
|
|
|
];
|
|
|
|
|
|
|
|
|
- return $resultItem;
|
|
|
- }, $data);
|
|
|
+ return $resultItem;
|
|
|
+ }, $data);
|
|
|
+ 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);
|
|
|
}
|
|
|
|