Study.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\common\model\BusinessModel;
  5. use app\common\model\StudyModel;
  6. use think\Db;
  7. /**
  8. * 在线学习
  9. */
  10. class Study extends Api
  11. {
  12. protected $noNeedLogin = ['lists', 'banner', 'listInfo', 'gg', 'parkMessage', 'activity', 'protable', 'protableInfo', 'NoticeInfo', 'GgInfo'];
  13. protected $noNeedRight = ['*'];
  14. /**
  15. * 在线学习列表
  16. * @param string $page 页数
  17. * @param string $limit 条数
  18. */
  19. public function lists()
  20. {
  21. $page = $this->request->get('page');
  22. $limit = $this->request->get('limit');
  23. if (!$page) {
  24. $pages = '0,10';
  25. } else {
  26. $page = $page - 1;
  27. if ($page < 0) $page = 0;
  28. $pages = $page . ',' . $limit;
  29. }
  30. $studyModel = new StudyModel();
  31. $data = $studyModel->where('switch', 1)
  32. ->order('sort desc')
  33. ->limit($pages)
  34. ->select();
  35. if ($data) {
  36. return $this->success('', $data);
  37. } else {
  38. return $this->success('暂无数据');
  39. }
  40. }
  41. /**
  42. * 在线学习详情
  43. * @param string $id id
  44. *
  45. */
  46. public function listInfo()
  47. {
  48. $id = $this->request->get('id');
  49. if (!isset($id) || empty($id)) return $this->error('缺少参数');
  50. $studyModel = new StudyModel();
  51. $data = $studyModel->where('switch', 1)
  52. ->where('id', $id)
  53. ->order('sort desc')
  54. ->find();
  55. if ($data) {
  56. return $this->success('', $data);
  57. } else {
  58. return $this->success('暂无数据');
  59. }
  60. }
  61. }