import {
  get,
  post
} from '@/common/utils/http-util.ts'

export default {
  paging(data: RoleTypes.SearchForm, {size, current, orders}: G.PageParam) {
    return get<G.PageResult<RoleTypes.SysRole>>('/sys_role/paging', {
      size, current, orders,
      ...data
    })
  },
  list(pid: string | null = null) {
    return get<RoleTypes.SysRole[]>('/sys_role/list', {pid: pid})
  },
  detail(id: string) {
    return get<RoleTypes.SysRole>('/sys_role/detail', {id})
  },
  add(data: RoleTypes.SysRole) {
    return post('/sys_role/add', data)
  },
  modify(data: RoleTypes.SysRole) {
    return post('/sys_role/modify', data)
  },
  del(ids: string[]) {
    return post('/sys_role/del', ids)
  },
  listRes(keywords?: string, tableName: string = 'sys_menu',) {
    return get<RoleTypes.SysResource[]>('/sys_resource/list', {tableName, keywords})
  },
}
