request->get('page'); $limit = $this->request->get('limit'); if (!$page) { $pages = '0,10'; } else { $page = $page - 1; if ($page < 0) $page = 0; $pages = $page . ',' . $limit; } $studyModel = new StudyModel(); $data = $studyModel->where('switch', 1) ->order('sort desc') ->limit($pages) ->select(); if ($data) { return $this->success('', $data); } else { return $this->success('暂无数据'); } } /** * 在线学习详情 * @param string $id id * */ public function listInfo() { $id = $this->request->get('id'); if (!isset($id) || empty($id)) return $this->error('缺少参数'); $studyModel = new StudyModel(); $data = $studyModel->where('switch', 1) ->where('id', $id) ->order('sort desc') ->find(); if ($data) { return $this->success('', $data); } else { return $this->success('暂无数据'); } } }