Przeglądaj źródła

师傅端首页

lizhen_gitee 6 miesięcy temu
rodzic
commit
b5d1b04c8a
1 zmienionych plików z 7 dodań i 21 usunięć
  1. 7 21
      application/api/controller/worker/News.php

+ 7 - 21
application/api/controller/worker/News.php

@@ -21,23 +21,7 @@ class News extends Api
             ->order('id' , 'asc')
             ->select();
 
-        //第一个分类的内容
-        $list = [];
-        if(!empty($typelist)){
-            $list = Db::name('news')->field('content',true)
-                ->where('company_id',$this->auth->company_id)
-                ->where('type_id',$typelist[0]['id'])
-                ->autopage()
-                ->select();
-            $list = list_domain_image($list,['image']);
-        }
-
-        $rs = [
-            'typelist' => $typelist,
-            'list'     => $list,
-        ];
-
-        $this->success(1, $rs);
+        $this->success(1, $typelist);
     }
 
     //
@@ -45,15 +29,17 @@ class News extends Api
         $type_id = input('type_id',0);
         $keyword = input('keyword','','trim');
 
-        $wheresearch = [];
+        $where = [];
+        if(!empty($type_id)){
+            $where['type_id'] = $type_id;
+        }
         if(!empty($keyword)){
-            $wheresearch['title'] = ['LIKE','%'.$keyword.'%'];
+            $where['title'] = ['LIKE','%'.$keyword.'%'];
         }
 
         $list = Db::name('news')->field('content',true)
             ->where('company_id',$this->auth->company_id)
-            ->where('type_id',$type_id)
-            ->where($wheresearch)
+            ->where($where)
             ->autopage()
             ->select();
         $list = list_domain_image($list,['image']);