SelectListController.class.php 1.08 KB
<?php
/**
 * 【考试中心-后台】 获取试卷已选择题目列表接口
 * SelectListController.class.php
 * User: daijun
 * Date: 2017-05-23
 */

namespace Apicp\Controller\Paper;

use Common\Service\SnapshotService;

class SelectListController extends AbstractController
{
    /** @var  SnapshotService 试卷试题快照信息表 */
    protected $snapshot_service;

    public function before_action($action = '')
    {

        if (!parent::before_action($action)) {
            return false;
        }

        // 实例化试卷试题快照信息表
        $this->snapshot_service = new SnapshotService();

        return true;
    }

    public function Index_post()
    {
        $ep_id = I('post.ep_id', 0, 'intval');

        // 验证参数
        if (empty($ep_id)) {

            E('_EMPTY_PAPER_ID');
        }

        // 获取已选题列表
        $list = $this->snapshot_service->get_snapshot_list($ep_id);

        // 组装返回数据
        $this->_result = [
            'total' => count($list),
            'list' => $list
        ];

        return true;
    }
}