import request from '/@/utils/request'

/** 查询角色列表 */
export function getList(params?: any) {
  return request({
    url: '/system/role/list',
    method: 'get',
    params,
  })
}

/** 新增角色 */
export const doAdd = (data: any) => {
  return request({
    url: '/system/role',
    method: 'post',
    data,
  })
}

/** 编辑角色 */
export const doEdit = (data: any) => {
  return request({
    url: '/system/role',
    method: 'put',
    data,
  })
}

/** 删除角色 */
export const doDelete = (roleId: any) => {
  return request({
    url: `/system/role/${roleId}`,
    method: 'delete',
  })
}

// 查询角色详细
export function getRole(roleId: any) {
  return request({
    url: `/system/role/${roleId}`,
    method: 'get',
  })
}

// 角色状态修改
export function changeRoleStatus(roleId: any, status: any) {
  const data = {
    roleId,
    status,
  }
  return request({
    url: '/system/role/changeStatus',
    method: 'put',
    data,
  })
}

// 根据角色ID查询部门树结构
export function deptTreeSelect(roleId: any) {
  return request({
    url: `/system/role/deptTree/${roleId}`,
    method: 'get',
  })
}

// 角色数据权限
export function dataScope(data: any) {
  return request({
    url: '/system/role/dataScope',
    method: 'put',
    data,
  })
}
