TopicController.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Services\Exam\TopicService;
  4. /**
  5. * 题目管理-控制器
  6. */
  7. class TopicController extends Backend
  8. {
  9. public function __construct()
  10. {
  11. parent::__construct();
  12. $this->service = TopicService::make();
  13. }
  14. public function index()
  15. {
  16. $pageSize = request()->get('limit', 10);
  17. $list = $this->service->customList(request()->all(), $pageSize);
  18. $message = array(
  19. "msg" => '操作成功',
  20. "code" => 0,
  21. "data" => isset($list['list']) ? $list['list'] : [],
  22. "count" => isset($list['total']) ? $list['total'] : 0,
  23. );
  24. return $message;
  25. }
  26. public function sort()
  27. {
  28. $param = request()->all();
  29. return $this->service->sort($param);
  30. }
  31. /**
  32. * 获取题目类型列表
  33. */
  34. public function getTopicTypes()
  35. {
  36. $types = [
  37. ['label' => '单选题', 'value' => '单选题'],
  38. ['label' => '多选题', 'value' => '多选题'],
  39. ['label' => '判断题', 'value' => '判断题'],
  40. ['label' => '填空题', 'value' => '填空题'],
  41. ['label' => '简答题', 'value' => '简答题'],
  42. ['label' => '写作题', 'value' => '写作题'],
  43. ['label' => '应用题', 'value' => '应用题'],
  44. ['label' => '计算题', 'value' => '计算题'],
  45. ['label' => '证明题', 'value' => '证明题'],
  46. ['label' => '解答题', 'value' => '解答题'],
  47. ['label' => '论述题', 'value' => '论述题'],
  48. ];
  49. return response()->json([
  50. 'code' => 0,
  51. 'msg' => '获取成功',
  52. 'data' => $types
  53. ]);
  54. }
  55. }