| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace App\Http\Controllers\Api\v1;
- use App\Http\Controllers\Api\webApp;
- use App\Services\Api\ArticleService;
- use App\Services\Api\ExamService;
- /**
- * 考试管理
- * @package App\Http\Controllers\Api
- */
- class ExamController extends webApp
- {
- /**
- * 答题记录
- * @return array
- */
- public function index()
- {
- $params = request()->post();
- $pageSize = request()->post('pageSize', 15);
- $datas = ExamService::make()->getDataList($params, $pageSize);
- return message(1010, true, $datas);
- }
- /**
- * 答题历史
- * @return array
- */
- public function history()
- {
- try {
- $params = request()->post();
- $pageSize = request()->post('pageSize', 15);
- $datas = ExamService::make()->getHistoryList($params, $pageSize);
- return message(1010, true, $datas);
- } catch (\Exception $exception) {
- return message(1009, false);
- }
- }
- /**
- * 详情
- */
- public function info()
- {
- $params = request()->all();
- $id = isset($params['id']) ? intval($params['id']) : 0;
- if (empty($id)) {
- return message(1036, false);
- }
- if ($info = ArticleService::make()->getInfo($id)) {
- return message(1010, true, $info);
- } else {
- return message(1009, false);
- }
- }
- /**
- * 排行榜
- */
- public function ranks()
- {
- $params = request()->all();
- $type = isset($params['type']) ? intval($params['type']) : 0;
- if (empty($type)) {
- return message(1031, false);
- }
- $datas = ExamService::make()->getRankByType($type);
- return message(1010, true, $datas);
- }
- }
|