소스 검색

解决冲突

rkljw 1 개월 전
부모
커밋
060b84e4f2
2개의 변경된 파일28개의 추가작업 그리고 20개의 파일을 삭제
  1. 26 20
      app/JsonRpc/NewsService.php
  2. 2 0
      app/JsonRpc/NewsServiceInterface.php

+ 26 - 20
app/JsonRpc/NewsService.php

@@ -664,15 +664,14 @@ 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");
+        })
+        ->orderBy("updated_at", "desc")
+        ->limit($data['pageSize'])
+        ->offset(($data['page'] - 1) * $data['pageSize'])
+        ->get();
         $count = Article::where(function ($query) use ($where) {
             foreach ($where as $condition) {
                 if ($condition[1] === 'in') {
@@ -705,21 +704,28 @@ class NewsService implements NewsServiceInterface
             'article.id' => $data['id'],
             'article.status' => 1,
         ];
-        $result = Article::where($where)->leftJoin("article_data", "article.id", "article_data.article_id")
-            ->where(function ($query) use ($data) {
-                $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
-                    ->orWhereNull("ignore_ids");
-            })
+
+        $result = Article::where($where)->leftJoin("article_data","article.id","article_data.article_id")
+        ->where(function ($query) use ($data) {
+            $query->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($data['website_id'])."') = 0")
+                  ->orWhereNull("ignore_ids");
+        })
+        ->first();
+        if(empty($result)){
+            return Result::error("暂无此新闻!",0);
+        }
+        $category = WebsiteCategory::leftJoin('website', 'website.id', '=', 'website_category.website_id')
+            ->select('website_category.*', 'website.website_name', 'website.suffix')
+            ->where('website_category.website_id', $data['website_id'])
+            ->where(['website_category.category_id' => $result['catid']])
             ->first();
-        if (empty($result)) {
-            return Result::error("暂无此新闻!", 0);
-        }
-        $category = WebsiteCategory::where('website_id', $data['website_id'])->where(['category_id' => $result['catid']])->first();
         if (empty($category)) {
             return Result::error("查询失败", 0);
         }
         $result['category_id'] = $category['category_id'];
-        $result['cat_name'] = $category['name'];
+        $result['cat_name'] = $category['alias'];
+        $result['website_name'] = $category['website_name']??"";
+        $result['suffix'] = $category['suffix']??"";
         return Result::success($result);
     }
     /**
@@ -972,7 +978,7 @@ class NewsService implements NewsServiceInterface
         return Result::success($result);
     }
 
-    /**
+     /**
      * 前端-搜索新闻列表
      * @param array $data
      * @return array

+ 2 - 0
app/JsonRpc/NewsServiceInterface.php

@@ -142,6 +142,7 @@ interface NewsServiceInterface
      */
     public function addWebsiteSurveyVote(array $data): array;
 
+
     public function getSurveyList(array $data): array;
     /**
      * @param array $data
@@ -234,4 +235,5 @@ interface NewsServiceInterface
      */
     public function getCompanyNature(array $data): array;
 
+
 }