diff --git a/control/weibo.php b/control/weibo.php index bec104f..b75157c 100644 --- a/control/weibo.php +++ b/control/weibo.php @@ -85,6 +85,26 @@ class weibo extends publicBase { $this->ajax_json(true, '保存成功'); } + public function ajax_get_spider_list() { + $date = trim($this->post('date')); + $cur_page = $this->post('currentPage') ? $this->post('currentPage') : 1; + $page_size = $this->post('pageSize') ? $this->post('pageSize') : 20; + + $obj = new mWeiboBehavior(); + $list = $obj->getSpiderBehavior($date, $cur_page, $page_size); + $total = $obj->getSpiderBehaviorTotal($date); + + $rdata = array( + 'total' => $total, + 'per_page' => $page_size, + 'last_page' => ceil($total / $page_size), + 'cur_page' => $cur_page, + 'list' => $list, + ); + + $this->ajax_json(true, '获取成功', $rdata); + } + public function ajax_hot_list() { $type = $this->post('type') + 0; $sdate = trim($this->post('sdate')); diff --git a/model/mWeiboBehavior.php b/model/mWeiboBehavior.php index c183e1c..582d84b 100644 --- a/model/mWeiboBehavior.php +++ b/model/mWeiboBehavior.php @@ -36,6 +36,15 @@ class mWeiboBehavior extends mBase { return $this->obj->delete($this->tbl_delta, array('sql' => "`date` array($date))); } + public function getSpiderBehavior($date, $page_num, $page_size) { + $offset = ($page_num - 1) * $page_size; + return $this->obj->selectAll($this->tbl_data, array('sql' => "`date`=?", 'vals' => array($date)), 'created_at desc', array($offset, $page_size)); + } + + public function getSpiderBehaviorTotal($date) { + return $this->obj->count($this->tbl_data, array('sql' => "`date`=?", 'vals' => array($date))); + } + public function getHotBehavior($type, $sdate, $edate, $page_num, $page_size) { $offset = ($page_num - 1) * $page_size;