GetController.class.php 1.47 KB
<?php
/**
 * 获取指定缓存
 * User: zhuxun37
 * Date: 2017/5/12
 * Time: 上午10:32
 */

namespace Apicp\Controller\Setting;


use Common\Common\Cache;
use Common\Common\User;

class GetController extends AbstractController
{

    // 管理权限查询key
    const MANAGE_AUTHS_KEY = "manageAuths";

    public function Index_post()
    {

        $key = (string)I('post.key');
        if (empty($key)) {
            E('_ERR_PARAM_IS_NULL');
            return false;
        }

        $settings = Cache::instance()->get('Common.AppSetting');
        if (empty($settings[$key])) {
            E('_ERR_PARAM_IS_NULL');
            return false;
        }

        // 是获取管理权限配置
        if (self::MANAGE_AUTHS_KEY == $key) {

            // 有管理权限的用户
            $manageAuths = $settings[$key]['value'];
            $hadSetting = !empty($manageAuths);

            // 有配置管理用户, 过滤掉不存在的管理用户
            if ($hadSetting) {
                list($existAuthIds, $existAuthInfoList) = $this->filterNonExistAuthTarget($manageAuths['selectedList']);
                $manageAuths['selectedList'] = $existAuthInfoList;
                $manageAuths['auths'] = $existAuthIds;
                $this->_result = $manageAuths;
            } else {
                $this->_result = [];
            }

        } else {

            $this->_result = empty($settings[$key]['value']) ? [] : $settings[$key]['value'];
        }

        return true;
    }

}