|
@@ -823,9 +823,6 @@ class NewsService implements NewsServiceInterface
|
|
{
|
|
{
|
|
// return Result::success($data);
|
|
// return Result::success($data);
|
|
$where[] = ['status', '=', 1];
|
|
$where[] = ['status', '=', 1];
|
|
- if (isset($data['keyword']) && !empty($data['keyword'])) {
|
|
|
|
- array_push($where, ['article.title', 'like', '%' . $data['keyword'] . '%']);
|
|
|
|
- }
|
|
|
|
if (isset($data['catid']) && !empty($data['catid'])) {
|
|
if (isset($data['catid']) && !empty($data['catid'])) {
|
|
if (is_array($data['catid'])) {
|
|
if (is_array($data['catid'])) {
|
|
$category = WebsiteCategory::where('website_id', $data['website_id'])->whereIn('category_id', $data['catid'])->pluck('category_id');
|
|
$category = WebsiteCategory::where('website_id', $data['website_id'])->whereIn('category_id', $data['catid'])->pluck('category_id');
|
|
@@ -866,8 +863,7 @@ class NewsService implements NewsServiceInterface
|
|
->orderBy("updated_at", "desc")
|
|
->orderBy("updated_at", "desc")
|
|
->limit($data['pageSize'])
|
|
->limit($data['pageSize'])
|
|
->offset(($data['page'] - 1) * $data['pageSize'])
|
|
->offset(($data['page'] - 1) * $data['pageSize'])
|
|
- ->get()
|
|
|
|
- // ;
|
|
|
|
|
|
+ ->get()->all()
|
|
->map(function ($article ) use ($data) {
|
|
->map(function ($article ) use ($data) {
|
|
$catid = $article->catid ?? 0;
|
|
$catid = $article->catid ?? 0;
|
|
$pinyin = '';
|
|
$pinyin = '';
|
|
@@ -1247,10 +1243,36 @@ class NewsService implements NewsServiceInterface
|
|
// 计算总数
|
|
// 计算总数
|
|
$count = $query->count();
|
|
$count = $query->count();
|
|
// 分页查询
|
|
// 分页查询
|
|
- $articles = $query->orderBy("updated_at", "desc")
|
|
|
|
- ->limit($data['pageSize'])
|
|
|
|
|
|
+ $articles = $query
|
|
|
|
+ ->select(
|
|
|
|
+ 'article.id',
|
|
|
|
+ 'article.title',
|
|
|
|
+ 'article.imgurl',
|
|
|
|
+ 'article.author',
|
|
|
|
+ 'article.updated_at',
|
|
|
|
+ 'article.introduce',
|
|
|
|
+ 'article.islink',
|
|
|
|
+ 'article.linkurl',
|
|
|
|
+ 'article.copyfrom',
|
|
|
|
+ 'article.catid',
|
|
|
|
+ 'article.department_arr_id',
|
|
|
|
+ 'article.city_arr_id',)
|
|
|
|
+ ->orderBy("updated_at", "desc")
|
|
->offset(($data['page'] - 1) * $data['pageSize'])
|
|
->offset(($data['page'] - 1) * $data['pageSize'])
|
|
- ->get()->all();
|
|
|
|
|
|
+ ->limit($data['pageSize'])
|
|
|
|
+ ->get()->all()
|
|
|
|
+ ->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;
|
|
|
|
+ });
|
|
if (empty($articles)) {
|
|
if (empty($articles)) {
|
|
return Result::error("没有符合条件的资讯数据");
|
|
return Result::error("没有符合条件的资讯数据");
|
|
}
|
|
}
|