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

namespace frontend\models;


class RoleApi extends BaseApi
{
    public $apiUrl = 'role';

    public function getRoleList($data = [])
    {
        $result = $this->get($this->apiUrl.'/get-role-list', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data']);
        } else {
            return $this->returnArray(0, [], '获取列表失败');
        }
    }

    public function saveRole($data = [])
    {
        $result = $this->post($this->apiUrl.'/save-role', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data']);
        } else {
            return $this->returnArray(0, [], $result['message']);
        }
    }

    public function getRoleDetail($data = [])
    {
        $result = $this->get($this->apiUrl.'/get-role-detail', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data']);
        } else {
            return $this->returnArray(0, [], '获取列表失败');
        }
    }

    public function deleteRole($data = [])
    {
        $result = $this->post($this->apiUrl.'/delete-role', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data']);
        } else {
            return $this->returnArray(0, [], $result['message']);
        }
    }
}
