chenbo 4 år sedan
förälder
incheckning
ddf3c2fe74
2 ändrade filer med 58 tillägg och 37 borttagningar
  1. 34 17
      lib/index_day_k.class.php
  2. 24 20
      lib/table/table_index_day_k.class.php

+ 34 - 17
lib/index_day_k.class.php

@@ -8,11 +8,44 @@
  */
 class Index_day_k {
 
-    public function __construct()
+    static public function getInfoById($id)
+    {
+        $Table_index_day_k = new Table_index_day_k();
+        return $Table_index_day_k->getInfoById($id);
+    }
+
+    static public function getInfoByCodeAndDate($code, $date)
+    {
+        $Table_index_day_k = new Table_index_day_k();
+        return $Table_index_day_k->getInfoByCodeAndDate($code, $date);
+    }
+
+    static public function getList($filter = array(), $count=0, $page=0, $pagesize=0, $order=0)
     {
+        $Table_index_day_k = new Table_index_day_k();
+        return $Table_index_day_k->getList($filter, $count, $page, $pagesize, $order);
+    }
 
+    static public function getAllList()
+    {
+        $Table_index_day_k = new Table_index_day_k();
+        return $Table_index_day_k->getList();
+    }
+
+    static public function addOrUpdateByCodeDate($attrs)
+    {
+        if (empty($attrs)) throw new Exception('参数不能为空', 101);
+        if (empty($attrs['code'])) throw new Exception('股票代码不能为空', 102);
+        if (empty($attrs['date'])) throw new Exception('日期不能为空', 103);
+        $Table_index_day_k = new Table_index_day_k();
+        $id = $Table_index_day_k->addOrUpdateByCodeDate($attrs);
+        return $id;
     }
 
+
+
+    //----------------------------------------
+
     /***
      * @param $code
      * @param $start_date
@@ -29,16 +62,6 @@ class Index_day_k {
     }
 
 
-
-
-
-    static public function getInfoById($id)
-    {
-        $Table_index_day_k = new Table_index_day_k();
-        return $Table_index_day_k->getInfoById($id);
-    }
-
-
     static public function add($attrs){
         if (empty($attrs)) throw new Exception('参数不能为空', 102);
         $Table_index_day_k = new Table_index_day_k();
@@ -46,12 +69,6 @@ class Index_day_k {
         return $id;
     }
 
-    static public function getList($filter = array(), $count=0, $page=0, $pageSize=0)
-    {
-        $Table_index_day_k = new Table_index_day_k();
-        return $Table_index_day_k->getList($filter, $count, $page, $pageSize);
-    }
-
     static public function insert($attrs)
     {
         if (empty($attrs)) throw new Exception('参数不能为空', 102);

+ 24 - 20
lib/table/table_index_day_k.class.php

@@ -9,8 +9,10 @@
 
 class Table_index_day_k extends Table {
 
-    protected $table_name       = "index_day_k";//表名,不带前缀,前缀在config中定义
-    protected $table_id         = "index_day_k_id";//指定ID字段名称,必须
+    protected $table_name       = 'index_day_k';//表名,不带前缀,前缀在config中定义
+    protected $table_id         = 'index_day_k_id';//指定ID字段名称,必须
+    protected $table_status     = '';//指定状态字段名称,如果有
+    protected $table_order      = '';//指定排序字段名称,如果有
 
 	//数据库结构
 	protected function struct(){
@@ -22,17 +24,35 @@ class Table_index_day_k extends Table {
         $attr['name']               = 'index_day_k_name';
         $attr['open_price']         = 'index_day_k_open_price';
         $attr['close_price']        = 'index_day_k_close_price';
-        $attr['highest_price']     = 'index_day_k_highest_price';
+        $attr['highest_price']      = 'index_day_k_highest_price';
         $attr['lowest_price']       = 'index_day_k_lowest_price';
         $attr['increase_price']     = 'index_day_k_increase_price';
         $attr['increase_ratio']     = 'index_day_k_increase_ratio';
         $attr['amount']             = 'index_day_k_amount';
         $attr['value']              = 'index_day_k_value';
-
 		return $attr;
 	}
 
+    public function add($attr){
+        $param = array (
+            'index_day_k_timestamp'      => array('number', $attr['timestamp']),
+            'index_day_k_date'           => array('number', $attr['date']),
+            'index_day_k_code'           => array('string', $attr['code']),
+            'index_day_k_name'           => array('string', $attr['name']),
+            'index_day_k_open_price'     => array('number', $attr['open_price']),
+            'index_day_k_close_price'    => array('number', $attr['close_price']),
+            'index_day_k_highest_price'  => array('number', $attr['highest_price']),
+            'index_day_k_lowest_price'   => array('number', $attr['lowest_price']),
+            'index_day_k_increase_price' => array('number', $attr['increase_price']),
+            'index_day_k_increase_ratio' => array('number', $attr['increase_ratio']),
+            'index_day_k_amount'         => array('number', $attr['amount']),
+            'index_day_k_value'          => array('number', $attr['value']),
+        );
+        return $this->pdo->sqlinsert($this->table_fullname, $param);
+    }
+
 
+    //-------------------------------
 
     public function index_recent_days($code,$start_date,$traceback_days,$order)
     {
@@ -148,23 +168,7 @@ class Table_index_day_k extends Table {
     }
 
 
-    public function add($attr){
-        $param = array (
 
-            'index_day_k_timestamp'    => array('number', $attr['timestamp']),
-            'index_day_k_date'    => array('number', $attr['date']),
-            'index_day_k_code'    => array('string', $attr['code']),
-            'index_day_k_name'    => array('string', $attr['name']),
-            'index_day_k_open_price'    => array('number', $attr['open_price']),
-            'index_day_k_close_price'    => array('number', $attr['close_price']),
-            'index_day_k_highest_price'    => array('number', $attr['highest_price']),
-            'index_day_k_lowest_price'    => array('number', $attr['lowest_price']),
-            'index_day_k_increase_price'    => array('number', $attr['increase_price']),
-            'index_day_k_increase_ratio'    => array('number', $attr['increase_ratio']),
-            'index_day_k_amount'    => array('number', $attr['amount']),
-            'index_day_k_value'    => array('number', $attr['value']),        );
-        return $this->pdo->sqlinsert($this->table_fullname, $param);
-    }
 
 
     /***