import request from '../request.js';

/** 接口管理 */
const Api = {
    page: '/api/sys/role/page',
    list: '/api/sys/role/list',
    save: '/api/sys/role/save',
    edit: '/api/sys/role/edit',
    give: '/api/sys/role/give',
    remove: '/api/sys/role/remove',
    removeBatch: '/api/sys/role/removeBatch',
    power: '/api/sys/role/power',
    dept: '/api/sys/role/dept',
    change: '/api/sys/role/edit',
}

/** 角色列表 (分页) */
export const page = data => {
    return request.request({
        url: Api.page,
        params: data,
        method: 'GET'
    })
}

/** 角色列表 */
export const list = data => {
    return request.request({
        url: Api.list,
        params: data,
        method: 'GET'
    })
}

/** 新增角色 */
export const save = data => {
    return request.request({
        url: Api.save,
        data: data,
        method: 'POST'
    })
}

/** 修改角色 */
export const edit = data => {
    return request.request({
        url: Api.edit,
        data: data,
        method: 'PUT'
    })
}

/** 删除角色 */
export const remove = data => {
    return request.request({
        url: Api.remove,
        params: data,
        method: 'DELETE'
    })
}

/** 批量删除 */
export const removeBatch = data => {
    return request.request({
        url: Api.removeBatch,
        params: data,
        method: 'DELETE'
    })
}

/** 角色权限 */
export const power = data => {
    return request.request({
        url: Api.power,
        params: data,
        method: 'GET'
    })
}

/** 分配权限 */
export const give = data => {
    return request.request({
        url: Api.give,
        data: data,
        method: 'POST'
    })
}

/** 角色部门 */
export const dept = data => {
    return request.request({
        url: Api.dept,
        params: data,
        method: 'GET'
    })
}

/** 改变角色状态 */
export const change = data => {
    return request.request({
        url: Api.change,
        data: data,
        method: 'PUT'
    })
}