import http from '@/api'

/**
 * @name 查询角色信息列表
 * @param query 参数
 * @returns 返回列表
 */
export const listRoleApi = (query: any) => {
  return http.get<any>('/system/role/list', query, { loading: true })
}

/**
 * @name 根据角色ID查询部门树结构
 * @param roleId 角色Id
 * @returns 返回列表
 */
export const deptTreeSelectApi = (roleId: any) => {
  return http.get<any>(`/system/role/deptTree/${roleId}`)
}

/**
 * @name 根据角色ID查询菜单下拉树结构
 * @param roleId 角色Id
 * @returns 返回列表
 */
export const roleMenuTreeSelectApi = (roleId: any) => {
  return http.get<any>(`/system/menu/roleMenuTreeselect/${roleId}`)
}

/**
 * @name 查询角色信息详细
 * @param roleId roleId
 * @returns returns
 */
export const getRoleApi = (roleId: any) => {
  return http.get<any>(`/system/role/${roleId}`)
}

/**
 * @name 新增角色信息
 * @param data data
 * @returns returns
 */
export const addRoleApi = (data: any) => {
  return http.post<any>('/system/role', data, { loading: false })
}

/**
 * @name 修改角色信息
 * @param data data
 * @returns returns
 */
export const updateRoleApi = (data: any) => {
  return http.put<any>('/system/role', data, { loading: false })
}

/**
 * @name 角色数据权限
 * @param data data
 * @returns returns
 */
export const dataScopeApi = (data: any) => {
  return http.put<any>('/system/role/dataScope', data, { loading: false })
}

/**
 * @name 修改角色状态
 * @param data data
 * @returns returns
 */
export const changeStatusApi = (data: any) => {
  return http.put<any>('/system/role/changeStatus', data, { loading: false })
}

/**
 * @name 删除角色信息
 * @param roleId roleId
 * @returns returns
 */
export const delRoleApi = (roleId: any) => {
  return http.delete<any>(`/system/role/${roleId}`)
}

/**
 * @name 下载模板
 * @returns returns
 */
export const importTemplateApi = () => {
  return http.downloadPost('/system/role/importTemplate', {})
}

/**
 * @name 导入数据
 * @returns returns
 */
export const importDataApi = (data: any) => {
  return http.post('/system/role/importData', data)
}

/**
 * @name 导出数据
 * @returns returns
 */
export const exportApi = (data: any) => {
  return http.downloadPost('/system/role/export', data)
}

/**
 * @name 查询角色已授权用户列表
 * @param query 参数
 * @returns 返回列表
 */
export const allocatedUserListApi = (query: any) => {
  return http.get<any>(`/system/role/authUser/allocatedList`, query, { loading: true })
}

/**
 * @name 查询角色未授权用户列表
 * @param query 参数
 * @returns 返回列表
 */
export const unallocatedUserListApi = (query: any) => {
  return http.get<any>(`/system/role/authUser/unallocatedList`, query, { loading: true })
}

/**
 * @name 取消用户授权角色
 * @param data data
 * @returns returns
 */
export const authUserCancelApi = (data: any) => {
  return http.put<any>('/system/role/authUser/cancel', data, { loading: false })
}

/**
 * @name 批量取消用户授权角色
 * @param data data
 * @returns returns
 */
export const authUserCancelAllApi = (data: any) => {
  return http.put<any>('/system/role/authUser/cancelAll', data, { loading: false })
}

/**
 * @name 授权用户选择
 * @param data data
 * @returns returns
 */
export const authUserSelectAllApi = (data: any) => {
  return http.put<any>('/system/role/authUser/selectAll', data, { loading: false })
}
