import { defHttp } from '/@/utils/http/axios';
import { setParams } from '/@/utils/index';
enum Api {
  sysRoleAdd = '/sys/role/add',
  sysRoleDetail = '/sys/role/detail',
  sysRoleEdit = '/sys/role/edit',
  sysRoleExport = '/sys/role/export',
  sysRoleQueryPage = '/sys/role/query/page',
  sysRoleAssign = '/sys/role/assign',
  sysRoleRemove = '/sys/role/deleteByIds',
  sysRoleMenuTree = '/sys/role/menu/list',
}

/**
 * @description: 新增角色信息,权限 - sys:role:add
 * @method: POST
 */
export const sysRoleAdd = (params?: object) => {
  return defHttp.post({ url: Api.sysRoleAdd, params: params });
};
/**
 * @description: 获取角色信息详细信息,权限 - sys:role:query
 * @method: POST
 */
export const sysRoleDetail = (params?: object) => {
  return defHttp.post({ url: Api.sysRoleDetail, params: params });
};
/**
 * @description: 通过主键id修改角色信息,权限 - sys:role:edit
 * @method: POST
 */
export const sysRoleEdit = (params?: object) => {
  return defHttp.post({ url: Api.sysRoleEdit, params: params });
};
/**
 * @description: 菜单导出
 * @method: POST
 */
export const sysRoleExport = (params?: object) => {
  return defHttp.post({ url: Api.sysRoleExport, params: params });
};
/**
 * @description: 查询角色信息列表,权限 - sys:role:query
 * @method: POST
 */
export const sysRoleQueryPage = (params?: object) => {
  return defHttp.post({ url: Api.sysRoleQueryPage, params: setParams(params) });
};
/**
 * @description: 分配角色权限,权限 - sys:role:assign
 * @method: POST
 */
export const sysRoleAssign = (params?: object) => {
  return defHttp.post({ url: Api.sysRoleAssign, params: params });
};

/**
 * @description: 分配角色权限,权限 - sys:role:assign
 * @method: GET
 */
export const sysRoleQueryMenuTree = (roleId: string) => {
  return defHttp.get({ url: Api.sysRoleMenuTree + '/' + roleId });
};
/**
 * @description: 删除增角色信息,权限 - sys:role:remove
 * @method: POST
 */
export const sysRoleRemove = (params?: object) => {
  return defHttp.post({ url: Api.sysRoleRemove, params: params });
};
