소스 검색

修改获取新闻详情

15313670163 2 달 전
부모
커밋
1e1cfcc6a9
2개의 변경된 파일28개의 추가작업 그리고 6개의 파일을 삭제
  1. 23 6
      app/JsonRpc/NewsService.php
  2. 5 0
      app/JsonRpc/NewsServiceInterface.php

+ 23 - 6
app/JsonRpc/NewsService.php

@@ -279,12 +279,6 @@ class NewsService implements NewsServiceInterface
         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'];
         return Result::success($result);
     }
     /**
@@ -440,4 +434,27 @@ class NewsService implements NewsServiceInterface
         }
         return Result::success($data);
     }
+    /**
+     * 前端-获取新闻详情
+     * @param array $data
+     * @return array
+     */
+    public function selectWebsiteArticleInfo(array $data): array
+    {
+        $where = [
+            'article.id'=>$data['id'],
+            'article.status'=>1
+        ];
+        $result = Article::where($where)->leftJoin("article_data","article.id","article_data.article_id")->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'];
+        return Result::success($result);
+    }
 }

+ 5 - 0
app/JsonRpc/NewsServiceInterface.php

@@ -90,5 +90,10 @@ interface NewsServiceInterface
      * @return array
      */
     public function getWebsiteArticleList(array $data):array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function selectWebsiteArticleInfo(array $data):array;
 
 }