import http from '@/utils/http'
import { AppDispatch } from '..'
/**
 * 角色管理 -获取分页列表
 */
export const Z5_APIgetList = (data: any): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post('sys/role/listCountPage', data)
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total
      }

      dispatch({ type: 'Z5/getList', payload: obj })
    }
  }
}

/**
 * 角色管理 -删除
 */
export const Z5_APIdel = (id: number) => {
  return http.get(`sys/role/remove/${id}`)
}

/**
 * 角色管理 -新增--获取权限列表
 */
export const Z5_APIgetAddTreeList = () => {
  return http.get('sys/resource/getTreeResource')
}

/**
 * 角色管理 -新增/编辑
 */
export const Z5_APIsave = (data: any) => {
  return http.post('sys/role/save', data)
}

/**
 * 角色管理 -获取详情
 */
export const Z5_APIgetInfo = (id: number) => {
  return http.get(`sys/role/detail/${id}`)
}
