<?php
namespace backend\controllers;

use Yii;
use backend\models\Permission;

class PermissionController extends BaseController
{
    /**
     * 获取权限
     */
    public function actionGetPermission()
    {
        $member_id = (int) Yii::$app->request->post('member_id');
        $model = new Permission();
        $result = $model->getPermission($member_id);
        if ($result['code']) {
            return $this->outJson(1, $result['data']);
        } else {
            return $this->outJson(0, [], $result['message']);
        }
    }

    /**
     * 跟新权限
     */
    public function actionUpdatePermission()
    {
        $member_id = (int) Yii::$app->request->post('member_id');
        $url = Yii::$app->request->post('url');
        $model = new Permission();
        $result = $model->updatePermission($member_id, $url);
        if ($result['code']) {
            return $this->outJson(1, $result['data']);
        } else {
            return $this->outJson(0, [], $result['message']);
        }
    }
    
}