浏览代码

获取网站栏目的seo

15313670163 3 月之前
父节点
当前提交
b330c3e5bb
共有 3 个文件被更改,包括 55 次插入22 次删除
  1. 12 21
      app/JsonRpc/NewsService.php
  2. 1 1
      runtime/hyperf.pid
  3. 42 0
      runtime/logs/hyperf.log

+ 12 - 21
app/JsonRpc/NewsService.php

@@ -380,32 +380,23 @@ class NewsService implements NewsServiceInterface
     public function getWebsiteArticleList(array $data): array
     {
         $where= [];
-
-        if(isset($data['title'])  && $data['title']){
-            array_push($where,['article.title','like','%'.$data['title'].'%']);
-        }
-        if(isset($data['category_name'])  && $data['category_name']){
-            array_push($where,['category.name','like','%'.$data['category_name'].'%']);
-        }
-        if(isset($data['author'])  && $data['author']){
-             array_push($where,['article.author','=',$data['author']]);
-        }
-        if(isset($data['islink'])  && $data['islink']!==""){
-            array_push($where,['article.islink','=',$data['islink']]);
+       
+       if(isset($data['keyword'])  && !empty($data['keyword'])){
+            array_push($where,['article.title','like','%'.$data['keyword'].'%']);
         }
-        if(isset($data['status']) && $data['status']!==""){
-            array_push($where,['article.status','=',$data['status']]);
+        if(isset($data['catid'])  && !empty($data['catid'])){
+            $category = WebsiteCategory::where('website_id',$data['website_id'])->where('category_id',$data['catid'])->select('category_id')->first();
+            if(empty($category)){
+               return Result::error("此网站暂无此栏目",0); 
+            }
+            array_push($where,['catid',$data['catid']]);
         }
-        
+
         $rep = Article::where($where)
-            ->whereNotIn('article.status',[404])
-            ->leftJoin('category','article.catid','category.id')
-            ->select("article.*","category.name as category_name")
-            ->orderBy("article.id","desc")
+            ->orderBy("created_at","desc")
             ->limit($data['pageSize'])
             ->offset(($data['page']-1)*$data['pageSize'])->get();
-        $count =  Article::where($where)->whereNotIn('article.status',[404])
-            ->leftJoin('category','article.catid','category.id')->count();
+        $count =  Article::where($where)->count();
         $data = [
             'rows'=>$rep->toArray(),
             'count'=>$count

+ 1 - 1
runtime/hyperf.pid

@@ -1 +1 @@
-4000
+58024

+ 42 - 0
runtime/logs/hyperf.log

@@ -1920,3 +1920,45 @@
 [2025-02-11T16:47:32.854647+08:00] sql.INFO: [22.99] select count(*) as aggregate from `article` left join `category` on `article`.`catid` = `category`.`id` where `article`.`status` not in ('404') [] []
 [2025-02-11T16:47:43.836910+08:00] sql.INFO: [18.58] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `article`.`status` not in ('404') order by `article`.`id` desc limit 20 offset 0 [] []
 [2025-02-11T16:47:43.862506+08:00] sql.INFO: [20.7] select count(*) as aggregate from `article` left join `category` on `article`.`catid` = `category`.`id` where `article`.`status` not in ('404') [] []
+[2025-02-12T09:09:00.963821+08:00] sql.INFO: [60.83] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `article`.`status` not in ('404') order by `article`.`id` desc limit 5 offset 0 [] []
+[2025-02-12T09:09:01.001357+08:00] sql.INFO: [21.7] select count(*) as aggregate from `article` left join `category` on `article`.`catid` = `category`.`id` where `article`.`status` not in ('404') [] []
+[2025-02-12T09:09:04.982298+08:00] sql.INFO: [22.73] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `article`.`status` not in ('404') order by `article`.`id` desc limit 20 offset 0 [] []
+[2025-02-12T09:09:05.010357+08:00] sql.INFO: [23.87] select count(*) as aggregate from `article` left join `category` on `article`.`catid` = `category`.`id` where `article`.`status` not in ('404') [] []
+[2025-02-12T09:13:46.587529+08:00] sql.INFO: [63.48] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `article`.`status` not in ('404') order by `article`.`id` desc limit 20 offset 0 [] []
+[2025-02-12T09:13:46.614575+08:00] sql.INFO: [22.47] select count(*) as aggregate from `article` left join `category` on `article`.`catid` = `category`.`id` where `article`.`status` not in ('404') [] []
+[2025-02-12T09:14:08.642735+08:00] sql.INFO: [36.47] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `article`.`status` not in ('404') order by `article`.`id` desc limit 20 offset 20 [] []
+[2025-02-12T09:14:08.687973+08:00] sql.INFO: [40.23] select count(*) as aggregate from `article` left join `category` on `article`.`catid` = `category`.`id` where `article`.`status` not in ('404') [] []
+[2025-02-12T09:15:35.220428+08:00] sql.INFO: [63.31] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `article`.`status` not in ('404') order by `article`.`id` desc limit 20 offset 20 [] []
+[2025-02-12T09:15:35.247450+08:00] sql.INFO: [22.46] select count(*) as aggregate from `article` left join `category` on `article`.`catid` = `category`.`id` where `article`.`status` not in ('404') [] []
+[2025-02-12T09:22:08.428194+08:00] sql.INFO: [65.67] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' [] []
+[2025-02-12T09:22:09.517226+08:00] sql.INFO: [17.7] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' [] []
+[2025-02-12T09:22:17.427139+08:00] sql.INFO: [16.23] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' [] []
+[2025-02-12T09:22:38.702988+08:00] sql.INFO: [16.4] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' [] []
+[2025-02-12T09:23:25.505411+08:00] sql.INFO: [495.52] select * from `article` [] []
+[2025-02-12T09:23:34.945579+08:00] sql.INFO: [1318.65] select * from `article` [] []
+[2025-02-12T09:23:53.678710+08:00] sql.INFO: [1135.08] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' [] []
+[2025-02-12T09:23:57.822333+08:00] sql.INFO: [17.09] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' [] []
+[2025-02-12T09:24:16.798417+08:00] sql.INFO: [115.49] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' [] []
+[2025-02-12T09:24:20.819186+08:00] sql.INFO: [63.27] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' [] []
+[2025-02-12T09:24:41.450646+08:00] sql.INFO: [64.73] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' limit 1 [] []
+[2025-02-12T09:25:01.214371+08:00] sql.INFO: [14.22] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' limit 1 [] []
+[2025-02-12T09:25:02.830784+08:00] sql.INFO: [13.92] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' limit 1 [] []
+[2025-02-12T09:25:06.875571+08:00] sql.INFO: [63.41] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' limit 1 [] []
+[2025-02-12T09:25:26.233176+08:00] sql.INFO: [2168.41] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' limit 1 [] []
+[2025-02-12T09:25:26.345215+08:00] sql.INFO: [95.56] select * from `article` where (`article`.`title` like '%测试%' and `catid` = '17') [] []
+[2025-02-12T09:25:57.423457+08:00] sql.INFO: [33.89] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' limit 1 [] []
+[2025-02-12T09:25:57.474113+08:00] sql.INFO: [49.62] select * from `article` where (`article`.`title` like '%测试%' and `catid` = '17') [] []
+[2025-02-12T09:25:58.402386+08:00] sql.INFO: [49.53] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' limit 1 [] []
+[2025-02-12T09:25:58.448421+08:00] sql.INFO: [45.02] select * from `article` where (`article`.`title` like '%测试%' and `catid` = '17') [] []
+[2025-02-12T09:26:01.995963+08:00] sql.INFO: [63.03] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' limit 1 [] []
+[2025-02-12T09:26:09.404133+08:00] sql.INFO: [16.58] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' limit 1 [] []
+[2025-02-12T09:26:16.473759+08:00] sql.INFO: [36.68] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' limit 1 [] []
+[2025-02-12T09:26:21.302757+08:00] sql.INFO: [68.52] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' limit 1 [] []
+[2025-02-12T09:26:21.337451+08:00] sql.INFO: [17.85] select * from `article` where (`catid` = '17') [] []
+[2025-02-12T09:26:55.214230+08:00] sql.INFO: [16.9] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' limit 1 [] []
+[2025-02-12T09:26:55.232917+08:00] sql.INFO: [17.76] select * from `article` where (`catid` = '17') [] []
+[2025-02-12T09:27:50.860409+08:00] sql.INFO: [1022.79] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' limit 1 [] []
+[2025-02-12T09:27:51.417555+08:00] sql.INFO: [536.49] select * from `article` where (`catid` = '17') [] []
+[2025-02-12T09:27:54.590410+08:00] sql.INFO: [241.68] select `category_id` from `website_category` where `website_id` = '2' and `category_id` = '17' limit 1 [] []
+[2025-02-12T09:27:54.915225+08:00] sql.INFO: [309] select * from `article` where (`catid` = '17') order by `created_at` desc limit 20 offset 20 [] []
+[2025-02-12T09:27:55.226457+08:00] sql.INFO: [310.08] select count(*) as aggregate from `article` where (`catid` = '17') [] []