import request from '@/config/axios'

export interface RoleVO {
  id: number
  name: string
  code: string
  sort: number
  status: number
  type: number
  dataScope: number
  dataScopeDeptIds: number[]
  createTime: Date
}

export interface UpdateStatusReqVO {
  id: number
  status: number
}

// 查询角色列表
export const getRolePage = async (params: PageParam) => {
  return await request.get({ url: '/admin-api/system/role/page', params })
}

// 查询角色（精简)列表
export const getSimpleRoleList = async () => {
  return await request.get({ url: '/admin-api/system/role/list-all-simple' })
}

// 查询角色详情
export const getRole = async (id: number) => {
  return await request.get({ url: '/admin-api/system/role/get?id=' + id })
}

// 新增角色
export const createRole = async (data: RoleVO) => {
  return await request.post({ url: '/admin-api/system/role/create', data })
}

// 修改角色
export const updateRole = async (data: RoleVO) => {
  return await request.put({ url: '/admin-api/system/role/update', data })
}

// 删除角色
export const deleteRole = async (id: number) => {
  return await request.delete({ url: '/admin-api/system/role/delete?id=' + id })
}

// 角色用户
export const getRoleUsers = async (params) => {
  return await request.get({ url: '/admin-api/system/role/getUserByRole', params })
}
