stock.class.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /***
  3. * Class Stock
  4. * * @author 王刚涛
  5. * 日线数据
  6. */
  7. class Stock {
  8. static public function getStockCodeList()
  9. {
  10. $Table_stock = new Table_stock();
  11. return $Table_stock->getStockCodeList();
  12. }
  13. static public function getInfoById($id)
  14. {
  15. $Table_stock = new Table_stock();
  16. return $Table_stock->getInfoById($id);
  17. }
  18. static public function getInfoByCode($code)
  19. {
  20. $Table_stock = new Table_stock();
  21. return $Table_stock->getInfoByCode($code);
  22. }
  23. static public function getList($filter = array(), $count=0, $page=0, $pageSize=0)
  24. {
  25. $Table_stock = new Table_stock();
  26. return $Table_stock->getList($filter, $count, $page, $pageSize);
  27. }
  28. static public function addOrUpdateByCode($attrs)
  29. {
  30. if (empty($attrs)) throw new Exception('参数不能为空', 101);
  31. $Table_stock = new Table_stock();
  32. $rs = $Table_stock->getInfoByCode($attrs['code']);
  33. if (empty($rs)) {
  34. $id = $Table_stock->add($attrs);
  35. } else {
  36. $id = $rs['id'];
  37. $Table_stock->update($id, $attrs);
  38. }
  39. return $id;
  40. }
  41. }
  42. ?>