BaseDetailController.class.php 1.83 KB
<?php
/**
 * 【考试中心-后台】 获取试卷基本设置(编辑用)
 * BaseDetailController.class.php
 * User: daijun
 * Date: 2017-05-23
 */

namespace Apicp\Controller\Paper;

use Common\Service\PaperService;
use Common\Service\RightService;

class BaseDetailController extends AbstractController
{

    /** @var  PaperService 试卷信息表 */
    protected $paper_service;
    /** @var RightService 权限信息表 */
    protected $right_service;

    public function before_action($action = '')
    {

        if (!parent::before_action($action)) {
            return false;
        }
        // 实例化试卷信息表
        $this->paper_service = new PaperService();

        // 实例化权限信息表
        $this->right_service = new RightService();

        return true;
    }

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

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

            E('_EMPTY_PAPER_ID');
        }

        // 获取基本信息
        $result = $this->paper_service->get_paper_base_detail($ep_id);

        // 给权限字段赋值初始值
        $right_data = [
            'user_list' => [],
            'dp_list' => [],
            'role_list' => [],
            'job_list' => [],
            'tag_list'=> []
        ];

        // 如果不是全公司,
        if ($result['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]);

            $result['import_num'] = $import_num; // 导入人员数量
        }

        $result['right'] = $right_data;

        // 组装返回数据
        $this->_result = $result;

        return true;
    }

}