DetailController.class.php
3.07 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/**
* 【考试中心-后台】 获取试卷基本信息(详情用)
* DetailController.class.php
* User: daijun
* Date: 2017-05-23
*/
namespace Apicp\Controller\Paper;
use Common\Service\AnswerService;
use Common\Service\PaperService;
use Common\Service\RightService;
class DetailController extends AbstractController
{
public function __construct() {
parent::__construct();
// 无需登录
$this->_require_login = false;
}
/** @var PaperService 试卷信息表 */
protected $paper_service;
/** @var RightService 权限信息表 */
protected $right_service;
/** @var AnswerService 用户答题记录表 */
protected $answer_service;
public function before_action($action = '')
{
if (!parent::before_action($action)) {
return false;
}
// 实例化试卷信息表
$this->paper_service = new PaperService();
// 实例化权限信息表
$this->right_service = new RightService();
// 实例化用户答题信息表
$this->answer_service = new AnswerService();
return true;
}
public function Index_post()
{
$ep_id = I('post.ep_id', 0, 'intval');
// 验证参数
if (empty($ep_id)) {
E('_EMPTY_PAPER_ID');
}
// 获取基本信息
$data = $this->paper_service->get_paper_detail_admin($ep_id);
// 给权限字段赋值初始值
$right_data = [
'user_list' => [],
'dp_list' => [],
'job_list' => [],
'role_list' => [],
'tag_list' => []
];
// 用来查询应参与人列表数据
$arr = [];
$arr['is_all'] = PaperService::AUTH_ALL;
//如果不是全公司,
if ($data['is_all'] == PaperService::AUTH_NOT_ALL) {
//此处查询权限数据
list($right_list, $right_data, $import_num) = $this->right_service->get_right_data([
'epc_id' => $ep_id,
'er_type' => RightService::RIGHT_PAPER
]);
$data['import_num'] = $import_num; // 导入人员总数
$arr['is_all'] = PaperService::AUTH_NOT_ALL;
$arr['uids'] = array_filter(array_column($right_list, 'uid'));
$arr['dp_ids'] = array_filter(array_column($right_list, 'cd_id'));
$arr['role_ids'] = array_filter(array_column($right_list, 'role_id'));
$arr['job_ids'] = array_filter(array_column($right_list, 'job_id'));
$arr['tag_ids'] = array_filter(array_column($right_list, 'tag_id'));
}
$data['right'] = $right_data;
// 获取已参与与未参与人数
$join_data = $this->answer_service->get_unjoin_data([
'epc_id' => $ep_id,
'er_type' => AnswerService::RIGHT_PAPER
], $ep_id, $data['is_all']);
$data['join_num'] = count($join_data['join_list']);
$data['no_join_num'] = count($join_data['unjoin_list']);;
// 返回数据
$this->_result = $data;
return true;
}
}