import request from '../index'
const prefix = 'sys'

// 资源查询
export function getResourceList(params: object) {
  return request({
    url: `${prefix}/resource/list`,
    method: 'get',
    params,
  })
}
// 资源查询
export function getResourceListByRole(roleId: string) {
  return request({
    url: `${prefix}/resource/treeListByRoleId`,
    method: 'get',
    params: {
      roleId,
    },
  })
}
// 资源树列表
export function getResourceTreeList() {
  return request({
    url: `${prefix}/resource/tree`,
    method: 'get',
  })
}

// 资源类型列表
export function getResourceTypeList() {
  return request({
    url: `${prefix}/dict/code/resourceType`,
    method: 'get',
  })
}

// 添加资源
export function addResource(data: object) {
  return request({
    url: `${prefix}/resource/add`,
    method: 'post',
    data,
  })
}
// 修改资源
export function updateResource(data: object) {
  return request({
    url: `${prefix}/resource/update`,
    method: 'post',
    data,
  })
}
// 删除资源
export function delResource(id: string) {
  return request({
    url: `${prefix}/resource/delete`,
    method: 'post',
    data: {
      id,
    },
  })
}
