ExamListController.class.php 1.5 KB
<?php
/**
 * 【后台】获取考试列表接口
 * ExamListController.class.php
 * User: daijun
 * Date: 2017/8/31
 */

namespace Apicp\Controller\Education;

use Common\Service\PlanService;

class ExamListController extends \Apicp\Controller\AbstractController
{

    public function Index_post()
    {
        $params = I('post.');

        // 默认值
        $page = !empty($params['page']) ? intval($params['page']) : self::PAGE_DEFAULT;
        $limit = !empty($params['limit']) ? intval($params['limit']) : self::PAGE_LIMIT_DEFAULT;
        $keyword = empty($params['search_key']) ? '' : trim($params['search_key']);
        $class_id = empty($params['class_id']) ? 0 : intval($params['class_id']);

        $plan_s = new PlanService();
        // 获取已经使用的应用数据id集合
        $plan_obj_ids = $plan_s->get_obj_ids(PlanService::PLAN_TYPE_EXAM);
        $obj_ids = [];
        if (!empty($plan_obj_ids)) {

            $obj_ids = array_unique(array_filter(array_column($plan_obj_ids, 'plan_obj_id')));
            sort($obj_ids);
        }

        // 请求地址
        $url = rpcUrl('/Exam/Rpc/Train/List');
        // 请求参数
        $data_send = [
            'page' => $page,
            'limit' => $limit,
            'keyword' => $keyword,
            'class_id' => $class_id,
            'ids' => $obj_ids
        ];
        // 发送请求,获取结果
        $res_data = \Com\Rpc::phprpc($url)->invoke('Index', $data_send);

        $this->_result = $res_data;

        return true;
    }
}