Index.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. * 首页接口
  7. */
  8. class Index extends Api
  9. {
  10. protected $noNeedLogin = ['*'];
  11. protected $noNeedRight = ['*'];
  12. /**
  13. * 首页
  14. *
  15. */
  16. public function index()
  17. {
  18. //热门试卷列表
  19. $now = time();
  20. $papers = Db::name('exam_paper')->field('id,image,title,start_time,end_time,total_score,limit_time')
  21. ->where('status', 'NORMAL')
  22. ->where('index_status', 1)
  23. ->whereRaw("((start_time = 0 and end_time = 0) or (start_time < {$now} and end_time > {$now}))")
  24. ->limit(3)
  25. ->select();
  26. foreach($papers as $key => &$val){
  27. $val['image'] = localpath_to_netpath($val['image']);
  28. $val['limit_time'] = $val['limit_time']/60; //秒转换分种
  29. }
  30. $this->success('', $papers);
  31. }
  32. //在线考试
  33. //我的考试
  34. //可参加考试
  35. //我的试卷
  36. //进行中考试
  37. //历史考试
  38. }