chenbo 4 år sedan
förälder
incheckning
450861c33e
3 ändrade filer med 10 tillägg och 58 borttagningar
  1. 2 2
      api/v1.0/stock_list.php
  2. 8 16
      lib/stock.class.php
  3. 0 40
      lib/table/table_stock.class.php

+ 2 - 2
api/v1.0/stock_list.php

@@ -32,7 +32,7 @@ try {
 
     //总数
     $params=array();
-    $count_num=Stock::getStockList($filter,11,$page, $pagesize);//总条数
+    $count_num=Stock::getList($filter,1);//总条数
     if($pagesize!=0){
         $count_page=ceil($count_num/$pagesize);//总页数
     }
@@ -50,7 +50,7 @@ try {
 
 
     $data=array();
-    $stock_info=Stock::getStockList($filter,0,$page, $pagesize);
+    $stock_info=Stock::getList($filter,0,$page, $pagesize);
     if(!empty($stock_info)){
         foreach($stock_info as $key=>$value){
             $param=array();

+ 8 - 16
lib/stock.class.php

@@ -8,12 +8,6 @@
 
 class Stock {
 
-    static public function getAllList()
-    {
-        $Table_stock = new Table_stock();
-        return $Table_stock->getList(array(), 0, 0, 0, 1);  //升序
-    }
-
     static public function getInfoById($id)
     {
         $Table_stock = new Table_stock();
@@ -26,20 +20,12 @@ class Stock {
         return $Table_stock->getInfoByCode($code);
     }
 
-
-    static public function getList($filter = array(), $sector=0, $page=0, $pageSize=0)
-    {
-        $Table_stock = new Table_stock();
-        return $Table_stock->getList($filter, $sector, $page, $pageSize);
-    }
-
-    static public function getStockList($filter = array(), $count, $page, $pagesize)
+    static public function getList($filter = array(), $count=0, $page=0, $pagesize=0, $order=0)
     {
         $Table_stock = new Table_stock();
-        return $Table_stock->getStockList($filter, $count,$page, $pagesize);
+        return $Table_stock->getList($filter, $count, $page, $pagesize, $order);
     }
 
-
     static public function addOrUpdateByCode($attrs)
     {
         if (empty($attrs)) throw new Exception('参数不能为空', 101);
@@ -49,6 +35,12 @@ class Stock {
         return $id;
     }
 
+    static public function getAllList()
+    {
+        $Table_stock = new Table_stock();
+        return $Table_stock->getList(array(), 0, 0, 0, 1);  //升序
+    }
+
 }
 
 ?>

+ 0 - 40
lib/table/table_stock.class.php

@@ -37,45 +37,5 @@ class Table_stock extends Table {
         return $this->pdo->sqlinsert($this->table_fullname, $param);
     }
 
-    public function getStockList($filter = array(), $count = 0, $page = 0, $pagesize = 0){
-        $where=" ";
-        if(!empty($filter["sector"])){
-            $where = $this->filterToWhere($filter);
-        }
-        if($count == 0){//列表
-            if($page==0 ||$page==-1 ){//表示不分页
-                $sql = "select * from ". $this->table_fullname ." $where order by ".$this->table_id." desc";
-
-
-            }else{//表示不分页
-                $sql = "select * from ". $this->table_fullname ." $where order by ".$this->table_id." desc";
-                if($page > 0){//分页
-                    $startrow = ($page - 1) * $pagesize;
-                    $sql_limit = " limit $startrow, $pagesize";
-                    $sql .= $sql_limit;
-                }
-            }
-            $rs  = $this->pdo->sqlQuery($sql);
-            $r   = array();
-            if($rs){
-                foreach($rs as $key => $val){
-                    $r[$key] = $this->dataToAttr($val);
-                }
-                return $r;
-            }else{
-                return $r;
-            }
-
-        }else{//统计
-            $sql = "select count(*) as c from ". $this->table_fullname . " $where ";
-            $rs  = $this->pdo->sqlQuery($sql);
-            if($rs){
-                return $rs[0]['c'];
-            }else{
-                return 0;
-            }
-        }
-    }
-
 }
 ?>