<?php
/**
 * Created by PhpStorm.
 * User: chenkuan
 * Date: 2017/12/21
 * Time: 上午10:17
 */

namespace frontend\controllers;


use frontend\models\AdminRole;
use frontend\models\Role;

class AdminRoleController extends BaseController
{
    /**
     * 通过登录的管理员ID获取管理员权限列表
     */
    public function actionGetGrantByUserId()
    {
        $id = \Yii::$app->getRequest()->get('id', '');
        $adminRole = AdminRole::findOne(['admin_set_id' => $id]);
        if ($adminRole) {
            $role = Role::findOne(['id' => $adminRole->role_set_id]);
            if (!empty($role->authority_list_store)) {
                return $this->outJson(1, json_decode($role->authority_list_store, true));
            } else {
                return $this->outJson(0, [], '暂无权限');
            }
        } else {
            return $this->outJson(0, [], '获取用户权限错误!');
        }
    }
}
