import request from '@/utils/request'
import { PageType, StrAnyObj, StrAnyObjArr } from '@/typings'

export function getListApi(params: StrAnyObj): Promise<StrAnyObjArr> {
  return request.get('/sysRole/getList', params)
}

export function getPageApi(params: StrAnyObj): Promise<PageType<StrAnyObj>> {
  return request.get('/sysRole/getPage', params)
}

export function getDetailApi(params: StrAnyObj): Promise<StrAnyObj> {
  return request.get('/sysRole/getDetail', params)
}

export function addApi(data: StrAnyObj): Promise<void> {
  return request.post('/sysRole/add', data)
}

export function editApi(data: StrAnyObj): Promise<void> {
  return request.post('/sysRole/edit', data)
}

export function deleteApi(data: StrAnyObj): Promise<void> {
  return request.post('/sysRole/delete', data)
}

export function getMenuScopeApi(
  params: StrAnyObj
): Promise<{ menuTree: StrAnyObjArr; menuIdList: Array<string> }> {
  return request.get('/sysRole/getMenuScope', params)
}

export function editMenuScopeApi(data: StrAnyObj): Promise<void> {
  return request.post('/sysRole/editMenuScope', data)
}

export function getDataScopeApi(params: StrAnyObj): Promise<StrAnyObj> {
  return request.get('/sysRole/getDataScope', params)
}

export function editDataScopeApi(data: StrAnyObj): Promise<void> {
  return request.post('/sysRole/editDataScope', data)
}

export function authUserApi(data: StrAnyObj): Promise<void> {
  return request.post('/sysRole/authUser', data)
}

export function unAuthUserApi(data: StrAnyObj): Promise<void> {
  return request.post('/sysRole/unAuthUser', data)
}
