Parcourir la source

Merge branch 'web_sannong_fr'

15313670163 il y a 2 semaines
Parent
commit
1927ae2bf2
1 fichiers modifiés avec 30 ajouts et 8 suppressions
  1. 30 8
      app/JsonRpc/NewsService.php

+ 30 - 8
app/JsonRpc/NewsService.php

@@ -823,9 +823,6 @@ class NewsService implements NewsServiceInterface
     {
         // return Result::success($data);
         $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 (is_array($data['catid'])) {
                 $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")
         ->limit($data['pageSize'])
         ->offset(($data['page'] - 1) * $data['pageSize'])
-        ->get()
-        // ;
+        ->get()->all()
         ->map(function ($article ) use ($data) {
             $catid = $article->catid ?? 0;
             $pinyin = '';
@@ -1247,10 +1243,36 @@ class NewsService implements NewsServiceInterface
         // 计算总数
         $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'])
-            ->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)) {
             return Result::error("没有符合条件的资讯数据");
         }