ExamListController.class.php
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?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;
}
}