import request from '@/utils/request';

export function getList(data) {
  let pram = '?page=' + data.page + '&size=' + data.size;
  if (data.name) {
    pram += '&name=' + data.name;
  }
  return request({
    url: '/sysRole/select' + pram,
    method: 'get',
    data,
  });
}

export function doEdit(data) {
  return request({
    url: '/sysRole/update',
    method: 'post',
    data,
  });
}

export function doDelete(data) {
  return request({
    url: '/sysRole/remove',
    method: 'post',
    data,
  });
}

export function doAdd(data) {
  return request({
    url: '/sysRole/insert',
    method: 'post',
    data,
  });
}

export function getMenuIdsByRoleId(data) {
  return request({
    url: '/sysRole/getMenuIdsByRoleId?roleId=' + data.roleId,
    method: 'get',
    data,
  });
}

export function assignMenu(data) {
  return request({
    url: '/sysRole/assignMenu',
    method: 'post',
    data,
  });
}

//分页查询小程序角色
export function miniRoleSelect(data) {
  let pram = '?page=' + data.page + '&size=' + data.size;
  if (data.name != undefined) {
    pram += '&name=' + data.name;
  }
  return request({
    url: '/miniRole/select' + pram,
    method: 'get',
    data,
  });
}

//添加小程序角色
export function miniRoleInsert(data) {
  return request({
    url: '/miniRole/insert',
    method: 'post',
    data,
  });
}

//修改小程序角色
export function miniRoleUpdate(data) {
  return request({
    url: '/miniRole/update',
    method: 'post',
    data,
  });
}

//删除小程序角色
export function miniRoleRemove(data) {
  return request({
    url: '/miniRole/remove?roleId=' + data.roleId,
    method: 'post',
    data,
  });
}

//授权小程序角色
export function miniRoleAssignMenu(data) {
  return request({
    url: '/miniRole/assignMenu',
    method: 'post',
    data,
  });
}

//获取角色菜单ids
export function getMiniRoleMenuIdsByRoleId(data) {
  return request({
    url: '/miniRole/getMenuIdsByRoleId?roleId=' + data.roleId,
    method: 'get',
    data,
  });
}
