ExamController.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace App\Http\Controllers\Api\v1;
  3. use App\Http\Controllers\Api\webApp;
  4. use App\Services\Api\ArticleService;
  5. use App\Services\Api\ExamService;
  6. /**
  7. * 考试管理
  8. * @package App\Http\Controllers\Api
  9. */
  10. class ExamController extends webApp
  11. {
  12. /**
  13. * 答题记录
  14. * @return array
  15. */
  16. public function index()
  17. {
  18. $params =request()->post();
  19. $pageSize = request()->post('pageSize', 15);
  20. $datas = ExamService::make()->getDataList($params, $pageSize);
  21. return message(1010, true, $datas);
  22. }
  23. /**
  24. * 答题历史
  25. * @return array
  26. */
  27. public function history()
  28. {
  29. $params =request()->post();
  30. $pageSize = request()->post('pageSize', 15);
  31. $datas = ExamService::make()->getHistoryList($params, $pageSize);
  32. return message(1010, true, $datas);
  33. }
  34. /**
  35. * 详情
  36. */
  37. public function info()
  38. {
  39. $params = request()->all();
  40. $id = isset($params['id'])? intval($params['id']) : 0;
  41. if(empty($id)){
  42. return message(1036, false);
  43. }
  44. if($info = ArticleService::make()->getInfo($id)){
  45. return message(1010, true, $info);
  46. }else{
  47. return message(1009, false);
  48. }
  49. }
  50. /**
  51. * 单页数据
  52. */
  53. public function page()
  54. {
  55. $params = request()->all();
  56. $type = isset($params['type'])? intval($params['type']) : 0;
  57. if(empty($type)){
  58. return message(1031, false);
  59. }
  60. if($info = ArticleService::make()->getInfoByType($type)){
  61. return message(1010, true, $info);
  62. }else{
  63. return message(1009, false);
  64. }
  65. }
  66. }