Index.php 807 B

12345678910111213141516171819202122232425262728293031323334353637
  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. ->limit(3)
  24. ->select();
  25. foreach($papers as $key => &$val){
  26. $val['image'] = localpath_to_netpath($val['image']);
  27. $val['limit_time'] = $val['limit_time']/60; //秒转换分种
  28. }
  29. $this->success('', $papers);
  30. }
  31. }