PaperController.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace App\Http\Controllers\Api\v1;
  3. use App\Http\Controllers\Api\webApp;
  4. use App\Services\Api\PaperService;
  5. /**
  6. * 试卷管理
  7. * @package App\Http\Controllers\Api
  8. */
  9. class PaperController extends webApp
  10. {
  11. /**
  12. * 试题列表
  13. * @return array
  14. */
  15. public function index()
  16. {
  17. $params =request()->post();
  18. $pageSize = request()->post('pageSize', 15);
  19. $datas = PaperService::make()->getDataList($params, $pageSize);
  20. return message(1010, true, $datas);
  21. }
  22. /**
  23. * 详情
  24. */
  25. public function info()
  26. {
  27. try {
  28. $params = request()->all();
  29. $id = isset($params['id'])? intval($params['id']) : 0;
  30. $tid = isset($params['tid'])? intval($params['tid']) : 0;
  31. $rid = isset($params['rid'])? intval($params['rid']) : 0;
  32. if(empty($id)){
  33. return message(1036, false);
  34. }
  35. if($info = PaperService::make()->getInfo($this->userId, $id, $tid, $rid)){
  36. return message(1010, true, $info);
  37. }else{
  38. return message(1009, false);
  39. }
  40. }catch (\Exception $exception){
  41. return message(1009, false, $exception->getMessage());
  42. }
  43. }
  44. }