wanggangtao 5 年之前
父節點
當前提交
93b63639ef
共有 4 個文件被更改,包括 48 次插入15 次删除
  1. 2 13
      api/v1.0/demo/index_info.html
  2. 1 1
      api/v1.0/index_info.php
  3. 12 0
      lib/index.class.php
  4. 33 1
      lib/table/table_index.class.php

+ 2 - 13
api/v1.0/demo/index_info.html

@@ -67,20 +67,9 @@
                 <input type="text" class="input-text"  name="timestamp" value="11111111" />
             </p>
 
-
-            <p>
-                <span>code</span>
-                <input type="text" class="input-text"  name="code" value="600008"/>
-            </p>
-
-
-            <p>
-                <span>date</span>
-                <input type="text" class="input-text"  name="date" value=20201201 />
-            </p>
             <p>
-                <span>index_type:0:表示全部指数,1:上证指数,2:深成指数 3:上证50指数 4:沪深300 5:创业板指数 6:科创50指数 </span>
-                <input type="text" class="input-text"  name="index_type" value=0 />
+                <span>1:上证指数,2:深成指数 3:上证50指数 4:沪深300 5:创业板指数 6:科创50指数 </span>
+                <input type="text" class="input-text"  name="index_type" value=5 />
             </p>
 
 

File diff suppressed because it is too large
+ 1 - 1
api/v1.0/index_info.php


+ 12 - 0
lib/index.class.php

@@ -13,6 +13,18 @@ class Index {
 
     }
 
+    /**
+     * @return mixed
+     * wanggangtao
+     * 获取指数的基本信息
+     */
+    static public function get_index_info($type)
+    {
+        $Table_index = new Table_index();
+        return $Table_index->get_index_info($type);
+    }
+
+
     /***
      * @return array
      * wanggangtao

+ 33 - 1
lib/table/table_index.class.php

@@ -64,8 +64,40 @@ class Table_index extends Table {
         }
     }
 
+    public function get_index_info($index_type){
 
-
+        $where=" where 1=1 ";
+        $sql = "select "."`*`". "from ". $this->table_fullname . $where ;
+        if($index_type==1){
+            $stock_code="000001";
+            $sql.=" and index_code=".$stock_code ;
+        }else if($index_type==2){
+            $stock_code="399001";
+            $sql.=" and index_code=".$stock_code ;
+        }else if($index_type==3){
+            $stock_code="000016";
+            $sql.=" and index_code=".$stock_code ;
+        }else if($index_type==4){
+            $stock_code="399300";
+            $sql.=" and index_code=".$stock_code ;
+        }else if($index_type==5){
+            $stock_code="399006";
+            $sql.=" and index_code=".$stock_code ;
+        }else if($index_type==6){
+            $stock_code="000688";
+            $sql.=" and index_code=".$stock_code ;
+        }
+        $rs = $this->pdo->sqlQuery($sql);
+        $r  = array();
+        if($rs){
+            foreach($rs as $key => $val){
+                $r[$key] = $this->dataToAttr($val);
+            }
+            return $r;
+        }else{
+            return $r;
+        }
+    }