import request from '@/utils/request'

// 查询菜单列表
export const listMenu = (data) => {
  return request({
    url: '/api/v1/permission/permissions/tree',
    method: 'get',
    params: data
  });
};

// 查询菜单下拉树结构
export const treeselect = () => {
  return request({
    url: '/system/menu/treeselect',
    method: 'get'
  });
};

// 根据角色ID查询菜单下拉树结构
export const roleMenuTreeselect = (roleId) => {
  return request({
    url: '/system/menu/roleMenuTreeselect/' + roleId,
    method: 'get'
  });
};

// 新增菜单
export const addMenu = (data) => {
  return request({
    url: '/api/v1/permission/permissions',
    method: 'post',
    data: data
  });
};

// 修改菜单
export const updateMenu = (data) => {
  return request({
    url: '/api/v1/permission/permissions/' + data.uid,
    method: 'put',
    data: data
  });
};

// 删除菜单
export const delMenu = (menuId) => {
  return request({
    url: '/api/v1/permission/permissions/' + menuId,
    method: 'delete'
  });
};

//分配权限增量
export const dataScope = (data) => {
  return request({
    url: '/api/v1/permission/roles/' + data.roleId + '/permissions/add',
    method: 'post',
    data: data
  });
};

//获取当前角色存在的权限菜单
export const getRolePermissions = (roleId) => {
  return request({
    url: '/api/v1/permission/roles/' + roleId + '/all-permissions',
    method: 'get'
  });
};

