rkljw hai 5 meses
pai
achega
13c63f0f4f
Modificáronse 4 ficheiros con 141 adicións e 17 borrados
  1. 73 16
      app/JsonRpc/NewsService.php
  2. 13 0
      app/JsonRpc/NewsServiceInterface.php
  3. 1 1
      runtime/hyperf.pid
  4. 54 0
      runtime/logs/hyperf.log

+ 73 - 16
app/JsonRpc/NewsService.php

@@ -13,24 +13,34 @@ class NewsService implements NewsServiceInterface
 {
 
     /**
+     * 获取导航池列表
      * @param array $data
      * @return array
      */
     public function getCategoryList(array $data): array
     {
-        $where = [
-            ['name','like','%'.$data['keyWord'].'%'],
-            ['website_id','=',$data['website_id']],
-            ['pid','=',$data['pid']??0]
-        ];
-        $rep = Category::where($where)->limit($data['pageSize'])->orderBy("sort","asc")->offset(($data['page']-1)*$data['pageSize'])->get();
+        $where = [];
+        if(isset($data['name']) && $data['name']){
+            array_push($where, ['category.name','like','%'.$data['name'].'%']);
+        }
+        if(isset($data['department_id']) && $data['department_id']){
+            array_push($where, ['category.department_id','=',$data['department_id']]);
+        }
+        if(isset($data['city_id']) && $data['city_id']){
+            array_push($where, ['category.city_id','=',$data['city_id']]);
+        }
+        $rep = Category::where($where)
+            ->leftJoin('district','category.city_id','district.id')
+            ->leftJoin('department','category.department_id','department.id')
+            ->select("category.*","district.name as city_name","department.name as department_name")
+            ->limit($data['pageSize'])->orderBy("category.sort","desc")->offset(($data['page']-1)*$data['pageSize'])->get();
         $count =  Category::where($where)->count();
         $data = [
             'rows'=>$rep->toArray(),
             'count'=>$count
         ];
         if(empty($rep->toArray())){
-            return Result::error("没有栏目数据");
+            return Result::error("没有导航池数据");
         }
         return Result::success($data);
     }
@@ -41,7 +51,14 @@ class NewsService implements NewsServiceInterface
      */
     public function categoryList(array $data): array
     {
-       $result =  Category::where($data)->get();
+        $where[] = [
+            'pid','=',$data['pid']
+        ];
+        if(isset($data['name'])){
+            array_push($where, ['category.name','like','%'.$data['name'].'%']);
+        }
+        var_dump($where);
+       $result =  Category::where($where)->get();
         if(empty($result)){
             return Result::error("没有栏目数据");
         }
@@ -100,6 +117,23 @@ class NewsService implements NewsServiceInterface
         }
     }
 
+    /**
+     * 获取导航池信息
+     * @param array $data
+     * @return array
+     */
+    public function getCategoryInfo(array $data): array
+    {
+        $where = [
+            'id'=>$data['id']
+        ];
+        $result = Category::where($where)->first();
+        if($result){
+            return Result::success($result);
+        }else{
+            return Result::error("更新失败");
+        }
+    }
     /**
      * @param array $data
      * @return array
@@ -107,14 +141,25 @@ class NewsService implements NewsServiceInterface
     public function getArticleList(array $data): array
     {
         $where= [];
-        if(isset($data['keyWord'])){
-            $where[] =   ['article.title','like','%'.$data['keyWord'].'%'];
-            $where[] =   ['article.status','!=','5'];
+        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','=',$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['status'])  && $data['status']){
+            array_push($where,['article.status','=',$data['status']]);
         }
         $rep = Article::where($where)
+            ->whereNotIn('status',[404])
             ->leftJoin('category','article.catid','category.id')
-            ->leftJoin("article_data","article.id","article_data.article_id")
-            ->select("article.*","category.name","article_data.content")
+            ->select("article.*","category.name as category_name")
             ->orderBy("article.id","desc")
             ->limit($data['pageSize'])
             ->offset(($data['page']-1)*$data['pageSize'])->get();
@@ -138,8 +183,6 @@ class NewsService implements NewsServiceInterface
         Db::beginTransaction();
         try{
 
-        $data['cat_arr_id'] = isset($data['cat_arr_id'])?json_encode($data['cat_arr_id']):'';
-        $data['tag'] = isset($data['tag'])?json_encode($data['tag']):'';
             $articleData = $data;
             unset($articleData['content']);
             $id = Article::insertGetId($articleData);
@@ -164,7 +207,7 @@ class NewsService implements NewsServiceInterface
      */
     public function delArticle(array $data): array
     {
-        $result = Article::where($data)->update(['status'=>5]);
+        $result = Article::where($data)->update(['status'=>404]);
         if(!$result){
             return Result::error("删除失败");
         }
@@ -202,6 +245,20 @@ class NewsService implements NewsServiceInterface
 
     }
 
+    /**
+     * 更新资讯状态
+     * @param array $data
+     * @return array
+     */
+    public function upArticleStatus(array $data):array
+    {
+       $result =  Article::where(['id'=>$data['id']])->update($data);
+        if($result){
+            return Result::success();
+        }else{
+            return Result::error("更新状态失败",0);
+        }
+    }
     /**
      * @param array $data
      * @return array

+ 13 - 0
app/JsonRpc/NewsServiceInterface.php

@@ -62,4 +62,17 @@ interface NewsServiceInterface
      */
     public function getArticleInfo(array $data):array;
 
+    /**
+     * 获取导航池信息
+     * @param array $data
+     * @return array
+     */
+    public function getCategoryInfo(array $data):array;
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function upArticleStatus(array $data):array;
+
 }

+ 1 - 1
runtime/hyperf.pid

@@ -1 +1 @@
-164
+71476

+ 54 - 0
runtime/logs/hyperf.log

@@ -0,0 +1,54 @@
+[2024-10-28T09:19:22.425365+00:00] sql.INFO: [8.16] select * from `category` where (`pid` = '0' and `category`.`name` like '%sa%') [] []
+[2024-10-28T09:19:23.932164+00:00] sql.INFO: [3.85] select * from `category` where (`pid` = '0' and `category`.`name` like '%san%') [] []
+[2024-10-28T09:19:25.594721+00:00] sql.INFO: [5.64] select * from `category` where (`pid` = '0' and `category`.`name` like '%san%') [] []
+[2024-10-28T09:19:26.302275+00:00] sql.INFO: [2.31] select * from `category` where (`pid` = '0' and `category`.`name` like '%sannong %') [] []
+[2024-10-28T09:19:26.955566+00:00] sql.INFO: [14.88] select * from `category` where (`pid` = '0' and `category`.`name` like '%sannon%') [] []
+[2024-10-28T09:19:30.277954+00:00] sql.INFO: [3.66] select * from `category` where (`pid` = '0' and `category`.`name` like '%三农%') [] []
+[2024-10-28T09:20:42.957341+00:00] sql.INFO: [16.46] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` order by `article`.`id` desc limit 10 offset 0 [] []
+[2024-10-28T09:20:42.960700+00:00] sql.INFO: [1.35] select count(*) as aggregate from `article` [] []
+[2024-10-28T09:20:50.061214+00:00] sql.INFO: [18.99] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` order by `article`.`id` desc limit 10 offset 10 [] []
+[2024-10-28T09:20:50.066286+00:00] sql.INFO: [2.05] select count(*) as aggregate from `article` [] []
+[2024-10-28T09:21:30.505188+00:00] sql.INFO: [7.85] select `category`.*, `district`.`name` as `city_name`, `department`.`name` as `department_name` from `category` left join `district` on `category`.`city_id` = `district`.`id` left join `department` on `category`.`department_id` = `department`.`id` order by `category`.`sort` desc limit 10 offset 0 [] []
+[2024-10-28T09:21:30.508374+00:00] sql.INFO: [1.28] select count(*) as aggregate from `category` [] []
+[2024-10-28T09:21:31.723785+00:00] sql.INFO: [2.1] select * from `category` where (`pid` = '0') [] []
+[2024-10-28T09:22:14.520423+00:00] sql.INFO: [6.66] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` order by `article`.`id` desc limit 10 offset 0 [] []
+[2024-10-28T09:22:14.523783+00:00] sql.INFO: [1.18] select count(*) as aggregate from `article` [] []
+[2024-10-28T09:23:41.330394+00:00] sql.INFO: [92.39] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `status` not in ('404') order by `article`.`id` desc limit 10 offset 0 [] []
+[2024-10-28T09:23:41.346166+00:00] sql.INFO: [1.79] select count(*) as aggregate from `article` [] []
+[2024-10-28T09:30:05.455611+00:00] sql.INFO: [15.11] select `category`.*, `district`.`name` as `city_name`, `department`.`name` as `department_name` from `category` left join `district` on `category`.`city_id` = `district`.`id` left join `department` on `category`.`department_id` = `department`.`id` order by `category`.`sort` desc limit 10 offset 0 [] []
+[2024-10-28T09:30:05.458772+00:00] sql.INFO: [1.08] select count(*) as aggregate from `category` [] []
+[2024-10-28T09:30:31.187444+00:00] sql.INFO: [25.53] select `category`.*, `district`.`name` as `city_name`, `department`.`name` as `department_name` from `category` left join `district` on `category`.`city_id` = `district`.`id` left join `department` on `category`.`department_id` = `department`.`id` order by `category`.`sort` desc limit 10 offset 0 [] []
+[2024-10-28T09:30:31.191557+00:00] sql.INFO: [1.12] select count(*) as aggregate from `category` [] []
+[2024-10-28T09:35:56.762161+00:00] sql.INFO: [12.17] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `status` not in ('404') order by `article`.`id` desc limit 10 offset 0 [] []
+[2024-10-28T09:35:56.765863+00:00] sql.INFO: [1.44] select count(*) as aggregate from `article` [] []
+[2024-10-28T09:36:40.526749+00:00] sql.INFO: [11.29] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `status` not in ('404') order by `article`.`id` desc limit 10 offset 10 [] []
+[2024-10-28T09:36:40.530191+00:00] sql.INFO: [1.21] select count(*) as aggregate from `article` [] []
+[2024-10-28T09:44:00.034063+00:00] sql.INFO: [12.58] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `status` not in ('404') order by `article`.`id` desc limit 10 offset 0 [] []
+[2024-10-28T09:44:00.037791+00:00] sql.INFO: [1.5] select count(*) as aggregate from `article` [] []
+[2024-10-28T09:44:19.228731+00:00] sql.INFO: [6.89] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `status` not in ('404') order by `article`.`id` desc limit 10 offset 0 [] []
+[2024-10-28T09:44:19.232045+00:00] sql.INFO: [1.36] select count(*) as aggregate from `article` [] []
+[2024-10-28T09:44:28.172028+00:00] sql.INFO: [13.78] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `status` not in ('404') order by `article`.`id` desc limit 10 offset 0 [] []
+[2024-10-28T09:44:28.177518+00:00] sql.INFO: [1.86] select count(*) as aggregate from `article` [] []
+[2024-10-28T09:47:12.603134+00:00] sql.INFO: [26.94] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `status` not in ('404') order by `article`.`id` desc limit 10 offset 0 [] []
+[2024-10-28T09:47:12.609128+00:00] sql.INFO: [2.02] select count(*) as aggregate from `article` [] []
+[2024-10-28T09:47:56.180069+00:00] sql.INFO: [6.11] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `status` not in ('404') order by `article`.`id` desc limit 10 offset 0 [] []
+[2024-10-28T09:47:56.183781+00:00] sql.INFO: [1.14] select count(*) as aggregate from `article` [] []
+[2024-10-28T09:48:47.552614+00:00] sql.INFO: [11.21] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `status` not in ('404') order by `article`.`id` desc limit 10 offset 0 [] []
+[2024-10-28T09:48:47.558361+00:00] sql.INFO: [2.06] select count(*) as aggregate from `article` [] []
+[2024-10-28T09:59:31.273413+00:00] sql.INFO: [8.26] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `status` not in ('404') order by `article`.`id` desc limit 10 offset 0 [] []
+[2024-10-28T09:59:31.276597+00:00] sql.INFO: [1.21] select count(*) as aggregate from `article` [] []
+[2024-10-28T10:01:41.907784+00:00] sql.INFO: [16.13] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `status` not in ('404') order by `article`.`id` desc limit 10 offset 0 [] []
+[2024-10-28T10:01:41.913900+00:00] sql.INFO: [2.31] select count(*) as aggregate from `article` [] []
+[2024-10-28T10:01:56.976205+00:00] sql.INFO: [6.23] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `status` not in ('404') order by `article`.`id` desc limit 10 offset 0 [] []
+[2024-10-28T10:01:56.979928+00:00] sql.INFO: [1.39] select count(*) as aggregate from `article` [] []
+[2024-10-28T10:11:01.574355+00:00] sql.INFO: [5.79] select * from `category` where (`pid` = '0') [] []
+[2024-10-28T10:12:33.978283+00:00] sql.INFO: [6.73] select * from `category` where (`pid` = '0') [] []
+[2024-10-28T10:15:45.796213+00:00] sql.INFO: [6.69] select * from `category` where (`pid` = '0') [] []
+[2024-10-29T00:45:12.074297+00:00] sql.INFO: [12.16] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `status` not in ('404') order by `article`.`id` desc limit 10 offset 0 [] []
+[2024-10-29T00:45:12.077776+00:00] sql.INFO: [1.12] select count(*) as aggregate from `article` [] []
+[2024-10-29T00:45:17.287355+00:00] sql.INFO: [10.05] select `category`.*, `district`.`name` as `city_name`, `department`.`name` as `department_name` from `category` left join `district` on `category`.`city_id` = `district`.`id` left join `department` on `category`.`department_id` = `department`.`id` order by `category`.`sort` desc limit 10 offset 0 [] []
+[2024-10-29T00:45:17.291775+00:00] sql.INFO: [2.26] select count(*) as aggregate from `category` [] []
+[2024-10-29T00:45:19.787894+00:00] sql.INFO: [11.3] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `status` not in ('404') order by `article`.`id` desc limit 10 offset 0 [] []
+[2024-10-29T00:45:19.792318+00:00] sql.INFO: [1.57] select count(*) as aggregate from `article` [] []
+[2024-10-29T01:48:07.980493+00:00] sql.INFO: [14.03] select `article`.*, `category`.`name` as `category_name` from `article` left join `category` on `article`.`catid` = `category`.`id` where `status` not in ('404') order by `article`.`id` desc limit 10 offset 0 [] []
+[2024-10-29T01:48:07.983844+00:00] sql.INFO: [1.17] select count(*) as aggregate from `article` [] []