import request from '@/utils/request'
import qs from 'qs'

/**
 * 权限接口
 */

// 获取权限树形列表
const getTreeList = function() {
    return request({
        url: '/permission/findPermissionList.do',
        method: 'post'
    })
}
// 添加权限
const addPermission = function(params) {
    return request({
        url: '/permission/addPermission.do',
        method: 'get',
        params
    })
}
// 更新权限
const updatePermission = function(params) {
    return request({
        url: '/permission/updatePermission.do',
        method: 'get',
        params
    })
}
// 删除权限
const delPermission = function(params) {
    return request({
        url: '/permission/deletePermission.do',
        method: 'get',
        params
    })
}

/**
 * 角色接口
 */

// 获取角色列表
const getRoleList = function(params) {
    return request({
        url: '/role/findPageList.do',
        method: 'post',
        data: qs.stringify(params)
    })
}
// 添加角色
const addRole = function(params) {
    return request({
        url: '/role/add.do',
        method: 'get',
        params
    })
}
// 更新角色
const updateRole = function(params) {
    return request({
        url: '/role/update.do',
        method: 'get',
        params
    })
}
// 删除角色
const delRole = function(params) {
    return request({
        url: '/role/delete.do',
        method: 'get',
        params
    })
}

export default {
    getTreeList,
    addPermission,
    updatePermission,
    delPermission,

    getRoleList,
    addRole,
    updateRole,
    delRole
}

