wugg 2 年 前
コミット
0aa99d90fd
1 ファイル変更17 行追加13 行削除
  1. 17 13
      app/admin/controller/CatPlat.php

+ 17 - 13
app/admin/controller/CatPlat.php

@@ -298,19 +298,18 @@ use think\App;class CatPlat extends Base{
         $plat_id=isset($this->post['platform_id']) && $this->post['platform_id'] !==""? intval($this->post['platform_id']) :"";
         if($pid!==""){
             $where[]=["pid","=",$pid];
-          if ($pid!=0){
-               $pcat =  Db::name('cat')->where(['id'=>$pid,"is_del"=>0])->find();
-            if($pcat==false){
-                return error_show(1004,"未找到分类数据");
-            }else{
-                if($pcat['level']==2){
-                   if($plat_id==""){
-                        return error_show(1004,"参数 platform_id 不能为空");
-                   }
+            if ($pid!=0){
+                $pcat =  Db::name('cat')->where(['id'=>$pid,"is_del"=>0])->find();
+                if($pcat==false){
+                    return error_show(1004,"未找到分类数据");
+                }else{
+                    if($pcat['level']==2){
+                        if($plat_id==""){
+                            return error_show(1004,"参数 platform_id 不能为空");
+                        }
+                    }
                 }
             }
-          }
-
         }
         if($plat_id!=""){
               $platform = Db::name("platform")->where(["id"=>$plat_id,"is_del"=>0])->find();
@@ -319,7 +318,12 @@ use think\App;class CatPlat extends Base{
         if($status!==""){
             $where[]=['status',"=",$status];
         }
-        $list = Db::name('cat')->where($where)->select();
+        $page = isset($post['page'])&&$post['page']!=""?intval($post['page']) :"1";
+        $size = isset($post['size'])&&$post['size']!=""?intval($post['size']) :"15";
+        $count = Db::name("cat")->where($where)->count();
+        $total = ceil($count/$size);
+        $page = $total> $page ? $page: intval($total);
+        $list = Db::name('cat')->where($where)->page($page,$size)->select();
         $data=[];
         foreach ($list as $key=>$value){
             if($value['level']==3){
@@ -338,6 +342,6 @@ use think\App;class CatPlat extends Base{
             $value['platform_id'] = $plat_id;
             $data[]=$value;
         }
-        return app_show(0, "获取成功",$list);
+        return app_show(0, "获取成功",["list"=>$list,"count"=>$count]);
     }
 }