import axios from '@/libs/api.request'

/**
 * 分页查询方法
 * @param parmas
 * @returns {*|void|ClientRequest|ClientHttp2Stream|never|AxiosPromise<any>}
 */
export const getRbacUserPage = (parmas) => {
  return axios.request({
    url: '/api/v1/baseSenior/page',
    params: parmas,
    method: 'get',
  })
}

/**
 * 根据参数查询列表
 * @param parmas
 * @returns {*|void|ClientRequest|ClientHttp2Stream|never|AxiosPromise<any>}
 */
export const getRbacUserList = (parmas) => {
  return axios.request({
    url: 'api/v1/baseSenior/list',
    params: parmas,
    method: 'get',
  })
}

/**
 * 新增
 * @param params
 * @returns {Promise<any>}
 */
export const addRbacUser = (params) => {
  return new Promise((resolve, reject) => {
    axios
      .request({
        url: '/v1/baseSenior/add',
        method: 'POST',
        data: params,
      })
      .then((response) => {
        resolve(response.data)
      })
      .catch((err) => {
        reject(err)
      })
  })
}

/**
 * 修改
 * @param params
 * @returns {Promise<any>}
 */
export const editRbacUser = (params) => {
  return new Promise((resolve, reject) => {
    axios
      .request({
        url: '/v1/baseSenior/merge',
        method: 'POST',
        data: params,
      })
      .then((response) => {
        resolve(response.data)
      })
      .catch((err) => {
        reject(err)
      })
  })
}

/**
 * 删除
 * @param id
 * @returns {Promise<any>}
 */
export const deleteRbacUser = (id) => {
  return new Promise((resolve, reject) => {
    axios
      .request({
        url: '/v1/baseSenior/delete/' + id,
        method: 'POST',
      })
      .then((response) => {
        resolve(response.data)
      })
      .catch((err) => {
        reject(err)
      })
  })
}

/**
 * 关键字分页查询
 * @param parmas
 * @returns {*|void|ClientRequest|ClientHttp2Stream|never|AxiosPromise<any>}
 */
export const getRbacUserByKeyValue = (parmas) => {
  return axios.request({
    url: 'api/v1/baseSenior/keyValue',
    params: parmas,
    method: 'post',
  })
}
