12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use app\common\model\BusinessModel;
- use app\common\model\StudyModel;
- use think\Db;
- /**
- * 在线学习
- */
- class Study extends Api
- {
- protected $noNeedLogin = ['lists', 'banner', 'listInfo', 'gg', 'parkMessage', 'activity', 'protable', 'protableInfo', 'NoticeInfo', 'GgInfo'];
- protected $noNeedRight = ['*'];
- /**
- * 在线学习列表
- * @param string $page 页数
- * @param string $limit 条数
- */
- public function lists()
- {
- $page = $this->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('暂无数据');
- }
- }
- }
|